diff options
author | Tobias Weingartner <weingart@cvs.openbsd.org> | 1999-09-12 19:44:05 +0000 |
---|---|---|
committer | Tobias Weingartner <weingart@cvs.openbsd.org> | 1999-09-12 19:44:05 +0000 |
commit | 32244ca4856ee717e790f916e1bd1de8d9c56519 (patch) | |
tree | 6a7282ff12f33be3faf63824d43b2172adecf93e /sys | |
parent | 32a51369368a4f765e6e4ea2d3e323b3d36ee4d8 (diff) |
Fix rootdev handling, use disk checksums to find the device we were booted
from. Hopefully this will fix all the hangs/panics where the root device
was not found.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/autoconf.c | 59 | ||||
-rw-r--r-- | sys/arch/i386/i386/dkcsum.c | 23 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 5 | ||||
-rw-r--r-- | sys/kern/init_main.c | 16 | ||||
-rw-r--r-- | sys/sys/systm.h | 3 |
5 files changed, 64 insertions, 42 deletions
diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c index ffd768cb7ad..28c2a8ed743 100644 --- a/sys/arch/i386/i386/autoconf.c +++ b/sys/arch/i386/i386/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.29 1999/07/30 19:05:09 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.30 1999/09/12 19:44:04 weingart Exp $ */ /* $NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $ */ /*- @@ -62,9 +62,10 @@ #include <dev/cons.h> +void rootconf __P((void)); void swapconf __P((void)); void setroot __P((void)); -void setconf __P((void)); +void diskconf __P((void)); /* * The following several variables are related to @@ -72,6 +73,7 @@ void setconf __P((void)); * the machine. */ extern int cold; /* cold start flag initialized in locore.s */ +dev_t bootdev = 0; /* bootdevice, initialized in locore.s */ /* * Determine i/o configuration for a machine. @@ -91,15 +93,34 @@ configure() spl0(); - setconf(); + /* + * We can not know which is our root disk, defer + * until we can checksum blocks to figure it out. + */ + md_diskconf = diskconf; + cold = 0; +} +/* + * Now that we are fully operational, we can checksum the + * disks, and using some heuristics, hopefully are able to + * always determine the correct root disk. + */ +void +diskconf() +{ /* - * Configure swap area and related system - * parameter based on device(s) used. + * Configure root, swap, and dump area. This is + * currently done by running the same checksum + * algorithm over all known disks, as was done in + * /boot. Then we basically fixup the *dev vars + * from the info we gleaned from this. */ + dkcsumattach(); + + rootconf(); swapconf(); dumpconf(); - cold = 0; } /* @@ -127,7 +148,6 @@ swapconf() } #define DOSWAP /* change swdevt and dumpdev */ -u_long bootdev = 0; /* should be dev_t, but not until 32 bits */ static const char *devname[] = { "wd", /* 0 = wd */ @@ -176,13 +196,13 @@ setroot() if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC) return; - majdev = (bootdev >> B_TYPESHIFT) & B_TYPEMASK; + majdev = B_TYPE(bootdev); if (majdev > sizeof(devname)/sizeof(devname[0]) || *devname[majdev] == '\0') return; - adaptor = (bootdev >> B_ADAPTORSHIFT) & B_ADAPTORMASK; - part = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK; - unit = (bootdev >> B_UNITSHIFT) & B_UNITMASK; + adaptor = B_ADAPTOR(bootdev); + part = B_PARTITION(bootdev); + unit = B_UNIT(bootdev); mindev = (unit * MAXPARTITIONS) + part; orootdev = rootdev; rootdev = makedev(majdev, mindev); @@ -268,17 +288,14 @@ struct genericconf { }; void -setconf() +rootconf() { register struct genericconf *gc; int unit, part = 0; -#if 0 - int swaponroot = 0; -#endif char *num; #ifdef INSTALL - if (((bootdev >> B_TYPESHIFT) & B_TYPEMASK) == 2) { + if (B_TYPE(bootdev) == 2) { printf("\n\nInsert file system floppy...\n"); if (!(boothowto & RB_ASKNAME)) cngetc(); @@ -299,12 +316,6 @@ retry: break; if (gc->gc_driver) { num = &name[strlen(gc->gc_name)]; -#if 0 - if (num[0] == '*') { - strcpy(num, num+1); - swaponroot++; - } -#endif unit = -2; do { @@ -360,8 +371,4 @@ doswap: swdevt[0].sw_dev = argdev = dumpdev = makedev(major(rootdev), minor(rootdev) + 1); /* swap size and dumplo set during autoconfigure */ -#if 0 - if (swaponroot) - rootdev = dumpdev; -#endif } diff --git a/sys/arch/i386/i386/dkcsum.c b/sys/arch/i386/i386/dkcsum.c index 9ec30def28d..4f97fe5e662 100644 --- a/sys/arch/i386/i386/dkcsum.c +++ b/sys/arch/i386/i386/dkcsum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkcsum.c,v 1.8 1999/07/24 23:04:34 deraadt Exp $ */ +/* $OpenBSD: dkcsum.c,v 1.9 1999/09/12 19:44:04 weingart Exp $ */ /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. @@ -55,8 +55,7 @@ dev_t dev_rawpart __P((struct device *)); /* XXX */ extern u_int32_t bios_cksumlen; extern bios_diskinfo_t *bios_diskinfo; - -void dkcsumattach __P((void)); /* XXX should be elsewhere */ +extern dev_t bootdev; void dkcsumattach() @@ -169,6 +168,24 @@ dkcsumattach() continue; } + /* Fixup bootdev if units match. This means that all of + * hd*, sd*, wd*, will be interpreted the same. Not 100% + * backwards compatible, but sd* and wd* should be phased- + * out in the bootblocks. + */ + if (B_UNIT(bootdev) == (hit->bios_number & 0x7F)) { + int type, ctrl, adap, part, unit; + + /* Translate to MAKEBOOTDEV() style */ + type = major(bp->b_dev); + adap = B_ADAPTOR(bootdev); + ctrl = B_CONTROLLER(bootdev); + unit = DISKUNIT(bp->b_dev); + part = B_PARTITION(bootdev); + + bootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part); + } + /* This will overwrite /boot's guess, just so you remember */ hit->bsd_dev = MAKEBOOTDEV(major(bp->b_dev), 0, 0, DISKUNIT(bp->b_dev), RAW_PART); diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index aa7e25d5f86..3cea1adab7d 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.27 1999/07/06 07:59:54 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.28 1999/09/12 19:44:04 weingart Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -175,6 +175,9 @@ void fix_f00f __P((void)); /* autoconf.c */ void configure __P((void)); +/* dkcsum.c */ +void dkcsumattach __P((void)); + /* machdep.c */ void delay __P((int)); void dumpconf __P((void)); diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index b27d668fc31..da3da993f9c 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.40 1999/08/17 10:32:18 niklas Exp $ */ +/* $OpenBSD: init_main.c,v 1.41 1999/09/12 19:44:04 weingart Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -123,6 +123,7 @@ struct proc *initproc; int cmask = CMASK; extern struct user *proc0paddr; +void (*md_diskconf) __P((void)) = NULL; struct vnode *rootvp, *swapdev_vp; int boothowto; struct timeval boottime; @@ -364,16 +365,9 @@ main(framep) roundrobin(NULL); schedcpu(NULL); -#ifdef i386 -#include "bios.h" -#if NBIOS - /* XXX This is only a transient solution */ - { - extern void dkcsumattach __P((void)); - dkcsumattach(); - } -#endif -#endif + /* Configure root/swap devices */ + if (md_diskconf) + (*md_diskconf)(); /* Mount the root file system. */ if (vfs_mountroot()) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index de541b2ff73..e9ac3597d82 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.31 1999/07/21 21:12:51 deraadt Exp $ */ +/* $OpenBSD: systm.h,v 1.32 1999/09/12 19:44:04 weingart Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -246,6 +246,7 @@ void consinit __P((void)); void cpu_startup __P((void)); void cpu_set_kpc __P((struct proc *, void (*)(void *), void *)); +extern void (*md_diskconf) __P((void)); #ifdef GPROF |