diff options
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.c | 44 | ||||
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.h | 2 | ||||
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.inf | 4 |
3 files changed, 50 insertions, 0 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 8c4eb9c..bfe75ba 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -5,6 +5,9 @@ #include <Library/UefiLib.h> #include <Library/UefiBootServicesTableLib.h> +#include <Library/HiiLib.h> +#include <Library/UefiHiiServicesLib.h> + #include "UefiMonitorTest.h" #include "MainMenu.h" @@ -12,6 +15,41 @@ STATIC CONST UMT_STATE_ACTIONS mStateActions[UMT_STATE_END] = { { MainMenuInit, MainMenuDoit, MainMenuTip, MainMenuKeyRight, MainMenuKeyLeft } }; +EFI_HII_HANDLE gUmtHiiHandle = NULL; + +STATIC +EFI_STATUS +RegisterHiiPackage ( + IN EFI_HANDLE ImageHandle, + OUT EFI_HII_HANDLE *HiiHandle + ) +{ + EFI_STATUS Status; + EFI_HII_PACKAGE_LIST_HEADER *PackageList; + + // Retrieve HII package list from ImageHandle + Status = gBS->OpenProtocol ( + ImageHandle, + &gEfiHiiPackageListProtocolGuid, + (VOID **)&PackageList, + ImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to open EFI_HII_PACKAGE_LIST_PROTOCOL\n")); + return Status; + } + + Status = gHiiDatabase->NewPackageList(gHiiDatabase, PackageList, NULL, HiiHandle); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add HII Package list to HII database: %r\n", Status)); + return Status; + } + + return Status; +} + STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL * GetGraphicsOutputProtocol ( @@ -90,6 +128,12 @@ UefiMain ( Status = EFI_SUCCESS; + Status = RegisterHiiPackage (ImageHandle, &gUmtHiiHandle); + if (EFI_ERROR(Status)) { + Print (L"Error: Failed to register HII Package list\n"); + return Status; + } + Gop = GetGraphicsOutputProtocol (); if (Gop == NULL) { Print (L"Error: Getting a Graphical Output Protocol is failed\n"); diff --git a/UefiMonitorTest/UefiMonitorTest.h b/UefiMonitorTest/UefiMonitorTest.h index 6c7e0ed..66aaee9 100644 --- a/UefiMonitorTest/UefiMonitorTest.h +++ b/UefiMonitorTest/UefiMonitorTest.h @@ -28,4 +28,6 @@ struct _UMT_CONTEXT { GRAPHICS_CONTEXT *Graphics; }; +extern EFI_HII_HANDLE gUmtHiiHandle; + #endif /* UEFI_MONITOR_TEST_H */ diff --git a/UefiMonitorTest/UefiMonitorTest.inf b/UefiMonitorTest/UefiMonitorTest.inf index df169d9..5492350 100644 --- a/UefiMonitorTest/UefiMonitorTest.inf +++ b/UefiMonitorTest/UefiMonitorTest.inf @@ -5,6 +5,7 @@ MODULE_TYPE = UEFI_APPLICATION VERSION_STRING = 1.0 ENTRY_POINT = UefiMain + UEFI_HII_RESOURCE_SECTION = TRUE [Sources] UefiMonitorTest.c @@ -18,15 +19,18 @@ [LibraryClasses] BaseLib DebugLib + HiiLib MemoryAllocationLib PcdLib PrintLib UefiApplicationEntryPoint UefiBootServicesTableLib + UefiHiiServicesLib UefiLib UefiRuntimeServicesTableLib [Protocols] + gEfiHiiPackageListProtocolGuid gEfiSimplePointerProtocolGuid gEfiSimpleTextInputExProtocolGuid |