aboutsummaryrefslogtreecommitdiff
path: root/src/interrupts.zig
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-05-13 23:35:15 +0200
committerHimbeer <himbeer@disroot.org>2024-05-13 23:35:15 +0200
commit6bfb99b969621fd51fde4562a09a78f363297b18 (patch)
treeb0b0ca38d2b415d770398818e0e93e27407a0e5c /src/interrupts.zig
parent17abd1049d12f335012578426ccfaab21b1e94c5 (diff)
interrupts: Fix context switching to U-mode from S-mode
This ensures that kernel code never gets skipped or otherwise messed with. The first switch to U-mode is handled explicitly elsewhere by manually calling process.switchTo on the init process.
Diffstat (limited to 'src/interrupts.zig')
-rw-r--r--src/interrupts.zig8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/interrupts.zig b/src/interrupts.zig
index ba5f440..9d47934 100644
--- a/src/interrupts.zig
+++ b/src/interrupts.zig
@@ -130,11 +130,13 @@ export fn handleTrap(epc: usize, tval: usize, cause_bits: usize, hart_id: usize,
// before returning into it.
process.list.last.?.data.pc = epc;
+
+ schedule() catch |err| {
+ std.debug.panic("Hart {d}: Unable to schedule next process: {any}", .{ hart_id, err });
+ };
}
- schedule() catch |err| {
- std.debug.panic("Hart {d}: Unable to schedule next process: {any}", .{ hart_id, err });
- };
+ // Don't interrupt kernel code, it may never run otherwise.
},
.supervisor_external => {
const context: u14 = @intCast(2 * hart_id + 1);