Index: algor/algor/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/algor/algor/interrupt.c,v retrieving revision 1.5 diff -u -r1.5 interrupt.c --- algor/algor/interrupt.c 2001/06/15 04:01:40 1.5 +++ algor/algor/interrupt.c 2003/05/25 09:28:45 @@ -41,7 +41,6 @@ #include "opt_algor_p6032.h" #include -#include #include #include @@ -67,8 +66,6 @@ void (*algor_iointr)(u_int32_t, u_int32_t, u_int32_t, u_int32_t); -struct algor_soft_intrhand *softnet_intrhand; - u_long cycles_per_hz; /* @@ -119,15 +116,13 @@ MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */ }; -const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = { +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ }; -struct algor_soft_intr algor_soft_intrs[_IPL_NSOFT]; - struct evcnt mips_int5_evcnt = EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "mips", "int 5 (clock)"); @@ -150,9 +145,6 @@ cpu_intr(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending) { struct clockframe cf; - struct algor_soft_intr *asi; - struct algor_soft_intrhand *sih; - int i, s; uvmexp.intrs++; @@ -183,108 +175,6 @@ return; _clrsoftintr(ipending); - - for (i = _IPL_NSOFT - 1; i >= 0; i--) { - if ((ipending & ipl_si_to_sr[i]) == 0) - continue; - - asi = &algor_soft_intrs[i]; - - if (TAILQ_FIRST(&asi->softintr_q) != NULL) - asi->softintr_evcnt.ev_count++; - - for (;;) { - s = splhigh(); - - sih = TAILQ_FIRST(&asi->softintr_q); - if (sih != NULL) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - - splx(s); - - if (sih == NULL) - break; - - uvmexp.softs++; - (*sih->sih_fn)(sih->sih_arg); - } - } -} - -/* - * softintr_init: - * - * Initialize the software interrupt system. - */ -void -softintr_init(void) -{ - static const char *softintr_names[] = IPL_SOFTNAMES; - struct algor_soft_intr *asi; - int i; - - for (i = 0; i < _IPL_NSOFT; i++) { - asi = &algor_soft_intrs[i]; - TAILQ_INIT(&asi->softintr_q); - asi->softintr_ipl = IPL_SOFT + i; - evcnt_attach_dynamic(&asi->softintr_evcnt, EVCNT_TYPE_INTR, - NULL, "soft", softintr_names[i]); - } - - /* XXX Establish legacy soft interrupt handlers. */ - softnet_intrhand = softintr_establish(IPL_SOFTNET, - (void (*)(void *))netintr, NULL); - - assert(softnet_intrhand != NULL); -} - -/* - * softintr_establish: [interface] - * - * Register a software interrupt handler. - */ -void * -softintr_establish(int ipl, void (*func)(void *), void *arg) -{ - struct algor_soft_intr *asi; - struct algor_soft_intrhand *sih; - - if (__predict_false(ipl >= (IPL_SOFT + _IPL_NSOFT) || - ipl < IPL_SOFT)) - panic("softintr_establish"); - - asi = &algor_soft_intrs[ipl - IPL_SOFT]; - - sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); - if (__predict_true(sih != NULL)) { - sih->sih_intrhead = asi; - sih->sih_fn = func; - sih->sih_arg = arg; - sih->sih_pending = 0; - } - return (sih); -} - -/* - * softintr_disestablish: [interface] - * - * Unregister a software interrupt handler. - */ -void -softintr_disestablish(void *arg) -{ - struct algor_soft_intrhand *sih = arg; - struct algor_soft_intr *asi = sih->sih_intrhead; - int s; - - s = splhigh(); - if (sih->sih_pending) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - splx(s); - free(sih, M_DEVBUF); + softintr_dispatch(ipending); } Index: algor/conf/files.algor =================================================================== RCS file: /cvsroot/src/sys/arch/algor/conf/files.algor,v retrieving revision 1.15 diff -u -r1.15 files.algor --- algor/conf/files.algor 2002/10/26 13:50:20 1.15 +++ algor/conf/files.algor 2003/05/25 09:28:45 @@ -43,6 +43,8 @@ file arch/algor/algor/machdep.c file arch/algor/algor/pmon.c +file arch/mips/mips/softintr.c + # # The autoconfiguration root. # Index: algor/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/algor/include/intr.h,v retrieving revision 1.4 diff -u -r1.4 intr.h --- algor/include/intr.h 2001/06/15 04:01:40 1.4 +++ algor/include/intr.h 2003/05/25 09:28:46 @@ -122,54 +122,7 @@ const void *ih_irqmap; }; -#define setsoft(x) \ -do { \ - _setsoftintr(ipl_si_to_sr[(x) - IPL_SOFT]); \ -} while (0) - -struct algor_soft_intrhand { - TAILQ_ENTRY(algor_soft_intrhand) - sih_q; - struct algor_soft_intr *sih_intrhead; - void (*sih_fn)(void *); - void *sih_arg; - int sih_pending; -}; - -struct algor_soft_intr { - TAILQ_HEAD(, algor_soft_intrhand) - softintr_q; - struct evcnt softintr_evcnt; - struct simplelock softintr_slock; - unsigned long softintr_ipl; -}; - -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_init(void); -void softintr_dispatch(void); - -#define softintr_schedule(arg) \ -do { \ - struct algor_soft_intrhand *__sih = (arg); \ - struct algor_soft_intr *__si = __sih->sih_intrhead; \ - int __s; \ - \ - __s = splhigh(); \ - simple_lock(&__si->softintr_slock); \ - if (__sih->sih_pending == 0) { \ - TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ - __sih->sih_pending = 1; \ - setsoft(__si->softintr_ipl); \ - } \ - simple_unlock(&__si->softintr_slock); \ - splx(__s); \ -} while (0) - -/* XXX For legacy software interrupts. */ -extern struct algor_soft_intrhand *softnet_intrhand; - -#define setsoftnet() softintr_schedule(softnet_intrhand) +#include extern struct evcnt mips_int5_evcnt; Index: arc/arc/arc_trap.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/arc_trap.c,v retrieving revision 1.24 diff -u -r1.24 arc_trap.c --- arc/arc/arc_trap.c 2003/04/27 17:13:01 1.24 +++ arc/arc/arc_trap.c 2003/05/25 09:28:48 @@ -133,15 +133,14 @@ u_int32_t pc; u_int32_t ipending; /* pending interrupts & enable mask */ { -#if defined(MIPS3) && defined(MIPS_INT_MASK_CLOCK) - if ((ipending & MIPS_INT_MASK_CLOCK) && CPUISMIPS3) { + + if (ipending & MIPS_INT_MASK_CLOCK) { /* * Writing a value to the Compare register, * as a side effect, clears the timer interrupt request. */ mips3_cp0_compare_write(mips3_cp0_count_read()); } -#endif uvmexp.intrs++; /* real device interrupt */ @@ -149,30 +148,12 @@ _splset(arc_hardware_intr(status, cause, pc, ipending)); } -#if defined(MIPS1) && defined(INT_MASK_FPU) - if ((ipending & INT_MASK_FPU) && CPUISMIPS1) { - intrcnt[FPU_INTR]++; - if (!USERMODE(status)) - panic("kernel used FPU: PC %x, CR %x, SR %x", - pc, cause, status); -#if !defined(SOFTFLOAT) - MachFPInterrupt(status, cause, pc, curlwp->l_md.md_regs); -#endif - } -#endif + /* software interrupts */ + ipending &= (MIPS_SOFT_INT_MASK_1|MIPS_SOFT_INT_MASK_0); + if (ipending == 0) + return; - /* 'softnet' interrupt */ - if (ipending & MIPS_SOFT_INT_MASK_1) { - clearsoftnet(); - uvmexp.softs++; - netintr(); - } + _clrsoftintr(ipending); - /* 'softclock' interrupt */ - if (ipending & MIPS_SOFT_INT_MASK_0) { - clearsoftclock(); - uvmexp.softs++; - intrcnt[SOFTCLOCK_INTR]++; - softclock(NULL); - } + softintr_dispatch(ipending); } Index: arc/arc/autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/autoconf.c,v retrieving revision 1.18 diff -u -r1.18 autoconf.c --- arc/arc/autoconf.c 2002/09/27 02:24:09 1.18 +++ arc/arc/autoconf.c 2003/05/25 09:28:48 @@ -91,6 +91,9 @@ void cpu_configure() { + + softintr_init(); + (void)splhigh(); /* To be really sure.. */ if (config_rootfound("mainbus", "mainbus") == NULL) panic("no mainbus found"); Index: arc/arc/c_magnum.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/c_magnum.c,v retrieving revision 1.3 diff -u -r1.3 c_magnum.c --- arc/arc/c_magnum.c 2003/04/27 11:33:36 1.3 +++ arc/arc/c_magnum.c 2003/05/25 09:28:48 @@ -80,6 +80,54 @@ timer_magnum_init, }; +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +static const u_int32_t magnum_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3, /* IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3, /* IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3, /* IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */ +}; + int timer_magnum_intr(mask, cf) u_int mask; @@ -189,12 +237,7 @@ /* * Initialize interrupt priority */ - splvec.splnet = MIPS_INT_MASK_SPL3; - splvec.splbio = MIPS_INT_MASK_SPL3; - splvec.splvm = MIPS_INT_MASK_SPL3; - splvec.spltty = MIPS_INT_MASK_SPL3; - splvec.splclock = MIPS_INT_MASK_SPL5; - splvec.splstatclock = MIPS_INT_MASK_SPL5; + ipl_sr_bits = magnum_ipl_sr_bits; /* * Disable all interrupts. New masks will be set up Index: arc/arc/c_nec_eisa.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/c_nec_eisa.c,v retrieving revision 1.5 diff -u -r1.5 c_nec_eisa.c --- arc/arc/c_nec_eisa.c 2003/01/31 22:07:52 1.5 +++ arc/arc/c_nec_eisa.c 2003/05/25 09:28:49 @@ -73,6 +73,51 @@ isabr_nec_eisa_intr_status, }; +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +static const u_int32_t nec_eisa_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */ +}; + int isabr_nec_eisa_intr_status() { @@ -131,12 +176,7 @@ /* * Initialize interrupt priority */ - splvec.splnet = MIPS_INT_MASK_SPL2; - splvec.splbio = MIPS_INT_MASK_SPL2; - splvec.splvm = MIPS_INT_MASK_SPL2; - splvec.spltty = MIPS_INT_MASK_SPL2; - splvec.splclock = MIPS_INT_MASK_SPL5; - splvec.splstatclock = MIPS_INT_MASK_SPL5; + ipl_sr_bits = nec_eisa_ipl_sr_bits; /* * Disable all interrupts. New masks will be set up Index: arc/arc/c_nec_pci.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/c_nec_pci.c,v retrieving revision 1.4 diff -u -r1.4 c_nec_pci.c --- arc/arc/c_nec_pci.c 2003/01/19 10:06:12 1.4 +++ arc/arc/c_nec_pci.c 2003/05/25 09:28:49 @@ -98,6 +98,51 @@ { mc_nec_pci_read, mc_nec_pci_write } }; +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +static const u_int32_t nec_pci_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */ +}; + u_int mc_nec_pci_read(sc, reg) struct mcclock_softc *sc; @@ -194,12 +239,7 @@ /* * Initialize interrupt priority */ - splvec.splnet = MIPS_INT_MASK_SPL2; - splvec.splbio = MIPS_INT_MASK_SPL2; - splvec.splvm = MIPS_INT_MASK_SPL2; - splvec.spltty = MIPS_INT_MASK_SPL2; - splvec.splclock = MIPS_INT_MASK_SPL5; - splvec.splstatclock = MIPS_INT_MASK_SPL5; + ipl_sr_bits = nec_pci_ipl_sr_bits; /* * Disable all interrupts. New masks will be set up Index: arc/arc/locore_machdep.S =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/locore_machdep.S,v retrieving revision 1.8 diff -u -r1.8 locore_machdep.S --- arc/arc/locore_machdep.S 2000/06/09 05:07:32 1.8 +++ arc/arc/locore_machdep.S 2003/05/25 09:28:49 @@ -392,19 +392,14 @@ /* - * Interrupt counters for vmstat. + * Symbols that vmstat -i wants, even though they're not used. */ .data .globl _C_LABEL(intrcnt) .globl _C_LABEL(eintrcnt) .globl _C_LABEL(intrnames) .globl _C_LABEL(eintrnames) -_C_LABEL(intrnames): - .asciiz "softclock" - .asciiz "softnet" - .asciiz "fpu" -_C_LABEL(eintrnames): - .align 3 _C_LABEL(intrcnt): - .word 0,0,0 _C_LABEL(eintrcnt): +_C_LABEL(intrnames): +_C_LABEL(eintrnames): Index: arc/arc/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/machdep.c,v retrieving revision 1.77 diff -u -r1.77 machdep.c --- arc/arc/machdep.c 2003/04/27 17:05:56 1.77 +++ arc/arc/machdep.c 2003/05/25 09:28:50 @@ -180,13 +180,12 @@ */ int safepri = MIPS3_PSL_LOWIPL; -struct splvec splvec = { /* XXX will go XXX */ - MIPS_INT_MASK_SPLHIGH, /* splbio */ - MIPS_INT_MASK_SPLHIGH, /* splnet */ - MIPS_INT_MASK_SPLHIGH, /* spltty */ - MIPS_INT_MASK_SPLHIGH, /* splvm */ - MIPS_INT_MASK_SPLHIGH, /* splclock */ - MIPS_INT_MASK_SPLHIGH, /* splstatclock */ +const u_int32_t *ipl_sr_bits; +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ }; extern char kernel_text[], edata[], end[]; Index: arc/arc/p_dti_arcstation.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/p_dti_arcstation.c,v retrieving revision 1.1 diff -u -r1.1 p_dti_arcstation.c --- arc/arc/p_dti_arcstation.c 2001/06/13 15:27:17 1.1 +++ arc/arc/p_dti_arcstation.c 2003/05/25 09:28:50 @@ -95,6 +95,61 @@ arc_set_intr, }; +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +/* XXX see comments in p_dti_arcstation_init() */ +static const u_int32_t dti_arcstation_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{CLOCK,HIGH} */ +}; + #if NPC_ISA > 0 || NOPMS_ISA > 0 /* * platform-dependent pccons configuration @@ -202,6 +257,7 @@ * or * - use MIP3_INTERNAL_TIMER_INTERRUPT for clock */ + ipl_sr_bits = dti_arcstation_ipl_sr_bits; /* * common configuration for DTI platforms Index: arc/arc/p_dti_tyne.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/p_dti_tyne.c,v retrieving revision 1.1 diff -u -r1.1 p_dti_tyne.c --- arc/arc/p_dti_tyne.c 2001/06/13 15:27:18 1.1 +++ arc/arc/p_dti_tyne.c 2003/05/25 09:28:50 @@ -97,6 +97,61 @@ arc_set_intr, }; +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +/* XXX see comments in p_dti_tyne_init() */ +static const u_int32_t dti_tyne_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{CLOCK,HIGH} */ +}; + #if NPC_ISA > 0 || NOPMS_ISA > 0 /* * platform-dependent pccons configuration @@ -199,6 +254,7 @@ * or * - use MIP3_INTERNAL_TIMER_INTERRUPT for clock */ + ipl_sr_bits = dti_tyne_ipl_sr_bits; /* * common configuration for DTI platforms Index: arc/arc/p_sni_rm200pci.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/arc/p_sni_rm200pci.c,v retrieving revision 1.1 diff -u -r1.1 p_sni_rm200pci.c --- arc/arc/p_sni_rm200pci.c 2001/06/13 15:36:44 1.1 +++ arc/arc/p_sni_rm200pci.c 2003/05/25 09:28:50 @@ -79,6 +79,61 @@ }; /* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +/* XXX lack of hardware info for sni_rm200pci */ +static const u_int32_t sni_rm200pci_ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2| + MIPS_INT_MASK_3| + MIPS_INT_MASK_4| + MIPS_INT_MASK_5, /* XXX IPL_{CLOCK,HIGH} */ +}; + +/* * critial i/o space, interrupt, and other chipset related initialization. */ void @@ -109,6 +164,7 @@ /* * Initialize interrupt priority */ + ipl_sr_bits = sni_rm200pci_ipl_sr_bits; } void Index: arc/conf/files.arc =================================================================== RCS file: /cvsroot/src/sys/arch/arc/conf/files.arc,v retrieving revision 1.44 diff -u -r1.44 files.arc --- arc/conf/files.arc 2003/05/04 10:07:50 1.44 +++ arc/conf/files.arc 2003/05/25 09:28:50 @@ -80,6 +80,8 @@ file arch/arc/arc/arcbios.c +file arch/mips/mips/softintr.c + ## ## Machine-independent ATAPI drivers ## Index: arc/conf/std.arc =================================================================== RCS file: /cvsroot/src/sys/arch/arc/conf/std.arc,v retrieving revision 1.14 diff -u -r1.14 std.arc --- arc/conf/std.arc 2003/04/28 05:03:44 1.14 +++ arc/conf/std.arc 2003/05/25 09:28:50 @@ -18,6 +18,4 @@ options MIPS3_L2CACHE_ABSENT # may not have L2 cache -options __NO_SOFT_SERIAL_INTERRUPT # for "com" driver - makeoptions DEFTEXTADDR="0x80200000" Index: arc/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/arc/include/intr.h,v retrieving revision 1.10 diff -u -r1.10 intr.h --- arc/include/intr.h 2001/06/13 15:08:06 1.10 +++ arc/include/intr.h 2003/05/25 09:28:50 @@ -1,8 +1,12 @@ /* $NetBSD: intr.h,v 1.10 2001/06/13 15:08:06 soda Exp $ */ -/* - * Copyright (c) 1998 Jonathan Stone. All rights reserved. +/*- + * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,38 +17,58 @@ * 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 Jonathan Stone for - * the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 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 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. + * 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. */ #ifndef _ARC_INTR_H_ #define _ARC_INTR_H_ #define IPL_NONE 0 /* disable only this interrupt */ -#define IPL_BIO 1 /* disable block I/O interrupts */ -#define IPL_NET 2 /* disable network interrupts */ -#define IPL_TTY 3 /* disable terminal interrupts */ -#define IPL_IMP 4 /* memory allocation */ -#define IPL_CLOCK 5 /* disable clock interrupts */ -#define IPL_STATCLOCK 6 /* disable profiling interrupts */ -#if 0 /* XXX */ + +#define IPL_SOFT 1 /* generic software interrupts (SI 0) */ +#define IPL_SOFTCLOCK 2 /* clock software interrupts (SI 0) */ +#define IPL_SOFTNET 3 /* network software interrupts (SI 1) */ +#define IPL_SOFTSERIAL 4 /* serial software interrupts (SI 1) */ + +#define IPL_BIO 5 /* disable block I/O interrupts */ +#define IPL_NET 6 /* disable network interrupts */ +#define IPL_TTY 7 /* disable terminal interrupts */ #define IPL_SERIAL 7 /* disable serial hardware interrupts */ -#endif +#define IPL_CLOCK 8 /* disable clock interrupts */ +#define IPL_STATCLOCK 8 /* disable profiling interrupts */ #define IPL_HIGH 8 /* disable all interrupts */ -#define NIPL 9 + +#define _IPL_NSOFT 4 +#define _IPL_N 9 + +#define _IPL_SI0_FIRST IPL_SOFT +#define _IPL_SI0_LAST IPL_SOFTCLOCK + +#define _IPL_SI1_FIRST IPL_SOFTNET +#define _IPL_SI1_LAST IPL_SOFTSERIAL + +#define IPL_SOFTNAMES { \ + "misc", \ + "clock", \ + "net", \ + "serial", \ +} /* Interrupt sharing types. */ #define IST_NONE 0 /* none */ @@ -52,86 +76,45 @@ #define IST_EDGE 2 /* edge-triggered */ #define IST_LEVEL 3 /* level-triggered */ -/* Soft interrupt masks. */ -/* XXX - revisit here */ -#define SIR_CLOCK 31 -#define SIR_NET 30 -#define SIR_CLOCKMASK ((1 << SIR_CLOCK)) -#define SIR_NETMASK ((1 << SIR_NET) | SIR_CLOCKMASK) -#define SIR_ALLMASK (SIR_CLOCKMASK | SIR_NETMASK) - #ifdef _KERNEL #ifndef _LOCORE - -#include -extern int _splraise __P((int)); -extern int _spllower __P((int)); -extern int _splset __P((int)); -extern int _splget __P((void)); -extern void _splnone __P((void)); -extern void _setsoftintr __P((int)); -extern void _clrsoftintr __P((int)); - -#define setsoftclock() _setsoftintr(MIPS_SOFT_INT_MASK_0) -#define setsoftnet() _setsoftintr(MIPS_SOFT_INT_MASK_1) -#define clearsoftclock() _clrsoftintr(MIPS_SOFT_INT_MASK_0) -#define clearsoftnet() _clrsoftintr(MIPS_SOFT_INT_MASK_1) +extern const u_int32_t *ipl_sr_bits; -/* - * nesting interrupt masks. - */ -#define MIPS_INT_MASK_SPL_SOFT0 MIPS_SOFT_INT_MASK_0 -#define MIPS_INT_MASK_SPL_SOFT1 (MIPS_SOFT_INT_MASK_1|MIPS_INT_MASK_SPL_SOFT0) -#define MIPS_INT_MASK_SPL0 (MIPS_INT_MASK_0|MIPS_INT_MASK_SPL_SOFT1) -#define MIPS_INT_MASK_SPL1 (MIPS_INT_MASK_1|MIPS_INT_MASK_SPL0) -#define MIPS_INT_MASK_SPL2 (MIPS_INT_MASK_2|MIPS_INT_MASK_SPL1) -#define MIPS_INT_MASK_SPL3 (MIPS_INT_MASK_3|MIPS_INT_MASK_SPL2) -#define MIPS_INT_MASK_SPL4 (MIPS_INT_MASK_4|MIPS_INT_MASK_SPL3) -#define MIPS_INT_MASK_SPL5 (MIPS_INT_MASK_5|MIPS_INT_MASK_SPL4) -#define MIPS_INT_MASK_SPLHIGH MIPS_INT_MASK_SPL5 +extern int _splraise(int); +extern int _spllower(int); +extern int _splset(int); +extern int _splget(void); +extern void _splnone(void); +extern void _setsoftintr(int); +extern void _clrsoftintr(int); +#define splhigh() _splraise(ipl_sr_bits[IPL_HIGH]) #define spl0() (void)_spllower(0) #define splx(s) (void)_splset(s) -#define splbio() (_splraise(splvec.splbio)) -#define splnet() (_splraise(splvec.splnet)) -#define spltty() (_splraise(splvec.spltty)) -#define splvm() (_splraise(splvec.splvm)) -#define splclock() (_splraise(splvec.splclock)) -#define splstatclock() (_splraise(splvec.splstatclock)) -#define splhigh() _splraise(MIPS_INT_MASK_SPLHIGH) - -#define splsoftclock() _splraise(MIPS_INT_MASK_SPL_SOFT0) -#define splsoftnet() _splraise(MIPS_INT_MASK_SPL_SOFT1) -#define spllowersoftclock() _spllower(MIPS_INT_MASK_SPL_SOFT0) +#define splbio() _splraise(ipl_sr_bits[IPL_BIO]) +#define splnet() _splraise(ipl_sr_bits[IPL_NET]) +#define spltty() _splraise(ipl_sr_bits[IPL_TTY]) +#define splserial() _splraise(ipl_sr_bits[IPL_SERIAL]) +#define splvm() spltty() +#define splclock() _splraise(ipl_sr_bits[IPL_CLOCK]) +#define splstatclock() splclock() -#define splsched() splhigh() -#define spllock() splhigh() +#define splsched() splclock() +#define spllock() splhigh() #define spllpt() spltty() /* lpt driver */ -struct splvec { - int splbio; - int splnet; - int spltty; - int splvm; - int splclock; - int splstatclock; -}; -extern struct splvec splvec; +#define splsoft() _splraise(ipl_sr_bits[IPL_SOFT]) +#define splsoftclock() _splraise(ipl_sr_bits[IPL_SOFTCLOCK]) +#define splsoftnet() _splraise(ipl_sr_bits[IPL_SOFTNET]) +#define splsoftserial() _splraise(ipl_sr_bits[IPL_SOFTSERIAL]) -/* - * Index into intrcnt[], which is defined in locore - */ -#define SOFTCLOCK_INTR 0 -#define SOFTNET_INTR 1 -#define FPU_INTR 2 -extern u_long intrcnt[]; +#define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK]) -struct clockframe; -void arc_set_intr __P((int, int(*)(u_int, struct clockframe *), int)); +#include -/* XXX - revisit here */ -int imask[NIPL]; +struct clockframe; +void arc_set_intr(int, int(*)(u_int, struct clockframe *), int); #endif /* !_LOCORE */ #endif /* _KERNEL */ Index: arc/include/types.h =================================================================== RCS file: /cvsroot/src/sys/arch/arc/include/types.h,v retrieving revision 1.13 diff -u -r1.13 types.h --- arc/include/types.h 2002/03/05 16:12:36 1.13 +++ arc/include/types.h 2003/05/25 09:28:51 @@ -6,6 +6,7 @@ #include +#define __HAVE_GENERIC_SOFT_INTERRUPTS #define __HAVE_DEVICE_REGISTER #define __HAVE_NWSCONS Index: arc/isa/isabus.c =================================================================== RCS file: /cvsroot/src/sys/arch/arc/isa/isabus.c,v retrieving revision 1.19 diff -u -r1.19 isabus.c --- arc/isa/isabus.c 2003/04/27 17:05:58 1.19 +++ arc/isa/isabus.c 2003/05/25 09:28:51 @@ -133,6 +133,7 @@ int fakeintr __P((void *a)); struct isabr_config *isabr_conf = NULL; +u_int32_t imask[_IPL_N]; /* XXX */ void isabrattach(sc) @@ -217,39 +218,47 @@ } /* Then figure out which IRQs use each level. */ - for (level = 0; level < 5; level++) { + for (level = 0; level < _IPL_N; level++) { int irqs = 0; for (irq = 0; irq < ICU_LEN; irq++) if (intrlevel[irq] & (1 << level)) irqs |= 1 << irq; - imask[level] = irqs | SIR_ALLMASK; + imask[level] = irqs; } - /* - * There are tty, network and disk drivers that use free() at interrupt - * time, so imp > (tty | net | bio). - */ - imask[IPL_IMP] |= imask[IPL_TTY] | imask[IPL_NET] | imask[IPL_BIO]; + imask[IPL_NONE] = 0; + + imask[IPL_SOFT] |= imask[IPL_NONE]; + imask[IPL_SOFTCLOCK] |= imask[IPL_SOFT]; + imask[IPL_SOFTNET] |= imask[IPL_SOFTCLOCK]; + imask[IPL_SOFTSERIAL] |= imask[IPL_SOFTNET]; /* * Enforce a hierarchy that gives slow devices a better chance at not * dropping data. */ - imask[IPL_TTY] |= imask[IPL_NET] | imask[IPL_BIO]; + imask[IPL_BIO] |= imask[IPL_SOFTSERIAL]; imask[IPL_NET] |= imask[IPL_BIO]; + imask[IPL_TTY] |= imask[IPL_NET]; + + /* + * Since run queues may be manipulated by both the statclock and tty, + * network, and diskdrivers, clock > tty. + */ + imask[IPL_CLOCK] |= imask[IPL_TTY]; + imask[IPL_STATCLOCK] |= imask[IPL_CLOCK]; /* - * These are pseudo-levels. + * IPL_HIGH must block everything that can manipulate a run queue. */ - imask[IPL_NONE] = 0x00000000; - imask[IPL_HIGH] = 0xffffffff; + imask[IPL_HIGH] |= imask[IPL_STATCLOCK]; /* And eventually calculate the complete masks. */ for (irq = 0; irq < ICU_LEN; irq++) { int irqs = 1 << irq; for (q = intrhand[irq]; q; q = q->ih_next) irqs |= imask[q->ih_level]; - intrmask[irq] = irqs | SIR_ALLMASK; + intrmask[irq] = irqs; } /* Lastly, determine which IRQs are actually in use. */ Index: evbmips/conf/files.malta =================================================================== RCS file: /cvsroot/src/sys/arch/evbmips/conf/files.malta,v retrieving revision 1.6 diff -u -r1.6 files.malta --- evbmips/conf/files.malta 2002/10/28 13:33:07 1.6 +++ evbmips/conf/files.malta 2003/05/25 09:28:54 @@ -15,6 +15,8 @@ file arch/evbmips/evbmips/interrupt.c file arch/evbmips/evbmips/yamon.c # XXX should be in arch/mips/yamon ? +file arch/mips/mips/softintr.c + # The autoconfiguration root. device mainbus { [addr = -1] } attach mainbus at root Index: evbmips/conf/files.pb1000 =================================================================== RCS file: /cvsroot/src/sys/arch/evbmips/conf/files.pb1000,v retrieving revision 1.5 diff -u -r1.5 files.pb1000 --- evbmips/conf/files.pb1000 2003/04/01 17:40:19 1.5 +++ evbmips/conf/files.pb1000 2003/05/25 09:28:54 @@ -11,6 +11,8 @@ file arch/evbmips/evbmips/interrupt.c file arch/evbmips/evbmips/yamon.c +file arch/mips/mips/softintr.c + # System bus device mainbus { } attach mainbus at root Index: evbmips/evbmips/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/evbmips/evbmips/interrupt.c,v retrieving revision 1.4 diff -u -r1.4 interrupt.c --- evbmips/evbmips/interrupt.c 2002/11/10 15:21:51 1.4 +++ evbmips/evbmips/interrupt.c 2003/05/25 09:28:54 @@ -37,7 +37,6 @@ */ #include -#include #include #include @@ -47,9 +46,6 @@ #include -struct evbmips_soft_intrhand *softnet_intrhand; -struct evbmips_soft_intr evbmips_soft_intrs[_IPL_NSOFT]; - struct evcnt mips_int5_evcnt = EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "mips", "int 5 (clock)"); @@ -70,10 +66,7 @@ cpu_intr(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending) { struct clockframe cf; - struct evbmips_soft_intr *si; - struct evbmips_soft_intrhand *sih; uint32_t new_cnt; - int i, s; uvmexp.intrs++; @@ -122,111 +115,6 @@ return; _clrsoftintr(ipending); - - for (i = _IPL_NSOFT - 1; i >= 0; i--) { - if ((ipending & ipl_si_to_sr[i]) == 0) - continue; - - si = &evbmips_soft_intrs[i]; - - if (TAILQ_FIRST(&si->softintr_q) != NULL) - si->softintr_evcnt.ev_count++; - - for (;;) { - s = splhigh(); - - sih = TAILQ_FIRST(&si->softintr_q); - if (sih != NULL) { - TAILQ_REMOVE(&si->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - - splx(s); - - if (sih == NULL) - break; - - uvmexp.softs++; - (*sih->sih_fn)(sih->sih_arg); - } - } -} - -/* - * softintr_init: - * - * Initialize the software interrupt system. - */ -void -softintr_init(void) -{ - static const char *softintr_names[] = IPL_SOFTNAMES; - struct evbmips_soft_intr *si; - int i; - - for (i = 0; i < _IPL_NSOFT; i++) { - si = &evbmips_soft_intrs[i]; - TAILQ_INIT(&si->softintr_q); - simple_lock_init(&si->softintr_slock); - si->softintr_ipl = IPL_SOFT + i; - evcnt_attach_dynamic(&si->softintr_evcnt, EVCNT_TYPE_INTR, - NULL, "soft", softintr_names[i]); - } - - /* XXX Establish legacy software interrupt handlers. */ - softnet_intrhand = softintr_establish(IPL_SOFTNET, - (void (*)(void *))netintr, NULL); - - assert(softnet_intrhand != NULL); -} - -/* - * softintr_establish: [interface] - * - * Register a software interrupt handler. - */ -void * -softintr_establish(int ipl, void (*func)(void *), void *arg) -{ - struct evbmips_soft_intr *si; - struct evbmips_soft_intrhand *sih; - - if (__predict_false(ipl >= (IPL_SOFT + _IPL_NSOFT) || - ipl < IPL_SOFT)) - panic("softintr_establish"); - - si = &evbmips_soft_intrs[ipl - IPL_SOFT]; - - sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); - if (__predict_true(sih != NULL)) { - sih->sih_intrhead = si; - sih->sih_fn = func; - sih->sih_arg = arg; - sih->sih_pending = 0; - } - return (sih); -} - -/* - * softintr_disestablish: [interface] - * - * Unregister a software interrupt handler. - */ -void -softintr_disestablish(void *arg) -{ - struct evbmips_soft_intrhand *sih = arg; - struct evbmips_soft_intr *si = sih->sih_intrhead; - int s; - - s = splhigh(); - simple_lock(&si->softintr_slock); - if (sih->sih_pending) { - TAILQ_REMOVE(&si->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - simple_unlock(&si->softintr_slock); - splx(s); - free(sih, M_DEVBUF); + softintr_dispatch(ipending); } Index: evbmips/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/evbmips/include/intr.h,v retrieving revision 1.4 diff -u -r1.4 intr.h --- evbmips/include/intr.h 2003/04/01 17:34:10 1.4 +++ evbmips/include/intr.h 2003/05/25 09:28:54 @@ -123,53 +123,7 @@ int ih_irq; }; -#define setsoft(x) \ -do { \ - _setsoftintr(ipl_si_to_sr[(x) - IPL_SOFT]); \ -} while (0) - -struct evbmips_soft_intrhand { - TAILQ_ENTRY(evbmips_soft_intrhand) - sih_q; - struct evbmips_soft_intr *sih_intrhead; - void (*sih_fn)(void *); - void *sih_arg; - int sih_pending; -}; - -struct evbmips_soft_intr { - TAILQ_HEAD(, evbmips_soft_intrhand) - softintr_q; - struct evcnt softintr_evcnt; - struct simplelock softintr_slock; - unsigned long softintr_ipl; -}; - -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_init(void); - -#define softintr_schedule(arg) \ -do { \ - struct evbmips_soft_intrhand *__sih = (arg); \ - struct evbmips_soft_intr *__si = __sih->sih_intrhead; \ - int __s; \ - \ - __s = splhigh(); \ - simple_lock(&__si->softintr_slock); \ - if (__sih->sih_pending == 0) { \ - TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ - __sih->sih_pending = 1; \ - setsoft(__si->softintr_ipl); \ - } \ - simple_unlock(&__si->softintr_slock); \ - splx(__s); \ -} while (0) - -/* XXX For legacy software interrupts. */ -extern struct evbmips_soft_intrhand *softnet_intrhand; - -#define setsoftnet() softintr_schedule(softnet_intrhand) +#include void evbmips_intr_init(void); void intr_init(void); Index: evbmips/malta/malta_intr.c =================================================================== RCS file: /cvsroot/src/sys/arch/evbmips/malta/malta_intr.c,v retrieving revision 1.7 diff -u -r1.7 malta_intr.c --- evbmips/malta/malta_intr.c 2002/12/06 05:46:47 1.7 +++ evbmips/malta/malta_intr.c 2003/05/25 09:28:55 @@ -101,7 +101,7 @@ * given software interrupt priority level. * Hardware ipls are port/board specific. */ -const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = { +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ Index: hpcmips/conf/files.hpcmips =================================================================== RCS file: /cvsroot/src/sys/arch/hpcmips/conf/files.hpcmips,v retrieving revision 1.90 diff -u -r1.90 files.hpcmips --- hpcmips/conf/files.hpcmips 2003/05/01 07:01:58 1.90 +++ hpcmips/conf/files.hpcmips 2003/05/25 09:28:56 @@ -53,6 +53,8 @@ file arch/hpcmips/hpcmips/machdep.c file arch/hpcmips/hpcmips/mainbus.c +file arch/mips/mips/softintr.c + file arch/hpc/hpc/kloader.c kloader file arch/hpcmips/hpcmips/kloader_machdep.c kloader file arch/hpcmips/hpcmips/kloader_vr41.S vr41xx & kloader Index: hpcmips/hpcmips/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/hpcmips/hpcmips/interrupt.c,v retrieving revision 1.7 diff -u -r1.7 interrupt.c --- hpcmips/hpcmips/interrupt.c 2002/01/29 18:38:32 1.7 +++ hpcmips/hpcmips/interrupt.c 2003/05/25 09:28:57 @@ -40,7 +40,6 @@ #include "opt_tx39xx.h" #include -#include #include @@ -49,7 +48,7 @@ extern const u_int32_t __ipl_sr_bits_vr[]; extern const u_int32_t __ipl_sr_bits_tx[]; -const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = { +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ @@ -57,8 +56,6 @@ }; const u_int32_t *ipl_sr_bits; -struct hpcmips_soft_intrhand *softnet_intrhand; -struct hpcmips_soft_intr hpcmips_soft_intrs[_IPL_NSOFT]; void intr_init() @@ -81,129 +78,13 @@ { (*platform.cpu_intr)(status, cause, pc, ipending); -} -#endif /* VR41XX && TX39XX */ - -/* - * softintr: - * - * dispatch pending software interrupt handler. - */ -void -softintr(u_int32_t ipending) -{ - struct hpcmips_soft_intr *asi; - struct hpcmips_soft_intrhand *sih; - int i, s; ipending &= (MIPS_SOFT_INT_MASK_1 | MIPS_SOFT_INT_MASK_0); if (ipending == 0) return; _clrsoftintr(ipending); - - for (i = _IPL_NSOFT - 1; i >= 0; i--) { - if ((ipending & ipl_si_to_sr[i]) == 0) - continue; - - asi = &hpcmips_soft_intrs[i]; - if (TAILQ_FIRST(&asi->softintr_q) != NULL) - asi->softintr_evcnt.ev_count++; - - for (;;) { - s = splhigh(); - - sih = TAILQ_FIRST(&asi->softintr_q); - if (sih != NULL) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - - splx(s); - - if (sih == NULL) - break; - - uvmexp.softs++; - (*sih->sih_fn)(sih->sih_arg); - } - } + softintr_dispatch(ipending); } - -/* - * softintr_init: - * - * Initialize the software interrupt system. - */ -void -softintr_init(void) -{ - static const char *softintr_names[] = IPL_SOFTNAMES; - struct hpcmips_soft_intr *asi; - int i; - - for (i = 0; i < _IPL_NSOFT; i++) { - asi = &hpcmips_soft_intrs[i]; - TAILQ_INIT(&asi->softintr_q); - asi->softintr_ipl = IPL_SOFT + i; - simple_lock_init(&asi->softintr_slock); - evcnt_attach_dynamic(&asi->softintr_evcnt, EVCNT_TYPE_INTR, - NULL, "soft", softintr_names[i]); - } - - /* XXX Establish legacy soft interrupt handlers. */ - softnet_intrhand = softintr_establish(IPL_SOFTNET, - (void (*)(void *))netintr, NULL); - - assert(softnet_intrhand != NULL); -} - -/* - * softintr_establish: [interface] - * - * Register a software interrupt handler. - */ -void * -softintr_establish(int ipl, void (*func)(void *), void *arg) -{ - struct hpcmips_soft_intr *asi; - struct hpcmips_soft_intrhand *sih; - - if (__predict_false(ipl >= (IPL_SOFT + _IPL_NSOFT) || - ipl < IPL_SOFT)) - panic("softintr_establish"); - - asi = &hpcmips_soft_intrs[ipl - IPL_SOFT]; - - sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); - if (__predict_true(sih != NULL)) { - sih->sih_intrhead = asi; - sih->sih_fn = func; - sih->sih_arg = arg; - sih->sih_pending = 0; - } - return (sih); -} - -/* - * softintr_disestablish: [interface] - * - * Unregister a software interrupt handler. - */ -void -softintr_disestablish(void *arg) -{ - struct hpcmips_soft_intrhand *sih = arg; - struct hpcmips_soft_intr *asi = sih->sih_intrhead; - int s; - - s = splhigh(); - if (sih->sih_pending) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - splx(s); - - free(sih, M_DEVBUF); -} +#endif /* VR41XX && TX39XX */ Index: hpcmips/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/hpcmips/include/intr.h,v retrieving revision 1.16 diff -u -r1.16 intr.h --- hpcmips/include/intr.h 2002/05/15 15:19:54 1.16 +++ hpcmips/include/intr.h 2003/05/25 09:28:57 @@ -113,58 +113,7 @@ #define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK]) -/* - * software simulated interrupt - */ -#define setsoft(x) \ -do { \ - _setsoftintr(ipl_si_to_sr[(x) - IPL_SOFT]); \ -} while (0) - -struct hpcmips_soft_intrhand { - TAILQ_ENTRY(hpcmips_soft_intrhand) - sih_q; - struct hpcmips_soft_intr *sih_intrhead; - void (*sih_fn)(void *); - void *sih_arg; - int sih_pending; -}; - -struct hpcmips_soft_intr { - TAILQ_HEAD(, hpcmips_soft_intrhand) - softintr_q; - struct evcnt softintr_evcnt; - struct simplelock softintr_slock; - unsigned long softintr_ipl; -}; - -void softintr_init(void); -void softintr(u_int32_t); -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_dispatch(void); - -#define softintr_schedule(arg) \ -do { \ - struct hpcmips_soft_intrhand *__sih = (arg); \ - struct hpcmips_soft_intr *__si = __sih->sih_intrhead; \ - int __s; \ - \ - __s = splhigh(); \ - simple_lock(&__si->softintr_slock); \ - if (__sih->sih_pending == 0) { \ - TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ - __sih->sih_pending = 1; \ - setsoft(__si->softintr_ipl); \ - } \ - simple_unlock(&__si->softintr_slock); \ - splx(__s); \ -} while (0) - -/* XXX For legacy software interrupts. */ -extern struct hpcmips_soft_intrhand *softnet_intrhand; - -#define setsoftnet() softintr_schedule(softnet_intrhand) +#include #endif /* !_LOCORE */ #endif /* _KERNEL */ Index: hpcmips/tx/tx39icu.c =================================================================== RCS file: /cvsroot/src/sys/arch/hpcmips/tx/tx39icu.c,v retrieving revision 1.20 diff -u -r1.20 tx39icu.c --- hpcmips/tx/tx39icu.c 2002/10/02 05:26:50 1.20 +++ hpcmips/tx/tx39icu.c 2003/05/25 09:28:58 @@ -333,7 +333,7 @@ uvmexp.intrs++; if ((ipending & MIPS_HARD_INT_MASK) == 0) - goto softintr; + goto out; tc = tx_conf_get_tag(); sc = tc->tc_intrt; @@ -366,7 +366,7 @@ if (ipending & MIPS_INT_MASK_4) { tx39_irqhigh_intr(ipending, pc, status, cause); - goto softintr; + goto out; } /* IRQLOW */ @@ -423,10 +423,8 @@ tx_conf_write(tc, TX39_INTRENABLE6_REG, reg); #endif - softintr: + out: _splset((status & ~cause & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE); - - softintr(ipending); } int Index: hpcmips/vr/vr.c =================================================================== RCS file: /cvsroot/src/sys/arch/hpcmips/vr/vr.c,v retrieving revision 1.41 diff -u -r1.41 vr.c --- hpcmips/vr/vr.c 2003/04/02 03:58:13 1.41 +++ hpcmips/vr/vr.c 2003/05/25 09:28:59 @@ -568,8 +568,6 @@ cause &= ~MIPS_INT_MASK_0; } _splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE); - - softintr(ipending); } void * Index: mips/alchemy/au_icu.c =================================================================== RCS file: /cvsroot/src/sys/arch/mips/alchemy/au_icu.c,v retrieving revision 1.5 diff -u -r1.5 au_icu.c --- mips/alchemy/au_icu.c 2003/04/01 17:28:24 1.5 +++ mips/alchemy/au_icu.c 2003/05/25 09:29:01 @@ -104,7 +104,7 @@ * given software interrupt priority level. * Hardware ipls are port/board specific. */ -const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = { +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTNET */ Index: mipsco/conf/files.mipsco =================================================================== RCS file: /cvsroot/src/sys/arch/mipsco/conf/files.mipsco,v retrieving revision 1.10 diff -u -r1.10 files.mipsco --- mipsco/conf/files.mipsco 2002/10/26 13:50:34 1.10 +++ mipsco/conf/files.mipsco 2003/05/25 09:29:02 @@ -62,6 +62,8 @@ file dev/clock_subr.c file dev/cons.c +file arch/mips/mips/softintr.c + # Memory Disk file dev/md_root.c memory_disk_hooks Index: mipsco/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/mipsco/include/intr.h,v retrieving revision 1.9 diff -u -r1.9 intr.h --- mipsco/include/intr.h 2002/01/14 19:08:35 1.9 +++ mipsco/include/intr.h 2003/05/25 09:29:02 @@ -41,7 +41,7 @@ #define IPL_STATCLOCK 5 /* disable profiling interrupts */ #define IPL_SERIAL 6 /* disable serial hardware interrupts */ #define IPL_HIGH 7 /* disable all interrupts */ -#define NIPL 8 +#define _IPL_N 8 /* Interrupt sharing types. */ #define IST_NONE 0 /* none */ @@ -49,12 +49,14 @@ #define IST_EDGE 2 /* edge-triggered */ #define IST_LEVEL 3 /* level-triggered */ -#define IPL_SOFTSERIAL 0 /* serial software interrupts */ -#define IPL_SOFTNET 1 /* network software interrupts */ -#define IPL_SOFTCLOCK 2 /* clock software interrupts */ -#define IPL_NSOFT 3 +#define IPL_SOFT 0 /* generic software interrupts */ +#define IPL_SOFTSERIAL 1 /* serial software interrupts */ +#define IPL_SOFTNET 2 /* network software interrupts */ +#define IPL_SOFTCLOCK 3 /* clock software interrupts */ +#define _IPL_NSOFT 4 #define IPL_SOFTNAMES { \ + "misc", \ "serial", \ "net", \ "clock", \ @@ -74,30 +76,8 @@ extern void _setsoftintr __P((int)); extern void _clrsoftintr __P((int)); -/* - * software simulated interrupt - */ -#define setsoft(x) do { \ - extern u_int ssir; \ - int s; \ - \ - s = splhigh(); \ - ssir |= 1 << (x); \ - _setsoftintr(MIPS_SOFT_INT_MASK_1); \ - splx(s); \ -} while (0) - -#define softintr_schedule(arg) \ -do { \ - struct mipsco_intrhand *__ih = (arg); \ - __ih->ih_pending = 1; \ - setsoft(__ih->ih_intrhead->intr_ipl); \ -} while (0) - -extern struct mipsco_intrhand *softnet_intrhand; +#include -#define setsoftnet() softintr_schedule(softnet_intrhand) - /* * nesting interrupt masks. */ @@ -164,11 +144,6 @@ #define MAX_INTR_COOKIES 16 #define CALL_INTR(lev) ((*intrtab[lev].ih_fun)(intrtab[lev].ih_arg)) - -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_init(void); -void softintr_dispatch(void); #endif /* !_LOCORE */ #endif /* _KERNEL */ Index: mipsco/mipsco/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/mipsco/mipsco/interrupt.c,v retrieving revision 1.1 diff -u -r1.1 interrupt.c --- mipsco/mipsco/interrupt.c 2001/03/30 23:21:30 1.1 +++ mipsco/mipsco/interrupt.c 2003/05/25 09:29:02 @@ -37,129 +37,18 @@ */ #include -#include #include -#include /* Legacy softnet support */ - #include #include - -struct mipsco_intr softintr_tab[IPL_NSOFT]; - -/* XXX For legacy software interrupts. */ -struct mipsco_intrhand *softnet_intrhand; - -u_int32_t ssir; - -/* - * softintr_init: - * - * Initialize the software interrupt system. - */ -void -softintr_init() -{ - static const char *softintr_names[] = IPL_SOFTNAMES; - struct mipsco_intr *sip; - int i; - - for (i = 0; i < IPL_NSOFT; i++) { - sip = &softintr_tab[i]; - sip->intr_ipl = i; - LIST_INIT(&sip->intr_q); - evcnt_attach_dynamic(&sip->ih_evcnt, EVCNT_TYPE_INTR, - NULL, "soft", softintr_names[i]); - } - - /* XXX Establish legacy software interrupt handlers. */ - softnet_intrhand = softintr_establish(IPL_SOFTNET, - (void (*)(void *))netintr, NULL); - - KASSERT(softnet_intrhand != NULL); -} - -/* - * softintr_dispatch: - * - * Process pending software interrupts. - * - * Called at splsoft() - */ -void -softintr_dispatch() -{ - struct mipsco_intr *sip; - struct mipsco_intrhand *sih; - u_int32_t n, i, s; - - s = splhigh(); - n = ssir; ssir = 0; - splx(s); - sip = softintr_tab; - for (i = 0; i < IPL_NSOFT; sip++, i++) { - if ((n & (1 << i)) == 0) - continue; - sip->ih_evcnt.ev_count++; - - LIST_FOREACH(sih, &sip->intr_q, ih_q) { - if (sih->ih_pending) { - uvmexp.softs++; - sih->ih_pending = 0; - (*sih->ih_fun)(sih->ih_arg); - } - } - } -} - -/* - * softintr_establish: [interface] - * - * Register a software interrupt handler. - */ -void * -softintr_establish(int ipl, void (*func)(void *), void *arg) -{ - struct mipsco_intr *sip; - struct mipsco_intrhand *sih; - int s; - - if (__predict_false(ipl >= IPL_NSOFT || ipl < 0)) - panic("softintr_establish"); - - sip = &softintr_tab[ipl]; - - sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); - if (__predict_true(sih != NULL)) { - sih->ih_fun = (void *)func; - sih->ih_arg = arg; - sih->ih_intrhead = sip; - sih->ih_pending = 0; - - s = splsoft(); - LIST_INSERT_HEAD(&sip->intr_q, sih, ih_q); - splx(s); - } - return (sih); -} - -/* - * softintr_disestablish: [interface] - * - * Unregister a software interrupt handler. - */ -void -softintr_disestablish(void *arg) -{ - struct mipsco_intrhand *ih = arg; - int s; - s = splsoft(); - LIST_REMOVE(ih, ih_q); - splx(s); - free(ih, M_DEVBUF); -} +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ +}; void cpu_intr(status, cause, pc, ipending) @@ -172,11 +61,13 @@ /* device interrupts */ (*platform.iointr)(status, cause, pc, ipending); + + /* software interrupts */ + ipending &= (MIPS_SOFT_INT_MASK_1|MIPS_SOFT_INT_MASK_0); + if (ipending == 0) + return; + + _clrsoftintr(ipending); - /* software simulated interrupt */ - if ((ipending & MIPS_SOFT_INT_MASK_1) - || (ssir && (status & MIPS_SOFT_INT_MASK_1))) { - _clrsoftintr(MIPS_SOFT_INT_MASK_1); - softintr_dispatch(); - } + softintr_dispatch(ipending); } Index: mipsco/mipsco/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/mipsco/mipsco/machdep.c,v retrieving revision 1.38 diff -u -r1.38 machdep.c --- mipsco/mipsco/machdep.c 2003/04/26 11:05:15 1.38 +++ mipsco/mipsco/machdep.c 2003/05/25 09:29:03 @@ -131,8 +131,6 @@ void kgdb_connect __P((int)); #endif -struct evcnt soft_evcnt[IPL_NSOFT]; - /* * Local functions. */ Index: newsmips/apbus/zs_ap.c =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/apbus/zs_ap.c,v retrieving revision 1.14 diff -u -r1.14 zs_ap.c --- newsmips/apbus/zs_ap.c 2003/05/09 17:39:12 1.14 +++ newsmips/apbus/zs_ap.c 2003/05/25 09:29:04 @@ -311,6 +311,7 @@ if (!didintr) { didintr = 1; + zsc->zsc_si = softintr_establish(IPL_SOFTSERIAL, zssoft, zsc); apbus_intr_establish(1, /* interrupt level ( 0 or 1 ) */ NEWS5000_INT1_SCC, 0, /* priority */ Index: newsmips/conf/files.newsmips =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/conf/files.newsmips,v retrieving revision 1.21 diff -u -r1.21 files.newsmips --- newsmips/conf/files.newsmips 2002/10/26 13:50:38 1.21 +++ newsmips/conf/files.newsmips 2003/05/25 09:29:04 @@ -98,6 +98,8 @@ file dev/clock_subr.c file dev/cons.c +file arch/mips/mips/softintr.c + # # Machine-independent SCSI driver. # Index: newsmips/dev/scsireg.h =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/dev/scsireg.h,v retrieving revision 1.7 diff -u -r1.7 scsireg.h --- newsmips/dev/scsireg.h 2002/05/31 21:45:01 1.7 +++ newsmips/dev/scsireg.h 2003/05/25 09:29:05 @@ -176,7 +176,7 @@ #ifdef CPU_SINGLE # define ipc_phys(x) (caddr_t)(x) # ifdef news3400 -# define splsc cpu_spl0 /* Lite2 used spl3 */ +# define splsc splbio /* Lite2 used spl3 */ # define splscon spl2 XXX not used extern int cpu_spl0 __P((void)); # else Index: newsmips/dev/zs.c =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/dev/zs.c,v retrieving revision 1.17 diff -u -r1.17 zs.c --- newsmips/dev/zs.c 2003/04/26 18:43:20 1.17 +++ newsmips/dev/zs.c 2003/05/25 09:29:05 @@ -84,8 +84,6 @@ return UNCONF; } -static volatile int zssoftpending; - /* * Our ZS chips all share a common, autovectored interrupt, * so we have to look at all of them on each interrupt. @@ -97,20 +95,16 @@ struct zsc_softc *zsc; int unit, rval, softreq; - rval = softreq = 0; + rval = 0; for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) { zsc = zsc_cd.cd_devs[unit]; if (zsc == NULL) continue; rval |= zsc_intr_hard(zsc); - softreq |= zsc->zsc_cs[0]->cs_softreq; + softreq = zsc->zsc_cs[0]->cs_softreq; softreq |= zsc->zsc_cs[1]->cs_softreq; - } - - /* We are at splzs here, so no need to lock. */ - if (softreq && (zssoftpending == 0)) { - zssoftpending = 1; - setsoftserial(); + if (softreq) + softintr_schedule(zsc->zsc_si); } return rval; @@ -126,19 +120,6 @@ struct zsc_softc *zsc; int s, unit; - /* This is not the only ISR on this IPL. */ - if (zssoftpending == 0) - return; - - /* - * The soft intr. bit will be set by zshard only if - * the variable zssoftpending is zero. The order of - * these next two statements prevents our clearing - * the soft intr bit just after zshard has set it. - */ - /* clearsoftnet(); */ - zssoftpending = 0; - /* Make sure we call the tty layer at spltty. */ s = spltty(); for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) { @@ -214,7 +195,7 @@ * Therefore, NEVER set the HFC bit, and instead use the * status interrupt to detect CTS changes. */ - s = splzs(); + s = splserial(); cs->cs_rr0_pps = 0; if ((cflag & (CLOCAL | MDMBUF)) != 0) { cs->cs_rr0_dcd = 0; Index: newsmips/dev/zs_hb.c =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/dev/zs_hb.c,v retrieving revision 1.15 diff -u -r1.15 zs_hb.c --- newsmips/dev/zs_hb.c 2003/05/10 09:46:25 1.15 +++ newsmips/dev/zs_hb.c 2003/05/25 09:29:05 @@ -296,6 +296,7 @@ if (!didintr) { didintr = 1; + zsc->zsc_si = softintr_establish(IPL_SOFTSERIAL, zssoft, zsc); hb_intr_establish(intlevel, INTST1_SCC, IPL_SERIAL, zshard_hb, NULL); } Index: newsmips/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/include/intr.h,v retrieving revision 1.12 diff -u -r1.12 intr.h --- newsmips/include/intr.h 2003/05/10 09:46:25 1.12 +++ newsmips/include/intr.h 2003/05/25 09:29:05 @@ -1,7 +1,11 @@ /* $NetBSD: intr.h,v 1.12 2003/05/10 09:46:25 tsutsui Exp $ */ -/* - * Copyright (c) 1998 Jonathan Stone. All rights reserved. +/*- + * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,40 +17,66 @@ * 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 Jonathan Stone for - * the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 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 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. + * 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. */ #ifndef _MACHINE_INTR_H_ #define _MACHINE_INTR_H_ #define IPL_NONE 0 /* disable only this interrupt */ -#define IPL_BIO 1 /* disable block I/O interrupts */ -#define IPL_NET 2 /* disable network interrupts */ -#define IPL_TTY 3 /* disable terminal interrupts */ -#define IPL_CLOCK 4 /* disable clock interrupts */ -#define IPL_STATCLOCK 5 /* disable profiling interrupts */ -#define IPL_SERIAL 6 /* disable serial hardware interrupts */ -#define IPL_HIGH 7 /* disable all interrupts */ +#define IPL_SOFT 1 /* generic software interrupts (SI 0) */ +#define IPL_SOFTCLOCK 2 /* clock software interrupts (SI 0) */ +#define IPL_SOFTNET 3 /* network software interrupts (SI 1) */ +#define IPL_SOFTSERIAL 4 /* serial software interrupts (SI 1) */ + +#define IPL_BIO 5 /* disable block I/O interrupts */ +#define IPL_NET 6 /* disable network interrupts */ +#define IPL_TTY 7 /* disable terminal interrupts */ +#define IPL_SERIAL 7 /* disable serial hardware interrupts */ +#define IPL_CLOCK 8 /* disable clock interrupts */ +#define IPL_STATCLOCK 8 /* disable profiling interrupts */ +#define IPL_HIGH 8 /* disable all interrupts */ + +#define _IPL_NSOFT 4 +#define _IPL_N 9 + +#define _IPL_SI0_FIRST IPL_SOFT +#define _IPL_SI0_LAST IPL_SOFTCLOCK + +#define _IPL_SI1_FIRST IPL_SOFTNET +#define _IPL_SI1_LAST IPL_SOFTSERIAL + +#define IPL_SOFTNAMES { \ + "misc", \ + "clock", \ + "net", \ + "serial", \ +} + #ifdef _KERNEL #ifndef _LOCORE + #include -#include +extern const u_int32_t ipl_sr_bits[_IPL_N]; + extern int _splraise __P((int)); extern int _spllower __P((int)); extern int _splset __P((int)); @@ -54,54 +84,27 @@ extern void _splnone __P((void)); extern void _setsoftintr __P((int)); extern void _clrsoftintr __P((int)); - -/* - * software simulated interrupt - */ -#define SIR_NET 0x01 -#define SIR_SERIAL 0x02 - -#define setsoft(x) do { \ - extern u_int ssir; \ - int s; \ - \ - s = splhigh(); \ - ssir |= (x); \ - _setsoftintr(MIPS_SOFT_INT_MASK_1); \ - splx(s); \ -} while (0) - -#define setsoftclock() _setsoftintr(MIPS_SOFT_INT_MASK_0) -#define setsoftnet() setsoft(SIR_NET) -#define setsoftserial() setsoft(SIR_SERIAL) -/* - * nesting interrupt masks. - */ -#define MIPS_INT_MASK_SPL_SOFT0 MIPS_SOFT_INT_MASK_0 -#define MIPS_INT_MASK_SPL_SOFT1 (MIPS_SOFT_INT_MASK_1|MIPS_INT_MASK_SPL_SOFT0) -#define MIPS_INT_MASK_SPL0 (MIPS_INT_MASK_0|MIPS_INT_MASK_SPL_SOFT1) -#define MIPS_INT_MASK_SPL1 (MIPS_INT_MASK_1|MIPS_INT_MASK_SPL0) -#define MIPS_INT_MASK_SPL2 (MIPS_INT_MASK_2|MIPS_INT_MASK_SPL1) -#define MIPS_INT_MASK_SPL3 (MIPS_INT_MASK_3|MIPS_INT_MASK_SPL2) -#define MIPS_INT_MASK_SPL4 (MIPS_INT_MASK_4|MIPS_INT_MASK_SPL3) -#define MIPS_INT_MASK_SPL5 (MIPS_INT_MASK_5|MIPS_INT_MASK_SPL4) - +#define splhigh() _splraise(ipl_sr_bits[IPL_HIGH]) #define spl0() (void)_spllower(0) #define splx(s) (void)_splset(s) -#define splbio() _splraise(MIPS_INT_MASK_SPL0) -#define splnet() _splraise(MIPS_INT_MASK_SPL1) -#define spltty() _splraise(MIPS_INT_MASK_SPL1) -#define splvm() _splraise(MIPS_INT_MASK_SPL1) -#define splclock() _splraise(MIPS_INT_MASK_SPL2) -#define splstatclock() _splraise(MIPS_INT_MASK_SPL2) -#define splhigh() _splraise(MIPS_INT_MASK_SPL2) -#define splsched() splhigh() -#define spllock() splhigh() - -#define splsoftclock() _splraise(MIPS_INT_MASK_SPL_SOFT0) -#define splsoftnet() _splraise(MIPS_INT_MASK_SPL_SOFT1) -#define spllowersoftclock() _spllower(MIPS_INT_MASK_SPL_SOFT0) +#define splbio() _splraise(ipl_sr_bits[IPL_BIO]) +#define splnet() _splraise(ipl_sr_bits[IPL_NET]) +#define spltty() _splraise(ipl_sr_bits[IPL_TTY]) +#define splserial() _splraise(ipl_sr_bits[IPL_SERIAL]) +#define splvm() spltty() +#define splclock() _splraise(ipl_sr_bits[IPL_CLOCK]) +#define splstatclock() splclock() + +#define splsched() splclock() +#define spllock() splhigh() + +#define splsoft() _splraise(ipl_sr_bits[IPL_SOFT]) +#define splsoftclock() _splraise(ipl_sr_bits[IPL_SOFTCLOCK]) +#define splsoftnet() _splraise(ipl_sr_bits[IPL_SOFTNET]) +#define splsoftserial() _splraise(ipl_sr_bits[IPL_SOFTSERIAL]) + +#define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK]) struct newsmips_intrhand { LIST_ENTRY(newsmips_intrhand) ih_q; @@ -117,33 +120,38 @@ LIST_HEAD(,newsmips_intrhand) intr_q; }; +#include + /* * Index into intrcnt[], which is defined in locore */ -#define SOFTCLOCK_INTR 0 -#define SOFTNET_INTR 1 -#define SERIAL0_INTR 2 -#define SERIAL1_INTR 3 -#define SERIAL2_INTR 4 -#define LANCE_INTR 5 -#define SCSI_INTR 6 -#define ERROR_INTR 7 -#define HARDCLOCK_INTR 8 -#define FPU_INTR 9 -#define SLOT1_INTR 10 -#define SLOT2_INTR 11 -#define SLOT3_INTR 12 -#define FLOPPY_INTR 13 -#define STRAY_INTR 14 +#define SERIAL0_INTR 0 +#define SERIAL1_INTR 1 +#define SERIAL2_INTR 2 +#define LANCE_INTR 3 +#define SCSI_INTR 4 +#define ERROR_INTR 5 +#define HARDCLOCK_INTR 6 +#define FPU_INTR 7 +#define SLOT1_INTR 8 +#define SLOT2_INTR 9 +#define SLOT3_INTR 10 +#define FLOPPY_INTR 11 +#define STRAY_INTR 12 extern u_int intrcnt[]; /* handle i/o device interrupts */ -extern void news3400_intr __P((u_int, u_int, u_int, u_int)); -extern void news5000_intr __P((u_int, u_int, u_int, u_int)); +#ifdef news3400 +void news3400_intr __P((u_int, u_int, u_int, u_int)); +#endif +#ifdef news5000 +void news5000_intr __P((u_int, u_int, u_int, u_int)); +#endif +void (*hardware_intr) __P((u_int, u_int, u_int, u_int)); -extern void (*enable_intr) __P((void)); -extern void (*disable_intr) __P((void)); +void (*enable_intr) __P((void)); +void (*disable_intr) __P((void)); #endif /* !_LOCORE */ #endif /* _KERNEL */ Index: newsmips/include/types.h =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/include/types.h,v retrieving revision 1.5 diff -u -r1.5 types.h --- newsmips/include/types.h 2002/08/05 02:13:15 1.5 +++ newsmips/include/types.h 2003/05/25 09:29:05 @@ -3,6 +3,7 @@ #include #define __BROKEN_CONFIG_UNIT_USAGE +#define __HAVE_GENERIC_SOFT_INTERRUPTS /* MIPS specific options */ #define __HAVE_BOOTINFO_H Index: newsmips/include/z8530var.h =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/include/z8530var.h,v retrieving revision 1.4 diff -u -r1.4 z8530var.h --- newsmips/include/z8530var.h 2003/04/26 18:43:20 1.4 +++ newsmips/include/z8530var.h 2003/05/25 09:29:05 @@ -52,6 +52,7 @@ struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ /* Machine-dependent part follows... */ struct zs_chanstate zsc_cs_store[2]; + void *zsc_si; /* softinterrupt handle */ }; /* @@ -76,6 +77,4 @@ int zs_get_speed __P((struct zs_chanstate *)); void (*zs_delay) __P((void)); -/* Zilog Serial hardware interrupts (level 1) */ -#define splzs cpu_spl1 -extern int splzs(void); +#define splzs() splserial() Index: newsmips/newsmips/autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/autoconf.c,v retrieving revision 1.16 diff -u -r1.16 autoconf.c --- newsmips/newsmips/autoconf.c 2002/09/25 22:21:15 1.16 +++ newsmips/newsmips/autoconf.c 2003/05/25 09:29:05 @@ -98,6 +98,7 @@ /* * Kick off autoconfiguration */ + softintr_init(); _splnone(); /* enable all interrupts */ splhigh(); /* ...then disable device interrupts */ Index: newsmips/newsmips/locore_machdep.S =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/locore_machdep.S,v retrieving revision 1.9 diff -u -r1.9 locore_machdep.S --- newsmips/newsmips/locore_machdep.S 2003/04/26 18:40:00 1.9 +++ newsmips/newsmips/locore_machdep.S 2003/05/25 09:29:06 @@ -226,8 +226,6 @@ .globl _C_LABEL(intrnames) .globl _C_LABEL(eintrnames) _C_LABEL(intrnames): - .asciiz "softclock" - .asciiz "softnet" .asciiz "serial0" .asciiz "serial1" .asciiz "serial2" @@ -246,7 +244,7 @@ _C_LABEL(eintrnames): .align 2 _C_LABEL(intrcnt): - .word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0 + .word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0 _C_LABEL(eintrcnt): .word 0 # This shouldn't be needed but with 4.4bsd's as, the eintrcnt # label ends end up in a different section otherwise. Index: newsmips/newsmips/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/machdep.c,v retrieving revision 1.69 diff -u -r1.69 machdep.c --- newsmips/newsmips/machdep.c 2003/04/26 18:50:19 1.69 +++ newsmips/newsmips/machdep.c 2003/05/25 09:29:06 @@ -78,6 +78,7 @@ #include /* mfs_initminiroot() */ #include +#include #include #include #include @@ -129,13 +130,8 @@ int mem_cluster_cnt; struct idrom idrom; -void (*enable_intr) __P((void)); -void (*disable_intr) __P((void)); void (*readmicrotime) __P((struct timeval *tvp)); -static void (*hardware_intr) __P((u_int, u_int, u_int, u_int)); -u_int ssir; - /* * Local functions. */ @@ -159,6 +155,51 @@ */ int safepri = MIPS3_PSL_LOWIPL; /* XXX */ +/* + * This is a mask of bits to clear in the SR when we go to a + * given interrupt priority level. + */ +const u_int32_t ipl_sr_bits[_IPL_N] = { + 0, /* IPL_NONE */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0, /* IPL_BIO */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1, /* IPL_NET */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1, /* IPL_{TTY,SERIAL} */ + + MIPS_SOFT_INT_MASK_0| + MIPS_SOFT_INT_MASK_1| + MIPS_INT_MASK_0| + MIPS_INT_MASK_1| + MIPS_INT_MASK_2, /* IPL_{CLOCK,HIGH} */ +}; + +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ +}; + extern struct user *proc0paddr; extern u_long bootdev; extern char edata[], end[]; @@ -651,10 +692,6 @@ DELAY(n); } -#include "zsc.h" - -int zssoft __P((void)); - void cpu_intr(status, cause, pc, ipending) u_int32_t status; @@ -662,39 +699,18 @@ u_int32_t pc; u_int32_t ipending; { + uvmexp.intrs++; /* device interrupts */ (*hardware_intr)(status, cause, pc, ipending); - /* software simulated interrupt */ - if ((ipending & MIPS_SOFT_INT_MASK_1) || - (ssir && (status & MIPS_SOFT_INT_MASK_1))) { - -#define DO_SIR(bit, fn) \ - do { \ - if (n & (bit)) { \ - uvmexp.softs++; \ - fn; \ - } \ - } while (0) - - unsigned n; - n = ssir; ssir = 0; - _clrsoftintr(MIPS_SOFT_INT_MASK_1); + /* software interrupts */ + ipending &= (MIPS_SOFT_INT_MASK_1|MIPS_SOFT_INT_MASK_0); + if (ipending == 0) + return; -#if NZSC > 0 - DO_SIR(SIR_SERIAL, zssoft()); -#endif - DO_SIR(SIR_NET, netintr()); -#undef DO_SIR - } + _clrsoftintr(ipending); - /* 'softclock' interrupt */ - if (ipending & MIPS_SOFT_INT_MASK_0) { - _clrsoftintr(MIPS_SOFT_INT_MASK_0); - uvmexp.softs++; - intrcnt[SOFTCLOCK_INTR]++; - softclock(NULL); - } + softintr_dispatch(ipending); } Index: pmax/conf/files.pmax =================================================================== RCS file: /cvsroot/src/sys/arch/pmax/conf/files.pmax,v retrieving revision 1.103 diff -u -r1.103 files.pmax --- pmax/conf/files.pmax 2002/10/26 13:50:40 1.103 +++ pmax/conf/files.pmax 2003/05/25 09:29:07 @@ -187,6 +187,8 @@ file arch/pmax/stand/common/callvec.c file dev/cons.c +file arch/mips/mips/softintr.c + # pmax configuration glue for rconsole. Requires fb pseudo-device. include "dev/rcons/files.rcons" Index: pmax/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/pmax/include/intr.h,v retrieving revision 1.23 diff -u -r1.23 intr.h --- pmax/include/intr.h 2001/08/27 02:00:16 1.23 +++ pmax/include/intr.h 2003/05/25 09:29:07 @@ -70,8 +70,6 @@ #ifdef _KERNEL #ifndef _LOCORE -extern const u_int32_t ipl_si_to_sr[_IPL_NSOFT]; - #include int _splraise __P((int)); @@ -92,12 +90,15 @@ #define splclock() (_splraise(splvec.splclock)) #define splstatclock() (_splraise(splvec.splstatclock)) #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_0) -#define splsoftclock() _splraise(MIPS_SOFT_INT_MASK_0) -#define splsoftnet() _splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1) #define splsched() splhigh() #define spllock() splhigh() +#define splsoft() _splraise(MIPS_SOFT_INT_MASK_0) +#define splsoftclock() _splraise(MIPS_SOFT_INT_MASK_0) +#define splsoftnet() _splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1) +#define splsoftserial() _splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1) + struct splvec { int splbio; int splnet; @@ -160,54 +161,8 @@ int (*ih_func)(void *); void *ih_arg; }; - -#define setsoft(x) \ -do { \ - _setsoftintr(ipl_si_to_sr[(x) - IPL_SOFT]); \ -} while (0) - -struct pmax_soft_intrhand { - TAILQ_ENTRY(pmax_soft_intrhand) - sih_q; - struct pmax_soft_intr *sih_intrhead; - void (*sih_fn)(void *); - void *sih_arg; - int sih_pending; -}; - -struct pmax_soft_intr { - TAILQ_HEAD(, pmax_soft_intrhand) - softintr_q; - struct evcnt softintr_evcnt; - struct simplelock softintr_slock; - unsigned long softintr_ipl; -}; - -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_init(void); -void softintr_dispatch(void); - -#define softintr_schedule(arg) \ -do { \ - struct pmax_soft_intrhand *__sih = (arg); \ - struct pmax_soft_intr *__si = __sih->sih_intrhead; \ - int __s; \ - \ - __s = splhigh(); \ - simple_lock(&__si->softintr_slock); \ - if (__sih->sih_pending == 0) { \ - TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ - __sih->sih_pending = 1; \ - setsoft(__si->softintr_ipl); \ - } \ - simple_unlock(&__si->softintr_slock); \ - splx(__s); \ -} while (0) - -extern struct pmax_soft_intrhand *softnet_intrhand; -#define setsoftnet() softintr_schedule(softnet_intrhand) +#include extern struct evcnt pmax_clock_evcnt; extern struct evcnt pmax_fpu_evcnt; Index: pmax/pmax/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/pmax/pmax/interrupt.c,v retrieving revision 1.6 diff -u -r1.6 interrupt.c --- pmax/pmax/interrupt.c 2003/01/18 06:15:24 1.6 +++ pmax/pmax/interrupt.c 2003/05/25 09:29:08 @@ -37,7 +37,6 @@ */ #include -#include #include #include @@ -49,15 +48,13 @@ #include #include -const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = { +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ }; -struct pmax_soft_intr pmax_soft_intrs[_IPL_NSOFT]; - struct evcnt pmax_clock_evcnt = EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "clock", "intr"); struct evcnt pmax_fpu_evcnt = @@ -78,10 +75,6 @@ u_int32_t ipending; { - int i, s; - struct pmax_soft_intr *asi; - struct pmax_soft_intrhand *sih; - uvmexp.intrs++; /* device interrupts */ @@ -104,114 +97,10 @@ return; _clrsoftintr(ipending); - - for (i = _IPL_NSOFT - 1; i >= 0; i--) { - if ((ipending & ipl_si_to_sr[i]) == 0) - continue; - - asi = &pmax_soft_intrs[i]; - - if (TAILQ_FIRST(&asi->softintr_q) != NULL) - asi->softintr_evcnt.ev_count++; - - for (;;) { - s = splhigh(); - - sih = TAILQ_FIRST(&asi->softintr_q); - if (sih != NULL) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - - splx(s); - if (sih == NULL) - break; + softintr_dispatch(ipending); - uvmexp.softs++; - (*sih->sih_fn)(sih->sih_arg); - } - } return; kerneltouchedFPU: panic("kernel used FPU: PC %x, CR %x, SR %x", pc, cause, status); -} - -/* XXX For legacy software interrupts. */ -struct pmax_soft_intrhand *softnet_intrhand; - -/* - * softintr_init: - * - * Initialize the software interrupt system. - */ -void -softintr_init(void) -{ - static const char *softintr_names[] = IPL_SOFTNAMES; - struct pmax_soft_intr *asi; - int i; - - for (i = 0; i < _IPL_NSOFT; i++) { - asi = &pmax_soft_intrs[i]; - TAILQ_INIT(&asi->softintr_q); - asi->softintr_ipl = IPL_SOFT + i; - evcnt_attach_dynamic(&asi->softintr_evcnt, EVCNT_TYPE_INTR, - NULL, "soft", softintr_names[i]); - } - - /* XXX Establish legacy soft interrupt handlers. */ - softnet_intrhand = softintr_establish(IPL_SOFTNET, - (void (*)(void *))netintr, NULL); - - assert(softnet_intrhand != NULL); -} - -/* - * softintr_establish: [interface] - * - * Register a software interrupt handler. - */ -void * -softintr_establish(int ipl, void (*func)(void *), void *arg) -{ - struct pmax_soft_intr *asi; - struct pmax_soft_intrhand *sih; - - if (__predict_false(ipl >= (IPL_SOFT + _IPL_NSOFT) || - ipl < IPL_SOFT)) - panic("softintr_establish"); - - asi = &pmax_soft_intrs[ipl - IPL_SOFT]; - - sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); - if (__predict_true(sih != NULL)) { - sih->sih_intrhead = asi; - sih->sih_fn = func; - sih->sih_arg = arg; - sih->sih_pending = 0; - } - return (sih); -} - -/* - * softintr_disestablish: [interface] - * - * Unregister a software interrupt handler. - */ -void -softintr_disestablish(void *arg) -{ - struct pmax_soft_intrhand *sih = arg; - struct pmax_soft_intr *asi = sih->sih_intrhead; - int s; - - s = splhigh(); - if (sih->sih_pending) { - TAILQ_REMOVE(&asi->softintr_q, sih, sih_q); - sih->sih_pending = 0; - } - splx(s); - - free(sih, M_DEVBUF); } Index: sgimips/conf/files.sgimips =================================================================== RCS file: /cvsroot/src/sys/arch/sgimips/conf/files.sgimips,v retrieving revision 1.22 diff -u -r1.22 files.sgimips --- sgimips/conf/files.sgimips 2002/10/26 13:50:43 1.22 +++ sgimips/conf/files.sgimips 2003/05/25 09:29:09 @@ -71,7 +71,8 @@ file arch/sgimips/sgimips/console.c file arch/sgimips/sgimips/disksubr.c file arch/sgimips/sgimips/machdep.c -file arch/sgimips/sgimips/softintr.c + +file arch/mips/mips/softintr.c file dev/md_root.c memory_disk_hooks Index: sgimips/include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/sgimips/include/intr.h,v retrieving revision 1.13 diff -u -r1.13 intr.h --- sgimips/include/intr.h 2002/05/03 01:51:38 1.13 +++ sgimips/include/intr.h 2003/05/25 09:29:09 @@ -54,12 +54,14 @@ #define IST_LEVEL 3 /* level-triggered */ /* Soft interrupt numbers */ -#define IPL_SOFTSERIAL 0 /* serial software interrupts */ -#define IPL_SOFTNET 1 /* network software interrupts */ -#define IPL_SOFTCLOCK 2 /* clock software interrupts */ -#define IPL_NSOFT 3 +#define IPL_SOFT 0 /* generic software interrupts */ +#define IPL_SOFTSERIAL 1 /* serial software interrupts */ +#define IPL_SOFTNET 2 /* network software interrupts */ +#define IPL_SOFTCLOCK 3 /* clock software interrupts */ +#define _IPL_NSOFT 4 #define IPL_SOFTNAMES { \ + "misc", \ "serial", \ "net", \ "clock", \ @@ -73,30 +75,6 @@ #include #include -/* - * software simulated interrupt - */ -#define setsoft(x) do { \ - extern u_int ssir; \ - int s; \ - \ - s = splhigh(); \ - ssir |= 1 << (x); \ - _setsoftintr(MIPS_SOFT_INT_MASK_1); \ - splx(s); \ -} while (0) - -#define softintr_schedule(arg) \ -do { \ - struct sgimips_intrhand *__ih = (arg); \ - __ih->ih_pending = 1; \ - setsoft(__ih->ih_intrhead->intr_ipl); \ -} while (0) - -extern struct sgimips_intrhand *softnet_intrhand; - -#define setsoftnet() softintr_schedule(softnet_intrhand) - #define NINTR 32 struct sgimips_intrhand { @@ -152,10 +130,8 @@ #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_1) extern void * cpu_intr_establish(int, int, int (*)(void *), void *); -void * softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_init(void); -void softintr_dispatch(void); + +#include #endif /* _LOCORE */ #endif /* !_KERNEL */ Index: sgimips/sgimips/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/sgimips/sgimips/machdep.c,v retrieving revision 1.54 diff -u -r1.54 machdep.c --- sgimips/sgimips/machdep.c 2003/04/26 11:05:19 1.54 +++ sgimips/sgimips/machdep.c 2003/05/25 09:29:10 @@ -102,6 +102,13 @@ struct sgimips_intrhand intrtab[NINTR]; +const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT] = { + MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */ + MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */ + MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */ +}; + /* Our exported CPU info; we can have only one. */ struct cpu_info cpu_info_store; @@ -868,21 +875,14 @@ if (ipending & MIPS_HARD_INT_MASK) (*platform.iointr)(status, cause, pc, ipending); - /* - * Service pending soft interrupts -- make sure to re-enable - * only those hardware interrupts that are not masked and - * that weren't pending on the current invocation of the - * interrupt handler, else we risk infinite stack growth - * due to nested interrupts. - */ - /* software simulated interrupt */ - if ((ipending & MIPS_SOFT_INT_MASK_1) || - (ssir && (status & MIPS_SOFT_INT_MASK_1))) { - _splset(MIPS_SR_INT_IE | - (status & ~ipending & MIPS_HARD_INT_MASK)); - _clrsoftintr(MIPS_SOFT_INT_MASK_1); - softintr_dispatch(); - } + /* software interrupt */ + ipending &= (MIPS_SOFT_INT_MASK_1|MIPS_SOFT_INT_MASK_0); + if (ipending == 0) + return; + + _clrsoftintr(ipending); + + softintr_dispatch(ipending); } void unconfigured_system_type(int ipnum) --- /dev/null 2003-05-25 18:21:21.000000000 +0900 +++ mips/include/softintr.h 2003-05-25 17:53:59.000000000 +0900 @@ -0,0 +1,97 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * 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. + */ + +#ifndef _MIPS_SOFTINTR_H_ +#define _MIPS_SOFTINTR_H_ + +#ifndef _LOCORE + +#include +#include + +extern const u_int32_t mips_ipl_si_to_sr[_IPL_NSOFT]; + +#define setsoft(x) \ +do { \ + _setsoftintr(mips_ipl_si_to_sr[(x) - IPL_SOFT]); \ +} while (/*CONSTCOND*/0) + +struct mips_soft_intrhand { + TAILQ_ENTRY(mips_soft_intrhand) sih_q; + struct mips_soft_intr *sih_intrhead; + void (*sih_func)(void *); + void *sih_arg; + int sih_pending; +}; + +struct mips_soft_intr { + TAILQ_HEAD(,mips_soft_intrhand) softintr_q; + struct evcnt softintr_evcnt; + struct simplelock softintr_slock; + unsigned long softintr_ipl; +}; + +void softintr_init(void); +void *softintr_establish(int, void (*)(void *), void *); +void softintr_disestablish(void *); +void softintr_dispatch(u_int32_t); + +#define softintr_schedule(arg) \ +do { \ + struct mips_soft_intrhand *__sih = (arg); \ + struct mips_soft_intr *__msi = __sih->sih_intrhead; \ + int __s; \ + \ + __s = splhigh(); \ + simple_lock(&__msi->softintr_slock); \ + if (__sih->sih_pending == 0) { \ + TAILQ_INSERT_TAIL(&__msi->softintr_q, __sih, sih_q); \ + __sih->sih_pending = 1; \ + setsoft(__msi->softintr_ipl); \ + } \ + simple_unlock(&__msi->softintr_slock); \ + splx(__s); \ +} while (/*CONSTCOND*/0) + +/* XXX For legacy software interrupts. */ +extern struct mips_soft_intrhand *softnet_intrhand; + +#define setsoftnet() softintr_schedule(softnet_intrhand) + +#endif /* !_LOCORE */ +#endif /* _MIPS_SOFTINTR_H_ */ --- /dev/null 2003-05-25 18:37:20.000000000 +0900 +++ mips/mips/softintr.c 2003-05-25 18:59:10.000000000 +0900 @@ -0,0 +1,177 @@ +/* $NetBSD$ */ + +/* + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * 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 +#include +#include + +#include + +#include /* Legacy softnet support */ + +#include + +/* XXX For legacy software interrupts. */ +struct mips_soft_intrhand *softnet_intrhand; + +struct mips_soft_intr mips_soft_intrs[_IPL_NSOFT]; + +/* + * softintr_init: + * + * Initialize the software interrupt system. + */ +void +softintr_init(void) +{ + static const char *softintr_names[] = IPL_SOFTNAMES; + struct mips_soft_intr *msi; + int i; + + for (i = 0; i < _IPL_NSOFT; i++) { + msi = &mips_soft_intrs[i]; + TAILQ_INIT(&msi->softintr_q); + simple_lock_init(&msi->softintr_slock); + msi->softintr_ipl = IPL_SOFT + i; + evcnt_attach_dynamic(&msi->softintr_evcnt, EVCNT_TYPE_INTR, + NULL, "soft", softintr_names[i]); + } + + /* XXX Establish legacy soft interrupt handlers. */ + softnet_intrhand = softintr_establish(IPL_SOFTNET, + (void (*)(void *))netintr, NULL); + + KASSERT(softnet_intrhand != NULL); +} + +/* + * softintr_establish: [interface] + * + * Register a software interrupt handler. + */ +void * +softintr_establish(int ipl, void (*func)(void *), void *arg) +{ + struct mips_soft_intr *msi; + struct mips_soft_intrhand *sih; + + if (__predict_false(ipl >= (IPL_SOFT + _IPL_NSOFT) || + ipl < IPL_SOFT)) + panic("softintr_establish"); + + msi = &mips_soft_intrs[ipl - IPL_SOFT]; + + sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); + if (__predict_true(sih != NULL)) { + sih->sih_intrhead = msi; + sih->sih_func = func; + sih->sih_arg = arg; + sih->sih_pending = 0; + } + return sih; +} + +/* + * softintr_disestablish: [interface] + * + * Unregister a software interrupt handler. + */ +void +softintr_disestablish(void *arg) +{ + struct mips_soft_intrhand *sih = arg; + struct mips_soft_intr *msi = sih->sih_intrhead; + int s; + + s = splhigh(); + simple_lock(&msi->softintr_slock); + if (sih->sih_pending) { + TAILQ_REMOVE(&msi->softintr_q, sih, sih_q); + sih->sih_pending = 0; + } + simple_unlock(&msi->softintr_slock); + splx(s); + + free(sih, M_DEVBUF); +} + +/* + * softintr_dispatch: + * + * Process pending software interrupts. + * + * Called at splsoft() + */ +void +softintr_dispatch(ipending) + u_int32_t ipending; +{ + struct mips_soft_intr *msi; + struct mips_soft_intrhand *sih; + int i, s; + + for (i = _IPL_NSOFT - 1; i >= 0; i--) { + if ((ipending & mips_ipl_si_to_sr[i]) == 0) + continue; + + msi = &mips_soft_intrs[i]; + + if (TAILQ_FIRST(&msi->softintr_q) != NULL) + msi->softintr_evcnt.ev_count++; + + for (;;) { + s = splhigh(); + simple_lock(&msi->softintr_slock); + + sih = TAILQ_FIRST(&msi->softintr_q); + if (sih != NULL) { + TAILQ_REMOVE(&msi->softintr_q, sih, sih_q); + sih->sih_pending = 0; + } + + simple_unlock(msi->softintr_slock); + splx(s); + + if (sih == NULL) + break; + + uvmexp.softs++; + (*sih->sih_func)(sih->sih_arg); + } + } +}