]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kdp/ml/ppc/kdp_machdep.c
xnu-792.17.14.tar.gz
[apple/xnu.git] / osfmk / kdp / ml / ppc / kdp_machdep.c
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
1c79356b
A
28
29#include <mach/mach_types.h>
30#include <mach/exception_types.h>
31#include <ppc/exception.h>
32#include <ppc/proc_reg.h>
33#include <kdp/kdp_internal.h>
34#include <ppc/savearea.h>
35#include <kern/debug.h>
91447636 36#include <IOKit/IOPlatformExpert.h>
1c79356b
A
37
38#define KDP_TEST_HARNESS 0
39#if KDP_TEST_HARNESS
40#define dprintf(x) kprintf x
41#else
42#define dprintf(x)
43#endif
44
45void print_saved_state(void *);
46void kdp_call(void);
9bccf70c 47void kdp_trap( unsigned int, struct savearea *saved_state);
1c79356b
A
48int kdp_getc(void);
49boolean_t kdp_call_kdb(void);
50
51void
52kdp_exception(
53 unsigned char *pkt,
54 int *len,
55 unsigned short *remote_port,
56 unsigned int exception,
57 unsigned int code,
58 unsigned int subcode
59)
60{
61 struct {
62 kdp_exception_t pkt;
63 kdp_exc_info_t exc;
64 } aligned_pkt;
65 kdp_exception_t *rq = (kdp_exception_t *)&aligned_pkt;
66
67 bcopy((char *)pkt, (char *)rq, sizeof(*rq));
68 rq->hdr.request = KDP_EXCEPTION;
69 rq->hdr.is_reply = 0;
70 rq->hdr.seq = kdp.exception_seq;
71 rq->hdr.key = 0;
72 rq->hdr.len = sizeof (*rq) + sizeof(kdp_exc_info_t);
73
74 rq->n_exc_info = 1;
75 rq->exc_info[0].cpu = 0;
76 rq->exc_info[0].exception = exception;
77 rq->exc_info[0].code = code;
78 rq->exc_info[0].subcode = subcode;
79
80 rq->hdr.len += rq->n_exc_info * sizeof (kdp_exc_info_t);
81
82 bcopy((char *)rq, (char *)pkt, rq->hdr.len);
83
84 kdp.exception_ack_needed = TRUE;
85
86 *remote_port = kdp.exception_port;
87 *len = rq->hdr.len;
88}
89
90boolean_t
91kdp_exception_ack(
92 unsigned char *pkt,
93 int len
94)
95{
96 kdp_exception_ack_t aligned_pkt;
97 kdp_exception_ack_t *rq = (kdp_exception_ack_t *)&aligned_pkt;
98
99 if (len < sizeof (*rq))
100 return(FALSE);
101
102 bcopy((char *)pkt, (char *)rq, sizeof(*rq));
103
104 if (!rq->hdr.is_reply || rq->hdr.request != KDP_EXCEPTION)
105 return(FALSE);
106
107 dprintf(("kdp_exception_ack seq %x %x\n", rq->hdr.seq, kdp.exception_seq));
108
109 if (rq->hdr.seq == kdp.exception_seq) {
110 kdp.exception_ack_needed = FALSE;
111 kdp.exception_seq++;
112 }
113 return(TRUE);
114}
115
116static void
117kdp_getintegerstate(
118 struct ppc_thread_state *state
119)
120{
9bccf70c 121 struct savearea *saved_state;
1c79356b
A
122
123 saved_state = kdp.saved_state;
124
125 bzero((char *)state,sizeof (struct ppc_thread_state)) ;
126
55e303ae
A
127 state->srr0 = (unsigned int)saved_state->save_srr0;
128 state->srr1 = (unsigned int)saved_state->save_srr1;
129 state->r0 = (unsigned int)saved_state->save_r0;
130 state->r1 = (unsigned int)saved_state->save_r1;
131 state->r2 = (unsigned int)saved_state->save_r2;
132 state->r3 = (unsigned int)saved_state->save_r3;
133 state->r4 = (unsigned int)saved_state->save_r4;
134 state->r5 = (unsigned int)saved_state->save_r5;
135 state->r6 = (unsigned int)saved_state->save_r6;
136 state->r7 = (unsigned int)saved_state->save_r7;
137 state->r8 = (unsigned int)saved_state->save_r8;
138 state->r9 = (unsigned int)saved_state->save_r9;
139 state->r10 = (unsigned int)saved_state->save_r10;
140 state->r11 = (unsigned int)saved_state->save_r11;
141 state->r12 = (unsigned int)saved_state->save_r12;
142 state->r13 = (unsigned int)saved_state->save_r13;
143 state->r14 = (unsigned int)saved_state->save_r14;
144 state->r15 = (unsigned int)saved_state->save_r15;
145 state->r16 = (unsigned int)saved_state->save_r16;
146 state->r17 = (unsigned int)saved_state->save_r17;
147 state->r18 = (unsigned int)saved_state->save_r18;
148 state->r19 = (unsigned int)saved_state->save_r19;
149 state->r20 = (unsigned int)saved_state->save_r20;
150 state->r21 = (unsigned int)saved_state->save_r21;
151 state->r22 = (unsigned int)saved_state->save_r22;
152 state->r23 = (unsigned int)saved_state->save_r23;
153 state->r24 = (unsigned int)saved_state->save_r24;
154 state->r25 = (unsigned int)saved_state->save_r25;
155 state->r26 = (unsigned int)saved_state->save_r26;
156 state->r27 = (unsigned int)saved_state->save_r27;
157 state->r28 = (unsigned int)saved_state->save_r28;
158 state->r29 = (unsigned int)saved_state->save_r29;
159 state->r30 = (unsigned int)saved_state->save_r30;
160 state->r31 = (unsigned int)saved_state->save_r31;
161 state->cr = (unsigned int)saved_state->save_cr;
162 state->xer = (unsigned int)saved_state->save_xer;
163 state->lr = (unsigned int)saved_state->save_lr;
164 state->ctr = (unsigned int)saved_state->save_ctr;
165}
166
167static void
168kdp_getintegerstate64(
169 struct ppc_thread_state64 *state
170)
171{
172 struct savearea *saved_state;
173
174 saved_state = kdp.saved_state;
175
176 bzero((char *)state,sizeof (struct ppc_thread_state64)) ;
177
9bccf70c
A
178 state->srr0 = saved_state->save_srr0;
179 state->srr1 = saved_state->save_srr1;
180 state->r0 = saved_state->save_r0;
181 state->r1 = saved_state->save_r1;
182 state->r2 = saved_state->save_r2;
183 state->r3 = saved_state->save_r3;
184 state->r4 = saved_state->save_r4;
185 state->r5 = saved_state->save_r5;
186 state->r6 = saved_state->save_r6;
187 state->r7 = saved_state->save_r7;
188 state->r8 = saved_state->save_r8;
189 state->r9 = saved_state->save_r9;
190 state->r10 = saved_state->save_r10;
191 state->r11 = saved_state->save_r11;
192 state->r12 = saved_state->save_r12;
193 state->r13 = saved_state->save_r13;
194 state->r14 = saved_state->save_r14;
195 state->r15 = saved_state->save_r15;
196 state->r16 = saved_state->save_r16;
197 state->r17 = saved_state->save_r17;
198 state->r18 = saved_state->save_r18;
199 state->r19 = saved_state->save_r19;
200 state->r20 = saved_state->save_r20;
201 state->r21 = saved_state->save_r21;
202 state->r22 = saved_state->save_r22;
203 state->r23 = saved_state->save_r23;
204 state->r24 = saved_state->save_r24;
205 state->r25 = saved_state->save_r25;
206 state->r26 = saved_state->save_r26;
207 state->r27 = saved_state->save_r27;
208 state->r28 = saved_state->save_r28;
209 state->r29 = saved_state->save_r29;
210 state->r30 = saved_state->save_r30;
211 state->r31 = saved_state->save_r31;
212 state->cr = saved_state->save_cr;
213 state->xer = saved_state->save_xer;
214 state->lr = saved_state->save_lr;
215 state->ctr = saved_state->save_ctr;
1c79356b
A
216}
217
218kdp_error_t
219kdp_machine_read_regs(
220 unsigned int cpu,
221 unsigned int flavor,
222 char *data,
223 int *size
224)
225{
226 switch (flavor) {
227
228 case PPC_THREAD_STATE:
229 dprintf(("kdp_readregs THREAD_STATE\n"));
230 kdp_getintegerstate((struct ppc_thread_state *)data);
231 *size = PPC_THREAD_STATE_COUNT * sizeof(int);
232 return KDPERR_NO_ERROR;
55e303ae
A
233
234 case PPC_THREAD_STATE64:
235 dprintf(("kdp_readregs THREAD_STATE\n"));
236 kdp_getintegerstate64((struct ppc_thread_state64 *)data);
237 *size = PPC_THREAD_STATE64_COUNT * sizeof(int);
238 return KDPERR_NO_ERROR;
239
1c79356b
A
240 case PPC_FLOAT_STATE:
241 dprintf(("kdp_readregs THREAD_FPSTATE\n"));
242 bzero((char *)data ,sizeof(struct ppc_float_state));
243 *size = PPC_FLOAT_STATE_COUNT * sizeof(int);
244 return KDPERR_NO_ERROR;
55e303ae 245
1c79356b
A
246 default:
247 dprintf(("kdp_readregs bad flavor %d\n"));
248 return KDPERR_BADFLAVOR;
249 }
250}
251
252static void
253kdp_setintegerstate(
254 struct ppc_thread_state *state
255)
256{
9bccf70c 257 struct savearea *saved_state;
1c79356b
A
258
259 saved_state = kdp.saved_state;
260
9bccf70c
A
261 saved_state->save_srr0 = state->srr0;
262 saved_state->save_srr1 = state->srr1;
263 saved_state->save_r0 = state->r0;
264 saved_state->save_r1 = state->r1;
265 saved_state->save_r2 = state->r2;
266 saved_state->save_r3 = state->r3;
267 saved_state->save_r4 = state->r4;
268 saved_state->save_r5 = state->r5;
269 saved_state->save_r6 = state->r6;
270 saved_state->save_r7 = state->r7;
271 saved_state->save_r8 = state->r8;
272 saved_state->save_r9 = state->r9;
273 saved_state->save_r10 = state->r10;
274 saved_state->save_r11 = state->r11;
275 saved_state->save_r12 = state->r12;
276 saved_state->save_r13 = state->r13;
277 saved_state->save_r14 = state->r14;
278 saved_state->save_r15 = state->r15;
279 saved_state->save_r16 = state->r16;
280 saved_state->save_r17 = state->r17;
281 saved_state->save_r18 = state->r18;
282 saved_state->save_r19 = state->r19;
283 saved_state->save_r20 = state->r20;
284 saved_state->save_r21 = state->r21;
285 saved_state->save_r22 = state->r22;
286 saved_state->save_r23 = state->r23;
287 saved_state->save_r24 = state->r24;
288 saved_state->save_r25 = state->r25;
289 saved_state->save_r26 = state->r26;
290 saved_state->save_r27 = state->r27;
291 saved_state->save_r28 = state->r28;
292 saved_state->save_r29 = state->r29;
293 saved_state->save_r30 = state->r30;
294 saved_state->save_r31 = state->r31;
295 saved_state->save_cr = state->cr;
296 saved_state->save_xer = state->xer;
297 saved_state->save_lr = state->lr;
298 saved_state->save_ctr = state->ctr;
1c79356b
A
299}
300
55e303ae
A
301static void
302kdp_setintegerstate64(
303 struct ppc_thread_state64 *state
304)
305{
306 struct savearea *saved_state;
307
308 saved_state = kdp.saved_state;
309
310 saved_state->save_srr0 = state->srr0;
311 saved_state->save_srr1 = state->srr1;
312 saved_state->save_r0 = state->r0;
313 saved_state->save_r1 = state->r1;
314 saved_state->save_r2 = state->r2;
315 saved_state->save_r3 = state->r3;
316 saved_state->save_r4 = state->r4;
317 saved_state->save_r5 = state->r5;
318 saved_state->save_r6 = state->r6;
319 saved_state->save_r7 = state->r7;
320 saved_state->save_r8 = state->r8;
321 saved_state->save_r9 = state->r9;
322 saved_state->save_r10 = state->r10;
323 saved_state->save_r11 = state->r11;
324 saved_state->save_r12 = state->r12;
325 saved_state->save_r13 = state->r13;
326 saved_state->save_r14 = state->r14;
327 saved_state->save_r15 = state->r15;
328 saved_state->save_r16 = state->r16;
329 saved_state->save_r17 = state->r17;
330 saved_state->save_r18 = state->r18;
331 saved_state->save_r19 = state->r19;
332 saved_state->save_r20 = state->r20;
333 saved_state->save_r21 = state->r21;
334 saved_state->save_r22 = state->r22;
335 saved_state->save_r23 = state->r23;
336 saved_state->save_r24 = state->r24;
337 saved_state->save_r25 = state->r25;
338 saved_state->save_r26 = state->r26;
339 saved_state->save_r27 = state->r27;
340 saved_state->save_r28 = state->r28;
341 saved_state->save_r29 = state->r29;
342 saved_state->save_r30 = state->r30;
343 saved_state->save_r31 = state->r31;
344 saved_state->save_cr = state->cr;
345 saved_state->save_xer = state->xer;
346 saved_state->save_lr = state->lr;
347 saved_state->save_ctr = state->ctr;
348}
349
1c79356b
A
350kdp_error_t
351kdp_machine_write_regs(
352 unsigned int cpu,
353 unsigned int flavor,
354 char *data,
355 int *size
356)
357{
358 switch (flavor) {
359
360 case PPC_THREAD_STATE:
361 dprintf(("kdp_writeregs THREAD_STATE\n"));
362 kdp_setintegerstate((struct ppc_thread_state *)data);
363
364#if KDP_TEST_HARNESS
365 DumpTheSave((struct savearea *)data); /* (TEST/DEBUG) */
366#endif
367 return KDPERR_NO_ERROR;
55e303ae
A
368
369 case PPC_THREAD_STATE64:
370 dprintf(("kdp_writeregs THREAD_STATE64\n"));
371 kdp_setintegerstate64((struct ppc_thread_state64 *)data);
372
373#if KDP_TEST_HARNESS
374 DumpTheSave((struct savearea *)data); /* (TEST/DEBUG) */
375#endif
376 return KDPERR_NO_ERROR;
1c79356b
A
377 case PPC_FLOAT_STATE:
378 dprintf(("kdp_writeregs THREAD_FPSTATE\n"));
379 return KDPERR_NO_ERROR;
55e303ae 380
1c79356b
A
381 default:
382 dprintf(("kdp_writeregs bad flavor %d\n"));
383 return KDPERR_BADFLAVOR;
384 }
385}
386
387void
388kdp_machine_hostinfo(
389 kdp_hostinfo_t *hostinfo
390)
391{
1c79356b
A
392 int i;
393
394 hostinfo->cpus_mask = 0;
0b4e3aa0 395 hostinfo->cpu_type = 0;
1c79356b
A
396
397 for (i = 0; i < machine_info.max_cpus; i++) {
91447636
A
398 if ((PerProcTable[i].ppe_vaddr == (struct per_proc_info *)NULL) ||
399 !(PerProcTable[i].ppe_vaddr->running))
1c79356b
A
400 continue;
401
402 hostinfo->cpus_mask |= (1 << i);
403 if (hostinfo->cpu_type == 0) {
91447636
A
404 hostinfo->cpu_type = slot_type(i);
405 hostinfo->cpu_subtype = slot_subtype(i);
1c79356b
A
406 }
407 }
408}
409
410void
411kdp_panic(
412 const char *msg
413)
414{
415 printf("kdp panic: %s\n", msg);
416 while(1) {}
417}
418
419
420void
421kdp_reboot(void)
422{
91447636
A
423 printf("Attempting system restart...");
424 /* Call the platform specific restart*/
425 if (PE_halt_restart)
426 (*PE_halt_restart)(kPERestartCPU);
427 /* If we do reach this, give up */
428 halt_all_cpus(TRUE);
1c79356b
A
429}
430
431int
432kdp_intr_disbl(void)
433{
434 return (splhigh());
435}
436
437void
438kdp_intr_enbl(int s)
439{
440 splx(s);
441}
442
443void
444kdp_us_spin(int usec)
445{
446 extern void delay(int);
447
448 delay(usec/100);
449}
450
451void print_saved_state(void *state)
452{
453 struct ppc_thread_state *saved_state;
454
455 saved_state = state;
456
457 printf("pc = 0x%x\n", saved_state->srr0);
458 printf("msr = 0x%x\n", saved_state->srr1);
459 printf("rp = 0x%x\n", saved_state->lr);
460 printf("sp = 0x%x\n", saved_state->r1);
461
462}
463
464void
465kdp_call()
466{
467 Debugger("inline call to debugger(machine_startup)");
468}
469
470/*
471 * table to convert system specific code to generic codes for kdb
472 */
473int kdp_trap_codes[] = {
474 EXC_BAD_ACCESS, /* 0x0000 INVALID EXCEPTION */
475 EXC_BAD_ACCESS, /* 0x0100 System reset */
476 EXC_BAD_ACCESS, /* 0x0200 Machine check */
477 EXC_BAD_ACCESS, /* 0x0300 Data access */
478 EXC_BAD_ACCESS, /* 0x0400 Instruction access */
479 EXC_BAD_ACCESS, /* 0x0500 External interrupt */
480 EXC_BAD_ACCESS, /* 0x0600 Alignment */
481 EXC_BREAKPOINT, /* 0x0700 Program - fp exc, ill/priv instr, trap */
482 EXC_ARITHMETIC, /* 0x0800 Floating point disabled */
483 EXC_SOFTWARE, /* 0x0900 Decrementer */
484 EXC_BAD_ACCESS, /* 0x0A00 I/O controller interface */
485 EXC_BAD_ACCESS, /* 0x0B00 INVALID EXCEPTION */
486 EXC_SOFTWARE, /* 0x0C00 System call exception */
487 EXC_BREAKPOINT, /* 0x0D00 Trace */
488 EXC_SOFTWARE, /* 0x0E00 FP assist */
489 EXC_SOFTWARE, /* 0x0F00 Performance monitoring */
490 EXC_ARITHMETIC, /* 0x0F20 Altivec disabled */
491 EXC_BAD_ACCESS, /* 0x1000 Instruction PTE miss */
492 EXC_BAD_ACCESS, /* 0x1100 Data load PTE miss */
493 EXC_BAD_ACCESS, /* 0x1200 Data store PTE miss */
494 EXC_BREAKPOINT, /* 0x1300 Instruction bkpt */
495 EXC_SOFTWARE, /* 0x1400 System management */
496 EXC_BAD_ACCESS, /* 0x1500 INVALID EXCEPTION */
497 EXC_ARITHMETIC, /* 0x1600 Altivec Assist */
498 EXC_BAD_ACCESS, /* 0x1700 INVALID EXCEPTION */
499 EXC_BAD_ACCESS, /* 0x1800 INVALID EXCEPTION */
500 EXC_BAD_ACCESS, /* 0x1900 INVALID EXCEPTION */
501 EXC_BAD_ACCESS, /* 0x1A00 INVALID EXCEPTION */
502 EXC_BAD_ACCESS, /* 0x1B00 INVALID EXCEPTION */
503 EXC_BAD_ACCESS, /* 0x1C00 INVALID EXCEPTION */
504 EXC_BAD_ACCESS, /* 0x1D00 INVALID EXCEPTION */
505 EXC_BAD_ACCESS, /* 0x1E00 INVALID EXCEPTION */
506 EXC_BAD_ACCESS, /* 0x1F00 INVALID EXCEPTION */
507 EXC_BREAKPOINT, /* 0x2000 Run Mode/Trace */
508 EXC_BAD_ACCESS, /* 0x2100 INVALID EXCEPTION */
509 EXC_BAD_ACCESS, /* 0x2200 INVALID EXCEPTION */
510 EXC_BAD_ACCESS, /* 0x2300 INVALID EXCEPTION */
511 EXC_BAD_ACCESS, /* 0x2400 INVALID EXCEPTION */
512 EXC_BAD_ACCESS, /* 0x2500 INVALID EXCEPTION */
513 EXC_BAD_ACCESS, /* 0x2600 INVALID EXCEPTION */
514 EXC_BAD_ACCESS, /* 0x2700 INVALID EXCEPTION */
515 EXC_BAD_ACCESS, /* 0x2800 INVALID EXCEPTION */
516 EXC_BAD_ACCESS, /* 0x2900 INVALID EXCEPTION */
517 EXC_BAD_ACCESS, /* 0x2A00 INVALID EXCEPTION */
518 EXC_BAD_ACCESS, /* 0x2B00 INVALID EXCEPTION */
519 EXC_BAD_ACCESS, /* 0x2C00 INVALID EXCEPTION */
520 EXC_BAD_ACCESS, /* 0x2D00 INVALID EXCEPTION */
521 EXC_BAD_ACCESS, /* 0x2E00 INVALID EXCEPTION */
522 EXC_BAD_ACCESS, /* 0x2F00 INVALID EXCEPTION */
523 EXC_SOFTWARE /* 0x3000 AST trap (software) */
524};
525
526int
527kdp_getc()
528{
529 return(cnmaygetc());
530}
531
532int kdp_backtrace;
533int kdp_sr_dump;
534int kdp_dabr;
535int kdp_noisy;
536
537#define kdp_code(x) kdp_trap_codes[((x)==T_AST?0x31:(x)/T_VECTOR_SIZE)]
538
539void
540kdp_trap(
541 unsigned int exception,
9bccf70c 542 struct savearea *saved_state
1c79356b
A
543)
544{
545 unsigned int *fp;
55e303ae 546 unsigned int sp;
9bccf70c 547 struct savearea *state;
1c79356b
A
548
549 if (kdp_noisy) {
550 if (kdp_backtrace) {
551 printf("\nvector=%x, \n", exception/4);
9bccf70c 552 sp = saved_state->save_r1;
1c79356b
A
553 printf("stack backtrace - sp(%x) ", sp);
554 fp = (unsigned int *) *((unsigned int *)sp);
555 while (fp) {
556 printf("0x%08x ", fp[2]);
557 fp = (unsigned int *)*fp;
558 }
559 printf("\n");
560 }
561#ifdef XXX
562 if (kdp_sr_dump) {
563 dump_segment_registers();
564 }
565#endif
566
9bccf70c 567 printf("vector=%d ", exception/4);
1c79356b 568 }
1c79356b
A
569 kdp_raise_exception(kdp_code(exception), 0, 0, saved_state);
570
571 if (kdp_noisy)
572 printf("kdp_trap: kdp_raise_exception() ret\n");
573
55e303ae 574 if ((unsigned int)(saved_state->save_srr0) == 0x7c800008)
9bccf70c
A
575 saved_state->save_srr0 += 4; /* BKPT_SIZE */
576
577 if(saved_state->save_srr1 & (MASK(MSR_SE) | MASK(MSR_BE))) { /* Are we just stepping or continuing */
1c79356b
A
578 db_run_mode = STEP_ONCE; /* We are stepping */
579 }
580 else db_run_mode = STEP_CONTINUE; /* Otherwise we are continuing */
9bccf70c 581
1c79356b
A
582#ifdef XXX
583 mtspr(dabr, kdp_dabr);
584#endif
585}
586
587boolean_t
588kdp_call_kdb(
589 void)
590{
591 switch_debugger=1;
592 return(TRUE);
593}
594
9bccf70c 595void kdp_print_registers(struct savearea *state)
1c79356b
A
596{
597 int i;
598 for (i=0; i<32; i++) {
599 if ((i % 8) == 0)
600 printf("\n%4d :",i);
9bccf70c 601 printf(" %08x",*(&state->save_r0+i));
1c79356b
A
602 }
603 printf("\n");
9bccf70c
A
604 printf("cr = 0x%08x\t\t",state->save_cr);
605 printf("xer = 0x%08x\n",state->save_xer);
606 printf("lr = 0x%08x\t\t",state->save_lr);
607 printf("ctr = 0x%08x\n",state->save_ctr);
608 printf("srr0(iar) = 0x%08x\t\t",state->save_srr0);
609 printf("srr1(msr) = 0x%08B\n",state->save_srr1,
1c79356b
A
610 "\x10\x11""EE\x12PR\x13""FP\x14ME\x15""FE0\x16SE\x18"
611 "FE1\x19""AL\x1a""EP\x1bIT\x1c""DT");
1c79356b
A
612 printf("\n");
613}
614
615void
616kdp_print_backtrace(
617 unsigned int exception,
9bccf70c 618 struct savearea *saved_state)
1c79356b 619{
9bccf70c
A
620 extern void kdp_print_registers(struct savearea *);
621 extern void print_backtrace(struct savearea *);
1c79356b
A
622
623 disableDebugOuput = FALSE;
624 debug_mode = TRUE;
625 printf("re-entering kdp:\n");
626 printf("vector=%x, \n", exception/4);
627 kdp_print_registers(saved_state);
628 print_backtrace(saved_state);
629 printf("panic: We are hanging here...\n");
630 while(1);
631}
9bccf70c 632
91447636 633unsigned int kdp_ml_get_breakinsn(void)
9bccf70c
A
634{
635 return 0x7fe00008;
636}