]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/interrupt.c
xnu-517.9.4.tar.gz
[apple/xnu.git] / osfmk / ppc / interrupt.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * @APPLE_FREE_COPYRIGHT@
27 */
28 #include <kern/misc_protos.h>
29 #include <kern/assert.h>
30 #include <kern/thread.h>
31 #include <kern/counters.h>
32 #include <ppc/misc_protos.h>
33 #include <ppc/trap.h>
34 #include <ppc/proc_reg.h>
35 #include <ppc/exception.h>
36 #include <ppc/savearea.h>
37 #include <pexpert/pexpert.h>
38 #include <sys/kdebug.h>
39
40 perfTrap perfIntHook = 0; /* Pointer to performance trap hook routine */
41
42 struct savearea * interrupt(
43 int type,
44 struct savearea *ssp,
45 unsigned int dsisr,
46 unsigned int dar)
47 {
48 int current_cpu;
49 uint64_t now;
50 thread_act_t act;
51
52 disable_preemption();
53
54 if(perfIntHook) { /* Is there a hook? */
55 if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */
56 }
57
58 #if 0
59 {
60 extern void fctx_text(void);
61 fctx_test();
62 }
63 #endif
64
65
66 current_cpu = cpu_number();
67
68 switch (type) {
69
70 case T_DECREMENTER:
71 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
72 isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0);
73
74 #if 0
75 if (pcsample_enable) {
76 if (find_user_regs(current_act()))
77 add_pcsamples (user_pc(current_act()));
78 }
79 #endif
80
81 act = current_act(); /* Find ourselves */
82 if(act->mact.qactTimer != 0) { /* Is the timer set? */
83 clock_get_uptime(&now); /* Find out what time it is */
84 if (act->mact.qactTimer <= now) { /* It is set, has it popped? */
85 act->mact.qactTimer = 0; /* Clear single shot timer */
86 if((unsigned int)act->mact.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */
87 vmm_timer_pop(act); /* Yes, check out them out... */
88 }
89 }
90 }
91
92 rtclock_intr(0, ssp, 0);
93 break;
94
95 case T_INTERRUPT:
96 /* Call the platform interrupt routine */
97 counter_always(c_incoming_interrupts++);
98
99 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
100 current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0);
101
102 per_proc_info[current_cpu].interrupt_handler(
103 per_proc_info[current_cpu].interrupt_target,
104 per_proc_info[current_cpu].interrupt_refCon,
105 per_proc_info[current_cpu].interrupt_nub,
106 per_proc_info[current_cpu].interrupt_source);
107
108 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
109 0, 0, 0, 0, 0);
110
111 break;
112
113 case T_SIGP:
114 /* Did the other processor signal us? */
115 cpu_signal_handler();
116 break;
117
118 case T_SHUTDOWN:
119 cpu_doshutdown();
120 panic("returning from cpu_doshutdown()\n");
121 break;
122
123
124 default:
125 #if MACH_KDP || MACH_KDB
126 (void)Call_Debugger(type, ssp);
127 #else
128 panic("Invalid interrupt type %x\n", type);
129 #endif
130 break;
131 }
132
133 enable_preemption();
134 return ssp;
135 }