]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
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. | |
1c79356b | 11 | * |
de355530 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
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. | |
1c79356b A |
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> | |
de355530 A |
37 | #if NCPUS > 1 |
38 | #include <ppc/POWERMAC/mp/MPPlugIn.h> | |
39 | #endif /* NCPUS > 1 */ | |
1c79356b A |
40 | #include <sys/kdebug.h> |
41 | ||
9bccf70c | 42 | struct savearea * interrupt( |
1c79356b | 43 | int type, |
9bccf70c | 44 | struct savearea *ssp, |
1c79356b A |
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 | ||
9bccf70c A |
55 | #if 0 |
56 | { | |
57 | extern void fctx_text(void); | |
58 | fctx_test(); | |
59 | } | |
60 | #endif | |
61 | ||
62 | ||
1c79356b A |
63 | current_cpu = cpu_number(); |
64 | ||
65 | switch (type) { | |
66 | ||
67 | case T_THERMAL: /* Fix the air conditioning, I'm dripping with sweat, or freezing, whatever... */ | |
68 | ||
69 | /* | |
70 | * Note that this code is just a hackification until we have a real thermal plan. | |
71 | */ | |
72 | ||
73 | tmpr = ml_read_temp(); /* Find out just how hot it is */ | |
74 | targtemp = (dar >> 23) & 0x7F; /* Get the temprature we were looking for */ | |
75 | if(dar & 4) { /* Did the temprature drop down? */ | |
76 | #if 1 | |
77 | kprintf("THERMAL below (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar); | |
78 | #endif | |
79 | #if 0 | |
80 | throttle = ml_throttle(0); /* Set throttle off */ | |
81 | #if 1 | |
82 | kprintf("THERMAL (cpu %d) throttle set off; last = %d\n", current_cpu, throttle); | |
83 | #endif | |
84 | #endif | |
85 | ml_thrm_set(0, per_proc_info[current_cpu].thrm.throttleTemp); /* Set no low temp and max allowable as max */ | |
86 | ||
87 | #if 1 | |
88 | kprintf("THERMAL (cpu %d) temp set to: off min, %d max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp); | |
89 | #endif | |
90 | } | |
91 | else { | |
92 | #if 1 | |
93 | kprintf("THERMAL above (cpu %d) target = %d; actual = %d; thrm = %08X\n", current_cpu, targtemp, tmpr, dar); | |
94 | #endif | |
95 | #if 0 | |
96 | throttle = ml_throttle(32); /* Set throttle on about 1/8th */ | |
97 | #if 1 | |
98 | kprintf("THERMAL (cpu %d) throttle set to 32; last = %d\n", current_cpu, throttle); | |
99 | #endif | |
100 | #endif | |
101 | ml_thrm_set(per_proc_info[current_cpu].thrm.throttleTemp - 4, 0); /* Set low temp to max - 4 and max off */ | |
102 | #if 1 | |
103 | kprintf("THERMAL (cpu %d) temp set to: %d min, off max\n", current_cpu, per_proc_info[current_cpu].thrm.throttleTemp - 4); | |
104 | #endif | |
105 | ||
106 | } | |
107 | break; | |
108 | ||
109 | case T_DECREMENTER: | |
110 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE, | |
de355530 | 111 | isync_mfdec(), ssp->save_srr0, 0, 0, 0); |
1c79356b A |
112 | |
113 | #if 0 | |
114 | if (pcsample_enable) { | |
115 | if (find_user_regs(current_act())) | |
116 | add_pcsamples (user_pc(current_act())); | |
117 | } | |
118 | #endif | |
119 | ||
120 | act = current_act(); /* Find ourselves */ | |
0b4e3aa0 | 121 | if(act->mact.qactTimer != 0) { /* Is the timer set? */ |
1c79356b | 122 | clock_get_uptime(&now); /* Find out what time it is */ |
0b4e3aa0 A |
123 | if (act->mact.qactTimer <= now) { /* It is set, has it popped? */ |
124 | act->mact.qactTimer = 0; /* Clear single shot timer */ | |
1c79356b A |
125 | if((unsigned int)act->mact.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */ |
126 | vmm_timer_pop(act); /* Yes, check out them out... */ | |
127 | } | |
128 | } | |
129 | } | |
130 | ||
131 | rtclock_intr(0, ssp, 0); | |
132 | break; | |
133 | ||
134 | case T_INTERRUPT: | |
135 | /* Call the platform interrupt routine */ | |
136 | counter_always(c_incoming_interrupts++); | |
137 | ||
138 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START, | |
de355530 | 139 | current_cpu, ssp->save_srr0, 0, 0, 0); |
1c79356b A |
140 | |
141 | per_proc_info[current_cpu].interrupt_handler( | |
142 | per_proc_info[current_cpu].interrupt_target, | |
143 | per_proc_info[current_cpu].interrupt_refCon, | |
144 | per_proc_info[current_cpu].interrupt_nub, | |
145 | per_proc_info[current_cpu].interrupt_source); | |
146 | ||
147 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END, | |
148 | 0, 0, 0, 0, 0); | |
149 | ||
150 | break; | |
151 | ||
152 | case T_SIGP: | |
153 | /* Did the other processor signal us? */ | |
154 | cpu_signal_handler(); | |
155 | break; | |
156 | ||
157 | case T_SHUTDOWN: | |
158 | cpu_doshutdown(); | |
159 | panic("returning from cpu_doshutdown()\n"); | |
160 | break; | |
161 | ||
162 | ||
163 | default: | |
164 | #if MACH_KDP || MACH_KDB | |
165 | (void)Call_Debugger(type, ssp); | |
166 | #else | |
167 | panic("Invalid interrupt type %x\n", type); | |
168 | #endif | |
169 | break; | |
170 | } | |
171 | ||
172 | enable_preemption(); | |
173 | return ssp; | |
174 | } |