summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-06-03 19:16:45 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-06-03 19:16:45 +0000
commit72130d50757c6491f915108edcc00859f74834b2 (patch)
treef15637e1809fda9c029b7caa2712f94dc3f9a88e /sys
parent713e451c66a1c9391a21a5bf04fb669fd9eda55b (diff)
Rework the logic for matching the boot device to allow for root on
any drive attached to the first controller. Fix an issue reported by Jan Stary, hans at stare dot cz. Note that this new logic still doesn't allow for root on any drive attached to a secondary controller. ok miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/macppc/autoconf.c81
-rw-r--r--sys/arch/macppc/macppc/machdep.c8
2 files changed, 50 insertions, 39 deletions
diff --git a/sys/arch/macppc/macppc/autoconf.c b/sys/arch/macppc/macppc/autoconf.c
index 238fc7752ce..a25deef4bcb 100644
--- a/sys/arch/macppc/macppc/autoconf.c
+++ b/sys/arch/macppc/macppc/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.39 2010/11/11 17:58:21 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.40 2013/06/03 19:16:43 mpi Exp $ */
/*
* Copyright (c) 1996, 1997 Per Fogelstrom
* Copyright (c) 1995 Theo de Raadt
@@ -37,7 +37,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.39 2010/11/11 17:58:21 miod Exp $
+ * $Id: autoconf.c,v 1.40 2013/06/03 19:16:43 mpi Exp $
*/
/*
@@ -62,13 +62,12 @@
#include <sys/disk.h>
#include <scsi/scsi_all.h>
-#include <scsi/scsi_disk.h>
#include <scsi/scsiconf.h>
-#include <scsi/sdvar.h>
+#include <dev/ata/atavar.h>
void dumpconf(void);
static struct devmap *findtype(char **);
-void makebootdev(char *cp);
+void parseofwbp(char *);
int getpno(char **);
/*
@@ -79,6 +78,9 @@ int getpno(char **);
int cold = 1; /* if 1, still working on cold-start */
char bootdev[16]; /* to hold boot dev name */
struct device *bootdv = NULL;
+enum devclass bootdev_class = DV_DULL;
+int bootdev_type = 0;
+int bootdev_unit = 0;
struct dumpmem dumpmem[VM_PHYSSEG_MAX];
u_int ndumpmem;
@@ -165,9 +167,9 @@ findtype(char **s)
* '/ht@0,f2000000/pci@2/bcom5704@4/bsd'
*/
void
-makebootdev(char *bp)
+parseofwbp(char *bp)
{
- int unit, ptype;
+ int ptype;
char *dev, *cp;
struct devmap *dp;
@@ -184,6 +186,8 @@ makebootdev(char *bp)
} while((dp->type & T_IFACE) == 0);
if (dp->att && dp->type == T_IFACE) {
+ bootdev_class = DV_IFNET;
+ bootdev_type = dp->type;
strlcpy(bootdev, dp->dev, sizeof bootdev);
return;
}
@@ -193,24 +197,9 @@ makebootdev(char *bp)
ptype = dp->type;
dp = findtype(&cp);
if (dp->att && dp->type == T_DISK) {
- unit = getpno(&cp);
- if (ptype == T_SCSI) {
- struct device *dv;
- struct sd_softc *sd;
-
- TAILQ_FOREACH(dv, &alldevs, dv_list) {
- if (dv->dv_class != DV_DISK ||
- strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd"))
- continue;
- sd = (struct sd_softc *)dv;
- if (sd->sc_link->target != unit)
- continue;
- snprintf(bootdev, sizeof bootdev,
- "%s%c", dv->dv_xname, 'a');
- return;
- }
- }
- snprintf(bootdev, sizeof bootdev, "%s%d%c", dev, unit, 'a');
+ bootdev_class = DV_DISK;
+ bootdev_type = ptype;
+ bootdev_unit = getpno(&cp);
return;
}
printf("Warning: boot device unrecognized: %s\n", bp);
@@ -239,25 +228,43 @@ getpno(char **cp)
void
device_register(struct device *dev, void *aux)
{
+ const char *drvrname = dev->dv_cfdata->cf_driver->cd_name;
+ const char *name = dev->dv_xname;
+
+ if (bootdv != NULL || dev->dv_class != bootdev_class)
+ return;
+
+ switch (bootdev_type) {
+ case T_SCSI:
+ if (strcmp(drvrname, "sd") == 0) {
+ struct scsi_attach_args *sa = aux;
+
+ if (sa->sa_sc_link->target == bootdev_unit)
+ bootdv = dev;
+ }
+ case T_IDE:
+ if (strcmp(drvrname, "wd") == 0) {
+ struct ata_atapi_attach *aa = aux;
+
+ if (aa->aa_drv_data->drive == bootdev_unit)
+ bootdv = dev;
+ }
+ break;
+ case T_IFACE:
+ if (strcmp(name, bootdev) == 0)
+ bootdv = dev;
+ break;
+ default:
+ break;
+ }
}
-/*
- * 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(void)
{
- dev_t temp;
- int part = 0;
-
printf("bootpath: %s\n", bootpath);
- makebootdev(bootpath);
- /* Lookup boot device from boot if not set by configuration */
- bootdv = parsedisk(bootdev, strlen(bootdev), 0, &temp);
- setroot(bootdv, part, RB_USERREQ);
+ setroot(bootdv, 0, RB_USERREQ);
dumpconf();
}
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index 2d571cb8454..05bd61dd45b 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.135 2012/12/06 12:35:22 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.136 2013/06/03 19:16:44 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -114,6 +114,9 @@ char ofw_eth_addr[6]; /* Save address of first network ifc found */
char *bootpath;
char bootpathbuf[512];
+/* from autoconf.c */
+extern void parseofwbp(char *);
+
struct firmware *fw = NULL;
#ifdef DDB
@@ -367,7 +370,8 @@ initppc(startkernel, endkernel, args)
}
}
}
- bootpath= &bootpathbuf[0];
+ bootpath = &bootpathbuf[0];
+ parseofwbp(bootpath);
#ifdef DDB
ddb_init();