1 /*-
2 * Copyright 2002 by Peter Grehan. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: releng/6.2/sys/powerpc/powerpc/interrupt.c 139825 2005-01-07 02:29:27Z imp $
28 */
29
30 /*
31 * Interrupts are dispatched to here from locore asm
32 */
33
34 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/bus.h>
39 #include <sys/interrupt.h>
40 #include <sys/kernel.h>
41 #include <sys/kthread.h>
42 #include <sys/ktr.h>
43 #include <sys/lock.h>
44 #include <sys/malloc.h>
45 #include <sys/mutex.h>
46 #include <sys/proc.h>
47 #include <sys/smp.h>
48 #include <sys/unistd.h>
49 #include <sys/vmmeter.h>
50
51 #include <machine/cpu.h>
52 #include <machine/db_machdep.h>
53 #include <machine/fpu.h>
54 #include <machine/frame.h>
55 #include <machine/pcb.h>
56 #include <machine/psl.h>
57 #include <machine/trap.h>
58 #include <machine/spr.h>
59 #include <machine/sr.h>
60 #include <machine/interruptvar.h>
61
62 void powerpc_interrupt(struct trapframe *);
63
64 /*
65 * External interrupt install routines
66 */
67 static void (*powerpc_extintr_handler)(void);
68
69 void
70 ext_intr_install(void (*new_extint)(void))
71 {
72 powerpc_extintr_handler = new_extint;
73 }
74
75 extern void decr_intr(struct clockframe *);
76 extern void trap(struct trapframe *);
77
78 /*
79 * A very short dispatch, to try and maximise assembler code use
80 * between all exception types. Maybe 'true' interrupts should go
81 * here, and the trap code can come in separately
82 */
83 void
84 powerpc_interrupt(struct trapframe *framep)
85 {
86 struct thread *td;
87 struct clockframe ckframe;
88
89 td = curthread;
90
91 switch (framep->exc) {
92 case EXC_EXI:
93 atomic_add_int(&td->td_intr_nesting_level, 1);
94 (*powerpc_extintr_handler)();
95 atomic_subtract_int(&td->td_intr_nesting_level, 1);
96 break;
97
98 case EXC_DECR:
99 atomic_add_int(&td->td_intr_nesting_level, 1);
100 ckframe.srr0 = framep->srr0;
101 ckframe.srr1 = framep->srr1;
102 decr_intr(&ckframe);
103 atomic_subtract_int(&td->td_intr_nesting_level, 1);
104 break;
105
106 default:
107 /*
108 * Re-enable interrupts and call the generic trap code
109 */
110 #if 0
111 printf("powerpc_interrupt: got trap\n");
112 mtmsr(mfmsr() | PSL_EE);
113 isync();
114 #endif
115 trap(framep);
116 }
117 }
Cache object: a6c9b05c6a8685ec70a2dfaf7206dc2c
|