]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/interrupt.c
xnu-201.42.3.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 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25/*
26 * @APPLE_FREE_COPYRIGHT@
27 */
28#include <kern/misc_protos.h>
29#include <kern/assert.h>
30#include <kern/thread.h>
31#include <kern/counters.h>
32#include <ppc/misc_protos.h>
33#include <ppc/proc_reg.h>
34#include <ppc/exception.h>
35#include <ppc/savearea.h>
36#include <pexpert/pexpert.h>
37#if NCPUS > 1
38#include <ppc/POWERMAC/mp/MPPlugIn.h>
39#endif /* NCPUS > 1 */
40#include <sys/kdebug.h>
41
42struct ppc_saved_state * interrupt(
43 int type,
44 struct ppc_saved_state *ssp,
45 unsigned int dsisr,
46 unsigned int dar)
47{
48 int current_cpu, tmpr, targtemp;
49 unsigned int throttle;
0b4e3aa0 50 uint64_t now;
1c79356b
A
51 thread_act_t act;
52
53 disable_preemption();
54
55 current_cpu = cpu_number();
56
57 switch (type) {
58
59 case T_THERMAL: /* Fix the air conditioning, I'm dripping with sweat, or freezing, whatever... */
60
61/*
62 * Note that this code is just a hackification until we have a real thermal plan.
63 */
64
65 tmpr = ml_read_temp(); /* Find out just how hot it is */
66 targtemp = (dar >> 23) & 0x7F; /* Get the temprature we were looking for */
67 if(dar & 4) { /* Did the temprature drop down? */
68#if 1
69 kprintf("THERMAL below (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar);
70#endif
71#if 0
72 throttle = ml_throttle(0); /* Set throttle off */
73#if 1
74 kprintf("THERMAL (cpu %d) throttle set off; last = %d\n", current_cpu, throttle);
75#endif
76#endif
77 ml_thrm_set(0, per_proc_info[current_cpu].thrm.throttleTemp); /* Set no low temp and max allowable as max */
78
79#if 1
80 kprintf("THERMAL (cpu %d) temp set to: off min, %d max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp);
81#endif
82 }
83 else {
84#if 1
85 kprintf("THERMAL above (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar);
86#endif
87#if 0
88 throttle = ml_throttle(32); /* Set throttle on about 1/8th */
89#if 1
90 kprintf("THERMAL (cpu %d) throttle set to 32; last = %d\n", current_cpu, throttle);
91#endif
92#endif
93 ml_thrm_set(per_proc_info[current_cpu].thrm.throttleTemp - 4, 0); /* Set low temp to max - 4 and max off */
94#if 1
95 kprintf("THERMAL (cpu %d) temp set to: %d min, off max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp - 4);
96#endif
97
98 }
99 break;
100
101 case T_DECREMENTER:
102 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
103 isync_mfdec(), ((savearea *)ssp)->save_srr0, 0, 0, 0);
104
105#if 0
106 if (pcsample_enable) {
107 if (find_user_regs(current_act()))
108 add_pcsamples (user_pc(current_act()));
109 }
110#endif
111
112 act = current_act(); /* Find ourselves */
0b4e3aa0 113 if(act->mact.qactTimer != 0) { /* Is the timer set? */
1c79356b 114 clock_get_uptime(&now); /* Find out what time it is */
0b4e3aa0
A
115 if (act->mact.qactTimer <= now) { /* It is set, has it popped? */
116 act->mact.qactTimer = 0; /* Clear single shot timer */
1c79356b
A
117 if((unsigned int)act->mact.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */
118 vmm_timer_pop(act); /* Yes, check out them out... */
119 }
120 }
121 }
122
123 rtclock_intr(0, ssp, 0);
124 break;
125
126 case T_INTERRUPT:
127 /* Call the platform interrupt routine */
128 counter_always(c_incoming_interrupts++);
129
130 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
131 current_cpu, ((savearea *)ssp)->save_srr0, 0, 0, 0);
132
133 per_proc_info[current_cpu].interrupt_handler(
134 per_proc_info[current_cpu].interrupt_target,
135 per_proc_info[current_cpu].interrupt_refCon,
136 per_proc_info[current_cpu].interrupt_nub,
137 per_proc_info[current_cpu].interrupt_source);
138
139 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
140 0, 0, 0, 0, 0);
141
142 break;
143
144 case T_SIGP:
145 /* Did the other processor signal us? */
146 cpu_signal_handler();
147 break;
148
149 case T_SHUTDOWN:
150 cpu_doshutdown();
151 panic("returning from cpu_doshutdown()\n");
152 break;
153
154
155 default:
156 #if MACH_KDP || MACH_KDB
157 (void)Call_Debugger(type, ssp);
158 #else
159 panic("Invalid interrupt type %x\n", type);
160 #endif
161 break;
162 }
163
164 enable_preemption();
165 return ssp;
166}