diff options
author | Thierry Deval <tdeval@cvs.openbsd.org> | 2001-12-05 23:58:42 +0000 |
---|---|---|
committer | Thierry Deval <tdeval@cvs.openbsd.org> | 2001-12-05 23:58:42 +0000 |
commit | 41bc9e864940c498f11169f1b63c082c057d8534 (patch) | |
tree | 2183e20ba9a198c0a2f432da175beb4a12b4bae0 /sys/arch/sparc | |
parent | 03573bfb57ddd4be432cfa80b3e1fa1405abcc13 (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/sparc')
-rw-r--r-- | sys/arch/sparc/sparc/autoconf.c | 44 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/conf.c | 15 |
2 files changed, 51 insertions, 8 deletions
diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c index ed269516a4c..d1b05dd2f1e 100644 --- a/sys/arch/sparc/sparc/autoconf.c +++ b/sys/arch/sparc/sparc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.43 2001/11/22 09:45:42 art Exp $ */ +/* $OpenBSD: autoconf.c,v 1.44 2001/12/05 23:58:41 tdeval Exp $ */ /* $NetBSD: autoconf.c,v 1.73 1997/07/29 09:41:53 fair Exp $ */ /* @@ -109,7 +109,8 @@ static int rootnode; void setroot __P((void)); static char *str2hex __P((char *, int *)); static int getstr __P((char *, int)); -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 *)); static int mbprint __P((void *, const char *)); static void crazymap __P((char *, int *)); @@ -1749,28 +1750,41 @@ struct nam2blk { char *name; int maj; } nam2blk[] = { - { "xy", 3 }, - { "sd", 7 }, + { "xy", 3 }, + { "sd", 7 }, { "xd", 10 }, { "st", 11 }, { "fd", 16 }, { "rd", 17 }, { "cd", 18 }, + { "raid", 25 }, }; -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; @@ -1885,6 +1899,22 @@ setroot() bootdv = (bp == NULL) ? NULL : bp->dev; /* + * (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); + } + + /* * If `swap generic' and we couldn't determine boot device, * ask the user. */ diff --git a/sys/arch/sparc/sparc/conf.c b/sys/arch/sparc/sparc/conf.c index af5e6f9bae6..1157cb7d2cd 100644 --- a/sys/arch/sparc/sparc/conf.c +++ b/sys/arch/sparc/sparc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.29 2001/09/28 02:53:13 mickey Exp $ */ +/* $OpenBSD: conf.c,v 1.30 2001/12/05 23:58:41 tdeval Exp $ */ /* $NetBSD: conf.c,v 1.40 1996/04/11 19:20:03 thorpej Exp $ */ /* @@ -424,6 +424,19 @@ static int chrtoblktbl[] = { /*108 */ NODEV, /*109 */ NODEV, /*110 */ 8, + /*111 */ NODEV, + /*112 */ NODEV, + /*113 */ NODEV, + /*114 */ NODEV, + /*115 */ NODEV, + /*116 */ NODEV, + /*117 */ NODEV, + /*118 */ NODEV, + /*119 */ NODEV, + /*120 */ NODEV, + /*121 */ NODEV, + /*122 */ NODEV, + /*123 */ 25, }; /* |