]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/interrupt.c
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * @APPLE_FREE_COPYRIGHT@
36 #include <kern/misc_protos.h>
37 #include <kern/assert.h>
38 #include <kern/thread.h>
39 #include <kern/counters.h>
40 #include <kern/etimer.h>
42 #include <ppc/misc_protos.h>
44 #include <ppc/proc_reg.h>
45 #include <ppc/exception.h>
46 #include <ppc/savearea.h>
47 #include <pexpert/pexpert.h>
48 #include <sys/kdebug.h>
50 perfCallback perfIntHook
= 0; /* Pointer to CHUD trap hook routine */
52 void unresolved_kernel_trap(int trapno
,
58 struct savearea
* interrupt(
65 struct per_proc_info
*proc_info
;
71 if(perfIntHook
) { /* Is there a hook? */
72 if(perfIntHook(type
, ssp
, dsisr
, dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
77 extern void fctx_text(void);
83 current_cpu
= cpu_number();
84 proc_info
= getPerProc();
89 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI
, 0) | DBG_FUNC_NONE
,
90 isync_mfdec(), (unsigned int)ssp
->save_srr0
, 0, 0, 0);
93 if (pcsample_enable
) {
94 if (find_user_regs(current_thread()))
95 add_pcsamples (user_pc(current_thread()));
99 now
= mach_absolute_time(); /* Find out what time it is */
101 if(now
>= proc_info
->pms
.pmsPop
) { /* Is it time for power management state change? */
102 pmsStep(1); /* Yes, advance step */
103 now
= mach_absolute_time(); /* Get the time again since we ran a bit */
106 thread
= current_thread(); /* Find ourselves */
107 if(thread
->machine
.qactTimer
!= 0) { /* Is the timer set? */
108 if (thread
->machine
.qactTimer
<= now
) { /* It is set, has it popped? */
109 thread
->machine
.qactTimer
= 0; /* Clear single shot timer */
110 if((unsigned int)thread
->machine
.vmmControl
& 0xFFFFFFFE) { /* Are there any virtual machines? */
111 vmm_timer_pop(thread
); /* Yes, check out them out... */
116 etimer_intr(USER_MODE(ssp
->save_srr1
), ssp
->save_srr0
); /* Handle event timer */
120 /* Call the platform interrupt routine */
121 counter_always(c_incoming_interrupts
++);
123 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_START
,
124 current_cpu
, (unsigned int)ssp
->save_srr0
, 0, 0, 0);
126 proc_info
->interrupt_handler(
127 proc_info
->interrupt_target
,
128 proc_info
->interrupt_refCon
,
129 proc_info
->interrupt_nub
,
130 proc_info
->interrupt_source
);
132 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_END
,
138 /* Did the other processor signal us? */
139 cpu_signal_handler();
144 panic("returning from cpu_doshutdown()\n");
149 if (!Call_Debugger(type
, ssp
))
150 unresolved_kernel_trap(type
, ssp
, dsisr
, dar
, NULL
);