Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/pci/pci_subr.c
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
pcib_host_res_decodes(struct pcib_host_resources *hr, int type, rman_res_t start, | pcib_host_res_decodes(struct pcib_host_resources *hr, int type, rman_res_t start, | ||||
rman_res_t end, u_int flags) | rman_res_t end, u_int flags) | ||||
{ | { | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
int rid; | int rid; | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(hr->hr_pcib, "decoding %d %srange %#lx-%#lx\n", | device_printf(hr->hr_pcib, "decoding %d %srange %#jx-%#jx\n", | ||||
type, flags & RF_PREFETCHABLE ? "prefetchable ": "", start, | type, flags & RF_PREFETCHABLE ? "prefetchable ": "", start, | ||||
end); | end); | ||||
rid = resource_list_add_next(&hr->hr_rl, type, start, end, | rid = resource_list_add_next(&hr->hr_rl, type, start, end, | ||||
end - start + 1); | end - start + 1); | ||||
if (flags & RF_PREFETCHABLE) { | if (flags & RF_PREFETCHABLE) { | ||||
KASSERT(type == SYS_RES_MEMORY, | KASSERT(type == SYS_RES_MEMORY, | ||||
("only memory is prefetchable")); | ("only memory is prefetchable")); | ||||
rle = resource_list_find(&hr->hr_rl, type, rid); | rle = resource_list_find(&hr->hr_rl, type, rid); | ||||
Show All 27 Lines | |||||
restart: | restart: | ||||
/* Try to allocate from each decoded range. */ | /* Try to allocate from each decoded range. */ | ||||
for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) { | for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) { | ||||
if (rle->type != type) | if (rle->type != type) | ||||
continue; | continue; | ||||
if (((flags & RF_PREFETCHABLE) != 0) != | if (((flags & RF_PREFETCHABLE) != 0) != | ||||
((rle->flags & RLE_PREFETCH) != 0)) | ((rle->flags & RLE_PREFETCH) != 0)) | ||||
continue; | continue; | ||||
new_start = ulmax(start, rle->start); | new_start = ummax(start, rle->start); | ||||
new_end = ulmin(end, rle->end); | new_end = ummin(end, rle->end); | ||||
if (new_start > new_end || | if (new_start > new_end || | ||||
new_start + count - 1 > new_end || | new_start + count - 1 > new_end || | ||||
new_start + count < new_start) | new_start + count < new_start) | ||||
continue; | continue; | ||||
r = bus_generic_alloc_resource(hr->hr_pcib, dev, type, rid, | r = bus_generic_alloc_resource(hr->hr_pcib, dev, type, rid, | ||||
new_start, new_end, count, flags); | new_start, new_end, count, flags); | ||||
if (r != NULL) { | if (r != NULL) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(hr->hr_pcib, | device_printf(hr->hr_pcib, | ||||
"allocated type %d (%#lx-%#lx) for rid %x of %s\n", | "allocated type %d (%#jx-%#jx) for rid %x of %s\n", | ||||
type, rman_get_start(r), rman_get_end(r), | type, rman_get_start(r), rman_get_end(r), | ||||
*rid, pcib_child_name(dev)); | *rid, pcib_child_name(dev)); | ||||
return (r); | return (r); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* If we failed to find a prefetch range for a memory | * If we failed to find a prefetch range for a memory | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |