commit d60556bf6cb6304a18de257d19b2e94bc6f80928
parent e88341aebb581d3376fa005d55efb145ee1b22c1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 18 Oct 2020 09:35:12 +0200
os9/arm64: Add fault()
This functions behaves like panic() but it receives
a context. The main use of this function is in exceptions
where it receives a pointer to the faulted context.
Change-Id: Icf1416043c2c00c5547509e98d567a04416bac90
Diffstat:
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/include/os9/os9.h b/include/os9/os9.h
@@ -217,6 +217,7 @@ extern int trylock(mutex_t *m);
extern void barrier(int);
extern noreturn void halt(void);
extern noreturn void panic(const char *msg);
+extern noreturn void fault(const char *msg, Context *ctx);
extern noreturn void swtch(Context *ctx);
extern noreturn void trap(Context *ctx);
diff --git a/src/os9/arch/arm64/panic.c b/src/os9/arch/arm64/panic.c
@@ -79,20 +79,26 @@ dumpstack(Context *ctx)
kprint("%0llx%c", *sp++, (i % 4 == 0) ? '\n' : ' ');
}
-void
-panic(const char *msg)
+noreturn void
+fault(const char *msg, Context *ctx)
{
static int first = 1;
- Context ctx;
+ Context local;
if (first) {
first = 0;
- getctx(&ctx);
kprint("panic: %s\n", msg);
- dumpregs(&ctx);
- backtrace(&ctx);
- dumpstack(&ctx);
+ if (!ctx)
+ ctx = getctx(&local);
+ dumpregs(ctx);
+ backtrace(ctx);
+ dumpstack(ctx);
}
-
halt();
}
+
+void
+panic(const char *msg)
+{
+ fault(msg, NULL);
+}
diff --git a/src/os9/arch/arm64/trap.c b/src/os9/arch/arm64/trap.c
@@ -23,7 +23,7 @@ trap(Context *ctx)
if (ec != SVC) {
msg = (ec < NR_EC_VALS) ? ecstr[ec] : "unknown reason";
- panic("unknown reason");
+ fault(msg, ctx);
}
numsvc = ctx->r[ESR] & 0xff;