> Were you thinking of something like that? It works for me (c) tm, with
> my PowerBooks (disk@0/wd0), I haven't tried NFS boot yet.
Not exactly, but your version is probably better than what I was
thinking of. However, it will not allow for root on the second wd disk
of a controller, or on any secondary pciide controller.
Borrowing the sparc64 logic is a larger work but less error-prone.
Miod
> Index: autoconf.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/macppc/autoconf.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 autoconf.c
> --- autoconf.c 11 Nov 2010 17:58:21 -0000 1.39
> +++ autoconf.c 22 May 2013 19:00:45 -0000
> @@ -68,7 +68,7 @@
>
> void dumpconf(void);
> static struct devmap *findtype(char **);
> -void makebootdev(char *cp);
> +void parseofwbp(char *);
> int getpno(char **);
>
> /*
> @@ -79,6 +79,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 +168,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 +187,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 +198,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 +229,44 @@ 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 sd_softc *sd = (struct sd_softc *)dev;
> +
> + if (sd->sc_link->target == bootdev_unit)
> + bootdv = dev;
> + }
> + case T_IDE:
> + /*
> + * Do not require the bootpath unit number to match
> + * against the driver's one, a slave disk on the ATA
> + * channel `disk@1' can attach as `wd0'.
> + */
> + if (strcmp(drvrname, "wd") == 0)
> + 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();
> }
>
> Index: machdep.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/macppc/machdep.c,v
> retrieving revision 1.135
> diff -u -p -r1.135 machdep.c
> --- machdep.c 6 Dec 2012 12:35:22 -0000 1.135
> +++ machdep.c 22 May 2013 18:24:25 -0000
> @@ -114,6 +114,9 @@ char ofw_eth_addr[6]; /* Save address o
> 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();