X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FHiiDatabaseDxe%2FConfigRouting.c;h=1fb16817b76a6282bc2abf62a95a52737881545b;hb=7248790ee958c41b4ba2284f3b6835f1c3e505be;hp=95ca8d4777fd0ebc80093be3348adb2b13091fad;hpb=270e8dfd860199613f7d6e6e3357ed6175f8c6bf;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 95ca8d4777..1fb16817b7 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -355,6 +355,9 @@ OutputConfigBody ( } Length = TmpPtr - String; + if (Length == 0) { + return EFI_NOT_FOUND; + } Result = AllocateCopyPool (Length * sizeof (CHAR16), String); if (Result == NULL) { return EFI_OUT_OF_RESOURCES; @@ -1109,6 +1112,7 @@ GetVarStoreType ( { EFI_STATUS Status; UINTN IfrOffset; + UINTN PackageOffset; EFI_IFR_OP_HEADER *IfrOpHdr; CHAR16 *VarStoreName; EFI_STRING GuidStr; @@ -1118,6 +1122,7 @@ GetVarStoreType ( UINT8 *HiiFormPackage; UINTN PackageSize; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + EFI_HII_PACKAGE_HEADER *PackageHeader; HiiFormPackage = NULL; LengthString = 0; @@ -1125,16 +1130,33 @@ GetVarStoreType ( GuidStr = NULL; NameStr = NULL; TempStr = NULL; + *IsEfiVarstore = FALSE; Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize); if (EFI_ERROR (Status)) { return Status; } - IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); + IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); + PackageOffset = IfrOffset; + PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage; + while (IfrOffset < PackageSize) { - IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); + // + // More than one form packages exist. + // + if (PackageOffset >= PackageHeader->Length) { + // + // Process the new form package. + // + PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); + IfrOffset += PackageOffset; + PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset); + } + + IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); IfrOffset += IfrOpHdr->Length; + PackageOffset += IfrOpHdr->Length; if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) { IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; @@ -1189,6 +1211,13 @@ GetVarStoreType ( FreePool (GuidStr); FreePool (NameStr); FreePool (TempStr); + + // + // Already found the varstore, break; + // + if (*IsEfiVarstore) { + break; + } } } Done: @@ -1255,6 +1284,13 @@ IsThisVarstore ( GuidStr = NULL; TempStr = NULL; + // + // If ConfigHdr has name field and varstore not has name, return FALSE. + // + if (Name == NULL && StrStr (ConfigHdr, L"NAME=&") == NULL) { + return FALSE; + } + GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *)VarstoreGuid, 1, &GuidStr); if (Name != NULL) { GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr); @@ -1291,6 +1327,130 @@ Done: return RetVal; } +/** + This function parses Form Package to get the efi varstore info according to the request ConfigHdr. + + @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package. + @param ConfigHdr Request string ConfigHdr. If it is NULL, + the first found varstore will be as ConfigHdr. + @retval TRUE This hii package is the reqeust one. + @retval FALSE This hii package is not the reqeust one. +**/ +BOOLEAN +IsThisPackageList ( + IN HII_DATABASE_RECORD *DataBaseRecord, + IN EFI_STRING ConfigHdr + ) +{ + EFI_STATUS Status; + UINTN IfrOffset; + UINTN PackageOffset; + EFI_IFR_OP_HEADER *IfrOpHdr; + CHAR16 *VarStoreName; + UINT8 *HiiFormPackage; + UINTN PackageSize; + EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + EFI_HII_PACKAGE_HEADER *PackageHeader; + EFI_IFR_VARSTORE *IfrVarStore; + EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; + BOOLEAN FindVarstore; + + HiiFormPackage = NULL; + VarStoreName = NULL; + Status = EFI_SUCCESS; + FindVarstore = FALSE; + + Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize); + if (EFI_ERROR (Status)) { + return FALSE; + } + + IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); + PackageOffset = IfrOffset; + PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage; + + while (IfrOffset < PackageSize) { + // + // More than one form packages exist. + // + if (PackageOffset >= PackageHeader->Length) { + // + // Process the new form package. + // + PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); + IfrOffset += PackageOffset; + PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset); + } + + IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); + IfrOffset += IfrOpHdr->Length; + PackageOffset += IfrOpHdr->Length; + + switch (IfrOpHdr->OpCode) { + + case EFI_IFR_VARSTORE_OP: + IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; + + VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16)); + if (VarStoreName == NULL) { + goto Done; + } + AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName); + + if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { + FindVarstore = TRUE; + goto Done; + } + break; + + case EFI_IFR_VARSTORE_EFI_OP: + IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; + VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); + if (VarStoreName == NULL) { + goto Done; + } + AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName); + + if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { + FindVarstore = TRUE; + goto Done; + } + break; + + case EFI_IFR_VARSTORE_NAME_VALUE_OP: + IfrNameValueVarStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr; + + if (IsThisVarstore (&IfrNameValueVarStore->Guid, NULL, ConfigHdr)) { + FindVarstore = TRUE; + goto Done; + } + break; + + case EFI_IFR_FORM_OP: + case EFI_IFR_FORM_MAP_OP: + // + // No matched varstore is found and directly return. + // + goto Done; + break; + + default: + break; + } + } + +Done: + if (HiiFormPackage != NULL) { + FreePool (HiiFormPackage); + } + + if (VarStoreName != NULL) { + FreePool (VarStoreName); + } + + return FindVarstore; +} + /** Check whether the this op code is required. @@ -1414,6 +1574,7 @@ ParseIfrData ( { EFI_STATUS Status; UINTN IfrOffset; + UINTN PackageOffset; EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; EFI_IFR_OP_HEADER *IfrOpHdr; @@ -1430,32 +1591,57 @@ ParseIfrData ( IFR_DEFAULT_DATA DefaultData; IFR_DEFAULT_DATA *DefaultDataPtr; IFR_BLOCK_DATA *BlockData; - CHAR16 *VarStoreName; - UINT16 VarWidth; - UINT16 VarDefaultId; - BOOLEAN FirstOneOfOption; - LIST_ENTRY *LinkData; - LIST_ENTRY *LinkDefault; - EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; - - Status = EFI_SUCCESS; - BlockData = NULL; - DefaultDataPtr = NULL; - FirstOneOfOption = FALSE; + CHAR16 *VarStoreName; + UINT16 VarWidth; + UINT16 VarDefaultId; + BOOLEAN FirstOneOfOption; + LIST_ENTRY *LinkData; + LIST_ENTRY *LinkDefault; + EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; + EFI_HII_PACKAGE_HEADER *PackageHeader; + EFI_VARSTORE_ID VarStoreId; + + Status = EFI_SUCCESS; + BlockData = NULL; + DefaultDataPtr = NULL; + FirstOneOfOption = FALSE; + VarStoreId = 0; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); // // Go through the form package to parse OpCode one by one. // - IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); + PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); + PackageHeader = (EFI_HII_PACKAGE_HEADER *) Package; + IfrOffset = PackageOffset; while (IfrOffset < PackageLength) { + + // + // More than one form package found. + // + if (PackageOffset >= PackageHeader->Length) { + // + // Already found varstore for this request, break; + // + if (VarStoreId != 0) { + VarStoreId = 0; + } + + // + // Get next package header info. + // + IfrOffset += sizeof (EFI_HII_PACKAGE_HEADER); + PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); + PackageHeader = (EFI_HII_PACKAGE_HEADER *) (Package + IfrOffset); + } + IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset); switch (IfrOpHdr->OpCode) { case EFI_IFR_VARSTORE_OP: // // VarStore is found. Don't need to search any more. // - if (VarStorageData->VarStoreId != 0) { + if (VarStoreId != 0) { break; } @@ -1473,10 +1659,10 @@ ParseIfrData ( // Find the matched VarStore // CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid); - VarStorageData->VarStoreId = IfrVarStore->VarStoreId; VarStorageData->Size = IfrVarStore->Size; VarStorageData->Name = VarStoreName; VarStorageData->Type = EFI_HII_VARSTORE_BUFFER; + VarStoreId = IfrVarStore->VarStoreId; } break; @@ -1484,7 +1670,7 @@ ParseIfrData ( // // VarStore is found. Don't need to search any more. // - if (VarStorageData->VarStoreId != 0) { + if (VarStoreId != 0) { break; } @@ -1511,10 +1697,10 @@ ParseIfrData ( // Find the matched VarStore // CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid); - VarStorageData->VarStoreId = IfrEfiVarStore->VarStoreId; VarStorageData->Size = IfrEfiVarStore->Size; VarStorageData->Name = VarStoreName; VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER; + VarStoreId = IfrEfiVarStore->VarStoreId; } break; @@ -1522,7 +1708,7 @@ ParseIfrData ( // // VarStore is found. Don't need to search any more. // - if (VarStorageData->VarStoreId != 0) { + if (VarStoreId != 0) { break; } @@ -1533,8 +1719,8 @@ ParseIfrData ( // Find the matched VarStore // CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid); - VarStorageData->VarStoreId = IfrNameValueVarStore->VarStoreId; VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE; + VarStoreId = IfrNameValueVarStore->VarStoreId; } break; @@ -1557,7 +1743,7 @@ ParseIfrData ( // // No matched varstore is found and directly return. // - if (VarStorageData->VarStoreId == 0) { + if ( VarStoreId == 0) { Status = EFI_SUCCESS; goto Done; } @@ -1567,7 +1753,7 @@ ParseIfrData ( // // Ref question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if ( VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1575,7 +1761,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrRef = (EFI_IFR_REF4 *) IfrOpHdr; - if (IfrRef->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrRef->Question.VarStoreId != VarStoreId) { break; } VarWidth = (UINT16) (sizeof (EFI_HII_REF)); @@ -1595,7 +1781,7 @@ ParseIfrData ( // // Numeric and OneOf question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1603,7 +1789,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr; - if (IfrOneOf->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrOneOf->Question.VarStoreId != VarStoreId) { break; } VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); @@ -1672,7 +1858,7 @@ ParseIfrData ( // // OrderedList question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1680,7 +1866,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr; - if (IfrOrderedList->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrOrderedList->Question.VarStoreId != VarStoreId) { BlockData = NULL; break; } @@ -1704,7 +1890,7 @@ ParseIfrData ( // // CheckBox question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1712,7 +1898,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr; - if (IfrCheckBox->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrCheckBox->Question.VarStoreId != VarStoreId) { break; } VarWidth = (UINT16) sizeof (BOOLEAN); @@ -1791,7 +1977,7 @@ ParseIfrData ( // // Date question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1799,7 +1985,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrDate = (EFI_IFR_DATE *) IfrOpHdr; - if (IfrDate->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrDate->Question.VarStoreId != VarStoreId) { break; } @@ -1820,7 +2006,7 @@ ParseIfrData ( // // Time question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1828,7 +2014,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrTime = (EFI_IFR_TIME *) IfrOpHdr; - if (IfrTime->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrTime->Question.VarStoreId != VarStoreId) { break; } @@ -1849,7 +2035,7 @@ ParseIfrData ( // // String question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1857,7 +2043,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrString = (EFI_IFR_STRING *) IfrOpHdr; - if (IfrString->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrString->Question.VarStoreId != VarStoreId) { break; } @@ -1883,7 +2069,7 @@ ParseIfrData ( // // Password question is not in IFR Form. This IFR form is not valid. // - if (VarStorageData->VarStoreId == 0) { + if (VarStoreId == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -1891,7 +2077,7 @@ ParseIfrData ( // Check whether this question is for the requested varstore. // IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr; - if (IfrPassword->Question.VarStoreId != VarStorageData->VarStoreId) { + if (IfrPassword->Question.VarStoreId != VarStoreId) { break; } @@ -2076,19 +2262,32 @@ ParseIfrData ( // // End Opcode is for Var question. // - if (BlockData != NULL && BlockData->Scope > 0) { - BlockData->Scope--; + if (BlockData != NULL) { + if (BlockData->Scope > 0) { + BlockData->Scope--; + } + if (BlockData->Scope == 0) { + BlockData = NULL; + } } + break; default: - if (BlockData != NULL && BlockData->Scope > 0) { - BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope); + if (BlockData != NULL) { + if (BlockData->Scope > 0) { + BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope); + } + + if (BlockData->Scope == 0) { + BlockData = NULL; + } } break; } - IfrOffset += IfrOpHdr->Length; + IfrOffset += IfrOpHdr->Length; + PackageOffset += IfrOpHdr->Length; } Done: @@ -2864,12 +3063,12 @@ GetFullStringFromHiiFormPackages ( IFR_DEFAULT_DATA *DefaultIdArray; IFR_VARSTORAGE_DATA *VarStorageData; EFI_STRING DefaultAltCfgResp; - EFI_STRING ConfigHdr; - EFI_STRING StringPtr; - EFI_STRING Progress; - - if (DataBaseRecord == NULL || DevicePath == NULL || Request == NULL || AltCfgResp == NULL) { - return EFI_INVALID_PARAMETER; + EFI_STRING ConfigHdr; + EFI_STRING StringPtr; + EFI_STRING Progress; + + if (DataBaseRecord == NULL || DevicePath == NULL || Request == NULL || AltCfgResp == NULL) { + return EFI_INVALID_PARAMETER; } // @@ -2879,12 +3078,12 @@ GetFullStringFromHiiFormPackages ( DefaultIdArray = NULL; VarStorageData = NULL; DefaultAltCfgResp = NULL; - ConfigHdr = NULL; - HiiFormPackage = NULL; - PackageSize = 0; - Progress = *Request; - - Status = GetFormPackageData (DataBaseRecord, &HiiFormPackage, &PackageSize); + ConfigHdr = NULL; + HiiFormPackage = NULL; + PackageSize = 0; + Progress = *Request; + + Status = GetFormPackageData (DataBaseRecord, &HiiFormPackage, &PackageSize); if (EFI_ERROR (Status)) { return Status; } @@ -2989,7 +3188,7 @@ GetFullStringFromHiiFormPackages ( // // No requested varstore in IFR data and directly return // - if (VarStorageData->VarStoreId == 0) { + if (VarStorageData->Type == 0 && VarStorageData->Name == NULL) { Status = EFI_SUCCESS; goto Done; } @@ -3147,10 +3346,11 @@ GetConfigRespFromEfiVarStore ( UINT8 *VarStore; UINTN BufferSize; - Status = EFI_SUCCESS; - BufferSize = 0; - VarStore = NULL; - VarStoreName = NULL; + Status = EFI_SUCCESS; + BufferSize = 0; + VarStore = NULL; + VarStoreName = NULL; + *AccessProgress = Request; VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16)); if (VarStoreName == NULL) { @@ -3447,8 +3647,10 @@ ConfigRequestValidate ( Progress parameter is set to NULL. @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set to most recent & before the error or the beginning of the string. - @retval EFI_INVALID_PARAMETER Unknown name. Progress points to the & before the - name in question. + @retval EFI_INVALID_PARAMETER The ExtractConfig function of the underlying HII + Configuration Access Protocol returned + EFI_INVALID_PARAMETER. Progress set to most recent + & before the error or the beginning of the string. **/ EFI_STATUS @@ -3482,6 +3684,7 @@ HiiConfigRoutingExtractConfig ( BOOLEAN IsEfiVarStore; EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; EFI_STRING ErrorPtr; + UINTN DevicePathSize; if (This == NULL || Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; @@ -3567,11 +3770,8 @@ HiiConfigRoutingExtractConfig ( Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE); if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) { CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER); - if (CompareMem ( - DevicePath, - CurrentDevicePath, - GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath) - ) == 0) { + DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath); + if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Request)) { DriverHandle = Database->DriverHandle; HiiHandle = Database->Handle; break; @@ -3766,9 +3966,9 @@ Done: instance. @param Results Null-terminated Unicode string in format which has all values - filled in for the names in the Request string. - String to be allocated by the called function. - De-allocation is up to the caller. + filled in for the entirety of the current HII + database. String to be allocated by the called + function. De-allocation is up to the caller. @retval EFI_SUCCESS The Results string is filled with the values corresponding to all requested names. @@ -4005,6 +4205,7 @@ HiiConfigRoutingRouteConfig ( EFI_STRING AccessProgress; EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; BOOLEAN IsEfiVarstore; + UINTN DevicePathSize; if (This == NULL || Progress == NULL) { return EFI_INVALID_PARAMETER; @@ -4076,11 +4277,8 @@ HiiConfigRoutingRouteConfig ( if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) { CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER); - if (CompareMem ( - DevicePath, - CurrentDevicePath, - GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath) - ) == 0) { + DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath); + if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Configuration)) { DriverHandle = Database->DriverHandle; break; } @@ -4321,7 +4519,7 @@ HiiBlockToConfig ( // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); if (EFI_ERROR (Status)) { - *Progress = ConfigRequest; + *Progress = TmpPtr - 1; goto Exit; } Offset = 0; @@ -4334,7 +4532,7 @@ HiiBlockToConfig ( StringPtr += Length; if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { - *Progress = StringPtr - Length - StrLen (L"OFFSET=") - 1; + *Progress = TmpPtr - 1; Status = EFI_INVALID_PARAMETER; goto Exit; } @@ -4345,7 +4543,7 @@ HiiBlockToConfig ( // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); if (EFI_ERROR (Status)) { - *Progress = ConfigRequest; + *Progress = TmpPtr - 1; goto Exit; } Width = 0; @@ -4358,7 +4556,7 @@ HiiBlockToConfig ( StringPtr += Length; if (*StringPtr != 0 && *StringPtr != L'&') { - *Progress = StringPtr - Length - StrLen (L"&WIDTH="); + *Progress = TmpPtr - 1; Status = EFI_INVALID_PARAMETER; goto Exit; } @@ -4481,8 +4679,9 @@ Exit: (see below) is returned. @param BlockSize The length of the Block in units of UINT8. On input, this is the size of the Block. On output, - if successful, contains the index of the last - modified byte in the Block. + if successful, contains the largest index of the + modified byte in the Block, or the required buffer + size if the Block is not large enough. @param Progress On return, points to an element of the ConfigResp string filled in with the offset of the most recent '&' before the first failing name / value @@ -4502,7 +4701,8 @@ Exit: value pair. Block is left updated and Progress points at the '&' preceding the first non-. - @retval EFI_DEVICE_ERROR Block not large enough. Progress undefined. + @retval EFI_BUFFER_TOO_SMALL Block not large enough. Progress undefined. + BlockSize is updated with the required buffer size. @retval EFI_NOT_FOUND Target for the specified routing data was not found. Progress points to the "G" in "GUID" of the errant routing data. @@ -4520,6 +4720,7 @@ HiiConfigToBlock ( { HII_DATABASE_PRIVATE_DATA *Private; EFI_STRING StringPtr; + EFI_STRING TmpPtr; UINTN Length; EFI_STATUS Status; UINT8 *TmpBuffer; @@ -4578,13 +4779,14 @@ HiiConfigToBlock ( // ::= 'OFFSET='&'WIDTH='&'VALUE=' // while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { + TmpPtr = StringPtr; StringPtr += StrLen (L"&OFFSET="); // // Get Offset // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); if (EFI_ERROR (Status)) { - *Progress = ConfigResp; + *Progress = TmpPtr; goto Exit; } Offset = 0; @@ -4597,7 +4799,7 @@ HiiConfigToBlock ( StringPtr += Length; if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { - *Progress = StringPtr - Length - StrLen (L"&OFFSET="); + *Progress = TmpPtr; Status = EFI_INVALID_PARAMETER; goto Exit; } @@ -4608,7 +4810,7 @@ HiiConfigToBlock ( // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); if (EFI_ERROR (Status)) { - *Progress = ConfigResp; + *Progress = TmpPtr; goto Exit; } Width = 0; @@ -4621,7 +4823,7 @@ HiiConfigToBlock ( StringPtr += Length; if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) { - *Progress = StringPtr - Length - StrLen (L"&WIDTH="); + *Progress = TmpPtr; Status = EFI_INVALID_PARAMETER; goto Exit; } @@ -4632,13 +4834,13 @@ HiiConfigToBlock ( // Status = GetValueOfNumber (StringPtr, &Value, &Length); if (EFI_ERROR (Status)) { - *Progress = ConfigResp; + *Progress = TmpPtr; goto Exit; } StringPtr += Length; if (*StringPtr != 0 && *StringPtr != L'&') { - *Progress = StringPtr - Length - StrLen (L"&VALUE="); + *Progress = TmpPtr; Status = EFI_INVALID_PARAMETER; goto Exit; } @@ -4679,7 +4881,7 @@ HiiConfigToBlock ( if (MaxBlockSize > BufferSize) { *BlockSize = MaxBlockSize; if (Block != NULL) { - return EFI_DEVICE_ERROR; + return EFI_BUFFER_TOO_SMALL; } }