]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | /* | |
32 | * @APPLE_FREE_COPYRIGHT@ | |
33 | */ | |
34 | ||
35 | #include <kern/misc_protos.h> | |
36 | #include <kern/assert.h> | |
37 | #include <kern/thread.h> | |
38 | #include <kern/counters.h> | |
39 | #include <kern/etimer.h> | |
40 | #include <kern/pms.h> | |
41 | #include <ppc/misc_protos.h> | |
42 | #include <ppc/trap.h> | |
43 | #include <ppc/proc_reg.h> | |
44 | #include <ppc/exception.h> | |
45 | #include <ppc/savearea.h> | |
46 | #include <ppc/vmachmon.h> | |
47 | #include <ppc/machine_cpu.h> | |
48 | #include <pexpert/pexpert.h> | |
49 | #include <sys/kdebug.h> | |
50 | ||
51 | perfCallback perfIntHook; /* Pointer to CHUD trap hook routine */ | |
52 | ||
53 | #if CONFIG_DTRACE | |
54 | #if (DEVELOPMENT || DEBUG ) | |
55 | #include <mach/sdt.h> | |
56 | #endif | |
57 | ||
58 | extern vm_offset_t dtrace_get_cpu_int_stack_top(void); | |
59 | ||
60 | vm_offset_t dtrace_get_cpu_int_stack_top(void) | |
61 | { | |
62 | return getPerProc()->intstack_top_ss; | |
63 | } | |
64 | ||
65 | /* See <rdar://problem/4613924> */ | |
66 | perfCallback tempDTraceIntHook; /* Pointer to DTrace fbt int handler */ | |
67 | #endif | |
68 | ||
69 | void unresolved_kernel_trap(int trapno, | |
70 | struct savearea *ssp, | |
71 | unsigned int dsisr, | |
72 | addr64_t dar, | |
73 | const char *message); | |
74 | ||
75 | unsigned int isync_mfdec(void); | |
76 | ||
77 | struct savearea * interrupt( | |
78 | int type, | |
79 | struct savearea *ssp, | |
80 | unsigned int dsisr, | |
81 | unsigned int dar) | |
82 | { | |
83 | int current_cpu; | |
84 | struct per_proc_info *proc_info; | |
85 | uint64_t now; | |
86 | thread_t thread; | |
87 | ||
88 | disable_preemption(); | |
89 | ||
90 | if(perfIntHook) { /* Is there a hook? */ | |
91 | if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */ | |
92 | } | |
93 | ||
94 | #if CONFIG_DTRACE | |
95 | if(tempDTraceIntHook) { /* Is there a hook? */ | |
96 | if(tempDTraceIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */ | |
97 | } | |
98 | #endif | |
99 | ||
100 | #if 0 | |
101 | { | |
102 | extern void fctx_text(void); | |
103 | fctx_test(); | |
104 | } | |
105 | #endif | |
106 | ||
107 | ||
108 | current_cpu = cpu_number(); | |
109 | proc_info = getPerProc(); | |
110 | ||
111 | switch (type) { | |
112 | ||
113 | case T_DECREMENTER: | |
114 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE, | |
115 | isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0); | |
116 | ||
117 | now = mach_absolute_time(); /* Find out what time it is */ | |
118 | ||
119 | if(now >= proc_info->pms.pmsPop) { /* Is it time for power management state change? */ | |
120 | pmsStep(1); /* Yes, advance step */ | |
121 | now = mach_absolute_time(); /* Get the time again since we ran a bit */ | |
122 | } | |
123 | ||
124 | thread = current_thread(); /* Find ourselves */ | |
125 | if(thread->machine.qactTimer != 0) { /* Is the timer set? */ | |
126 | if (thread->machine.qactTimer <= now) { /* It is set, has it popped? */ | |
127 | thread->machine.qactTimer = 0; /* Clear single shot timer */ | |
128 | if((unsigned int)thread->machine.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */ | |
129 | vmm_timer_pop(thread); /* Yes, check out them out... */ | |
130 | } | |
131 | } | |
132 | } | |
133 | ||
134 | etimer_intr(USER_MODE(ssp->save_srr1), ssp->save_srr0); /* Handle event timer */ | |
135 | break; | |
136 | ||
137 | case T_INTERRUPT: | |
138 | /* Call the platform interrupt routine */ | |
139 | counter(c_incoming_interrupts++); | |
140 | ||
141 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START, | |
142 | current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0); | |
143 | ||
144 | #if CONFIG_DTRACE && (DEVELOPMENT || DEBUG ) | |
145 | DTRACE_INT5(interrupt__start, void *, proc_info->interrupt_nub, int, proc_info->interrupt_source, | |
146 | void *, proc_info->interrupt_target, IOInterruptHandler, proc_info->interrupt_handler, | |
147 | void *, proc_info->interrupt_refCon); | |
148 | #endif | |
149 | ||
150 | proc_info->interrupt_handler( | |
151 | proc_info->interrupt_target, | |
152 | proc_info->interrupt_refCon, | |
153 | proc_info->interrupt_nub, | |
154 | proc_info->interrupt_source); | |
155 | ||
156 | #if CONFIG_DTRACE && (DEVELOPMENT || DEBUG ) | |
157 | DTRACE_INT5(interrupt__complete, void *, proc_info->interrupt_nub, int, proc_info->interrupt_source, | |
158 | void *, proc_info->interrupt_target, IOInterruptHandler, proc_info->interrupt_handler, | |
159 | void *, proc_info->interrupt_refCon); | |
160 | #endif | |
161 | ||
162 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END, | |
163 | 0, 0, 0, 0, 0); | |
164 | ||
165 | break; | |
166 | ||
167 | case T_SIGP: | |
168 | /* Did the other processor signal us? */ | |
169 | cpu_signal_handler(); | |
170 | break; | |
171 | ||
172 | case T_SHUTDOWN: | |
173 | cpu_doshutdown(); | |
174 | panic("returning from cpu_doshutdown()\n"); | |
175 | break; | |
176 | ||
177 | ||
178 | default: | |
179 | if (!Call_Debugger(type, ssp)) | |
180 | unresolved_kernel_trap(type, ssp, dsisr, dar, NULL); | |
181 | break; | |
182 | } | |
183 | ||
184 | enable_preemption(); | |
185 | return ssp; | |
186 | } |