summaryrefslogtreecommitdiff
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authorDale S. Rahn <rahnds@cvs.openbsd.org>1998-08-22 18:00:35 +0000
committerDale S. Rahn <rahnds@cvs.openbsd.org>1998-08-22 18:00:35 +0000
commitb14c08b6614b3ddf135f84c2140f08af903e259e (patch)
treeb44f5f966ebd33b53aa3af3f1be0a9817a4973d5 /sys/dev/ofw
parent439d30c5f938bc7e70126fad63f0b346da3ed51d (diff)
Allow ofroot to be child of mainbus or root.
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/files.ofw4
-rw-r--r--sys/dev/ofw/ofbus.c65
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;