diff options
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r-- | sys/dev/ofw/files.ofw | 4 | ||||
-rw-r--r-- | sys/dev/ofw/ofbus.c | 65 |
2 files changed, 65 insertions, 4 deletions
diff --git a/sys/dev/ofw/files.ofw b/sys/dev/ofw/files.ofw index a8a6a07d2aa..8eebf043651 100644 --- a/sys/dev/ofw/files.ofw +++ b/sys/dev/ofw/files.ofw @@ -1,4 +1,4 @@ -# $OpenBSD: files.ofw,v 1.2 1997/11/07 08:07:19 niklas Exp $ +# $OpenBSD: files.ofw,v 1.3 1998/08/22 18:00:32 rahnds Exp $ # # First cut on Openfirmware interface @@ -36,5 +36,5 @@ attach ofbus at openfirm file dev/ofw/ofbus.c openfirm device ofroot: openfirm -attach ofroot at root +attach ofroot at mainbus, root diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c index 54827495280..ba8f05022fe 100644 --- a/sys/dev/ofw/ofbus.c +++ b/sys/dev/ofw/ofbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofbus.c,v 1.2 1997/11/07 08:07:20 niklas Exp $ */ +/* $OpenBSD: ofbus.c,v 1.3 1998/08/22 18:00:34 rahnds Exp $ */ /* $NetBSD: ofbus.c,v 1.3 1996/10/13 01:38:11 christos Exp $ */ /* @@ -35,8 +35,11 @@ #include <sys/param.h> #include <sys/device.h> +#include <machine/autoconf.h> #include <dev/ofw/openfirm.h> +int ofrprobe __P((struct device *, void *, void *)); +void ofrattach __P((struct device *, struct device *, void *)); int ofbprobe __P((struct device *, void *, void *)); void ofbattach __P((struct device *, struct device *, void *)); static int ofbprint __P((void *, const char *)); @@ -50,7 +53,7 @@ struct cfdriver ofbus_cd = { }; struct cfattach ofroot_ca = { - sizeof(struct device), ofbprobe, ofbattach + sizeof(struct device), ofrprobe, ofrattach }; struct cfdriver ofroot_cd = { @@ -80,6 +83,64 @@ ofbprint(aux, name) } int +ofrprobe(parent, cf, aux) + struct device *parent; + void *cf, *aux; +{ + int node; + struct confargs *ca = aux; + + if (strcmp(ca->ca_name, ofroot_cd.cd_name) != 0) + return (0); + + return 1; +} +void +ofrattach(parent, dev, aux) + struct device *parent, *dev; + void *aux; +{ + int child; + char name[5]; + struct ofprobe *ofp = aux; + struct ofprobe probe; + int units; + int node; + char ofname[64]; + int l; + + if (!(node = OF_peer(0))) + panic("No PROM root"); + probe.phandle = node; + ofp = &probe; + + ofbprint(ofp, 0); + printf("\n"); + + if ((l = OF_getprop(ofp->phandle, "name", ofname, sizeof ofname - 1)) < 0) + { + /* no system name? */ + } else { + if (l >= sizeof ofname) + l = sizeof ofname - 1; + ofname[l] = 0; + systype(ofname); + } + + + for (child = OF_child(ofp->phandle); child; child = OF_peer(child)) { + /* + * This is a hack to skip all the entries in the tree + * that aren't devices (packages, openfirmware etc.). + */ + if (OF_getprop(child, "device_type", name, sizeof name) < 0) + continue; + probe.phandle = child; + probe.unit = 0; + config_found(dev, &probe, ofbprint); + } +} +int ofbprobe(parent, cf, aux) struct device *parent; void *cf, *aux; |