Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/marvell Add __HAVE_GENERIC_SOFT_INTERRUPT s...



details:   https://anonhg.NetBSD.org/src/rev/a876f3c25ef5
branches:  trunk
changeset: 544344:a876f3c25ef5
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Mar 17 16:54:16 2003 +0000

description:
Add __HAVE_GENERIC_SOFT_INTERRUPT support.

diffstat:

 sys/arch/powerpc/marvell/extintr.c      |  87 ++++++++++++++++++++++-----------
 sys/arch/powerpc/marvell/marvell_intr.h |  47 +++++++++--------
 2 files changed, 82 insertions(+), 52 deletions(-)

diffs (266 lines):

diff -r 6a6d8e7711d6 -r a876f3c25ef5 sys/arch/powerpc/marvell/extintr.c
--- a/sys/arch/powerpc/marvell/extintr.c        Mon Mar 17 16:53:52 2003 +0000
+++ b/sys/arch/powerpc/marvell/extintr.c        Mon Mar 17 16:54:16 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extintr.c,v 1.5 2003/03/16 06:56:47 matt Exp $ */
+/*     $NetBSD: extintr.c,v 1.6 2003/03/17 16:54:16 matt Exp $ */
 
 /*
  * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
@@ -140,13 +140,16 @@
  * the list.  The handler is called with its (single) argument.
  */
 struct intrhand {
-       int     (*ih_fun) __P((void *));
+       int     (*ih_fun)(void *);
        void    *ih_arg;
        struct  intrhand *ih_next;
        struct  intrsource *ih_source;
+       int     ih_flags;
        int     ih_level;       /* sanity only */
        u_long  ih_count;
+       int     ih_softimask;
 };
+#define        IH_ACTIVE       0x01
 
 struct intrsource intr_sources[NIRQ];
 
@@ -262,7 +265,7 @@
 }
 
 static void
-xsoftnet(void)
+xsoftnet(void *arg)
 {
        int pendisr;
        __asm __volatile(
@@ -276,25 +279,19 @@
        softnet(pendisr);
 }
 
+void *softnet_si;
+
 /*
  * softintr_init - establish softclock, softnet; reserve SIR_HWCLOCK
  */
 STATIC void
 softintr_init(void)
 {
-       void *p;
-
        intr_sources[SIR_HWCLOCK].is_type = IST_CLOCK;  /* exclusive */
 
-       p = intr_establish(SIR_SOFTCLOCK, IST_SOFT, IPL_SOFTCLOCK,
-               (int (*) __P((void *)))softclock, NULL);
-       if (p == NULL)
-               panic("softintr_init: cannot intr_establish SIR_SOFTCLOCK");
-
-       p = intr_establish(SIR_NET, IST_SOFT, IPL_SOFTNET, 
-               (int (*) __P((void *)))xsoftnet, NULL);
-       if (p == NULL)
-               panic("softintr_init: cannot intr_establish SIR_NET");
+       softnet_si = softintr_establish(IPL_SOFTNET, xsoftnet, NULL);
+       if (softnet_si == NULL)
+               panic("softintr_init: cannot softintr_establish IPL_SOFTNET");
 }
 
 /*
@@ -391,6 +388,13 @@
        ih->ih_source = is;
        ih->ih_next = NULL;
        ih->ih_count = 0;
+       if (irq >= SIR_BASE) {
+               ih->ih_flags = 0;
+               ih->ih_softimask = SIBIT(irq);
+       } else {
+               ih->ih_flags = IH_ACTIVE;
+               ih->ih_softimask = 0;
+       }
        *p = ih;
 
        intr_calculatemasks();
@@ -745,11 +749,13 @@
                        for (ih = is->is_hand; ih != NULL; ih = ih->ih_next) {
                                int rv;
 
-                               (void)extintr_enable();
-
-                               rv = (*ih->ih_fun)(ih->ih_arg);
-
-                               (void)extintr_disable();
+                               if (ih->ih_flags & IH_ACTIVE) {
+                                       if (irq >= SIR_BASE)
+                                               ih->ih_flags &= ~IH_ACTIVE;
+                                       (void)extintr_enable();
+                                       rv = (*ih->ih_fun)(ih->ih_arg);
+                                       (void)extintr_disable();
+                               }
 
                                KASSERT(ci->ci_cpl == ipl);
                                if (rv != 0)
@@ -775,6 +781,39 @@
        goto loop;
 }
 
+void *
+softintr_establish(int level, void (*fun)(void *), void *arg)
+{
+       int irq = 200;
+       switch (level) {
+       case IPL_SOFTNET:       irq = SIR_SOFTNET; break;
+       case IPL_SOFTCLOCK:     irq = SIR_SOFTCLOCK; break;
+       case IPL_SOFTSERIAL:    irq = SIR_SOFTSERIAL; break;
+       case IPL_SOFTI2C:       irq = SIR_SOFTI2C; break;
+       default:
+               panic("softintr_establish: bad level %d", level);
+       }
+
+       return intr_establish(irq, IST_SOFT, level, (int (*)(void *))fun, arg);
+}
+
+void
+softintr_disestablish(void *ih)
+{
+       intr_disestablish(ih);
+}
+
+void
+softintr_schedule(void *vih)
+{
+       struct intrhand *ih = vih;
+       register_t omsr;
+
+       omsr = extintr_disable();
+       ih->ih_flags |= IH_ACTIVE;
+       ipending[IMASK_SOFTINT] |= ih->ih_softimask;
+       extintr_restore(omsr);
+}
 
 #ifdef EXT_INTR_STATS
 /*
@@ -1257,14 +1296,4 @@
 
        return (ocpl);
 }
-
-void
-softintr(int sibit)
-{
-       int omsr;
-
-       omsr = extintr_disable();
-       ipending[IMASK_SOFTINT] |= sibit;
-       extintr_restore(omsr);
-}
 #endif
diff -r 6a6d8e7711d6 -r a876f3c25ef5 sys/arch/powerpc/marvell/marvell_intr.h
--- a/sys/arch/powerpc/marvell/marvell_intr.h   Mon Mar 17 16:53:52 2003 +0000
+++ b/sys/arch/powerpc/marvell/marvell_intr.h   Mon Mar 17 16:54:16 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: marvell_intr.h,v 1.3 2003/03/16 06:57:31 matt Exp $    */
+/*     $NetBSD: marvell_intr.h,v 1.4 2003/03/17 16:54:16 matt Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -320,12 +320,10 @@
 static __inline int splraise __P((int));
 static __inline int spllower __P((int));
 static __inline void splx __P((int));
-static __inline void softintr __P((int));
 #else
 extern int splraise __P((int));
 extern int spllower __P((int));
 extern void splx __P((int));
-extern void softintr __P((int));
 #endif
 
 extern volatile int tickspending;
@@ -434,16 +432,6 @@
 
        return (ocpl);
 }
-
-static __inline void
-softintr(int sibit)
-{
-       register_t omsr;
-
-       omsr = extintr_disable();
-       ipending[IMASK_SOFTINT] |= sibit;
-       extintr_restore(omsr);
-}
 #endif /* SPL_INLINE */
 
 
@@ -453,12 +441,15 @@
  */
 #define SIR_BASE       (NIRQ-32)
 #define SIR_SOFTCLOCK  (NIRQ-5)
-#define SIR_NET                (NIRQ-4)
-#define SIR_I2C                (NIRQ-3)
-#define SIR_SERIAL     (NIRQ-2)
+#define SIR_SOFTNET    (NIRQ-4)
+#define SIR_SOFTI2C    (NIRQ-3)
+#define SIR_SOFTSERIAL (NIRQ-2)
 #define SIR_HWCLOCK    (NIRQ-1)
-#define SIR_RES                ~(SIBIT(SIR_SOFTCLOCK)|SIBIT(SIR_NET)| \
-                         SIBIT(SIR_I2C)|SIBIT(SIR_SERIAL)|SIBIT(SIR_HWCLOCK))
+#define SIR_RES                ~(SIBIT(SIR_SOFTCLOCK)|\
+                         SIBIT(SIR_SOFTNET)|\
+                         SIBIT(SIR_SOFTI2C)|\
+                         SIBIT(SIR_SOFTSERIAL)|\
+                         SIBIT(SIR_HWCLOCK))
 
 /*
  * standard hardware interrupt spl's
@@ -485,6 +476,12 @@
 #define        splsoftnet()            splraise(IPL_SOFTNET)
 #define        splsoftserial()         splraise(IPL_SOFTSERIAL)
 
+#define __HAVE_GENERIC_SOFT_INTERRUPTS /* should be in <machine/types.h> */
+void *softintr_establish(int level, void (*fun)(void *), void *arg);
+void softintr_disestablish(void *cookie);
+void softintr_schedule(void *cookie);
+
+
 /*
  * Miscellaneous
  */
@@ -494,12 +491,14 @@
 #define        spl0()          spllower(IPL_NONE)
 
 #define SIBIT(ipl)     (1 << ((ipl) - SIR_BASE))
+#if 0
 #define        setsoftclock()  softintr(SIBIT(SIR_SOFTCLOCK))
-#define        setsoftnet()    softintr(SIBIT(SIR_NET))
-#define        setsoftserial() softintr(SIBIT(SIR_SERIAL))
-#define        setsofti2c()    softintr(SIBIT(SIR_I2C))
+#define        setsoftnet()    softintr(SIBIT(SIR_SOFTNET))
+#define        setsoftserial() softintr(SIBIT(SIR_SOFTSERIAL))
+#define        setsofti2c()    softintr(SIBIT(SIR_SOFTI2C))
+#endif
 
-extern volatile int intrcnt[];
+extern void *softnet_si;
 void   *intr_establish(int, int, int, int (*)(void *), void *);
 void   intr_disestablish(void *);
 void   init_interrupt(void);
@@ -508,7 +507,9 @@
 const struct evcnt * intr_evcnt(int);
 void   ext_intr(struct intrframe *);
 
+#if 0
 void   softserial(void);
+#endif
 void   strayintr(int);
 
 #define        schednetisr(isr)  do {                  \
@@ -520,7 +521,7 @@
           :                                    \
           : "r"(1 << (isr)), "b"(&netisr)      \
           : "cr0", "r0");                      \
-       setsoftnet();                           \
+       softintr_schedule(softnet_si);          \
 } while (/*CONSTCOND*/ 0)
 
 /*



Home | Main Index | Thread Index | Old Index