Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Split OpenPIC support into powerpc so ports only ne...



details:   https://anonhg.NetBSD.org/src/rev/4debcb78beb9
branches:  trunk
changeset: 503169:4debcb78beb9
user:      briggs <briggs%NetBSD.org@localhost>
date:      Fri Feb 02 06:11:52 2001 +0000

description:
Split OpenPIC support into powerpc so ports only need minimal custom
configuration.  openpic_init() now takes a single argument that is the
base of the OpenPIC register space.

diffstat:

 sys/arch/macppc/include/openpicreg.h  |    3 +
 sys/arch/macppc/macppc/extintr.c      |  134 ++-------------------------------
 sys/arch/powerpc/conf/files.powerpc   |    3 +-
 sys/arch/powerpc/include/openpic.h    |   76 +++++++++++++++++++
 sys/arch/powerpc/include/openpicreg.h |   98 ++++++++++++++++++++++++
 sys/arch/powerpc/powerpc/openpic.c    |   90 ++++++++++++++++++++++
 6 files changed, 277 insertions(+), 127 deletions(-)

diffs (truncated from 498 to 300 lines):

diff -r ecd9f07f9677 -r 4debcb78beb9 sys/arch/macppc/include/openpicreg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/include/openpicreg.h      Fri Feb 02 06:11:52 2001 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: openpicreg.h,v 1.1 2001/02/02 06:11:53 briggs Exp $    */
+
+#include <powerpc/openpicreg.h>
diff -r ecd9f07f9677 -r 4debcb78beb9 sys/arch/macppc/macppc/extintr.c
--- a/sys/arch/macppc/macppc/extintr.c  Fri Feb 02 06:01:01 2001 +0000
+++ b/sys/arch/macppc/macppc/extintr.c  Fri Feb 02 06:11:52 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extintr.c,v 1.22 2001/01/15 20:19:54 thorpej Exp $     */
+/*     $NetBSD: extintr.c,v 1.23 2001/02/02 06:11:53 briggs Exp $      */
 
 /*-
  * Copyright (c) 1995 Per Fogelstrom
@@ -51,7 +51,7 @@
 #include <machine/psl.h>
 #include <machine/pio.h>
 
-#include <macppc/macppc/openpicreg.h>
+#include <powerpc/openpic.h>
 
 #define NIRQ 32
 #define HWIRQ_MAX (NIRQ - 4 - 1)
@@ -66,14 +66,6 @@
 static __inline int mapirq __P((int));
 static void enable_irq __P((int));
 
-static __inline u_int openpic_read __P((int));
-static __inline void openpic_write __P((int, u_int));
-void openpic_enable_irq __P((int, int));
-void openpic_disable_irq __P((int));
-void openpic_set_priority __P((int, int));
-static __inline int openpic_read_irq __P((int));
-static __inline void openpic_eoi __P((int));
-
 static void do_pending_int __P((void));
 
 unsigned int imen = 0xffffffff;
@@ -85,7 +77,7 @@
 static u_char hwirq[NIRQ], virq[ICU_LEN];
 static int virq_max = 0;
 
-static u_char *obio_base, *openpic_base;
+static u_char *obio_base, *macppc_openpic_base;
 
 extern u_int *heathrow_FCR;
 
@@ -107,7 +99,7 @@
 #define INT_CLEAR_REG_L  (interrupt_reg + 0x18)
 #define INT_LEVEL_REG_L  (interrupt_reg + 0x1c)
 
-#define have_openpic   (openpic_base != NULL)
+#define have_openpic   (macppc_openpic_base != NULL)
 
 /*
  * Map 64 irqs into 32 (bits).
@@ -205,78 +197,6 @@
                out32rb(INT_ENABLE_REG_H, hi);
 }
 
-u_int
-openpic_read(reg)
-       int reg;
-{
-       char *addr = openpic_base + reg;
-
-       return in32rb(addr);
-}
-
-void
-openpic_write(reg, val)
-       int reg;
-       u_int val;
-{
-       char *addr = openpic_base + reg;
-
-       out32rb(addr, val);
-}
-
-void
-openpic_enable_irq(irq, type)
-       int irq, type;
-{
-       u_int x;
-
-       x = openpic_read(OPENPIC_SRC_VECTOR(irq));
-       x &= ~(OPENPIC_IMASK | OPENPIC_SENSE_LEVEL | OPENPIC_SENSE_EDGE);
-       if (type == IST_LEVEL)
-               x |= OPENPIC_SENSE_LEVEL;
-       else
-               x |= OPENPIC_SENSE_EDGE;
-       openpic_write(OPENPIC_SRC_VECTOR(irq), x);
-}
-
-void
-openpic_disable_irq(irq)
-       int irq;
-{
-       u_int x;
-
-       x = openpic_read(OPENPIC_SRC_VECTOR(irq));
-       x |= OPENPIC_IMASK;
-       openpic_write(OPENPIC_SRC_VECTOR(irq), x);
-}
-
-void
-openpic_set_priority(cpu, pri)
-       int cpu, pri;
-{
-       u_int x;
-
-       x = openpic_read(OPENPIC_CPU_PRIORITY(cpu));
-       x &= ~OPENPIC_CPU_PRIORITY_MASK;
-       x |= pri;
-       openpic_write(OPENPIC_CPU_PRIORITY(cpu), x);
-}
-
-int
-openpic_read_irq(cpu)
-       int cpu;
-{
-       return openpic_read(OPENPIC_IACK(cpu)) & OPENPIC_VECTOR_MASK;
-}
-
-void
-openpic_eoi(cpu)
-       int cpu;
-{
-       openpic_write(OPENPIC_EOI(cpu), 0);
-       openpic_read(OPENPIC_EOI(cpu));
-}
-
 /*
  * Recalculate the interrupt masks from scratch.
  * We could code special registry and deregistry versions of this function that
@@ -756,47 +676,9 @@
 }
 
 void
-openpic_init()
+macppc_openpic_init()
 {
-       int irq;
-       u_int x;
-
-       /* disable all interrupts */
-       for (irq = 0; irq < 256; irq++)
-               openpic_write(OPENPIC_SRC_VECTOR(irq), OPENPIC_IMASK);
-
-       openpic_set_priority(0, 15);
-
-       /* we don't need 8259 pass through mode */
-       x = openpic_read(OPENPIC_CONFIG);
-       x |= OPENPIC_CONFIG_8259_PASSTHRU_DISABLE;
-       openpic_write(OPENPIC_CONFIG, x);
-
-       /* send all interrupts to cpu 0 */
-       for (irq = 0; irq < ICU_LEN; irq++)
-               openpic_write(OPENPIC_IDEST(irq), 1 << 0);
-
-       for (irq = 0; irq < ICU_LEN; irq++) {
-               x = irq;
-               x |= OPENPIC_IMASK;
-               x |= OPENPIC_POLARITY_POSITIVE;
-               x |= OPENPIC_SENSE_LEVEL;
-               x |= 8 << OPENPIC_PRIORITY_SHIFT;
-               openpic_write(OPENPIC_SRC_VECTOR(irq), x);
-       }
-
-       /* XXX set spurious intr vector */
-
-       openpic_set_priority(0, 0);
-
-       /* clear all pending interrunts */
-       for (irq = 0; irq < 256; irq++) {
-               openpic_read_irq(0);
-               openpic_eoi(0);
-       }
-
-       for (irq = 0; irq < ICU_LEN; irq++)
-               openpic_disable_irq(irq);
+       openpic_init(macppc_openpic_base);
 
        install_extint(ext_intr_openpic);
 }
@@ -821,7 +703,7 @@
        int32_t ictlr;
        char type[32];
 
-       openpic_base = NULL;
+       macppc_openpic_base = NULL;
 
        mac_io = OF_finddevice("mac-io");
        if (mac_io == -1)
@@ -860,7 +742,7 @@
                if (OF_getprop(ictlr, "reg", reg, sizeof(reg)) < 8)
                        goto failed;
 
-               openpic_base = (void *)(obio_base + reg[0]);
+               macppc_openpic_base = (void *)(obio_base + reg[0]);
                openpic_init();
                return;
        }
diff -r ecd9f07f9677 -r 4debcb78beb9 sys/arch/powerpc/conf/files.powerpc
--- a/sys/arch/powerpc/conf/files.powerpc       Fri Feb 02 06:01:01 2001 +0000
+++ b/sys/arch/powerpc/conf/files.powerpc       Fri Feb 02 06:11:52 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.powerpc,v 1.14 2000/11/25 03:01:40 matt Exp $
+#      $NetBSD: files.powerpc,v 1.15 2001/02/02 06:11:52 briggs Exp $
 defopt altivec
 
 file   arch/powerpc/powerpc/Locore.c
@@ -13,6 +13,7 @@
 file   netinet/in4_cksum.c                             inet
 file   arch/powerpc/powerpc/ipkdb_glue.c               ipkdb
 file   arch/powerpc/powerpc/mem.c
+file   arch/powerpc/powerpc/openpic.c
 file   arch/powerpc/powerpc/pmap.c
 file   arch/powerpc/powerpc/process_machdep.c
 file   arch/powerpc/powerpc/sig_machdep.c
diff -r ecd9f07f9677 -r 4debcb78beb9 sys/arch/powerpc/include/openpic.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/include/openpic.h        Fri Feb 02 06:11:52 2001 +0000
@@ -0,0 +1,76 @@
+/*     $NetBSD: openpic.h,v 1.1 2001/02/02 06:11:52 briggs Exp $       */
+
+/*-
+ * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/pio.h>
+
+#include <machine/openpicreg.h>
+
+void openpic_enable_irq __P((int, int));
+void openpic_disable_irq __P((int));
+void openpic_set_priority __P((int, int));
+
+extern volatile unsigned char *openpic_base;
+
+static __inline u_int openpic_read __P((int));
+static __inline void openpic_write __P((int, u_int));
+static __inline int openpic_read_irq __P((int));
+static __inline void openpic_eoi __P((int));
+
+static __inline u_int
+openpic_read(reg)
+       int reg;
+{
+       volatile unsigned char *addr = openpic_base + reg;
+
+       return in32rb(addr);
+}
+
+static __inline void
+openpic_write(reg, val)
+       int reg;
+       u_int val;
+{
+       volatile unsigned char *addr = openpic_base + reg;
+
+       out32rb(addr, val);
+}
+
+static __inline int
+openpic_read_irq(cpu)
+       int cpu;
+{
+       return openpic_read(OPENPIC_IACK(cpu)) & OPENPIC_VECTOR_MASK;
+}
+
+static __inline void
+openpic_eoi(cpu)
+       int cpu;
+{
+       openpic_write(OPENPIC_EOI(cpu), 0);



Home | Main Index | Thread Index | Old Index