void pciaddr_resource_allocate(struct pcibios_softc *sc, pci_chipset_tag_t pc, pcitag_t tag) { if (pcibios_flags & PCIBIOS_VERBOSE) pciaddr_print_devid(pc, tag); pciaddr_resource_manage(sc, pc, tag, pciaddr_do_resource_allocate); }
void pciaddr_resource_reserve(struct shpcic_softc *sc, pci_chipset_tag_t pc, pcitag_t tag) { if (pcibr_flags & PCIBR_VERBOSE) pciaddr_print_devid(pc, tag); pciaddr_resource_manage(sc, pc, tag, pciaddr_do_resource_reserve); }
static void pciaddr_resource_allocate(pci_chipset_tag_t pc, pcitag_t tag, void *context) { pciaddr_print_devid(pc, tag); pciaddr_resource_manage(pc, tag, pciaddr_do_resource_allocate, &pciaddr); }
int pciaddr_do_resource_allocate(struct shpcic_softc *sc, pci_chipset_tag_t pc, pcitag_t tag, int mapreg, struct extent *ex, int type, bus_addr_t *addr, bus_size_t size) { bus_addr_t start; int error; if (type == PCI_MAPREG_TYPE_IO) { if ((*addr & PCIADDR_PORT_END) != 0) return (0); } else if (*addr) /* no need to allocate */ return (0); /* XXX Don't allocate if device is AGP device to avoid conflict. */ if (pciaddr_device_is_agp(pc, tag)) return (0); start = (type == PCI_MAPREG_TYPE_MEM ? sc->sc_membus_space.bus_base : sc->sc_iobus_space.bus_base); if (start < ex->ex_start || start + size - 1 >= ex->ex_end) { PCIBIOS_PRINTV(("No available resources. fixup failed\n")); return (1); } error = extent_alloc_subregion(ex, start, ex->ex_end, size, size, 0, 0, EX_FAST|EX_NOWAIT|EX_MALLOCOK, addr); if (error) { PCIBIOS_PRINTV(("No available resources. fixup failed\n")); return (1); } /* write new address to PCI device configuration header */ pci_conf_write(pc, tag, mapreg, *addr); /* check */ if (pcibr_flags & PCIBR_VERBOSE) { printf("pci_addr_fixup: "); pciaddr_print_devid(pc, tag); } if (pciaddr_ioaddr(pci_conf_read(pc, tag, mapreg)) != *addr) { pci_conf_write(pc, tag, mapreg, 0); /* clear */ printf("fixup failed. (new address=%#lx)\n", *addr); return (1); } if (pcibr_flags & PCIBR_VERBOSE) printf("new address 0x%08lx\n", *addr); return (0); }
static int pciaddr_do_resource_allocate(pci_chipset_tag_t pc, pcitag_t tag, int mapreg, void *ctx, int type, bus_addr_t *addr, bus_size_t size) { struct pciaddr *pciaddrmap = (struct pciaddr *)ctx; bus_addr_t start; int error; struct extent *ex; if (*addr != 0) /* no need to allocate */ return 0; ex = (type == PCI_MAPREG_TYPE_MEM ? pciaddrmap->extent_mem : pciaddrmap->extent_port); /* XXX Don't allocate if device is AGP device to avoid conflict. */ if (device_is_agp(pc, tag)) return 0; start = (type == PCI_MAPREG_TYPE_MEM ? pciaddrmap->mem_alloc_start : pciaddrmap->port_alloc_start); if (start < ex->ex_start || start + size - 1 >= ex->ex_end) { aprint_debug("No available resources. fixup failed\n"); return 1; } error = extent_alloc_subregion(ex, start, ex->ex_end, size, size, 0, EX_FAST|EX_NOWAIT|EX_MALLOCOK, (u_long *)addr); if (error) { aprint_debug("No available resources. fixup failed\n"); return 1; } /* write new address to PCI device configuration header */ pci_conf_write(pc, tag, mapreg, *addr); /* check */ aprint_debug("pci_addr_fixup: "); pciaddr_print_devid(pc, tag); if (pciaddr_ioaddr(pci_conf_read(pc, tag, mapreg)) != *addr) { pci_conf_write(pc, tag, mapreg, 0); /* clear */ aprint_error("fixup failed. (new address=%#x)\n", (unsigned)*addr); return 1; } aprint_debug("new address 0x%08x\n", (unsigned)*addr); return 0; }