aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-07-31 14:30:00 +0200
committerHimbeer <himbeer@disroot.org>2024-07-31 14:30:00 +0200
commit5e530b1783fae0c24a0d8998c88670d6ab835897 (patch)
tree5360ab0bd8e57893f5aa70d7df1024cba8cafc7c
parent7837f7c2c3a8d662db44bbf89f6b9c62fc948111 (diff)
root: Add launch syscall
-rw-r--r--src/root.zig12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/root.zig b/src/root.zig
index 5063e4e..0fd09ad 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -11,7 +11,7 @@ const Result = struct {
error_code: usize,
};
-const Error = error{Kernel};
+const SyscallError = error{Kernel};
fn ecall(number: usize, args: anytype) Result {
comptime var registers = [max_args]usize{0};
@@ -45,12 +45,18 @@ pub fn errorName(code: u16, buffer: []u8) !usize {
buffer.ptr,
buffer.len,
});
- if (result.error_code != 0) return Error.Kernel;
+ if (result.error_code != 0) return SyscallError.Kernel;
return result.value;
}
pub fn consoleWrite(bytes: []const u8) !usize {
const result = ecall(100001, .{ bytes.ptr, bytes.len });
- if (result.error_code != 0) return Error.Kernel;
+ if (result.error_code != 0) return SyscallError.Kernel;
+ return result.value;
+}
+
+pub fn launch(bytes: []align(@alignOf(std.elf.Elf64_Ehdr)) const u8) !usize {
+ const result = ecall(100002, .{ bytes.ptr, bytes.len });
+ if (result.error_code != 0) return SyscallError.Kernel;
return result.value;
}