Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/prep Rework bus_space to conform the PReP I/O & MEM...



details:   https://anonhg.NetBSD.org/src/rev/2c340208ca52
branches:  trunk
changeset: 499699:2c340208ca52
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Nov 27 08:53:54 2000 +0000

description:
Rework bus_space to conform the PReP I/O & MEM limits.  Add a few debugging
printfs concerning interrupts.

diffstat:

 sys/arch/prep/include/bus.h     |  13 ++++++++-
 sys/arch/prep/isa/isa_machdep.c |  12 +++++---
 sys/arch/prep/pci/pci_machdep.c |   4 ++-
 sys/arch/prep/pci/pcib.c        |  29 +++++++++++++++++++---
 sys/arch/prep/prep/bus_space.c  |  52 +++++++++++++++++++++++++++++-----------
 sys/arch/prep/prep/extintr.c    |   6 +++-
 sys/arch/prep/prep/machdep.c    |  10 +++---
 sys/arch/prep/prep/mainbus.c    |   6 ++--
 8 files changed, 95 insertions(+), 37 deletions(-)

diffs (truncated from 374 to 300 lines):

diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/include/bus.h
--- a/sys/arch/prep/include/bus.h       Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/include/bus.h       Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.3 2000/06/26 04:55:57 simonb Exp $   */
+/*     $NetBSD: bus.h,v 1.4 2000/11/27 08:53:54 matt Exp $     */
 /*     $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $    */
 
 /*-
@@ -125,7 +125,16 @@
 typedef u_int32_t bus_addr_t;
 typedef u_int32_t bus_size_t;
 typedef        u_int32_t bus_space_handle_t;
-typedef        u_int32_t bus_space_tag_t;
+typedef        const struct prep_bus_space {
+       u_int32_t pbs_type;
+       bus_addr_t pbs_base;
+       bus_addr_t pbs_limit;
+} *bus_space_tag_t;
+
+extern const struct prep_bus_space prep_io_space_tag;
+extern const struct prep_bus_space prep_isa_io_space_tag;
+extern const struct prep_bus_space prep_mem_space_tag;
+extern const struct prep_bus_space prep_isa_mem_space_tag;
 
 #define BUS_SPACE_MAP_CACHEABLE         0x01
 #define BUS_SPACE_MAP_LINEAR            0x02
diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/isa/isa_machdep.c
--- a/sys/arch/prep/isa/isa_machdep.c   Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/isa/isa_machdep.c   Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_machdep.c,v 1.3 2000/11/22 08:55:35 matt Exp $     */
+/*     $NetBSD: isa_machdep.c,v 1.4 2000/11/27 08:53:55 matt Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -175,7 +175,7 @@
  * Initialize the Interrupt controller logic.
  */
 void
-init_icu()
+init_icu(int lvlmask)
 {
        int i;
        extern int intrtype[];
@@ -188,12 +188,14 @@
                        intrtype[i] = IST_EDGE;
                        break;
                default:
-                       intrtype[i] = IST_NONE;
+                       intrtype[i] = (1 << i) & lvlmask ? IST_LEVEL : IST_NONE;
                }
        }
 
-       isa_outb(IO_ELCR1, 0);
-       isa_outb(IO_ELCR2, 0);
+       printf("old elcr = 0x%02x%02x, new = 0x%04x\n",
+               isa_inb(IO_ELCR2), isa_inb(IO_ELCR1), lvlmask);
+       isa_outb(IO_ELCR1, (lvlmask >> 0) & 0xff);
+       isa_outb(IO_ELCR2, (lvlmask >> 8) & 0xff);
 
        isa_outb(IO_ICU1, 0x11);                /* program device, four bytes */
        isa_outb(IO_ICU1+1, 0);                 /* starting at this vector */
diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/pci/pci_machdep.c
--- a/sys/arch/prep/pci/pci_machdep.c   Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/pci/pci_machdep.c   Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.6 2000/06/29 07:47:53 mrg Exp $      */
+/*     $NetBSD: pci_machdep.c,v 1.7 2000/11/27 08:53:55 matt Exp $     */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -223,6 +223,7 @@
                        }
 
                        /* Fixup intr */
+#if 1
                        /* XXX: ibm_machdep : ppc830 depend */
                        switch (device) {
                        case 12:
@@ -240,6 +241,7 @@
                                pci_conf_write(pc, tag, PCI_INTERRUPT_REG,
                                    (intr & ~0xff) | line);
                        }
+#endif
                }
        }
 }
diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/pci/pcib.c
--- a/sys/arch/prep/pci/pcib.c  Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/pci/pcib.c  Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcib.c,v 1.1 2000/02/29 15:21:46 nonaka Exp $  */
+/*     $NetBSD: pcib.c,v 1.2 2000/11/27 08:53:55 matt Exp $    */
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -109,12 +109,33 @@
 {
        struct pci_attach_args *pa = aux;
        char devinfo[256];
+       u_int32_t v;
+       int lvlmask = 0;
 
        printf("\n");
 
+       v = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x40);
+       if ((v & 0x20) == 0) {
+               printf("%s: PIRQ[0-3] not used\n");
+       } else {
+               v = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x60);
+               if ((v & 0x80808080) == 0x80808080) {
+                       printf("%s: PIRQ[0-3] disabled\n");
+               } else {
+                       int i;
+                       printf("%s:", self->dv_xname);
+                       for (i = 0; i < 4; i++, v >>= 8) {
+                               if ((v & 80) == 0 && (v & 0x0f) != 0) {
+                                       printf(" PIRQ[%d]=%d", i, v & 0x0f);
+                                       lvlmask |= (1 << (v & 0x0f));
+                               }
+                       }
+                       printf("\n");
+               }
+       }
 #if NISA > 0
        /* Initialize interrupt controller */
-       init_icu();
+       init_icu(lvlmask);
 #endif
 
        /*
@@ -141,8 +162,8 @@
        bzero(&iba, sizeof(iba));
        iba.iba_busname = "isa";
        iba.iba_ic = &sc->sc_chipset;
-       iba.iba_iot = (bus_space_tag_t)PREP_BUS_SPACE_IO;
-       iba.iba_memt = (bus_space_tag_t)PREP_BUS_SPACE_MEM;
+       iba.iba_iot = &prep_isa_io_space_tag;
+       iba.iba_memt = &prep_isa_mem_space_tag;
 #if NISA > 0
        iba.iba_dmat = &isa_bus_dma_tag;
 #endif
diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/prep/bus_space.c
--- a/sys/arch/prep/prep/bus_space.c    Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/prep/bus_space.c    Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.2 2000/04/16 14:44:03 kleink Exp $     */
+/*     $NetBSD: bus_space.c,v 1.3 2000/11/27 08:53:55 matt Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -45,6 +45,18 @@
 
 #include <machine/bus.h>
 
+const struct prep_bus_space prep_io_space_tag = {
+       PREP_BUS_SPACE_IO,  0x80000000, 0x3f800000
+};
+const struct prep_bus_space prep_isa_io_space_tag = {
+       PREP_BUS_SPACE_IO,  0x80000000, 0x00010000
+};
+const struct prep_bus_space prep_mem_space_tag = {
+       PREP_BUS_SPACE_MEM, 0xC0000000, 0x3f000000
+};
+const struct prep_bus_space prep_isa_mem_space_tag = {
+       PREP_BUS_SPACE_MEM, 0xC0000000, 0x01000000
+};
 static long ioport_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
 static long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
 
@@ -56,11 +68,15 @@
 void
 prep_bus_space_init()
 {
+       int error;
 
-       ioport_ex = extent_create("ioport", 0, 0xffffffff, M_DEVBUF,
+       ioport_ex = extent_create("ioport", 0, 0x3f7fffff, M_DEVBUF,
            (caddr_t)ioport_ex_storage, sizeof(ioport_ex_storage),
            EX_NOCOALESCE|EX_NOWAIT);
-       iomem_ex = extent_create("iomem", 0x0, 0xffffffff, M_DEVBUF,
+       error = extent_alloc_region(ioport_ex, 0x10000, 0x7F0000, EX_NOWAIT);
+       if (error)
+               panic("prep_bus_space_init: can't block out reserved I/O space 0x10000-0x7fffff: error=%d\n", error);
+       iomem_ex = extent_create("iomem", 0, 0x3effffff, M_DEVBUF,
            (caddr_t)iomem_ex_storage, sizeof(iomem_ex_storage),
            EX_NOCOALESCE|EX_NOWAIT);
 }
@@ -83,16 +99,18 @@
        int error;
        struct extent *ex;
 
+       if (bpa + size > t->pbs_limit)
+               return (EINVAL);
        /*
         * Pick the appropriate extent map.
         */
-       if (t == PREP_BUS_SPACE_IO) {
+       if (t->pbs_type == PREP_BUS_SPACE_IO) {
                if (flags & BUS_SPACE_MAP_LINEAR)
                        return (EOPNOTSUPP);
                ex = ioport_ex;
-       } else if (t == PREP_BUS_SPACE_MEM)
+       } else if (t->pbs_type == PREP_BUS_SPACE_MEM) {
                ex = iomem_ex;
-       else
+       } else
                panic("prep_memio_map: bad bus space tag");
 
        /*
@@ -104,7 +122,7 @@
        if (error)
                return (error);
 
-       *bshp = t + bpa;
+       *bshp = t->pbs_base + bpa;
 
        return (0);
 }
@@ -121,19 +139,19 @@
        /*
         * Find the correct extent and bus physical address.
         */
-       if (t == PREP_BUS_SPACE_IO)
+       if (t->pbs_type == PREP_BUS_SPACE_IO)
                ex = ioport_ex;
-       else if (t == PREP_BUS_SPACE_MEM)
+       else if (t->pbs_type == PREP_BUS_SPACE_MEM)
                ex = iomem_ex;
        else
                panic("prep_memio_unmap: bad bus space tag");
 
-       bpa = bsh - t;
+       bpa = bsh - t->pbs_base;
 
        if (extent_free(ex, bpa, size,
            EX_NOWAIT | (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
                printf("prep_memio_unmap: %s 0x%lx, size 0x%lx\n",
-                   (t == PREP_BUS_SPACE_IO) ? "port" : "mem",
+                   (t->pbs_type == PREP_BUS_SPACE_IO) ? "port" : "mem",
                    (unsigned long)bpa, (unsigned long)size);
                printf("prep_memio_unmap: can't free region\n");
        }
@@ -153,13 +171,16 @@
        u_long bpa;
        int error;
 
-       if (t == PREP_BUS_SPACE_IO) {
+       if (rstart + size > t->pbs_limit)
+               return (EINVAL);
+
+       if (t->pbs_type == PREP_BUS_SPACE_IO) {
                if (flags & BUS_SPACE_MAP_LINEAR)
                        return (EOPNOTSUPP);
                ex = ioport_ex;
-       } else if (t == PREP_BUS_SPACE_MEM)
+       } else if (t->pbs_type == PREP_BUS_SPACE_MEM) {
                ex = iomem_ex;
-       else
+       } else
                panic("prep_memio_alloc: bad bus space tag");
 
        if (rstart < ex->ex_start || rend > ex->ex_end)
@@ -173,7 +194,8 @@
        if (error)
                return (error);
 
-       *bshp = *bpap = t + bpa;
+       *bpap = bpa;
+       *bshp = t->pbs_base + bpa;
 
        return (0);
 }
diff -r 4ed5325b32f2 -r 2c340208ca52 sys/arch/prep/prep/extintr.c
--- a/sys/arch/prep/prep/extintr.c      Mon Nov 27 08:39:39 2000 +0000
+++ b/sys/arch/prep/prep/extintr.c      Mon Nov 27 08:53:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extintr.c,v 1.4 2000/11/22 16:07:16 nonaka Exp $       */
+/*     $NetBSD: extintr.c,v 1.5 2000/11/27 08:53:55 matt Exp $ */
 /*     $OpenBSD: isabus.c,v 1.12 1999/06/15 02:40:05 rahnds Exp $      */
 
 /*-
@@ -110,6 +110,7 @@
 int imask[NIPL];
 int intrtype[ICU_LEN], intrmask[ICU_LEN], intrlevel[ICU_LEN];
 struct intrhand *intrhand[ICU_LEN];
+unsigned intrcnt2[ICU_LEN];
 
 int
 fakeintr(arg)
@@ -140,6 +141,7 @@
        pcpl = splhigh();       /* Turn off all */
 
        irq = isa_intr();
+       intrcnt2[irq]++;
 
        r_imen = 1 << irq;
 
@@ -188,8 +190,8 @@



Home | Main Index | Thread Index | Old Index