Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sparc64/pci/apb.c
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | if (pci_get_vendor(dev) == 0x108e && /* Sun */ | ||||
pci_get_device(dev) == 0x5000) { /* APB */ | pci_get_device(dev) == 0x5000) { /* APB */ | ||||
device_set_desc(dev, "APB PCI-PCI bridge"); | device_set_desc(dev, "APB PCI-PCI bridge"); | ||||
return (0); | return (0); | ||||
} | } | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
static void | static void | ||||
apb_map_print(uint8_t map, u_long scale) | apb_map_print(uint8_t map, rman_res_t scale) | ||||
{ | { | ||||
int i, first; | int i, first; | ||||
for (first = 1, i = 0; i < 8; i++) { | for (first = 1, i = 0; i < 8; i++) { | ||||
if ((map & (1 << i)) != 0) { | if ((map & (1 << i)) != 0) { | ||||
printf("%s0x%lx-0x%lx", first ? "" : ", ", | printf("%s0x%lx-0x%lx", first ? "" : ", ", | ||||
i * scale, (i + 1) * scale - 1); | i * scale, (i + 1) * scale - 1); | ||||
first = 0; | first = 0; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
apb_checkrange(uint8_t map, u_long scale, u_long start, u_long end) | apb_checkrange(uint8_t map, rman_res_t scale, rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
int i, ei; | int i, ei; | ||||
i = start / scale; | i = start / scale; | ||||
ei = end / scale; | ei = end / scale; | ||||
if (i > 7 || ei > 7) | if (i > 7 || ei > 7) | ||||
return (0); | return (0); | ||||
for (; i <= ei; i++) | for (; i <= ei; i++) | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* We have to trap resource allocation requests and ensure that the bridge | * We have to trap resource allocation requests and ensure that the bridge | ||||
* is set up to, or capable of handling them. | * is set up to, or capable of handling them. | ||||
*/ | */ | ||||
static struct resource * | static struct resource * | ||||
apb_alloc_resource(device_t dev, device_t child, int type, int *rid, | apb_alloc_resource(device_t dev, 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 apb_softc *sc; | struct apb_softc *sc; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
/* | /* | ||||
* If this is a "default" allocation against this rid, we can't work | * If this is a "default" allocation against this rid, we can't work | ||||
* out where it's coming from (we should actually never see these) so | * out where it's coming from (we should actually never see these) so | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | passup: | ||||
* Bridge is OK decoding this resource, so pass it up. | * Bridge is OK decoding this resource, so pass it up. | ||||
*/ | */ | ||||
return (bus_generic_alloc_resource(dev, child, type, rid, start, end, | return (bus_generic_alloc_resource(dev, child, type, rid, start, end, | ||||
count, flags)); | count, flags)); | ||||
} | } | ||||
static int | static int | ||||
apb_adjust_resource(device_t dev, device_t child, int type, | apb_adjust_resource(device_t dev, device_t child, int type, | ||||
struct resource *r, u_long start, u_long end) | struct resource *r, rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
struct apb_softc *sc; | struct apb_softc *sc; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end)) | if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end)) | ||||
return (ENXIO); | return (ENXIO); | ||||
break; | break; | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, end)) | if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, end)) | ||||
return (ENXIO); | return (ENXIO); | ||||
break; | break; | ||||
} | } | ||||
return (bus_generic_adjust_resource(dev, child, type, r, start, end)); | return (bus_generic_adjust_resource(dev, child, type, r, start, end)); | ||||
} | } |