de-lint
[AROS.git] / arch / ppc-all / exec / alert_cpu.c
bloba0492b196dc23f76611ecf93393575205047e947
1 /*
2 Copyright © 2010-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: PowerPC CPU context parsing routines.
6 Lang: english
7 */
9 #define DEBUG 1
11 #include <exec/rawfmt.h>
12 #include <proto/exec.h>
14 #include <string.h>
16 #include "exec_intern.h"
17 #include "exec_util.h"
19 static const char *gpr_fmt = "MSR=%08lx IP=%08lx CR =%08lx XER=%08lx\n"
20 "CTR=%08lx LR=%08lx DSISR=%08lx DAR=%08lx\n"
21 "R0 =%08lx R1=%08lx R2 =%08lx R3 =%08lx\n"
22 "R4 =%08lx R5=%08lx R6 =%08lx R7 =%08lx\n"
23 "R8 =%08lx R9=%08lx R10=%08lx R11=%08lx\n" \
24 "R12=%08lx";
26 static const char *gp2_fmt = " R13=%08lx R14=%08lx R15=%08lx\n"
27 "R16=%08lx R17=%08lx R18=%08lx R19=%08lx\n"
28 "R20=%08lx R21=%08lx R22=%08lx R23=%08lx\n"
29 "R24=%08lx R25=%08lx R26=%08lx R27=%08lx\n"
30 "R28=%08lx R29=%08lx R30=%08lx R31=%08lx";
32 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase)
34 VOID_FUNC dest = buffer ? RAWFMTFUNC_STRING : RAWFMTFUNC_SERIAL;
35 char *buf;
37 buf = NewRawDoFmt(gpr_fmt, dest, buffer,
38 ctx->msr , ctx->ip , ctx->cr , ctx->xer,
39 ctx->ctr , ctx->lr , ctx->dsisr , ctx->dar,
40 ctx->gpr[0] , ctx->gpr[1], ctx->gpr[2] , ctx->gpr[3],
41 ctx->gpr[4] , ctx->gpr[5], ctx->gpr[6] , ctx->gpr[7],
42 ctx->gpr[8] , ctx->gpr[9], ctx->gpr[10], ctx->gpr[11],
43 ctx->gpr[12]);
44 if (ctx->Flags & ECF_FULL_GPRS)
46 buf = NewRawDoFmt(gp2_fmt, dest, buf - 1,
47 ctx->gpr[13], ctx->gpr[14], ctx->gpr[15],
48 ctx->gpr[16], ctx->gpr[17], ctx->gpr[18], ctx->gpr[19],
49 ctx->gpr[20], ctx->gpr[21], ctx->gpr[22], ctx->gpr[23],
50 ctx->gpr[24], ctx->gpr[25], ctx->gpr[26], ctx->gpr[27],
51 ctx->gpr[28], ctx->gpr[29], ctx->gpr[30], ctx->gpr[31]);
54 return buf - 1;
57 /* Unwind a single stack frame. CPU-dependent. */
58 APTR UnwindFrame(APTR fp, APTR *caller)
60 APTR *sp = fp;
62 sp = sp[0]; /* Go to previous frame first */
63 if (sp)
64 *caller = sp[1]; /* Caller address is stored in *caller's* frame */
66 return sp;