summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2004-02-04 12:52:57 +0000
committergrehan <grehan@FreeBSD.org>2004-02-04 12:52:57 +0000
commit5b27a3c25505dd541fcc5a770a08be9a07924ce9 (patch)
tree7138bde5f91e4aa453f533a4ff93c9ef113b4ccd /sys/dev
parente0e0aca56a0a2ae4b2ced6313e1c437d2d6b6c37 (diff)
downloadFreeBSD-src-5b27a3c25505dd541fcc5a770a08be9a07924ce9.zip
FreeBSD-src-5b27a3c25505dd541fcc5a770a08be9a07924ce9.tar.gz
- add an identify method, since the disk device used to be picked
up in the recursive OpenFirmware node walk. Rely on the psim config file to have a "ofwdisk" device alias - minor white space nits
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ofw/ofw_disk.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/sys/dev/ofw/ofw_disk.c b/sys/dev/ofw/ofw_disk.c
index aa0213a..8d4ae82 100644
--- a/sys/dev/ofw/ofw_disk.c
+++ b/sys/dev/ofw/ofw_disk.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <geom/geom_disk.h>
#include <dev/ofw/openfirm.h>
@@ -55,10 +56,12 @@ struct ofwd_softc
/*
* Disk device bus interface.
*/
+static void ofwd_identify(driver_t *, device_t);
static int ofwd_probe(device_t);
static int ofwd_attach(device_t);
static device_method_t ofwd_methods[] = {
+ DEVMETHOD(device_identify, ofwd_identify),
DEVMETHOD(device_probe, ofwd_probe),
DEVMETHOD(device_attach, ofwd_attach),
{ 0, 0 }
@@ -122,18 +125,41 @@ ofwd_strategy(struct bio *bp)
}
bp->bio_resid -= r;
-
+
if (r < bp->bio_bcount) {
device_printf(sc->ofwd_dev, "r (%ld) < bp->bio_bcount (%ld)\n",
r, bp->bio_bcount);
biofinish(bp, NULL, EIO); /* XXX: probably not an error */
return;
- }
+ }
biodone(bp);
return;
}
/*
+ * Attach the OpenFirmware disk to nexus if present
+ */
+static void
+ofwd_identify(driver_t *driver, device_t parent)
+{
+ device_t child;
+ phandle_t ofd;
+ static char type[8];
+
+ ofd = OF_finddevice("ofwdisk");
+ if (ofd == -1)
+ return;
+
+ OF_getprop(ofd, "device_type", type, sizeof(type));
+
+ child = BUS_ADD_CHILD(parent, INT_MAX, "ofwd", 0);
+ if (child != NULL) {
+ nexus_set_device_type(child, type);
+ nexus_set_node(child, ofd);
+ }
+}
+
+/*
* Probe for an OpenFirmware disk.
*/
static int
@@ -146,7 +172,7 @@ ofwd_probe(device_t dev)
type = nexus_get_device_type(dev);
node = nexus_get_node(dev);
- if (type == NULL ||
+ if (type == NULL ||
(strcmp(type, "disk") != 0 && strcmp(type, "block") != 0))
return (ENXIO);
OpenPOWER on IntegriCloud