]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/interrupt.c
xnu-124.13.tar.gz
[apple/xnu.git] / osfmk / ppc / interrupt.c
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
42 struct 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;
50 AbsoluteTime now;
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 */
113 if(act->mact.qactTimer.hi | act->mact.qactTimer.lo) { /* Is the timer set? */
114 clock_get_uptime(&now); /* Find out what time it is */
115 if (CMP_ABSOLUTETIME(&act->mact.qactTimer, &now) <= 0) { /* It is set, has it popped? */
116 act->mact.qactTimer.hi = 0; /* Clear single shot timer */
117 act->mact.qactTimer.lo = 0; /* and the other half */
118 if((unsigned int)act->mact.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */
119 vmm_timer_pop(act); /* Yes, check out them out... */
120 }
121 }
122 }
123
124 rtclock_intr(0, ssp, 0);
125 break;
126
127 case T_INTERRUPT:
128 /* Call the platform interrupt routine */
129 counter_always(c_incoming_interrupts++);
130
131 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
132 current_cpu, ((savearea *)ssp)->save_srr0, 0, 0, 0);
133
134 per_proc_info[current_cpu].interrupt_handler(
135 per_proc_info[current_cpu].interrupt_target,
136 per_proc_info[current_cpu].interrupt_refCon,
137 per_proc_info[current_cpu].interrupt_nub,
138 per_proc_info[current_cpu].interrupt_source);
139
140 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
141 0, 0, 0, 0, 0);
142
143 break;
144
145 case T_SIGP:
146 /* Did the other processor signal us? */
147 cpu_signal_handler();
148 break;
149
150 case T_SHUTDOWN:
151 cpu_doshutdown();
152 panic("returning from cpu_doshutdown()\n");
153 break;
154
155
156 default:
157 #if MACH_KDP || MACH_KDB
158 (void)Call_Debugger(type, ssp);
159 #else
160 panic("Invalid interrupt type %x\n", type);
161 #endif
162 break;
163 }
164
165 enable_preemption();
166 return ssp;
167 }