Fix boot device selection when booting from an alias. If the bootpath

isn't an OFW device, look it up in /aliases and substitute the bootpath
found into the string.  This allow device_register to do it's thing.
Key off the drive number, not the channel, in autoconf.c.  Closes PR#13756.
This commit is contained in:
matt 2001-11-19 23:22:48 +00:00
parent 859356d03b
commit 3ae5a183aa
2 changed files with 42 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.26 2001/07/22 11:29:47 wiz Exp $ */
/* $NetBSD: autoconf.c,v 1.27 2001/11/19 23:22:48 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -246,7 +246,7 @@ device_register(dev, aux)
} else if (DEVICE_IS(dev->dv_parent, "pciide")) {
struct ata_atapi_attach *aa = aux;
if (addr != aa->aa_channel)
if (addr != aa->aa_drv_data->drive)
return;
/*
@ -263,7 +263,7 @@ device_register(dev, aux)
} else if (DEVICE_IS(dev->dv_parent, "wdc")) {
struct ata_atapi_attach *aa = aux;
if (addr != aa->aa_channel)
if (addr != aa->aa_drv_data->drive)
return;
} else
return;
@ -280,6 +280,7 @@ device_register(dev, aux)
bp++;
return;
} else {
printf("%s -> %s\n", bootpath, dev->dv_xname);
booted_device = dev;
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.104 2001/09/10 21:19:17 chris Exp $ */
/* $NetBSD: machdep.c,v 1.105 2001/11/19 23:22:49 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -326,6 +326,43 @@ initppc(startkernel, endkernel, args)
BOOT_FLAG(*args++, boothowto);
}
/*
* If the bootpath doesn't start with a / then it isn't
* an OFW path and probably is an alias, so look up the alias
* and regenerate the full bootpath so device_register will work.
*/
if (bootpath[0] != '/' && bootpath[0] != '\0') {
int aliases = OF_finddevice("/aliases");
char tmpbuf[100];
char aliasbuf[256];
if (aliases != 0) {
char *cp1, *cp2, *cp;
char saved_ch = 0;
int len;
cp1 = strchr(bootpath, ':');
cp2 = strchr(bootpath, ',');
cp = cp1;
if (cp1 == NULL || (cp2 != NULL && cp2 < cp1))
cp = cp2;
tmpbuf[0] = '\0';
if (cp != NULL) {
strcpy(tmpbuf, cp);
saved_ch = *cp;
*cp = '\0';
}
len = OF_getprop(aliases, bootpath, aliasbuf,
sizeof(aliasbuf));
if (len > 0) {
if (aliasbuf[len-1] == '\0')
len--;
memcpy(bootpath, aliasbuf, len);
strcpy(&bootpath[len], tmpbuf);
} else {
*cp = saved_ch;
}
}
}
#ifdef DDB
ddb_init((int)((u_int)endsym - (u_int)startsym), startsym, endsym);
if (boothowto & RB_KDB)