Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/fdt/simplebus.c
Show All 40 Lines | |||||
#include <dev/fdt/simplebus.h> | #include <dev/fdt/simplebus.h> | ||||
/* | /* | ||||
* Bus interface. | * Bus interface. | ||||
*/ | */ | ||||
static int simplebus_probe(device_t dev); | static int simplebus_probe(device_t dev); | ||||
static int simplebus_attach(device_t dev); | static int simplebus_attach(device_t dev); | ||||
static struct resource *simplebus_alloc_resource(device_t, device_t, int, | static struct resource *simplebus_alloc_resource(device_t, device_t, int, | ||||
int *, u_long, u_long, u_long, u_int); | int *, rman_res_t, rman_res_t, rman_res_t, u_int); | ||||
static void simplebus_probe_nomatch(device_t bus, device_t child); | static void simplebus_probe_nomatch(device_t bus, device_t child); | ||||
static int simplebus_print_child(device_t bus, device_t child); | static int simplebus_print_child(device_t bus, device_t child); | ||||
static device_t simplebus_add_child(device_t dev, u_int order, | static device_t simplebus_add_child(device_t dev, u_int order, | ||||
const char *name, int unit); | const char *name, int unit); | ||||
static struct resource_list *simplebus_get_resource_list(device_t bus, | static struct resource_list *simplebus_get_resource_list(device_t bus, | ||||
device_t child); | device_t child); | ||||
/* | /* | ||||
* ofw_bus interface | * ofw_bus interface | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
ndi = device_get_ivars(child); | ndi = device_get_ivars(child); | ||||
if (ndi == NULL) | if (ndi == NULL) | ||||
return (NULL); | return (NULL); | ||||
return (&ndi->rl); | return (&ndi->rl); | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, | simplebus_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 simplebus_softc *sc; | struct simplebus_softc *sc; | ||||
struct simplebus_devinfo *di; | struct simplebus_devinfo *di; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
int j; | int j; | ||||
sc = device_get_softc(bus); | sc = device_get_softc(bus); | ||||
/* | /* | ||||
* Request for the default allocation with a given rid: use resource | * Request for the default allocation with a given rid: use resource | ||||
* list stored in the local device info. | * list stored in the local device info. | ||||
*/ | */ | ||||
if ((start == 0UL) && (end == ~0UL)) { | if ((start == 0) && (end == ~0)) { | ||||
jhb: Use ~0 here? (You have mostly used ~0 rather than RM_MAX_END in the rest of the code.) | |||||
if ((di = device_get_ivars(child)) == NULL) | if ((di = device_get_ivars(child)) == NULL) | ||||
return (NULL); | return (NULL); | ||||
if (type == SYS_RES_IOPORT) | if (type == SYS_RES_IOPORT) | ||||
type = SYS_RES_MEMORY; | type = SYS_RES_MEMORY; | ||||
rle = resource_list_find(&di->rl, type, *rid); | rle = resource_list_find(&di->rl, type, *rid); | ||||
if (rle == NULL) { | if (rle == NULL) { | ||||
Show All 17 Lines | |||||
end -= sc->ranges[j].bus; | end -= sc->ranges[j].bus; | ||||
end += sc->ranges[j].host; | end += sc->ranges[j].host; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (j == sc->nranges && sc->nranges != 0) { | if (j == sc->nranges && sc->nranges != 0) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(bus, "Could not map resource " | device_printf(bus, "Could not map resource " | ||||
"%#lx-%#lx\n", start, end); | "%#jx-%#jx\n", start, end); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
return (bus_generic_alloc_resource(bus, child, type, rid, start, end, | return (bus_generic_alloc_resource(bus, child, type, rid, start, end, | ||||
count, flags)); | count, flags)); | ||||
} | } | ||||
static int | static int | ||||
simplebus_print_res(struct simplebus_devinfo *di) | simplebus_print_res(struct simplebus_devinfo *di) | ||||
{ | { | ||||
int rv; | int rv; | ||||
if (di == NULL) | if (di == NULL) | ||||
return (0); | return (0); | ||||
rv = 0; | rv = 0; | ||||
rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#lx"); | rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#jx"); | ||||
rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%ld"); | rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%jd"); | ||||
return (rv); | return (rv); | ||||
} | } | ||||
static void | static void | ||||
simplebus_probe_nomatch(device_t bus, device_t child) | simplebus_probe_nomatch(device_t bus, device_t child) | ||||
{ | { | ||||
const char *name, *type, *compat; | const char *name, *type, *compat; | ||||
Show All 30 Lines |
Use ~0 here? (You have mostly used ~0 rather than RM_MAX_END in the rest of the code.)