aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/sysexchange.zig156
1 files changed, 156 insertions, 0 deletions
diff --git a/src/lib/sysexchange.zig b/src/lib/sysexchange.zig
index 0abf7bc..b018cd6 100644
--- a/src/lib/sysexchange.zig
+++ b/src/lib/sysexchange.zig
@@ -8,10 +8,114 @@ const trap = @import("trap.zig");
pub const Status = enum(usize) {
success = 0,
+ hart_id_out_of_range,
+ no_cpus_hw_info,
+ no_tar_file_initializer,
+ no_console,
+ empty_schedule,
+ no_init,
+ too_many_threads,
+ too_many_resource_descriptors,
+ bad_rd_handle,
+ bad_endian,
+ bad_arch,
+ bad_bit_len,
+ not_static_exe,
+ size_mismatch,
+ mem_overrun,
+ branch_perms,
+ zero_size,
+ out_of_memory,
+ out_of_range,
+ double_free,
+ already_taken,
+ not_a_leaf,
+ no_plic,
+ plic_incompatible,
+ no_plic_reg,
+ interrupt_out_of_range,
+ context_out_of_range,
+ unimplemented,
+ unknown_syscall,
+ no_pci_controller,
+ sbi_failed,
+ sbi_not_supported,
+ sbi_invalid_param,
+ sbi_denied,
+ sbi_invalid_addr,
+ sbi_already_avail,
+ sbi_already_started,
+ sbi_already_stopped,
+ sbi_no_shared_mem,
+ sbi_unknown,
+ hwi_missing_kind,
+ hwi_missing_reg_addr,
+ hwi_missing_reg_len,
+ hwi_unknown_dev_kind,
+ not_found,
+ relative_path_not_allowed,
+ not_a_directory,
+ no_absolute_containing_directory,
+ too_many_references,
+ read_not_supported,
+ write_not_supported,
+ in_use,
unknown = std.math.maxInt(usize),
pub fn fromError(err: anyerror) Status {
return switch (err) {
+ error.HartIdOutOfRange => .hart_id_out_of_range,
+ error.NoCpusHwInfo => .no_cpus_hw_info,
+ error.NoTarFileInitializer => .no_tar_file_initializer,
+ error.NoConsole => .no_console,
+ error.EmptySchedule => .empty_schedule,
+ error.NoInit => .no_init,
+ error.TooManyThreads => .too_many_threads,
+ error.TooManyResourceDescriptors => .too_many_resource_descriptors,
+ error.BadRdHandle => .bad_rd_handle,
+ error.BadEndian => .bad_endian,
+ error.BadArch => .bad_arch,
+ error.BadBitLen => .bad_bit_len,
+ error.NotStaticExe => .not_static_exe,
+ error.SizeMismatch => .size_mismatch,
+ error.MemOverrun => .mem_overrun,
+ error.BranchPerms => .branch_perms,
+ error.ZeroSize => .zero_size,
+ error.OutOfMemory => .out_of_memory,
+ error.OutOfRange => .out_of_range,
+ error.DoubleFree => .double_free,
+ error.AlreadyTaken => .already_taken,
+ error.NotALeaf => .not_a_leaf,
+ error.NoPlic => .no_plic,
+ error.PlicIncompatible => .plic_incompatible,
+ error.NoPlicReg => .no_plic_reg,
+ error.InterruptOutOfRange => .interrupt_out_of_range,
+ error.ContextOutOfRange => .context_out_of_range,
+ error.Unimplemented => .unimplemented,
+ error.UnknownSyscall => .unknown_syscall,
+ error.NoPciController => .no_pci_controller,
+ error.Failed => .sbi_failed,
+ error.NotSupported => .sbi_not_supported,
+ error.InvalidParam => .sbi_invalid_param,
+ error.Denied => .sbi_denied,
+ error.InvalidAddr => .sbi_invalid_addr,
+ error.AlreadyAvail => .sbi_already_avail,
+ error.AlreadyStarted => .sbi_already_started,
+ error.AlreadyStopped => .sbi_already_stopped,
+ error.NoSharedMem => .sbi_no_shared_mem,
+ error.Unknown => .sbi_unknown,
+ error.MissingKind => .hwi_missing_kind,
+ error.MissingRegAddr => .hwi_missing_reg_addr,
+ error.MissingRegLen => .hwi_missing_reg_len,
+ error.UnknownDevKind => .hwi_unknown_dev_kind,
+ error.NotFound => .not_found,
+ error.RelativePathNotAllowed => .relative_path_not_allowed,
+ error.NotADirectory => .not_a_directory,
+ error.NoAbsoluteContainingDirectory => .no_absolute_containing_directory,
+ error.TooManyReferences => .too_many_references,
+ error.ReadNotSupported => .read_not_supported,
+ error.WriteNotSupported => .write_not_supported,
+ error.InUse => .in_use,
else => .unknown,
};
}
@@ -21,6 +125,58 @@ pub const Status = enum(usize) {
pub fn toError(self: Status) anyerror {
return switch (self) {
.success => unreachable,
+ .hart_id_out_of_range => error.HartIdOutOfRange,
+ .no_cpus_hw_info => error.NoCpusHwInfo,
+ .no_tar_file_initializer => error.NoTarFileInitializer,
+ .no_console => error.NoConsole,
+ .empty_schedule => error.EmptySchedule,
+ .no_init => error.NoInit,
+ .too_many_threads => error.TooManyThreads,
+ .too_many_resource_descriptors => error.TooManyResourceDescriptors,
+ .bad_rd_handle => error.BadRdHandle,
+ .bad_endian => error.BadEndian,
+ .bad_arch => error.BadArch,
+ .bad_bit_len => error.BadBitLen,
+ .not_static_exe => error.NotStaticExe,
+ .size_mismatch => error.SizeMismatch,
+ .mem_overrun => error.MemOverrun,
+ .branch_perms => error.BranchPerms,
+ .zero_size => error.ZeroSize,
+ .out_of_memory => error.OutOfMemory,
+ .out_of_range => error.OutOfRange,
+ .double_free => error.DoubleFree,
+ .already_taken => error.AlreadyTaken,
+ .not_a_leaf => error.NotALeaf,
+ .no_plic => error.NoPlic,
+ .plic_incompatible => error.PlicIncompatible,
+ .no_plic_reg => error.NoPlicReg,
+ .interrupt_out_of_range => error.InterruptOutOfRange,
+ .context_out_of_range => error.ContextOutOfRange,
+ .unimplemented => error.Unimplemented,
+ .unknown_syscall => error.UnknownSyscall,
+ .no_pci_controller => error.NoPciController,
+ .sbi_failed => error.Failed,
+ .sbi_not_supported => error.NotSupported,
+ .sbi_invalid_param => error.InvalidParam,
+ .sbi_denied => error.Denied,
+ .sbi_invalid_addr => error.InvalidAddr,
+ .sbi_already_avail => error.AlreadyAvail,
+ .sbi_already_started => error.AlreadyStarted,
+ .sbi_already_stopped => error.AlreadyStopped,
+ .sbi_no_shared_mem => error.NoSharedMem,
+ .sbi_unknown => error.Unknown,
+ .hwi_missing_kind => error.MissingKind,
+ .hwi_missing_reg_addr => error.MissingRegAddr,
+ .hwi_missing_reg_len => error.MissingRegLen,
+ .hwi_unknown_dev_kind => error.UnknownDevKind,
+ .not_found => error.NotFound,
+ .relative_path_not_allowed => error.RelativePathNotAllowed,
+ .not_a_directory => error.NotADirectory,
+ .no_absolute_containing_directory => error.NoAbsoluteContainingDirectory,
+ .too_many_references => error.TooManyReferences,
+ .read_not_supported => error.ReadNotSupported,
+ .write_not_supported => error.WriteNotSupported,
+ .in_use => error.InUse,
.unknown => error.Unknown,
};
}