X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FHiiDatabaseDxe%2FConfigRouting.c;h=30f602d30fe316aa2877106fa42a1990eba02a8c;hb=6738e4e7a02f9c1f3239670ce457c276e9f18186;hp=e377fc4ce0a71303c05f4f3bed1da59bf0461729;hpb=ff28420b56601362654101ffcb7f7716aba4ad0f;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index e377fc4ce0..30f602d30f 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1,8 +1,8 @@ /** @file Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. -Copyright (c) 2007 - 2008, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2007 - 2011, 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 http://opensource.org/licenses/bsd-license.php @@ -168,7 +168,7 @@ GetDevicePath ( Converts the unicode character of the string from uppercase to lowercase. This is a internal function. - @param Str String to be converted + @param ConfigString String to be converted **/ VOID @@ -453,8 +453,9 @@ GetValueOfNumber ( UINTN Index; CHAR16 TemStr[2]; - ASSERT (StringPtr != NULL && Number != NULL && Len != NULL); - ASSERT (*StringPtr != L'\0'); + if (StringPtr == NULL || *StringPtr == L'\0' || Number == NULL || Len == NULL) { + return EFI_INVALID_PARAMETER; + } Buf = NULL; @@ -773,7 +774,7 @@ InsertBlockData ( /** This function checks VarOffset and VarWidth is in the block range. - @param BlockArray The block array is to be checked. + @param RequestBlockArray The block array is to be checked. @param VarOffset Offset of var to the structure @param VarWidth Width of var. @@ -831,7 +832,7 @@ EFI_STATUS EFIAPI ParseIfrData ( IN UINT8 *Package, - IN UINT32 PackageLenth, + IN UINT32 PackageLength, IN EFI_STRING ConfigHdr, IN IFR_BLOCK_DATA *RequestBlockArray, IN OUT IFR_VARSTORAGE_DATA *VarStorageData, @@ -860,6 +861,7 @@ ParseIfrData ( EFI_STRING NameStr; EFI_STRING TempStr; UINTN LengthString; + BOOLEAN FirstOneOfOption; LengthString = 0; Status = EFI_SUCCESS; @@ -869,12 +871,13 @@ ParseIfrData ( BlockData = NULL; DefaultData = NULL; VarDefaultName = 0; + FirstOneOfOption = FALSE; // // Go through the form package to parse OpCode one by one. // IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); - while (IfrOffset < PackageLenth) { + while (IfrOffset < PackageLength) { IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset); switch (IfrOpHdr->OpCode) { @@ -951,6 +954,7 @@ ParseIfrData ( break; case EFI_IFR_FORM_OP: + case EFI_IFR_FORM_MAP_OP: // // No matched varstore is found and directly return. // @@ -1022,6 +1026,59 @@ ParseIfrData ( // Add Block Data into VarStorageData BlockEntry // InsertBlockData (&VarStorageData->BlockEntry, &BlockData); + + if (IfrOpHdr->OpCode == EFI_IFR_ONE_OF_OP) { + // + // Set this flag to TRUE for the first oneof option. + // + FirstOneOfOption = TRUE; + } else if (IfrOpHdr->OpCode == EFI_IFR_NUMERIC_OP) { + // + // Numeric minimum value will be used as default value when no default is specified. + // + + // + // Set standard ID and Get DefaultName String ID + // + VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; + Status = FindDefaultName (DefaultIdArray, VarDefaultId, &VarDefaultName); + if (EFI_ERROR (Status)) { + goto Done; + } + // + // Prepare new DefaultValue + // + DefaultData = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA)); + if (DefaultData == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + DefaultData->OpCode = IfrOpHdr->OpCode; + DefaultData->DefaultId = VarDefaultId; + DefaultData->DefaultName = VarDefaultName; + + switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DefaultData->Value = (UINT64) IfrOneOf->data.u8.MinValue; + break; + + case EFI_IFR_NUMERIC_SIZE_2: + CopyMem (&DefaultData->Value, &IfrOneOf->data.u16.MinValue, sizeof (UINT16)); + break; + + case EFI_IFR_NUMERIC_SIZE_4: + CopyMem (&DefaultData->Value, &IfrOneOf->data.u32.MinValue, sizeof (UINT32)); + break; + + case EFI_IFR_NUMERIC_SIZE_8: + CopyMem (&DefaultData->Value, &IfrOneOf->data.u64.MinValue, sizeof (UINT64)); + break; + } + // + // Add DefaultValue into current BlockData + // + InsertDefaultValue (BlockData, DefaultData); + } break; case EFI_IFR_ORDERED_LIST_OP: @@ -1098,7 +1155,7 @@ ParseIfrData ( // Get Offset/Width by Question header and OneOf Flags // VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset; - VarWidth = sizeof (BOOLEAN); + VarWidth = (UINT16) sizeof (BOOLEAN); // // Check whether this question is in requested block array. @@ -1401,7 +1458,13 @@ ParseIfrData ( break; } - if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) { + if (((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) || + (BlockData->OpCode == EFI_IFR_ONE_OF_OP && FirstOneOfOption)) { + // + // This flag is used to specify whether this option is the first. Set it to FALSE for the following options. + // The first oneof option value will be used as default value when no default value is specified. + // + FirstOneOfOption = FALSE; // // Set standard ID to Manufacture ID and Get DefaultName String ID // @@ -3041,7 +3104,7 @@ HiiBlockToConfig ( // Get Offset // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (Status == EFI_OUT_OF_RESOURCES) { + if (EFI_ERROR (Status)) { *Progress = ConfigRequest; goto Exit; } @@ -3065,7 +3128,7 @@ HiiBlockToConfig ( // Get Width // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (Status == EFI_OUT_OF_RESOURCES) { + if (EFI_ERROR (Status)) { *Progress = ConfigRequest; goto Exit; } @@ -3191,7 +3254,7 @@ Exit: @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance. @param ConfigResp A null-terminated Unicode string in - format. It can be ConfigAltResp format string. + format. @param Block A possibly null array of bytes representing the current block. Only bytes referenced in the ConfigResp string in the block are modified. If @@ -3223,6 +3286,10 @@ 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_NOT_FOUND Target for the specified routing data was not found. + Progress points to the "G" in "GUID" of the errant + routing data. **/ EFI_STATUS @@ -3244,13 +3311,14 @@ HiiConfigToBlock ( UINTN Width; UINT8 *Value; UINTN BufferSize; + UINTN MaxBlockSize; if (This == NULL || BlockSize == NULL || Progress == NULL) { return EFI_INVALID_PARAMETER; } - if (ConfigResp == NULL || Block == NULL) { - *Progress = ConfigResp; + *Progress = ConfigResp; + if (ConfigResp == NULL) { return EFI_INVALID_PARAMETER; } @@ -3260,6 +3328,7 @@ HiiConfigToBlock ( StringPtr = ConfigResp; BufferSize = *BlockSize; Value = NULL; + MaxBlockSize = 0; // // Jump @@ -3326,7 +3395,7 @@ HiiConfigToBlock ( // Get Width // Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); - if (Status == EFI_OUT_OF_RESOURCES) { + if (EFI_ERROR (Status)) { *Progress = ConfigResp; goto Exit; } @@ -3365,13 +3434,12 @@ HiiConfigToBlock ( // // Update the Block with configuration info // - - if (Offset + Width > BufferSize) { - return EFI_DEVICE_ERROR; + if ((Block != NULL) && (Offset + Width <= BufferSize)) { + CopyMem (Block + Offset, Value, Width); + } + if (Offset + Width > MaxBlockSize) { + MaxBlockSize = Offset + Width; } - - CopyMem (Block + Offset, Value, Width); - *BlockSize = Offset + Width - 1; FreePool (Value); Value = NULL; @@ -3396,6 +3464,20 @@ HiiConfigToBlock ( } *Progress = StringPtr + StrLen (StringPtr); + *BlockSize = MaxBlockSize - 1; + + if (MaxBlockSize > BufferSize) { + *BlockSize = MaxBlockSize; + if (Block != NULL) { + return EFI_DEVICE_ERROR; + } + } + + if (Block == NULL) { + *Progress = ConfigResp; + return EFI_INVALID_PARAMETER; + } + return EFI_SUCCESS; Exit: @@ -3414,7 +3496,7 @@ Exit: @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance. @param Configuration A null-terminated Unicode string in - format. It is format. + format. @param Guid A pointer to the GUID value to search for in the routing portion of the ConfigResp string when retrieving the requested data. If Guid is NULL,