From e3c69271a3c92269d86b867ab089143e78bf78b4 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Tue, 4 Sep 2012 18:33:07 +0000 Subject: [PATCH] arch/m68k-all: Enable SAD dumping of task context Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45728 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/m68k-all/exec/alert_cpu.c | 136 +++++++++++------------------------------ 1 file changed, 36 insertions(+), 100 deletions(-) rewrite arch/m68k-all/exec/alert_cpu.c (80%) diff --git a/arch/m68k-all/exec/alert_cpu.c b/arch/m68k-all/exec/alert_cpu.c dissimilarity index 80% index 234652d7e6..3a2a55556c 100644 --- a/arch/m68k-all/exec/alert_cpu.c +++ b/arch/m68k-all/exec/alert_cpu.c @@ -1,100 +1,36 @@ -/* - Copyright © 2010-2012, The AROS Development Team. All rights reserved. - $Id$ - - Desc: CPU context parsing routines. Dummy nonfunctional template. - See code in arch/i386/all/exec/alert_cpu.c for working example. - Lang: english -*/ - -#include - -#include "exec_intern.h" -#include "exec_util.h" - -static inline char *addHex(char *buff, ULONG val) -{ - *(buff++) = "0123456789ABCDEF"[val & 0xf]; - - return buff; -} - -static inline char *addHexen(char *buff, ULONG val) -{ - int i; - - for (i = 0; i < 8; i++) - buff = addHex(buff, (val >> (28 - i * 4)) & 0xf); - - return buff; -} - -char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase) -{ - char *buf = buffer; - char tmp[16]; - int i; - UWORD sr = (ctx)->sr; - - if (!buffer) - { - /* - * FIXME: SAD now calls this routine with buffer = NULL in order to dump - * the context to debug output. - * This is very simple with (New)RawDoFmt(), but this code is - * completely another thing... - */ - kprintf("FIXME: Not implemented yet\n"); - return NULL; - } - - for (i = 0; i < 8; i++) { - tmp[0] = 'D'; - tmp[1] = '0' + i; - tmp[2] = ':'; - tmp[3] = ' '; - tmp[4] = 0; - buf = Alert_AddString(buf, tmp); - buf = addHexen(buf, (ctx)->d[i]); - if ((i%4) == 3) - *buf = '\n'; - else - *buf = ' '; - buf++; - } - for (i = 0; i < 8; i++) { - tmp[0] = 'A'; - tmp[1] = '0' + i; - tmp[2] = ':'; - tmp[3] = ' '; - tmp[4] = 0; - buf = Alert_AddString(buf, tmp); - buf = addHexen(buf, (ctx)->a[i]); - if ((i%4) == 3) - *buf = '\n'; - else - *buf = ' '; - buf++; - } - buf = Alert_AddString(buf, "SR: T="); buf = addHex(buf, (sr >> 14) & 3); - buf = Alert_AddString(buf, " S="); buf = addHex(buf, (sr >> 13) & 1); - buf = Alert_AddString(buf, " M="); buf = addHex(buf, (sr >> 5) & 1); - buf = Alert_AddString(buf, " X="); buf = addHex(buf, (sr >> 4) & 1); - buf = Alert_AddString(buf, " N="); buf = addHex(buf, (sr >> 3) & 1); - buf = Alert_AddString(buf, " Z="); buf = addHex(buf, (sr >> 2) & 1); - buf = Alert_AddString(buf, " V="); buf = addHex(buf, (sr >> 1) & 1); - buf = Alert_AddString(buf, " C="); buf = addHex(buf, (sr >> 0) & 1); - buf = Alert_AddString(buf, " IMASK="); buf = addHex(buf, (sr >> 8) & 7); - /* PC was already printed out */ - // buf = Alert_AddString(buf, "\nPC: "); buf = addHexen(buf, ctx->pc); - *(buf++) = '\n'; - *buf = 0; - - return buf; -} - -/* Unwind a single stack frame */ -APTR UnwindFrame(APTR fp, APTR *caller) -{ - return NULL; -} +/* + Copyright © 2010-2012, The AROS Development Team. All rights reserved. + $Id$ + + Desc: CPU context parsing routines. Dummy nonfunctional template. + See code in arch/i386/all/exec/alert_cpu.c for working example. + Lang: english +*/ + +#include + +#include + +#include "exec_intern.h" +#include "exec_util.h" + +char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase) +{ + VOID_FUNC dest = buffer ? RAWFMTFUNC_STRING : RAWFMTFUNC_SERIAL; + char *buf; + + buf = RawDoFmt("D0: %08lx %08lx %08lx %08lx\n" + "D4: %08lx %08lx %08lx %08lx\n" + "A0: %08lx %08lx %08lx %08lx\n" + "A4: %08lx %08lx %08lx %08lx\n" + "SR: %04x\n" + "PC: %08lx", ctx, dest, buffer); + + return buf - 1; +} + +/* Unwind a single stack frame */ +APTR UnwindFrame(APTR fp, APTR *caller) +{ + return NULL; +} -- 2.11.4.GIT