Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/dreamcast Abstracted handling of System ASIC contro...



details:   https://anonhg.NetBSD.org/src/rev/6dbb9712bf10
branches:  trunk
changeset: 509020:6dbb9712bf10
user:      marcus <marcus%NetBSD.org@localhost>
date:      Tue Apr 24 19:43:23 2001 +0000

description:
Abstracted handling of System ASIC controlled IRQ:s a little.
Three different IRQ:s can be selected for each event, 9, 11, or 13
(which selects hardware priority).  More events to be added as they
are discovered.  Do not use shb_intr_establish() to register IRQ 9, 11
or 13 anymore.

diffstat:

 sys/arch/dreamcast/conf/files.shbus     |    3 +-
 sys/arch/dreamcast/dev/g2/gapspci_pci.c |   14 +-
 sys/arch/dreamcast/dev/gdrom.c          |    7 +-
 sys/arch/dreamcast/dreamcast/shb.c      |   35 ++++--
 sys/arch/dreamcast/dreamcast/sysasic.c  |  161 ++++++++++++++++++++++++++++++++
 sys/arch/dreamcast/include/sysasicvar.h |   61 ++++++++++++
 6 files changed, 254 insertions(+), 27 deletions(-)

diffs (truncated from 375 to 300 lines):

diff -r c507ba982e88 -r 6dbb9712bf10 sys/arch/dreamcast/conf/files.shbus
--- a/sys/arch/dreamcast/conf/files.shbus       Tue Apr 24 19:30:53 2001 +0000
+++ b/sys/arch/dreamcast/conf/files.shbus       Tue Apr 24 19:43:23 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.shbus,v 1.1 2000/12/11 18:19:13 marcus Exp $
+#      $NetBSD: files.shbus,v 1.2 2001/04/24 19:43:25 marcus Exp $
 #
 # Config file and device description for machine-independent SHBus code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -14,6 +14,7 @@
 attach shb at mainbus
 
 file arch/dreamcast/dreamcast/shb.c            shb needs-flag
+file arch/dreamcast/dreamcast/sysasic.c                shb
 
 # Misc devices
 
diff -r c507ba982e88 -r 6dbb9712bf10 sys/arch/dreamcast/dev/g2/gapspci_pci.c
--- a/sys/arch/dreamcast/dev/g2/gapspci_pci.c   Tue Apr 24 19:30:53 2001 +0000
+++ b/sys/arch/dreamcast/dev/g2/gapspci_pci.c   Tue Apr 24 19:43:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gapspci_pci.c,v 1.1 2001/02/01 01:04:55 thorpej Exp $  */
+/*     $NetBSD: gapspci_pci.c,v 1.2 2001/04/24 19:43:25 marcus Exp $   */
 
 /*-
  * Copyright (c) 2001 Marcus Comstedt.
@@ -47,6 +47,7 @@
 #include <machine/cpu.h>
 #include <machine/bus.h>
 #include <machine/shbvar.h>
+#include <machine/sysasicvar.h>
 
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcireg.h>
@@ -180,15 +181,8 @@
 gaps_intr_establish(void *v, pci_intr_handle_t ih, int level,
     int (*func)(void *), void *arg)
 {
-       void *rv;
-
-       rv = shb_intr_establish(ih, IST_EDGE /* XXX IST_LEVEL? */,
-           level, func, arg);
-#if 0
-       if (rv != NULL)
-               *(volatile unsigned int *)(void *)(0xa05f6924) |= 1<<3;
-#endif
-       return (rv);
+       return sysasic_intr_establish(ih, SYSASIC_EVENT_EXT,
+                                     level, func, arg);
 }
 
 void
diff -r c507ba982e88 -r 6dbb9712bf10 sys/arch/dreamcast/dev/gdrom.c
--- a/sys/arch/dreamcast/dev/gdrom.c    Tue Apr 24 19:30:53 2001 +0000
+++ b/sys/arch/dreamcast/dev/gdrom.c    Tue Apr 24 19:43:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdrom.c,v 1.3 2001/02/20 00:04:40 marcus Exp $ */
+/*     $NetBSD: gdrom.c,v 1.4 2001/04/24 19:43:25 marcus Exp $ */
 
 /*-
  * Copyright (c) 2001 Marcus Comstedt
@@ -53,7 +53,8 @@
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <sh3/shbvar.h>
+#include <machine/shbvar.h>
+#include <machine/sysasicvar.h>
 
 int    gdrommatch __P((struct device *, struct cfdata *, void *));
 void   gdromattach __P((struct device *, struct device *, void *));
@@ -420,7 +421,7 @@
            x = ((volatile u_int32_t *)0xa0000000)[p];
        }
 
-       shb_intr_establish(9, IST_EDGE, 0, gdrom_intr, sc);
+       sysasic_intr_establish(9, SYSASIC_EVENT_GDROM, 0, gdrom_intr, sc);
 }
 
 int
diff -r c507ba982e88 -r 6dbb9712bf10 sys/arch/dreamcast/dreamcast/shb.c
--- a/sys/arch/dreamcast/dreamcast/shb.c        Tue Apr 24 19:30:53 2001 +0000
+++ b/sys/arch/dreamcast/dreamcast/shb.c        Tue Apr 24 19:43:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shb.c,v 1.4 2001/02/20 00:03:53 marcus Exp $   */
+/*     $NetBSD: shb.c,v 1.5 2001/04/24 19:43:23 marcus Exp $   */
 
 /*-
  * Copyright (c) 1993, 1994 Charles Hannum.  All rights reserved.
@@ -42,6 +42,7 @@
 #include <sh3/intcreg.h>
 #include <sh3/trapreg.h>
 #include <machine/shbvar.h>
+#include <machine/sysasicvar.h>
 
 #if 0
 #include <dev/isa/isareg.h>
@@ -650,13 +651,17 @@
                break;
 #endif
 
-        case 9:
-         *(volatile unsigned int *)(void *)(0xa05f6934) &= ~1;
-         break;
+       case 9:
+               sysasic_mask_irq(SYSASIC_IRQ_LEVEL_9);
+               break;
 
-        case 11:
-         *(volatile unsigned int *)(void *)(0xa05f6924) &= ~(1<<3);
-         break;
+       case 11:
+               sysasic_mask_irq(SYSASIC_IRQ_LEVEL_11);
+               break;
+
+       case 13:
+               sysasic_mask_irq(SYSASIC_IRQ_LEVEL_13);
+               break;
 
        default:
                if (irq < SHB_MAX_HARDINTR)
@@ -693,13 +698,17 @@
                SHREG_IPRE |= ((15 - irq)<<12);
                break;
 #endif
-        case 9:
-         *(volatile unsigned int *)(void *)(0xa05f6934) |= 1;
-         break;
+       case 9:
+               sysasic_unmask_irq(SYSASIC_IRQ_LEVEL_9);
+               break;
 
-        case 11:
-         *(volatile unsigned int *)(void *)(0xa05f6924) |= (1<<3);
-         break;
+       case 11:
+               sysasic_unmask_irq(SYSASIC_IRQ_LEVEL_11);
+               break;
+
+       case 13:
+               sysasic_unmask_irq(SYSASIC_IRQ_LEVEL_13);
+               break;
 
        default:
                if (irq < SHB_MAX_HARDINTR)
diff -r c507ba982e88 -r 6dbb9712bf10 sys/arch/dreamcast/dreamcast/sysasic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/dreamcast/dreamcast/sysasic.c    Tue Apr 24 19:43:23 2001 +0000
@@ -0,0 +1,161 @@
+/*     $NetBSD: sysasic.c,v 1.1 2001/04/24 19:43:23 marcus Exp $       */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+
+#include <machine/intr.h>
+#include <machine/shbvar.h>
+#include <machine/sysasicvar.h>
+
+
+static u_int32_t sysasicmasks[SYSASIC_IRQ_LEVEL_MAX+1][(SYSASIC_EVENT_MAX+1)/32];
+
+void
+sysasic_mask_irq(level)
+       int level;
+{
+       volatile unsigned int *masks =
+         (volatile unsigned int *)(void *)(0xa05f6910+(level<<4));
+
+       masks[0] = 0;
+       masks[1] = 0;
+}
+
+void
+sysasic_unmask_irq(level)
+       int level;
+{
+       volatile unsigned int *masks =
+         (volatile unsigned int *)(void *)(0xa05f6910+(level<<4));
+
+       masks[0] = sysasicmasks[level][0];
+       masks[1] = sysasicmasks[level][1];
+}
+
+/*
+ * Set up an interrupt handler to start being called.
+ */
+void *
+sysasic_intr_establish(irq, event, level, ih_fun, ih_arg)
+       int irq;
+       int event;
+       int level;
+       int (*ih_fun) __P((void *));
+       void *ih_arg;
+{
+       struct intrhand *ih;
+       int mask_no, bit_set, bit_no;
+
+       switch (irq) {
+       case 9:
+               mask_no = SYSASIC_IRQ_LEVEL_9;
+               break;
+       case 11:
+               mask_no = SYSASIC_IRQ_LEVEL_11;
+               break;
+        case 13:
+               mask_no = SYSASIC_IRQ_LEVEL_13;
+               break;
+       default:
+               panic("invalid sysasic IRQ %d", irq);
+       }
+
+       if (event < 0 || event > SYSASIC_EVENT_MAX)
+               panic("invalid sysasic event %d", event);
+
+       bit_set = event >> 5;
+       bit_no = event & 31;
+
+       if (sysasicmasks[mask_no][bit_set] & (1<<bit_no))
+               panic("multiple handlers for event %d", event);
+
+       sysasicmasks[mask_no][bit_set] |= 1<<bit_no;
+
+       ih = shb_intr_establish(irq, IST_LEVEL, level, ih_fun, ih_arg);
+
+       /* XXX need to remember the event no so that we can disestablish
+          correctly.  This should probably be a field of its own in
+          struct intrhand, but by jamming it into the ih_irq field we
+          can avoid changing the generic sh3 struct... */
+
+       ih->ih_irq |= (event << 8);
+
+       return ih;
+}
+
+
+/*
+ * Deregister an interrupt handler.
+ */
+void
+sysasic_intr_disestablish(ic, arg)
+       void *ic;
+       void *arg;
+{
+       struct intrhand *ih = arg;
+       int event, mask_no, bit_set, bit_no;
+
+       /* XXX kluge, see sysasic_intr_establish() */
+       event = ih->ih_irq >> 8;
+       ih->ih_irq &= 0xff;
+
+       switch (ih->ih_irq) {
+       case 9:
+               mask_no = SYSASIC_IRQ_LEVEL_9;
+               break;
+       case 11:
+               mask_no = SYSASIC_IRQ_LEVEL_11;
+               break;
+        case 13:
+               mask_no = SYSASIC_IRQ_LEVEL_13;
+               break;
+       default:
+               panic("invalid sysasic IRQ %d", ih->ih_irq);
+       }
+



Home | Main Index | Thread Index | Old Index