diff options
29 files changed, 645 insertions, 512 deletions
diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 4a88e4546e2..19f9bd4680c 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.45 2008/07/21 04:35:54 todd Exp $ */ +/* $OpenBSD: autoconf.c,v 1.46 2009/03/15 20:40:23 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */ /* @@ -226,6 +226,9 @@ mainbussearch(parent, match, aux) void cpu_configure() { + /* this couldn't be done in intr_init() because this uses malloc() */ + softintr_init(); + /* * Initialize the dev_data_lists. */ diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c index 4afe998208f..48bbc738bdc 100644 --- a/sys/arch/hp300/hp300/intr.c +++ b/sys/arch/hp300/hp300/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.22 2008/07/18 21:39:14 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.23 2009/03/15 20:40:23 miod Exp $ */ /* $NetBSD: intr.c,v 1.5 1998/02/16 20:58:30 thorpej Exp $ */ /*- @@ -41,13 +41,9 @@ #include <uvm/uvm_extern.h> -#include <net/netisr.h> #include "ppp.h" #include "bridge.h" -void netintr(void); - -#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -277,28 +273,6 @@ intr_dispatch(evec) printf("intr_dispatch: stray level %d interrupt\n", ipl); } -int netisr; - -void -netintr() -{ - int n; - - while ((n = netisr) != 0) { - atomic_clearbits_int(&netisr, n); - -#define DONETISR(bit, fn) \ - do { \ - if (n & (1 << (bit))) \ - (fn)(); \ - } while (0) - -#include <net/netisr_dispatch.h> - -#undef DONETISR - } -} - #ifdef DIAGNOSTIC void splassert_check(int wantipl, const char *func) diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index 89a0d6bb291..d62a4f32b61 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.63 2008/01/04 19:10:31 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.64 2009/03/15 20:40:23 miod Exp $ */ /* $NetBSD: locore.s,v 1.91 1998/11/11 06:41:25 thorpej Exp $ */ /* @@ -1005,10 +1005,10 @@ ENTRY_NOPROFILE(trap0) addql #4,sp | pop syscall arg tstl _C_LABEL(astpending) jne Lrei2 - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jeq Ltrap1 movw #SPL1,sr - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jne Lsir1 Ltrap1: movl sp@(FR_SP),a0 | grab and restore @@ -1264,7 +1264,7 @@ ENTRY_NOPROFILE(lev7intr) /* level 7: parity errors, reset key */ * necessitating a stack cleanup. */ -BSS(ssir,1) +BSS(softpending,4) ASENTRY_NOPROFILE(rei) tstl _C_LABEL(astpending) | AST pending? @@ -1302,7 +1302,7 @@ Laststkadj: movl sp@,sp | and our SP rte | and do real RTE Lchksir: - tstb _C_LABEL(ssir) | SIR pending? + tstl _C_LABEL(softpending) | SIR pending? jeq Ldorte | no, all done movl d0,sp@- | need a scratch register movw sp@(4),d0 | get SR @@ -1311,7 +1311,7 @@ Lchksir: movl sp@+,d0 | restore scratch register Lgotsir: movw #SPL1,sr | prevent others from servicing int - tstb _C_LABEL(ssir) | too late? + tstl _C_LABEL(softpending) | too late? jeq Ldorte | yes, oh well... clrl sp@- | stack adjust moveml #0xFFFF,sp@- | save all registers @@ -1808,7 +1808,7 @@ ENTRY(spl0) moveq #0,d0 movw sr,d0 | get old SR for return movw #PSL_LOWIPL,sr | restore new SR - tstb _C_LABEL(ssir) | software interrupt pending? + tstl _C_LABEL(softpending) | software interrupt pending? jeq Lspldone | no, all done subql #4,sp | make room for RTE frame movl sp@(4),sp@(2) | position return address diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index e96dda2303f..e2d7e8f6a3c 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.53 2008/06/08 20:57:16 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.54 2009/03/15 20:40:23 miod Exp $ */ /* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */ /* @@ -535,17 +535,19 @@ dopanic: case T_SSIR: /* software interrupt */ case T_SSIR|T_USER: - if (ssir & SIR_NET) { - void netintr(void); - siroff(SIR_NET); - uvmexp.softs++; - netintr(); - } - if (ssir & SIR_CLOCK) { - siroff(SIR_CLOCK); - uvmexp.softs++; - softclock(); + { + int sir, q, mask; + + while ((sir = softpending) != 0) { + atomic_clearbits_int(&softpending, sir); + + for (q = SI_NQUEUES - 1, mask = 1 << (SI_NQUEUES - 1); + mask != 0; q--, mask >>= 1) + if (mask & sir) + softintr_dispatch(q); } + } + /* * If this was not an AST trap, we are all done. */ diff --git a/sys/arch/hp300/include/intr.h b/sys/arch/hp300/include/intr.h index c7216332a51..25267bd661a 100644 --- a/sys/arch/hp300/include/intr.h +++ b/sys/arch/hp300/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.24 2008/07/18 21:39:16 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.25 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: intr.h,v 1.2 1997/07/24 05:43:08 scottr Exp $ */ /*- @@ -58,8 +58,7 @@ struct isr { * - compute CPU PSL values for the spl*() calls. */ #define IPL_NONE 0 -#define IPL_SOFTNET 1 -#define IPL_SOFTCLOCK 1 +#define IPL_SOFTINT 1 #define IPL_BIO 2 #define IPL_NET 3 #define IPL_TTY 4 @@ -90,21 +89,7 @@ extern unsigned short hp300_varpsl[NISR]; /* watch out for side effects */ #define splx(s) ((s) & PSL_IPL ? _spl((s)) : spl0()) -/* - * Simulated software interrupt register. - */ -extern volatile u_int8_t ssir; - -#define SIR_NET 0x01 -#define SIR_CLOCK 0x02 - -#define siron(mask) \ - __asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask)) -#define siroff(mask) \ - __asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask))) - -#define setsoftnet() siron(SIR_NET) -#define setsoftclock() siron(SIR_CLOCK) +#include <m68k/intr.h> /* soft interrupt support */ /* locore.s */ int spl0(void); diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k index d0ef0536d58..6d974de94f1 100644 --- a/sys/arch/m68k/conf/files.m68k +++ b/sys/arch/m68k/conf/files.m68k @@ -1,4 +1,4 @@ -# $OpenBSD: files.m68k,v 1.19 2008/04/25 14:51:35 jmc Exp $ +# $OpenBSD: files.m68k,v 1.20 2009/03/15 20:40:25 miod Exp $ # $NetBSD: files.m68k,v 1.18 1997/06/06 23:15:28 veego Exp $ # file arch/m68k/m68k/bcopy.s @@ -17,6 +17,7 @@ file arch/m68k/m68k/oc_cksum.s inet file arch/m68k/m68k/process_machdep.c file arch/m68k/m68k/regdump.c file arch/m68k/m68k/sig_machdep.c +file arch/m68k/m68k/softintr.c # # Older m68k4k executables binary compatibility diff --git a/sys/arch/m68k/include/_types.h b/sys/arch/m68k/include/_types.h index 485460e8657..5d701a38ee4 100644 --- a/sys/arch/m68k/include/_types.h +++ b/sys/arch/m68k/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.7 2008/07/21 20:50:54 martynas Exp $ */ +/* $OpenBSD: _types.h,v 1.8 2009/03/15 20:40:25 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -116,4 +116,7 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; +/* Feature test macros */ +#define __HAVE_GENERIC_SOFT_INTERRUPTS + #endif /* _M68K__TYPES_H_ */ diff --git a/sys/arch/m68k/include/intr.h b/sys/arch/m68k/include/intr.h new file mode 100644 index 00000000000..02846b8d158 --- /dev/null +++ b/sys/arch/m68k/include/intr.h @@ -0,0 +1,112 @@ +/* $OpenBSD: intr.h,v 1.1 2009/03/15 20:40:25 miod Exp $ */ +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe for Wasabi Systems, Inc. + * + * 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 for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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 _M68K_INTR_H_ +#define _M68K_INTR_H_ + +#ifdef _KERNEL +#ifndef _LOCORE + +/* SPL asserts */ +#ifdef DIAGNOSTIC +/* + * Although this function is implemented in MI code, it must be in this MD + * header because we don't want this header to include MI includes. + */ +void splassert_fail(int, int, const char *); +extern int splassert_ctl; +void splassert_check(int, const char *); +#define splassert(__wantipl) do { \ + if (splassert_ctl > 0) { \ + splassert_check(__wantipl, __func__); \ + } \ +} while (0) +#define splsoftassert(wantipl) splassert(IPL_SOFTINT) +#else +#define splassert(wantipl) do { /* nothing */ } while (0) +#define splsoftassert(wantipl) do { /* nothing */ } while (0) +#endif + +/* + * Generic software interrupt support for all m68k platforms. + */ + +#define IPL_SOFT 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTNET 2 +#define IPL_SOFTTTY 3 + +#define SI_SOFT 0 /* for IPL_SOFT */ +#define SI_SOFTCLOCK 1 /* for IPL_SOFTCLOCK */ +#define SI_SOFTNET 2 /* for IPL_SOFTNET */ +#define SI_SOFTTTY 3 /* for IPL_SOFTTTY */ + +#define SI_NQUEUES 4 + +#include <machine/mutex.h> +#include <sys/queue.h> + +struct soft_intrhand { + TAILQ_ENTRY(soft_intrhand) sih_list; + void (*sih_func)(void *); + void *sih_arg; + struct soft_intrq *sih_siq; + int sih_pending; +}; + +struct soft_intrq { + TAILQ_HEAD(, soft_intrhand) siq_list; + int siq_si; + struct mutex siq_mtx; +}; + +void *softintr_establish(int, void (*)(void *), void *); +void softintr_disestablish(void *); +void softintr_init(void); +void softintr_dispatch(int); +void softintr_schedule(void *); + +extern int softpending; + +/* XXX For legacy software interrupts. */ +extern struct soft_intrhand *softnet_intrhand; + +#define setsoftnet() softintr_schedule(softnet_intrhand) + +#endif /* _LOCORE */ + +#endif /* _KERNEL */ +#endif /* _M68K_INTR_H_ */ diff --git a/sys/arch/m68k/include/psl.h b/sys/arch/m68k/include/psl.h index f27c0ef0d8b..bf75afae893 100644 --- a/sys/arch/m68k/include/psl.h +++ b/sys/arch/m68k/include/psl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: psl.h,v 1.8 2009/03/15 19:40:40 miod Exp $ */ +/* $OpenBSD: psl.h,v 1.9 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: psl.h,v 1.5 1994/10/26 07:50:50 cgd Exp $ */ /* @@ -72,27 +72,6 @@ #ifdef _KERNEL -/* SPL asserts */ -#ifdef DIAGNOSTIC -/* - * Although this function is implemented in MI code, it must be in this MD - * header because we don't want this header to include MI includes. - */ -void splassert_fail(int, int, const char *); -extern int splassert_ctl; -void splassert_check(int, const char *); -#define splassert(__wantipl) \ -do { \ - if (splassert_ctl > 0) { \ - splassert_check(__wantipl, __func__); \ - } \ -} while (0) -#define splsoftassert(wantipl) splassert(wantipl) -#else -#define splassert(wantipl) do { /* nothing */ } while (0) -#define splsoftassert(wantipl) do { /* nothing */ } while (0) -#endif - /* * Convert PSL values to CPU IPLs and vice-versa. */ diff --git a/sys/arch/m68k/m68k/softintr.c b/sys/arch/m68k/m68k/softintr.c new file mode 100644 index 00000000000..35f0237335f --- /dev/null +++ b/sys/arch/m68k/m68k/softintr.c @@ -0,0 +1,198 @@ +/* $OpenBSD: softintr.c,v 1.1 2009/03/15 20:40:25 miod Exp $ */ +/* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe for Wasabi Systems, Inc. + * + * 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 for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/malloc.h> + +/* XXX Network interrupts should be converted to new softintrs. */ +#include <net/netisr.h> + +#include <uvm/uvm_extern.h> + +#include <machine/atomic.h> +#include <machine/intr.h> + +struct soft_intrq soft_intrq[SI_NQUEUES]; + +struct soft_intrhand *softnet_intrhand; + +void netintr(void); + +/* + * Initialize the software interrupt system. + */ +void +softintr_init(void) +{ + struct soft_intrq *siq; + int i; + + for (i = 0; i < SI_NQUEUES; i++) { + siq = &soft_intrq[i]; + TAILQ_INIT(&siq->siq_list); + siq->siq_si = i; + mtx_init(&siq->siq_mtx, IPL_HIGH); + } + + /* XXX Establish legacy software interrupt handlers. */ + softnet_intrhand = softintr_establish(IPL_SOFTNET, + (void (*)(void *))netintr, NULL); +} + +/* + * Process pending software interrupts on the specified queue. + * + * NOTE: We must already be at the correct interrupt priority level. + */ +void +softintr_dispatch(int si) +{ + struct soft_intrq *siq = &soft_intrq[si]; + struct soft_intrhand *sih; + + for (;;) { + mtx_enter(&siq->siq_mtx); + sih = TAILQ_FIRST(&siq->siq_list); + if (sih == NULL) { + mtx_leave(&siq->siq_mtx); + break; + } + + TAILQ_REMOVE(&siq->siq_list, sih, sih_list); + sih->sih_pending = 0; + + uvmexp.softs++; + + mtx_leave(&siq->siq_mtx); + + (*sih->sih_func)(sih->sih_arg); + } +} + +/* + * Register a software interrupt handler. + */ +void * +softintr_establish(int ipl, void (*func)(void *), void *arg) +{ + struct soft_intrhand *sih; + int si; + + switch (ipl) { + case IPL_SOFT: + si = SI_SOFT; + break; + case IPL_SOFTCLOCK: + si = SI_SOFTCLOCK; + break; + case IPL_SOFTNET: + si = SI_SOFTNET; + break; + case IPL_SOFTTTY: + si = SI_SOFTTTY; + break; + default: + printf("softintr_establish: unknown soft IPL %d\n", ipl); + return NULL; + } + + sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); + if (__predict_true(sih != NULL)) { + sih->sih_func = func; + sih->sih_arg = arg; + sih->sih_siq = &soft_intrq[si]; + sih->sih_pending = 0; + } + return (sih); +} + +/* + * Unregister a software interrupt handler. + */ +void +softintr_disestablish(void *arg) +{ + struct soft_intrhand *sih = arg; + struct soft_intrq *siq = sih->sih_siq; + + mtx_enter(&siq->siq_mtx); + if (sih->sih_pending) { + TAILQ_REMOVE(&siq->siq_list, sih, sih_list); + sih->sih_pending = 0; + } + mtx_leave(&siq->siq_mtx); + + free(sih, M_DEVBUF); +} + +/* + * Schedule a software interrupt. + */ +void +softintr_schedule(void *arg) +{ + struct soft_intrhand *sih = (struct soft_intrhand *)arg; + struct soft_intrq *siq = sih->sih_siq; + + mtx_enter(&siq->siq_mtx); + if (sih->sih_pending == 0) { + TAILQ_INSERT_TAIL(&siq->siq_list, sih, sih_list); + sih->sih_pending = 1; + atomic_setbits_int(&softpending, 1 << siq->siq_si); + } + mtx_leave(&siq->siq_mtx); +} + +int netisr; + +void +netintr(void) +{ + int n; + + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << (bit))) \ + fn(); \ + } while (0) +#include <net/netisr_dispatch.h> +#undef DONETISR + } +} diff --git a/sys/arch/mac68k/dev/adb.c b/sys/arch/mac68k/dev/adb.c index 0792b3b3e34..35e6700950b 100644 --- a/sys/arch/mac68k/dev/adb.c +++ b/sys/arch/mac68k/dev/adb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adb.c,v 1.26 2007/04/10 17:47:54 miod Exp $ */ +/* $OpenBSD: adb.c,v 1.27 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: adb.c,v 1.47 2005/06/16 22:43:36 jmc Exp $ */ /* $NetBSD: adb_direct.c,v 1.51 2005/06/16 22:43:36 jmc Exp $ */ @@ -113,6 +113,11 @@ int adb_polling; /* Are we polling? (Debugger mode) */ int adb_debug; /* Output debugging messages */ #endif /* ADB_DEBUG */ +struct adb_softc { + struct device sc_dev; + void *sc_softih; +}; + /* some misc. leftovers */ #define vPB 0x0000 #define vPB3 0x08 @@ -298,7 +303,7 @@ int adb_intr(void *); int adb_intr_II(void *); int adb_intr_IIsi(void *); int adb_intr_cuda(void *); -void adb_soft_intr(void); +void adb_soft_intr(void *); int send_adb_II(u_char *, u_char *, void *, void *, int); int send_adb_IIsi(u_char *, u_char *, void *, void *, int); int send_adb_cuda(u_char *, u_char *, void *, void *, int); @@ -306,14 +311,14 @@ void adb_intr_cuda_test(void); void adb_cuda_tickle(void); void adb_pass_up(struct adbCommand *); void adb_op_comprout(caddr_t, caddr_t, int); -void adb_reinit(struct device *); +void adb_reinit(struct adb_softc *); int count_adbs(void); int get_ind_adb_info(ADBDataBlock *, int); int get_adb_info(ADBDataBlock *, int); void adb_setup_hw_type(void); int adb_op(Ptr, Ptr, Ptr, short); void adb_read_II(u_char *); -void adb_hw_setup(struct device *); +void adb_hw_setup(struct adb_softc *); void adb_hw_setup_IIsi(u_char *); int adb_cmd_result(u_char *); int adb_guess_next_device(void); @@ -394,7 +399,7 @@ adb_intr_cuda(void *arg) struct adbCommand packet; s = splhigh(); /* can't be too careful - might be called */ - /* from a routine, NOT an interrupt */ + /* from a routine, NOT an interrupt */ ADB_VIA_CLR_INTR(); /* clear interrupt */ ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */ @@ -608,7 +613,7 @@ switch_start: splx(s); /* restore */ return (1); -} /* end adb_intr_cuda */ +} int @@ -696,12 +701,12 @@ send_adb_cuda(u_char *in, u_char *buffer, void *compRout, void *data, int if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ adb_intr_cuda(NULL); /* go process it */ if (adb_polling) - adb_soft_intr(); + adb_soft_intr(NULL); } } return 0; -} /* send_adb_cuda */ +} int @@ -1139,7 +1144,7 @@ send_adb_II(u_char *in, u_char *buffer, void *compRout, void *data, int command) if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ adb_intr_II(NULL); /* go process it */ if (adb_polling) - adb_soft_intr(); + adb_soft_intr(NULL); } } @@ -1418,7 +1423,7 @@ switch_start: splx(s); /* restore */ return (1); -} /* end adb_intr_IIsi */ +} /***************************************************************************** @@ -1512,12 +1517,12 @@ send_adb_IIsi(u_char *in, u_char *buffer, void *compRout, void *data, int if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ adb_intr_IIsi(NULL); /* go process it */ if (adb_polling) - adb_soft_intr(); + adb_soft_intr(NULL); } } - return 0; -} /* send_adb_IIsi */ + return 0; +} /* * adb_pass_up is called by the interrupt-time routines. @@ -1546,6 +1551,8 @@ send_adb_IIsi(u_char *in, u_char *buffer, void *compRout, void *data, int void adb_pass_up(struct adbCommand *in) { + extern struct cfdriver adb_cd; + struct adb_softc *sc; int start = 0, len = 0, cmd = 0; ADBDataBlock block; @@ -1650,10 +1657,14 @@ adb_pass_up(struct adbCommand *in) * If the debugger is running, call upper half manually. * Otherwise, trigger a soft interrupt to handle the rest later. */ - if (adb_polling) - adb_soft_intr(); + if (adb_cd.cd_ndevs != 0) + sc = (struct adb_softc *)adb_cd.cd_devs[0]; + else + sc = NULL; + if (adb_polling || sc == NULL || sc->sc_softih == NULL) + adb_soft_intr(NULL); else - setsoftadb(); + softintr_schedule(sc->sc_softih); } @@ -1663,7 +1674,7 @@ adb_pass_up(struct adbCommand *in) * */ void -adb_soft_intr(void) +adb_soft_intr(void *arg) { int s; int cmd = 0; @@ -1803,14 +1814,14 @@ adb_op(Ptr buffer, Ptr compRout, Ptr data, short command) * config (mainly VIA settings) for the various models. */ void -adb_hw_setup(struct device *self) +adb_hw_setup(struct adb_softc *sc) { volatile int i; u_char send_string[ADB_MAX_MSG_LENGTH]; switch (adbHardware) { case ADB_HW_II: - via1_register_irq(2, adb_intr_II, self, self->dv_xname); + via1_register_irq(2, adb_intr_II, sc, sc->sc_dev.dv_xname); via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: * outputs */ @@ -1829,7 +1840,7 @@ adb_hw_setup(struct device *self) break; case ADB_HW_IISI: - via1_register_irq(2, adb_intr_IIsi, self, self->dv_xname); + via1_register_irq(2, adb_intr_IIsi, sc, sc->sc_dev.dv_xname); via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: * outputs */ via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */ @@ -1864,11 +1875,11 @@ adb_hw_setup(struct device *self) * XXX - really PM_VIA_CLR_INTR - should we put it in * pm_direct.h? */ - pm_hw_setup(self); + pm_hw_setup(&sc->sc_dev); break; case ADB_HW_CUDA: - via1_register_irq(2, adb_intr_cuda, self, self->dv_xname); + via1_register_irq(2, adb_intr_cuda, sc, sc->sc_dev.dv_xname); via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: * outputs */ via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */ @@ -1979,7 +1990,7 @@ adb_hw_setup_IIsi(u_char *buffer) * */ void -adb_reinit(struct device *self) +adb_reinit(struct adb_softc *sc) { u_char send_string[ADB_MAX_MSG_LENGTH]; ADBDataBlock data; /* temp. holder for getting device info */ @@ -2012,7 +2023,7 @@ adb_reinit(struct device *self) ADBDevTable[i].origAddr = ADBDevTable[i].currentAddr = 0; } - adb_hw_setup(self); /* init the VIA bits and hard reset ADB */ + adb_hw_setup(sc); /* init the VIA bits and hard reset ADB */ delay(1000); @@ -2494,7 +2505,6 @@ set_adb_info(ADBSetInfoBlock *info, int adbAddr) } return (-1); /* not found */ - } /* caller should really use machine-independant version: getPramTime */ @@ -2741,8 +2751,9 @@ void adb_attach_deferred(void *); /* * Driver definition. */ + struct cfattach adb_ca = { - sizeof(struct device), adbmatch, adbattach + sizeof(struct adb_softc), adbmatch, adbattach }; int @@ -2769,15 +2780,15 @@ adbattach(struct device *parent, struct device *self, void *aux) void adb_attach_deferred(void *v) { - struct device *self = v; + struct adb_softc *sc = v; ADBDataBlock adbdata; struct adb_attach_args aa_args; int totaladbs; int adbindex, adbaddr; - printf("%s: ", self->dv_xname); + printf("%s: ", sc->sc_dev.dv_xname); adb_polling = 1; - adb_reinit(self); + adb_reinit(sc); #ifdef ADB_DEBUG if (adb_debug) @@ -2797,7 +2808,9 @@ adb_attach_deferred(void *v) aa_args.adbaddr = adbaddr; aa_args.handler_id = (int)(adbdata.devType); - (void)config_found(self, &aa_args, adbprint); + (void)config_found(&sc->sc_dev, &aa_args, adbprint); } + + sc->sc_softih = softintr_establish(IPL_SOFTTTY, adb_soft_intr, NULL); adb_polling = 0; } diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index 537eca51026..3a9bca02128 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn.c,v 1.50 2008/11/28 02:44:17 brad Exp $ */ +/* $OpenBSD: if_sn.c,v 1.51 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: if_sn.c,v 1.13 1997/04/25 03:40:10 briggs Exp $ */ /* @@ -29,7 +29,6 @@ #include <net/if.h> #include <net/if_dl.h> -#include <net/netisr.h> #ifdef INET #include <netinet/in.h> diff --git a/sys/arch/mac68k/dev/z8530sc.c b/sys/arch/mac68k/dev/z8530sc.c index 6ec3fef5ac6..28976cb10dc 100644 --- a/sys/arch/mac68k/dev/z8530sc.c +++ b/sys/arch/mac68k/dev/z8530sc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530sc.c,v 1.7 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: z8530sc.c,v 1.8 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: z8530sc.c,v 1.5 1996/12/17 20:42:40 gwr Exp $ */ /* @@ -229,69 +229,60 @@ zsc_intr_hard(arg) void *arg; { register struct zsc_softc *zsc = arg; - register struct zs_chanstate *cs_a; - register struct zs_chanstate *cs_b; - register int rval; - register u_char rr3, rr3a; - - cs_a = zsc->zsc_cs[0]; - cs_b = zsc->zsc_cs[1]; - rval = 0; - rr3a = 0; + register struct zs_chanstate *cs; + register u_char rr3; + /* First look at channel A. */ + cs = zsc->zsc_cs[0]; /* Note: only channel A has an RR3 */ - while ((rr3 = zs_read_reg(cs_a, 3)) != 0) { + rr3 = zs_read_reg(cs, 3); - /* Handle receive interrupts first. */ + /* + * Clear interrupt first to avoid a race condition. + * If a new interrupt condition happens while we are + * servicing this one, we will get another interrupt + * shortly. We can NOT just sit here in a loop, or + * we will cause horrible latency for other devices + * on this interrupt level (i.e. sun3x floppy disk). + */ + if (rr3 & (ZSRR3_IP_A_RX | ZSRR3_IP_A_TX | ZSRR3_IP_A_STAT)) { + zs_write_csr(cs, ZSWR0_CLR_INTR); if (rr3 & ZSRR3_IP_A_RX) - (*cs_a->cs_ops->zsop_rxint)(cs_a); - if (rr3 & ZSRR3_IP_B_RX) - (*cs_b->cs_ops->zsop_stint)(cs_b); - - /* Handle status interrupts (i.e. flow control). */ + (*cs->cs_ops->zsop_rxint)(cs); if (rr3 & ZSRR3_IP_A_STAT) - (*cs_a->cs_ops->zsop_stint)(cs_a); - if (rr3 & ZSRR3_IP_B_STAT) - (*cs_b->cs_ops->zsop_stint)(cs_b); - - /* Handle transmit done interrupts. */ + (*cs->cs_ops->zsop_stint)(cs); if (rr3 & ZSRR3_IP_A_TX) - (*cs_a->cs_ops->zsop_txint)(cs_a); - if (rr3 & ZSRR3_IP_B_TX) - (*cs_b->cs_ops->zsop_txint)(cs_b); - - /* Accumulate so we know what needs to be cleared. */ - rr3a |= rr3; + (*cs->cs_ops->zsop_txint)(cs); } - - /* Clear interrupt. */ - if (rr3a & (ZSRR3_IP_A_RX | ZSRR3_IP_A_TX | ZSRR3_IP_A_STAT)) { - zs_write_csr(cs_a, ZSWR0_CLR_INTR); - rval |= 1; - } - if (rr3a & (ZSRR3_IP_B_RX | ZSRR3_IP_B_TX | ZSRR3_IP_B_STAT)) { - zs_write_csr(cs_b, ZSWR0_CLR_INTR); - rval |= 2; + /* Now look at channel B. */ + cs = zsc->zsc_cs[1]; + if (rr3 & (ZSRR3_IP_B_RX | ZSRR3_IP_B_TX | ZSRR3_IP_B_STAT)) { + zs_write_csr(cs, ZSWR0_CLR_INTR); + if (rr3 & ZSRR3_IP_B_RX) + (*cs->cs_ops->zsop_stint)(cs); + if (rr3 & ZSRR3_IP_B_STAT) + (*cs->cs_ops->zsop_stint)(cs); + if (rr3 & ZSRR3_IP_B_TX) + (*cs->cs_ops->zsop_txint)(cs); } /* Note: caller will check cs_x->cs_softreq and DTRT. */ - return (rval); + return (rr3); } /* * ZS software interrupt. Scan all channels for deferred interrupts. */ -int +void zsc_intr_soft(arg) void *arg; { register struct zsc_softc *zsc = arg; register struct zs_chanstate *cs; - register int rval, chan; + register int chan; - rval = 0; for (chan = 0; chan < 2; chan++) { cs = zsc->zsc_cs[chan]; @@ -303,10 +294,8 @@ zsc_intr_soft(arg) if (cs->cs_softreq) { cs->cs_softreq = 0; (*cs->cs_ops->zsop_softint)(cs); - rval++; } } - return (rval); } /* diff --git a/sys/arch/mac68k/dev/z8530sc.h b/sys/arch/mac68k/dev/z8530sc.h index 6604c744bff..80a41ed7539 100644 --- a/sys/arch/mac68k/dev/z8530sc.h +++ b/sys/arch/mac68k/dev/z8530sc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530sc.h,v 1.6 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: z8530sc.h,v 1.7 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: z8530sc.h,v 1.5 1996/12/17 20:42:42 gwr Exp $ */ /* @@ -117,7 +117,7 @@ struct zsc_attach_args { #define ZS_HWFLAG_RAW 8 /* advise raw mode */ int zsc_intr_hard(void *); -int zsc_intr_soft(void *); +void zsc_intr_soft(void *); void zs_abort(struct zs_chanstate *); void zs_break(struct zs_chanstate *, int); diff --git a/sys/arch/mac68k/dev/z8530tty.c b/sys/arch/mac68k/dev/z8530tty.c index c1fc0235e88..246485e76c1 100644 --- a/sys/arch/mac68k/dev/z8530tty.c +++ b/sys/arch/mac68k/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.17 2006/04/14 09:36:49 martin Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.18 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.14 1996/12/17 20:42:43 gwr Exp $ */ /* @@ -163,20 +163,20 @@ struct zsops zsops_tty; /* Routines called from other code. */ cdev_decl(zs); /* open, close, read, write, ioctl, stop, ... */ -static void zsstart(struct tty *); -static int zsparam(struct tty *, struct termios *); -static void zs_modem(struct zstty_softc *zst, int onoff); -static int zshwiflow(struct tty *, int); -static void zs_hwiflow(struct zstty_softc *, int); -static void zstty_rxint(register struct zs_chanstate *); -static void zstty_txint(register struct zs_chanstate *); -static void zstty_stint(register struct zs_chanstate *); -static void zstty_softint(struct zs_chanstate *); -static void zsoverrun(struct zstty_softc *, long *, char *); +void zsstart(struct tty *); +int zsparam(struct tty *, struct termios *); +void zs_modem(struct zstty_softc *zst, int onoff); +int zshwiflow(struct tty *, int); +void zs_hwiflow(struct zstty_softc *, int); +void zstty_rxint(register struct zs_chanstate *); +void zstty_txint(register struct zs_chanstate *); +void zstty_stint(register struct zs_chanstate *); +void zstty_softint(struct zs_chanstate *); +void zsoverrun(struct zstty_softc *, long *, char *); /* * zstty_match: how is this zs channel configured? */ -int +static int zstty_match(parent, match, aux) struct device *parent; void *match, *aux; @@ -195,7 +195,7 @@ zstty_match(parent, match, aux) return 0; } -void +static void zstty_attach(parent, self, aux) struct device *parent, *self; void *aux; @@ -609,7 +609,7 @@ zsioctl(dev, cmd, data, flag, p) /* * Start or restart transmission. */ -static void +void zsstart(tp) register struct tty *tp; { @@ -711,7 +711,7 @@ zsstop(tp, flag) * XXX - Should just copy the whole termios after * making sure all the changes could be done. */ -static int +int zsparam(tp, t) register struct tty *tp; register struct termios *t; @@ -857,7 +857,7 @@ zsparam(tp, t) * Raise or lower modem control (DTR/RTS) signals. If a character is * in transmission, the change is deferred. */ -static void +void zs_modem(zst, onoff) struct zstty_softc *zst; int onoff; @@ -941,7 +941,7 @@ zshwiflow(tp, stop) * Internal version of zshwiflow * called at splzs */ -static void +void zs_hwiflow(zst, stop) register struct zstty_softc *zst; int stop; @@ -983,15 +983,15 @@ zs_hwiflow(zst, stop) * Interface to the lower layer (zscc) ****************************************************************/ -static void zstty_rxint (struct zs_chanstate *); -static void zstty_txint (struct zs_chanstate *); -static void zstty_stint (struct zs_chanstate *); +void zstty_rxint(struct zs_chanstate *); +void zstty_txint(struct zs_chanstate *); +void zstty_stint(struct zs_chanstate *); /* * receiver ready interrupt. * called at splzs */ -static void +void zstty_rxint(cs) register struct zs_chanstate *cs; { @@ -1058,7 +1058,7 @@ nextchar: /* * transmitter ready interrupt. (splzs) */ -static void +void zstty_txint(cs) register struct zs_chanstate *cs; { @@ -1110,7 +1110,7 @@ zstty_txint(cs) /* * status change interrupt. (splzs) */ -static void +void zstty_stint(cs) register struct zs_chanstate *cs; { @@ -1167,7 +1167,7 @@ zstty_stint(cs) /* * Print out a ring or fifo overrun error message. */ -static void +void zsoverrun(zst, ptime, what) struct zstty_softc *zst; long *ptime; @@ -1193,7 +1193,7 @@ zsoverrun(zst, ptime, what) * Note: an "input blockage" condition is assumed to exist if * EITHER the TS_TBLOCK flag or zst_rx_blocked flag is set. */ -static void +void zstty_softint(cs) struct zs_chanstate *cs; { diff --git a/sys/arch/mac68k/dev/zs.c b/sys/arch/mac68k/dev/zs.c index b1af641730f..794471d5002 100644 --- a/sys/arch/mac68k/dev/zs.c +++ b/sys/arch/mac68k/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.26 2008/01/23 16:37:56 jsing Exp $ */ +/* $OpenBSD: zs.c,v 1.27 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: zs.c,v 1.19 1998/01/12 19:22:18 thorpej Exp $ */ /* @@ -135,8 +135,6 @@ static int zs_defspeed[NZSC][2] = { }; void *zs_conschan = 0; int zs_consunit; -/* device to which the console is attached--if serial. */ -dev_t mac68k_zsdev; /* Mac stuff */ volatile unsigned char *sccA = 0; int nzsc_attached = 0; /* needed as long as we have spurious @@ -231,7 +229,7 @@ struct cfdriver zsc_cd = { }; int zshard(void *); -int zssoft(void *); +void zssoft(void *); /* @@ -415,6 +413,8 @@ zsc_attach(parent, self, aux) } } + /* XXX - Now safe to install interrupt handlers. */ + if (current_mac_model->class == MACH_CLASSAV) { add_psc_lev4_intr(PSCINTR_SCCA, zshard, zsc); add_psc_lev4_intr(PSCINTR_SCCB, zshard, zsc); @@ -422,7 +422,7 @@ zsc_attach(parent, self, aux) intr_establish(zshard, zsc, ZSHARD_PRI, self->dv_xname); } - /* XXX - Now safe to install interrupt handlers. */ + zsc->zsc_softih = softintr_establish(IPL_SOFTTTY, zssoft, zsc); /* * Set the master interrupt enable and interrupt vector. @@ -482,8 +482,6 @@ zsmd_setclock(cs) via_set_modem((xcs->cs_pclk_flag & ZSC_EXTERN) ? 1 : 0); } -static int zssoftpending; - /* * Do the minimum work to pull data off of the chip and queue it up * for later processing. @@ -493,54 +491,49 @@ zshard(arg) void *arg; { struct zsc_softc *zsc = (struct zsc_softc *)arg; - int rval; + int rr3, rval; + + /* + * The horror: the adb subsystem will invoke us directly. + * However if we were already servicing an interrupt, + * we'll lose bigtime. Don't allow such reentrancy. + */ + static int zshard_busy = 0; + + if (zshard_busy != 0) + return 0; if (zsc == NULL) return 0; + zshard_busy++; + rval = 0; - rval |= zsc_intr_hard(zsc); + while ((rr3 = zsc_intr_hard(zsc))) + rval |= rr3; + if ((zsc->zsc_cs[0]->cs_softreq) || (zsc->zsc_cs[1]->cs_softreq)) { /* zsc_req_softint(zsc); */ - /* We are at splzs here, so no need to lock. */ - if (zssoftpending == 0) { - zssoftpending = 1; - setsoftserial(); - } + softintr_schedule(zsc->zsc_softih); } + + zshard_busy--; + return (rval); } -/* - * Similar scheme as for zshard (look at all of them) - */ -int +void zssoft(arg) void *arg; { - register struct zsc_softc *zsc; - register int unit; - - /* This is not the only ISR on this IPL. */ - if (zssoftpending == 0) - return (0); - - /* - * The soft intr. bit will be set by zshard only if - * the variable zssoftpending is zero. - */ - zssoftpending = 0; + struct zsc_softc *zsc = (struct zsc_softc *)arg; + int s; - for (unit = 0; unit < zsc_cd.cd_ndevs; ++unit) { - zsc = zsc_cd.cd_devs[unit]; - if (zsc == NULL) - continue; - (void) zsc_intr_soft(zsc); - } - return (1); + s = spltty(); + zsc_intr_soft(zsc); + splx(s); } - #ifndef ZS_TOLERANCE #define ZS_TOLERANCE 51 /* 5% in tenths of a %, plus 1 so that exactly 5% will be ok. */ @@ -837,7 +830,8 @@ zs_write_reg(cs, reg, val) ZS_DELAY(); } -u_char zs_read_csr(cs) +u_char +zs_read_csr(cs) struct zs_chanstate *cs; { u_char val; @@ -849,7 +843,8 @@ u_char zs_read_csr(cs) return val; } -void zs_write_csr(cs, val) +void +zs_write_csr(cs, val) struct zs_chanstate *cs; register u_char val; { @@ -858,7 +853,8 @@ void zs_write_csr(cs, val) ZS_DELAY(); } -u_char zs_read_data(cs) +u_char +zs_read_data(cs) struct zs_chanstate *cs; { register u_char val; @@ -868,7 +864,8 @@ u_char zs_read_data(cs) return val; } -void zs_write_data(cs, val) +void +zs_write_data(cs, val) struct zs_chanstate *cs; u_char val; { @@ -973,7 +970,7 @@ zscnprobe(struct consdev * cp) zs_consunit = unit; zs_conschan = (struct zschan *) -1; /* dummy flag for zs_init() */ - mac68k_zsdev = cp->cn_dev = makedev(maj, unit); + cp->cn_dev = makedev(maj, unit); } if (mac68k_machine.serial_boot_echo) { /* diff --git a/sys/arch/mac68k/include/intr.h b/sys/arch/mac68k/include/intr.h index b29ee66d211..42d1140ef30 100644 --- a/sys/arch/mac68k/include/intr.h +++ b/sys/arch/mac68k/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.18 2007/11/30 08:19:43 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.19 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: intr.h,v 1.9 1998/08/12 06:58:42 scottr Exp $ */ /* @@ -55,8 +55,7 @@ extern u_short mac68k_statclockipl; * - compute CPU PSL values for the spl*() calls. */ #define IPL_NONE 0 -#define IPL_SOFTNET 1 -#define IPL_SOFTCLOCK 1 +#define IPL_SOFTINT 1 #define IPL_BIO 2 #define IPL_AUDIO PSLTOIPL(mac68k_audioipl) #define IPL_NET PSLTOIPL(mac68k_netipl) @@ -96,25 +95,7 @@ extern u_short mac68k_statclockipl; /* watch out for side effects */ #define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) -/* - * simulated software interrupt register - */ -extern volatile u_int8_t ssir; - -#define SIR_NET 0x01 -#define SIR_CLOCK 0x02 -#define SIR_SERIAL 0x04 -#define SIR_ADB 0x08 - -#define siron(mask) \ - __asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask)) -#define siroff(mask) \ - __asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask))) - -#define setsoftnet() siron(SIR_NET) -#define setsoftclock() siron(SIR_CLOCK) -#define setsoftserial() siron(SIR_SERIAL) -#define setsoftadb() siron(SIR_ADB) +#include <m68k/intr.h> /* soft interrupt support */ /* intr.c */ void intr_init(void); diff --git a/sys/arch/mac68k/include/z8530var.h b/sys/arch/mac68k/include/z8530var.h index 5bf9a0bb3a4..f031d38cda9 100644 --- a/sys/arch/mac68k/include/z8530var.h +++ b/sys/arch/mac68k/include/z8530var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530var.h,v 1.7 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: z8530var.h,v 1.8 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: z8530var.h,v 1.2 1996/06/07 10:27:19 briggs Exp $ */ /* @@ -97,6 +97,7 @@ struct zsc_softc { struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ /* Machine-dependent part follows... */ struct xzs_chanstate xzsc_xcs_store[2]; + void *zsc_softih; }; /* diff --git a/sys/arch/mac68k/mac68k/autoconf.c b/sys/arch/mac68k/mac68k/autoconf.c index ae2c49e962c..4e4d1235155 100644 --- a/sys/arch/mac68k/mac68k/autoconf.c +++ b/sys/arch/mac68k/mac68k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.31 2008/07/21 04:35:54 todd Exp $ */ +/* $OpenBSD: autoconf.c,v 1.32 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.38 1996/12/18 05:46:09 scottr Exp $ */ /* @@ -110,6 +110,9 @@ findbootdev() void cpu_configure() { + /* this couldn't be done in intr_init() because this uses malloc() */ + softintr_init(); + startrtclock(); if (config_rootfound("mainbus", "mainbus") == NULL) diff --git a/sys/arch/mac68k/mac68k/intr.c b/sys/arch/mac68k/mac68k/intr.c index 45b725cfe99..9e2c2bbea58 100644 --- a/sys/arch/mac68k/mac68k/intr.c +++ b/sys/arch/mac68k/mac68k/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.12 2008/06/26 05:42:12 ray Exp $ */ +/* $OpenBSD: intr.c,v 1.13 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: intr.c,v 1.2 1998/08/25 04:03:56 scottr Exp $ */ /*- @@ -42,9 +42,6 @@ #include <uvm/uvm_extern.h> -#include <net/netisr.h> - -#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -204,28 +201,6 @@ intr_dispatch(int evec) /* format | vector offset */ } } -int netisr; - -void -netintr() -{ - int isr; - - while ((isr = netisr) != 0) { - atomic_clearbits_int(&netisr, isr); - -#define DONETISR(bit, fn) \ - do { \ - if (isr & (1 << bit)) \ - (fn)(); \ - } while (0) - -#include <net/netisr_dispatch.h> - -#undef DONETISR - } -} - #ifdef DIAGNOSTIC void splassert_check(int wantipl, const char *func) diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s index 5fe0927635b..9feb14dd59c 100644 --- a/sys/arch/mac68k/mac68k/locore.s +++ b/sys/arch/mac68k/mac68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.61 2007/12/30 14:45:25 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.62 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: locore.s,v 1.103 1998/07/09 06:02:50 scottr Exp $ */ /* @@ -629,10 +629,10 @@ ENTRY_NOPROFILE(trap0) addql #4,sp | pop syscall arg tstl _C_LABEL(astpending) jne Lrei2 - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jeq Ltrap1 movw #SPL1,sr - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jne Lsir1 Ltrap1: movl sp@(FR_SP),a0 | grab and restore @@ -871,7 +871,7 @@ ENTRY_NOPROFILE(rtclock_intr) * necessitating a stack cleanup. */ -BSS(ssir,1) +BSS(softpending,4) ASENTRY_NOPROFILE(rei) tstl _C_LABEL(astpending) | AST pending? @@ -909,7 +909,7 @@ Laststkadj: movl sp@,sp | and our SP rte | and do real RTE Lchksir: - tstb _C_LABEL(ssir) | SIR pending? + tstl _C_LABEL(softpending) | SIR pending? jeq Ldorte | no, all done movl d0,sp@- | need a scratch register movw sp@(4),d0 | get SR @@ -918,7 +918,7 @@ Lchksir: movl sp@+,d0 | restore scratch register Lgotsir: movw #SPL1,sr | prevent others from servicing int - tstb _C_LABEL(ssir) | too late? + tstl _C_LABEL(softpending) | too late? jeq Ldorte | yes, oh well... clrl sp@- | stack adjust moveml #0xFFFF,sp@- | save all registers @@ -1318,7 +1318,7 @@ ENTRY(spl0) moveq #0,d0 movw sr,d0 | get old SR for return movw #PSL_LOWIPL,sr | restore new SR - tstb _C_LABEL(ssir) | software interrupt pending? + tstl _C_LABEL(softpending) | software interrupt pending? jeq Lspldone | no, all done subql #4,sp | make room for RTE frame movl sp@(4),sp@(2) | position return address diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 38d8e9d41ff..ddcb73577df 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.55 2008/06/08 20:57:19 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.56 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -476,30 +476,19 @@ copyfault: case T_SSIR: /* Software interrupt */ case T_SSIR|T_USER: - if (ssir & SIR_SERIAL) { - void zssoft(int); - siroff(SIR_SERIAL); - uvmexp.softs++; - zssoft(0); - } - if (ssir & SIR_NET) { - void netintr(void); - siroff(SIR_NET); - uvmexp.softs++; - netintr(); - } - if (ssir & SIR_CLOCK) { - void softclock(void); - siroff(SIR_CLOCK); - uvmexp.softs++; - softclock(); - } - if (ssir & SIR_ADB) { - void adb_soft_intr(void); - siroff(SIR_ADB); - uvmexp.softs++; - adb_soft_intr(); + { + int sir, q, mask; + + while ((sir = softpending) != 0) { + atomic_clearbits_int(&softpending, sir); + + for (q = SI_NQUEUES - 1, mask = 1 << (SI_NQUEUES - 1); + mask != 0; q--, mask >>= 1) + if (mask & sir) + softintr_dispatch(q); } + } + /* * If this was not an AST trap, we are all done. */ diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c index 9042dc80b93..d6c0b3e5d6f 100644 --- a/sys/arch/mac68k/mac68k/via.c +++ b/sys/arch/mac68k/mac68k/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.31 2007/09/10 20:29:50 miod Exp $ */ +/* $OpenBSD: via.c,v 1.32 2009/03/15 20:40:25 miod Exp $ */ /* $NetBSD: via.c,v 1.62 1997/09/10 04:38:48 scottr Exp $ */ /*- @@ -198,8 +198,7 @@ via1_intr(void *arg) return (0); /* - * Unflag interrupts here. If we do it after each interrupt, - * the MRG ADB hangs up. + * Unflag interrupts here. */ via_reg(VIA1, vIFR) = intbits; diff --git a/sys/arch/mvme68k/dev/cl.c b/sys/arch/mvme68k/dev/cl.c index dc47ddf252e..57b2baeeb36 100644 --- a/sys/arch/mvme68k/dev/cl.c +++ b/sys/arch/mvme68k/dev/cl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl.c,v 1.45 2009/03/01 21:37:41 miod Exp $ */ +/* $OpenBSD: cl.c,v 1.46 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn. All rights reserved. @@ -128,7 +128,7 @@ struct clsoftc { char sc_rxintrname[16 + 3]; char sc_txintrname[16 + 3]; int sc_flags; - u_int8_t ssir; + void *sc_softih; }; const struct { @@ -315,7 +315,7 @@ clattach(parent, self, aux) sc->sc_cl[i].psupply = sc->sc_cl[i].buffer; sc->sc_cl[i].nchar = 0; } - sc->ssir = allocate_sir(cl_softint, (void *)sc); + sc->sc_softih = softintr_establish(IPL_SOFTTTY, cl_softint, sc); #endif for (i = 0; i < CLCD_PORTS_PER_CHIP; i++) { #if 0 @@ -1973,7 +1973,7 @@ cl_appendbuf(sc, channel, c) sc->sc_cl[channel].psupply = sc->sc_cl[channel].buffer; } sc->sc_cl[channel].nchar ++; - setsoftint(sc->ssir); + softintr_schedule(sc->sc_softih); /* splx (s); */ } @@ -2004,7 +2004,7 @@ cl_appendbufn(sc, channel, buf, cnt) } sc->sc_cl[channel].nchar ++; } - setsoftint(sc->ssir); + softintr_schedule(sc->sc_softih); /* splx (s); */ } diff --git a/sys/arch/mvme68k/dev/zs.c b/sys/arch/mvme68k/dev/zs.c index c033c859a90..ac3e2a4fae8 100644 --- a/sys/arch/mvme68k/dev/zs.c +++ b/sys/arch/mvme68k/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.26 2008/01/23 16:37:57 jsing Exp $ */ +/* $OpenBSD: zs.c,v 1.27 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (c) 2000 Steve Murphree, Jr. @@ -109,10 +109,11 @@ struct zs { #define ZH_RXOVF 8 /* receiver buffer overflow */ struct zssoftc { - struct device sc_dev; - struct zs sc_zs[2]; - struct intrhand sc_ih; - int sc_flags; + struct device sc_dev; + struct zs sc_zs[2]; + struct intrhand sc_ih; + void *sc_softih; + int sc_flags; }; #define ZSSF_85230 1 @@ -129,7 +130,6 @@ int zsirq(void *); int zsregs(vaddr_t, int, volatile u_char **, volatile u_char **); int zspclk(void); -u_int8_t sir_zs; void zs_softint(void *); #define zsunit(dev) (minor(dev) >> 1) @@ -159,9 +159,9 @@ void zscc_mset(struct sccregs *, int); void zscc_mclr(struct sccregs *, int); void zs_drain(struct zs *); void zs_unblock(struct tty *); -void zs_txint(struct zs *); -void zs_rxint(struct zs *); -void zs_extint(struct zs *); +void zs_txint(struct zssoftc *, struct zs *); +void zs_rxint(struct zssoftc *, struct zs *); +void zs_extint(struct zssoftc *, struct zs *); cons_decl(zs); int @@ -263,8 +263,7 @@ zsattach(parent, self, args) zp->scc.s_dr = scc_dr; zp->flags |= ZS_RESET; - if (sir_zs == 0) - sir_zs = allocate_sir(zs_softint, 0); + sc->sc_softih = softintr_establish(IPL_SOFTTTY, zs_softint, sc); printf("\n"); @@ -535,7 +534,7 @@ zsstart(tp) zp->send_ptr = tp->t_outq.c_cf; zp->send_count = n; zp->sent_count = 0; - zs_txint(zp); + zs_txint(sc, zp); spltty(); } } @@ -759,26 +758,25 @@ zsirq(arg) if (ipend == 0) return (0); if ((ipend & 0x20) != 0) - zs_rxint(zp); + zs_rxint(sc, zp); if ((ipend & 0x10) != 0) - zs_txint(zp); + zs_txint(sc, zp); if ((ipend & 0x8) != 0) - zs_extint(zp); + zs_extint(sc, zp); ++zp; /* now look for B side ints */ if ((ipend & 0x4) != 0) - zs_rxint(zp); + zs_rxint(sc, zp); if ((ipend & 0x2) != 0) - zs_txint(zp); + zs_txint(sc, zp); if ((ipend & 0x1) != 0) - zs_extint(zp); + zs_extint(sc, zp); ZWRITE0(&zp->scc, 0x38); /* reset highest IUS */ return (1); } void -zs_txint(zp) - register struct zs *zp; +zs_txint(struct zssoftc *sc, struct zs *zp) { struct sccregs *scc; int c; @@ -798,14 +796,13 @@ zs_txint(zp) if (zp->send_count == 0 && (zp->hflags & ZH_TXING) != 0) { zp->hflags &= ~ZH_TXING; zp->hflags |= ZH_SIRQ; - setsoftint(sir_zs); + softintr_schedule(sc->sc_softih); } } } void -zs_rxint(zp) - register struct zs *zp; +zs_rxint(struct zssoftc *sc, struct zs *zp) { register int stat, c, n, extra; u_char *put; @@ -846,14 +843,13 @@ zs_rxint(zp) zp->rcv_put = put; zp->rcv_count = n; zp->hflags |= ZH_SIRQ; - setsoftint(sir_zs); + softintr_schedule(sc->sc_softih); } } /* Ext/status interrupt */ void -zs_extint(zp) - register struct zs *zp; +zs_extint(struct zssoftc *sc, struct zs *zp) { int rr0; struct tty *tp = zp->tty; @@ -875,13 +871,13 @@ zs_extint(zp) else { zp->hflags &= ~ZH_OBLOCK; if ((rr0 & SCC_TXRDY) != 0) - zs_txint(zp); + zs_txint(sc, zp); } } zp->modem_change |= rr0 ^ zp->modem_state; zp->modem_state = rr0; zp->hflags |= ZH_SIRQ; - setsoftint(sir_zs); + softintr_schedule(sc->sc_softih); } /* ARGSUSED */ @@ -889,97 +885,93 @@ void zs_softint(arg) void *arg; { + struct zssoftc *sc = (struct zssoftc *)arg; int s, c, stat, rr0; struct zs *zp; struct tty *tp; u_char *get; - int unit, side; + int side; s = splzs(); - for (unit = 0; unit < zs_cd.cd_ndevs; ++unit) { - if (zs_cd.cd_devs[unit] == NULL) + zp = &sc->sc_zs[0]; + for (side = 0; side < 2; ++side, ++zp) { + if ((zp->hflags & ZH_SIRQ) == 0) continue; - zp = &((struct zssoftc *) zs_cd.cd_devs[unit])->sc_zs[0]; - for (side = 0; side < 2; ++side, ++zp) { - if ((zp->hflags & ZH_SIRQ) == 0) - continue; - zp->hflags &= ~ZH_SIRQ; - tp = zp->tty; + zp->hflags &= ~ZH_SIRQ; + tp = zp->tty; - /* check for tx done */ - spltty(); - if (tp != NULL && zp->send_count == 0 - && (tp->t_state & TS_BUSY) != 0) { - tp->t_state &= ~(TS_BUSY | TS_FLUSH); - ndflush(&tp->t_outq, zp->sent_count); - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t) & tp->t_outq); - } - selwakeup(&tp->t_wsel); + /* check for tx done */ + spltty(); + if (tp != NULL && zp->send_count == 0 + && (tp->t_state & TS_BUSY) != 0) { + tp->t_state &= ~(TS_BUSY | TS_FLUSH); + ndflush(&tp->t_outq, zp->sent_count); + if (tp->t_outq.c_cc <= tp->t_lowat) { + if (tp->t_state & TS_ASLEEP) { + tp->t_state &= ~TS_ASLEEP; + wakeup((caddr_t) & tp->t_outq); } - if (tp->t_line != 0) - (*linesw[tp->t_line].l_start) (tp); - else - zsstart(tp); + selwakeup(&tp->t_wsel); } - splzs(); + if (tp->t_line != 0) + (*linesw[tp->t_line].l_start) (tp); + else + zsstart(tp); + } + splzs(); - /* check for received characters */ - get = zp->rcv_get; - while (zp->rcv_count > 0) { + /* check for received characters */ + get = zp->rcv_get; + while (zp->rcv_count > 0) { + c = *get++; + if (get >= zp->rcv_end) + get = zp->rcv_buf; + if (c == ERROR_DET) { + stat = *get++; + if (get >= zp->rcv_end) + get = zp->rcv_buf; c = *get++; if (get >= zp->rcv_end) get = zp->rcv_buf; - if (c == ERROR_DET) { - stat = *get++; - if (get >= zp->rcv_end) - get = zp->rcv_buf; - c = *get++; - if (get >= zp->rcv_end) - get = zp->rcv_buf; - zp->rcv_count -= 3; - } else { - stat = 0; - --zp->rcv_count; + zp->rcv_count -= 3; + } else { + stat = 0; + --zp->rcv_count; + } + spltty(); + if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) + continue; + if (zp->nzs_open == 0) { + } else { + if ((stat & 0x10) != 0) + c |= TTY_PE; + if ((stat & 0x20) != 0) { + log(LOG_WARNING, "zs: fifo overflow\n"); + c |= TTY_FE; /* need some error for + * slip stuff */ } + if ((stat & 0x40) != 0) + c |= TTY_FE; + (*linesw[tp->t_line].l_rint) (c, tp); + } + splzs(); + } + zp->rcv_get = get; + + /* check for modem lines changing */ + while (zp->modem_change != 0 || zp->modem_state != zp->rr0) { + rr0 = zp->rr0 ^ zp->modem_change; + zp->modem_change = rr0 ^ zp->modem_state; + + /* Check if DCD (carrier detect) has changed */ + if (tp != NULL && (rr0 & 8) != (zp->rr0 & 8)) { spltty(); - if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) - continue; - if (zp->nzs_open == 0) { - - } else { - if ((stat & 0x10) != 0) - c |= TTY_PE; - if ((stat & 0x20) != 0) { - log(LOG_WARNING, "zs: fifo overflow\n"); - c |= TTY_FE; /* need some error for - * slip stuff */ - } - if ((stat & 0x40) != 0) - c |= TTY_FE; - (*linesw[tp->t_line].l_rint) (c, tp); - } + ttymodem(tp, rr0 & 8); + /* XXX possibly should disable line if + * return value is 0 */ splzs(); } - zp->rcv_get = get; - - /* check for modem lines changing */ - while (zp->modem_change != 0 || zp->modem_state != zp->rr0) { - rr0 = zp->rr0 ^ zp->modem_change; - zp->modem_change = rr0 ^ zp->modem_state; - - /* Check if DCD (carrier detect) has changed */ - if (tp != NULL && (rr0 & 8) != (zp->rr0 & 8)) { - spltty(); - ttymodem(tp, rr0 & 8); - /* XXX possibly should disable line if - * return value is 0 */ - splzs(); - } - zp->rr0 = rr0; - } + zp->rr0 = rr0; } } splx(s); diff --git a/sys/arch/mvme68k/include/intr.h b/sys/arch/mvme68k/include/intr.h index c6f711cb9aa..bd16c4471f3 100644 --- a/sys/arch/mvme68k/include/intr.h +++ b/sys/arch/mvme68k/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.17 2009/03/01 21:40:49 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.18 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (C) 2000 Steve Murphree, Jr. * All rights reserved. @@ -34,25 +34,6 @@ #ifdef _KERNEL /* - * Simulated software interrupt register. - */ -extern volatile u_int8_t ssir; - -#define SIR_NET 0x01 -#define SIR_CLOCK 0x02 - -#define siron(mask) \ - __asm __volatile ( "orb %1,%0" : "=m" (ssir) : "ir" (mask)) -#define siroff(mask) \ - __asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask))) - -#define setsoftint(s) siron(s) -#define setsoftnet() siron(SIR_NET) -#define setsoftclock() siron(SIR_CLOCK) - -u_int8_t allocate_sir(void (*proc)(void *), void *arg); - -/* * Interrupt "levels". These are a more abstract representation * of interrupt levels, and do not have the same meaning as m68k * CPU interrupt levels. They serve two purposes: @@ -61,8 +42,7 @@ u_int8_t allocate_sir(void (*proc)(void *), void *arg); * - compute CPU PSL values for the spl*() calls. */ #define IPL_NONE 0 -#define IPL_SOFTNET 1 -#define IPL_SOFTCLOCK 1 +#define IPL_SOFTINT 1 #define IPL_BIO 2 #define IPL_NET 3 #define IPL_TTY 5 @@ -86,6 +66,8 @@ u_int8_t allocate_sir(void (*proc)(void *), void *arg); /* watch out for side effects */ #define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) +#include <m68k/intr.h> /* soft interrupt support */ + /* locore.s */ int spl0(void); diff --git a/sys/arch/mvme68k/mvme68k/locore.s b/sys/arch/mvme68k/mvme68k/locore.s index 56cdfa8f350..6dc91bbe290 100644 --- a/sys/arch/mvme68k/mvme68k/locore.s +++ b/sys/arch/mvme68k/mvme68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.60 2009/03/01 22:08:13 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.61 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -1009,10 +1009,10 @@ ENTRY_NOPROFILE(trap0) addql #4,sp | pop syscall arg tstl _C_LABEL(astpending) jne Lrei2 - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jeq Ltrap1 movw #SPL1,sr - tstb _C_LABEL(ssir) + tstl _C_LABEL(softpending) jne Lsir1 Ltrap1: movl sp@(FR_SP),a0 | grab and restore @@ -1197,7 +1197,7 @@ ENTRY_NOPROFILE(spurintr) * necessitating a stack cleanup. */ -BSS(ssir,1) +BSS(softpending,4) ASENTRY_NOPROFILE(rei) tstl _C_LABEL(astpending) | AST pending? @@ -1235,7 +1235,7 @@ Laststkadj: movl sp@,sp | and our SP rte | and do real RTE Lchksir: - tstb _C_LABEL(ssir) | SIR pending? + tstl _C_LABEL(softpending) | SIR pending? jeq Ldorte | no, all done movl d0,sp@- | need a scratch register movw sp@(4),d0 | get SR @@ -1244,7 +1244,7 @@ Lchksir: movl sp@+,d0 | restore scratch register Lgotsir: movw #SPL1,sr | prevent others from servicing int - tstb _C_LABEL(ssir) | too late? + tstl _C_LABEL(softpending) | too late? jeq Ldorte | yes, oh well... clrl sp@- | stack adjust moveml #0xFFFF,sp@- | save all registers @@ -1690,7 +1690,7 @@ ENTRY(spl0) moveq #0,d0 movw sr,d0 | get old SR for return movw #PSL_LOWIPL,sr | restore new SR - tstb _C_LABEL(ssir) | software interrupt pending? + tstl _C_LABEL(softpending) | software interrupt pending? jeq Lspldone | no, all done subql #4,sp | make room for RTE frame movl sp@(4),sp@(2) | position return address diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 0a8d85d8df9..206d606a0da 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.113 2009/03/01 22:08:13 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.114 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -111,8 +111,6 @@ #include <dev/cons.h> -#include <net/netisr.h> - #ifdef DDB #include <machine/db_machdep.h> #include <ddb/db_extern.h> @@ -870,29 +868,6 @@ badvaddr(addr, size) return (0); } -int netisr; - -void -netintr(arg) - void *arg; -{ - int n; - - while ((n = netisr) != 0) { - atomic_clearbits_int(&netisr, n); - -#define DONETISR(bit, fn) \ - do { \ - if (n & (1 << (bit))) \ - (fn)(); \ - } while (0) - -#include <net/netisr_dispatch.h> - -#undef DONETISR - } -} - /* * Level 7 interrupts are normally caused by the ABORT switch, * drop into ddb. diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index 38fdc8d0811..aa9f371ebcf 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.67 2007/05/15 13:46:22 martin Exp $ */ +/* $OpenBSD: trap.c,v 1.68 2009/03/15 20:40:25 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -158,11 +158,6 @@ int mmupid = -1; #define MDB_ISPID(p) (p) == mmupid #endif -#define NSIR 8 -void (*sir_routines[NSIR])(void *); -void *sir_args[NSIR]; -u_char next_sir; - void trap(int, u_int, u_int, struct frame); void syscall(register_t, struct frame); void init_intrs(void); @@ -238,7 +233,7 @@ trap(type, code, v, frame) register struct proc *p; register int i; u_int ucode; - int typ = 0, bit; + int typ = 0; #ifdef COMPAT_HPUX extern struct emul emul_hpux; #endif @@ -473,13 +468,19 @@ copyfault: case T_SSIR: /* software interrupt */ case T_SSIR|T_USER: - while ((bit = ffs(ssir))) { - --bit; - ssir &= ~(1 << bit); - uvmexp.softs++; - if (sir_routines[bit]) - sir_routines[bit](sir_args[bit]); + { + int sir, q, mask; + + while ((sir = softpending) != 0) { + atomic_clearbits_int(&softpending, sir); + + for (q = SI_NQUEUES - 1, mask = 1 << (SI_NQUEUES - 1); + mask != 0; q--, mask >>= 1) + if (mask & sir) + softintr_dispatch(q); } + } + /* * If this was not an AST trap, we are all done. */ @@ -1100,24 +1101,6 @@ bad: #endif } -/* - * Allocation routines for software interrupts. - */ -u_int8_t -allocate_sir(proc, arg) - void (*proc)(void *); - void *arg; -{ - int bit; - - if (next_sir >= NSIR) - panic("allocate_sir: none left"); - bit = next_sir++; - sir_routines[bit] = proc; - sir_args[bit] = arg; - return (1 << bit); -} - typedef SLIST_HEAD(,intrhand) intrhand_t; intrhand_t intrs[NVMEINTR]; @@ -1132,9 +1115,7 @@ init_intrs() SLIST_INIT(&intrs[i]); /* soft interrupts... */ - sir_routines[0] = netintr; - sir_routines[1] = (void (*)(void *))softclock; - next_sir = 2; + softintr_init(); } void |