diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/i386/i386/rbus_machdep.c | 63 | ||||
-rw-r--r-- | sys/arch/i386/pci/pci_addr_fixup.c | 37 | ||||
-rw-r--r-- | sys/arch/i386/pci/pcibiosvar.h | 6 |
3 files changed, 49 insertions, 57 deletions
diff --git a/sys/arch/i386/i386/rbus_machdep.c b/sys/arch/i386/i386/rbus_machdep.c index 9d058a69911..292dc200f03 100644 --- a/sys/arch/i386/i386/rbus_machdep.c +++ b/sys/arch/i386/i386/rbus_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbus_machdep.c,v 1.6 2001/01/24 23:40:25 mickey Exp $ */ +/* $OpenBSD: rbus_machdep.c,v 1.7 2001/01/25 01:00:52 mickey Exp $ */ /* $NetBSD: rbus_machdep.c,v 1.2 1999/10/15 06:43:06 haya Exp $ */ /* @@ -147,33 +147,9 @@ rbus_pccbb_parent_mem(pa) struct extent *ex; #if NPCIBIOS > 0 - if (!(pcibios_flags & PCIBIOS_ADDR_FIXUP)) { - struct extent_region *rp; - ex = pciaddr.extent_mem; - - /* This size is the maximum size that would be - requested by a cardbus/pcmcia device */ - size = RBUS_MEM_SIZE; - start = RBUS_MEM_START; - - /* Search the PCI I/O memory space extent for free - space that will accomidate size. Remember that the - extent stores allocated space and we're searching - for the gaps. */ - rp = ex->ex_regions.lh_first; - - /* If we're at the end or the gap between this region - and the next region big enough, then we're done */ - while (rp && start + size > rp->er_start) { - bus_addr_t new_start; - - new_start = (rp->er_end - 1 + size) & ~(size - 1); - if (new_start > start) - start = new_start; - - rp = rp->er_link.le_next; - } - } else + size = RBUS_MEM_SIZE; + start = RBUS_MEM_START; + if ((ex = pciaddr_search(PCIADDR_SEARCH_MEM, &start, size)) == NULL) #endif { extern struct extent *iomem_ex; @@ -188,7 +164,7 @@ rbus_pccbb_parent_mem(pa) * address region. * * if defined PCIBIOS_ADDR_FIXUP, PCI device using - * area which do not recognised by the kernel are + * area which is not recognised by the kernel are * already reserved. */ @@ -217,37 +193,14 @@ rbus_pccbb_parent_io(pa) bus_addr_t start; bus_size_t size; + size = RBUS_IO_SIZE; + start = RBUS_IO_START; #if NPCIBIOS > 0 - if (!(pcibios_flags & PCIBIOS_ADDR_FIXUP)) { - struct extent_region *rp; - ex = pciaddr.extent_port; - size = RBUS_IO_SIZE; - start = RBUS_IO_START; - - /* Search the PCI I/O port space extent for free space - that will accomidate size. Remember that the - extent stores allocated space and we're searching - for the gaps. */ - rp = ex->ex_regions.lh_first; - - /* If we're at the end or the gap between this region - and the next region big enough, then we're done */ - while (rp && start + size > rp->er_start) { - bus_addr_t new_start; - - new_start = (rp->er_end - 1 + size) & ~(size - 1); - if (new_start > start) - start = new_start; - - rp = rp->er_link.le_next; - } - } else + if ((ex = pciaddr_search(PCIADDR_SEARCH_IO, &start, size)) == NULL) #endif { extern struct extent *ioport_ex; ex = ioport_ex; - start = RBUS_IO_START; - size = RBUS_IO_START; } return rbus_new_root_share(pa->pa_iot, ex, start, size, 0); diff --git a/sys/arch/i386/pci/pci_addr_fixup.c b/sys/arch/i386/pci/pci_addr_fixup.c index eb63a9f4094..71afb374439 100644 --- a/sys/arch/i386/pci/pci_addr_fixup.c +++ b/sys/arch/i386/pci/pci_addr_fixup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_addr_fixup.c,v 1.6 2001/01/24 23:40:28 mickey Exp $ */ +/* $OpenBSD: pci_addr_fixup.c,v 1.7 2001/01/25 01:00:58 mickey Exp $ */ /* $NetBSD: pci_addr_fixup.c,v 1.7 2000/08/03 20:10:45 nathanw Exp $ */ /*- @@ -373,3 +373,38 @@ pciaddr_print_devid(pc, tag) printf("%03d:%02d:%d 0x%04x 0x%04x ", bus, device, function, PCI_VENDOR(id), PCI_PRODUCT(id)); } + +struct extent * +pciaddr_search(mem_port, startp, size) + int mem_port; + bus_addr_t *startp; + bus_size_t size; +{ + if (!(pcibios_flags & PCIBIOS_ADDR_FIXUP)) { + struct extent_region *rp; + struct extent *ex = mem_port? + pciaddr.extent_mem : pciaddr.extent_port; + + /* Search the PCI I/O memory space extent for free + * space that will accomodate size. Remember that the + * extent stores allocated space and we're searching + * for the gaps. + * + * If we're at the end or the gap between this region + * and the next region big enough, then we're done + */ + for (rp = LIST_FIRST(&ex->ex_regions); + rp && *startp + size > rp->er_start; + rp = LIST_NEXT(rp, er_link)) { + bus_addr_t new_start; + + new_start = (rp->er_end - 1 + size) & ~(size - 1); + if (new_start > *startp) + *startp = new_start; + } + + return (ex); + } + + return (NULL); +} diff --git a/sys/arch/i386/pci/pcibiosvar.h b/sys/arch/i386/pci/pcibiosvar.h index 85244dbd4de..9764ea2232e 100644 --- a/sys/arch/i386/pci/pcibiosvar.h +++ b/sys/arch/i386/pci/pcibiosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcibiosvar.h,v 1.4 2001/01/25 00:07:40 mickey Exp $ */ +/* $OpenBSD: pcibiosvar.h,v 1.5 2001/01/25 01:00:59 mickey Exp $ */ /* $NetBSD: pcibios.h,v 1.2 2000/04/28 17:15:16 uch Exp $ */ /* @@ -149,6 +149,10 @@ extern int pcibiosverbose; #define PCIBIOS_PRINTVN(n, arg) #endif +#define PCIADDR_SEARCH_IO 0 +#define PCIADDR_SEARCH_MEM 1 +struct extent *pciaddr_search __P((int, bus_addr_t *, bus_size_t)); + int pci_intr_fixup __P((pci_chipset_tag_t, bus_space_tag_t, u_int16_t *)); int pci_bus_fixup __P((pci_chipset_tag_t, int)); void pci_addr_fixup __P((pci_chipset_tag_t, int)); |