From e7e0e42baca19cf7e5a7d2ac5574f97c0ecaf134 Mon Sep 17 00:00:00 2001 From: Chris Phillips Date: Tue, 19 Aug 2014 23:15:22 +0000 Subject: ShellPkg: Move mHandleParsingHiiHandle init out of the constructor Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips Signed-off-by: Eugene Cohen Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15841 6f19259b-4bc3-4df7-8a09-765794883524 --- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index f361f3a274..acc8a29796 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -16,7 +16,7 @@ #include "UefiHandleParsingLib.h" #include "IndustryStandard/Acpi10.h" -EFI_HANDLE mHandleParsingHiiHandle; +EFI_HANDLE mHandleParsingHiiHandle = NULL; HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0}; GUID_INFO_BLOCK *GuidList; UINTN GuidListCount; @@ -102,12 +102,23 @@ HandleParsingLibConstructor ( GuidListCount = 0; GuidList = NULL; - mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL); + // + // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed. + // + return (EFI_SUCCESS); +} + +/** + Initialization function for HII packages. + +**/ +VOID +HandleParsingHiiInit (VOID) +{ if (mHandleParsingHiiHandle == NULL) { - return (EFI_DEVICE_ERROR); + mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL); + ASSERT (mHandleParsingHiiHandle != NULL); } - - return (EFI_SUCCESS); } /** @@ -166,6 +177,8 @@ LoadedImageProtocolDumpInformation( return (CatSPrint(NULL, L"LoadedImage")); } + HandleParsingHiiInit(); + Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL); RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize)); if (Temp == NULL || RetVal == NULL) { @@ -242,6 +255,8 @@ GraphicsOutputProtocolDumpInformation( return (CatSPrint(NULL, L"GraphicsOutput")); } + HandleParsingHiiInit(); + Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL); RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize)); if (Temp == NULL || RetVal == NULL) { @@ -322,6 +337,8 @@ PciRootBridgeIoDumpInformation( return (CatSPrint(NULL, L"PciRootBridgeIo")); } + HandleParsingHiiInit(); + Status = gBS->HandleProtocol( TheHandle, &gEfiPciRootBridgeIoProtocolGuid, @@ -445,6 +462,8 @@ TxtOutProtocolDumpInformation( return (NULL); } + HandleParsingHiiInit(); + RetVal = NULL; Size = 0; @@ -883,6 +902,8 @@ AddNewGuidNameMapping( CONST GUID_INFO_BLOCK *Temp; EFI_STRING_ID NameID; + HandleParsingHiiInit(); + if (Guid == NULL || TheName == NULL){ return (EFI_INVALID_PARAMETER); } @@ -919,6 +940,8 @@ GetStringNameFromGuid( { CONST GUID_INFO_BLOCK *Id; + HandleParsingHiiInit(); + Id = InternalShellGetNodeFromGuid(Guid); return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang)); } @@ -986,6 +1009,8 @@ GetGuidFromStringName( CHAR16 *String; UINTN LoopCount; + HandleParsingHiiInit(); + ASSERT(Guid != NULL); if (Guid == NULL) { return (EFI_INVALID_PARAMETER); -- cgit v1.2.3