Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofwbus.c
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | ofwbus_probe(device_t dev) | ||||
device_set_desc(dev, "Open Firmware Device Tree"); | device_set_desc(dev, "Open Firmware Device Tree"); | ||||
return (BUS_PROBE_NOWILDCARD); | return (BUS_PROBE_NOWILDCARD); | ||||
} | } | ||||
static int | static int | ||||
ofwbus_attach(device_t dev) | ofwbus_attach(device_t dev) | ||||
{ | { | ||||
phandle_t node; | phandle_t node; | ||||
struct ofw_bus_devinfo obd; | |||||
node = OF_peer(0); | node = OF_peer(0); | ||||
/* | /* | ||||
* If no Open Firmware, bail early | * If no Open Firmware, bail early | ||||
*/ | */ | ||||
if (node == -1) | if (node == -1) | ||||
return (ENXIO); | return (ENXIO); | ||||
/* | /* | ||||
* ofwbus bus starts on unamed node in FDT, so we cannot make | * ofwbus bus starts on unamed node in FDT, so we cannot make | ||||
* ofw_bus_devinfo from it. Pass node to simplebus_init directly. | * ofw_bus_devinfo from it. Pass node to simplebus_init directly. | ||||
*/ | */ | ||||
simplebus_init(dev, node); | simplebus_init(dev, node); | ||||
/* | /* | ||||
* Allow devices to identify. | * Allow devices to identify. | ||||
*/ | */ | ||||
bus_generic_probe(dev); | bus_generic_probe(dev); | ||||
/* | /* | ||||
* Now walk the OFW tree and attach top-level devices. | * Now walk the OFW tree and attach top-level devices. | ||||
*/ | */ | ||||
for (node = OF_child(node); node > 0; node = OF_peer(node)) { | for (node = OF_child(node); node > 0; node = OF_peer(node)) | ||||
if (ofw_bus_gen_setup_devinfo(&obd, node) != 0) | |||||
continue; | |||||
simplebus_add_device(dev, node, 0, NULL, -1, NULL); | simplebus_add_device(dev, node, 0, NULL, -1, NULL); | ||||
ofw_bus_gen_destroy_devinfo(&obd); | |||||
} | |||||
return (bus_generic_attach(dev)); | return (bus_generic_attach(dev)); | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
ofwbus_alloc_resource(device_t bus, device_t child, int type, int *rid, | ofwbus_alloc_resource(device_t bus, device_t child, int type, int *rid, | ||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct resource *rv; | struct resource *rv; | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |