]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/interrupt.c
xnu-792.18.15.tar.gz
[apple/xnu.git] / osfmk / ppc / interrupt.c
CommitLineData
1c79356b 1/*
3a60a9f5 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * @APPLE_FREE_COPYRIGHT@
33 */
34#include <kern/misc_protos.h>
35#include <kern/assert.h>
36#include <kern/thread.h>
37#include <kern/counters.h>
89b3af67
A
38#include <kern/etimer.h>
39#include <kern/pms.h>
1c79356b 40#include <ppc/misc_protos.h>
55e303ae 41#include <ppc/trap.h>
1c79356b
A
42#include <ppc/proc_reg.h>
43#include <ppc/exception.h>
44#include <ppc/savearea.h>
45#include <pexpert/pexpert.h>
1c79356b
A
46#include <sys/kdebug.h>
47
91447636
A
48perfCallback perfIntHook = 0; /* Pointer to CHUD trap hook routine */
49
50void unresolved_kernel_trap(int trapno,
51 struct savearea *ssp,
52 unsigned int dsisr,
53 addr64_t dar,
54 const char *message);
55e303ae 55
9bccf70c 56struct savearea * interrupt(
1c79356b 57 int type,
9bccf70c 58 struct savearea *ssp,
1c79356b
A
59 unsigned int dsisr,
60 unsigned int dar)
61{
483a1d10 62 int current_cpu;
91447636 63 struct per_proc_info *proc_info;
0b4e3aa0 64 uint64_t now;
91447636 65 thread_t thread;
1c79356b
A
66
67 disable_preemption();
55e303ae
A
68
69 if(perfIntHook) { /* Is there a hook? */
70 if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */
71 }
1c79356b 72
9bccf70c
A
73#if 0
74 {
75 extern void fctx_text(void);
76 fctx_test();
77 }
78#endif
91447636
A
79
80
1c79356b 81 current_cpu = cpu_number();
91447636 82 proc_info = getPerProc();
1c79356b
A
83
84 switch (type) {
85
1c79356b
A
86 case T_DECREMENTER:
87 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
55e303ae 88 isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b
A
89
90#if 0
91 if (pcsample_enable) {
91447636
A
92 if (find_user_regs(current_thread()))
93 add_pcsamples (user_pc(current_thread()));
1c79356b
A
94 }
95#endif
96
3a60a9f5
A
97 now = mach_absolute_time(); /* Find out what time it is */
98
99 if(now >= proc_info->pms.pmsPop) { /* Is it time for power management state change? */
100 pmsStep(1); /* Yes, advance step */
101 now = mach_absolute_time(); /* Get the time again since we ran a bit */
102 }
103
91447636
A
104 thread = current_thread(); /* Find ourselves */
105 if(thread->machine.qactTimer != 0) { /* Is the timer set? */
91447636
A
106 if (thread->machine.qactTimer <= now) { /* It is set, has it popped? */
107 thread->machine.qactTimer = 0; /* Clear single shot timer */
108 if((unsigned int)thread->machine.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */
109 vmm_timer_pop(thread); /* Yes, check out them out... */
1c79356b
A
110 }
111 }
112 }
113
89b3af67 114 etimer_intr(USER_MODE(ssp->save_srr1), ssp->save_srr0); /* Handle event timer */
1c79356b
A
115 break;
116
117 case T_INTERRUPT:
118 /* Call the platform interrupt routine */
119 counter_always(c_incoming_interrupts++);
120
121 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
55e303ae 122 current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b 123
91447636
A
124 proc_info->interrupt_handler(
125 proc_info->interrupt_target,
126 proc_info->interrupt_refCon,
127 proc_info->interrupt_nub,
128 proc_info->interrupt_source);
1c79356b
A
129
130 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
131 0, 0, 0, 0, 0);
132
133 break;
134
135 case T_SIGP:
136 /* Did the other processor signal us? */
137 cpu_signal_handler();
138 break;
139
140 case T_SHUTDOWN:
141 cpu_doshutdown();
142 panic("returning from cpu_doshutdown()\n");
143 break;
144
145
146 default:
3a60a9f5
A
147 if (!Call_Debugger(type, ssp))
148 unresolved_kernel_trap(type, ssp, dsisr, dar, NULL);
1c79356b
A
149 break;
150 }
151
152 enable_preemption();
153 return ssp;
154}