Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/nexus.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#ifdef DEV_ACPI | #ifdef DEV_ACPI | ||||
static device_probe_t nexus_acpi_probe; | static device_probe_t nexus_acpi_probe; | ||||
static device_attach_t nexus_acpi_attach; | static device_attach_t nexus_acpi_attach; | ||||
#endif | #endif | ||||
static int nexus_print_child(device_t, device_t); | static int nexus_print_child(device_t, device_t); | ||||
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 struct resource *nexus_alloc_resource(device_t, device_t, int, int *, | static struct resource *nexus_alloc_resource(device_t, device_t, int, int *, | ||||
u_long, u_long, u_long, u_int); | rman_res_t, rman_res_t, rman_res_t, u_int); | ||||
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_config_intr(device_t dev, int irq, enum intr_trigger trig, | static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, | ||||
enum intr_polarity pol); | enum intr_polarity pol); | ||||
static struct resource_list *nexus_get_reslist(device_t, device_t); | static struct resource_list *nexus_get_reslist(device_t, device_t); | ||||
static int nexus_set_resource(device_t, device_t, int, int, u_long, u_long); | static int nexus_set_resource(device_t, device_t, int, int, | ||||
rman_res_t, rman_res_t); | |||||
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 int nexus_setup_intr(device_t dev, device_t child, struct resource *res, | static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, | ||||
int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); | int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); | ||||
static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); | static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); | ||||
#ifdef FDT | #ifdef FDT | ||||
Show All 23 Lines | |||||
1 /* no softc */ | 1 /* no softc */ | ||||
}; | }; | ||||
static int | static int | ||||
nexus_attach(device_t dev) | nexus_attach(device_t dev) | ||||
{ | { | ||||
mem_rman.rm_start = 0; | mem_rman.rm_start = 0; | ||||
mem_rman.rm_end = ~0ul; | mem_rman.rm_end = ~0; | ||||
mem_rman.rm_type = RMAN_ARRAY; | mem_rman.rm_type = RMAN_ARRAY; | ||||
mem_rman.rm_descr = "I/O memory addresses"; | mem_rman.rm_descr = "I/O memory addresses"; | ||||
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0)) | if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0)) | ||||
panic("nexus_attach mem_rman"); | panic("nexus_attach mem_rman"); | ||||
irq_rman.rm_start = 0; | irq_rman.rm_start = 0; | ||||
irq_rman.rm_end = ~0ul; | irq_rman.rm_end = ~0; | ||||
irq_rman.rm_type = RMAN_ARRAY; | irq_rman.rm_type = RMAN_ARRAY; | ||||
irq_rman.rm_descr = "Interrupts"; | irq_rman.rm_descr = "Interrupts"; | ||||
if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0)) | if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0)) | ||||
panic("nexus_attach irq_rman"); | panic("nexus_attach irq_rman"); | ||||
bus_generic_probe(dev); | bus_generic_probe(dev); | ||||
bus_generic_attach(dev); | bus_generic_attach(dev); | ||||
Show All 33 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 needactivate = flags & RF_ACTIVE; | int needactivate = flags & RF_ACTIVE; | ||||
/* | /* | ||||
* If this is an allocation of the "default" range for a given | * If this is an allocation of the "default" range for a given | ||||
* RID, and we know what the resources for this device are | * RID, and we know what the resources for this device are | ||||
* (ie. they aren't maintained by a child bus), then work out | * (ie. they aren't maintained by a child bus), then work out | ||||
* the start/end values. | * the start/end values. | ||||
*/ | */ | ||||
if ((start == 0UL) && (end == ~0UL) && (count == 1)) { | if ((start == 0) && (end == ~0) && (count == 1)) { | ||||
if (device_get_parent(child) != bus || ndev == NULL) | if (device_get_parent(child) != bus || ndev == NULL) | ||||
return(NULL); | return(NULL); | ||||
rle = resource_list_find(&ndev->nx_resources, type, *rid); | rle = resource_list_find(&ndev->nx_resources, type, *rid); | ||||
if (rle == NULL) | if (rle == NULL) | ||||
return(NULL); | return(NULL); | ||||
start = rle->start; | start = rle->start; | ||||
end = rle->end; | end = rle->end; | ||||
count = rle->count; | count = rle->count; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
return (err); | return (err); | ||||
/* | /* | ||||
* If this is a memory resource, map it into the kernel. | * If this is a memory resource, map it into the kernel. | ||||
*/ | */ | ||||
if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { | if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { | ||||
paddr = (bus_addr_t)rman_get_start(r); | paddr = (bus_addr_t)rman_get_start(r); | ||||
psize = (bus_size_t)rman_get_size(r); | psize = (bus_size_t)rman_get_size(r); | ||||
if (paddr + psize > BUS_SPACE_MAXADDR) { | |||||
jhb: The rman should have BUS_SPACE_MAXADDR set for the end of its region in nexus_attach() and this… | |||||
rman_deactivate_resource(r); | |||||
return (ENOMEM); | |||||
} | |||||
err = bus_space_map(&memmap_bus, paddr, psize, 0, &vaddr); | err = bus_space_map(&memmap_bus, paddr, psize, 0, &vaddr); | ||||
if (err != 0) { | if (err != 0) { | ||||
rman_deactivate_resource(r); | rman_deactivate_resource(r); | ||||
return (err); | return (err); | ||||
} | } | ||||
rman_set_bustag(r, &memmap_bus); | rman_set_bustag(r, &memmap_bus); | ||||
rman_set_virtual(r, (void *)vaddr); | rman_set_virtual(r, (void *)vaddr); | ||||
rman_set_bushandle(r, vaddr); | rman_set_bushandle(r, vaddr); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static struct resource_list * | static struct resource_list * | ||||
nexus_get_reslist(device_t dev, device_t child) | nexus_get_reslist(device_t dev, device_t child) | ||||
{ | { | ||||
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; | ||||
/* XXX this should return a success/failure indicator */ | /* XXX this should return a success/failure indicator */ | ||||
resource_list_add(rl, type, rid, start, start + count - 1, count); | resource_list_add(rl, type, rid, start, start + count - 1, count); | ||||
return(0); | return(0); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
The rman should have BUS_SPACE_MAXADDR set for the end of its region in nexus_attach() and this check should be removed.