diff --git a/apps/exit.c b/apps/exit.c new file mode 100644 index 0000000..78b94a5 --- /dev/null +++ b/apps/exit.c @@ -0,0 +1,12 @@ +#include +#include + +EFI_STATUS +efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) +{ + InitializeLib(image_handle, systab); + + Exit(EFI_SUCCESS, 0, NULL); + + return EFI_UNSUPPORTED; +} diff --git a/inc/efilib.h b/inc/efilib.h index cd5d9ae..22da65b 100644 --- a/inc/efilib.h +++ b/inc/efilib.h @@ -208,6 +208,13 @@ EFIDebugVariable ( VOID ); +VOID +Exit( + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ); + INTN GetShellArgcArgv( EFI_HANDLE ImageHandle, diff --git a/lib/Makefile b/lib/Makefile index 4b1cfec..a687495 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -44,7 +44,7 @@ TOPDIR = $(SRCDIR)/.. CDIR = $(TOPDIR)/.. FILES = boxdraw smbios console crc data debug dpath \ - error event guid hand hw init lock \ + error event exit guid hand hw init lock \ misc print sread str cmdline \ runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata \ $(ARCH)/initplat $(ARCH)/math $(ARCH)/setjmp diff --git a/lib/data.c b/lib/data.c index d660c8c..5b4f3b5 100644 --- a/lib/data.c +++ b/lib/data.c @@ -24,6 +24,11 @@ Revision History BOOLEAN LibInitialized = FALSE; +// +// ImageHandle - Current ImageHandle, as passed to InitializeLib +// +EFI_HANDLE LibImageHandle; + // // ST - pointer to the EFI system table // diff --git a/lib/exit.c b/lib/exit.c new file mode 100644 index 0000000..ada27c9 --- /dev/null +++ b/lib/exit.c @@ -0,0 +1,19 @@ +#include "lib.h" + +VOID +Exit( + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ) +{ + uefi_call_wrapper(BS->Exit, + 4, + LibImageHandle, + ExitStatus, + ExitDataSize, + ExitData); + + // Uh oh, Exit() returned?! + for (;;) { } +} diff --git a/lib/init.c b/lib/init.c index fa6f893..4225d31 100644 --- a/lib/init.c +++ b/lib/init.c @@ -49,6 +49,8 @@ Returns: if (!LibInitialized) { LibInitialized = TRUE; LibFwInstance = FALSE; + LibImageHandle = ImageHandle; + // // Set up global pointer to the system table, boot services table, diff --git a/lib/lib.h b/lib/lib.h index 10e9391..e8332df 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -81,6 +81,7 @@ LibDuplicateDevicePathInstance ( // extern BOOLEAN LibInitialized; extern BOOLEAN LibFwInstance; +extern EFI_HANDLE LibImageHandle; extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut; extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface; extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface;