add-Exit - Add Exit() library function which calls BS->Exit()

Signed-off-by: Jonathon Reinhart <jonathon.reinhart@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
This commit is contained in:
Nigel Croxon 2017-02-17 16:30:28 -05:00
parent 787cb7fcd8
commit 3f8935c3d0
7 changed files with 47 additions and 1 deletions

12
apps/exit.c Normal file
View File

@ -0,0 +1,12 @@
#include <efi.h>
#include <efilib.h>
EFI_STATUS
efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
{
InitializeLib(image_handle, systab);
Exit(EFI_SUCCESS, 0, NULL);
return EFI_UNSUPPORTED;
}

View File

@ -208,6 +208,13 @@ EFIDebugVariable (
VOID
);
VOID
Exit(
IN EFI_STATUS ExitStatus,
IN UINTN ExitDataSize,
IN CHAR16 *ExitData OPTIONAL
);
INTN
GetShellArgcArgv(
EFI_HANDLE ImageHandle,

View File

@ -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

View File

@ -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
//

19
lib/exit.c Normal file
View File

@ -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 (;;) { }
}

View File

@ -49,6 +49,8 @@ Returns:
if (!LibInitialized) {
LibInitialized = TRUE;
LibFwInstance = FALSE;
LibImageHandle = ImageHandle;
//
// Set up global pointer to the system table, boot services table,

View File

@ -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;