]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/interrupt.c
xnu-792.13.8.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 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
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
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30/*
31 * @OSF_COPYRIGHT@
32 */
33/*
34 * @APPLE_FREE_COPYRIGHT@
35 */
36#include <kern/misc_protos.h>
37#include <kern/assert.h>
38#include <kern/thread.h>
39#include <kern/counters.h>
5d5c5d0d
A
40#include <kern/etimer.h>
41#include <kern/pms.h>
1c79356b 42#include <ppc/misc_protos.h>
55e303ae 43#include <ppc/trap.h>
1c79356b
A
44#include <ppc/proc_reg.h>
45#include <ppc/exception.h>
46#include <ppc/savearea.h>
47#include <pexpert/pexpert.h>
1c79356b
A
48#include <sys/kdebug.h>
49
91447636
A
50perfCallback perfIntHook = 0; /* Pointer to CHUD trap hook routine */
51
52void unresolved_kernel_trap(int trapno,
53 struct savearea *ssp,
54 unsigned int dsisr,
55 addr64_t dar,
56 const char *message);
55e303ae 57
9bccf70c 58struct savearea * interrupt(
1c79356b 59 int type,
9bccf70c 60 struct savearea *ssp,
1c79356b
A
61 unsigned int dsisr,
62 unsigned int dar)
63{
483a1d10 64 int current_cpu;
91447636 65 struct per_proc_info *proc_info;
0b4e3aa0 66 uint64_t now;
91447636 67 thread_t thread;
1c79356b
A
68
69 disable_preemption();
55e303ae
A
70
71 if(perfIntHook) { /* Is there a hook? */
72 if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */
73 }
1c79356b 74
9bccf70c
A
75#if 0
76 {
77 extern void fctx_text(void);
78 fctx_test();
79 }
80#endif
91447636
A
81
82
1c79356b 83 current_cpu = cpu_number();
91447636 84 proc_info = getPerProc();
1c79356b
A
85
86 switch (type) {
87
1c79356b
A
88 case T_DECREMENTER:
89 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
55e303ae 90 isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b
A
91
92#if 0
93 if (pcsample_enable) {
91447636
A
94 if (find_user_regs(current_thread()))
95 add_pcsamples (user_pc(current_thread()));
1c79356b
A
96 }
97#endif
98
3a60a9f5
A
99 now = mach_absolute_time(); /* Find out what time it is */
100
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 */
104 }
105
91447636
A
106 thread = current_thread(); /* Find ourselves */
107 if(thread->machine.qactTimer != 0) { /* Is the timer set? */
91447636
A
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... */
1c79356b
A
112 }
113 }
114 }
115
5d5c5d0d 116 etimer_intr(USER_MODE(ssp->save_srr1), ssp->save_srr0); /* Handle event timer */
1c79356b
A
117 break;
118
119 case T_INTERRUPT:
120 /* Call the platform interrupt routine */
121 counter_always(c_incoming_interrupts++);
122
123 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
55e303ae 124 current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b 125
91447636
A
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);
1c79356b
A
131
132 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
133 0, 0, 0, 0, 0);
134
135 break;
136
137 case T_SIGP:
138 /* Did the other processor signal us? */
139 cpu_signal_handler();
140 break;
141
142 case T_SHUTDOWN:
143 cpu_doshutdown();
144 panic("returning from cpu_doshutdown()\n");
145 break;
146
147
148 default:
3a60a9f5
A
149 if (!Call_Debugger(type, ssp))
150 unresolved_kernel_trap(type, ssp, dsisr, dar, NULL);
1c79356b
A
151 break;
152 }
153
154 enable_preemption();
155 return ssp;
156}