From 0e7bfce8d0dc29695d0eb141f16e7976abcc5486 Mon Sep 17 00:00:00 2001 From: xli24 Date: Thu, 11 Jan 2007 06:37:39 +0000 Subject: BDS code calls Hii->FindHandles() with hardcoded length. New code provides function BdsLibGetHiiHandles() in generic BDS library, which detects actual necessary memory, allocates memory, and finds handles as output. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2216 6f19259b-4bc3-4df7-8a09-765794883524 --- EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c | 13 +++++++------ .../Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c | 9 +++++++-- EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c | 9 +++++---- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'EdkNt32Pkg/Dxe') diff --git a/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c b/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c index 6f46386621..b4f6d481ce 100644 --- a/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c +++ b/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c @@ -464,8 +464,12 @@ Returns: EFI_GUID HiiGuid; EFI_HII_PROTOCOL *Hii; - HandleBufferLength = 0x1000; + // + // Initialize params. + // + HandleBufferLength = 0; HiiHandleBuffer = NULL; + Status = gBS->LocateProtocol ( &gEfiHiiProtocolGuid, NULL, @@ -478,12 +482,9 @@ Returns: // // Get all the Hii handles // - HiiHandleBuffer = AllocateZeroPool (HandleBufferLength); - ASSERT (HiiHandleBuffer != NULL); - - Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer); + Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer); ASSERT_EFI_ERROR (Status); - + // // Get the Hii Handle that matches the StructureNode->ProducerName // diff --git a/EdkNt32Pkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c b/EdkNt32Pkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c index c186fee9a3..2da9c6fa36 100644 --- a/EdkNt32Pkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c +++ b/EdkNt32Pkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c @@ -201,6 +201,7 @@ Returns: IfrOptionList = NULL; VideoOption = NULL; + HiiHandles = NULL; HandleBufferLength = 0; // @@ -268,8 +269,11 @@ Returns: CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data); Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData); - HiiHandles = AllocateZeroPool (HandleBufferLength); - Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles); + // + // Get all the Hii handles + // + Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandles); + ASSERT_EFI_ERROR (Status); for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) { // @@ -487,6 +491,7 @@ Returns: } gBS->FreePool (UpdateData); + gBS->FreePool (HiiHandles); return Status; } diff --git a/EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c b/EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c index a31e8a9570..c659384d4d 100644 --- a/EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c +++ b/EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c @@ -485,15 +485,16 @@ Returns: UINT16 Length; EFI_GUID HiiGuid; - HandleBufferLength = 0x1000; + // + // Initialize params. + // + HandleBufferLength = 0; HiiHandleBuffer = NULL; // // Get all the Hii handles // - HiiHandleBuffer = AllocateZeroPool (HandleBufferLength); - - Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer); + Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer); ASSERT_EFI_ERROR (Status); // -- cgit v1.2.3