Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pci/pci_pci.c
Context not available. | |||||
* ISA alias range. | * ISA alias range. | ||||
*/ | */ | ||||
static int | static int | ||||
pcib_is_isa_range(struct pcib_softc *sc, u_long start, u_long end, u_long count) | pcib_is_isa_range(struct pcib_softc *sc, rman_res_t start, rman_res_t end, | ||||
rman_res_t count) | |||||
{ | { | ||||
u_long next_alias; | rman_res_t next_alias; | ||||
if (!(sc->bridgectl & PCIB_BCR_ISA_ENABLE)) | if (!(sc->bridgectl & PCIB_BCR_ISA_ENABLE)) | ||||
return (0); | return (0); | ||||
Context not available. | |||||
alias: | alias: | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"I/O range %#lx-%#lx overlaps with an ISA alias\n", start, | "I/O range %#jx-%#jx overlaps with an ISA alias\n", start, | ||||
end); | end); | ||||
return (1); | return (1); | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
} | } | ||||
typedef void (nonisa_callback)(u_long start, u_long end, void *arg); | typedef void (nonisa_callback)(rman_res_t start, rman_res_t end, void *arg); | ||||
static void | static void | ||||
pcib_walk_nonisa_ranges(u_long start, u_long end, nonisa_callback *cb, | pcib_walk_nonisa_ranges(rman_res_t start, rman_res_t end, nonisa_callback *cb, | ||||
void *arg) | void *arg) | ||||
{ | { | ||||
u_long next_end; | rman_res_t next_end; | ||||
/* | /* | ||||
* If start is within an ISA alias range, move up to the start | * If start is within an ISA alias range, move up to the start | ||||
Context not available. | |||||
} | } | ||||
static void | static void | ||||
count_ranges(u_long start, u_long end, void *arg) | count_ranges(rman_res_t start, rman_res_t end, void *arg) | ||||
{ | { | ||||
int *countp; | int *countp; | ||||
Context not available. | |||||
}; | }; | ||||
static void | static void | ||||
alloc_ranges(u_long start, u_long end, void *arg) | alloc_ranges(rman_res_t start, rman_res_t end, void *arg) | ||||
{ | { | ||||
struct alloc_state *as; | struct alloc_state *as; | ||||
struct pcib_window *w; | struct pcib_window *w; | ||||
Context not available. | |||||
rid = w->reg; | rid = w->reg; | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(as->sc->dev, | device_printf(as->sc->dev, | ||||
"allocating non-ISA range %#lx-%#lx\n", start, end); | "allocating non-ISA range %#jx-%#jx\n", start, end); | ||||
as->res[as->count] = bus_alloc_resource(as->sc->dev, SYS_RES_IOPORT, | as->res[as->count] = bus_alloc_resource(as->sc->dev, SYS_RES_IOPORT, | ||||
&rid, start, end, end - start + 1, 0); | &rid, start, end, end - start + 1, 0); | ||||
if (as->res[as->count] == NULL) | if (as->res[as->count] == NULL) | ||||
Context not available. | |||||
} | } | ||||
static int | static int | ||||
pcib_alloc_nonisa_ranges(struct pcib_softc *sc, u_long start, u_long end) | pcib_alloc_nonisa_ranges(struct pcib_softc *sc, rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
struct alloc_state as; | struct alloc_state as; | ||||
int i, new_count; | int i, new_count; | ||||
Context not available. | |||||
char buf[64]; | char buf[64]; | ||||
int error, rid; | int error, rid; | ||||
if (max_address != (u_long)max_address) | if (max_address != (rman_res_t)max_address) | ||||
max_address = ~0ul; | max_address = ~(rman_res_t)0; | ||||
w->rman.rm_start = 0; | w->rman.rm_start = 0; | ||||
w->rman.rm_end = max_address; | w->rman.rm_end = max_address; | ||||
w->rman.rm_type = RMAN_ARRAY; | w->rman.rm_type = RMAN_ARRAY; | ||||
Context not available. | |||||
* if one exists, or a new bus range if one does not. | * if one exists, or a new bus range if one does not. | ||||
*/ | */ | ||||
rid = 0; | rid = 0; | ||||
bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0ul, ~0ul, | bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0, ~0, | ||||
min_count, 0); | min_count, 0); | ||||
if (bus->res == NULL) { | if (bus->res == NULL) { | ||||
/* | /* | ||||
Context not available. | |||||
* Fall back to just allocating a range of a single bus | * Fall back to just allocating a range of a single bus | ||||
* number. | * number. | ||||
*/ | */ | ||||
bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0ul, ~0ul, | bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0, ~0, | ||||
1, 0); | 1, 0); | ||||
} else if (rman_get_size(bus->res) < min_count) | } else if (rman_get_size(bus->res) < min_count) | ||||
/* | /* | ||||
Context not available. | |||||
static struct resource * | static struct resource * | ||||
pcib_suballoc_bus(struct pcib_secbus *bus, device_t child, int *rid, | pcib_suballoc_bus(struct pcib_secbus *bus, device_t child, 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 resource *res; | struct resource *res; | ||||
Context not available. | |||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(bus->dev, | device_printf(bus->dev, | ||||
"allocated bus range (%lu-%lu) for rid %d of %s\n", | "allocated bus range (%ju-%ju) for rid %d of %s\n", | ||||
rman_get_start(res), rman_get_end(res), *rid, | rman_get_start(res), rman_get_end(res), *rid, | ||||
pcib_child_name(child)); | pcib_child_name(child)); | ||||
rman_set_rid(res, *rid); | rman_set_rid(res, *rid); | ||||
Context not available. | |||||
* subbus. | * subbus. | ||||
*/ | */ | ||||
static int | static int | ||||
pcib_grow_subbus(struct pcib_secbus *bus, u_long new_end) | pcib_grow_subbus(struct pcib_secbus *bus, rman_res_t new_end) | ||||
{ | { | ||||
u_long old_end; | rman_res_t old_end; | ||||
int error; | int error; | ||||
old_end = rman_get_end(bus->res); | old_end = rman_get_end(bus->res); | ||||
Context not available. | |||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(bus->dev, "grew bus range to %lu-%lu\n", | device_printf(bus->dev, "grew bus range to %ju-%ju\n", | ||||
rman_get_start(bus->res), rman_get_end(bus->res)); | rman_get_start(bus->res), rman_get_end(bus->res)); | ||||
error = rman_manage_region(&bus->rman, old_end + 1, | error = rman_manage_region(&bus->rman, old_end + 1, | ||||
rman_get_end(bus->res)); | rman_get_end(bus->res)); | ||||
Context not available. | |||||
struct resource * | struct resource * | ||||
pcib_alloc_subbus(struct pcib_secbus *bus, device_t child, int *rid, | pcib_alloc_subbus(struct pcib_secbus *bus, device_t child, 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 resource *res; | struct resource *res; | ||||
u_long start_free, end_free, new_end; | rman_res_t start_free, end_free, new_end; | ||||
/* | /* | ||||
* First, see if the request can be satisified by the existing | * First, see if the request can be satisified by the existing | ||||
Context not available. | |||||
/* Finally, attempt to grow the existing resource. */ | /* Finally, attempt to grow the existing resource. */ | ||||
if (bootverbose) { | if (bootverbose) { | ||||
device_printf(bus->dev, | device_printf(bus->dev, | ||||
"attempting to grow bus range for %lu buses\n", count); | "attempting to grow bus range for %ju buses\n", count); | ||||
printf("\tback candidate range: %lu-%lu\n", start_free, | printf("\tback candidate range: %ju-%ju\n", start_free, | ||||
new_end); | new_end); | ||||
} | } | ||||
if (pcib_grow_subbus(bus, new_end) == 0) | if (pcib_grow_subbus(bus, new_end) == 0) | ||||
Context not available. | |||||
*/ | */ | ||||
static struct resource * | static struct resource * | ||||
pcib_suballoc_resource(struct pcib_softc *sc, struct pcib_window *w, | pcib_suballoc_resource(struct pcib_softc *sc, struct pcib_window *w, | ||||
device_t child, int type, int *rid, u_long start, u_long end, u_long count, | device_t child, int type, int *rid, rman_res_t start, rman_res_t end, | ||||
u_int flags) | rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct resource *res; | struct resource *res; | ||||
Context not available. | |||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"allocated %s range (%#lx-%#lx) for rid %x of %s\n", | "allocated %s range (%#jx-%#jx) for rid %x of %s\n", | ||||
w->name, rman_get_start(res), rman_get_end(res), *rid, | w->name, rman_get_start(res), rman_get_end(res), *rid, | ||||
pcib_child_name(child)); | pcib_child_name(child)); | ||||
rman_set_rid(res, *rid); | rman_set_rid(res, *rid); | ||||
Context not available. | |||||
/* Allocate a fresh resource range for an unconfigured window. */ | /* Allocate a fresh resource range for an unconfigured window. */ | ||||
static int | static int | ||||
pcib_alloc_new_window(struct pcib_softc *sc, struct pcib_window *w, int type, | pcib_alloc_new_window(struct pcib_softc *sc, struct pcib_window *w, int type, | ||||
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 resource *res; | struct resource *res; | ||||
u_long base, limit, wmask; | rman_res_t base, limit, wmask; | ||||
int rid; | int rid; | ||||
/* | /* | ||||
Context not available. | |||||
/* Try to expand an existing window to the requested base and limit. */ | /* Try to expand an existing window to the requested base and limit. */ | ||||
static int | static int | ||||
pcib_expand_window(struct pcib_softc *sc, struct pcib_window *w, int type, | pcib_expand_window(struct pcib_softc *sc, struct pcib_window *w, int type, | ||||
u_long base, u_long limit) | rman_res_t base, rman_res_t limit) | ||||
{ | { | ||||
struct resource *res; | struct resource *res; | ||||
int error, i, force_64k_base; | int error, i, force_64k_base; | ||||
Context not available. | |||||
*/ | */ | ||||
static int | static int | ||||
pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, | pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, | ||||
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) | ||||
{ | { | ||||
u_long align, start_free, end_free, front, back, wmask; | rman_res_t align, start_free, end_free, front, back, wmask; | ||||
int error; | int error; | ||||
/* | /* | ||||
Context not available. | |||||
end = w->rman.rm_end; | end = w->rman.rm_end; | ||||
if (start + count - 1 > end || start + count < start) | if (start + count - 1 > end || start + count < start) | ||||
return (EINVAL); | return (EINVAL); | ||||
wmask = (1ul << w->step) - 1; | wmask = ((rman_res_t)1 << w->step) - 1; | ||||
/* | /* | ||||
* If there is no resource at all, just try to allocate enough | * If there is no resource at all, just try to allocate enough | ||||
Context not available. | |||||
if (error) { | if (error) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"failed to allocate initial %s window (%#lx-%#lx,%#lx)\n", | "failed to allocate initial %s window (%#jx-%#jx,%#jx)\n", | ||||
w->name, start, end, count); | w->name, start, end, count); | ||||
return (error); | return (error); | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"attempting to grow %s window for (%#lx-%#lx,%#lx)\n", | "attempting to grow %s window for (%#jx-%#jx,%#jx)\n", | ||||
w->name, start, end, count); | w->name, start, end, count); | ||||
align = 1ul << RF_ALIGNMENT(flags); | align = (rman_res_t)1 << RF_ALIGNMENT(flags); | ||||
if (start < w->base) { | if (start < w->base) { | ||||
if (rman_first_free_region(&w->rman, &start_free, &end_free) != | if (rman_first_free_region(&w->rman, &start_free, &end_free) != | ||||
0 || start_free != w->base) | 0 || start_free != w->base) | ||||
Context not available. | |||||
*/ | */ | ||||
if (front >= start && front <= end_free) { | if (front >= start && front <= end_free) { | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("\tfront candidate range: %#lx-%#lx\n", | printf("\tfront candidate range: %#jx-%#jx\n", | ||||
front, end_free); | front, end_free); | ||||
front &= ~wmask; | front &= ~wmask; | ||||
front = w->base - front; | front = w->base - front; | ||||
Context not available. | |||||
*/ | */ | ||||
if (back <= end && start_free <= back) { | if (back <= end && start_free <= back) { | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("\tback candidate range: %#lx-%#lx\n", | printf("\tback candidate range: %#jx-%#jx\n", | ||||
start_free, back); | start_free, back); | ||||
back |= wmask; | back |= wmask; | ||||
back -= w->limit; | back -= w->limit; | ||||
Context not available. | |||||
*/ | */ | ||||
struct resource * | struct resource * | ||||
pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, | pcib_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 pcib_softc *sc; | struct pcib_softc *sc; | ||||
struct resource *r; | struct resource *r; | ||||
Context not available. | |||||
int | int | ||||
pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, | pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, | ||||
u_long start, u_long end) | rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
struct pcib_softc *sc; | struct pcib_softc *sc; | ||||
Context not available. | |||||
*/ | */ | ||||
struct resource * | struct resource * | ||||
pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, | pcib_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 pcib_softc *sc = device_get_softc(dev); | struct pcib_softc *sc = device_get_softc(dev); | ||||
const char *name, *suffix; | const char *name, *suffix; | ||||
Context not available. | |||||
#endif | #endif | ||||
} | } | ||||
if (end < start) { | if (end < start) { | ||||
device_printf(dev, "ioport: end (%lx) < start (%lx)\n", | device_printf(dev, "ioport: end (%jx) < start (%jx)\n", | ||||
end, start); | end, start); | ||||
start = 0; | start = 0; | ||||
end = 0; | end = 0; | ||||
Context not available. | |||||
} | } | ||||
if (!ok) { | if (!ok) { | ||||
device_printf(dev, "%s%srequested unsupported I/O " | device_printf(dev, "%s%srequested unsupported I/O " | ||||
"range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n", | "range 0x%jx-0x%jx (decoding 0x%x-0x%x)\n", | ||||
name, suffix, start, end, sc->iobase, sc->iolimit); | name, suffix, start, end, sc->iobase, sc->iolimit); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, | device_printf(dev, | ||||
"%s%srequested I/O range 0x%lx-0x%lx: in range\n", | "%s%srequested I/O range 0x%jx-0x%jx: in range\n", | ||||
name, suffix, start, end); | name, suffix, start, end); | ||||
break; | break; | ||||
Context not available. | |||||
#endif | #endif | ||||
} | } | ||||
if (end < start) { | if (end < start) { | ||||
device_printf(dev, "memory: end (%lx) < start (%lx)\n", | device_printf(dev, "memory: end (%jx) < start (%jx)\n", | ||||
end, start); | end, start); | ||||
start = 0; | start = 0; | ||||
end = 0; | end = 0; | ||||
Context not available. | |||||
} | } | ||||
if (!ok && bootverbose) | if (!ok && bootverbose) | ||||
device_printf(dev, | device_printf(dev, | ||||
"%s%srequested unsupported memory range %#lx-%#lx " | "%s%srequested unsupported memory range %#jx-%#jx " | ||||
"(decoding %#jx-%#jx, %#jx-%#jx)\n", | "(decoding %#jx-%#jx, %#jx-%#jx)\n", | ||||
name, suffix, start, end, | name, suffix, start, end, | ||||
(uintmax_t)sc->membase, (uintmax_t)sc->memlimit, | (uintmax_t)sc->membase, (uintmax_t)sc->memlimit, | ||||
Context not available. | |||||
return (NULL); | return (NULL); | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev,"%s%srequested memory range " | device_printf(dev,"%s%srequested memory range " | ||||
"0x%lx-0x%lx: good\n", | "0x%jx-0x%jx: good\n", | ||||
name, suffix, start, end); | name, suffix, start, end); | ||||
break; | break; | ||||
Context not available. |