start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / arch / x86_64-all / exec / alert_cpu.c
blob09fee2dc907e9dd024c6b18cad15983d7f82679b
1 /*
2 Copyright © 2011-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CPU context parsing routines, x86-64 version.
6 Lang: english
7 */
9 #include <exec/rawfmt.h>
10 #include <proto/exec.h>
12 #include <string.h>
14 #include "exec_intern.h"
15 #include "exec_util.h"
17 static const char *gpr_fmt = "RAX=%P RBX=%P RCX=%P RDX=%P\n"
18 "RSI=%P RDI=%P RSP=%P RBP=%P\n"
19 "R8 =%P R9 =%P R10=%P R11=%P\n"
20 "R12=%P R13=%P R14=%P R15=%P\n"
21 "RIP=%P RSP=%P RFLAGS=%P";
23 static const char *seg_fmt = "\nCS=%04lx SS=%04lx DS=%04lx\n"
24 "ES=%04lx FS=%04lx GS=%04lx";
26 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase)
28 VOID_FUNC dest = buffer ? RAWFMTFUNC_STRING : RAWFMTFUNC_SERIAL;
29 char *buf;
31 buf = NewRawDoFmt(gpr_fmt, dest, buffer,
32 ctx->rax, ctx->rbx, ctx->rcx, ctx->rdx,
33 ctx->rsi, ctx->rdi, ctx->rsp, ctx->rbp,
34 ctx->r8 , ctx->r9 , ctx->r10, ctx->r11,
35 ctx->r12, ctx->r13, ctx->r14, ctx->r15,
36 ctx->rip, ctx->rsp, ctx->rflags);
37 if (ctx->Flags & ECF_SEGMENTS)
39 buf = NewRawDoFmt(seg_fmt, dest, buf - 1,
40 ctx->cs, ctx->ss, ctx->ds,
41 ctx->es, ctx->fs, ctx->gs);
44 return buf - 1;
48 * Unwind a single stack frame. CPU-dependent.
49 * Note that for this to work you need to supply -fno-omit-frame-pointer to gcc.
51 APTR UnwindFrame(APTR fp, APTR *caller)
53 APTR *rbp = fp;
55 *caller = rbp[1]; /* Fill in caller address */
56 return rbp[0]; /* Return pointer to the previous frame */