Эх сурвалжийг харах

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>
Nigel Croxon 8 жил өмнө
parent
commit
3f8935c3d0
7 өөрчлөгдсөн 47 нэмэгдсэн , 1 устгасан
  1. 12 0
      apps/exit.c
  2. 7 0
      inc/efilib.h
  3. 1 1
      lib/Makefile
  4. 5 0
      lib/data.c
  5. 19 0
      lib/exit.c
  6. 2 0
      lib/init.c
  7. 1 0
      lib/lib.h

+ 12 - 0
apps/exit.c

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

+ 7 - 0
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,

+ 1 - 1
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

+ 5 - 0
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
 //

+ 19 - 0
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 (;;) { }
+}

+ 2 - 0
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,

+ 1 - 0
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;