Use the minimum value for Numeric and the first option value for OneOf as their default value when no specific default value is specified.

HII IFR Numeric and OneOf opcode may not specify their default value in opcode. And, zero may not be valid value for them. To make sure the valid value is set to default value, the minimum value for Numeric and the first option value for OneOf will be chosen as default value. 


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11497 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2011-04-01 09:39:11 +00:00
parent da0924fe8f
commit cf4c5a4270
2 changed files with 72 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -860,6 +860,7 @@ ParseIfrData (
EFI_STRING NameStr; EFI_STRING NameStr;
EFI_STRING TempStr; EFI_STRING TempStr;
UINTN LengthString; UINTN LengthString;
BOOLEAN FirstOneOfOption;
LengthString = 0; LengthString = 0;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -869,6 +870,7 @@ ParseIfrData (
BlockData = NULL; BlockData = NULL;
DefaultData = NULL; DefaultData = NULL;
VarDefaultName = 0; VarDefaultName = 0;
FirstOneOfOption = FALSE;
// //
// Go through the form package to parse OpCode one by one. // Go through the form package to parse OpCode one by one.
@ -1023,6 +1025,59 @@ ParseIfrData (
// Add Block Data into VarStorageData BlockEntry // Add Block Data into VarStorageData BlockEntry
// //
InsertBlockData (&VarStorageData->BlockEntry, &BlockData); 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; break;
case EFI_IFR_ORDERED_LIST_OP: case EFI_IFR_ORDERED_LIST_OP:
@ -1402,7 +1457,13 @@ ParseIfrData (
break; 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 // Set standard ID to Manufacture ID and Get DefaultName String ID
// //

View File

@ -1940,6 +1940,15 @@ GetQuestionDefault (
// For Questions without default // For Questions without default
// //
switch (Question->Operand) { switch (Question->Operand) {
case EFI_IFR_NUMERIC_OP:
//
// Take minimum value as numeric default value
//
if ((HiiValue->Value.u64 < Question->Minimum) || (HiiValue->Value.u64 > Question->Maximum)) {
HiiValue->Value.u64 = Question->Minimum;
}
break;
case EFI_IFR_ONE_OF_OP: case EFI_IFR_ONE_OF_OP:
// //
// Take first oneof option as oneof's default value // Take first oneof option as oneof's default value