Changeset View
Changeset View
Standalone View
Standalone View
sys/mips/mips/nexus.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) | #define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) | ||||
static struct rman irq_rman; | static struct rman irq_rman; | ||||
static struct rman mem_rman; | static struct rman mem_rman; | ||||
static struct resource * | static struct resource * | ||||
nexus_alloc_resource(device_t, device_t, int, int *, u_long, | nexus_alloc_resource(device_t, device_t, int, int *, rman_res_t, | ||||
u_long, u_long, u_int); | rman_res_t, rman_res_t, u_int); | ||||
static device_t nexus_add_child(device_t, u_int, const char *, int); | static device_t nexus_add_child(device_t, u_int, const char *, int); | ||||
static int nexus_attach(device_t); | static int nexus_attach(device_t); | ||||
static void nexus_delete_resource(device_t, device_t, int, int); | static void nexus_delete_resource(device_t, device_t, int, int); | ||||
static struct resource_list * | static struct resource_list * | ||||
nexus_get_reslist(device_t, device_t); | nexus_get_reslist(device_t, device_t); | ||||
static int nexus_get_resource(device_t, device_t, int, int, u_long *, | static int nexus_get_resource(device_t, device_t, int, int, rman_res_t *, | ||||
u_long *); | rman_res_t *); | ||||
static int nexus_print_child(device_t, device_t); | static int nexus_print_child(device_t, device_t); | ||||
static int nexus_print_all_resources(device_t dev); | static int nexus_print_all_resources(device_t dev); | ||||
static int nexus_probe(device_t); | static int nexus_probe(device_t); | ||||
static int nexus_release_resource(device_t, device_t, int, int, | static int nexus_release_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static int nexus_set_resource(device_t, device_t, int, int, u_long, | static int nexus_set_resource(device_t, device_t, int, int, rman_res_t, | ||||
u_long); | rman_res_t); | ||||
static int nexus_activate_resource(device_t, device_t, int, int, | static int nexus_activate_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static int nexus_deactivate_resource(device_t, device_t, int, int, | static int nexus_deactivate_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static void nexus_hinted_child(device_t, const char *, int); | static void nexus_hinted_child(device_t, const char *, int); | ||||
static int nexus_setup_intr(device_t dev, device_t child, | static int nexus_setup_intr(device_t dev, device_t child, | ||||
struct resource *res, int flags, driver_filter_t *filt, | struct resource *res, int flags, driver_filter_t *filt, | ||||
driver_intr_t *intr, void *arg, void **cookiep); | driver_intr_t *intr, void *arg, void **cookiep); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
irq_rman.rm_type = RMAN_ARRAY; | irq_rman.rm_type = RMAN_ARRAY; | ||||
irq_rman.rm_descr = "Hardware IRQs"; | irq_rman.rm_descr = "Hardware IRQs"; | ||||
if (rman_init(&irq_rman) != 0 || | if (rman_init(&irq_rman) != 0 || | ||||
rman_manage_region(&irq_rman, 0, NUM_MIPS_IRQS - 1) != 0) { | rman_manage_region(&irq_rman, 0, NUM_MIPS_IRQS - 1) != 0) { | ||||
panic("%s: irq_rman", __func__); | panic("%s: irq_rman", __func__); | ||||
} | } | ||||
mem_rman.rm_start = 0; | mem_rman.rm_start = 0; | ||||
mem_rman.rm_end = ~0ul; | mem_rman.rm_end = BUS_SPACE_MAXADDR; | ||||
mem_rman.rm_type = RMAN_ARRAY; | mem_rman.rm_type = RMAN_ARRAY; | ||||
mem_rman.rm_descr = "Memory addresses"; | mem_rman.rm_descr = "Memory addresses"; | ||||
if (rman_init(&mem_rman) != 0 || | if (rman_init(&mem_rman) != 0 || | ||||
rman_manage_region(&mem_rman, 0, ~0) != 0) { | rman_manage_region(&mem_rman, 0, ~0) != 0) { | ||||
panic("%s: mem_rman", __func__); | panic("%s: mem_rman", __func__); | ||||
} | } | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Allocate a resource on behalf of child. NB: child is usually going to be a | * Allocate a resource on behalf of child. NB: child is usually going to be a | ||||
* child of one of our descendants, not a direct child of nexus0. | * child of one of our descendants, not a direct child of nexus0. | ||||
* (Exceptions include footbridge.) | * (Exceptions include footbridge.) | ||||
*/ | */ | ||||
static struct resource * | static struct resource * | ||||
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, | nexus_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 nexus_device *ndev = DEVTONX(child); | struct nexus_device *ndev = DEVTONX(child); | ||||
struct resource *rv; | struct resource *rv; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
struct rman *rm; | struct rman *rm; | ||||
int isdefault, needactivate, passthrough; | int isdefault, needactivate, passthrough; | ||||
dprintf("%s: entry (%p, %p, %d, %p, %p, %p, %ld, %d)\n", | dprintf("%s: entry (%p, %p, %d, %p, %p, %p, %jd, %d)\n", | ||||
__func__, bus, child, type, rid, (void *)(intptr_t)start, | __func__, bus, child, type, rid, (void *)(intptr_t)start, | ||||
(void *)(intptr_t)end, count, flags); | (void *)(intptr_t)end, count, flags); | ||||
dprintf("%s: requested rid is %d\n", __func__, *rid); | dprintf("%s: requested rid is %d\n", __func__, *rid); | ||||
isdefault = (start == 0UL && end == ~0UL && count == 1); | isdefault = (start == 0 && end == ~0 && count == 1); | ||||
needactivate = flags & RF_ACTIVE; | needactivate = flags & RF_ACTIVE; | ||||
passthrough = (device_get_parent(child) != bus); | passthrough = (device_get_parent(child) != bus); | ||||
rle = NULL; | rle = NULL; | ||||
/* | /* | ||||
* If this is an allocation of the "default" range for a given RID, | * If this is an allocation of the "default" range for a given RID, | ||||
* and we know what the resources for this device are (ie. they aren't | * and we know what the resources for this device are (ie. they aren't | ||||
* maintained by a child bus), then work out the start/end values. | * maintained by a child bus), then work out the start/end values. | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct nexus_device *ndev = DEVTONX(child); | struct nexus_device *ndev = DEVTONX(child); | ||||
return (&ndev->nx_resources); | return (&ndev->nx_resources); | ||||
} | } | ||||
static int | static int | ||||
nexus_set_resource(device_t dev, device_t child, int type, int rid, | nexus_set_resource(device_t dev, device_t child, int type, int rid, | ||||
u_long start, u_long count) | rman_res_t start, rman_res_t count) | ||||
{ | { | ||||
struct nexus_device *ndev = DEVTONX(child); | struct nexus_device *ndev = DEVTONX(child); | ||||
struct resource_list *rl = &ndev->nx_resources; | struct resource_list *rl = &ndev->nx_resources; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
dprintf("%s: entry (%p, %p, %d, %d, %p, %ld)\n", | dprintf("%s: entry (%p, %p, %d, %d, %p, %jd)\n", | ||||
__func__, dev, child, type, rid, (void *)(intptr_t)start, count); | __func__, dev, child, type, rid, (void *)(intptr_t)start, count); | ||||
rle = resource_list_add(rl, type, rid, start, start + count - 1, | rle = resource_list_add(rl, type, rid, start, start + count - 1, | ||||
count); | count); | ||||
if (rle == NULL) | if (rle == NULL) | ||||
return (ENXIO); | return (ENXIO); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nexus_get_resource(device_t dev, device_t child, int type, int rid, | nexus_get_resource(device_t dev, device_t child, int type, int rid, | ||||
u_long *startp, u_long *countp) | rman_res_t *startp, rman_res_t *countp) | ||||
{ | { | ||||
struct nexus_device *ndev = DEVTONX(child); | struct nexus_device *ndev = DEVTONX(child); | ||||
struct resource_list *rl = &ndev->nx_resources; | struct resource_list *rl = &ndev->nx_resources; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
rle = resource_list_find(rl, type, rid); | rle = resource_list_find(rl, type, rid); | ||||
if (!rle) | if (!rle) | ||||
return(ENOENT); | return(ENOENT); | ||||
Show All 33 Lines | |||||
static int | static int | ||||
nexus_activate_resource(device_t bus, device_t child, int type, int rid, | nexus_activate_resource(device_t bus, device_t child, int type, int rid, | ||||
struct resource *r) | struct resource *r) | ||||
{ | { | ||||
void *vaddr; | void *vaddr; | ||||
vm_paddr_t paddr; | vm_paddr_t paddr; | ||||
vm_size_t psize; | vm_size_t psize; | ||||
/* | /* | ||||
Context not available. | |||||
jhb: As with arm, I think the proper place to fix this is when initializing the rman and/or the… |
As with arm, I think the proper place to fix this is when initializing the rman and/or the regions it covers, not to check here.