From 706f2c1c5deb9e5306630181d516ac1b534baacc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 16 Mar 2022 01:12:07 -0400 Subject: [PATCH] HEL: Call ExitBootServices --- src/hel/hel.d | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/hel/hel.d b/src/hel/hel.d index 78d03af..7d4f9d8 100644 --- a/src/hel/hel.d +++ b/src/hel/hel.d @@ -38,7 +38,7 @@ private bool set_graphics_mode() &gop_guid, null, &buffer_size, handles); if (status != EFI_SUCCESS) { - writeln("LocateHandle: error %u", status); + writeln("LocateHandle: error %x", status); return false; } EFI_HANDLE gop_handle = handles[0]; @@ -47,7 +47,7 @@ private bool set_graphics_mode() &gop_guid, &gop_interface); if (status != EFI_SUCCESS) { - writeln("HandleProtocol: error %u", status); + writeln("HandleProtocol: error %x", status); return false; } if (gop_interface == null) @@ -74,7 +74,7 @@ private bool set_graphics_mode() } if ((status = gop.SetMode(gop, best_mode_number)) != EFI_SUCCESS) { - writeln("SetMode: Error %u\n", status); + writeln("SetMode: Error %x\n", status); return false; } bootinfo.fb.buffer = cast(uint *)gop.Mode.FrameBufferBase; @@ -98,6 +98,7 @@ private bool get_memory_map() &descriptor_version); if (status != EFI_SUCCESS) { + writeln("GetMemoryMap: Error %x", status); return false; } size_t n_entries = memory_map_size / descriptor_size; @@ -133,9 +134,23 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st) return EFI_SUCCESS; } - get_memory_map(); + for (;;) + { + get_memory_map(); - wait_key(); + EFI_STATUS status = st.BootServices.ExitBootServices(image_handle, memory_map_key); + if ((status & 0xFFu) == (EFI_INVALID_PARAMETER & 0xFFu)) + { + continue; + } + if (status == EFI_SUCCESS) + { + break; + } + writeln("ExitBootServices: Error %x", status); + wait_key(); + return EFI_SUCCESS; + } return EFI_SUCCESS; }