diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-03-16 01:13:43 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-03-16 01:13:43 +0000 |
commit | bd92ac1178eeff98c863e5de035eeacc78eec388 (patch) | |
tree | 0559511574bc43cd15ad56bdecdda738b4a750f9 | |
parent | aab6c3e9e74d546123b5a46c1151dffede4f1bd6 (diff) |
separate out interrupt handling stuff
-rw-r--r-- | sys/arch/hppa/hppa/intr.c | 127 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/trap.c | 100 | ||||
-rw-r--r-- | sys/arch/hppa/include/autoconf.h | 3 |
3 files changed, 132 insertions, 98 deletions
diff --git a/sys/arch/hppa/hppa/intr.c b/sys/arch/hppa/hppa/intr.c new file mode 100644 index 00000000000..2931e689ca4 --- /dev/null +++ b/sys/arch/hppa/hppa/intr.c @@ -0,0 +1,127 @@ +/* $OpenBSD: intr.c,v 1.1 2002/03/16 01:13:42 mickey Exp $ */ + +/* + * Copyright (c) 2002 Michael Shalayeff + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael Shalayeff. + * 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 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 OR HIS RELATIVES 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 MIND, 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. + */ + +/* #define INTRDEBUG */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/device.h> + +#include <machine/autoconf.h> + +#ifdef DDB +#include <machine/db_machdep.h> +#endif + +#ifdef INTRDEBUG +#include <ddb/db_output.h> +#endif + +/* all the interrupts, minus cpu clock, which is the last */ +struct cpu_intr_vector { + struct evcnt evcnt; + int pri; + int (*handler)(void *); + void *arg; +} cpu_intr_vectors[CPU_NINTS]; + +void * +cpu_intr_establish(pri, irq, handler, arg, dv) + int pri, irq; + int (*handler)(void *); + void *arg; + struct device *dv; +{ + register struct cpu_intr_vector *iv; + + if (0 <= irq && irq < CPU_NINTS && cpu_intr_vectors[irq].handler) + return NULL; + + iv = &cpu_intr_vectors[irq]; + iv->pri = pri; + iv->handler = handler; + iv->arg = arg; + evcnt_attach(dv, dv->dv_xname, &iv->evcnt); + + return iv; +} + +void +cpu_intr(frame) + struct trapframe *frame; +{ + u_int32_t eirr = 0, r; + register struct cpu_intr_vector *iv; + register int bit; + + do { + mfctl(CR_EIRR, r); + eirr |= r; +#ifdef INTRDEBUG + if (eirr & 0x7fffffff) + db_printf ("cpu_intr: 0x%08x & 0x%08x\n", + eirr, frame->tf_eiem); +#endif + eirr &= frame->tf_eiem; + bit = ffs(eirr) - 1; + if (bit >= 0) { + mtctl(1 << bit, CR_EIRR); + eirr &= ~(1 << bit); + /* ((struct iomod *)cpu_gethpa(0))->io_eir = 0; */ +#ifdef INTRDEBUG + if (bit != 31) + db_printf ("cpu_intr: 0x%08x\n", (1 << bit)); +#endif + iv = &cpu_intr_vectors[bit]; + if (iv->handler) { + register int s, r; + + iv->evcnt.ev_count++; + s = splraise(iv->pri); + /* no arg means pass the frame */ + r = (iv->handler)(iv->arg? iv->arg:frame); + splx(s); +#ifdef INTRDEBUG + if (!r) + db_printf ("%s: can't handle interrupt\n", + iv->evcnt.ev_name); +#endif + } +#ifdef INTRDEBUG + else + db_printf ("cpu_intr: stray interrupt %d\n", bit); +#endif + } + } while (eirr); +} diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index a4d4322fd66..d74614e1e03 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.40 2002/03/15 21:44:18 mickey Exp $ */ +/* $OpenBSD: trap.c,v 1.41 2002/03/16 01:13:42 mickey Exp $ */ /* * Copyright (c) 1998-2001 Michael Shalayeff @@ -30,38 +30,28 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* #define INTRDEBUG */ /* #define TRAPDEBUG */ #include <sys/param.h> #include <sys/systm.h> -#include <sys/kernel.h> #include <sys/syscall.h> #include <sys/ktrace.h> #include <sys/proc.h> #include <sys/signalvar.h> #include <sys/user.h> -#include <sys/acct.h> -#include <sys/signal.h> -#include <sys/device.h> #include <net/netisr.h> #include <uvm/uvm.h> -#include <machine/iomod.h> -#include <machine/cpufunc.h> -#include <machine/reg.h> #include <machine/autoconf.h> #ifdef DDB #include <machine/db_machdep.h> -#endif - -#if defined(INTRDEBUG) || defined(TRAPDEBUG) +#ifdef TRAPDEBUG #include <ddb/db_output.h> #endif - +#endif const char *trap_type[] = { "invalid", @@ -99,8 +89,6 @@ int trap_types = sizeof(trap_type)/sizeof(trap_type[0]); u_int32_t sir; int want_resched, astpending; -void pmap_hptdump(void); -void cpu_intr(struct trapframe *frame); void syscall(struct trapframe *frame, int *args); static __inline void @@ -361,14 +349,10 @@ trap(type, frame) trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv); } else { if (p && p->p_addr->u_pcb.pcb_onfault) { -#ifdef PMAPDEBUG - printf("trap: copyin/out %d\n",ret); -#endif pcbp = &p->p_addr->u_pcb; frame->tf_iioq_tail = 4 + (frame->tf_iioq_head = pcbp->pcb_onfault); - pcbp->pcb_onfault = 0; break; } #if 0 @@ -542,81 +526,3 @@ syscall(frame, args) ktrsysret(p, code, error, rval[0]); #endif } - -/* all the interrupts, minus cpu clock, which is the last */ -struct cpu_intr_vector { - struct evcnt evcnt; - int pri; - int (*handler)(void *); - void *arg; -} cpu_intr_vectors[CPU_NINTS]; - -void * -cpu_intr_establish(pri, irq, handler, arg, dv) - int pri, irq; - int (*handler)(void *); - void *arg; - struct device *dv; -{ - register struct cpu_intr_vector *iv; - - if (0 <= irq && irq < CPU_NINTS && cpu_intr_vectors[irq].handler) - return NULL; - - iv = &cpu_intr_vectors[irq]; - iv->pri = pri; - iv->handler = handler; - iv->arg = arg; - evcnt_attach(dv, dv->dv_xname, &iv->evcnt); - - return iv; -} - -void -cpu_intr(frame) - struct trapframe *frame; -{ - u_int32_t eirr = 0, r; - register struct cpu_intr_vector *iv; - register int bit; - - do { - mfctl(CR_EIRR, r); - eirr |= r; -#ifdef INTRDEBUG - if (eirr & 0x7fffffff) - db_printf ("cpu_intr: 0x%08x & 0x%08x\n", - eirr, frame->tf_eiem); -#endif - eirr &= frame->tf_eiem; - bit = ffs(eirr) - 1; - if (bit >= 0) { - mtctl(1 << bit, CR_EIRR); - eirr &= ~(1 << bit); - /* ((struct iomod *)cpu_gethpa(0))->io_eir = 0; */ -#ifdef INTRDEBUG - if (bit != 31) - db_printf ("cpu_intr: 0x%08x\n", (1 << bit)); -#endif - iv = &cpu_intr_vectors[bit]; - if (iv->handler) { - register int s, r; - - iv->evcnt.ev_count++; - s = splraise(iv->pri); - /* no arg means pass the frame */ - r = (iv->handler)(iv->arg? iv->arg:frame); - splx(s); -#ifdef INTRDEBUG - if (!r) - db_printf ("%s: can't handle interrupt\n", - iv->evcnt.ev_name); -#endif - } -#ifdef INTRDEBUG - else - db_printf ("cpu_intr: stray interrupt %d\n", bit); -#endif - } - } while (eirr); -} diff --git a/sys/arch/hppa/include/autoconf.h b/sys/arch/hppa/include/autoconf.h index 17d4c304f02..dd6f804fd6e 100644 --- a/sys/arch/hppa/include/autoconf.h +++ b/sys/arch/hppa/include/autoconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.h,v 1.14 2002/03/14 03:15:53 millert Exp $ */ +/* $OpenBSD: autoconf.h,v 1.15 2002/03/16 01:13:42 mickey Exp $ */ /* * Copyright (c) 1998 Michael Shalayeff @@ -71,6 +71,7 @@ int mbprint(void *, const char *); int mbsubmatch(struct device *, void *, void *); void *cpu_intr_establish(int pri, int, int (*handler)(void *), void *arg, struct device *name); +void cpu_intr(struct trapframe *frame); int clock_intr(void *); void dumpconf(void); |