diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-30 00:57:33 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-30 00:57:33 +0200 |
| commit | 44a73ecab6e91519627786a5101cd4f1a2f2b0d7 (patch) | |
| tree | f5c811050a4d5ee832f5883c4d0c27efddd60817 /arch/riscv64/kernel/entry.S | |
| parent | 5976ad390a15726c3ddfacf8c8b282c8350f9554 (diff) | |
| download | kmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.tar.gz kmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.zip | |
most of the way to passing tests
Diffstat (limited to 'arch/riscv64/kernel/entry.S')
| -rw-r--r-- | arch/riscv64/kernel/entry.S | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/riscv64/kernel/entry.S b/arch/riscv64/kernel/entry.S index 0bc999e..f894e0d 100644 --- a/arch/riscv64/kernel/entry.S +++ b/arch/riscv64/kernel/entry.S @@ -62,6 +62,7 @@ handle_trap: bnez tp, continue_trap /* the trap came from the kernel, should never happen so just panic * and abort or whatever */ + csrw CSR_SSCRATCH, x0 csrr a0, CSR_SEPC csrr a1, CSR_STVAL csrr a2, CSR_SCAUSE @@ -92,8 +93,16 @@ continue_trap: save_caller mv a0, s10 + /* get actual kernel stack into sp */ + mv sp, tp call riscv_handle_interrupt + lr sp, offsetof_regs(tp) + addi sp, sp, -sizeof_registers + /* set execution continuation */ + lr s10, offsetof_exec(tp) + csrw CSR_SEPC, s10 + j _load_context handle_exception: @@ -108,7 +117,14 @@ handle_exception: csrr a0, CSR_SEPC csrr a1, CSR_STVAL csrr a2, CSR_SCAUSE - call unhandled_panic + mv sp, tp + call riscv_handle_exception + + lr sp, offsetof_regs(tp) + addi sp, sp, -sizeof_registers + /* set execution continuation */ + lr s10, offsetof_exec(tp) + csrw CSR_SEPC, s10 j _load_context @@ -129,6 +145,7 @@ fast_dispatch: csrr s10, CSR_SEPC sr s10, offsetof_exec(tp) /* jump to C */ + mv sp, tp call dispatch /* if we had a thread switch, load kernel stack of current thread and * restore its context */ |
