void pci_addr_fixup(void *v, int maxbus) { struct shpcic_softc *sc = v; const char *verbose_header = "[%s]-----------------------\n" " device vendor product\n" " register space address size\n" "--------------------------------------------\n"; const char *verbose_footer = "--------------------------[%3d devices bogus]\n"; sc->extent_mem = extent_create("PCI I/O memory space", sc->sc_membus_space.bus_base, sc->sc_membus_space.bus_base + sc->sc_membus_space.bus_size, M_DEVBUF, 0, 0, EX_NOWAIT); KASSERT(sc->extent_mem); sc->extent_port = extent_create("PCI I/O port space", sc->sc_iobus_space.bus_base, sc->sc_iobus_space.bus_base + sc->sc_iobus_space.bus_size, M_DEVBUF, 0, 0, EX_NOWAIT); KASSERT(sc->extent_port); /* * 1. check & reserve system BIOS setting. */ PCIBIOS_PRINTV((verbose_header, "System BIOS Setting")); pci_device_foreach(sc, &sc->sc_pci_chipset, maxbus, pciaddr_resource_reserve); pci_device_foreach(sc, &sc->sc_pci_chipset, maxbus, pciaddr_resource_reserve_disabled); PCIBIOS_PRINTV((verbose_footer, sc->nbogus)); { struct extent_region *rp; struct extent *ex = sc->extent_mem; for (rp = LIST_FIRST(&ex->ex_regions); rp; rp = LIST_NEXT(rp, er_link)) { } } { struct extent_region *rp; struct extent *ex = sc->extent_port; for (rp = LIST_FIRST(&ex->ex_regions); rp; rp = LIST_NEXT(rp, er_link)) { } } /* * 4. do fixup */ PCIBIOS_PRINTV((verbose_header, "PCIBIOS fixup stage")); sc->nbogus = 0; pci_device_foreach(sc, &sc->sc_pci_chipset, maxbus, pciaddr_resource_allocate); PCIBIOS_PRINTV((verbose_footer, sc->nbogus)); }
void pci_addr_fixup(struct pcibios_softc *sc, 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; 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; sc->extent_mem = extent_create("PCI I/O memory space", PCIADDR_MEM_START, PCIADDR_MEM_END, M_DEVBUF, 0, 0, EX_NOWAIT); KASSERT(sc->extent_mem); sc->extent_port = extent_create("PCI I/O port space", PCIADDR_PORT_START, PCIADDR_PORT_END, M_DEVBUF, 0, 0, EX_NOWAIT); KASSERT(sc->extent_port); /* * 1. check & reserve system BIOS setting. */ PCIBIOS_PRINTV((verbose_header, "System BIOS Setting")); pci_device_foreach(sc, pc, maxbus, pciaddr_resource_reserve); pci_device_foreach(sc, pc, maxbus, pciaddr_resource_reserve_disabled); PCIBIOS_PRINTV((verbose_footer, sc->nbogus)); /* * 2. reserve non-PCI area. */ for (srp = system_reserve; srp->size; srp++) { error = extent_alloc_region(sc->extent_mem, srp->start, srp->size, EX_NOWAIT| EX_MALLOCOK); if (error != 0) printf("WARNING: can't reserve area for %s.\n", srp->name); } /* * 3. determine allocation space */ start = round_page(avail_end + 1); if (start < PCIADDR_ISAMEM_RESERVE) start = PCIADDR_ISAMEM_RESERVE; sc->mem_alloc_start = (start + 0x100000 + 1) & ~(0x100000 - 1); sc->port_alloc_start = PCIADDR_ISAPORT_RESERVE; PCIBIOS_PRINTV((" Physical memory end: 0x%08x\n PCI memory mapped I/O " "space start: 0x%08x\n", avail_end, sc->mem_alloc_start)); /* * 4. do fixup */ PCIBIOS_PRINTV((verbose_header, "PCIBIOS fixup stage")); sc->nbogus = 0; pci_device_foreach(sc, pc, maxbus, pciaddr_resource_allocate); PCIBIOS_PRINTV((verbose_footer, sc->nbogus)); }
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); }