/** @file\r
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.\r
\r
-Copyright (c) 2007 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
UINTN Index;\r
CHAR16 TemStr[2];\r
\r
- ASSERT (StringPtr != NULL && Number != NULL && Len != NULL);\r
- ASSERT (*StringPtr != L'\0');\r
+ if (StringPtr == NULL || *StringPtr == L'\0' || Number == NULL || Len == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
\r
Buf = NULL;\r
\r
EFI_STRING NameStr;\r
EFI_STRING TempStr;\r
UINTN LengthString;\r
+ BOOLEAN FirstOneOfOption;\r
\r
LengthString = 0;\r
Status = EFI_SUCCESS;\r
BlockData = NULL;\r
DefaultData = NULL;\r
VarDefaultName = 0;\r
+ FirstOneOfOption = FALSE;\r
\r
//\r
// Go through the form package to parse OpCode one by one.\r
break;\r
\r
case EFI_IFR_FORM_OP:\r
+ case EFI_IFR_FORM_MAP_OP:\r
//\r
// No matched varstore is found and directly return.\r
//\r
// Add Block Data into VarStorageData BlockEntry\r
//\r
InsertBlockData (&VarStorageData->BlockEntry, &BlockData);\r
+ \r
+ if (IfrOpHdr->OpCode == EFI_IFR_ONE_OF_OP) {\r
+ //\r
+ // Set this flag to TRUE for the first oneof option.\r
+ //\r
+ FirstOneOfOption = TRUE;\r
+ } else if (IfrOpHdr->OpCode == EFI_IFR_NUMERIC_OP) {\r
+ //\r
+ // Numeric minimum value will be used as default value when no default is specified. \r
+ //\r
+\r
+ //\r
+ // Set standard ID and Get DefaultName String ID\r
+ //\r
+ VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+ Status = FindDefaultName (DefaultIdArray, VarDefaultId, &VarDefaultName);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+ //\r
+ // Prepare new DefaultValue\r
+ //\r
+ DefaultData = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
+ if (DefaultData == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ DefaultData->OpCode = IfrOpHdr->OpCode;\r
+ DefaultData->DefaultId = VarDefaultId;\r
+ DefaultData->DefaultName = VarDefaultName;\r
+\r
+ switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {\r
+ case EFI_IFR_NUMERIC_SIZE_1:\r
+ DefaultData->Value = (UINT64) IfrOneOf->data.u8.MinValue;\r
+ break;\r
+ \r
+ case EFI_IFR_NUMERIC_SIZE_2:\r
+ CopyMem (&DefaultData->Value, &IfrOneOf->data.u16.MinValue, sizeof (UINT16));\r
+ break;\r
+ \r
+ case EFI_IFR_NUMERIC_SIZE_4:\r
+ CopyMem (&DefaultData->Value, &IfrOneOf->data.u32.MinValue, sizeof (UINT32));\r
+ break;\r
+ \r
+ case EFI_IFR_NUMERIC_SIZE_8:\r
+ CopyMem (&DefaultData->Value, &IfrOneOf->data.u64.MinValue, sizeof (UINT64));\r
+ break;\r
+ }\r
+ //\r
+ // Add DefaultValue into current BlockData\r
+ //\r
+ InsertDefaultValue (BlockData, DefaultData); \r
+ }\r
break;\r
\r
case EFI_IFR_ORDERED_LIST_OP:\r
// Get Offset/Width by Question header and OneOf Flags\r
//\r
VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;\r
- VarWidth = sizeof (BOOLEAN);\r
+ VarWidth = (UINT16) sizeof (BOOLEAN);\r
\r
//\r
// Check whether this question is in requested block array.\r
break;\r
}\r
\r
- if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) {\r
+ if (((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) ||\r
+ (BlockData->OpCode == EFI_IFR_ONE_OF_OP && FirstOneOfOption)) {\r
+ //\r
+ // This flag is used to specify whether this option is the first. Set it to FALSE for the following options. \r
+ // The first oneof option value will be used as default value when no default value is specified. \r
+ //\r
+ FirstOneOfOption = FALSE;\r
//\r
// Set standard ID to Manufacture ID and Get DefaultName String ID\r
//\r
// Get Offset\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
- if (Status == EFI_OUT_OF_RESOURCES) {\r
+ if (EFI_ERROR (Status)) {\r
*Progress = ConfigRequest;\r
goto Exit;\r
}\r
// Get Width\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
- if (Status == EFI_OUT_OF_RESOURCES) {\r
+ if (EFI_ERROR (Status)) {\r
*Progress = ConfigRequest;\r
goto Exit;\r
}\r
@param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
instance.\r
@param ConfigResp A null-terminated Unicode string in <ConfigResp>\r
- format. It can be ConfigAltResp format string.\r
+ format.\r
@param Block A possibly null array of bytes representing the\r
current block. Only bytes referenced in the\r
ConfigResp string in the block are modified. If\r
value pair. Block is left updated and\r
Progress points at the '&' preceding the first\r
non-<BlockName>.\r
+ @retval EFI_DEVICE_ERROR Block not large enough. Progress undefined.\r
+ @retval EFI_NOT_FOUND Target for the specified routing data was not found.\r
+ Progress points to the "G" in "GUID" of the errant\r
+ routing data.\r
\r
**/\r
EFI_STATUS\r
UINTN Width;\r
UINT8 *Value;\r
UINTN BufferSize;\r
+ UINTN MaxBlockSize;\r
\r
if (This == NULL || BlockSize == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (ConfigResp == NULL || Block == NULL) {\r
- *Progress = ConfigResp;\r
+ *Progress = ConfigResp;\r
+ if (ConfigResp == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
StringPtr = ConfigResp;\r
BufferSize = *BlockSize;\r
Value = NULL;\r
+ MaxBlockSize = 0;\r
\r
//\r
// Jump <ConfigHdr>\r
// Get Width\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
- if (Status == EFI_OUT_OF_RESOURCES) {\r
+ if (EFI_ERROR (Status)) {\r
*Progress = ConfigResp;\r
goto Exit;\r
}\r
//\r
// Update the Block with configuration info\r
//\r
-\r
- if (Offset + Width > BufferSize) {\r
- return EFI_DEVICE_ERROR;\r
+ if ((Block != NULL) && (Offset + Width <= BufferSize)) {\r
+ CopyMem (Block + Offset, Value, Width);\r
+ }\r
+ if (Offset + Width > MaxBlockSize) {\r
+ MaxBlockSize = Offset + Width;\r
}\r
-\r
- CopyMem (Block + Offset, Value, Width);\r
- *BlockSize = Offset + Width - 1;\r
\r
FreePool (Value);\r
Value = NULL;\r
}\r
\r
*Progress = StringPtr + StrLen (StringPtr);\r
+ *BlockSize = MaxBlockSize - 1;\r
+\r
+ if (MaxBlockSize > BufferSize) {\r
+ *BlockSize = MaxBlockSize;\r
+ if (Block != NULL) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ }\r
+\r
+ if (Block == NULL) {\r
+ *Progress = ConfigResp;\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
return EFI_SUCCESS;\r
\r
Exit:\r
@param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
instance.\r
@param Configuration A null-terminated Unicode string in\r
- <MultiConfigAltResp> format. It is <ConfigAltResp> format.\r
+ <MultiConfigAltResp> format.\r
@param Guid A pointer to the GUID value to search for in the\r
routing portion of the ConfigResp string when\r
retrieving the requested data. If Guid is NULL,\r