Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Tsubai has convinced me that openpic_init() should ...



details:   https://anonhg.NetBSD.org/src/rev/f2b7dc04b5d8
branches:  trunk
changeset: 503424:f2b7dc04b5d8
user:      briggs <briggs%NetBSD.org@localhost>
date:      Mon Feb 05 19:22:23 2001 +0000

description:
Tsubai has convinced me that openpic_init() should remain machine-dependant
as the details might differ between archs, and passing the various options
leads to some clutter.

diffstat:

 sys/arch/macppc/include/openpicreg.h    |   4 ++-
 sys/arch/macppc/macppc/extintr.c        |  48 ++++++++++++++++++++++++++++++--
 sys/arch/powerpc/include/openpic.h      |   4 +-
 sys/arch/powerpc/include/openpicreg.h   |   8 +----
 sys/arch/powerpc/powerpc/openpic.c      |  47 +-------------------------------
 sys/arch/sandpoint/include/openpicreg.h |   4 ++-
 sys/arch/sandpoint/sandpoint/extintr.c  |  47 +++++++++++++++++++++++++++++++-
 sys/arch/sandpoint/sandpoint/machdep.c  |   4 +-
 8 files changed, 102 insertions(+), 64 deletions(-)

diffs (273 lines):

diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/macppc/include/openpicreg.h
--- a/sys/arch/macppc/include/openpicreg.h      Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/macppc/include/openpicreg.h      Mon Feb 05 19:22:23 2001 +0000
@@ -1,3 +1,5 @@
-/*     $NetBSD: openpicreg.h,v 1.1 2001/02/02 06:11:53 briggs Exp $    */
+/*     $NetBSD: openpicreg.h,v 1.2 2001/02/05 19:22:24 briggs Exp $    */
+
+void openpic_init __P((void));
 
 #include <powerpc/openpicreg.h>
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/macppc/macppc/extintr.c
--- a/sys/arch/macppc/macppc/extintr.c  Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/macppc/macppc/extintr.c  Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extintr.c,v 1.25 2001/02/04 17:46:33 briggs Exp $      */
+/*     $NetBSD: extintr.c,v 1.26 2001/02/05 19:22:24 briggs Exp $      */
 
 /*-
  * Copyright (c) 1995 Per Fogelstrom
@@ -676,9 +676,49 @@
 }
 
 void
-macppc_openpic_init()
+openpic_init()
 {
-       openpic_init(macppc_openpic_base, ICU_LEN);
+       int irq;
+       u_int x;
+
+       openpic_base = (volatile unsigned char *) macppc_openpic_base;
+
+       /* 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);
 
        install_extint(ext_intr_openpic);
 }
@@ -743,7 +783,7 @@
                        goto failed;
 
                macppc_openpic_base = (void *)(obio_base + reg[0]);
-               macppc_openpic_init();
+               openpic_init();
                return;
        }
 
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/powerpc/include/openpic.h
--- a/sys/arch/powerpc/include/openpic.h        Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/powerpc/include/openpic.h        Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openpic.h,v 1.2 2001/02/04 17:38:10 briggs Exp $       */
+/*     $NetBSD: openpic.h,v 1.3 2001/02/05 19:22:23 briggs Exp $       */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -30,7 +30,7 @@
 
 #include <machine/openpicreg.h>
 
-void openpic_init __P((unsigned char *, int));
+/* void openpic_init(): defined in machdep code, must set openpic_base */
 void openpic_enable_irq __P((int, int));
 void openpic_disable_irq __P((int));
 void openpic_set_priority __P((int, int));
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/powerpc/include/openpicreg.h
--- a/sys/arch/powerpc/include/openpicreg.h     Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/powerpc/include/openpicreg.h     Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openpicreg.h,v 1.1 2001/02/02 06:11:52 briggs Exp $    */
+/*     $NetBSD: openpicreg.h,v 1.2 2001/02/05 19:22:23 briggs Exp $    */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -74,12 +74,6 @@
 #define OPENPIC_IDEST(irq)             (0x10010 + (irq) * 0x20)
 #endif
 
-#ifndef OPENPIC_INIT_SRC
-#define OPENPIC_INIT_SRC(irq)  \
-           ((irq) | OPENPIC_IMASK | OPENPIC_POLARITY_POSITIVE | \
-            OPENPIC_SENSE_LEVEL | (8 << OPENPIC_PRIORITY_SHIFT))
-#endif
-
 /*
  * PROCESSOR register (IDU base + 0x20000)
  */
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/powerpc/powerpc/openpic.c
--- a/sys/arch/powerpc/powerpc/openpic.c        Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/powerpc/powerpc/openpic.c        Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openpic.c,v 1.2 2001/02/04 17:35:28 briggs Exp $       */
+/*     $NetBSD: openpic.c,v 1.3 2001/02/05 19:22:24 briggs Exp $       */
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -7,51 +7,6 @@
 volatile unsigned char *openpic_base;
 
 void
-openpic_init(unsigned char *base, int topirq)
-{
-       int irq, maxirq;
-       u_int x;
-
-       openpic_base = (volatile unsigned char *) base;
-
-       x = openpic_read(OPENPIC_FEATURE);
-       maxirq = (x >> 16) & 0x7ff;
-
-       /* disable all interrupts */
-       for (irq = 0; irq < maxirq; 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 < topirq; irq++)
-               openpic_write(OPENPIC_IDEST(irq), 1 << 0);
-
-       for (irq = 0; irq < topirq; irq++) {
-               x = OPENPIC_INIT_SRC(irq);
-               openpic_write(OPENPIC_SRC_VECTOR(irq), x);
-       }
-
-       openpic_write(OPENPIC_SPURIOUS_VECTOR, 0xff);
-
-       openpic_set_priority(0, 0);
-
-       /* clear all pending interrunts */
-       for (irq = 0; irq < maxirq; irq++) {
-               openpic_read_irq(0);
-               openpic_eoi(0);
-       }
-
-       for (irq = 0; irq < topirq; irq++)
-               openpic_disable_irq(irq);
-}
-
-void
 openpic_enable_irq(irq, type)
        int irq, type;
 {
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/sandpoint/include/openpicreg.h
--- a/sys/arch/sandpoint/include/openpicreg.h   Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/sandpoint/include/openpicreg.h   Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openpicreg.h,v 1.1 2001/02/04 18:32:14 briggs Exp $    */
+/*     $NetBSD: openpicreg.h,v 1.2 2001/02/05 19:22:24 briggs Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -60,4 +60,6 @@
            
 #define OPENPIC_IDEST(irq)             OPENPIC_SRC_VECTOR(irq) + 0x10
 
+void openpic_init __P((unsigned char *));
+
 #include <powerpc/openpicreg.h>
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/sandpoint/sandpoint/extintr.c
--- a/sys/arch/sandpoint/sandpoint/extintr.c    Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/sandpoint/sandpoint/extintr.c    Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extintr.c,v 1.1 2001/02/04 18:32:17 briggs Exp $       */
+/*     $NetBSD: extintr.c,v 1.2 2001/02/05 19:22:25 briggs Exp $       */
 
 /*-
  * Copyright (c) 1995 Per Fogelstrom
@@ -422,3 +422,48 @@
        processing = 0;
        asm volatile("mtmsr %0" :: "r"(emsr));
 }
+
+void
+openpic_init(unsigned char *base)
+{
+       int irq, maxirq;
+       u_int x;
+
+       openpic_base = (volatile unsigned char *) base;
+
+       x = openpic_read(OPENPIC_FEATURE);
+       maxirq = (x >> 16) & 0x7ff;
+
+       /* disable all interrupts */
+       for (irq = 0; irq < maxirq; 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 = OPENPIC_INIT_SRC(irq);
+               openpic_write(OPENPIC_SRC_VECTOR(irq), x);
+       }
+
+       openpic_write(OPENPIC_SPURIOUS_VECTOR, 0xff);
+
+       openpic_set_priority(0, 0);
+
+       /* clear all pending interrunts */
+       for (irq = 0; irq < maxirq; irq++) {
+               openpic_read_irq(0);
+               openpic_eoi(0);
+       }
+
+       for (irq = 0; irq < ICU_LEN; irq++)
+               openpic_disable_irq(irq);
+}
diff -r 8b27e834bc48 -r f2b7dc04b5d8 sys/arch/sandpoint/sandpoint/machdep.c
--- a/sys/arch/sandpoint/sandpoint/machdep.c    Mon Feb 05 19:07:57 2001 +0000
+++ b/sys/arch/sandpoint/sandpoint/machdep.c    Mon Feb 05 19:22:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.1 2001/02/04 18:32:18 briggs Exp $       */
+/*     $NetBSD: machdep.c,v 1.2 2001/02/05 19:22:25 briggs Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -335,7 +335,7 @@
        out32rb(SANDPOINT_PCI_CONFIG_DATA, SANDPOINT_BUS_SPACE_EUMB);
        out32rb(SANDPOINT_PCI_CONFIG_ADDR, 0);
 
-       openpic_init(eumb_base + 0x40000, ICU_LEN);
+       openpic_init(eumb_base + 0x40000);
 #if (NISA > 0)
        isa_intr_init();
 #endif



Home | Main Index | Thread Index | Old Index