]>
Commit | Line | Data |
---|---|---|
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 | #include <mach_kdb.h> | |
30 | #include <mach_kgdb.h> | |
31 | #include <mach_debug.h> | |
32 | #include <assym.s> | |
33 | #include <ppc/asm.h> | |
34 | #include <ppc/proc_reg.h> | |
35 | #include <mach/ppc/vm_param.h> | |
36 | ||
37 | /* | |
38 | * vm_offset_t getrpc(void) - Return address of the function | |
39 | * that called the current function | |
40 | */ | |
41 | ||
42 | /* By using this function, we force the caller to save its LR in a known | |
43 | * location, which we can pick up and return. See PowerPC ELF specs. | |
44 | */ | |
45 | ENTRY(getrpc, TAG_NO_FRAME_USED) | |
46 | lwz ARG0, FM_BACKPTR(r1) /* Load our backchain ptr */ | |
47 | lwz ARG0, FM_LR_SAVE(ARG0) /* Load previously saved LR */ | |
48 | blr /* And return */ | |
49 | ||
50 | ||
51 | /* Mask and unmask interrupts at the processor level */ | |
52 | ENTRY(interrupt_disable, TAG_NO_FRAME_USED) | |
55e303ae A |
53 | lis r8,hi16(MASK(MSR_VEC)) ; Get the vector flag |
54 | mfmsr r0 ; Save the MSR | |
55 | ori r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Add the FP flag | |
56 | andc r0,r0,r8 ; Clear VEC, FP, DR, and EE | |
57 | mtmsr r0 | |
58 | isync | |
59 | blr | |
1c79356b A |
60 | |
61 | ENTRY(interrupt_enable, TAG_NO_FRAME_USED) | |
62 | ||
63 | mfmsr r0 | |
64 | ori r0, r0, MASK(MSR_EE) | |
65 | mtmsr r0 | |
66 | blr | |
67 | ||
68 | #if MACH_KDB | |
69 | /* | |
70 | * Kernel debugger versions of the spl*() functions. This allows breakpoints | |
71 | * in the spl*() functions. | |
72 | */ | |
73 | ||
74 | /* Mask and unmask interrupts at the processor level */ | |
75 | ENTRY(db_interrupt_disable, TAG_NO_FRAME_USED) | |
55e303ae A |
76 | lis r8,hi16(MASK(MSR_VEC)) ; Get the vector flag |
77 | mfmsr r0 ; Save the MSR | |
78 | ori r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Add the FP flag | |
79 | andc r0,r0,r8 ; Clear VEC, FP, DR, and EE | |
80 | mtmsr r0 | |
81 | isync | |
82 | blr | |
1c79356b A |
83 | |
84 | ENTRY(db_interrupt_enable, TAG_NO_FRAME_USED) | |
85 | mfmsr r0 | |
86 | ori r0, r0, MASK(MSR_EE) | |
87 | mtmsr r0 | |
88 | blr | |
89 | #endif /* MACH_KDB */ | |
90 | ||
91 | /* | |
92 | * General entry for all debuggers. This gets us onto the debug stack and | |
93 | * then back off at exit. We need to pass back R3 to caller. | |
94 | */ | |
95 | ||
96 | ENTRY(Call_Debugger, TAG_NO_FRAME_USED) | |
97 | ||
55e303ae A |
98 | |
99 | lis r8,hi16(MASK(MSR_VEC)) ; Get the vector flag | |
1c79356b | 100 | mfmsr r7 ; Get the current MSR |
55e303ae | 101 | ori r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Add the FP flag |
1c79356b | 102 | mflr r0 ; Save the return |
55e303ae | 103 | andc r7,r7,r8 ; Clear VEC and FP |
1c79356b | 104 | mtmsr r7 ; Do it |
9bccf70c | 105 | isync |
1c79356b A |
106 | mfsprg r8,0 ; Get the per_proc block |
107 | stw r0,FM_LR_SAVE(r1) ; Save return on current stack | |
108 | ||
109 | lwz r9,PP_DEBSTACKPTR(r8) ; Get the debug stack | |
110 | cmpwi r9,0 ; Are we already on it? | |
111 | bne cdNewDeb ; No... | |
112 | ||
113 | mr r9,r1 ; We are already on the stack, so use the current value | |
114 | subi r9,r9,FM_REDZONE+FM_SIZE ; Carve some extra space here | |
115 | ||
116 | cdNewDeb: li r0,0 ; Clear this out | |
117 | stw r1,FM_ARG0(r9) ; Save the old stack pointer as if it were the first arg | |
118 | ||
119 | stw r0,PP_DEBSTACKPTR(r8) ; Mark debug stack as busy | |
120 | ||
121 | subi r1,r9,FM_SIZE ; Carve a new frame | |
122 | stw r0,FM_BACKPTR(r1) ; Chain back | |
123 | ||
124 | bl EXT(Call_DebuggerC) ; Call the "C" phase of this | |
125 | ||
55e303ae A |
126 | lis r8,hi16(MASK(MSR_VEC)) ; Get the vector flag |
127 | mfmsr r0 ; Get the current MSR | |
128 | ori r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Add the FP flag | |
1c79356b | 129 | addi r1,r1,FM_SIZE ; Pop off first stack frame |
55e303ae | 130 | andc r0,r0,r8 ; Turn off all the interesting stuff |
1c79356b A |
131 | mtmsr r0 |
132 | ||
133 | mfsprg r8,0 ; Get the per_proc block address | |
134 | ||
135 | lwz r9,PP_DEBSTACK_TOP_SS(r8) ; Get the top of the stack | |
136 | cmplw r1,r9 ; Have we hit the bottom of the debug stack? | |
137 | lwz r1,FM_ARG0(r1) ; Get previous stack frame | |
138 | lwz r0,FM_LR_SAVE(r1) ; Get return address | |
139 | mtlr r0 ; Set the return point | |
140 | bnelr ; Return if still on debug stack | |
141 | ||
142 | stw r9,PP_DEBSTACKPTR(r8) ; Mark debug stack as free | |
143 | blr | |
144 | ||
145 | ||
146 | /* The following routines are for C-support. They are usually | |
147 | * inlined into the C using the specifications in proc_reg.h, | |
148 | * but if optimisation is switched off, the inlining doesn't work | |
149 | */ | |
150 | ||
151 | ENTRY(get_got, TAG_NO_FRAME_USED) | |
152 | mr ARG0, r2 | |
153 | blr | |
154 | ||
155 | ENTRY(mflr, TAG_NO_FRAME_USED) | |
156 | mflr ARG0 | |
157 | blr | |
158 | ||
159 | ENTRY(mfpvr, TAG_NO_FRAME_USED) | |
160 | mfpvr ARG0 | |
161 | blr | |
162 | ||
163 | ENTRY(mtmsr, TAG_NO_FRAME_USED) | |
164 | mtmsr ARG0 | |
165 | isync | |
166 | blr | |
167 | ||
168 | ENTRY(mfmsr, TAG_NO_FRAME_USED) | |
169 | mfmsr ARG0 | |
170 | blr | |
171 | ||
172 | ENTRY(mtsrin, TAG_NO_FRAME_USED) | |
173 | isync | |
174 | mtsrin ARG0, ARG1 | |
175 | isync | |
176 | blr | |
177 | ||
178 | ENTRY(mfsrin, TAG_NO_FRAME_USED) | |
179 | mfsrin ARG0, ARG0 | |
180 | blr | |
181 | ||
182 | ENTRY(mtsdr1, TAG_NO_FRAME_USED) | |
183 | mtsdr1 ARG0 | |
184 | blr | |
185 | ||
186 | ENTRY(mtdar, TAG_NO_FRAME_USED) | |
187 | mtdar ARG0 | |
188 | blr | |
189 | ||
190 | ENTRY(mfdar, TAG_NO_FRAME_USED) | |
191 | mfdar ARG0 | |
192 | blr | |
193 | ||
194 | ENTRY(mtdec, TAG_NO_FRAME_USED) | |
195 | mtdec ARG0 | |
196 | blr | |
197 | ||
55e303ae A |
198 | ENTRY(cntlzw, TAG_NO_FRAME_USED) |
199 | cntlzw r3,r3 | |
200 | blr | |
201 | ||
1c79356b A |
202 | /* Decrementer frequency and realtime|timebase processor registers |
203 | * are different between ppc601 and ppc603/4, we define them all. | |
204 | */ | |
205 | ||
206 | ENTRY(isync_mfdec, TAG_NO_FRAME_USED) | |
207 | isync | |
208 | mfdec ARG0 | |
209 | blr | |
210 | ||
211 | ||
212 | ENTRY(mftb, TAG_NO_FRAME_USED) | |
213 | mftb ARG0 | |
214 | blr | |
215 | ||
216 | ENTRY(mftbu, TAG_NO_FRAME_USED) | |
217 | mftbu ARG0 | |
218 | blr | |
219 | ||
220 | ENTRY(mfrtcl, TAG_NO_FRAME_USED) | |
221 | mfspr ARG0, 5 | |
222 | blr | |
223 | ||
224 | ENTRY(mfrtcu, TAG_NO_FRAME_USED) | |
225 | mfspr ARG0, 4 | |
226 | blr | |
227 | ||
228 | ENTRY(tlbie, TAG_NO_FRAME_USED) | |
229 | tlbie ARG0 | |
230 | blr | |
231 | ||
232 | ||
233 | /* | |
234 | * Performance Monitor Register Support | |
235 | */ | |
236 | ||
237 | ENTRY(mfmmcr0, TAG_NO_FRAME_USED) | |
238 | mfspr r3,mmcr0 | |
239 | blr | |
240 | ||
241 | ENTRY(mtmmcr0, TAG_NO_FRAME_USED) | |
242 | mtspr mmcr0,r3 | |
243 | blr | |
244 | ||
245 | ENTRY(mfmmcr1, TAG_NO_FRAME_USED) | |
246 | mfspr r3,mmcr1 | |
247 | blr | |
248 | ||
249 | ENTRY(mtmmcr1, TAG_NO_FRAME_USED) | |
250 | mtspr mmcr1,r3 | |
251 | blr | |
252 | ||
253 | ENTRY(mfmmcr2, TAG_NO_FRAME_USED) | |
254 | mfspr r3,mmcr2 | |
255 | blr | |
256 | ||
257 | ENTRY(mtmmcr2, TAG_NO_FRAME_USED) | |
258 | mtspr mmcr2,r3 | |
259 | blr | |
260 | ||
261 | ENTRY(mfpmc1, TAG_NO_FRAME_USED) | |
262 | mfspr r3,pmc1 | |
263 | blr | |
264 | ||
265 | ENTRY(mtpmc1, TAG_NO_FRAME_USED) | |
266 | mtspr pmc1,r3 | |
267 | blr | |
268 | ||
269 | ENTRY(mfpmc2, TAG_NO_FRAME_USED) | |
270 | mfspr r3,pmc2 | |
271 | blr | |
272 | ||
273 | ENTRY(mtpmc2, TAG_NO_FRAME_USED) | |
274 | mtspr pmc2,r3 | |
275 | blr | |
276 | ||
277 | ENTRY(mfpmc3, TAG_NO_FRAME_USED) | |
278 | mfspr r3,pmc3 | |
279 | blr | |
280 | ||
281 | ENTRY(mtpmc3, TAG_NO_FRAME_USED) | |
282 | mtspr pmc3,r3 | |
283 | blr | |
284 | ||
285 | ENTRY(mfpmc4, TAG_NO_FRAME_USED) | |
286 | mfspr r3,pmc4 | |
287 | blr | |
288 | ||
289 | ENTRY(mtpmc4, TAG_NO_FRAME_USED) | |
290 | mtspr pmc4,r3 | |
291 | blr | |
292 | ||
293 | ENTRY(mfsia, TAG_NO_FRAME_USED) | |
294 | mfspr r3,sia | |
295 | blr | |
296 | ||
297 | ENTRY(mfsda, TAG_NO_FRAME_USED) | |
298 | mfspr r3,sda | |
299 | blr | |
300 | ||
55e303ae A |
301 | .globl EXT(hid0get64) |
302 | ||
303 | LEXT(hid0get64) | |
304 | ||
305 | mfspr r4,hid0 ; Get the HID0 | |
306 | srdi r3,r4,32 ; Move top down | |
307 | rlwinm r4,r4,0,0,31 ; Clean top | |
308 | blr |