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 --- EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'EdkUnixPkg/Library') diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c index 659bdc666d..6b4d1aa149 100644 --- a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c +++ b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c @@ -976,3 +976,56 @@ Returns: } } } + +EFI_STATUS +BdsLibGetHiiHandles ( + IN EFI_HII_PROTOCOL *Hii, + IN OUT UINT16 *HandleBufferLength, + OUT EFI_HII_HANDLE **HiiHandleBuffer + ) +/*++ + +Routine Description: + + Determines the handles that are currently active in the database. + It's the caller's responsibility to free handle buffer. + +Arguments: + + This - A pointer to the EFI_HII_PROTOCOL instance. + HandleBufferLength - On input, a pointer to the length of the handle buffer. On output, + the length of the handle buffer that is required for the handles found. + HiiHandleBuffer - Pointer to an array of EFI_HII_PROTOCOL instances returned. + +Returns: + + EFI_SUCCESS - Get an array of EFI_HII_PROTOCOL instances successfully. + EFI_INVALID_PARAMETER - Hii is NULL. + EFI_NOT_FOUND - Database not found. + +--*/ +{ + UINT16 TempBufferLength; + EFI_STATUS Status; + + TempBufferLength = 0; + + // + // Try to find the actual buffer size for HiiHandle Buffer. + // + Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer); + + if (Status == EFI_BUFFER_TOO_SMALL) { + *HiiHandleBuffer = AllocateZeroPool (TempBufferLength); + Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer); + // + // we should not fail here. + // + ASSERT_EFI_ERROR (Status); + } + + *HandleBufferLength = TempBufferLength; + + return Status; + +} -- cgit v1.2.3