]>
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_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * @APPLE_FREE_COPYRIGHT@
28 #include <kern/misc_protos.h>
29 #include <kern/assert.h>
30 #include <kern/thread.h>
31 #include <kern/counters.h>
32 #include <kern/etimer.h>
34 #include <ppc/misc_protos.h>
36 #include <ppc/proc_reg.h>
37 #include <ppc/exception.h>
38 #include <ppc/savearea.h>
39 #include <pexpert/pexpert.h>
40 #include <sys/kdebug.h>
42 perfCallback perfIntHook
= 0; /* Pointer to CHUD trap hook routine */
44 void unresolved_kernel_trap(int trapno
,
50 struct savearea
* interrupt(
57 struct per_proc_info
*proc_info
;
63 if(perfIntHook
) { /* Is there a hook? */
64 if(perfIntHook(type
, ssp
, dsisr
, dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
69 extern void fctx_text(void);
75 current_cpu
= cpu_number();
76 proc_info
= getPerProc();
81 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI
, 0) | DBG_FUNC_NONE
,
82 isync_mfdec(), (unsigned int)ssp
->save_srr0
, 0, 0, 0);
85 if (pcsample_enable
) {
86 if (find_user_regs(current_thread()))
87 add_pcsamples (user_pc(current_thread()));
91 now
= mach_absolute_time(); /* Find out what time it is */
93 if(now
>= proc_info
->pms
.pmsPop
) { /* Is it time for power management state change? */
94 pmsStep(1); /* Yes, advance step */
95 now
= mach_absolute_time(); /* Get the time again since we ran a bit */
98 thread
= current_thread(); /* Find ourselves */
99 if(thread
->machine
.qactTimer
!= 0) { /* Is the timer set? */
100 if (thread
->machine
.qactTimer
<= now
) { /* It is set, has it popped? */
101 thread
->machine
.qactTimer
= 0; /* Clear single shot timer */
102 if((unsigned int)thread
->machine
.vmmControl
& 0xFFFFFFFE) { /* Are there any virtual machines? */
103 vmm_timer_pop(thread
); /* Yes, check out them out... */
108 etimer_intr(USER_MODE(ssp
->save_srr1
), ssp
->save_srr0
); /* Handle event timer */
112 /* Call the platform interrupt routine */
113 counter_always(c_incoming_interrupts
++);
115 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_START
,
116 current_cpu
, (unsigned int)ssp
->save_srr0
, 0, 0, 0);
118 proc_info
->interrupt_handler(
119 proc_info
->interrupt_target
,
120 proc_info
->interrupt_refCon
,
121 proc_info
->interrupt_nub
,
122 proc_info
->interrupt_source
);
124 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_END
,
130 /* Did the other processor signal us? */
131 cpu_signal_handler();
136 panic("returning from cpu_doshutdown()\n");
141 if (!Call_Debugger(type
, ssp
))
142 unresolved_kernel_trap(type
, ssp
, dsisr
, dar
, NULL
);