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/12.0/sys/powerpc/powerpc/interrupt.c 334827 2018-06-08 04:58:03Z mmacy $
28 */
29
30 /*
31 * Interrupts are dispatched to here from locore asm
32 */
33
34 #include "opt_hwpmc_hooks.h"
35
36 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/bus.h>
41 #include <sys/interrupt.h>
42 #include <sys/kernel.h>
43 #include <sys/kthread.h>
44 #include <sys/ktr.h>
45 #include <sys/lock.h>
46 #include <sys/malloc.h>
47 #include <sys/mutex.h>
48 #ifdef HWPMC_HOOKS
49 #include <sys/pmckern.h>
50 #endif
51 #include <sys/proc.h>
52 #include <sys/smp.h>
53 #include <sys/unistd.h>
54 #include <sys/vmmeter.h>
55
56 #include <machine/cpu.h>
57 #include <machine/clock.h>
58 #include <machine/db_machdep.h>
59 #include <machine/fpu.h>
60 #include <machine/frame.h>
61 #include <machine/intr_machdep.h>
62 #include <machine/md_var.h>
63 #include <machine/pcb.h>
64 #include <machine/psl.h>
65 #include <machine/trap.h>
66 #include <machine/spr.h>
67 #include <machine/sr.h>
68
69 #include "pic_if.h"
70
71 /*
72 * A very short dispatch, to try and maximise assembler code use
73 * between all exception types. Maybe 'true' interrupts should go
74 * here, and the trap code can come in separately
75 */
76 void
77 powerpc_interrupt(struct trapframe *framep)
78 {
79 struct thread *td;
80 struct trapframe *oldframe;
81 register_t ee;
82
83 td = curthread;
84
85 CTR2(KTR_INTR, "%s: EXC=%x", __func__, framep->exc);
86
87 switch (framep->exc) {
88 case EXC_EXI:
89 case EXC_HVI:
90 critical_enter();
91 PIC_DISPATCH(root_pic, framep);
92 critical_exit();
93 #ifdef BOOKE
94 framep->srr1 &= ~PSL_WE;
95 #endif
96 break;
97
98 case EXC_DECR:
99 critical_enter();
100 atomic_add_int(&td->td_intr_nesting_level, 1);
101 oldframe = td->td_intr_frame;
102 td->td_intr_frame = framep;
103 decr_intr(framep);
104 td->td_intr_frame = oldframe;
105 atomic_subtract_int(&td->td_intr_nesting_level, 1);
106 critical_exit();
107 #ifdef BOOKE
108 framep->srr1 &= ~PSL_WE;
109 #endif
110 break;
111 #ifdef HWPMC_HOOKS
112 case EXC_PERF:
113 critical_enter();
114 KASSERT(pmc_intr != NULL, ("Performance exception, but no handler!"));
115 (*pmc_intr)(framep);
116 if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
117 pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, framep);
118 critical_exit();
119 break;
120 #endif
121
122 default:
123 /* Re-enable interrupts if applicable. */
124 ee = framep->srr1 & PSL_EE;
125 if (ee != 0)
126 mtmsr(mfmsr() | ee);
127 trap(framep);
128 }
129 }
Cache object: b9bc43f0f1f99387c7a24799785a7f7b
|