diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-17 13:22:43 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-17 13:22:43 +0200 |
commit | b084e65f9f5d63b968081ecf82bf5d64d7d9f613 (patch) | |
tree | d7c737beaaf3c7fda741c6dbf152d5b5363c2a38 | |
parent | 191a27ab252884e9457c898a6aa919eec93dc5ac (diff) |
rethooks: Move functions from Container struct(s) into their own file (for readability)
-rw-r--r-- | src/lib/process.zig | 13 | ||||
-rw-r--r-- | src/lib/rethooks.zig | 11 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/process.zig b/src/lib/process.zig index a4bbb75..d7ecd5f 100644 --- a/src/lib/process.zig +++ b/src/lib/process.zig @@ -7,6 +7,7 @@ const std = @import("std"); const instructions = @import("instructions.zig"); const paging = @import("paging.zig"); +const rethooks = @import("rethooks.zig"); const sysexchange = @import("sysexchange.zig"); const time = @import("sbi/time.zig"); const trap = @import("trap.zig"); @@ -139,20 +140,10 @@ pub const Info = struct { } pub fn call(self: *Info, function: usize, args: anytype, cleanup_hook: ?CleanupHook, term_hook: ?TermHook) noreturn { - const Container = struct { - fn terminate() linksection(".rethooks") callconv(.Naked) noreturn { - // Syscall #100011 is "terminate". - asm volatile ( - \\ li a7, 100011 - \\ ecall - ); - } - }; - self.pc = function; self.cleanup_hook = cleanup_hook; self.term_hook = term_hook; - self.trap_frame.general_purpose_registers[1] = @intFromPtr(&Container.terminate); + self.trap_frame.general_purpose_registers[1] = @intFromPtr(&rethooks.terminate); inline for (args, 0..) |arg, i| { if (i >= 6) break; diff --git a/src/lib/rethooks.zig b/src/lib/rethooks.zig new file mode 100644 index 0000000..bad4d55 --- /dev/null +++ b/src/lib/rethooks.zig @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +pub fn terminate() linksection(".rethooks") callconv(.Naked) noreturn { + // Syscall #100011 is "terminate". + asm volatile ( + \\ li a7, 100011 + \\ ecall + ); +} |