Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofwbus.c
Show All 20 Lines | |||||
*/ | */ | ||||
simplebus_init(dev, node); | simplebus_init(dev, node); | ||||
sc->sc_intr_rman.rm_type = RMAN_ARRAY; | sc->sc_intr_rman.rm_type = RMAN_ARRAY; | ||||
sc->sc_intr_rman.rm_descr = "Interrupts"; | sc->sc_intr_rman.rm_descr = "Interrupts"; | ||||
sc->sc_mem_rman.rm_type = RMAN_ARRAY; | sc->sc_mem_rman.rm_type = RMAN_ARRAY; | ||||
sc->sc_mem_rman.rm_descr = "Device Memory"; | sc->sc_mem_rman.rm_descr = "Device Memory"; | ||||
if (rman_init(&sc->sc_intr_rman) != 0 || | if (rman_init(&sc->sc_intr_rman) != 0 || | ||||
rman_init(&sc->sc_mem_rman) != 0 || | rman_init(&sc->sc_mem_rman) != 0 || | ||||
rman_manage_region(&sc->sc_intr_rman, 0, ~0) != 0 || | rman_manage_region(&sc->sc_intr_rman, 0, ~0) != 0 || | ||||
jhb: Given the other changes, not sure why this is using RM_MAX_END instead of ~0? (Also lower down… | |||||
rman_manage_region(&sc->sc_mem_rman, 0, BUS_SPACE_MAXADDR) != 0) | rman_manage_region(&sc->sc_mem_rman, 0, BUS_SPACE_MAXADDR) != 0) | ||||
panic("%s: failed to set up rmans.", __func__); | panic("%s: failed to set up rmans.", __func__); | ||||
/* | /* | ||||
* 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) | if (ofw_bus_gen_setup_devinfo(&obd, node) != 0) | ||||
continue; | continue; | ||||
simplebus_add_device(dev, node, 0, NULL, -1, NULL); | simplebus_add_device(dev, node, 0, NULL, -1, NULL); | ||||
} | } | ||||
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, | ||||
u_long start, u_long end, u_long count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct ofwbus_softc *sc; | struct ofwbus_softc *sc; | ||||
struct rman *rm; | struct rman *rm; | ||||
struct resource *rv; | struct resource *rv; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
int isdefault, passthrough; | int isdefault, passthrough; | ||||
isdefault = (start == 0UL && end == ~0UL); | isdefault = (start == 0 && end == ~0); | ||||
passthrough = (device_get_parent(child) != bus); | passthrough = (device_get_parent(child) != bus); | ||||
sc = device_get_softc(bus); | sc = device_get_softc(bus); | ||||
rle = NULL; | rle = NULL; | ||||
if (!passthrough && isdefault) { | if (!passthrough && isdefault) { | ||||
rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), | rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), | ||||
type, *rid); | type, *rid); | ||||
if (rle == NULL) { | if (rle == NULL) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(bus, "no default resources for " | device_printf(bus, "no default resources for " | ||||
"rid = %d, type = %d\n", *rid, type); | "rid = %d, type = %d\n", *rid, type); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
start = rle->start; | start = rle->start; | ||||
count = ulmax(count, rle->count); | count = ummax(count, rle->count); | ||||
end = ulmax(rle->end, start + count - 1); | end = ummax(rle->end, start + count - 1); | ||||
} | } | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IRQ: | case SYS_RES_IRQ: | ||||
rm = &sc->sc_intr_rman; | rm = &sc->sc_intr_rman; | ||||
break; | break; | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
rm = &sc->sc_mem_rman; | rm = &sc->sc_mem_rman; | ||||
Show All 21 Lines | |||||
rle->count = rle->end - rle->start + 1; | rle->count = rle->end - rle->start + 1; | ||||
} | } | ||||
return (rv); | return (rv); | ||||
} | } | ||||
static int | static int | ||||
ofwbus_adjust_resource(device_t bus, device_t child __unused, int type, | ofwbus_adjust_resource(device_t bus, device_t child __unused, int type, | ||||
struct resource *r, u_long start, u_long end) | struct resource *r, rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
struct ofwbus_softc *sc; | struct ofwbus_softc *sc; | ||||
struct rman *rm; | struct rman *rm; | ||||
device_t ofwbus; | device_t ofwbus; | ||||
ofwbus = bus; | ofwbus = bus; | ||||
while (strcmp(device_get_name(device_get_parent(ofwbus)), "root") != 0) | while (strcmp(device_get_name(device_get_parent(ofwbus)), "root") != 0) | ||||
ofwbus = device_get_parent(ofwbus); | ofwbus = device_get_parent(ofwbus); | ||||
Show All 37 Lines |
Given the other changes, not sure why this is using RM_MAX_END instead of ~0? (Also lower down in this same file.)