Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc Finish the switch to the softintr(9) framework.



details:   https://anonhg.NetBSD.org/src/rev/fdb398481ccc
branches:  trunk
changeset: 540316:fdb398481ccc
user:      pk <pk%NetBSD.org@localhost>
date:      Mon Dec 09 16:11:50 2002 +0000

description:
Finish the switch to the softintr(9) framework.

To make this work, we now have to use separate handler lists for hardware
and software interrupts as the soft interrupt handlers do not return
an `interrupt handled' status.

Thanks to Matt Fredette for providing an initial set of patches on port-sparc.

diffstat:

 sys/arch/sparc/dev/audioamd.c |   49 ++++++--------
 sys/arch/sparc/dev/fd.c       |   47 ++++---------
 sys/arch/sparc/dev/zs.c       |   48 +++++---------
 sys/arch/sparc/include/intr.h |   31 ++++++++-
 sys/arch/sparc/sparc/intr.c   |  136 +++++++++++++++++++++++++++++++++--------
 5 files changed, 192 insertions(+), 119 deletions(-)

diffs (truncated from 640 to 300 lines):

diff -r 5b884384586e -r fdb398481ccc sys/arch/sparc/dev/audioamd.c
--- a/sys/arch/sparc/dev/audioamd.c     Mon Dec 09 15:50:57 2002 +0000
+++ b/sys/arch/sparc/dev/audioamd.c     Mon Dec 09 16:11:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audioamd.c,v 1.13 2002/10/15 13:49:52 jdc Exp $        */
+/*     $NetBSD: audioamd.c,v 1.14 2002/12/09 16:11:50 pk Exp $ */
 /*     NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp  */
 
 /*
@@ -64,20 +64,9 @@
 /* interrupt interfaces */
 #ifdef AUDIO_C_HANDLER
 int    am7930hwintr __P((void *));
-#if defined(SUN4M)
-#define AUDIO_SET_SWINTR do {          \
-       if (CPU_ISSUN4M)                \
-               raise(0, 4);            \
-       else                            \
-               ienab_bis(IE_L4);       \
-} while(0);
-#else
-#define AUDIO_SET_SWINTR ienab_bis(IE_L4)
-#endif /* defined(SUN4M) */
-#else
+#endif /* AUDIO_C_HANDLER */
 struct auio *auiop;
-#endif /* AUDIO_C_HANDLER */
-int    am7930swintr __P((void *));
+void   am7930swintr __P((void *));
 
 /*
  * interrupt-handler status 
@@ -102,6 +91,7 @@
        /* sc_au is special in that the hardware interrupt handler uses it */
        struct  auio sc_au;             /* recv and xmit buffers, etc */
 #define sc_intrcnt     sc_au.au_intrcnt        /* statistics */
+       void    *sc_sicookie;           /* softintr(9) cookie */
 };
 
 void   audioamd_mainbus_attach __P((struct device *,
@@ -306,8 +296,6 @@
        int pri;
 {
 
-       printf(" softpri %d\n", PIL_AUSOFT);
-
        /*
         * Set up glue for MI code early; we use some of it here.
         */
@@ -315,8 +303,8 @@
 
        am7930_init(&sc->sc_am7930, AUDIOAMD_POLL_MODE);
 
+       auiop = &sc->sc_au;
 #ifndef AUDIO_C_HANDLER
-       auiop = &sc->sc_au;
        (void)bus_intr_establish(sc->sc_bt, pri, IPL_AUDIO,
                                 BUS_INTR_ESTABLISH_FASTTRAP,
                                 (int (*) __P((void *)))amd7930_trap, NULL);
@@ -324,9 +312,16 @@
        (void)bus_intr_establish(sc->sc_bt, pri, IPL_AUDIO, 0,
                                 am7930hwintr, sc);
 #endif
-       (void)bus_intr_establish(sc->sc_bt, PIL_AUSOFT, IPL_AUDIO,
-                                BUS_INTR_ESTABLISH_SOFTINTR,
-                                am7930swintr, sc);
+
+       sc->sc_sicookie = softintr_establish(IPL_SOFTAUDIO, am7930swintr, sc);
+       if (sc->sc_sicookie == NULL) {
+               printf("\n%s: cannot establish software interrupt\n",
+                       sc->sc_am7930.sc_dev.dv_xname);
+               return;
+       }
+
+       printf(" softpri %d\n", IPL_SOFTAUDIO);
+
 
        evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
            sc->sc_am7930.sc_dev.dv_xname, "intr");
@@ -436,6 +431,9 @@
 
        /* clear interrupt */
        k = audioamd_codec_dread(sc, AM7930_DREG_IR);
+       if ((k & (AM7930_IR_DTTHRSH|AM7930_IR_DRTHRSH|AM7930_IR_DSRI|
+                 AM7930_IR_DERI|AM7930_IR_BBUFF)) == 0)
+               return (0);
 
        /* receive incoming data */
        d = au->au_rdata;
@@ -445,7 +443,7 @@
                au->au_rdata++;
                if (d == e) {
                        DPRINTFN(1, ("am7930hwintr: swintr(r) requested"));
-                       AUDIO_SET_SWINTR;
+                       softintr_schedule(sc->sc_sicookie);
                }
        }
 
@@ -457,7 +455,7 @@
                au->au_pdata++;
                if (d == e) {
                        DPRINTFN(1, ("am7930hwintr: swintr(p) requested"));
-                       AUDIO_SET_SWINTR;
+                       softintr_schedule(sc->sc_sicookie);
                }
        }
 
@@ -466,13 +464,13 @@
 }
 #endif /* AUDIO_C_HANDLER */
 
-int
+void
 am7930swintr(sc0)
        void *sc0;
 {
        struct audioamd_softc *sc = sc0;
        struct auio *au;
-       int s, ret = 0;
+       int s;
 
        DPRINTFN(1, ("audiointr: sc=%p\n", sc););
 
@@ -480,17 +478,14 @@
        s = splaudio();
        if (au->au_rdata > au->au_rend && sc->sc_rintr != NULL) {
                splx(s);
-               ret = 1;
                (*sc->sc_rintr)(sc->sc_rarg);
                s = splaudio();
        }
        if (au->au_pdata > au->au_pend && sc->sc_pintr != NULL) {
                splx(s);
-               ret = 1;
                (*sc->sc_pintr)(sc->sc_parg);
        } else
                splx(s);
-       return (ret);
 }
 
 
diff -r 5b884384586e -r fdb398481ccc sys/arch/sparc/dev/fd.c
--- a/sys/arch/sparc/dev/fd.c   Mon Dec 09 15:50:57 2002 +0000
+++ b/sys/arch/sparc/dev/fd.c   Mon Dec 09 16:11:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.96 2002/11/01 11:31:53 mrg Exp $      */
+/*     $NetBSD: fd.c,v 1.97 2002/12/09 16:11:50 pk Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -174,6 +174,8 @@
 #define sc_nstat       sc_io.fdcio_nstat
 #define sc_status      sc_io.fdcio_status
 #define sc_intrcnt     sc_io.fdcio_intrcnt
+
+       void            *sc_sicookie;   /* softintr(9) cookie */
 };
 
 extern struct fdcio    *fdciop;        /* I/O descriptor used in fdintr.s */
@@ -302,7 +304,7 @@
 void   fdcpseudointr __P((void *arg));
 int    fdc_c_hwintr __P((void *));
 void   fdchwintr __P((void));
-int    fdcswintr __P((void *));
+void   fdcswintr __P((void *));
 int    fdcstate __P((struct fdc_softc *));
 void   fdcretry __P((struct fdc_softc *fdc));
 void   fdfinish __P((struct fd_softc *fd, struct buf *bp));
@@ -318,23 +320,6 @@
                bus_space_handle_t));
 
 
-#if PIL_FDSOFT == 4
-#define IE_FDSOFT      IE_L4
-#else
-#error 4
-#endif
-
-#if defined(SUN4M)
-#define FD_SET_SWINTR do {             \
-       if (CPU_ISSUN4M)                \
-               raise(0, PIL_FDSOFT);   \
-       else                            \
-               ienab_bis(IE_L4);       \
-} while(0)
-#else
-#define FD_SET_SWINTR ienab_bis(IE_FDSOFT)
-#endif /* defined(SUN4M) */
-
 #define OBP_FDNAME     (CPU_ISSUN4M ? "SUNW,fdtwo" : "fd")
 
 int
@@ -624,8 +609,6 @@
                code = '2';
        }
 
-       printf(" softpri %d: chip 8207%c\n", PIL_FDSOFT, code);
-
        /*
         * Configure controller; enable FIFO, Implied seek, no POLL mode?.
         * Note: CFG_EFIFO is active-low, initial threshold value: 8
@@ -651,13 +634,13 @@
                }
        }
 
-       if (bus_intr_establish(fdc->sc_bustag, PIL_FDSOFT, IPL_BIO,
-                        BUS_INTR_ESTABLISH_SOFTINTR,
-                        fdcswintr, fdc) == NULL) {
-               printf("%s: cannot register interrupt handler\n",
+       fdc->sc_sicookie = softintr_establish(IPL_SOFTFDC, fdcswintr, fdc);
+       if (fdc->sc_sicookie == NULL) {
+               printf("\n%s: cannot register soft interrupt handler\n",
                        fdc->sc_dev.dv_xname);
                return (-1);
        }
+       printf(" softpri %d: chip 8207%c\n", IPL_SOFTFDC, code);
 
        evcnt_attach_dynamic(&fdc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
            fdc->sc_dev.dv_xname, "intr");
@@ -1320,7 +1303,7 @@
                        fdc->sc_istatus = FDC_ISTATUS_ERROR;
                else
                        fdc->sc_istatus = FDC_ISTATUS_DONE;
-               FD_SET_SWINTR;
+               softintr_schedule(fdc->sc_sicookie);
                return (1);
        case FDC_ITASK_DMA:
                /* Proceed with pseudo-dma below */
@@ -1328,7 +1311,7 @@
        default:
                printf("fdc: stray hard interrupt: itask=%d\n", fdc->sc_itask);
                fdc->sc_istatus = FDC_ISTATUS_SPURIOUS;
-               FD_SET_SWINTR;
+               softintr_schedule(fdc->sc_sicookie);
                return (1);
        }
 
@@ -1347,7 +1330,7 @@
                if ((msr & NE7_NDM) == 0) {
                        fdcresult(fdc);
                        fdc->sc_istatus = FDC_ISTATUS_DONE;
-                       FD_SET_SWINTR;
+                       softintr_schedule(fdc->sc_sicookie);
 #ifdef FD_DEBUG
                        if (fdc_debug > 1)
                                printf("fdc: overrun: tc = %d\n", fdc->sc_tc);
@@ -1368,14 +1351,14 @@
                        fdc->sc_istatus = FDC_ISTATUS_DONE;
                        FTC_FLIP;
                        fdcresult(fdc);
-                       FD_SET_SWINTR;
+                       softintr_schedule(fdc->sc_sicookie);
                        break;
                }
        }
        return (1);
 }
 
-int
+void
 fdcswintr(arg)
        void *arg;
 {
@@ -1384,7 +1367,7 @@
 
        if (fdc->sc_istatus == FDC_ISTATUS_NONE)
                /* This (software) interrupt is not for us */
-               return (0);
+               return;
 
        switch (fdc->sc_istatus) {
        case FDC_ISTATUS_ERROR:
@@ -1398,7 +1381,7 @@
        s = splbio();
        fdcstate(fdc);
        splx(s);
-       return (1);
+       return;
 }
 
 int
diff -r 5b884384586e -r fdb398481ccc sys/arch/sparc/dev/zs.c
--- a/sys/arch/sparc/dev/zs.c   Mon Dec 09 15:50:57 2002 +0000
+++ b/sys/arch/sparc/dev/zs.c   Mon Dec 09 16:11:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.92 2002/10/09 08:56:25 jdc Exp $      */
+/*     $NetBSD: zs.c,v 1.93 2002/12/09 16:11:51 pk Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -96,19 +96,6 @@
  */
 #define PCLK   (9600 * 512)    /* PCLK pin input clock rate */
 
-/*
- * Select software interrupt bit based on TTY ipl.
- */
-#if PIL_TTY == 1
-# define IE_ZSSOFT IE_L1
-#elif PIL_TTY == 4



Home | Main Index | Thread Index | Old Index