diff options
author | Tobias Weingartner <weingart@cvs.openbsd.org> | 1997-10-23 15:13:31 +0000 |
---|---|---|
committer | Tobias Weingartner <weingart@cvs.openbsd.org> | 1997-10-23 15:13:31 +0000 |
commit | f38cadc3de4222e909586f97b256ec25685f8fad (patch) | |
tree | e9b2ec92e49c3ab6a5981b746add1fbe539191df /sys | |
parent | 0d9bd07968d409a80abe35559697b1985274468c (diff) |
Better BIOS diskprobe. Cleanup and re-org by mickey.
Fix bug in BIOS memprobe. Cleanup and re-org by mickey.
Do checksum of HD devices.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.c | 7 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/diskprobe.c | 103 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 22 |
4 files changed, 87 insertions, 54 deletions
diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index 24b91a8f119..cb97b38ca7c 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.39 1997/10/22 23:34:36 mickey Exp $ */ +/* $OpenBSD: biosdev.c,v 1.40 1997/10/23 15:13:26 weingart Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -80,8 +80,11 @@ bios_getinfo(dev, pdi) "=b" (pdi->bios_sectors) : "0" (0x0800), "1" (dev) : "cc"); + /* Fix up info */ pdi->bios_number = dev; - pdi->bios_heads++; /* make it number of heads */ + pdi->bios_heads++; + pdi->bios_cylinders &= 0x3ff; + pdi->bios_cylinders++; if (rv & 0xff) return (rv & 0xff) >> 8; diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 823ab7a858c..30e10bc23f9 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.15 1997/10/22 23:34:37 mickey Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.16 1997/10/23 15:13:27 weingart Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff, Tobias Weingartner @@ -61,17 +61,18 @@ Xdiskinfo() { int i; - printf("Disk\tBIOS#\t BSD#\tCylinders\tHeads\tSectors\n"); + printf("Disk\tBIOS#\t BSD#\tCylinders\tHeads\tSectors\tChecksum\n"); for(i = 0; bios_diskinfo[i].bios_number != -1 && i < 10; i++){ int d = bios_diskinfo[i].bios_number; - printf("%cd%d\t 0x%x\t0x%x\t %s%d \t%d\t%d\n", + printf("%cd%d\t 0x%x\t0x%x\t %s%d \t%d\t%d\t0x%x[%d]\n", (d & 0x80)?'h':'f', (d & 0x80)?d - 128:d, d, bios_diskinfo[i].bsd_dev, (bios_diskinfo[i].bios_cylinders < 100)?" ":" ", bios_diskinfo[i].bios_cylinders, bios_diskinfo[i].bios_heads, - bios_diskinfo[i].bios_sectors); + bios_diskinfo[i].bios_sectors, + bios_diskinfo[i].checksum, bios_diskinfo[i].checklen); } return 0; diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c index 66d7f6fd83d..16e8ee6b029 100644 --- a/sys/arch/i386/stand/libsa/diskprobe.c +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.3 1997/10/22 23:34:38 mickey Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.4 1997/10/23 15:13:29 weingart Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -37,37 +37,16 @@ #include <sys/disklabel.h> #include <stand/boot/bootarg.h> #include <machine/biosvar.h> +#include <lib/libz/zlib.h> #include "biosdev.h" #include "libsa.h" -/* These get passed to kernel */ -bios_diskinfo_t bios_diskinfo[16]; -#if notyet -/* Checksum given buffer */ -static u_int32_t -bufsum(buf, len) - void *buf; - int len; -{ - u_int32_t sum = 0; - u_int8_t *p = buf; - - while(len--){ - sum += p[len]; - } - return(sum); -} +/* Local Prototypes */ +static void disksum __P((bios_diskinfo_t*)); -/* Checksum given drive until different */ -void -disksum(pos) - int pos; -{ - u_int32_t sum; - int len, i; -} -#endif +/* These get passed to kernel */ +bios_diskinfo_t bios_diskinfo[16]; /* Probe for all BIOS disks */ void @@ -83,16 +62,13 @@ diskprobe() for(drive = 0; drive < 4; drive++) { rv = bios_getinfo(drive, &bios_diskinfo[i]); - if( (rv & 0x00FF)) continue; - if(!(rv & 0xFF00)) continue; + if( (rv & 0x00FF)) break; + if(!(rv & 0xFF00)) break; printf(" fd%u", drive); /* Fill out best we can - (fd?) */ bios_diskinfo[i].bsd_dev = MAKEBOOTDEV(2, 0, 0, drive, 0); -#if 0 - disksum(&bios_diskinfo[i]); -#endif i++; } @@ -120,9 +96,7 @@ diskprobe() /* Fill out best we can */ bios_diskinfo[i].bsd_dev = MAKEBOOTDEV(type, 0, 0, unit, 0); -#if 0 disksum(&bios_diskinfo[i]); -#endif i++; } @@ -147,3 +121,64 @@ bios_dklookup(dev) return(NULL); } + +/* Find given sum in diskinfo array */ +static bios_diskinfo_t * +find_sum(sum) + u_int32_t sum; +{ + int i; + + for(i = 0; bios_diskinfo[i].bios_number != -1; i++) + if(bios_diskinfo[i].checksum == sum) + return(&bios_diskinfo[i]); + + return(NULL); +} + +/* Checksum given drive until different + * + * Use the adler32() function from libz, + * as it is quick, small, and available. + */ +static void +disksum(bdi) + bios_diskinfo_t *bdi; +{ + u_int32_t sum; + int len, st; + int hpc, spt, dev; + char *buf; + + buf = alloca(DEV_BSIZE); + dev = bdi->bios_number; + hpc = bdi->bios_heads; + spt = bdi->bios_sectors; + + /* Adler32 checksum */ + sum = adler32(0, NULL, 0); + for(len = 0; len < 32; len++){ + int cyl, head, sect; + bios_diskinfo_t *bd; + + btochs(len, cyl, head, sect, hpc, spt); + + st = biosd_io(F_READ, dev, cyl, head, sect, 1, buf); + if(st) break; + + sum = adler32(sum, buf, DEV_BSIZE); + + /* Do a minimum of 8 sectors (floppy is slow...) */ + if((len >= 8) && ((bd = find_sum(sum)) == NULL)) + break; + } + + if(st) { + bdi->checksum = 0; + bdi->checklen = 0; + } else { + bdi->checksum = sum; + bdi->checklen = len; + } +} + diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index 3632484ecf8..6ae13844fd1 100644 --- a/sys/arch/i386/stand/libsa/memprobe.c +++ b/sys/arch/i386/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.23 1997/10/22 23:34:40 mickey Exp $ */ +/* $OpenBSD: memprobe.c,v 1.24 1997/10/23 15:13:30 weingart Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner, Michael Shalayeff @@ -256,7 +256,6 @@ memprobe() { static bios_memmap_t bm[32]; /* This is easier */ bios_memmap_t *pm = bm, *im; - int total = 0; #ifdef DEBUG printf("Probing memory: "); #endif @@ -281,22 +280,17 @@ memprobe() memory_map = bm; /* XXX for 'machine mem' command only */ printf("mem0:"); - /* Get total free memory */ + /* XXX - Compatibility, remove later */ + extmem = cnvmem = 0; for(im = bm; im->type != BIOS_MAP_END; im++) { if (im->type == BIOS_MAP_FREE) { - total += im->size; printf(" %luK", (u_long)im->size); + + if(im->addr < 0x100000) + cnvmem += im->size; + else + extmem += im->size; } } printf("\n"); - - /* XXX - Compatibility, remove later */ - for(im = bm; im->type != BIOS_MAP_END; im++) - if ((im->addr & 0xFFFFF) == im->addr && - im->type == BIOS_MAP_FREE) { - cnvmem = im->size; - break; /* Take the first region */ - } - - extmem = total - cnvmem; } |