summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1999-09-12 19:44:05 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1999-09-12 19:44:05 +0000
commit32244ca4856ee717e790f916e1bd1de8d9c56519 (patch)
tree6a7282ff12f33be3faf63824d43b2172adecf93e /sys/arch
parent32a51369368a4f765e6e4ea2d3e323b3d36ee4d8 (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/arch')
-rw-r--r--sys/arch/i386/i386/autoconf.c59
-rw-r--r--sys/arch/i386/i386/dkcsum.c23
-rw-r--r--sys/arch/i386/include/cpu.h5
3 files changed, 57 insertions, 30 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));