Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powerpc/nexus.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static device_probe_t nexus_probe; | static device_probe_t nexus_probe; | ||||
static device_attach_t nexus_attach; | static device_attach_t nexus_attach; | ||||
static bus_setup_intr_t nexus_setup_intr; | static bus_setup_intr_t nexus_setup_intr; | ||||
static bus_teardown_intr_t nexus_teardown_intr; | static bus_teardown_intr_t nexus_teardown_intr; | ||||
static bus_activate_resource_t nexus_activate_resource; | static bus_activate_resource_t nexus_activate_resource; | ||||
static bus_deactivate_resource_t nexus_deactivate_resource; | static bus_deactivate_resource_t nexus_deactivate_resource; | ||||
static int nexus_map_resource(device_t bus, device_t child, int type, | |||||
struct resource *r, | |||||
struct resource_map_request *argsp, | |||||
struct resource_map *map); | |||||
static int nexus_unmap_resource(device_t bus, device_t child, int type, | |||||
struct resource *r, struct resource_map *map); | |||||
static bus_space_tag_t nexus_get_bus_tag(device_t, device_t); | static bus_space_tag_t nexus_get_bus_tag(device_t, device_t); | ||||
static int nexus_get_cpus(device_t, device_t, enum cpu_sets, size_t, | static int nexus_get_cpus(device_t, device_t, enum cpu_sets, size_t, | ||||
cpuset_t *); | cpuset_t *); | ||||
#ifdef SMP | #ifdef SMP | ||||
static bus_bind_intr_t nexus_bind_intr; | static bus_bind_intr_t nexus_bind_intr; | ||||
#endif | #endif | ||||
static bus_config_intr_t nexus_config_intr; | static bus_config_intr_t nexus_config_intr; | ||||
static ofw_bus_map_intr_t nexus_ofw_map_intr; | static ofw_bus_map_intr_t nexus_ofw_map_intr; | ||||
static device_method_t nexus_methods[] = { | static device_method_t nexus_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, nexus_probe), | DEVMETHOD(device_probe, nexus_probe), | ||||
DEVMETHOD(device_attach, nexus_attach), | DEVMETHOD(device_attach, nexus_attach), | ||||
/* Bus interface */ | /* Bus interface */ | ||||
DEVMETHOD(bus_add_child, bus_generic_add_child), | DEVMETHOD(bus_add_child, bus_generic_add_child), | ||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource), | DEVMETHOD(bus_activate_resource, nexus_activate_resource), | ||||
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), | DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), | ||||
DEVMETHOD(bus_map_resource, nexus_map_resource), | |||||
DEVMETHOD(bus_unmap_resource, nexus_unmap_resource), | |||||
DEVMETHOD(bus_setup_intr, nexus_setup_intr), | DEVMETHOD(bus_setup_intr, nexus_setup_intr), | ||||
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), | DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), | ||||
#ifdef SMP | #ifdef SMP | ||||
DEVMETHOD(bus_bind_intr, nexus_bind_intr), | DEVMETHOD(bus_bind_intr, nexus_bind_intr), | ||||
#endif | #endif | ||||
DEVMETHOD(bus_config_intr, nexus_config_intr), | DEVMETHOD(bus_config_intr, nexus_config_intr), | ||||
DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag), | DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag), | ||||
DEVMETHOD(bus_get_cpus, nexus_get_cpus), | DEVMETHOD(bus_get_cpus, nexus_get_cpus), | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | nexus_deactivate_resource(device_t bus __unused, device_t child __unused, | ||||
if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { | if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { | ||||
bus_size_t psize; | bus_size_t psize; | ||||
psize = rman_get_size(r); | psize = rman_get_size(r); | ||||
pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize); | pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize); | ||||
} | } | ||||
return (rman_deactivate_resource(r)); | return (rman_deactivate_resource(r)); | ||||
} | |||||
static int | |||||
nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, | |||||
struct resource_map_request *argsp, struct resource_map *map) | |||||
{ | |||||
struct resource_map_request args; | |||||
rman_res_t end, length, start; | |||||
/* Resources must be active to be mapped. */ | |||||
if (!(rman_get_flags(r) & RF_ACTIVE)) | |||||
return (ENXIO); | |||||
/* Mappings are only supported on I/O and memory resources. */ | |||||
switch (type) { | |||||
case SYS_RES_IOPORT: | |||||
case SYS_RES_MEMORY: | |||||
break; | |||||
default: | |||||
return (EINVAL); | |||||
} | |||||
resource_init_map_request(&args); | |||||
if (argsp != NULL) | |||||
bcopy(argsp, &args, imin(argsp->size, args.size)); | |||||
start = rman_get_start(r) + args.offset; | |||||
if (args.length == 0) | |||||
length = rman_get_size(r); | |||||
else | |||||
length = args.length; | |||||
bryanv: Missing ident | |||||
end = start + length - 1; | |||||
if (start > rman_get_end(r) || start < rman_get_start(r)) | |||||
return (EINVAL); | |||||
if (end > rman_get_end(r) || end < start) | |||||
return (EINVAL); | |||||
/* | |||||
* If this is a memory resource, map it into the kernel. | |||||
*/ | |||||
switch (type) { | |||||
case SYS_RES_IOPORT: | |||||
panic("%s:%d SYS_RES_IOPORT handling not implemented", __func__, __LINE__); | |||||
/* XXX: untested | |||||
map->r_bushandle = start; | |||||
map->r_bustag = &bs_le_tag; | |||||
map->r_size = length; | |||||
map->r_vaddr = NULL; | |||||
*/ | |||||
break; | |||||
case SYS_RES_MEMORY: | |||||
map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr); | |||||
/* XXX: should use return of nexus_get_bus_tag? | |||||
* Currently nexus_get_bus_tag returns bs_be_tag on BE systems, | |||||
* however PCI bus layer already do byte swap transparently. | |||||
* Use of bs_be_tag here makes virtio-modern PCI configuration | |||||
alfredoAuthorUnsubmitted Done Inline Actionsactually part of this statement is wrong, (I mixed things with another issue from virtio-modern code) Use of bs_be_tag here actually makes virtio driver (net) crash/panic during attachment. alfredo: actually part of this statement is wrong, (I mixed things with another issue from virtio-modern… | |||||
* area read/write data with incorrect endian | |||||
*/ | |||||
map->r_bustag = &bs_le_tag; | |||||
map->r_size = length; | |||||
map->r_bushandle = (bus_space_handle_t)map->r_vaddr; | |||||
break; | |||||
} | |||||
return (0); | |||||
} | |||||
static int | |||||
nexus_unmap_resource(device_t bus, device_t child, int type, struct resource *r, | |||||
struct resource_map *map) | |||||
{ | |||||
/* | |||||
* If this is a memory resource, unmap it. | |||||
*/ | |||||
switch (type) { | |||||
case SYS_RES_MEMORY: | |||||
pmap_unmapdev((vm_offset_t)map->r_vaddr, map->r_size); | |||||
/* FALLTHROUGH */ | |||||
case SYS_RES_IOPORT: | |||||
break; | |||||
default: | |||||
return (EINVAL); | |||||
} | |||||
return (0); | |||||
} | } |
Missing ident