void pci_bridge_foreach(pci_chipset_tag_t pc, int minbus, int maxbus, void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *ctx) { struct pci_bridge_hook_arg bridge_hook; bridge_hook.func = func; bridge_hook.arg = ctx; pci_device_foreach_min(pc, minbus, maxbus, pci_bridge_hook, &bridge_hook); }
void pci_addr_fixup(pci_chipset_tag_t pc, int maxbus) { extern paddr_t avail_end; const char *verbose_header = "[%s]-----------------------\n" " device vendor product\n" " register space address size\n" "--------------------------------------------\n"; const char *verbose_footer = "--------------------------[%3d devices bogus]\n"; const struct { bus_addr_t start; bus_size_t size; const char *name; } system_reserve [] = { { 0xfec00000, 0x100000, "I/O APIC" }, { 0xfee00000, 0x100000, "Local APIC" }, { 0xfffe0000, 0x20000, "BIOS PROM" }, { 0, 0, 0 }, /* terminator */ }, *srp; paddr_t start; int error; pciaddr.extent_mem = extent_create("PCI I/O memory space", PCIADDR_MEM_START, PCIADDR_MEM_END, 0, 0, EX_NOWAIT); KASSERT(pciaddr.extent_mem); pciaddr.extent_port = extent_create("PCI I/O port space", PCIADDR_PORT_START, PCIADDR_PORT_END, 0, 0, EX_NOWAIT); KASSERT(pciaddr.extent_port); /* * 1. check & reserve system BIOS setting. */ aprint_debug(verbose_header, "System BIOS Setting"); pci_device_foreach(pc, maxbus, pciaddr_resource_reserve, NULL); aprint_debug(verbose_footer, pciaddr.nbogus); /* * 2. reserve non-PCI area. */ for (srp = system_reserve; srp->size; srp++) { error = extent_alloc_region(pciaddr.extent_mem, srp->start, srp->size, EX_NOWAIT| EX_MALLOCOK); if (error != 0) { aprint_error("WARNING: can't reserve area for %s.\n", srp->name); } } /* * 3. determine allocation space */ start = x86_round_page(avail_end + 1); if (start < PCIADDR_ISAMEM_RESERVE) start = PCIADDR_ISAMEM_RESERVE; pciaddr.mem_alloc_start = (start + 0x100000 + 1) & ~(0x100000 - 1); pciaddr.port_alloc_start = PCIADDR_ISAPORT_RESERVE; aprint_debug(" Physical memory end: 0x%08x\n PCI memory mapped I/O " "space start: 0x%08x\n", (unsigned)avail_end, (unsigned)pciaddr.mem_alloc_start); if (pciaddr.nbogus == 0) return; /* no need to fixup */ /* * 4. do fixup */ aprint_debug(verbose_header, "PCIBIOS fixup stage"); pciaddr.nbogus = 0; pci_device_foreach_min(pc, 0, maxbus, pciaddr_resource_allocate, NULL); aprint_debug(verbose_footer, pciaddr.nbogus); }
void pci_device_foreach(pci_chipset_tag_t pc, int maxbus, void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *context) { pci_device_foreach_min(pc, 0, maxbus, func, context); }