]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/interrupt.c
xnu-517.3.15.tar.gz
[apple/xnu.git] / osfmk / ppc / interrupt.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28/*
29 * @APPLE_FREE_COPYRIGHT@
30 */
31#include <kern/misc_protos.h>
32#include <kern/assert.h>
33#include <kern/thread.h>
34#include <kern/counters.h>
35#include <ppc/misc_protos.h>
55e303ae 36#include <ppc/trap.h>
1c79356b
A
37#include <ppc/proc_reg.h>
38#include <ppc/exception.h>
39#include <ppc/savearea.h>
40#include <pexpert/pexpert.h>
1c79356b
A
41#include <sys/kdebug.h>
42
55e303ae
A
43perfTrap perfIntHook = 0; /* Pointer to performance trap hook routine */
44
9bccf70c 45struct savearea * interrupt(
1c79356b 46 int type,
9bccf70c 47 struct savearea *ssp,
1c79356b
A
48 unsigned int dsisr,
49 unsigned int dar)
50{
51 int current_cpu, tmpr, targtemp;
52 unsigned int throttle;
0b4e3aa0 53 uint64_t now;
1c79356b
A
54 thread_act_t act;
55
56 disable_preemption();
55e303ae
A
57
58 if(perfIntHook) { /* Is there a hook? */
59 if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */
60 }
1c79356b 61
9bccf70c
A
62#if 0
63 {
64 extern void fctx_text(void);
65 fctx_test();
66 }
67#endif
68
69
1c79356b
A
70 current_cpu = cpu_number();
71
72 switch (type) {
73
74 case T_THERMAL: /* Fix the air conditioning, I'm dripping with sweat, or freezing, whatever... */
75
76/*
77 * Note that this code is just a hackification until we have a real thermal plan.
78 */
79
80 tmpr = ml_read_temp(); /* Find out just how hot it is */
81 targtemp = (dar >> 23) & 0x7F; /* Get the temprature we were looking for */
82 if(dar & 4) { /* Did the temprature drop down? */
83#if 1
84 kprintf("THERMAL below (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar);
85#endif
86#if 0
87 throttle = ml_throttle(0); /* Set throttle off */
88#if 1
89 kprintf("THERMAL (cpu %d) throttle set off; last = %d\n", current_cpu, throttle);
90#endif
91#endif
92 ml_thrm_set(0, per_proc_info[current_cpu].thrm.throttleTemp); /* Set no low temp and max allowable as max */
93
94#if 1
95 kprintf("THERMAL (cpu %d) temp set to: off min, %d max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp);
96#endif
97 }
98 else {
99#if 1
100 kprintf("THERMAL above (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar);
101#endif
102#if 0
103 throttle = ml_throttle(32); /* Set throttle on about 1/8th */
104#if 1
105 kprintf("THERMAL (cpu %d) throttle set to 32; last = %d\n", current_cpu, throttle);
106#endif
107#endif
108 ml_thrm_set(per_proc_info[current_cpu].thrm.throttleTemp - 4, 0); /* Set low temp to max - 4 and max off */
109#if 1
110 kprintf("THERMAL (cpu %d) temp set to: %d min, off max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp - 4);
111#endif
112
113 }
114 break;
115
116 case T_DECREMENTER:
117 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
55e303ae 118 isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b
A
119
120#if 0
121 if (pcsample_enable) {
122 if (find_user_regs(current_act()))
123 add_pcsamples (user_pc(current_act()));
124 }
125#endif
126
127 act = current_act(); /* Find ourselves */
0b4e3aa0 128 if(act->mact.qactTimer != 0) { /* Is the timer set? */
1c79356b 129 clock_get_uptime(&now); /* Find out what time it is */
0b4e3aa0
A
130 if (act->mact.qactTimer <= now) { /* It is set, has it popped? */
131 act->mact.qactTimer = 0; /* Clear single shot timer */
1c79356b
A
132 if((unsigned int)act->mact.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */
133 vmm_timer_pop(act); /* Yes, check out them out... */
134 }
135 }
136 }
137
138 rtclock_intr(0, ssp, 0);
139 break;
140
141 case T_INTERRUPT:
142 /* Call the platform interrupt routine */
143 counter_always(c_incoming_interrupts++);
144
145 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
55e303ae 146 current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0);
1c79356b
A
147
148 per_proc_info[current_cpu].interrupt_handler(
149 per_proc_info[current_cpu].interrupt_target,
150 per_proc_info[current_cpu].interrupt_refCon,
151 per_proc_info[current_cpu].interrupt_nub,
152 per_proc_info[current_cpu].interrupt_source);
153
154 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
155 0, 0, 0, 0, 0);
156
157 break;
158
159 case T_SIGP:
160 /* Did the other processor signal us? */
161 cpu_signal_handler();
162 break;
163
164 case T_SHUTDOWN:
165 cpu_doshutdown();
166 panic("returning from cpu_doshutdown()\n");
167 break;
168
169
170 default:
171 #if MACH_KDP || MACH_KDB
172 (void)Call_Debugger(type, ssp);
173 #else
174 panic("Invalid interrupt type %x\n", type);
175 #endif
176 break;
177 }
178
179 enable_preemption();
180 return ssp;
181}