X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FHiiDatabaseDxe%2FConfigRouting.c;h=30f602d30fe316aa2877106fa42a1990eba02a8c;hb=6738e4e7a02f9c1f3239670ce457c276e9f18186;hp=eca4fefc93a22e9fa7241e9ad7ccb784989ba818;hpb=e5eed7d3641d71d7ea539e5379ea9c6a5cd97004;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index eca4fefc93..30f602d30f 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1,7 +1,7 @@ /** @file Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. -Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+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 @@ -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; @@ -860,6 +861,7 @@ ParseIfrData ( EFI_STRING NameStr; EFI_STRING TempStr; UINTN LengthString; + BOOLEAN FirstOneOfOption; LengthString = 0; Status = EFI_SUCCESS; @@ -869,6 +871,7 @@ ParseIfrData ( BlockData = NULL; DefaultData = NULL; VarDefaultName = 0; + FirstOneOfOption = FALSE; // // Go through the form package to parse OpCode one by one. @@ -1023,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: @@ -1099,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. @@ -1402,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 // @@ -3042,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; } @@ -3066,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; } @@ -3224,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 @@ -3245,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; } @@ -3261,6 +3328,7 @@ HiiConfigToBlock ( StringPtr = ConfigResp; BufferSize = *BlockSize; Value = NULL; + MaxBlockSize = 0; // // Jump @@ -3327,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; } @@ -3366,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; @@ -3397,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: