aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorwxjstz <wxjstz@126.com>2018-08-07 03:09:06 +0800
committerAndrew Waterman <aswaterman@gmail.com>2018-08-06 12:09:06 -0700
commit41ff94a84c6bc7ada906a38a250f4d175d796d92 (patch)
tree65837e4a33dddfdd9be51371906a4213b87b7dba /pk
parentd64dfb3d17c82ba1a95cdc7e31fd14ae4d27587c (diff)
downloadpk-41ff94a84c6bc7ada906a38a250f4d175d796d92.zip
pk-41ff94a84c6bc7ada906a38a250f4d175d796d92.tar.gz
pk-41ff94a84c6bc7ada906a38a250f4d175d796d92.tar.bz2
Add some exception handling functions to s-mode to handle exception return from m-mode. (#117)
Diffstat (limited to 'pk')
-rw-r--r--pk/handlers.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/pk/handlers.c b/pk/handlers.c
index b0eb76b..cb12d22 100644
--- a/pk/handlers.c
+++ b/pk/handlers.c
@@ -5,6 +5,24 @@
#include "syscall.h"
#include "mmap.h"
+static void handle_instruction_access_fault(trapframe_t *tf)
+{
+ dump_tf(tf);
+ panic("Instruction access fault!");
+}
+
+static void handle_load_access_fault(trapframe_t *tf)
+{
+ dump_tf(tf);
+ panic("Load access fault!");
+}
+
+static void handle_store_access_fault(trapframe_t *tf)
+{
+ dump_tf(tf);
+ panic("Store/AMO access fault!");
+}
+
static void handle_illegal_instruction(trapframe_t* tf)
{
tf->insn = *(uint16_t*)tf->epc;
@@ -31,6 +49,12 @@ static void handle_misaligned_fetch(trapframe_t* tf)
panic("Misaligned instruction access!");
}
+static void handle_misaligned_load(trapframe_t* tf)
+{
+ dump_tf(tf);
+ panic("Misaligned Load!");
+}
+
static void handle_misaligned_store(trapframe_t* tf)
{
dump_tf(tf);
@@ -83,10 +107,14 @@ void handle_trap(trapframe_t* tf)
const static trap_handler trap_handlers[] = {
[CAUSE_MISALIGNED_FETCH] = handle_misaligned_fetch,
+ [CAUSE_FETCH_ACCESS] = handle_instruction_access_fault,
+ [CAUSE_LOAD_ACCESS] = handle_load_access_fault,
+ [CAUSE_STORE_ACCESS] = handle_store_access_fault,
[CAUSE_FETCH_PAGE_FAULT] = handle_fault_fetch,
[CAUSE_ILLEGAL_INSTRUCTION] = handle_illegal_instruction,
[CAUSE_USER_ECALL] = handle_syscall,
[CAUSE_BREAKPOINT] = handle_breakpoint,
+ [CAUSE_MISALIGNED_LOAD] = handle_misaligned_load,
[CAUSE_MISALIGNED_STORE] = handle_misaligned_store,
[CAUSE_LOAD_PAGE_FAULT] = handle_fault_load,
[CAUSE_STORE_PAGE_FAULT] = handle_fault_store,