aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-07-31 14:20:58 +0200
committerHimbeer <himbeer@disroot.org>2024-07-31 14:20:58 +0200
commit9e3eaed167665c47c61ee5b8a2ddaea5116b5b67 (patch)
treeca1bc4381a350a86840191d03388efe04c69bb1d
parent2fa9f57e125912672ec24514d9cc8e71f9e0fea7 (diff)
root: Add errorName syscall
-rw-r--r--src/root.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index 7a8ce3a..c5625d0 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -11,6 +11,8 @@ const Result = struct {
error_code: usize,
};
+const Error = error{Kernel};
+
fn ecall(number: usize, args: anytype) Result {
comptime var registers = [max_args]usize{0};
inline for (args, 0..) |arg, i| {
@@ -36,3 +38,13 @@ fn ecall(number: usize, args: anytype) Result {
);
return result;
}
+
+pub fn errorName(code: u16, buffer: []u8) !usize {
+ const result = ecall(100000, .{
+ code,
+ buffer.ptr,
+ buffer.len,
+ });
+ if (result.error_code != 0) return Error.Kernel;
+ return result.value;
+}