diff options
-rw-r--r-- | sys/arch/amd64/amd64/dkcsum.c | 59 | ||||
-rw-r--r-- | sys/arch/i386/i386/dkcsum.c | 59 |
2 files changed, 52 insertions, 66 deletions
diff --git a/sys/arch/amd64/amd64/dkcsum.c b/sys/arch/amd64/amd64/dkcsum.c index b0c6dadf8ab..f5ded444a18 100644 --- a/sys/arch/amd64/amd64/dkcsum.c +++ b/sys/arch/amd64/amd64/dkcsum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkcsum.c,v 1.7 2005/07/26 00:56:25 krw Exp $ */ +/* $OpenBSD: dkcsum.c,v 1.8 2005/08/01 16:46:55 krw Exp $ */ /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. @@ -59,7 +59,7 @@ dkcsumattach(void) struct buf *bp; struct bdevsw *bdsw; dev_t dev, pribootdev, altbootdev; - int error; + int error, picked; u_int32_t csum; bios_diskinfo_t *bdi, *hit; @@ -68,7 +68,11 @@ dkcsumattach(void) return; #ifdef DEBUG - printf("dkcsum: bootdev=0x%x\n", bootdev); + printf("dkcsum: bootdev=%#x\n", bootdev); + for (bdi = bios_diskinfo; bdi->bios_number != -1; bdi++) + if (bdi->bios_number & 0x80) + printf("dkcsum: BIOS drive %#x checksum is %#x\n", + bdi->bios_number, bdi->checksum); #endif pribootdev = altbootdev = 0; @@ -95,7 +99,7 @@ dkcsumattach(void) if (error) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: open of %s failed (%d)\n", + printf("dkcsum: %s open failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -110,13 +114,13 @@ dkcsumattach(void) if ((error = biowait(bp))) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: read of %s failed (%d)\n", + printf("dkcsum: %s read failed (%d)\n", dv->dv_xname, error); #endif error = (*bdsw->d_close)(dev, 0, S_IFCHR, curproc); #ifdef DEBUG if (error) - printf("dkcsum: close of %s failed (%d)\n", + printf("dkcsum: %s close failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -125,7 +129,7 @@ dkcsumattach(void) if (error) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: close of %s failed (%d)\n", + printf("dkcsum: %s closed failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -133,7 +137,7 @@ dkcsumattach(void) csum = adler32(0, bp->b_data, bios_cksumlen * DEV_BSIZE); #ifdef DEBUG - printf("dkcsum: checksum of %s is %x\n", dv->dv_xname, csum); + printf("dkcsum: %s checksum is %#x\n", dv->dv_xname, csum); #endif /* Find the BIOS device */ @@ -142,36 +146,25 @@ dkcsumattach(void) /* Skip non-harddrives */ if (!(bdi->bios_number & 0x80)) continue; -#ifdef DEBUG - printf("dkcsum: " - "attempting to match with BIOS drive %x csum %x\n", - bdi->bios_number, bdi->checksum); -#endif - if (bdi->checksum == csum) { - if (!hit && !(bdi->flags & BDI_PICKED)) - hit = bdi; - else { - /* XXX add other heuristics here. */ - printf("dkcsum: warning: " - "dup BSD->BIOS disk mapping\n"); - } - } + if (bdi->checksum != csum) + continue; + picked = hit || (bdi->flags & BDI_PICKED); + if (!picked) + hit = bdi; + printf("dkcsum: %s matches BIOS drive %#x%s\n", + dv->dv_xname, bdi->bios_number, + (picked ? " IGNORED" : "")); } /* * If we have no hit, that's OK, we can see a lot more devices * than the BIOS can, so this case is pretty normal. */ - if (hit) { -#ifdef DIAGNOSTIC - printf("dkcsum: %s matched BIOS disk %x\n", - dv->dv_xname, hit->bios_number); -#endif - } else { -#ifdef DIAGNOSTIC - printf("dkcsum: %s had no matching BIOS disk\n", + if (!hit) { +#ifdef DEBUG + printf("dkcsum: %s has no matching BIOS drive\n", dv->dv_xname); -#endif +#endif continue; } @@ -195,7 +188,7 @@ dkcsumattach(void) pribootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part); #ifdef DEBUG - printf("dkcsum: setting %s as primary boot disk\n", + printf("dkcsum: %s is primary boot disk\n", dv->dv_xname); #endif } @@ -211,7 +204,7 @@ dkcsumattach(void) altbootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part); #ifdef DEBUG - printf("dkcsum: setting %s as alternate boot disk\n", + printf("dkcsum: %s is alternate boot disk\n", dv->dv_xname); #endif } diff --git a/sys/arch/i386/i386/dkcsum.c b/sys/arch/i386/i386/dkcsum.c index 4b703685f3a..850caedf9a1 100644 --- a/sys/arch/i386/i386/dkcsum.c +++ b/sys/arch/i386/i386/dkcsum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkcsum.c,v 1.18 2005/07/26 00:56:25 krw Exp $ */ +/* $OpenBSD: dkcsum.c,v 1.19 2005/08/01 16:46:55 krw Exp $ */ /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. @@ -59,7 +59,7 @@ dkcsumattach(void) struct buf *bp; struct bdevsw *bdsw; dev_t dev, pribootdev, altbootdev; - int error; + int error, picked; u_int32_t csum; bios_diskinfo_t *bdi, *hit; @@ -68,7 +68,11 @@ dkcsumattach(void) return; #ifdef DEBUG - printf("dkcsum: bootdev=0x%x\n", bootdev); + printf("dkcsum: bootdev=%#x\n", bootdev); + for (bdi = bios_diskinfo; bdi->bios_number != -1; bdi++) + if (bdi->bios_number & 0x80) + printf("dkcsum: BIOS drive %#x checksum is %#x\n", + bdi->bios_number, bdi->checksum); #endif pribootdev = altbootdev = 0; @@ -95,7 +99,7 @@ dkcsumattach(void) if (error) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: open of %s failed (%d)\n", + printf("dkcsum: %s open failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -110,13 +114,13 @@ dkcsumattach(void) if ((error = biowait(bp))) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: read of %s failed (%d)\n", + printf("dkcsum: %s read failed (%d)\n", dv->dv_xname, error); #endif error = (*bdsw->d_close)(dev, 0, S_IFCHR, curproc); #ifdef DEBUG if (error) - printf("dkcsum: close of %s failed (%d)\n", + printf("dkcsum: %s close failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -125,7 +129,7 @@ dkcsumattach(void) if (error) { /* XXX What to do here? */ #ifdef DEBUG - printf("dkcsum: close of %s failed (%d)\n", + printf("dkcsum: %s closed failed (%d)\n", dv->dv_xname, error); #endif continue; @@ -133,7 +137,7 @@ dkcsumattach(void) csum = adler32(0, bp->b_data, bios_cksumlen * DEV_BSIZE); #ifdef DEBUG - printf("dkcsum: checksum of %s is %x\n", dv->dv_xname, csum); + printf("dkcsum: %s checksum is %#x\n", dv->dv_xname, csum); #endif /* Find the BIOS device */ @@ -142,36 +146,25 @@ dkcsumattach(void) /* Skip non-harddrives */ if (!(bdi->bios_number & 0x80)) continue; -#ifdef DEBUG - printf("dkcsum: " - "attempting to match with BIOS drive %x csum %x\n", - bdi->bios_number, bdi->checksum); -#endif - if (bdi->checksum == csum) { - if (!hit && !(bdi->flags & BDI_PICKED)) - hit = bdi; - else { - /* XXX add other heuristics here. */ - printf("dkcsum: warning: " - "dup BSD->BIOS disk mapping\n"); - } - } + if (bdi->checksum != csum) + continue; + picked = hit || (bdi->flags & BDI_PICKED); + if (!picked) + hit = bdi; + printf("dkcsum: %s matches BIOS drive %#x%s\n", + dv->dv_xname, bdi->bios_number, + (picked ? " IGNORED" : "")); } /* * If we have no hit, that's OK, we can see a lot more devices * than the BIOS can, so this case is pretty normal. */ - if (hit) { -#ifdef DIAGNOSTIC - printf("dkcsum: %s matched BIOS disk %x\n", - dv->dv_xname, hit->bios_number); -#endif - } else { -#ifdef DIAGNOSTIC - printf("dkcsum: %s had no matching BIOS disk\n", + if (!hit) { +#ifdef DEBUG + printf("dkcsum: %s has no matching BIOS drive\n", dv->dv_xname); -#endif +#endif continue; } @@ -195,7 +188,7 @@ dkcsumattach(void) pribootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part); #ifdef DEBUG - printf("dkcsum: setting %s as primary boot disk\n", + printf("dkcsum: %s is primary boot disk\n", dv->dv_xname); #endif } @@ -211,7 +204,7 @@ dkcsumattach(void) altbootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part); #ifdef DEBUG - printf("dkcsum: setting %s as alternate boot disk\n", + printf("dkcsum: %s is alternate boot disk\n", dv->dv_xname); #endif } |