aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-06-15 21:13:22 +0200
committerHimbeer <himbeer@disroot.org>2024-06-15 21:13:22 +0200
commitae5d317408315ac631351b265a79924c281368a9 (patch)
tree2bd625c55e812445717fc7082d3ee3a9bf51d8f4 /src
parentf13549ebe9688eb653c2e57f2b2f42b019eb1278 (diff)
interrupts: Restore global pointer before entering handleTrap
Diffstat (limited to 'src')
-rw-r--r--src/lib/interrupts.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/interrupts.zig b/src/lib/interrupts.zig
index ebb6e9a..a91e079 100644
--- a/src/lib/interrupts.zig
+++ b/src/lib/interrupts.zig
@@ -93,6 +93,7 @@ export fn handleTrap(epc: usize, tval: usize, cause_bits: usize, frame: *trap.Fr
const w = console.writer();
const status = instructions.sstatus.read();
+
const cause: Cause = @bitCast(cause_bits);
if (cause.isAsync()) {
@@ -226,10 +227,16 @@ export fn supervisorTrapVector() align(4) callconv(.Naked) noreturn {
\\
\\ csrw sscratch, t5
\\
+ \\ .option push
+ \\ .option norelax
+ \\ la gp, _global_pointer
+ \\ .option pop
+ \\
\\ csrr a0, sepc
\\ csrr a1, stval
\\ csrr a2, scause
\\ mv a3, t5
+ \\
\\ la sp, _stvec_stack_end
\\ call handleTrap
\\