From d91c7bf9e42e8be23bb67bf7c189348b4ec11797 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Fri, 17 Apr 2009 05:28:31 +0000 Subject: [PATCH] Update HiiLib to copy all IfrOpcode, not Opcode by Opcode. Update DriverSampleDxe to use new UEFI 2.1 classguid git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8114 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 34 +++++++++---------- .../Universal/DriverSampleDxe/NVDataStruc.h | 2 ++ .../Universal/DriverSampleDxe/Vfr.vfr | 9 +++-- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index e1d8a64730..d36828a115 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -2191,8 +2191,7 @@ InternalHiiUpdateFormPackageData ( BOOLEAN GetFormSet; BOOLEAN GetForm; BOOLEAN Updated; - EFI_IFR_OP_HEADER *AddOpCode; - UINT32 UpdatePackageLength; + UINTN UpdatePackageLength; CopyMem (TempPackage, Package, sizeof (EFI_HII_PACKAGE_HEADER)); UpdatePackageLength = sizeof (EFI_HII_PACKAGE_HEADER); @@ -2230,7 +2229,7 @@ InternalHiiUpdateFormPackageData ( // // The matched Form is found, and Update data in this form // - if (GetFormSet && GetForm && !Updated) { + if (GetFormSet && GetForm) { UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer; if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \ (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) { @@ -2263,22 +2262,14 @@ InternalHiiUpdateFormPackageData ( return EFI_NOT_FOUND; } } + // // Insert the updated data // - UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer; - AddSize = UpdateIfrOpHdr->Length; - AddOpCode = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + AddSize); - while (AddSize < OpCodeBufferStart->Position) { - CopyMem (BufferPos, AddOpCode, AddOpCode->Length); - BufferPos += AddOpCode->Length; - UpdatePackageLength += AddOpCode->Length; - - AddSize += AddOpCode->Length; - AddOpCode = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + AddSize); - } - - ASSERT (AddSize == OpCodeBufferStart->Position); + AddSize = ((EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer)->Length; + CopyMem (BufferPos, OpCodeBufferStart->Buffer + AddSize, OpCodeBufferStart->Position - AddSize); + BufferPos += OpCodeBufferStart->Position - AddSize; + UpdatePackageLength += OpCodeBufferStart->Position - AddSize; if (OpCodeBufferEnd != NULL) { // @@ -2288,10 +2279,19 @@ InternalHiiUpdateFormPackageData ( BufferPos += IfrOpHdr->Length; UpdatePackageLength += IfrOpHdr->Length; } + + // + // Copy the left package data. + // + Offset += IfrOpHdr->Length; + CopyMem (BufferPos, (UINT8 *) Package + Offset, PackageHeader.Length - Offset); + UpdatePackageLength += PackageHeader.Length - Offset; + // // Set update flag // Updated = TRUE; + break; } } @@ -2311,7 +2311,7 @@ InternalHiiUpdateFormPackageData ( // // Update the package length. // - PackageHeader.Length = UpdatePackageLength; + PackageHeader.Length = (UINT32) UpdatePackageLength; CopyMem (TempPackage, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER)); return EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h index 162c5ecd1f..0a5d46bc96 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -25,6 +25,8 @@ Revision History: #ifndef _NVDATASTRUC_H_ #define _NVDATASTRUC_H_ +#include + #define FORMSET_GUID \ { \ 0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D} \ diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index fc6b5da766..71a4c91057 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -51,11 +51,10 @@ #define LABEL_UPDATE_BBS 0x2222 formset - guid = FORMSET_GUID, - title = STRING_TOKEN(STR_FORM_SET_TITLE), - help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP), - class = EFI_ON_BOARD_DEVICE_CLASS, - subclass = EFI_SETUP_APPLICATION_SUBCLASS, + guid = FORMSET_GUID, + title = STRING_TOKEN(STR_FORM_SET_TITLE), + help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP), + classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID, // // Notes: VfrCompiler will insert a Standard Default Storage declaration