aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+}