Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/sparc Introduce mspcic_{read, write}_N instead...



details:   https://anonhg.NetBSD.org/src/rev/7327e47f6512
branches:  trunk
changeset: 584561:7327e47f6512
user:      uwe <uwe%NetBSD.org@localhost>
date:      Fri Sep 23 23:22:57 2005 +0000

description:
Introduce mspcic_{read,write}_N instead of using struct syntax.  This
is the first step to make PCIC run without byteswapping - which is
necessary for X server support.  Current macros are still just a
kludgy shim over struct syntax, but accesses to PCIC in the .c files
are now marked up properly.

diffstat:

 sys/arch/sparc/sparc/autoconf.c     |  10 ++----
 sys/arch/sparc/sparc/intr.c         |  19 +++++--------
 sys/arch/sparc/sparc/msiiep.c       |  50 ++++++++++++++++++------------------
 sys/arch/sparc/sparc/msiiepreg.h    |  18 ++++++++++++-
 sys/arch/sparc/sparc/timer_msiiep.c |  33 ++++++++++--------------
 5 files changed, 68 insertions(+), 62 deletions(-)

diffs (truncated from 390 to 300 lines):

diff -r bea0268573fc -r 7327e47f6512 sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c   Fri Sep 23 22:27:14 2005 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c   Fri Sep 23 23:22:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.210 2005/06/16 04:17:49 briggs Exp $ */
+/*     $NetBSD: autoconf.c,v 1.211 2005/09/23 23:22:57 uwe Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.210 2005/06/16 04:17:49 briggs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.211 2005/09/23 23:22:57 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -441,8 +441,6 @@
 
 
 #if defined(SUN4M) && defined(MSIIEP)
-#define msiiep ((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)
-
 /*
  * On ms-IIep all the interrupt registers, counters etc
  * are PCIC registers, so we need to map it early.
@@ -469,7 +467,7 @@
                panic("bootstrap: unable to map ms-IIep pcic registers");
 
        /* verify that it's PCIC (it's still little-endian at this point) */
-       id = le32toh(msiiep->pcic_id);
+       id = le32toh(mspcic_read_4(pcic_id));
        if (PCI_VENDOR(id) != PCI_VENDOR_SUN
            && PCI_PRODUCT(id) != PCI_PRODUCT_SUN_MS_IIep)
                panic("bootstrap: PCI id %08x", id);
@@ -478,7 +476,7 @@
        msiiep_swap_endian(1);
 
        /* sanity check (it's big-endian now!) */
-       id = msiiep->pcic_id;
+       id = mspcic_read_4(pcic_id);
        if (PCI_VENDOR(id) != PCI_VENDOR_SUN
            && PCI_PRODUCT(id) != PCI_PRODUCT_SUN_MS_IIep)
                panic("bootstrap: PCI id %08x (big-endian mode)", id);
diff -r bea0268573fc -r 7327e47f6512 sys/arch/sparc/sparc/intr.c
--- a/sys/arch/sparc/sparc/intr.c       Fri Sep 23 22:27:14 2005 +0000
+++ b/sys/arch/sparc/sparc/intr.c       Fri Sep 23 23:22:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.88 2005/09/10 01:27:54 uwe Exp $ */
+/*     $NetBSD: intr.c,v 1.89 2005/09/23 23:22:57 uwe Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.88 2005/09/10 01:27:54 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.89 2005/09/23 23:22:57 uwe Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -394,9 +394,6 @@
 
 #include <sparc/sparc/msiiepreg.h>
 
-/* ms-IIep PCIC registers are mapped at fixed VA */
-#define mspcic ((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)
-
 void   nmi_hard_msiiep(void);
 void   nmi_soft_msiiep(void);
 
@@ -409,7 +406,7 @@
        char bits[128];
        int fatal = 0;
 
-       si = mspcic->pcic_sys_ipr;
+       si = mspcic_read_4(pcic_sys_ipr);
        printf("NMI: system interrupts: %s\n",
               bitmask_snprintf(si, MSIIEP_SYS_IPR_BITS, bits, sizeof(bits)));
 
@@ -437,7 +434,7 @@
                fatal = 0;
        }
 
-       byteswap = mspcic->pcic_pio_ctrl & MSIIEP_PIO_CTRL_BIG_ENDIAN;
+       byteswap = mspcic_read_1(pcic_pio_ctrl) & MSIIEP_PIO_CTRL_BIG_ENDIAN;
 
        if (si & MSIIEP_SYS_IPR_SERR) { /* XXX */
                printf("serr#\n");
@@ -445,7 +442,7 @@
        }
 
        if (si & MSIIEP_SYS_IPR_DMA_ERR) {
-               uint32_t iotlb_err_addr = mspcic->pcic_iotlb_err_addr;
+               uint32_t iotlb_err_addr = mspcic_read_4(pcic_iotlb_err_addr);
 
                if (byteswap)
                        iotlb_err_addr = bswap32(iotlb_err_addr);
@@ -455,13 +452,13 @@
        }
 
        if (si & MSIIEP_SYS_IPR_PIO_ERR) {
-               uint32_t pio_err_addr = mspcic->pcic_pio_err_addr;
+               uint32_t pio_err_addr = mspcic_read_4(pcic_pio_err_addr);
 
                if (byteswap)
                        pio_err_addr = bswap32(pio_err_addr);
 
                printf("pio: addr=%08x, cmd=%x\n",
-                      pio_err_addr, mspcic->pcic_pio_err_cmd);
+                      pio_err_addr, mspcic_read_1(pcic_pio_err_cmd));
                fatal = 0;
        }
 
@@ -469,7 +466,7 @@
                panic("nmi");
 
        /* Clear the NMI if it was PCIC related */
-       mspcic->pcic_sys_ipr_clr = MSIIEP_SYS_IPR_CLR_ALL;
+       mspcic_write_1(pcic_sys_ipr_clr, MSIIEP_SYS_IPR_CLR_ALL);
 }
 
 
diff -r bea0268573fc -r 7327e47f6512 sys/arch/sparc/sparc/msiiep.c
--- a/sys/arch/sparc/sparc/msiiep.c     Fri Sep 23 22:27:14 2005 +0000
+++ b/sys/arch/sparc/sparc/msiiep.c     Fri Sep 23 23:22:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msiiep.c,v 1.25 2005/09/10 02:22:33 uwe Exp $ */
+/*     $NetBSD: msiiep.c,v 1.26 2005/09/23 23:22:57 uwe Exp $ */
 
 /*
  * Copyright (c) 2001 Valeriy E. Ushakov
@@ -27,7 +27,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1.25 2005/09/10 02:22:33 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1.26 2005/09/23 23:22:57 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -81,12 +81,6 @@
     mspcic_match, mspcic_attach, NULL, NULL);
 
 /**
- * ms-IIep PCIC registers are mapped at fixed VA
- */
-#define mspcic ((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)
-
-
-/**
  * Only one PCI controller per MS-IIep and only one MS-IIep per system
  * so don't bother with malloc'ing our tags.
  */
@@ -193,7 +187,7 @@
         * bootstrap code maps them at a fixed va, MSIIEP_PCIC_VA, and
         * switches the endian-swapping mode on.
         */
-       id = mspcic->pcic_id;
+       id = mspcic_read_4(pcic_id);
        if (PCI_VENDOR(id) != PCI_VENDOR_SUN
            && PCI_PRODUCT(id) != PCI_PRODUCT_SUN_MS_IIep)
                panic("msiiep_match: id %08x", id);
@@ -234,15 +228,15 @@
 {
        uint8_t pioctl;
 
-       pioctl = mspcic->pcic_pio_ctrl;
+       pioctl = mspcic_read_1(pcic_pio_ctrl);
        if (on)
                pioctl |= MSIIEP_PIO_CTRL_BIG_ENDIAN;
        else
                pioctl &= ~MSIIEP_PIO_CTRL_BIG_ENDIAN;
-       mspcic->pcic_pio_ctrl = pioctl;
+       mspcic_write_1(pcic_pio_ctrl, pioctl);
 
        /* read it back to make sure transaction completed */
-       pioctl = mspcic->pcic_pio_ctrl;
+       pioctl = mspcic_read_1(pcic_pio_ctrl);
 }
 
 
@@ -286,8 +280,8 @@
        sc->sc_bh = (bus_space_handle_t)MSIIEP_PCIC_VA;
 
        /* print our PCI device info and bus clock frequency */
-       pci_devinfo(mspcic->pcic_id, mspcic->pcic_class, 0, devinfo,
-           sizeof(devinfo));
+       pci_devinfo(mspcic_read_4(pcic_id), mspcic_read_4(pcic_class), 0,
+                   devinfo, sizeof(devinfo));
        printf(": %s: clock = %s MHz\n", devinfo, clockfreq(sc->sc_clockfreq));
 
        mspcic_init_maps();
@@ -357,9 +351,9 @@
                return (-1);
 
        if (line < 4) {
-               intrmap = mspcic->pcic_intr_asgn_sel;
+               intrmap = mspcic_read_2(pcic_intr_asgn_sel);
        } else {
-               intrmap = mspcic->pcic_intr_asgn_sel_hi;
+               intrmap = mspcic_read_2(pcic_intr_asgn_sel_hi);
                line -= 4;
        }
        return ((intrmap >> (line * 4)) & 0xf);
@@ -403,33 +397,39 @@
 
 #ifdef DEBUG
        printf("mspcic0: SMBAR0 %02x  PMBAR0 %02x  MSIZE0 %02x\n",
-              mspcic->pcic_smbar0, mspcic->pcic_pmbar0, mspcic->pcic_msize0);
+              mspcic_read_1(pcic_smbar0), mspcic_read_1(pcic_pmbar0),
+              mspcic_read_1(pcic_msize0));
        printf("mspcic0: SMBAR1 %02x  PMBAR1 %02x  MSIZE1 %02x\n",
-              mspcic->pcic_smbar1, mspcic->pcic_pmbar1, mspcic->pcic_msize1);
+              mspcic_read_1(pcic_smbar1), mspcic_read_1(pcic_pmbar1),
+              mspcic_read_1(pcic_msize1));
        printf("mspcic0: SIBAR  %02x  PIBAR  %02x  IOSIZE %02x\n",
-              mspcic->pcic_sibar, mspcic->pcic_pibar, mspcic->pcic_iosize);
+              mspcic_read_1(pcic_sibar), mspcic_read_1(pcic_pibar),
+              mspcic_read_1(pcic_iosize));
 #endif
        nmem = nio = 1;
 
        m0 = &mspcic_pci_memmap[nmem];
-       mspcic_pci_map_from_reg(m0, mspcic->pcic_smbar0, mspcic->pcic_pmbar0,
-                               mspcic->pcic_msize0);
+       mspcic_pci_map_from_reg(m0,
+               mspcic_read_1(pcic_smbar0), mspcic_read_1(pcic_pmbar0),
+               mspcic_read_1(pcic_msize0));
        if (OVERLAP_FIXED(m0))
                m0 = NULL;
        else
                ++nmem;
 
        m1 = &mspcic_pci_memmap[nmem];
-       mspcic_pci_map_from_reg(m1, mspcic->pcic_smbar1, mspcic->pcic_pmbar1,
-                               mspcic->pcic_msize1);
+       mspcic_pci_map_from_reg(m1,
+               mspcic_read_1(pcic_smbar1), mspcic_read_1(pcic_pmbar1),
+               mspcic_read_1(pcic_msize1));
        if (OVERLAP_FIXED(m1) || OVERLAP_MAP(m1, m0))
                m1 = NULL;
        else
                ++nmem;
 
        io = &mspcic_pci_iomap[nio];
-       mspcic_pci_map_from_reg(io, mspcic->pcic_sibar, mspcic->pcic_pibar,
-                               mspcic->pcic_iosize);
+       mspcic_pci_map_from_reg(io,
+               mspcic_read_1(pcic_sibar), mspcic_read_1(pcic_pibar),
+               mspcic_read_1(pcic_iosize));
        if (OVERLAP_FIXED(io) || OVERLAP_MAP(io, m0) || OVERLAP_MAP(io, m1))
                io = NULL;
        else
diff -r bea0268573fc -r 7327e47f6512 sys/arch/sparc/sparc/msiiepreg.h
--- a/sys/arch/sparc/sparc/msiiepreg.h  Fri Sep 23 22:27:14 2005 +0000
+++ b/sys/arch/sparc/sparc/msiiepreg.h  Fri Sep 23 23:22:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msiiepreg.h,v 1.3 2005/09/10 01:01:40 uwe Exp $ */
+/*     $NetBSD: msiiepreg.h,v 1.4 2005/09/23 23:22:57 uwe Exp $ */
 
 /*
  * Copyright (c) 2001 Valeriy E. Ushakov
@@ -225,4 +225,20 @@
        uint32_t        pcic_unused_pad[11];
 };
 
+
+/* XXX: these are temporary hacks to for the conversion of the sources */
+#define mspcic_read_1(reg) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg)
+#define mspcic_read_2(reg) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg)
+#define mspcic_read_4(reg) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg)
+
+#define mspcic_write_1(reg, val) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg) = (val)
+#define mspcic_write_2(reg, val) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg) = (val)
+#define mspcic_write_4(reg, val) \
+       (((volatile struct msiiep_pcic_reg *)MSIIEP_PCIC_VA)->reg) = (val)
+
 #endif /* _SPARC_MSIIEP_REG_H_ */
diff -r bea0268573fc -r 7327e47f6512 sys/arch/sparc/sparc/timer_msiiep.c
--- a/sys/arch/sparc/sparc/timer_msiiep.c       Fri Sep 23 22:27:14 2005 +0000
+++ b/sys/arch/sparc/sparc/timer_msiiep.c       Fri Sep 23 23:22:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: timer_msiiep.c,v 1.14 2004/07/01 10:23:41 pk Exp $     */
+/*     $NetBSD: timer_msiiep.c,v 1.15 2005/09/23 23:22:57 uwe Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.14 2004/07/01 10:23:41 pk Exp $");



Home | Main Index | Thread Index | Old Index