aboutsummaryrefslogtreecommitdiff
path: root/std/os.zig
diff options
context:
space:
mode:
authorNick Erdmann <n@nirf.de>2019-07-28 23:51:51 +0200
committerNick Erdmann <n@nirf.de>2019-08-04 21:53:49 +0200
commitb979fc1bcd6d1bdc19b7f518498fb8c9740d6dea (patch)
treed9b04d1e688dde7c08a50544a953042f369b7a9f /std/os.zig
parent6e8ef5b6f2205ada3f2c1b4769aefdfc61aca39e (diff)
downloadzig-b979fc1bcd6d1bdc19b7f518498fb8c9740d6dea.tar.gz
zig-b979fc1bcd6d1bdc19b7f518498fb8c9740d6dea.zip
initial work torwards std lib support for uefi
Diffstat (limited to 'std/os.zig')
-rw-r--r--std/os.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/std/os.zig b/std/os.zig
index 190f02101e..9e3a6d3cb7 100644
--- a/std/os.zig
+++ b/std/os.zig
@@ -155,8 +155,7 @@ pub fn abort() noreturn {
system.abort();
}
if (builtin.os == .uefi) {
- // TODO there must be a better thing to do here than loop forever
- while (true) {}
+ exit(0); // TODO choose appropriate exit code
}
raise(SIGABRT) catch {};
@@ -228,6 +227,15 @@ pub fn exit(status: u8) noreturn {
if (linux.is_the_target and !builtin.single_threaded) {
linux.exit_group(status);
}
+ if (uefi.is_the_target) {
+ // exit() is only avaliable if exitBootServices() has not been called yet.
+ // This call to exit should not fail, so we don't care about its return value.
+ if (uefi.system_table.boot_services) |bs| {
+ _ = bs.exit(uefi.handle, status, 0, null);
+ }
+ // If we can't exit, reboot the system instead.
+ uefi.system_table.runtime_services.resetSystem(uefi.tables.ResetType.ResetCold, status, 0, null);
+ }
system.exit(status);
}