diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index fe274185d30a..a3ddeb80e667 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: pci.c,v 1.9 1994/11/02 23:47:13 se Exp $ +** $Id: pci.c,v 1.14 1995/02/14 23:33:38 se Exp $ ** ** General subroutines for the PCI bus on 80*86 systems. ** pci_configure () @@ -36,6 +36,8 @@ *************************************************************************** */ +#define PCI_PATCHLEVEL "pl2 95/02/21" + #include #if NPCI > 0 @@ -104,16 +106,27 @@ static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize); /*-------------------------------------------------------- ** ** The pci devices can be mapped to any address. -** As default we start at the last gigabyte. +** This is a list of possible starting addresses. +** It can be prepended by a config option. ** **-------------------------------------------------------- */ -#ifndef PCI_PMEM_START -#define PCI_PMEM_START 0xc0000000 +static u_long pci_stable[] = { +#ifdef PCI_PMEM_START + (PCI_PMEM_START), #endif + 0xf1000000, + 0x53900000, + 0xc0000000, + 0x81000000, + 0x0f000000, +}; + +static vm_offset_t pci_paddr = 0; +static vm_offset_t pci_pold = 0; +static vm_offset_t pci_pidx = 0; -static vm_offset_t pci_paddr = PCI_PMEM_START; /*-------------------------------------------------------- ** @@ -175,7 +188,6 @@ void pci_configure() int pciint; int irq; char* name=0; - vm_offset_t old_addr=pci_paddr; u_short old_ioaddr=pci_ioaddr; int dvi; @@ -204,8 +216,8 @@ void pci_configure() /* ** hello world .. */ - + pci_pold=pci_paddr; for (bus=0;bus= sizeof(pci_stable)/sizeof(u_long)) { + printf ("pci_map_mem: out of start addresses.\n"); + return (0); + }; + + pci_paddr = pci_stable[pci_pidx++]; + pci_pold = 0; + + if (pci_pidx>1) + printf ("\t(retry at 0x%x)\n", + (unsigned) pci_paddr); + }; /* ** align physical address to virtual size */ @@ -568,53 +616,83 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa) if ((data = pci_paddr % vsize)) pci_paddr += vsize - data; - vaddr = (vm_offset_t) pmap_mapdev (pci_paddr, vsize); - + if (!pci_pold) + pci_pold = pci_paddr; + + /* + ** set physical mapping address, + ** and reserve physical address range + */ + + paddr = pci_paddr; + pci_paddr += vsize; + +domap: + vaddr = (vm_offset_t) pmap_mapdev (paddr, vsize); if (!vaddr) return (0); - + #ifndef PCI_QUIET /* ** display values. */ printf ("\treg%d: virtual=0x%lx physical=0x%lx\n", - (unsigned) reg, (u_long)vaddr, (u_long)pci_paddr); + (unsigned) reg, (u_long)vaddr, (u_long)paddr); #endif /* ** probe for already mapped device. */ - for (i=0; i #if NPCI > 0 @@ -104,16 +106,27 @@ static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize); /*-------------------------------------------------------- ** ** The pci devices can be mapped to any address. -** As default we start at the last gigabyte. +** This is a list of possible starting addresses. +** It can be prepended by a config option. ** **-------------------------------------------------------- */ -#ifndef PCI_PMEM_START -#define PCI_PMEM_START 0xc0000000 +static u_long pci_stable[] = { +#ifdef PCI_PMEM_START + (PCI_PMEM_START), #endif + 0xf1000000, + 0x53900000, + 0xc0000000, + 0x81000000, + 0x0f000000, +}; + +static vm_offset_t pci_paddr = 0; +static vm_offset_t pci_pold = 0; +static vm_offset_t pci_pidx = 0; -static vm_offset_t pci_paddr = PCI_PMEM_START; /*-------------------------------------------------------- ** @@ -175,7 +188,6 @@ void pci_configure() int pciint; int irq; char* name=0; - vm_offset_t old_addr=pci_paddr; u_short old_ioaddr=pci_ioaddr; int dvi; @@ -204,8 +216,8 @@ void pci_configure() /* ** hello world .. */ - + pci_pold=pci_paddr; for (bus=0;bus= sizeof(pci_stable)/sizeof(u_long)) { + printf ("pci_map_mem: out of start addresses.\n"); + return (0); + }; + + pci_paddr = pci_stable[pci_pidx++]; + pci_pold = 0; + + if (pci_pidx>1) + printf ("\t(retry at 0x%x)\n", + (unsigned) pci_paddr); + }; /* ** align physical address to virtual size */ @@ -568,53 +616,83 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa) if ((data = pci_paddr % vsize)) pci_paddr += vsize - data; - vaddr = (vm_offset_t) pmap_mapdev (pci_paddr, vsize); - + if (!pci_pold) + pci_pold = pci_paddr; + + /* + ** set physical mapping address, + ** and reserve physical address range + */ + + paddr = pci_paddr; + pci_paddr += vsize; + +domap: + vaddr = (vm_offset_t) pmap_mapdev (paddr, vsize); if (!vaddr) return (0); - + #ifndef PCI_QUIET /* ** display values. */ printf ("\treg%d: virtual=0x%lx physical=0x%lx\n", - (unsigned) reg, (u_long)vaddr, (u_long)pci_paddr); + (unsigned) reg, (u_long)vaddr, (u_long)paddr); #endif /* ** probe for already mapped device. */ - for (i=0; i