From 286f0de74c81e209b2cef628c06202ec722cf82f Mon Sep 17 00:00:00 2001 From: qwang12 Date: Mon, 1 Sep 2008 06:15:02 +0000 Subject: [PATCH] 1) Remove the hard-code length before building FRAMEWORK_EFI_IFR_DATA_ARRAY. 2) Support data type of EFI_IFR_TYPE_STRING when building FRAMEWORK_EFI_IFR_DATA_ARRAY. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5760 6f19259b-4bc3-4df7-8a09-765794883524 --- .../FrameworkHiiToUefiHiiThunk/ConfigAccess.c | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c index b5f4bf4bc0..b1f3651240 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c @@ -1,3 +1,4 @@ + /**@file This file contains functions related to Config Access Protocols installed by by HII Thunk Modules which is used to thunk UEFI Config Access Callback to @@ -644,13 +645,47 @@ CreateIfrDataArray ( BUFFER_STORAGE_ENTRY *BufferStorageEntry; LIST_ENTRY *Link; EFI_STATUS Status; + UINTN Size; + UINTN StringSize; + EFI_STRING String; + + String = NULL; Link = GetFirstNode (&ConfigAccess->BufferStorageListHead); if (IsNull (&ConfigAccess->BufferStorageListHead, Link)) { return NULL; } - - IfrDataArray = AllocateZeroPool (0x100); + + switch (Type) { + case EFI_IFR_TYPE_NUM_SIZE_8: + case EFI_IFR_TYPE_NUM_SIZE_16: + case EFI_IFR_TYPE_NUM_SIZE_32: + case EFI_IFR_TYPE_NUM_SIZE_64: + case EFI_IFR_TYPE_BOOLEAN: + Size = sizeof (*Value); + break; + + case EFI_IFR_TYPE_STRING: + StringSize = 0; + Status = HiiLibGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, String, &StringSize); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + + String = AllocateZeroPool (StringSize); + ASSERT (String != NULL); + + Status = HiiLibGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, String, &StringSize); + ASSERT_EFI_ERROR (Status); + + Size = StringSize; + break; + + default: + ASSERT (FALSE); + Size = 0; + break; + } + + IfrDataArray = AllocateZeroPool (sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY) + sizeof (FRAMEWORK_EFI_IFR_DATA_ENTRY) + Size); ASSERT (IfrDataArray != NULL); BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link); @@ -678,6 +713,11 @@ CreateIfrDataArray ( CopyMem (&IfrDataEntry->Data, &(Value->u8), sizeof (*Value)); break; + case EFI_IFR_TYPE_STRING: + ASSERT (String != NULL); + StrCpy ((CHAR16 *) &IfrDataEntry->Data, String); + FreePool (String); + break; default: ASSERT (FALSE); break;