Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/arch/i386/pci Pull up to netbsd-1-5 branch



details:   https://anonhg.NetBSD.org/src/rev/6cb9dc3c1f93
branches:  netbsd-1-5
changeset: 489036:6cb9dc3c1f93
user:      soda <soda%NetBSD.org@localhost>
date:      Thu Aug 10 22:42:04 2000 +0000

description:
Pull up to netbsd-1-5 branch
Approved by: thorpej

- define PCIBIOS_PRINTV() as pcibiosverbose printf(),
  instead of DPRINTF() in each C source.

- define PIR_DEVFUNC_{DEVICE,FUNCTION}.

- fix oversight introduced in pci_addr_fixup.c revision 1.4,
  pointed out by Michael Shalayeff <mickey%openbsd.org@localhost>.

- reserve AGP space to avoid resource conflict.

  by UCHIYAMA Yasushi <uch%netbsd.org@localhost>

- Fix a problem uncovered by rev 1.5 of pcibios.c:

  Avoid interpreting the upper 32 bits of 64-bit BARs as a 32-bit BAR.
  Otherwise, the code would assume that the value 0 was incorrect and either:
  (a) [on bus 0] "fix up" the address to some nonzero value, thus placing
      the decoded address range outside of 32-bit address space, or
  (b) [elsewhere] completely disable the device.

  The fact that this behaviour depends on the bus number of the device is
  already XXX'd.

  XXX: This will need revisiting if and when we ever want to handle a PCI bus
  XXX: with more than 32 bits of address space on an i386.

  The onboard Adaptec 7890 on my Dell Precision Workstation 410 works again.

  by Nathan J Williams <nathanw%netbsd.org@localhost>

Revisions pulled up:
 > cvs rdiff -r1.2 -r1.3 syssrc/sys/arch/i386/pci/pcibios.h
 > cvs rdiff -r1.3 -r1.5 syssrc/sys/arch/i386/pci/pcibios.c
 > cvs rdiff -r1.3 -r1.7 syssrc/sys/arch/i386/pci/pci_addr_fixup.c

diffstat:

 sys/arch/i386/pci/pci_addr_fixup.c |  88 +++++++++++++++++++++----------------
 sys/arch/i386/pci/pcibios.c        |  14 +++--
 sys/arch/i386/pci/pcibios.h        |  23 +++++++++-
 3 files changed, 81 insertions(+), 44 deletions(-)

diffs (truncated from 312 to 300 lines):

diff -r 85bbb396baea -r 6cb9dc3c1f93 sys/arch/i386/pci/pci_addr_fixup.c
--- a/sys/arch/i386/pci/pci_addr_fixup.c        Thu Aug 10 22:31:24 2000 +0000
+++ b/sys/arch/i386/pci/pci_addr_fixup.c        Thu Aug 10 22:42:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_addr_fixup.c,v 1.3 2000/05/31 16:38:55 uch Exp $   */
+/*     $NetBSD: pci_addr_fixup.c,v 1.3.2.1 2000/08/10 22:42:05 soda Exp $      */
 
 /*-
  * Copyright (c) 2000 UCHIYAMA Yasushi.  All rights reserved.
@@ -43,15 +43,6 @@
 #include <i386/pci/pcibios.h>
 #include <i386/pci/pci_addr_fixup.h>
 
-#ifdef PCIBIOSVERBOSE
-int    pcibiosverbose = 1;
-#define        DPRINTF(arg) if (pcibiosverbose) printf arg;
-#define        DPRINTFN(n, arg) if (pcibiosverbose > (n)) printf arg;
-#else
-#define        DPRINTF(arg)
-#define DPRINTFN(n, arg)
-#endif
-
 struct pciaddr pciaddr;
 
 typedef int (*pciaddr_resource_manage_func_t) 
@@ -80,9 +71,9 @@
 #define PCIADDR_ISAMEM_RESERVE (16 * 1024 * 1024)
 
 void
-pci_addr_fixup(pc, bus)
+pci_addr_fixup(pc, maxbus)
        pci_chipset_tag_t pc;
-       int bus;
+       int maxbus;
 {
        extern paddr_t avail_end;
 #ifdef PCIBIOSVERBOSE
@@ -106,7 +97,7 @@
        }, *srp;
        paddr_t start;
        int error;
-       
+
        pciaddr.extent_mem = extent_create("PCI I/O memory space",
                                           PCIADDR_MEM_START, 
                                           PCIADDR_MEM_END,
@@ -121,9 +112,9 @@
        /* 
         * 1. check & reserve system BIOS setting.
         */
-       DPRINTF((verbose_header, "System BIOS Setting"));
-       pci_device_foreach(pc, bus, pciaddr_resource_reserve);
-       DPRINTF((verbose_footer, pciaddr.nbogus));
+       PCIBIOS_PRINTV((verbose_header, "System BIOS Setting"));
+       pci_device_foreach(pc, maxbus, pciaddr_resource_reserve);
+       PCIBIOS_PRINTV((verbose_footer, pciaddr.nbogus));
 
        /* 
         * 2. reserve non-PCI area.
@@ -146,9 +137,9 @@
                start = PCIADDR_ISAMEM_RESERVE;
        pciaddr.mem_alloc_start = (start + 0x100000 + 1) & ~(0x100000 - 1);
        pciaddr.port_alloc_start = PCIADDR_ISAPORT_RESERVE;
-       DPRINTF((" Physical memory end: 0x%08x\n PCI memory mapped I/O "
-                "space start: 0x%08x\n", (unsigned)avail_end, 
-                (unsigned)pciaddr.mem_alloc_start));
+       PCIBIOS_PRINTV((" 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 */
@@ -156,10 +147,11 @@
        /* 
         * 4. do fixup 
         */
-       DPRINTF((verbose_header, "PCIBIOS fixup stage"));
+       PCIBIOS_PRINTV((verbose_header, "PCIBIOS fixup stage"));
        pciaddr.nbogus = 0;
-       pci_device_foreach(pc, bus, pciaddr_resource_allocate);
-       DPRINTF((verbose_footer, pciaddr.nbogus));
+       /* XXX bus #0 only. */
+       pci_device_foreach(pc, 0, pciaddr_resource_allocate);
+       PCIBIOS_PRINTV((verbose_footer, pciaddr.nbogus));
 
 }
 
@@ -169,7 +161,8 @@
        pcitag_t tag;
 {
 #ifdef PCIBIOSVERBOSE
-       pciaddr_print_devid(pc, tag);
+       if (pcibiosverbose)
+               pciaddr_print_devid(pc, tag);
 #endif
        pciaddr_resource_manage(pc, tag, pciaddr_do_resource_reserve);  
 }
@@ -180,7 +173,8 @@
        pcitag_t tag;
 {
 #ifdef PCIBIOSVERBOSE
-       pciaddr_print_devid(pc, tag);
+       if (pcibiosverbose)
+               pciaddr_print_devid(pc, tag);
 #endif
        pciaddr_resource_manage(pc, tag, pciaddr_do_resource_allocate);
 }
@@ -195,7 +189,7 @@
        pcireg_t val, mask;
        bus_addr_t addr;
        bus_size_t size;
-       int error, useport, usemem, mapreg, type, reg_start, reg_end;
+       int error, useport, usemem, mapreg, type, reg_start, reg_end, width;
 
        val = pci_conf_read(pc, tag, PCI_BHLC_REG);
        switch (PCI_HDRTYPE_TYPE(val)) {
@@ -218,7 +212,7 @@
        }
        error = useport = usemem = 0;
     
-       for (mapreg = reg_start; mapreg < reg_end; mapreg += 4) {
+       for (mapreg = reg_start; mapreg < reg_end; mapreg += width) {
                /* inquire PCI device bus space requirement */
                val = pci_conf_read(pc, tag, mapreg);
                pci_conf_write(pc, tag, mapreg, ~0);
@@ -227,7 +221,21 @@
                pci_conf_write(pc, tag, mapreg, val);
        
                type = PCI_MAPREG_TYPE(val);
+               width = 4;
                if (type == PCI_MAPREG_TYPE_MEM) {
+                       if (PCI_MAPREG_MEM_TYPE(val) == 
+                           PCI_MAPREG_MEM_TYPE_64BIT) {
+                               /* XXX We could examine the upper 32 bits
+                                * XXX of the BAR here, but we are totally 
+                                * XXX unprepared to handle a non-zero value, 
+                                * XXX either here or anywhere else in 
+                                * XXX i386-land. 
+                                * XXX So just arrange to not look at the
+                                * XXX upper 32 bits, lest we misinterpret
+                                * XXX it as a 32-bit BAR set to zero. 
+                                */
+                           width = 8;
+                       }
                        size = PCI_MAPREG_MEM_SIZE(mask);
                        ex = pciaddr.extent_mem;
                } else {
@@ -247,9 +255,9 @@
                /* reservation/allocation phase */
                error += (*func) (pc, tag, mapreg, ex, type, &addr, size);
 
-               DPRINTF(("\n\t%02xh %s 0x%08x 0x%08x", 
-                        mapreg, type ? "port" : "mem ", 
-                        (unsigned int)addr, (unsigned int)size));
+               PCIBIOS_PRINTV(("\n\t%02xh %s 0x%08x 0x%08x", 
+                               mapreg, type ? "port" : "mem ", 
+                               (unsigned int)addr, (unsigned int)size));
        }
     
        /* enable/disable PCI device */
@@ -265,7 +273,7 @@
        if (error)
                pciaddr.nbogus++;
 
-       DPRINTF(("\n\t\t[%s]\n", error ? "NG" : "OK"));
+       PCIBIOS_PRINTV(("\n\t\t[%s]\n", error ? "NG" : "OK"));
 }
 
 int
@@ -286,32 +294,36 @@
        start = type == PCI_MAPREG_TYPE_MEM ? pciaddr.mem_alloc_start
                : pciaddr.port_alloc_start;
        if (start < ex->ex_start || start + size - 1 >= ex->ex_end) {
-               DPRINTF(("No available resources. fixup failed\n"));
+               PCIBIOS_PRINTV(("No available resources. fixup failed\n"));
                return (1);
        }
        error = extent_alloc_subregion(ex, start, start + size - 1, size,
                                       size, 0,
                                       EX_FAST|EX_NOWAIT|EX_MALLOCOK, addr);
        if (error) {
-               DPRINTF(("No available resources. fixup failed\n"));
+               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 */
-#ifndef PCIBIOSVERBOSE
-       printf("pci_addr_fixup: ");
-       pciaddr_print_devid(pc, tag);
+#ifdef PCIBIOSVERBOSE
+       if (!pcibiosverbose)
 #endif 
+       {
+               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=%#x)\n", (unsigned)*addr);
                return (1);
        }
-#ifndef PCIBIOSVERBOSE
-       printf("new address 0x%08x\n", (unsigned)*addr);
+#ifdef PCIBIOSVERBOSE
+       if (!pcibiosverbose)
 #endif
+               printf("new address 0x%08x\n", (unsigned)*addr);
 
        return (0);
 }
@@ -332,7 +344,7 @@
 
        error = extent_alloc_region(ex, *addr, size, EX_NOWAIT| EX_MALLOCOK);
        if (error) {
-               DPRINTF(("Resource conflict.\n"));
+               PCIBIOS_PRINTV(("Resource conflict.\n"));
                pci_conf_write(pc, tag, mapreg, 0); /* clear */
                return (1);
        }
diff -r 85bbb396baea -r 6cb9dc3c1f93 sys/arch/i386/pci/pcibios.c
--- a/sys/arch/i386/pci/pcibios.c       Thu Aug 10 22:31:24 2000 +0000
+++ b/sys/arch/i386/pci/pcibios.c       Thu Aug 10 22:42:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcibios.c,v 1.3 2000/04/28 17:15:15 uch Exp $  */
+/*     $NetBSD: pcibios.c,v 1.3.6.1 2000/08/10 22:42:04 soda Exp $     */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -93,6 +93,10 @@
 
 #include <machine/bios32.h> 
 
+#ifdef PCIBIOSVERBOSE
+int    pcibiosverbose = 1;
+#endif
+
 int pcibios_present;
 
 struct pcibios_pir_header pcibios_pir_header;
@@ -210,7 +214,7 @@
 #endif
 
 #ifdef PCIBIOS_ADDR_FIXUP
-       pci_addr_fixup(NULL, 0); /* PCI bus #0 only */
+       pci_addr_fixup(NULL, pcibios_max_bus);
 #endif
 }
 
@@ -273,8 +277,8 @@
 
                printf("PCI Interrupt Router at %03d:%02d:%01d",
                    pcibios_pir_header.router_bus,
-                   (pcibios_pir_header.router_devfunc >> 3) & 0x1f,
-                   pcibios_pir_header.router_devfunc & 7);
+                   PIR_DEVFUNC_DEVICE(pcibios_pir_header.router_devfunc),
+                   PIR_DEVFUNC_FUNCTION(pcibios_pir_header.router_devfunc));
                if (pcibios_pir_header.compat_router != 0) {
                        pci_devinfo(pcibios_pir_header.compat_router, 0, 0,
                            devinfo);
@@ -469,7 +473,7 @@
                printf("PIR Entry %d:\n", i);
                printf("\tBus: %d  Device: %d\n",
                    pcibios_pir_table[i].bus,
-                   pcibios_pir_table[i].device >> 3);
+                   PIR_DEVFUNC_DEVICE(pcibios_pir_table[i].device));
                for (j = 0; j < 4; j++) {
                        printf("\t\tINT%c: link 0x%02x bitmap 0x%04x\n",
                            'A' + j,
diff -r 85bbb396baea -r 6cb9dc3c1f93 sys/arch/i386/pci/pcibios.h
--- a/sys/arch/i386/pci/pcibios.h       Thu Aug 10 22:31:24 2000 +0000
+++ b/sys/arch/i386/pci/pcibios.h       Thu Aug 10 22:42:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcibios.h,v 1.2 2000/04/28 17:15:16 uch Exp $  */
+/*     $NetBSD: pcibios.h,v 1.2.6.1 2000/08/10 22:42:04 soda Exp $     */
 
 /*
  * Copyright (c) 1999, by UCHIYAMA Yasushi
@@ -79,6 +79,9 @@
        u_int8_t        checksum;
 } __attribute__((__packed__));
 
+#define        PIR_DEVFUNC_DEVICE(devfunc)     (((devfunc) >> 3) & 0x1f)
+#define        PIR_DEVFUNC_FUNCTION(devfunc)   ((devfunc) & 7)
+
 void   pcibios_init __P((void));
 
 extern struct pcibios_pir_header pcibios_pir_header;
@@ -88,3 +91,21 @@
 
 void pci_device_foreach __P((pci_chipset_tag_t, int,
                             void (*) (pci_chipset_tag_t, pcitag_t)));
+
+#ifdef PCIBIOSVERBOSE
+extern int pcibiosverbose;
+
+#define        PCIBIOS_PRINTV(arg) \
+       do { \



Home | Main Index | Thread Index | Old Index