X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FUefiHiiLib%2FHiiLib.c;h=a2abf26980b9ddaec07cdced210fbe68dd3b93b0;hp=7e93df9adadbdd9f17561e5ad44e754f669fc249;hb=16f6922709952c7ad468dcdee6ef94b3e5a3cd90;hpb=81b618fe85f67f70a81d38a968cb5eca719e64d9 diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index 7e93df9ada..a2abf26980 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -1,7 +1,7 @@ /** @file HII Library implementation that uses DXE protocols and services. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -31,6 +31,11 @@ typedef struct { UINT8 Scope; } IFR_BLOCK_DATA; +typedef struct { + EFI_VARSTORE_ID VarStoreId; + UINT16 Size; +} IFR_VARSTORAGE_DATA; + // // Template // @@ -129,7 +134,7 @@ InternalHiiExtractGuidFromHiiHandle ( to packages terminated by a NULL. @retval NULL A HII Handle has already been registered in the HII Database with - the same PackageListGuid. + the same PackageListGuid and DeviceHandle. @retval NULL The HII Handle could not be created. @retval NULL An empty list of packages was passed in. @retval NULL All packages are empty. @@ -372,6 +377,127 @@ HiiGetHiiHandles ( } } +/** + This function allows a caller to extract the form set opcode form the Hii Handle. + The returned buffer is allocated using AllocatePool().The caller is responsible + for freeing the allocated buffer using FreePool(). + + @param Handle The HII handle. + @param Buffer On return, points to a pointer which point to the buffer that contain the formset opcode. + @param BufferSize On return, points to the length of the buffer. + + @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated. + @retval EFI_NOT_FOUND Can't find the package data for the input Handle. + @retval EFI_INVALID_PARAMETER The input parameters are not correct. + @retval EFI_SUCCESS Get the formset opcode from the hii handle successfully. + +**/ +EFI_STATUS +EFIAPI +HiiGetFormSetFromHiiHandle( + IN EFI_HII_HANDLE Handle, + OUT EFI_IFR_FORM_SET **Buffer, + OUT UINTN *BufferSize + ) +{ + EFI_STATUS Status; + UINTN PackageListSize; + UINTN TempSize; + EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList; + UINT8 *Package; + UINT8 *OpCodeData; + UINT8 *FormSetBuffer; + UINT8 *TempBuffer; + UINT32 Offset; + UINT32 Offset2; + UINT32 PackageListLength; + EFI_HII_PACKAGE_HEADER PackageHeader; + + TempSize = 0; + FormSetBuffer = NULL; + TempBuffer = NULL; + + // + // Get HII PackageList + // + PackageListSize = 0; + HiiPackageList = NULL; + Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList); + if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) { + return Status; + } + + HiiPackageList = AllocatePool (PackageListSize); + if (HiiPackageList == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList); + ASSERT_EFI_ERROR (Status); + + // + // Get Form package from this HII package List + // + Status = EFI_NOT_FOUND; + Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); + PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength); + + while (Offset < PackageListLength) { + Package = ((UINT8 *) HiiPackageList) + Offset; + CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER)); + Offset += PackageHeader.Length; + + if (PackageHeader.Type != EFI_HII_PACKAGE_FORMS) { + continue; + } + + // + // Search FormSet Opcode in this Form Package + // + Offset2 = sizeof (EFI_HII_PACKAGE_HEADER); + while (Offset2 < PackageHeader.Length) { + OpCodeData = Package + Offset2; + Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; + + if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode != EFI_IFR_FORM_SET_OP) { + continue; + } + + if (FormSetBuffer != NULL){ + TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, FormSetBuffer); + FreePool(FormSetBuffer); + FormSetBuffer = NULL; + if (TempBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); + } else { + TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, OpCodeData); + if (TempBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + } + TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; + FormSetBuffer = TempBuffer; + + Status = EFI_SUCCESS; + // + //One form package has one formset, exit current form package to search other form package in the packagelist. + // + break; + } + } +Done: + FreePool (HiiPackageList); + + *BufferSize = TempSize; + *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer; + + return Status; +} + /** Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for hex digits that appear between a '=' and a '&' in a config string. @@ -570,17 +696,17 @@ InternalHiiBrowserCallback ( @param[in] Guid Pointer to an EFI_GUID that is the routing information GUID. Each of the 16 bytes in Guid is converted to - a 2 Unicode character hexidecimal string. This is + a 2 Unicode character hexadecimal string. This is an optional parameter that may be NULL. @param[in] Name Pointer to a Null-terminated Unicode string that is the routing information NAME. This is an optional parameter that may be NULL. Each 16-bit Unicode character in Name is converted to a 4 character Unicode - hexidecimal string. + hexadecimal string. @param[in] DriverHandle The driver handle which supports a Device Path Protocol that is the routing information PATH. Each byte of the Device Path associated with DriverHandle is converted - to a 2 Unicode character hexidecimal string. + to a 2 Unicode character hexadecimal string. @retval NULL DriverHandle does not support the Device Path Protocol. @retval Other A pointer to the Null-terminate Unicode string @@ -601,6 +727,7 @@ HiiConstructConfigHdr ( CHAR16 *ReturnString; UINTN Index; UINT8 *Buffer; + UINTN MaxLen; // // Compute the length of Name in Unicode characters. @@ -631,7 +758,8 @@ HiiConstructConfigHdr ( // GUID=32&NAME=NameLength&PATH=DevicePathSize // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 | // - String = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16)); + MaxLen = 5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1; + String = AllocateZeroPool (MaxLen * sizeof (CHAR16)); if (String == NULL) { return NULL; } @@ -639,7 +767,8 @@ HiiConstructConfigHdr ( // // Start with L"GUID=" // - ReturnString = StrCpy (String, L"GUID="); + StrCpyS (String, MaxLen, L"GUID="); + ReturnString = String; String += StrLen (String); if (Guid != NULL) { @@ -647,14 +776,21 @@ HiiConstructConfigHdr ( // Append Guid converted to 32 // for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); + UnicodeValueToStringS ( + String, + MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } } // // Append L"&NAME=" // - StrCpy (String, L"&NAME="); + StrCatS (ReturnString, MaxLen, L"&NAME="); String += StrLen (String); if (Name != NULL) { @@ -662,21 +798,35 @@ HiiConstructConfigHdr ( // Append Name converted to NameLength // for (; *Name != L'\0'; Name++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4); + UnicodeValueToStringS ( + String, + sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *Name, + 4 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } } // // Append L"&PATH=" // - StrCpy (String, L"&PATH="); + StrCatS (ReturnString, MaxLen, L"&PATH="); String += StrLen (String); // // Append the device path associated with DriverHandle converted to DevicePathSize // for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); + UnicodeValueToStringS ( + String, + sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), + PREFIX_ZERO | RADIX_HEX, + *(Buffer++), + 2 + ); + String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); } // @@ -781,7 +931,7 @@ InternalHiiGetBufferFromString ( StringPtr = (CHAR16 *) DataBuffer; ZeroMem (TemStr, sizeof (TemStr)); for (Index = 0; Index < Length; Index += 4) { - StrnCpy (TemStr, ConfigHdr + Index, 4); + StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4); StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr); } // @@ -794,7 +944,6 @@ InternalHiiGetBufferFromString ( default: return EFI_INVALID_PARAMETER; - break; } return EFI_SUCCESS; @@ -914,49 +1063,103 @@ InternalHiiGetValueOfNumber ( return EFI_SUCCESS; } +/** + Get value from config request resp string. + + @param ConfigElement ConfigResp string contains the current setting. + @param VarName The variable name which need to get value. + @param VarValue The return value. + + @retval EFI_SUCCESS Get the value for the VarName + @retval EFI_OUT_OF_RESOURCES The memory is not enough. +**/ +EFI_STATUS +GetValueFromRequest ( + IN CHAR16 *ConfigElement, + IN CHAR16 *VarName, + OUT UINT64 *VarValue + ) +{ + UINT8 *TmpBuffer; + CHAR16 *StringPtr; + UINTN Length; + EFI_STATUS Status; + + // + // Find VarName related string. + // + StringPtr = StrStr (ConfigElement, VarName); + ASSERT (StringPtr != NULL); + + // + // Skip the "VarName=" string + // + StringPtr += StrLen (VarName) + 1; + + // + // Get Offset + // + Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); + if (EFI_ERROR (Status)) { + return Status; + } + + *VarValue = 0; + CopyMem (VarValue, TmpBuffer, (((Length + 1) / 2) < sizeof (UINT64)) ? ((Length + 1) / 2) : sizeof (UINT64)); + + FreePool (TmpBuffer); + + return EFI_SUCCESS; +} + /** This internal function parses IFR data to validate current setting. - @param ConfigResp ConfigResp string contains the current setting. + Base on the NameValueType, if it is TRUE, RequestElement and HiiHandle is valid; + else the VarBuffer and CurrentBlockArray is valid. + @param HiiPackageList Point to Hii package list. @param PackageListLength The length of the pacakge. @param VarGuid Guid of the buffer storage. @param VarName Name of the buffer storage. + @param VarBuffer The data buffer for the storage. + @param CurrentBlockArray The block array from the config Requst string. + @param RequestElement The config string for this storage. + @param HiiHandle The HiiHandle for this formset. + @param NameValueType Whether current storage is name/value varstore or not. @retval EFI_SUCCESS The current setting is valid. @retval EFI_OUT_OF_RESOURCES The memory is not enough. @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid. **/ EFI_STATUS -EFIAPI -InternalHiiValidateCurrentSetting ( - IN EFI_STRING ConfigResp, +ValidateQuestionFromVfr ( IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList, IN UINTN PackageListLength, IN EFI_GUID *VarGuid, - IN CHAR16 *VarName + IN CHAR16 *VarName, + IN UINT8 *VarBuffer, + IN IFR_BLOCK_DATA *CurrentBlockArray, + IN CHAR16 *RequestElement, + IN EFI_HII_HANDLE HiiHandle, + IN BOOLEAN NameValueType ) -{ - IFR_BLOCK_DATA *CurrentBlockArray; - IFR_BLOCK_DATA *BlockData; - IFR_BLOCK_DATA *NewBlockData; +{ IFR_BLOCK_DATA VarBlockData; - EFI_STRING StringPtr; - UINTN Length; - UINT8 *TmpBuffer; UINT16 Offset; UINT16 Width; UINT64 VarValue; - LIST_ENTRY *Link; - UINT8 *VarBuffer; - UINTN MaxBufferSize; + EFI_IFR_TYPE_VALUE TmpValue; EFI_STATUS Status; - EFI_HII_PACKAGE_HEADER PacakgeHeader; + EFI_HII_PACKAGE_HEADER PackageHeader; UINT32 PackageOffset; UINT8 *PackageData; UINTN IfrOffset; EFI_IFR_OP_HEADER *IfrOpHdr; EFI_IFR_VARSTORE *IfrVarStore; + EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueStore; + EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + IFR_VARSTORAGE_DATA VarStoreData; EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ONE_OF_OPTION *IfrOneOfOption; @@ -964,255 +1167,114 @@ InternalHiiValidateCurrentSetting ( EFI_IFR_STRING *IfrString; CHAR8 *VarStoreName; UINTN Index; - - // - // 1. Get the current setting to current block data array and Convert them into VarBuffer - // + CHAR16 *QuestionName; + CHAR16 *StringPtr; - // - // Skip ConfigHdr string - // - StringPtr = ConfigResp; - StringPtr = StrStr (ConfigResp, L"&OFFSET"); - if (StringPtr == NULL) { - // - // No ConfigBlock value is required to be validated. - // EFI_SUCCESS directly return. - // - return EFI_SUCCESS; - } - // // Initialize the local variables. // - Index = 0; - VarStoreName = NULL; - Status = EFI_SUCCESS; - BlockData = NULL; - NewBlockData = NULL; - TmpBuffer = NULL; - MaxBufferSize = HII_LIB_DEFAULT_VARSTORE_SIZE; - VarBuffer = AllocateZeroPool (MaxBufferSize); - if (VarBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } + Index = 0; + VarStoreName = NULL; + Status = EFI_SUCCESS; + VarValue = 0; + IfrVarStore = NULL; + IfrNameValueStore = NULL; + IfrEfiVarStore = NULL; + ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA)); + ZeroMem (&VarBlockData, sizeof (VarBlockData)); // - // Init CurrentBlockArray - // - CurrentBlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); - if (CurrentBlockArray == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - InitializeListHead (&CurrentBlockArray->Entry); - - // - // Parse each if exists - // Only format is supported by this help function. - // ::= &'OFFSET='&'WIDTH=' + // Check IFR value is in block data, then Validate Value // - while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { - // - // Skip the &OFFSET= string - // - StringPtr += StrLen (L"&OFFSET="); - - // - // Get Offset - // - Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (EFI_ERROR (Status)) { - goto Done; - } - Offset = 0; - CopyMem ( - &Offset, - TmpBuffer, - (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) - ); - FreePool (TmpBuffer); - TmpBuffer = NULL; - - StringPtr += Length; - if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - StringPtr += StrLen (L"&WIDTH="); + PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); + while (PackageOffset < PackageListLength) { + CopyMem (&PackageHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PackageHeader)); // - // Get Width + // Parse IFR opcode from the form package. // - Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (EFI_ERROR (Status)) { - goto Done; - } - Width = 0; - CopyMem ( - &Width, - TmpBuffer, - (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) - ); - FreePool (TmpBuffer); - TmpBuffer = NULL; + if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) { + IfrOffset = sizeof (PackageHeader); + PackageData = (UINT8 *) HiiPackageList + PackageOffset; + while (IfrOffset < PackageHeader.Length) { + IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset); + // + // Validate current setting to the value built in IFR opcode + // + switch (IfrOpHdr->OpCode) { + case EFI_IFR_VARSTORE_OP: + // + // VarStoreId has been found. No further found. + // + if (VarStoreData.VarStoreId != 0) { + break; + } + // + // Find the matched VarStoreId to the input VarGuid and VarName + // + IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; + if (CompareGuid ((EFI_GUID *) (VOID *) &IfrVarStore->Guid, VarGuid)) { + VarStoreName = (CHAR8 *) IfrVarStore->Name; + for (Index = 0; VarStoreName[Index] != 0; Index ++) { + if ((CHAR16) VarStoreName[Index] != VarName[Index]) { + break; + } + } + // + // The matched VarStore is found. + // + if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) { + IfrVarStore = NULL; + } + } else { + IfrVarStore = NULL; + } - StringPtr += Length; - if (*StringPtr != 0 && *StringPtr != L'&') { - Status = EFI_INVALID_PARAMETER; - goto Done; - } + if (IfrVarStore != NULL) { + VarStoreData.VarStoreId = IfrVarStore->VarStoreId; + VarStoreData.Size = IfrVarStore->Size; + } + break; + case EFI_IFR_VARSTORE_NAME_VALUE_OP: + // + // VarStoreId has been found. No further found. + // + if (VarStoreData.VarStoreId != 0) { + break; + } + // + // Find the matched VarStoreId to the input VarGuid + // + IfrNameValueStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr; + if (!CompareGuid ((EFI_GUID *) (VOID *) &IfrNameValueStore->Guid, VarGuid)) { + IfrNameValueStore = NULL; + } - if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - StringPtr += StrLen (L"&VALUE="); + if (IfrNameValueStore != NULL) { + VarStoreData.VarStoreId = IfrNameValueStore->VarStoreId; + } + break; + case EFI_IFR_VARSTORE_EFI_OP: + // + // VarStore is found. Don't need to search any more. + // + if (VarStoreData.VarStoreId != 0) { + break; + } - // - // Get Value - // - Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (EFI_ERROR (Status)) { - goto Done; - } + IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; - StringPtr += Length; - if (*StringPtr != 0 && *StringPtr != L'&') { - Status = EFI_INVALID_PARAMETER; - goto Done; - } + // + // If the length is small than the structure, this is from old efi + // varstore definition. Old efi varstore get config directly from + // GetVariable function. + // + if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) { + break; + } - // - // Check whether VarBuffer is enough - // - if ((UINTN) (Offset + Width) > MaxBufferSize) { - VarBuffer = ReallocatePool ( - MaxBufferSize, - Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE, - VarBuffer - ); - if (VarBuffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - MaxBufferSize = Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE; - } - - // - // Update the Block with configuration info - // - CopyMem (VarBuffer + Offset, TmpBuffer, Width); - FreePool (TmpBuffer); - TmpBuffer = NULL; - - // - // Set new Block Data - // - NewBlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); - if (NewBlockData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - NewBlockData->Offset = Offset; - NewBlockData->Width = Width; - - // - // Insert the new block data into the block data array. - // - for (Link = CurrentBlockArray->Entry.ForwardLink; Link != &CurrentBlockArray->Entry; Link = Link->ForwardLink) { - BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); - if (NewBlockData->Offset == BlockData->Offset) { - if (NewBlockData->Width > BlockData->Width) { - BlockData->Width = NewBlockData->Width; - } - FreePool (NewBlockData); - break; - } else if (NewBlockData->Offset < BlockData->Offset) { - // - // Insert new block data as the previous one of this link. - // - InsertTailList (Link, &NewBlockData->Entry); - break; - } - } - - // - // Insert new block data into the array tail. - // - if (Link == &CurrentBlockArray->Entry) { - InsertTailList (Link, &NewBlockData->Entry); - } - - // - // If '\0', parsing is finished. - // - if (*StringPtr == 0) { - break; - } - // - // Go to next ConfigBlock - // - } - - // - // Merge the aligned block data into the single block data. - // - Link = CurrentBlockArray->Entry.ForwardLink; - while ((Link != &CurrentBlockArray->Entry) && (Link->ForwardLink != &CurrentBlockArray->Entry)) { - BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); - NewBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry); - if ((NewBlockData->Offset >= BlockData->Offset) && (NewBlockData->Offset <= (BlockData->Offset + BlockData->Width))) { - if ((NewBlockData->Offset + NewBlockData->Width) > (BlockData->Offset + BlockData->Width)) { - BlockData->Width = (UINT16) (NewBlockData->Offset + NewBlockData->Width - BlockData->Offset); - } - RemoveEntryList (Link->ForwardLink); - FreePool (NewBlockData); - continue; - } - Link = Link->ForwardLink; - } - - if (IsListEmpty (&CurrentBlockArray->Entry)) { - Status = EFI_SUCCESS; - goto Done; - } - - // - // 2. Check IFR value is in block data, then Validate Value - // - ZeroMem (&VarBlockData, sizeof (VarBlockData)); - VarValue = 0; - IfrVarStore = NULL; - PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); - while (PackageOffset < PackageListLength) { - CopyMem (&PacakgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader)); - - // - // Parse IFR opcode from the form package. - // - if (PacakgeHeader.Type == EFI_HII_PACKAGE_FORMS) { - IfrOffset = sizeof (PacakgeHeader); - PackageData = (UINT8 *) HiiPackageList + PackageOffset; - while (IfrOffset < PacakgeHeader.Length) { - IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset); - // - // Validate current setting to the value built in IFR opcode - // - switch (IfrOpHdr->OpCode) { - case EFI_IFR_VARSTORE_OP: - // - // VarStoreId has been found. No further found. - // - if (IfrVarStore != NULL) { - break; - } - // - // Find the matched VarStoreId to the input VarGuid and VarName - // - IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; - if (CompareGuid ((EFI_GUID *) (VOID *) &IfrVarStore->Guid, VarGuid)) { - VarStoreName = (CHAR8 *) IfrVarStore->Name; + if (CompareGuid ((EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid, VarGuid)) { + VarStoreName = (CHAR8 *) IfrEfiVarStore->Name; for (Index = 0; VarStoreName[Index] != 0; Index ++) { if ((CHAR16) VarStoreName[Index] != VarName[Index]) { break; @@ -1222,10 +1284,18 @@ InternalHiiValidateCurrentSetting ( // The matched VarStore is found. // if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) { - IfrVarStore = NULL; + IfrEfiVarStore = NULL; } } else { - IfrVarStore = NULL; + IfrEfiVarStore = NULL; + } + + if (IfrEfiVarStore != NULL) { + // + // Find the matched VarStore + // + VarStoreData.VarStoreId = IfrEfiVarStore->VarStoreId; + VarStoreData.Size = IfrEfiVarStore->Size; } break; case EFI_IFR_FORM_OP: @@ -1233,9 +1303,8 @@ InternalHiiValidateCurrentSetting ( // // Check the matched VarStoreId is found. // - if (IfrVarStore == NULL) { - Status = EFI_SUCCESS; - goto Done; + if (VarStoreData.VarStoreId == 0) { + return EFI_SUCCESS; } break; case EFI_IFR_ONE_OF_OP: @@ -1246,53 +1315,66 @@ InternalHiiValidateCurrentSetting ( // // OneOf question is not in IFR Form. This IFR form is not valid. // - if (IfrVarStore == NULL) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarStoreData.VarStoreId == 0) { + return EFI_INVALID_PARAMETER; } // // Check whether this question is for the requested varstore. // IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr; - if (IfrOneOf->Question.VarStoreId != IfrVarStore->VarStoreId) { + if (IfrOneOf->Question.VarStoreId != VarStoreData.VarStoreId) { break; } - - // - // Get Offset by Question header and Width by DataType Flags - // - Offset = IfrOneOf->Question.VarStoreInfo.VarOffset; - Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); - // - // Check whether this question is in current block array. - // - if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + + if (NameValueType) { + QuestionName = HiiGetString (HiiHandle, IfrOneOf->Question.VarStoreInfo.VarName, NULL); + ASSERT (QuestionName != NULL); + + if (StrStr (RequestElement, QuestionName) == NULL) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + + Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue); + if (EFI_ERROR (Status)) { + return Status; + } + } else { // - // This question is not in the current configuration string. Skip it. + // Get Offset by Question header and Width by DataType Flags // - break; - } - // - // Check this var question is in the var storage - // - if ((Offset + Width) > IfrVarStore->Size) { + Offset = IfrOneOf->Question.VarStoreInfo.VarOffset; + Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); // - // This question exceeds the var store size. + // Check whether this question is in current block array. // - Status = EFI_INVALID_PARAMETER; - goto Done; - } + if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + // + // Check this var question is in the var storage + // + if ((Offset + Width) > VarStoreData.Size) { + // + // This question exceeds the var store size. + // + return EFI_INVALID_PARAMETER; + } - // - // Get the current value for oneof opcode - // - VarValue = 0; - CopyMem (&VarValue, VarBuffer + Offset, Width); + // + // Get the current value for oneof opcode + // + VarValue = 0; + CopyMem (&VarValue, VarBuffer + Offset, Width); + } // // Set Block Data, to be checked in the following Oneof option opcode. // - VarBlockData.Offset = Offset; - VarBlockData.Width = Width; VarBlockData.OpCode = IfrOpHdr->OpCode; VarBlockData.Scope = IfrOpHdr->Scope; break; @@ -1304,87 +1386,134 @@ InternalHiiValidateCurrentSetting ( // // Numeric question is not in IFR Form. This IFR form is not valid. // - if (IfrVarStore == NULL) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarStoreData.VarStoreId == 0) { + return EFI_INVALID_PARAMETER; } // // Check whether this question is for the requested varstore. // IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpHdr; - if (IfrNumeric->Question.VarStoreId != IfrVarStore->VarStoreId) { + if (IfrNumeric->Question.VarStoreId != VarStoreData.VarStoreId) { break; } - - // - // Get Offset by Question header and Width by DataType Flags - // - Offset = IfrNumeric->Question.VarStoreInfo.VarOffset; - Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); - // - // Check whether this question is in current block array. - // - if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + + if (NameValueType) { + QuestionName = HiiGetString (HiiHandle, IfrNumeric->Question.VarStoreInfo.VarName, NULL); + ASSERT (QuestionName != NULL); + + if (StrStr (RequestElement, QuestionName) == NULL) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + + Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue); + if (EFI_ERROR (Status)) { + return Status; + } + } else { // - // This question is not in the current configuration string. Skip it. + // Get Offset by Question header and Width by DataType Flags // - break; - } - // - // Check this var question is in the var storage - // - if ((Offset + Width) > IfrVarStore->Size) { + Offset = IfrNumeric->Question.VarStoreInfo.VarOffset; + Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); // - // This question exceeds the var store size. + // Check whether this question is in current block array. // - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - // - // Check the current value is in the numeric range. - // - VarValue = 0; - CopyMem (&VarValue, VarBuffer + Offset, Width); - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) { + if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { // - // Not in the valid range. + // This question is not in the current configuration string. Skip it. // - Status = EFI_INVALID_PARAMETER; - goto Done; + break; } - break; - case EFI_IFR_NUMERIC_SIZE_2: - if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) { + // + // Check this var question is in the var storage + // + if ((Offset + Width) > VarStoreData.Size) { // - // Not in the valid range. + // This question exceeds the var store size. // - Status = EFI_INVALID_PARAMETER; - goto Done; + return EFI_INVALID_PARAMETER; } - break; - case EFI_IFR_NUMERIC_SIZE_4: - if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) { - // - // Not in the valid range. - // - Status = EFI_INVALID_PARAMETER; - goto Done; + + // + // Check the current value is in the numeric range. + // + VarValue = 0; + CopyMem (&VarValue, VarBuffer + Offset, Width); + } + if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_2: + if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_4: + if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_8: + if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; } - break; - case EFI_IFR_NUMERIC_SIZE_8: - if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) { - // - // Not in the valid range. - // - Status = EFI_INVALID_PARAMETER; - goto Done; + } else { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_2: + if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_4: + if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_8: + if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; } - break; } - break; case EFI_IFR_CHECKBOX_OP: // @@ -1394,52 +1523,69 @@ InternalHiiValidateCurrentSetting ( // // CheckBox question is not in IFR Form. This IFR form is not valid. // - if (IfrVarStore == NULL) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarStoreData.VarStoreId == 0) { + return EFI_INVALID_PARAMETER; } // // Check whether this question is for the requested varstore. // IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr; - if (IfrCheckBox->Question.VarStoreId != IfrVarStore->VarStoreId) { + if (IfrCheckBox->Question.VarStoreId != VarStoreData.VarStoreId) { break; } - - // - // Get Offset by Question header - // - Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset; - Width = (UINT16) sizeof (BOOLEAN); - // - // Check whether this question is in current block array. - // - if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + + if (NameValueType) { + QuestionName = HiiGetString (HiiHandle, IfrCheckBox->Question.VarStoreInfo.VarName, NULL); + ASSERT (QuestionName != NULL); + + if (StrStr (RequestElement, QuestionName) == NULL) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + + Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue); + if (EFI_ERROR (Status)) { + return Status; + } + } else { // - // This question is not in the current configuration string. Skip it. + // Get Offset by Question header // - break; - } - // - // Check this var question is in the var storage - // - if ((Offset + Width) > IfrVarStore->Size) { + Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset; + Width = (UINT16) sizeof (BOOLEAN); + // + // Check whether this question is in current block array. + // + if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } // - // This question exceeds the var store size. + // Check this var question is in the var storage // - Status = EFI_INVALID_PARAMETER; - goto Done; + if ((Offset + Width) > VarStoreData.Size) { + // + // This question exceeds the var store size. + // + return EFI_INVALID_PARAMETER; + } + // + // Check the current value is in the numeric range. + // + VarValue = 0; + CopyMem (&VarValue, VarBuffer + Offset, Width); } - // // Boolean type, only 1 and 0 is valid. // - if (*(VarBuffer + Offset) > 1) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarValue > 1) { + return EFI_INVALID_PARAMETER; } - break; case EFI_IFR_STRING_OP: // @@ -1449,121 +1595,471 @@ InternalHiiValidateCurrentSetting ( // // CheckBox question is not in IFR Form. This IFR form is not valid. // - if (IfrVarStore == NULL) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarStoreData.VarStoreId == 0) { + return EFI_INVALID_PARAMETER; } // // Check whether this question is for the requested varstore. // IfrString = (EFI_IFR_STRING *) IfrOpHdr; - if (IfrString->Question.VarStoreId != IfrVarStore->VarStoreId) { + if (IfrString->Question.VarStoreId != VarStoreData.VarStoreId) { break; } - // - // Get Offset/Width by Question header and OneOf Flags + // Get Width by OneOf Flags // - Offset = IfrString->Question.VarStoreInfo.VarOffset; Width = (UINT16) (IfrString->MaxSize * sizeof (UINT16)); - // - // Check whether this question is in current block array. - // - if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + if (NameValueType) { + QuestionName = HiiGetString (HiiHandle, IfrString->Question.VarStoreInfo.VarName, NULL); + ASSERT (QuestionName != NULL); + + StringPtr = StrStr (RequestElement, QuestionName); + if (StringPtr == NULL) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + + // + // Skip the "=". + // + StringPtr += 1; + + // + // Check current string length is less than maxsize + // + if (StrSize (StringPtr) > Width) { + return EFI_INVALID_PARAMETER; + } + } else { + // + // Get Offset/Width by Question header and OneOf Flags + // + Offset = IfrString->Question.VarStoreInfo.VarOffset; + // + // Check whether this question is in current block array. + // + if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { + // + // This question is not in the current configuration string. Skip it. + // + break; + } + // + // Check this var question is in the var storage + // + if ((Offset + Width) > VarStoreData.Size) { + // + // This question exceeds the var store size. + // + return EFI_INVALID_PARAMETER; + } + // - // This question is not in the current configuration string. Skip it. + // Check current string length is less than maxsize // + if (StrSize ((CHAR16 *) (VarBuffer + Offset)) > Width) { + return EFI_INVALID_PARAMETER; + } + } + break; + case EFI_IFR_ONE_OF_OPTION_OP: + // + // Opcode Scope is zero. This one of option is not to be checked. + // + if (VarBlockData.Scope == 0) { break; } + // - // Check this var question is in the var storage + // Only check for OneOf and OrderList opcode // - if ((Offset + Width) > IfrVarStore->Size) { + IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpHdr; + if (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP) { // - // This question exceeds the var store size. + // Check current value is the value of one of option. // - Status = EFI_INVALID_PARAMETER; - goto Done; + ASSERT (IfrOneOfOption->Type <= EFI_IFR_TYPE_NUM_SIZE_64); + ZeroMem (&TmpValue, sizeof (EFI_IFR_TYPE_VALUE)); + CopyMem (&TmpValue, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value)); + if (VarValue == TmpValue.u64) { + // + // The value is one of option value. + // Set OpCode to Zero, don't need check again. + // + VarBlockData.OpCode = 0; + } } - + break; + case EFI_IFR_END_OP: // - // Check current string length is less than maxsize + // Decrease opcode scope for the validated opcode // - if (StrSize ((CHAR16 *) (VarBuffer + Offset)) > Width) { - Status = EFI_INVALID_PARAMETER; - goto Done; + if (VarBlockData.Scope > 0) { + VarBlockData.Scope --; + } + + // + // OneOf value doesn't belong to one of option value. + // + if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) { + return EFI_INVALID_PARAMETER; } break; - case EFI_IFR_ONE_OF_OPTION_OP: + default: // - // Opcode Scope is zero. This one of option is not to be checked. + // Increase Scope for the validated opcode // - if (VarBlockData.Scope == 0) { - break; + if (VarBlockData.Scope > 0) { + VarBlockData.Scope = (UINT8) (VarBlockData.Scope + IfrOpHdr->Scope); } + break; + } + // + // Go to the next opcode + // + IfrOffset += IfrOpHdr->Length; + } + // + // Only one form is in a package list. + // + break; + } + + // + // Go to next package. + // + PackageOffset += PackageHeader.Length; + } + + return EFI_SUCCESS; +} + +/** + This internal function parses IFR data to validate current setting. + + @param ConfigElement ConfigResp element string contains the current setting. + @param CurrentBlockArray Current block array. + @param VarBuffer Data buffer for this varstore. + + @retval EFI_SUCCESS The current setting is valid. + @retval EFI_OUT_OF_RESOURCES The memory is not enough. + @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid. +**/ +EFI_STATUS +GetBlockDataInfo ( + IN CHAR16 *ConfigElement, + OUT IFR_BLOCK_DATA **CurrentBlockArray, + OUT UINT8 **VarBuffer + ) +{ + IFR_BLOCK_DATA *BlockData; + IFR_BLOCK_DATA *NewBlockData; + EFI_STRING StringPtr; + UINTN Length; + UINT8 *TmpBuffer; + UINT16 Offset; + UINT16 Width; + LIST_ENTRY *Link; + UINTN MaxBufferSize; + EFI_STATUS Status; + IFR_BLOCK_DATA *BlockArray; + UINT8 *DataBuffer; + + // + // Initialize the local variables. + // + Status = EFI_SUCCESS; + BlockData = NULL; + NewBlockData = NULL; + TmpBuffer = NULL; + BlockArray = NULL; + MaxBufferSize = HII_LIB_DEFAULT_VARSTORE_SIZE; + DataBuffer = AllocateZeroPool (MaxBufferSize); + if (DataBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Init BlockArray + // + BlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); + if (BlockArray == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + InitializeListHead (&BlockArray->Entry); + + StringPtr = StrStr (ConfigElement, L"&OFFSET="); + ASSERT (StringPtr != NULL); + + // + // Parse each if exists + // Only format is supported by this help function. + // ::= &'OFFSET='&'WIDTH=' + // + while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { + // + // Skip the &OFFSET= string + // + StringPtr += StrLen (L"&OFFSET="); + + // + // Get Offset + // + Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); + if (EFI_ERROR (Status)) { + goto Done; + } + Offset = 0; + CopyMem ( + &Offset, + TmpBuffer, + (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) + ); + FreePool (TmpBuffer); + TmpBuffer = NULL; + + StringPtr += Length; + if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + StringPtr += StrLen (L"&WIDTH="); + + // + // Get Width + // + Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); + if (EFI_ERROR (Status)) { + goto Done; + } + Width = 0; + CopyMem ( + &Width, + TmpBuffer, + (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) + ); + FreePool (TmpBuffer); + TmpBuffer = NULL; - // - // Only check for OneOf and OrderList opcode - // - IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpHdr; - if (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP) { - // - // Check current value is the value of one of option. - // - if (VarValue == IfrOneOfOption->Value.u64) { - // - // The value is one of option value. - // Set OpCode to Zero, don't need check again. - // - VarBlockData.OpCode = 0; - } - } + StringPtr += Length; + if (*StringPtr != 0 && *StringPtr != L'&') { + Status = EFI_INVALID_PARAMETER; + goto Done; + } - break; - case EFI_IFR_END_OP: - // - // Decrease opcode scope for the validated opcode - // - if (VarBlockData.Scope > 0) { - VarBlockData.Scope --; - } + if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + StringPtr += StrLen (L"&VALUE="); - // - // OneOf value doesn't belong to one of option value. - // - if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - break; - default: - // - // Increase Scope for the validated opcode - // - if (VarBlockData.Scope > 0) { - VarBlockData.Scope = (UINT8) (VarBlockData.Scope + IfrOpHdr->Scope); - } - break; + // + // Get Value + // + Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length); + if (EFI_ERROR (Status)) { + goto Done; + } + + StringPtr += Length; + if (*StringPtr != 0 && *StringPtr != L'&') { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + + // + // Check whether VarBuffer is enough + // + if ((UINT32)Offset + Width > MaxBufferSize) { + DataBuffer = ReallocatePool ( + MaxBufferSize, + Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE, + DataBuffer + ); + if (DataBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + MaxBufferSize = Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE; + } + + // + // Update the Block with configuration info + // + CopyMem (DataBuffer + Offset, TmpBuffer, Width); + FreePool (TmpBuffer); + TmpBuffer = NULL; + + // + // Set new Block Data + // + NewBlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); + if (NewBlockData == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + NewBlockData->Offset = Offset; + NewBlockData->Width = Width; + + // + // Insert the new block data into the block data array. + // + for (Link = BlockArray->Entry.ForwardLink; Link != &BlockArray->Entry; Link = Link->ForwardLink) { + BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); + if (NewBlockData->Offset == BlockData->Offset) { + if (NewBlockData->Width > BlockData->Width) { + BlockData->Width = NewBlockData->Width; } + FreePool (NewBlockData); + break; + } else if (NewBlockData->Offset < BlockData->Offset) { // - // Go to the next opcode + // Insert new block data as the previous one of this link. // - IfrOffset += IfrOpHdr->Length; + InsertTailList (Link, &NewBlockData->Entry); + break; } - // - // Only one form is in a package list. - // + } + + // + // Insert new block data into the array tail. + // + if (Link == &BlockArray->Entry) { + InsertTailList (Link, &NewBlockData->Entry); + } + + // + // If '\0', parsing is finished. + // + if (*StringPtr == 0) { break; } - // - // Go to next package. + // Go to next ConfigBlock // - PackageOffset += PacakgeHeader.Length; } + // + // Merge the aligned block data into the single block data. + // + Link = BlockArray->Entry.ForwardLink; + while ((Link != &BlockArray->Entry) && (Link->ForwardLink != &BlockArray->Entry)) { + BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); + NewBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry); + if ((NewBlockData->Offset >= BlockData->Offset) && (NewBlockData->Offset <= (BlockData->Offset + BlockData->Width))) { + if ((NewBlockData->Offset + NewBlockData->Width) > (BlockData->Offset + BlockData->Width)) { + BlockData->Width = (UINT16) (NewBlockData->Offset + NewBlockData->Width - BlockData->Offset); + } + RemoveEntryList (Link->ForwardLink); + FreePool (NewBlockData); + continue; + } + Link = Link->ForwardLink; + } + + *VarBuffer = DataBuffer; + *CurrentBlockArray = BlockArray; + return EFI_SUCCESS; + Done: + if (DataBuffer != NULL) { + FreePool (DataBuffer); + } + + if (BlockArray != NULL) { + // + // Free Link Array CurrentBlockArray + // + while (!IsListEmpty (&BlockArray->Entry)) { + BlockData = BASE_CR (BlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry); + RemoveEntryList (&BlockData->Entry); + FreePool (BlockData); + } + FreePool (BlockArray); + } + + return Status; +} + +/** + This internal function parses IFR data to validate current setting. + + @param ConfigResp ConfigResp string contains the current setting. + @param HiiPackageList Point to Hii package list. + @param PackageListLength The length of the pacakge. + @param VarGuid Guid of the buffer storage. + @param VarName Name of the buffer storage. + @param HiiHandle The HiiHandle for this package. + + @retval EFI_SUCCESS The current setting is valid. + @retval EFI_OUT_OF_RESOURCES The memory is not enough. + @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid. +**/ +EFI_STATUS +EFIAPI +InternalHiiValidateCurrentSetting ( + IN EFI_STRING ConfigResp, + IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList, + IN UINTN PackageListLength, + IN EFI_GUID *VarGuid, + IN CHAR16 *VarName, + IN EFI_HII_HANDLE HiiHandle + ) +{ + CHAR16 *StringPtr; + EFI_STATUS Status; + IFR_BLOCK_DATA *CurrentBlockArray; + IFR_BLOCK_DATA *BlockData; + UINT8 *VarBuffer; + BOOLEAN NameValueType; + + CurrentBlockArray = NULL; + VarBuffer = NULL; + StringPtr = NULL; + Status = EFI_SUCCESS; + + // + // If StringPtr != NULL, get the request elements. + // + if (StrStr (ConfigResp, L"&OFFSET=") != NULL) { + Status = GetBlockDataInfo(ConfigResp, &CurrentBlockArray, &VarBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + NameValueType = FALSE; + } else { + // + // Skip header part. + // + StringPtr = StrStr (ConfigResp, L"PATH="); + ASSERT (StringPtr != NULL); + + if (StrStr (StringPtr, L"&") != NULL) { + NameValueType = TRUE; + } else { + // + // Not found Request element, return success. + // + return EFI_SUCCESS; + } + } + + Status = ValidateQuestionFromVfr( + HiiPackageList, + PackageListLength, + VarGuid, + VarName, + VarBuffer, + CurrentBlockArray, + ConfigResp, + HiiHandle, + NameValueType + ); + if (VarBuffer != NULL) { FreePool (VarBuffer); } @@ -1577,12 +2073,40 @@ Done: RemoveEntryList (&BlockData->Entry); FreePool (BlockData); } - FreePool (CurrentBlockArray); + FreePool (CurrentBlockArray); } return Status; } +/** + Check whether the ConfigRequest string has the request elements. + For EFI_HII_VARSTORE_BUFFER type, the request has "&OFFSET=****&WIDTH=****..." format. + For EFI_HII_VARSTORE_NAME_VALUE type, the request has "&NAME1**&NAME2..." format. + + @param ConfigRequest The input config request string. + + @retval TRUE The input include config request elements. + @retval FALSE The input string not includes. + +**/ +BOOLEAN +GetElementsFromRequest ( + IN EFI_STRING ConfigRequest + ) +{ + EFI_STRING TmpRequest; + + TmpRequest = StrStr (ConfigRequest, L"PATH="); + ASSERT (TmpRequest != NULL); + + if ((StrStr (TmpRequest, L"&OFFSET=") != NULL) || (StrStr (TmpRequest, L"&") != NULL)) { + return TRUE; + } + + return FALSE; +} + /** This function parses the input ConfigRequest string and its matched IFR code string for setting default value and validating current setting. @@ -1604,7 +2128,7 @@ Done: @param DefaultId Specifies the type of defaults to retrieve only for setting default action. @param ActionType Action supports setting defaults and validate current setting. - @retval TURE Action runs successfully. + @retval TRUE Action runs successfully. @retval FALSE Action is not valid or Action can't be executed successfully.. **/ BOOLEAN @@ -1630,12 +2154,12 @@ InternalHiiIfrValueAction ( EFI_GUID *VarGuid; EFI_STRING VarName; - UINT8 *PackageData; EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList; UINTN PackageListLength; + UINTN MaxLen; EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; - + ConfigAltResp = NULL; ConfigResp = NULL; VarGuid = NULL; @@ -1646,7 +2170,6 @@ InternalHiiIfrValueAction ( Index = 0; TempDriverHandle = NULL; HiiHandle = NULL; - PackageData = NULL; HiiPackageList = NULL; // @@ -1764,7 +2287,7 @@ InternalHiiIfrValueAction ( // Its default value and validating can't execute by parsing IFR data. // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path. // - Status = EFI_SUCCESS; + Status = EFI_SUCCESS; goto NextConfigAltResp; } @@ -1821,7 +2344,7 @@ InternalHiiIfrValueAction ( // // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set. // - if (StrStr (ConfigResp, L"&OFFSET=") == NULL) { + if (!GetElementsFromRequest (ConfigResp)) { goto NextConfigAltResp; } @@ -1838,7 +2361,7 @@ InternalHiiIfrValueAction ( // // Current Setting is in ConfigResp, will be set into buffer, then check it again. // - Status = InternalHiiValidateCurrentSetting (ConfigResp, HiiPackageList, PackageListLength, VarGuid, VarName); + Status = InternalHiiValidateCurrentSetting (ConfigResp, HiiPackageList, PackageListLength, VarGuid, VarName, HiiHandle); } if (EFI_ERROR (Status)) { @@ -1854,10 +2377,10 @@ NextConfigAltResp: HiiPackageList = NULL; } - if (ConfigResp != NULL) { - FreePool (ConfigResp); - ConfigResp = NULL; - } + if (ConfigResp != NULL) { + FreePool (ConfigResp); + ConfigResp = NULL; + } // // Free the allocated buffer. @@ -1889,14 +2412,15 @@ NextConfigAltResp: // Construct ConfigAltHdr string "&&ALTCFG=\0" // | 1 | StrLen (ConfigHdr) | 8 | 1 | // - ConfigAltHdr = AllocateZeroPool ((1 + StringPtr - StringHdr + 8 + 1) * sizeof (CHAR16)); + MaxLen = 1 + StringPtr - StringHdr + 8 + 1; + ConfigAltHdr = AllocateZeroPool ( MaxLen * sizeof (CHAR16)); if (ConfigAltHdr == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - StrCpy (ConfigAltHdr, L"&"); - StrnCat (ConfigAltHdr, StringHdr, StringPtr - StringHdr); - StrCat (ConfigAltHdr, L"&ALTCFG="); + StrCpyS (ConfigAltHdr, MaxLen, L"&"); + StrnCatS (ConfigAltHdr, MaxLen, StringHdr, StringPtr - StringHdr); + StrCatS (ConfigAltHdr, MaxLen, L"&ALTCFG="); // // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr @@ -1998,7 +2522,7 @@ HiiValidateSettings ( entirety of the current HII database will be reset. @param DefaultId Specifies the type of defaults to retrieve. - @retval TURE The default value is set successfully. + @retval TRUE The default value is set successfully. @retval FALSE The default value can't be found and set. **/ BOOLEAN @@ -2446,9 +2970,7 @@ InternalHiiGrowOpCodeHandle ( OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE), OpCodeBuffer->Buffer ); - if (Buffer == NULL) { - return NULL; - } + ASSERT (Buffer != NULL); OpCodeBuffer->Buffer = Buffer; OpCodeBuffer->BufferSize += (Size + HII_LIB_OPCODE_ALLOCATION_SIZE); } @@ -2633,7 +3155,7 @@ HiiCreateOneOfOptionOpCode ( OpCode.Type = Type; CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]); - return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, sizeof (OpCode)); + return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, OFFSET_OF(EFI_IFR_ONE_OF_OPTION, Value) + mHiiDefaultTypeToWidth[Type]); } /** @@ -2669,7 +3191,7 @@ HiiCreateDefaultOpCode ( OpCode.DefaultId = DefaultId; CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]); - return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, sizeof (OpCode)); + return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, OFFSET_OF(EFI_IFR_DEFAULT, Value) + mHiiDefaultTypeToWidth[Type]); } /** @@ -2859,6 +3381,82 @@ HiiCreateGotoOpCode ( return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_REF_OP, sizeof (OpCode)); } +/** + Create EFI_IFR_REF_OP, EFI_IFR_REF2_OP, EFI_IFR_REF3_OP and EFI_IFR_REF4_OP opcode. + + When RefDevicePath is not zero, EFI_IFR_REF4 opcode will be created. + When RefDevicePath is zero and RefFormSetId is not NULL, EFI_IFR_REF3 opcode will be created. + When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is not zero, EFI_IFR_REF2 opcode will be created. + When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is zero, EFI_IFR_REF opcode will be created. + + If OpCodeHandle is NULL, then ASSERT(). + If any reserved bits are set in QuestionFlags, then ASSERT(). + + @param[in] OpCodeHandle The handle to the buffer of opcodes. + @param[in] RefFormId The Destination Form ID. + @param[in] Prompt The string ID for Prompt. + @param[in] Help The string ID for Help. + @param[in] QuestionFlags The flags in Question Header + @param[in] QuestionId Question ID. + @param[in] RefQuestionId The question on the form to which this link is referring. + If its value is zero, then the link refers to the top of the form. + @param[in] RefFormSetId The form set to which this link is referring. If its value is NULL, and RefDevicePath is + zero, then the link is to the current form set. + @param[in] RefDevicePath The string identifier that specifies the string containing the text representation of + the device path to which the form set containing the form specified by FormId. + If its value is zero, then the link refers to the current page. + + @retval NULL There is not enough space left in Buffer to add the opcode. + @retval Other A pointer to the created opcode. + +**/ +UINT8 * +EFIAPI +HiiCreateGotoExOpCode ( + IN VOID *OpCodeHandle, + IN EFI_FORM_ID RefFormId, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN EFI_QUESTION_ID QuestionId, + IN EFI_QUESTION_ID RefQuestionId, + IN EFI_GUID *RefFormSetId, OPTIONAL + IN EFI_STRING_ID RefDevicePath + ) +{ + EFI_IFR_REF4 OpCode; + UINTN OpCodeSize; + + ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED))) == 0); + + ZeroMem (&OpCode, sizeof (OpCode)); + OpCode.Question.Header.Prompt = Prompt; + OpCode.Question.Header.Help = Help; + OpCode.Question.QuestionId = QuestionId; + OpCode.Question.Flags = QuestionFlags; + OpCode.FormId = RefFormId; + OpCode.QuestionId = RefQuestionId; + OpCode.DevicePath = RefDevicePath; + if (RefFormSetId != NULL) { + CopyMem (&OpCode.FormSetId, RefFormSetId, sizeof (OpCode.FormSetId)); + } + + // + // Cacluate OpCodeSize based on the input Ref value. + // Try to use the small OpCode to save size. + // + OpCodeSize = sizeof (EFI_IFR_REF); + if (RefDevicePath != 0) { + OpCodeSize = sizeof (EFI_IFR_REF4); + } else if (RefFormSetId != NULL) { + OpCodeSize = sizeof (EFI_IFR_REF3); + } else if (RefQuestionId != 0) { + OpCodeSize = sizeof (EFI_IFR_REF2); + } + + return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_REF_OP, OpCodeSize); +} + /** Create EFI_IFR_CHECKBOX_OP opcode. @@ -2869,7 +3467,8 @@ HiiCreateGotoOpCode ( @param[in] OpCodeHandle Handle to the buffer of opcodes. @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID - @param[in] VarOffset Offset in Storage + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @param[in] QuestionFlags Flags in Question Header @@ -2930,7 +3529,8 @@ HiiCreateCheckBoxOpCode ( @param[in] OpCodeHandle Handle to the buffer of opcodes. @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID - @param[in] VarOffset Offset in Storage + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @param[in] QuestionFlags Flags in Question Header @@ -2964,9 +3564,11 @@ HiiCreateNumericOpCode ( { EFI_IFR_NUMERIC OpCode; UINTN Position; + UINTN Length; ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED))) == 0); + Length = 0; ZeroMem (&OpCode, sizeof (OpCode)); OpCode.Question.QuestionId = QuestionId; OpCode.Question.VarStoreId = VarStoreId; @@ -2981,33 +3583,39 @@ HiiCreateNumericOpCode ( OpCode.data.u8.MinValue = (UINT8)Minimum; OpCode.data.u8.MaxValue = (UINT8)Maximum; OpCode.data.u8.Step = (UINT8)Step; + Length = 3; break; case EFI_IFR_NUMERIC_SIZE_2: OpCode.data.u16.MinValue = (UINT16)Minimum; OpCode.data.u16.MaxValue = (UINT16)Maximum; OpCode.data.u16.Step = (UINT16)Step; + Length = 6; break; case EFI_IFR_NUMERIC_SIZE_4: OpCode.data.u32.MinValue = (UINT32)Minimum; OpCode.data.u32.MaxValue = (UINT32)Maximum; OpCode.data.u32.Step = (UINT32)Step; + Length = 12; break; case EFI_IFR_NUMERIC_SIZE_8: OpCode.data.u64.MinValue = Minimum; OpCode.data.u64.MaxValue = Maximum; OpCode.data.u64.Step = Step; + Length = 24; break; } + Length += OFFSET_OF (EFI_IFR_NUMERIC, data); + if (DefaultsOpCodeHandle == NULL) { - return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, sizeof (OpCode)); + return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, Length); } Position = InternalHiiOpCodeHandlePosition (OpCodeHandle); - InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, sizeof (OpCode), 0, 1); + InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, Length, 0, 1); InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle); HiiCreateEndOpCode (OpCodeHandle); return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position; @@ -3023,7 +3631,8 @@ HiiCreateNumericOpCode ( @param[in] OpCodeHandle Handle to the buffer of opcodes. @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID - @param[in] VarOffset Offset in Storage + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @param[in] QuestionFlags Flags in Question Header @@ -3090,7 +3699,8 @@ HiiCreateStringOpCode ( @param[in] OpCodeHandle Handle to the buffer of opcodes. @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID - @param[in] VarOffset Offset in Storage + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @param[in] QuestionFlags Flags in Question Header @@ -3120,6 +3730,7 @@ HiiCreateOneOfOpCode ( { EFI_IFR_ONE_OF OpCode; UINTN Position; + UINTN Length; ASSERT (OptionsOpCodeHandle != NULL); ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0); @@ -3133,8 +3744,11 @@ HiiCreateOneOfOpCode ( OpCode.Question.Flags = QuestionFlags; OpCode.Flags = OneOfFlags; + Length = OFFSET_OF (EFI_IFR_ONE_OF, data); + Length += (1 << (OneOfFlags & EFI_IFR_NUMERIC_SIZE)) * 3; + Position = InternalHiiOpCodeHandlePosition (OpCodeHandle); - InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OP, sizeof (OpCode), 0, 1); + InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OP, Length, 0, 1); InternalHiiAppendOpCodes (OpCodeHandle, OptionsOpCodeHandle); if (DefaultsOpCodeHandle != NULL) { InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle); @@ -3153,7 +3767,8 @@ HiiCreateOneOfOpCode ( @param[in] OpCodeHandle Handle to the buffer of opcodes. @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID - @param[in] VarOffset Offset in Storage + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @param[in] QuestionFlags Flags in Question Header @@ -3255,7 +3870,8 @@ HiiCreateTextOpCode ( @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID, optional. If DateFlags is not QF_DATE_STORAGE_NORMAL, this parameter is ignored. - @param[in] VarOffset Offset in Storage, optional. If DateFlags is not + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair, optional. If DateFlags is not QF_DATE_STORAGE_NORMAL, this parameter is ignored. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @@ -3319,7 +3935,8 @@ HiiCreateDateOpCode ( @param[in] QuestionId Question ID @param[in] VarStoreId Storage ID, optional. If TimeFlags is not QF_TIME_STORAGE_NORMAL, this parameter is ignored. - @param[in] VarOffset Offset in Storage, optional. If TimeFlags is not + @param[in] VarOffset Offset in Storage or String ID of the name (VarName) + for this name/value pair, optional. If TimeFlags is not QF_TIME_STORAGE_NORMAL, this parameter is ignored. @param[in] Prompt String ID for Prompt @param[in] Help String ID for Help @@ -3610,7 +4227,7 @@ HiiUpdateForm ( UINTN BufferSize; UINT8 *UpdateBufferPos; EFI_HII_PACKAGE_HEADER *Package; - EFI_HII_PACKAGE_HEADER *TempPacakge; + EFI_HII_PACKAGE_HEADER *TempPackage; EFI_HII_PACKAGE_HEADER PackageHeader; BOOLEAN Updated; HII_LIB_OPCODE_BUFFER *OpCodeBufferStart; @@ -3622,7 +4239,7 @@ HiiUpdateForm ( ASSERT (HiiHandle != NULL); ASSERT (StartOpCodeHandle != NULL); UpdatePackageList = NULL; - TempPacakge = NULL; + TempPackage = NULL; HiiPackageList = NULL; // @@ -3668,8 +4285,8 @@ HiiUpdateForm ( // // Allocate temp buffer to store the temp updated package buffer // - TempPacakge = AllocateZeroPool (BufferSize); - if (TempPacakge == NULL) { + TempPackage = AllocateZeroPool (BufferSize); + if (TempPackage == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Finish; } @@ -3697,7 +4314,7 @@ HiiUpdateForm ( // // Check this package is the matched package. // - Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPacakge); + Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPackage); // // The matched package is found. Its package buffer will be updated by the input new data. // @@ -3709,7 +4326,7 @@ HiiUpdateForm ( // // Add updated package buffer // - Package = TempPacakge; + Package = TempPackage; } } @@ -3748,8 +4365,8 @@ Finish: FreePool (UpdatePackageList); } - if (TempPacakge != NULL) { - FreePool (TempPacakge); + if (TempPackage != NULL) { + FreePool (TempPackage); } return Status;