From d9dc2f74ef170b31c8c0542d8cd7a53810b766cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Wed, 22 Feb 1995 14:17:15 +0000 Subject: [PATCH] New PCI attach code: PCI BIOS mappings are retained, except if option PCI_REMAP is specified in the kernel config file. There is now a list of attach addresses, and the first address that seems to make some device registers appear is chosen. Reviewed by: se Submitted by: wolf --- sys/dev/pci/pci.c | 176 +++++++++++++++++++++++++++++++++------------- sys/pci/pci.c | 176 +++++++++++++++++++++++++++++++++------------- 2 files changed, 254 insertions(+), 98 deletions(-) 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