summaryrefslogtreecommitdiff
path: root/sys/arch/macppc
diff options
context:
space:
mode:
authorThierry Deval <tdeval@cvs.openbsd.org>2001-12-05 23:58:42 +0000
committerThierry Deval <tdeval@cvs.openbsd.org>2001-12-05 23:58:42 +0000
commit41bc9e864940c498f11169f1b63c082c057d8534 (patch)
tree2183e20ba9a198c0a2f432da175beb4a12b4bae0 /sys/arch/macppc
parent03573bfb57ddd4be432cfa80b3e1fa1405abcc13 (diff)
Enable rootdev auto-configuration by device drivers during boot.
Add support for "raid" devices (prepare future raidframe changes). OK deraadt@, Reviewed by drahn@, jason@, mickey@ and miod@
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r--sys/arch/macppc/macppc/autoconf.c42
-rw-r--r--sys/arch/macppc/macppc/conf.c39
2 files changed, 74 insertions, 7 deletions
diff --git a/sys/arch/macppc/macppc/autoconf.c b/sys/arch/macppc/macppc/autoconf.c
index 68e3f99af68..573e5ff8a8f 100644
--- a/sys/arch/macppc/macppc/autoconf.c
+++ b/sys/arch/macppc/macppc/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.1 2001/09/01 15:44:20 drahn Exp $ */
+/* $OpenBSD: autoconf.c,v 1.2 2001/12/05 23:58:41 tdeval Exp $ */
/*
* Copyright (c) 1996, 1997 Per Fogelstrom
* Copyright (c) 1995 Theo de Raadt
@@ -41,7 +41,7 @@
* from: Utah Hdr: autoconf.c 1.31 91/01/21
*
* from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
- * $Id: autoconf.c,v 1.1 2001/09/01 15:44:20 drahn Exp $
+ * $Id: autoconf.c,v 1.2 2001/12/05 23:58:41 tdeval Exp $
*/
/*
@@ -66,7 +66,8 @@ struct device *parsedisk __P((char *, int, int, dev_t *));
void setroot __P((void));
void swapconf __P((void));
extern void dumpconf __P((void));
-static int findblkmajor __P((struct device *));
+int findblkmajor __P((struct device *));
+char *findblkname __P((int));
static struct device * getdisk __P((char *, int, int, dev_t *));
struct device * getdevunit __P((char *, int));
static struct devmap * findtype __P((char **));
@@ -214,21 +215,34 @@ static struct nam2blk {
{ "wd", 0 }, /* 0 = wd */
{ "sd", 2 }, /* 2 = sd */
{ "ofdisk", 4 }, /* 4 = ofdisk */
+ { "raid", 19 }, /* 19 = raid */
};
-static int
+int
findblkmajor(dv)
struct device *dv;
{
char *name = dv->dv_xname;
- register int i;
+ int i;
for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i)
- if (strncmp(name, nam2blk[i].name, strlen(nam2blk[0].name)) == 0)
+ if (strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name)) == 0)
return (nam2blk[i].maj);
return (-1);
}
+char *
+findblkname(maj)
+ int maj;
+{
+ int i;
+
+ for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++)
+ if (nam2blk[i].maj == maj)
+ return (nam2blk[i].name);
+ return (NULL);
+}
+
static struct device *
getdisk(str, len, defpart, devp)
char *str;
@@ -319,6 +333,22 @@ printf("bootpath: '%s'\n", bootpath);
if(boothowto & RB_DFLTROOT)
return; /* Boot compiled in */
+ /*
+ * (raid) device auto-configuration could have returned
+ * the root device's id in rootdev. Check this case.
+ */
+ if (rootdev != NODEV) {
+ majdev = major(rootdev);
+ unit = DISKUNIT(rootdev);
+ part = DISKPART(rootdev);
+
+ len = sprintf(buf, "%s%d", findblkname(majdev), unit);
+ if (len >= sizeof(buf))
+ panic("setroot: device name too long");
+
+ bootdv = getdisk(buf, len, part, &rootdev);
+ }
+
/* Lookup boot device from boot if not set by configuration */
if(bootdv == NULL) {
bootdv = parsedisk(bootdev, strlen(bootdev), 0, &temp);
diff --git a/sys/arch/macppc/macppc/conf.c b/sys/arch/macppc/macppc/conf.c
index 46666f1845b..2de543c0c01 100644
--- a/sys/arch/macppc/macppc/conf.c
+++ b/sys/arch/macppc/macppc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.6 2001/11/06 23:46:05 drahn Exp $ */
+/* $OpenBSD: conf.c,v 1.7 2001/12/05 23:58:41 tdeval Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -296,6 +296,43 @@ static int chrtoblktbl[] = {
/* 15 */ NODEV,
/* 16 */ NODEV,
/* 17 */ 17,
+ /* 18 */ NODEV,
+ /* 19 */ NODEV,
+ /* 20 */ NODEV,
+ /* 21 */ NODEV,
+ /* 22 */ NODEV,
+ /* 23 */ NODEV,
+ /* 24 */ NODEV,
+ /* 25 */ NODEV,
+ /* 26 */ NODEV,
+ /* 27 */ NODEV,
+ /* 28 */ NODEV,
+ /* 29 */ NODEV,
+ /* 30 */ NODEV,
+ /* 31 */ NODEV,
+ /* 32 */ NODEV,
+ /* 33 */ NODEV,
+ /* 34 */ NODEV,
+ /* 35 */ NODEV,
+ /* 36 */ NODEV,
+ /* 37 */ NODEV,
+ /* 38 */ NODEV,
+ /* 39 */ NODEV,
+ /* 40 */ NODEV,
+ /* 41 */ NODEV,
+ /* 42 */ NODEV,
+ /* 43 */ NODEV,
+ /* 44 */ NODEV,
+ /* 45 */ NODEV,
+ /* 46 */ NODEV,
+ /* 47 */ NODEV,
+ /* 48 */ NODEV,
+ /* 49 */ NODEV,
+ /* 50 */ NODEV,
+ /* 51 */ NODEV,
+ /* 52 */ NODEV,
+ /* 53 */ NODEV,
+ /* 54 */ 19,
};
/*