2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * @APPLE_FREE_COPYRIGHT@
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>
41 #include <ppc/misc_protos.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>
51 perfCallback perfIntHook
; /* Pointer to CHUD trap hook routine */
54 #if (DEVELOPMENT || DEBUG )
58 extern vm_offset_t
dtrace_get_cpu_int_stack_top(void);
60 vm_offset_t
dtrace_get_cpu_int_stack_top(void)
62 return getPerProc()->intstack_top_ss
;
65 /* See <rdar://problem/4613924> */
66 perfCallback tempDTraceIntHook
; /* Pointer to DTrace fbt int handler */
69 void unresolved_kernel_trap(int trapno
,
75 unsigned int isync_mfdec(void);
77 struct savearea
* interrupt(
84 struct per_proc_info
*proc_info
;
90 if(perfIntHook
) { /* Is there a hook? */
91 if(perfIntHook(type
, ssp
, dsisr
, dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
95 if(tempDTraceIntHook
) { /* Is there a hook? */
96 if(tempDTraceIntHook(type
, ssp
, dsisr
, dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
102 extern void fctx_text(void);
108 current_cpu
= cpu_number();
109 proc_info
= getPerProc();
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);
117 now
= mach_absolute_time(); /* Find out what time it is */
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 */
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... */
134 etimer_intr(USER_MODE(ssp
->save_srr1
), ssp
->save_srr0
); /* Handle event timer */
138 /* Call the platform interrupt routine */
139 counter(c_incoming_interrupts
++);
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);
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
);
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
);
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
);
162 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_END
,
168 /* Did the other processor signal us? */
169 cpu_signal_handler();
174 panic("returning from cpu_doshutdown()\n");
179 if (!Call_Debugger(type
, ssp
))
180 unresolved_kernel_trap(type
, ssp
, dsisr
, dar
, NULL
);