]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/interrupt.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * @APPLE_FREE_COPYRIGHT@
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>
38 #include <ppc/POWERMAC/mp/MPPlugIn.h>
39 #endif /* NCPUS > 1 */
40 #include <sys/kdebug.h>
42 struct ppc_saved_state
* interrupt(
44 struct ppc_saved_state
*ssp
,
48 int current_cpu
, tmpr
, targtemp
;
49 unsigned int throttle
;
55 current_cpu
= cpu_number();
59 case T_THERMAL
: /* Fix the air conditioning, I'm dripping with sweat, or freezing, whatever... */
62 * Note that this code is just a hackification until we have a real thermal plan.
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? */
69 kprintf("THERMAL below (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu
, targtemp
, tmpr
, dar
);
72 throttle
= ml_throttle(0); /* Set throttle off */
74 kprintf("THERMAL (cpu %d) throttle set off; last = %d\n", current_cpu
, throttle
);
77 ml_thrm_set(0, per_proc_info
[current_cpu
].thrm
.throttleTemp
); /* Set no low temp and max allowable as max */
80 kprintf("THERMAL (cpu %d) temp set to: off min, %d max\n", current_cpu
, per_proc_info
[current_cpu
].thrm
.throttleTemp
);
85 kprintf("THERMAL above (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu
, targtemp
, tmpr
, dar
);
88 throttle
= ml_throttle(32); /* Set throttle on about 1/8th */
90 kprintf("THERMAL (cpu %d) throttle set to 32; last = %d\n", current_cpu
, throttle
);
93 ml_thrm_set(per_proc_info
[current_cpu
].thrm
.throttleTemp
- 4, 0); /* Set low temp to max - 4 and max off */
95 kprintf("THERMAL (cpu %d) temp set to: %d min, off max\n", current_cpu
, per_proc_info
[current_cpu
].thrm
.throttleTemp
- 4);
102 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI
, 0) | DBG_FUNC_NONE
,
103 isync_mfdec(), ((savearea
*)ssp
)->save_srr0
, 0, 0, 0);
106 if (pcsample_enable
) {
107 if (find_user_regs(current_act()))
108 add_pcsamples (user_pc(current_act()));
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... */
124 rtclock_intr(0, ssp
, 0);
128 /* Call the platform interrupt routine */
129 counter_always(c_incoming_interrupts
++);
131 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_START
,
132 current_cpu
, ((savearea
*)ssp
)->save_srr0
, 0, 0, 0);
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
);
140 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR
, 0) | DBG_FUNC_END
,
146 /* Did the other processor signal us? */
147 cpu_signal_handler();
152 panic("returning from cpu_doshutdown()\n");
157 #if MACH_KDP || MACH_KDB
158 (void)Call_Debugger(type
, ssp
);
160 panic("Invalid interrupt type %x\n", type
);