Commit 9720bade7a
lib/std/os/uefi.zig
@@ -7,6 +7,7 @@ pub const hii = @import("uefi/hii.zig");
/// Status codes returned by EFI interfaces
pub const Status = @import("uefi/status.zig").Status;
+pub const Error = UnexpectedError || Status.Error;
pub const tables = @import("uefi/tables.zig");
/// The memory type to allocate when using the pool.
lib/std/start.zig
@@ -211,13 +211,24 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
root.main();
return 0;
},
- usize => {
- return root.main();
- },
uefi.Status => {
return @intFromEnum(root.main());
},
- else => @compileError("expected return type of main to be 'void', 'noreturn', 'usize', or 'std.os.uefi.Status'"),
+ uefi.Error!void => {
+ root.main() catch |err| switch (err) {
+ error.Unexpected => @panic("EfiMain: unexpected error"),
+ else => {
+ const status = uefi.Status.fromError(@errorCast(err));
+ return @intFromEnum(status);
+ },
+ };
+
+ return 0;
+ },
+ else => @compileError(
+ "expected return type of main to be 'void', 'noreturn', " ++
+ "'uefi.Status', or 'uefi.Error!void'",
+ ),
}
}