/** @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
This is a internal function.\r
\r
@param String UEFI configuration string\r
- @param DevicePath binary of a UEFI device path.\r
+ @param DevicePathData Binary of a UEFI device path.\r
\r
+ @retval EFI_NOT_FOUND The device path is not invalid.\r
@retval EFI_INVALID_PARAMETER Any incoming parameter is invalid.\r
@retval EFI_OUT_OF_RESOURCES Lake of resources to store neccesary structures.\r
@retval EFI_SUCCESS The device path is retrieved and translated to\r
EFI_STATUS\r
GetDevicePath (\r
IN EFI_STRING String,\r
- OUT UINT8 **DevicePath\r
+ OUT UINT8 **DevicePathData\r
)\r
{\r
- UINTN Length;\r
- EFI_STRING PathHdr;\r
- EFI_STRING DevicePathString;\r
- UINT8 *DevicePathBuffer;\r
- CHAR16 TemStr[2];\r
- UINTN Index;\r
- UINT8 DigitUint8;\r
-\r
- if (String == NULL || DevicePath == NULL) {\r
+ UINTN Length;\r
+ EFI_STRING PathHdr;\r
+ UINT8 *DevicePathBuffer;\r
+ CHAR16 TemStr[2];\r
+ UINTN Index;\r
+ UINT8 DigitUint8;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+\r
+ if (String == NULL || DevicePathData == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
if (*String == 0) {\r
return EFI_INVALID_PARAMETER;\r
}\r
-\r
+ //\r
+ // Check whether path data does exist.\r
+ //\r
String += StrLen (L"PATH=");\r
+ if (*String == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
PathHdr = String;\r
\r
//\r
// of UEFI device path.\r
//\r
for (Length = 0; *String != 0 && *String != L'&'; String++, Length++);\r
- DevicePathString = (EFI_STRING) AllocateZeroPool ((Length + 1) * sizeof (CHAR16));\r
- if (DevicePathString == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
+ //\r
+ // Check DevicePath Length\r
+ //\r
+ if (((Length + 1) / 2) < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
+ return EFI_NOT_FOUND;\r
}\r
- StrnCpy (DevicePathString, PathHdr, Length);\r
- *(DevicePathString + Length) = 0;\r
-\r
+ \r
//\r
// The data in <PathHdr> is encoded as hex UNICODE %02x bytes in the same order\r
// as the device path resides in RAM memory.\r
//\r
DevicePathBuffer = (UINT8 *) AllocateZeroPool ((Length + 1) / 2);\r
if (DevicePathBuffer == NULL) {\r
- FreePool (DevicePathString);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
-\r
+ \r
+ //\r
+ // Convert DevicePath\r
+ //\r
ZeroMem (TemStr, sizeof (TemStr));\r
- for (Index = 0; DevicePathString[Index] != L'\0'; Index ++) {\r
- TemStr[0] = DevicePathString[Index];\r
+ for (Index = 0; Index < Length; Index ++) {\r
+ TemStr[0] = PathHdr[Index];\r
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
if ((Index & 1) == 0) {\r
DevicePathBuffer [Index/2] = DigitUint8;\r
DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8);\r
}\r
}\r
-\r
- FreePool (DevicePathString);\r
\r
- *DevicePath = DevicePathBuffer;\r
+ //\r
+ // Validate DevicePath\r
+ //\r
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathBuffer;\r
+ while (!IsDevicePathEnd (DevicePath)) {\r
+ if ((DevicePath->Type == 0) || (DevicePath->SubType == 0) || (DevicePathNodeLength (DevicePath) < sizeof (EFI_DEVICE_PATH_PROTOCOL))) {\r
+ //\r
+ // Invalid device path\r
+ //\r
+ FreePool (DevicePathBuffer);\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ DevicePath = NextDevicePathNode (DevicePath);\r
+ }\r
\r
+ //\r
+ // return the device path\r
+ //\r
+ *DevicePathData = DevicePathBuffer;\r
return EFI_SUCCESS;\r
-\r
}\r
\r
/**\r
Converts the unicode character of the string from uppercase to lowercase.\r
This is a internal function.\r
\r
- @param Str String to be converted\r
+ @param ConfigString String to be converted\r
\r
**/\r
VOID\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
SizeAltCfgResp + StrSize (StringPtrDefault),\r
(VOID *) (*AltCfgResp)\r
);\r
+ if (*AltCfgResp == NULL) {\r
+ FreePool (AltConfigHdr);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
StrCat (*AltCfgResp, StringPtrDefault);\r
break;\r
} else {\r
SizeAltCfgResp + StrSize (StringPtrDefault),\r
(VOID *) (*AltCfgResp)\r
);\r
+ if (*AltCfgResp == NULL) {\r
+ FreePool (AltConfigHdr);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
StrCat (*AltCfgResp, StringPtrDefault);\r
*StringPtrEnd = TempChar;\r
}\r
\r
//\r
// Find next AltCfg String\r
- // \r
+ //\r
*(AltConfigHdr + HeaderLength) = L'\0';\r
StringPtrDefault = StrStr (StringPtrDefault + 1, AltConfigHdr); \r
}\r
-\r
- return EFI_SUCCESS; \r
-}\r
-\r
-/**\r
- This function finds the matched DefaultName for the input DefaultId\r
-\r
- @param DefaultIdArray Array stores the map table between DefaultId and DefaultName.\r
- @param VarDefaultId Default Id\r
- @param VarDefaultName Default Name string ID for the input default ID.\r
- \r
- @retval EFI_SUCCESS The mapped default name string ID is found.\r
- @retval EFI_NOT_FOUND The mapped default name string ID is not found.\r
-**/\r
-EFI_STATUS\r
-FindDefaultName (\r
- IN IFR_DEFAULT_DATA *DefaultIdArray, \r
- IN UINT16 VarDefaultId, \r
- OUT EFI_STRING_ID *VarDefaultName\r
- )\r
-{\r
- LIST_ENTRY *Link;\r
- IFR_DEFAULT_DATA *DefaultData;\r
-\r
- for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) {\r
- DefaultData = BASE_CR (Link, IFR_DEFAULT_DATA, Entry);\r
- if (DefaultData->DefaultId == VarDefaultId) {\r
- *VarDefaultName = DefaultData->DefaultName;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
\r
- return EFI_NOT_FOUND;\r
+ FreePool (AltConfigHdr);\r
+ return EFI_SUCCESS; \r
}\r
\r
/**\r
DefaultValueArray = BASE_CR (Link, IFR_DEFAULT_DATA, Entry);\r
if (DefaultValueArray->DefaultId == DefaultValueData->DefaultId) {\r
//\r
- // Update the default value array in BlockData.\r
- //\r
- DefaultValueArray->Value = DefaultValueData->Value;\r
- FreePool (DefaultValueData);\r
- return;\r
- } else if (DefaultValueArray->DefaultId > DefaultValueData->DefaultId) {\r
- //\r
- // Insert new default value data in the front of this default value array.\r
+ // DEFAULT_VALUE_FROM_OPCODE has high priority, DEFAULT_VALUE_FROM_DEFAULT has low priority.\r
//\r
- InsertTailList (Link, &DefaultValueData->Entry);\r
+ if (DefaultValueData->Type > DefaultValueArray->Type) {\r
+ //\r
+ // Update the default value array in BlockData.\r
+ //\r
+ DefaultValueArray->Value = DefaultValueData->Value;\r
+ DefaultValueArray->Type = DefaultValueData->Type;\r
+ DefaultValueArray->Cleaned = DefaultValueData->Cleaned;\r
+ }\r
return;\r
- }\r
+ } \r
}\r
\r
//\r
// Insert new default value data in tail.\r
//\r
- InsertTailList (Link, &DefaultValueData->Entry);\r
- return;\r
+ DefaultValueArray = AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
+ ASSERT (DefaultValueArray != NULL);\r
+ CopyMem (DefaultValueArray, DefaultValueData, sizeof (IFR_DEFAULT_DATA));\r
+ InsertTailList (Link, &DefaultValueArray->Entry);\r
}\r
\r
/**\r
/**\r
This function checks VarOffset and VarWidth is in the block range.\r
\r
- @param BlockArray The block array is to be checked. \r
+ @param RequestBlockArray The block array is to be checked. \r
@param VarOffset Offset of var to the structure\r
@param VarWidth Width of var.\r
\r
return FALSE;\r
}\r
\r
+/**\r
+ Get form package data from data base.\r
+\r
+ @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package.\r
+ @param HiiFormPackage The buffer saves the package data.\r
+ @param PackageSize The buffer size of the package data.\r
+\r
+**/\r
+EFI_STATUS\r
+GetFormPackageData (\r
+ IN HII_DATABASE_RECORD *DataBaseRecord,\r
+ IN OUT UINT8 **HiiFormPackage,\r
+ OUT UINTN *PackageSize\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
+ UINTN ResultSize;\r
+\r
+ if (DataBaseRecord == NULL || HiiFormPackage == NULL || PackageSize == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Size = 0;\r
+ ResultSize = 0;\r
+ //\r
+ // 0. Get Hii Form Package by HiiHandle\r
+ //\r
+ Status = ExportFormPackages (\r
+ &mPrivate, \r
+ DataBaseRecord->Handle, \r
+ DataBaseRecord->PackageList, \r
+ 0, \r
+ Size, \r
+ HiiFormPackage,\r
+ &ResultSize\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ \r
+ (*HiiFormPackage) = AllocatePool (ResultSize);\r
+ if (*HiiFormPackage == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get HiiFormPackage by HiiHandle\r
+ //\r
+ Size = ResultSize;\r
+ ResultSize = 0;\r
+ Status = ExportFormPackages (\r
+ &mPrivate, \r
+ DataBaseRecord->Handle, \r
+ DataBaseRecord->PackageList, \r
+ 0,\r
+ Size, \r
+ *HiiFormPackage,\r
+ &ResultSize\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (*HiiFormPackage);\r
+ }\r
+ \r
+ *PackageSize = Size;\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ This function parses Form Package to get the efi varstore info according to the request ConfigHdr.\r
+\r
+ @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package.\r
+ @param ConfigHdr Request string ConfigHdr. If it is NULL,\r
+ the first found varstore will be as ConfigHdr.\r
+ @param IsEfiVarstore Whether the request storage type is efi varstore type.\r
+ @param EfiVarStore The efi varstore info which will return.\r
+**/ \r
+EFI_STATUS\r
+GetVarStoreType (\r
+ IN HII_DATABASE_RECORD *DataBaseRecord,\r
+ IN EFI_STRING ConfigHdr,\r
+ OUT BOOLEAN *IsEfiVarstore,\r
+ OUT EFI_IFR_VARSTORE_EFI **EfiVarStore\r
+ \r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN IfrOffset;\r
+ EFI_IFR_OP_HEADER *IfrOpHdr;\r
+ CHAR16 *VarStoreName;\r
+ EFI_STRING GuidStr;\r
+ EFI_STRING NameStr;\r
+ EFI_STRING TempStr;\r
+ UINTN LengthString; \r
+ UINT8 *HiiFormPackage;\r
+ UINTN PackageSize;\r
+ EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
+ \r
+ HiiFormPackage = NULL;\r
+ LengthString = 0;\r
+ Status = EFI_SUCCESS;\r
+ GuidStr = NULL;\r
+ NameStr = NULL;\r
+ TempStr = NULL;\r
+\r
+ Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ while (IfrOffset < PackageSize) {\r
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); \r
+ IfrOffset += IfrOpHdr->Length;\r
+\r
+ if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) {\r
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
+ //\r
+ // If the length is small than the structure, this is from old efi \r
+ // varstore definition. Old efi varstore get config directly from \r
+ // GetVariable function.\r
+ //\r
+ if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) {\r
+ continue;\r
+ }\r
+\r
+ VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName);\r
+\r
+ GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrEfiVarStore->Guid, 1, &GuidStr);\r
+ GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr);\r
+ LengthString = StrLen (GuidStr);\r
+ LengthString = LengthString + StrLen (NameStr) + 1;\r
+ TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16));\r
+ if (TempStr == NULL) {\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
+ FreePool (VarStoreName);\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ StrCpy (TempStr, GuidStr);\r
+ StrCat (TempStr, NameStr);\r
+ if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) {\r
+ *EfiVarStore = (EFI_IFR_VARSTORE_EFI *) AllocateZeroPool (IfrOpHdr->Length);\r
+ if (*EfiVarStore == NULL) {\r
+ FreePool (VarStoreName);\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
+ FreePool (TempStr);\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ *IsEfiVarstore = TRUE;\r
+ CopyMem (*EfiVarStore, IfrEfiVarStore, IfrOpHdr->Length);\r
+ } \r
+ \r
+ //\r
+ // Free alllocated temp string.\r
+ //\r
+ FreePool (VarStoreName);\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
+ FreePool (TempStr);\r
+ }\r
+ }\r
+Done:\r
+ if (HiiFormPackage != NULL) {\r
+ FreePool (HiiFormPackage);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
/**\r
This function parses Form Package to get the block array and the default\r
value array according to the request ConfigHdr.\r
EFIAPI\r
ParseIfrData (\r
IN UINT8 *Package,\r
- IN UINT32 PackageLenth,\r
+ IN UINT32 PackageLength,\r
IN EFI_STRING ConfigHdr,\r
IN IFR_BLOCK_DATA *RequestBlockArray,\r
IN OUT IFR_VARSTORAGE_DATA *VarStorageData,\r
- OUT IFR_DEFAULT_DATA **PIfrDefaultIdArray\r
+ OUT IFR_DEFAULT_DATA *DefaultIdArray\r
)\r
{\r
EFI_STATUS Status;\r
UINTN IfrOffset;\r
EFI_IFR_VARSTORE *IfrVarStore;\r
+ EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
EFI_IFR_OP_HEADER *IfrOpHdr;\r
EFI_IFR_ONE_OF *IfrOneOf;\r
EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;\r
EFI_IFR_CHECKBOX *IfrCheckBox;\r
EFI_IFR_PASSWORD *IfrPassword;\r
EFI_IFR_STRING *IfrString;\r
- IFR_DEFAULT_DATA *DefaultIdArray;\r
- IFR_DEFAULT_DATA *DefaultData;\r
+ IFR_DEFAULT_DATA DefaultData;\r
+ IFR_DEFAULT_DATA *DefaultDataPtr;\r
IFR_BLOCK_DATA *BlockData;\r
CHAR16 *VarStoreName;\r
UINT16 VarOffset;\r
UINT16 VarWidth;\r
- EFI_STRING_ID VarDefaultName;\r
UINT16 VarDefaultId;\r
EFI_STRING GuidStr;\r
EFI_STRING NameStr;\r
EFI_STRING TempStr;\r
UINTN LengthString;\r
+ BOOLEAN FirstOneOfOption;\r
+ LIST_ENTRY *LinkData;\r
+ LIST_ENTRY *LinkDefault;\r
\r
- //\r
- // Initialize DefaultIdArray to store the map between DeaultId and DefaultName\r
- //\r
LengthString = 0;\r
Status = EFI_SUCCESS;\r
GuidStr = NULL;\r
NameStr = NULL;\r
TempStr = NULL;\r
BlockData = NULL;\r
- DefaultData = NULL;\r
- DefaultIdArray = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
- if (DefaultIdArray == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- InitializeListHead (&DefaultIdArray->Entry);\r
+ DefaultDataPtr = NULL;\r
+ FirstOneOfOption = FALSE;\r
+ ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));\r
\r
//\r
// Go through the form package to parse OpCode one by one.\r
//\r
IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
- while (IfrOffset < PackageLenth) {\r
+ while (IfrOffset < PackageLength) {\r
IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset);\r
\r
switch (IfrOpHdr->OpCode) {\r
LengthString = StrLen (GuidStr);\r
LengthString = LengthString + StrLen (NameStr) + 1;\r
TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16));\r
- FreePool (GuidStr);\r
- FreePool (NameStr);\r
- if (TempStr == NULL) {\r
+ if (TempStr == NULL) {\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
FreePool (VarStoreName);\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
//\r
// Free alllocated temp string.\r
//\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
+ FreePool (TempStr);\r
+ break;\r
+\r
+ case EFI_IFR_VARSTORE_EFI_OP:\r
+ //\r
+ // VarStore is found. Don't need to search any more.\r
+ //\r
+ if (VarStorageData->Size != 0) {\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Get the requied varstore information\r
+ // Add varstore by Guid and Name in ConfigHdr\r
+ // Make sure Offset is in varstore size and varstoreid\r
+ //\r
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
+\r
+ //\r
+ // If the length is small than the structure, this is from old efi \r
+ // varstore definition. Old efi varstore get config directly from \r
+ // GetVariable function.\r
+ // \r
+ if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) {\r
+ break;\r
+ }\r
+\r
+ VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName);\r
+\r
+ GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrEfiVarStore->Guid, 1, &GuidStr);\r
+ GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr);\r
+ LengthString = StrLen (GuidStr);\r
+ LengthString = LengthString + StrLen (NameStr) + 1;\r
+ TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16));\r
+ if (TempStr == NULL) {\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
+ FreePool (VarStoreName);\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ StrCpy (TempStr, GuidStr);\r
+ StrCat (TempStr, NameStr);\r
+ if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) {\r
+ //\r
+ // Find the matched VarStore\r
+ //\r
+ CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid);\r
+ VarStorageData->VarStoreId = IfrEfiVarStore->VarStoreId;\r
+ VarStorageData->Size = IfrEfiVarStore->Size;\r
+ VarStorageData->Name = VarStoreName;\r
+ } else {\r
+ //\r
+ // No found, free the allocated memory \r
+ //\r
+ FreePool (VarStoreName);\r
+ }\r
+ //\r
+ // Free alllocated temp string.\r
+ //\r
+ FreePool (GuidStr);\r
+ FreePool (NameStr);\r
FreePool (TempStr);\r
break;\r
\r
//\r
// Add new the map between default id and default name.\r
//\r
- DefaultData = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
- if (DefaultData == NULL) {\r
+ DefaultDataPtr = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
+ if (DefaultDataPtr == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- DefaultData->DefaultId = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId;\r
- DefaultData->DefaultName = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultName;\r
- InsertTailList (&DefaultIdArray->Entry, &DefaultData->Entry);\r
- DefaultData = NULL;\r
+ DefaultDataPtr->DefaultId = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId;\r
+ InsertTailList (&DefaultIdArray->Entry, &DefaultDataPtr->Entry);\r
+ DefaultDataPtr = NULL;\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
// Numeric and OneOf has the same opcode structure.\r
//\r
\r
+ //\r
+ // Numeric and OneOf question is not in IFR Form. This IFR form is not valid. \r
+ //\r
+ if (VarStorageData->Size == 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
//\r
// Check whether this question is for the requested varstore.\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
+ DefaultData.Type = DefaultValueFromDefault;\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
+ // Set default value base on the DefaultId list get from IFR data.\r
+ // \r
+ for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {\r
+ DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); \r
+ DefaultData.DefaultId = DefaultDataPtr->DefaultId;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+ }\r
+ }\r
break;\r
\r
case EFI_IFR_ORDERED_LIST_OP:\r
// width by EFI_IFR_ORDERED_LIST MaxContainers * OneofOption Type\r
// no default value and default id, how to define its default value?\r
//\r
- \r
+\r
+ //\r
+ // OrderedList question is not in IFR Form. This IFR form is not valid. \r
+ //\r
+ if (VarStorageData->Size == 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
//\r
// Check whether this question is for the requested varstore.\r
//\r
IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr;\r
if (IfrOrderedList->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ BlockData = NULL;\r
break;\r
}\r
- \r
+\r
//\r
// Get Offset/Width by Question header and OneOf Flags\r
//\r
VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset;\r
VarWidth = IfrOrderedList->MaxContainers;\r
-\r
- //\r
- // Check whether this question is in requested block array.\r
- //\r
- if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) {\r
- //\r
- // This question is not in the requested string. Skip it.\r
- //\r
- break;\r
- }\r
-\r
- //\r
- // Check this var question is in the var storage \r
- //\r
- if ((VarOffset + VarWidth) > VarStorageData->Size) {\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Done;\r
- }\r
\r
//\r
// Set Block Data\r
BlockData->OpCode = IfrOpHdr->OpCode;\r
BlockData->Scope = IfrOpHdr->Scope;\r
InitializeListHead (&BlockData->DefaultValueEntry);\r
- \r
- //\r
- // Add Block Data into VarStorageData BlockEntry\r
- //\r
- InsertBlockData (&VarStorageData->BlockEntry, &BlockData);\r
break;\r
\r
case EFI_IFR_CHECKBOX_OP:\r
// default id by DeaultOption DefaultId can override CheckBox Flags and Default value.\r
// \r
\r
+ //\r
+ // CheckBox question is not in IFR Form. This IFR form is not valid. \r
+ //\r
+ if (VarStorageData->Size == 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
//\r
// Check whether this question is for the requested varstore.\r
//\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
InsertBlockData (&VarStorageData->BlockEntry, &BlockData);\r
\r
//\r
- // Add default value by CheckBox Flags \r
+ // Add default value for standard ID by CheckBox Flag\r
//\r
+ VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+ //\r
+ // Prepare new DefaultValue\r
+ //\r
+ DefaultData.DefaultId = VarDefaultId;\r
if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT) == EFI_IFR_CHECKBOX_DEFAULT) {\r
//\r
- // Set standard ID to Manufacture 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
+ // When flag is set, defautl value is TRUE.\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->DefaultId = VarDefaultId;\r
- DefaultData->DefaultName = VarDefaultName;\r
- DefaultData->Value = 1;\r
+ DefaultData.Type = DefaultValueFromFlag;\r
+ DefaultData.Value = 1;\r
+ } else {\r
//\r
- // Add DefaultValue into current BlockData\r
+ // When flag is not set, defautl value is FASLE.\r
//\r
- InsertDefaultValue (BlockData, DefaultData);\r
+ DefaultData.Type = DefaultValueFromDefault;\r
+ DefaultData.Value = 0;\r
}\r
+ //\r
+ // Add DefaultValue into current BlockData\r
+ //\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
\r
+ //\r
+ // Add default value for Manufacture ID by CheckBox Flag\r
+ //\r
+ VarDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
+ //\r
+ // Prepare new DefaultValue\r
+ //\r
+ DefaultData.DefaultId = VarDefaultId;\r
if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) == EFI_IFR_CHECKBOX_DEFAULT_MFG) {\r
//\r
- // Set standard ID to Manufacture ID and Get DefaultName String ID\r
- //\r
- VarDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
- Status = FindDefaultName (DefaultIdArray, VarDefaultId, &VarDefaultName);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
+ // When flag is set, defautl value is TRUE.\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->DefaultId = VarDefaultId;\r
- DefaultData->DefaultName = VarDefaultName;\r
- DefaultData->Value = 1;\r
+ DefaultData.Type = DefaultValueFromFlag;\r
+ DefaultData.Value = 1;\r
+ } else {\r
//\r
- // Add DefaultValue into current BlockData\r
+ // When flag is not set, defautl value is FASLE.\r
//\r
- InsertDefaultValue (BlockData, DefaultData);\r
+ DefaultData.Type = DefaultValueFromDefault; \r
+ DefaultData.Value = 0;\r
}\r
+ //\r
+ // Add DefaultValue into current BlockData\r
+ //\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
break;\r
\r
case EFI_IFR_STRING_OP:\r
// no default value, only block array\r
//\r
\r
+ //\r
+ // String question is not in IFR Form. This IFR form is not valid. \r
+ //\r
+ if (VarStorageData->Size == 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
//\r
// Check whether this question is for the requested varstore.\r
//\r
// no default value, only block array\r
//\r
\r
+ //\r
+ // Password question is not in IFR Form. This IFR form is not valid. \r
+ //\r
+ if (VarStorageData->Size == 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
//\r
// Check whether this question is for the requested varstore.\r
//\r
// Invalid ordered list option data type.\r
//\r
Status = EFI_INVALID_PARAMETER;\r
+ FreePool (BlockData);\r
goto Done;\r
}\r
+\r
//\r
// Calculate Ordered list QuestionId width.\r
//\r
BlockData->Width = (UINT16) (BlockData->Width * VarWidth);\r
- BlockData = NULL;\r
- break;\r
- }\r
-\r
- if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) {\r
//\r
- // Set standard ID to Manufacture ID and Get DefaultName String ID\r
+ // Check whether this question is in requested block array.\r
//\r
- VarDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
- Status = FindDefaultName (DefaultIdArray, VarDefaultId, &VarDefaultName);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
+ if (!BlockArrayCheck (RequestBlockArray, BlockData->Offset, BlockData->Width)) {\r
+ //\r
+ // This question is not in the requested string. Skip it.\r
+ //\r
+ FreePool (BlockData);\r
+ BlockData = NULL;\r
+ break;\r
}\r
//\r
- // Prepare new DefaultValue\r
+ // Check this var question is in the var storage \r
//\r
- DefaultData = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
- if (DefaultData == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ if ((BlockData->Offset + BlockData->Width) > VarStorageData->Size) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ FreePool (BlockData);\r
goto Done;\r
}\r
- DefaultData->DefaultId = VarDefaultId;\r
- DefaultData->DefaultName = VarDefaultName;\r
- DefaultData->Value = IfrOneOfOption->Value.u64;\r
//\r
- // Add DefaultValue into current BlockData\r
+ // Add Block Data into VarStorageData BlockEntry\r
+ //\r
+ InsertBlockData (&VarStorageData->BlockEntry, &BlockData);\r
+ //\r
+ // No default data for OrderedList.\r
//\r
- InsertDefaultValue (BlockData, DefaultData);\r
+ BlockData = NULL;\r
+ break;\r
}\r
\r
- if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG) {\r
- //\r
- // Set default ID to Manufacture ID and Get DefaultName String ID\r
+ //\r
+ // 1. Set default value for OneOf option when flag field has default attribute.\r
+ //\r
+ if (((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) ||\r
+ ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG)) {\r
//\r
- VarDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
- Status = FindDefaultName (DefaultIdArray, VarDefaultId, &VarDefaultName);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\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
// 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
+ DefaultData.Type = DefaultValueFromFlag;\r
+ DefaultData.Value = IfrOneOfOption->Value.u64;\r
+ if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) {\r
+ DefaultData.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+ } \r
+ if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG) {\r
+ DefaultData.DefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
}\r
- DefaultData->DefaultId = VarDefaultId;\r
- DefaultData->DefaultName = VarDefaultName;\r
- DefaultData->Value = IfrOneOfOption->Value.u64;\r
- //\r
- // Add DefaultValue into current BlockData\r
+\r
+ \r
+ }\r
+ \r
+ //\r
+ // 2. Set as the default value when this is the first option.\r
+ // The first oneof option value will be used as default value when no default value is specified. \r
+ //\r
+ if (FirstOneOfOption) {\r
+ // This flag is used to specify whether this option is the first. Set it to FALSE for the following options. \r
+ FirstOneOfOption = FALSE;\r
+ \r
//\r
- InsertDefaultValue (BlockData, DefaultData);\r
+ // Prepare new DefaultValue\r
+ // \r
+ DefaultData.Type = DefaultValueFromDefault;\r
+ DefaultData.Value = IfrOneOfOption->Value.u64; \r
+ for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {\r
+ DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); \r
+ DefaultData.DefaultId = DefaultDataPtr->DefaultId;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+ } \r
}\r
break;\r
\r
break;\r
}\r
//\r
- // Get the DefaultId and DefaultName String ID\r
+ // Get the DefaultId\r
//\r
IfrDefault = (EFI_IFR_DEFAULT *) IfrOpHdr;\r
VarDefaultId = IfrDefault->DefaultId;\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
+ DefaultData.Type = DefaultValueFromOpcode;\r
+ DefaultData.DefaultId = VarDefaultId;\r
+ DefaultData.Value = IfrDefault->Value.u64; \r
+ \r
+ // If the value field is expression, set the cleaned flag.\r
+ if (IfrDefault->Type == EFI_IFR_TYPE_OTHER) {\r
+ DefaultData.Cleaned = TRUE;\r
}\r
- DefaultData->DefaultId = VarDefaultId;\r
- DefaultData->DefaultName = VarDefaultName;\r
- DefaultData->Value = IfrDefault->Value.u64;\r
//\r
// Add DefaultValue into current BlockData\r
//\r
- InsertDefaultValue (BlockData, DefaultData);\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+ \r
+ //\r
+ // After insert the default value, reset the cleaned value for next \r
+ // time used. If not set here, need to set the value before everytime \r
+ // use it.\r
+ //\r
+ DefaultData.Cleaned = FALSE;\r
break;\r
case EFI_IFR_END_OP:\r
//\r
- // End Opcode is for Var.\r
+ // End Opcode is for Var question.\r
//\r
if (BlockData != NULL && BlockData->Scope > 0) {\r
BlockData->Scope--;\r
}\r
\r
Done:\r
- //\r
- // Set the defualt ID array.\r
- //\r
- *PIfrDefaultIdArray = DefaultIdArray;\r
+ for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) {\r
+ BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry);\r
+ for (LinkDefault = BlockData->DefaultValueEntry.ForwardLink; LinkDefault != &BlockData->DefaultValueEntry; ) {\r
+ DefaultDataPtr = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry);\r
+ LinkDefault = LinkDefault->ForwardLink;\r
+ if (DefaultDataPtr->Cleaned == TRUE) {\r
+ RemoveEntryList (&DefaultDataPtr->Entry);\r
+ FreePool (DefaultDataPtr);\r
+ }\r
+ }\r
+ }\r
\r
return Status; \r
}\r
When Request points to NULL string, the request string and default value string \r
for each varstore in form package will return. \r
\r
- @param HiiHandle Hii Handle which Hii Packages are registered.\r
+ @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package.\r
@param DevicePath Device Path which Hii Config Access Protocol is registered.\r
@param Request Pointer to a null-terminated Unicode string in\r
<ConfigRequest> format. When it doesn't contain\r
When Request points to NULL, the default value string \r
for each varstore in form package will be merged into \r
a <MultiConfigAltResp> format string and return.\r
+ @param PointerProgress Optional parameter, it can be be NULL. \r
+ When it is not NULL, if Request is NULL, it returns NULL. \r
+ On return, points to a character in the Request\r
+ string. Points to the string's null terminator if\r
+ request was successful. Points to the most recent\r
+ & before the first failing name / value pair (or\r
+ the beginning of the string if the failure is in\r
+ the first name / value pair) if the request was\r
+ not successful.\r
@retval EFI_SUCCESS The Results string is set to the full request string.\r
And AltCfgResp contains all default value string.\r
@retval EFI_OUT_OF_RESOURCES Not enough memory for the return string.\r
@retval EFI_NOT_FOUND The varstore (Guid and Name) in Request string \r
can't be found in Form package.\r
@retval EFI_NOT_FOUND HiiPackage can't be got on the input HiiHandle.\r
- @retval EFI_INVALID_PARAMETER *Request points to NULL.\r
+ @retval EFI_INVALID_PARAMETER Request points to NULL.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
GetFullStringFromHiiFormPackages (\r
- IN EFI_HII_HANDLE HiiHandle,\r
+ IN HII_DATABASE_RECORD *DataBaseRecord,\r
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
IN OUT EFI_STRING *Request,\r
- IN OUT EFI_STRING *AltCfgResp\r
+ IN OUT EFI_STRING *AltCfgResp,\r
+ OUT EFI_STRING *PointerProgress OPTIONAL\r
)\r
{\r
EFI_STATUS Status;\r
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;\r
- UINT32 PackageListLength; \r
- UINTN BufferSize;\r
+ UINT8 *HiiFormPackage;\r
+ UINTN PackageSize;\r
IFR_BLOCK_DATA *RequestBlockArray;\r
IFR_BLOCK_DATA *BlockData;\r
IFR_BLOCK_DATA *NextBlockData;\r
IFR_DEFAULT_DATA *DefaultValueData;\r
IFR_DEFAULT_DATA *DefaultId;\r
IFR_DEFAULT_DATA *DefaultIdArray;\r
- EFI_HII_PACKAGE_HEADER PacakgeHeader;\r
- UINT32 PackageOffset;\r
IFR_VARSTORAGE_DATA *VarStorageData;\r
EFI_STRING DefaultAltCfgResp;\r
EFI_STRING FullConfigRequest;\r
EFI_STRING NameStr;\r
EFI_STRING PathStr;\r
EFI_STRING StringPtr;\r
+ EFI_STRING Progress;\r
UINTN Length;\r
UINT8 *TmpBuffer;\r
UINT16 Offset;\r
LIST_ENTRY *Link;\r
LIST_ENTRY *LinkData;\r
LIST_ENTRY *LinkDefault;\r
+ BOOLEAN DataExist;\r
+\r
+ if (DataBaseRecord == NULL || DevicePath == NULL || Request == NULL || AltCfgResp == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
\r
//\r
// Initialize the local variables.\r
//\r
RequestBlockArray = NULL;\r
+ DefaultIdArray = NULL;\r
VarStorageData = NULL;\r
DefaultAltCfgResp = NULL;\r
FullConfigRequest = NULL;\r
ConfigHdr = NULL;\r
- DefaultIdArray = NULL;\r
GuidStr = NULL;\r
NameStr = NULL;\r
PathStr = NULL;\r
+ HiiFormPackage = NULL;\r
+ PackageSize = 0;\r
+ DataExist = FALSE;\r
+ Progress = *Request;\r
\r
- //\r
- // 1. Get HiiPackage by HiiHandle\r
- //\r
- BufferSize = 0;\r
- HiiPackageList = NULL;\r
- Status = HiiExportPackageLists (&mPrivate.HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
-\r
- //\r
- // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.\r
- //\r
- if (Status != EFI_BUFFER_TOO_SMALL) {\r
- return Status;\r
- }\r
-\r
- HiiPackageList = AllocatePool (BufferSize);\r
- if (HiiPackageList == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Get PackageList on HiiHandle\r
- //\r
- Status = HiiExportPackageLists (&mPrivate.HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
+ Status = GetFormPackageData (DataBaseRecord, &HiiFormPackage, &PackageSize);\r
if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- //\r
- // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray.\r
- // 1) Request is NULL.\r
- // 2) Request is not NULL. And it doesn't contain any BlockArray.\r
- // 3) Request is not NULL. And it containts BlockArray.\r
- //\r
-\r
- //\r
- // Initialize VarStorageData to store the var store Block and Default value information.\r
- //\r
- VarStorageData = (IFR_VARSTORAGE_DATA *) AllocateZeroPool (sizeof (IFR_VARSTORAGE_DATA));\r
- if (VarStorageData == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Done;\r
+ return Status;\r
}\r
\r
- InitializeListHead (&VarStorageData->Entry);\r
- InitializeListHead (&VarStorageData->BlockEntry);\r
-\r
//\r
- // Gte the request block array by Request String \r
+ // 1. Get the request block array by Request String when Request string containts the block array.\r
//\r
StringPtr = NULL;\r
if (*Request != NULL) {\r
- StringPtr = StrStr (*Request, L"&OFFSET=");\r
+ StringPtr = *Request;\r
+ //\r
+ // Jump <ConfigHdr>\r
+ //\r
+ if (StrnCmp (StringPtr, L"GUID=", StrLen (L"GUID=")) != 0) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
+ StringPtr += StrLen (L"GUID=");\r
+ while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&NAME=", StrLen (L"&NAME=")) != 0) {\r
+ StringPtr++;\r
+ }\r
+ if (*StringPtr == L'\0') {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
+ StringPtr += StrLen (L"&NAME=");\r
+ while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&PATH=", StrLen (L"&PATH=")) != 0) {\r
+ StringPtr++;\r
+ }\r
+ if (*StringPtr == L'\0') {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
+ StringPtr += StrLen (L"&PATH=");\r
+ while (*StringPtr != L'\0' && *StringPtr != L'&') {\r
+ StringPtr ++;\r
+ }\r
+ //\r
+ // Check the following string &OFFSET=\r
+ //\r
+ if (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) != 0) {\r
+ Progress = StringPtr;\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ } else if (*StringPtr == L'\0') {\r
+ //\r
+ // No request block is found.\r
+ //\r
+ StringPtr = NULL;\r
+ }\r
}\r
if (StringPtr != NULL) {\r
//\r
while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) {\r
//\r
// Skip the OFFSET string\r
- // \r
+ //\r
+ Progress = StringPtr;\r
StringPtr += StrLen (L"&OFFSET=");\r
//\r
// Get Offset\r
BlockData->Offset = Offset;\r
BlockData->Width = Width;\r
InsertBlockData (&RequestBlockArray->Entry, &BlockData);\r
+ \r
+ //\r
+ // Skip &VALUE string if &VALUE does exists.\r
+ //\r
+ if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) == 0) {\r
+ StringPtr += StrLen (L"&VALUE=");\r
+\r
+ //\r
+ // Get Value\r
+ //\r
+ Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
\r
+ StringPtr += Length;\r
+ if (*StringPtr != 0 && *StringPtr != L'&') {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Done;\r
+ }\r
+ }\r
//\r
// If '\0', parsing is finished. \r
//\r
}\r
\r
//\r
- // Get the form package\r
+ // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray.\r
//\r
- PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
- PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);\r
- while (PackageOffset < PackageListLength) {\r
- CopyMem (&PacakgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader));\r
\r
- if (PacakgeHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
- //\r
- // Reset VarStorageData\r
- //\r
- VarStorageData->Size = 0;\r
- VarStorageData->VarStoreId = 0;\r
- if (VarStorageData->Name != NULL) {\r
- FreePool (VarStorageData->Name);\r
- VarStorageData->Name = NULL;\r
- }\r
-\r
- //\r
- // Parse the opcode in form package \r
- //\r
- Status = ParseIfrData ((UINT8 *) HiiPackageList + PackageOffset, PacakgeHeader.Length, *Request, RequestBlockArray, VarStorageData, &DefaultIdArray);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
+ //\r
+ // Initialize DefaultIdArray to store the map between DeaultId and DefaultName\r
+ //\r
+ DefaultIdArray = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));\r
+ if (DefaultIdArray == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ InitializeListHead (&DefaultIdArray->Entry);\r
\r
- //\r
- // Only one form is in a pacakge list.\r
- //\r
- break;\r
- }\r
+ //\r
+ // Initialize VarStorageData to store the var store Block and Default value information.\r
+ //\r
+ VarStorageData = (IFR_VARSTORAGE_DATA *) AllocateZeroPool (sizeof (IFR_VARSTORAGE_DATA));\r
+ if (VarStorageData == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ InitializeListHead (&VarStorageData->Entry);\r
+ InitializeListHead (&VarStorageData->BlockEntry);\r
\r
- PackageOffset += PacakgeHeader.Length;\r
+ //\r
+ // Parse the opcode in form pacakge to get the default setting.\r
+ //\r
+ Status = ParseIfrData (HiiFormPackage, (UINT32) PackageSize, *Request, RequestBlockArray, VarStorageData, DefaultIdArray);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
}\r
\r
//\r
// No requested varstore in IFR data and directly return\r
//\r
if (VarStorageData->Size == 0) {\r
+ Status = EFI_SUCCESS;\r
goto Done;\r
}\r
\r
// Compute the length of the entire request starting with <ConfigHdr> and a \r
// Null-terminator\r
//\r
- Length = StrLen (ConfigHdr) + 1;\r
+ DataExist = FALSE;\r
+ Length = StrLen (ConfigHdr) + 1;\r
\r
for (Link = VarStorageData->BlockEntry.ForwardLink; Link != &VarStorageData->BlockEntry; Link = Link->ForwardLink) {\r
//\r
// <BlockName> ::= &OFFSET=1234&WIDTH=1234\r
// | 8 | 4 | 7 | 4 |\r
//\r
+ DataExist = TRUE;\r
Length = Length + (8 + 4 + 7 + 4);\r
}\r
\r
+ //\r
+ // No any request block data is found. The request string can't be constructed.\r
+ //\r
+ if (!DataExist) {\r
+ Status = EFI_SUCCESS;\r
+ goto Done;\r
+ }\r
+\r
//\r
// Allocate buffer for the entire <ConfigRequest>\r
//\r
FullConfigRequest = AllocateZeroPool (Length * sizeof (CHAR16));\r
if (FullConfigRequest == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
StringPtr = FullConfigRequest;\r
// Go through all VarStorageData Entry and get the DefaultId array for each one\r
// Then construct them all to : ConfigHdr AltConfigHdr ConfigBody AltConfigHdr ConfigBody\r
//\r
-\r
+ DataExist = FALSE;\r
//\r
// Add length for <ConfigHdr> + '\0'\r
//\r
// Add length for "&OFFSET=XXXX&WIDTH=YYYY&VALUE=zzzzzzzzzzzz"\r
// | 8 | 4 | 7 | 4 | 7 | Width * 2 |\r
//\r
- Length += (8 + 4 + 7 + 4 + 7 + BlockData->Width * 2); \r
+ Length += (8 + 4 + 7 + 4 + 7 + BlockData->Width * 2);\r
+ DataExist = TRUE;\r
}\r
}\r
}\r
}\r
+ \r
+ //\r
+ // No default value is found. The default string doesn't exist.\r
+ //\r
+ if (!DataExist) {\r
+ Status = EFI_SUCCESS;\r
+ goto Done;\r
+ }\r
\r
//\r
// Allocate buffer for the entire <DefaultAltCfgResp>\r
//\r
DefaultAltCfgResp = AllocateZeroPool (Length * sizeof (CHAR16));\r
if (DefaultAltCfgResp == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
StringPtr = DefaultAltCfgResp;\r
(1 + StrLen (ConfigHdr) + 8 + 4 + 1) * sizeof (CHAR16), \r
L"&%s&ALTCFG=%04X", \r
ConfigHdr, \r
- DefaultId->DefaultName\r
+ DefaultId->DefaultId\r
);\r
StringPtr += StrLen (StringPtr);\r
\r
//\r
// 5. Merge string into the input AltCfgResp if the iput *AltCfgResp is not NULL.\r
//\r
- if (*AltCfgResp != NULL) {\r
+ if (*AltCfgResp != NULL && DefaultAltCfgResp != NULL) {\r
Status = MergeDefaultString (AltCfgResp, DefaultAltCfgResp);\r
FreePool (DefaultAltCfgResp);\r
- } else {\r
- *AltCfgResp = DefaultAltCfgResp;\r
+ } else if (*AltCfgResp == NULL) {\r
+ *AltCfgResp = DefaultAltCfgResp;\r
}\r
\r
Done:\r
//\r
// Free Pacakge data\r
//\r
- if (HiiPackageList != NULL) {\r
- FreePool (HiiPackageList);\r
+ if (HiiFormPackage != NULL) {\r
+ FreePool (HiiFormPackage);\r
+ }\r
+\r
+ if (PointerProgress != NULL) {\r
+ if (*Request == NULL) {\r
+ *PointerProgress = NULL;\r
+ } else if (EFI_ERROR (Status)) {\r
+ *PointerProgress = Progress;\r
+ } else {\r
+ *PointerProgress = *Request + StrLen (*Request);\r
+ }\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ This function gets the full request resp string by \r
+ parsing IFR data in HII form packages.\r
+\r
+ @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
+ instance.\r
+ @param EfiVarStoreInfo The efi varstore info which is save in the EFI \r
+ varstore data structure. \r
+ @param Request Pointer to a null-terminated Unicode string in\r
+ <ConfigRequest> format.\r
+ @param RequestResp Pointer to a null-terminated Unicode string in\r
+ <ConfigResp> format.\r
+ @param AccessProgress On return, points to a character in the Request\r
+ string. Points to the string's null terminator if\r
+ request was successful. Points to the most recent\r
+ & before the first failing name / value pair (or\r
+ the beginning of the string if the failure is in\r
+ the first name / value pair) if the request was\r
+ not successful.\r
+\r
+ @retval EFI_SUCCESS The Results string is set to the full request string.\r
+ And AltCfgResp contains all default value string.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough memory for the return string.\r
+ @retval EFI_INVALID_PARAMETER Request points to NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+GetConfigRespFromEfiVarStore (\r
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,\r
+ IN EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo, \r
+ IN EFI_STRING Request,\r
+ OUT EFI_STRING *RequestResp,\r
+ OUT EFI_STRING *AccessProgress\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STRING VarStoreName;\r
+ UINT8 *VarStore;\r
+ UINTN BufferSize;\r
+\r
+ Status = EFI_SUCCESS;\r
+ BufferSize = 0;\r
+ VarStore = NULL;\r
+ VarStoreName = NULL;\r
+ \r
+ VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ \r
+ \r
+ Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
+ if (Status != EFI_BUFFER_TOO_SMALL) {\r
+ goto Done;\r
+ }\r
+\r
+ VarStore = AllocateZeroPool (BufferSize);\r
+ ASSERT (VarStore != NULL);\r
+ Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, VarStore);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = HiiBlockToConfig(This, Request, VarStore, BufferSize, RequestResp, AccessProgress);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+Done:\r
+ if (VarStoreName != NULL) {\r
+ FreePool (VarStoreName);\r
+ }\r
+\r
+ if (VarStore != NULL) {\r
+ FreePool (VarStore);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ This function route the full request resp string for efi varstore. \r
+\r
+ @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
+ instance.\r
+ @param EfiVarStoreInfo The efi varstore info which is save in the EFI \r
+ varstore data structure. \r
+ @param RequestResp Pointer to a null-terminated Unicode string in\r
+ <ConfigResp> format.\r
+ @param Result Pointer to a null-terminated Unicode string in\r
+ <ConfigResp> format.\r
+ \r
+ @retval EFI_SUCCESS The Results string is set to the full request string.\r
+ And AltCfgResp contains all default value string.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough memory for the return string.\r
+ @retval EFI_INVALID_PARAMETER Request points to NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+RouteConfigRespForEfiVarStore (\r
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,\r
+ IN EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo, \r
+ IN EFI_STRING RequestResp,\r
+ OUT EFI_STRING *Result\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STRING VarStoreName;\r
+ UINT8 *VarStore;\r
+ UINTN BufferSize;\r
+ UINTN BlockSize;\r
+\r
+ Status = EFI_SUCCESS;\r
+ BufferSize = 0;\r
+ VarStore = NULL;\r
+ VarStoreName = NULL;\r
+\r
+ VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ \r
+ Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
+ if (Status != EFI_BUFFER_TOO_SMALL) {\r
+ goto Done;\r
+ }\r
+\r
+ BlockSize = BufferSize;\r
+ VarStore = AllocateZeroPool (BufferSize);\r
+ ASSERT (VarStore != NULL);\r
+ Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, VarStore);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = HiiConfigToBlock(This, RequestResp, VarStore, &BlockSize, Result);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = gRT->SetVariable (VarStoreName, &EfiVarStoreInfo->Guid, EfiVarStoreInfo->Attributes, BufferSize, VarStore);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+Done:\r
+ if (VarStoreName != NULL) {\r
+ FreePool (VarStoreName);\r
+ }\r
+\r
+ if (VarStore != NULL) {\r
+ FreePool (VarStore);\r
}\r
\r
return Status;\r
EFI_STRING AccessResults;\r
EFI_STRING DefaultResults;\r
BOOLEAN FirstElement;\r
- UINTN DevicePathLength;\r
+ BOOLEAN IfrDataParsedFlag;\r
+ BOOLEAN IsEfiVarStore;\r
+ EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; \r
\r
if (This == NULL || Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
ConfigRequest = NULL;\r
Status = EFI_SUCCESS;\r
AccessResults = NULL;\r
+ AccessProgress = NULL;\r
DevicePath = NULL;\r
+ IfrDataParsedFlag = FALSE;\r
+ IsEfiVarStore = FALSE;\r
+ EfiVarStoreInfo = NULL;\r
\r
//\r
// The first element of <MultiConfigRequest> should be\r
//\r
DriverHandle = NULL;\r
HiiHandle = NULL;\r
- DevicePathLength = GetDevicePathSize (DevicePath);\r
+ Database = NULL;\r
for (Link = Private->DatabaseList.ForwardLink;\r
Link != &Private->DatabaseList;\r
Link = Link->ForwardLink\r
) {\r
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);\r
- \r
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if ((DevicePathLength == GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)) && \r
- (CompareMem (\r
+ if (CompareMem (\r
DevicePath,\r
CurrentDevicePath,\r
- DevicePathLength\r
- ) == 0)) {\r
+ GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)\r
+ ) == 0) {\r
DriverHandle = Database->DriverHandle;\r
HiiHandle = Database->Handle;\r
break;\r
//\r
// Check whether ConfigRequest contains request string OFFSET/WIDTH\r
//\r
+ IfrDataParsedFlag = FALSE;\r
if ((HiiHandle != NULL) && (StrStr (ConfigRequest, L"&OFFSET=") == NULL)) {\r
//\r
// Get the full request string from IFR when HiiPackage is registered to HiiHandle \r
//\r
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &DefaultResults);\r
+ IfrDataParsedFlag = TRUE;\r
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &DefaultResults, &AccessProgress);\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // AccessProgress indicates the parsing progress on <ConfigRequest>.\r
+ // Map it to the progress on <MultiConfigRequest> then return it.\r
+ //\r
+ *Progress = StrStr (StringPtr, AccessProgress);\r
goto Done;\r
}\r
//\r
}\r
\r
//\r
- // Call corresponding ConfigAccess protocol to extract settings\r
+ // Check whether this ConfigRequest is search from Efi varstore type storage.\r
//\r
- Status = gBS->HandleProtocol (\r
- DriverHandle,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- (VOID **) &ConfigAccess\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ Status = GetVarStoreType(Database, ConfigRequest, &IsEfiVarStore, &EfiVarStoreInfo);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+ \r
+ if (IsEfiVarStore) {\r
+ //\r
+ // Call the GetVariable function to extract settings.\r
+ //\r
+ Status = GetConfigRespFromEfiVarStore(This, EfiVarStoreInfo, ConfigRequest, &AccessResults, &AccessProgress);\r
+ FreePool (EfiVarStoreInfo); \r
+ } else {\r
+ //\r
+ // Call corresponding ConfigAccess protocol to extract settings\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ DriverHandle,\r
+ &gEfiHiiConfigAccessProtocolGuid,\r
+ (VOID **) &ConfigAccess\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
\r
- Status = ConfigAccess->ExtractConfig (\r
- ConfigAccess,\r
- ConfigRequest,\r
- &AccessProgress,\r
- &AccessResults\r
- );\r
+ Status = ConfigAccess->ExtractConfig (\r
+ ConfigAccess,\r
+ ConfigRequest,\r
+ &AccessProgress,\r
+ &AccessResults\r
+ );\r
+ }\r
if (EFI_ERROR (Status)) {\r
//\r
// AccessProgress indicates the parsing progress on <ConfigRequest>.\r
//\r
// Update AccessResults by getting default setting from IFR when HiiPackage is registered to HiiHandle \r
//\r
- if (HiiHandle != NULL) {\r
- if (DefaultResults == NULL) {\r
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &AccessResults);\r
- } else {\r
- Status = MergeDefaultString (&AccessResults, DefaultResults);\r
- }\r
+ if (!IfrDataParsedFlag && HiiHandle != NULL) {\r
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &DefaultResults, NULL);\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
+\r
FreePool (DevicePath);\r
DevicePath = NULL;\r
- \r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
\r
- //\r
- // Free the allocated memory.\r
- //\r
if (DefaultResults != NULL) {\r
+ Status = MergeDefaultString (&AccessResults, DefaultResults);\r
+ ASSERT_EFI_ERROR (Status);\r
FreePool (DefaultResults);\r
DefaultResults = NULL;\r
}\r
-\r
+ \r
NextConfigString: \r
if (!FirstElement) {\r
Status = AppendToMultiString (Results, L"&");\r
Done:\r
if (EFI_ERROR (Status)) {\r
FreePool (*Results);\r
- *Results = NULL;\r
+ *Results = NULL;\r
}\r
\r
if (ConfigRequest != NULL) {\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
EFI_STRING AccessResults;\r
EFI_STRING Progress;\r
+ EFI_STRING StringPtr;\r
EFI_STRING ConfigRequest;\r
UINTN Index;\r
EFI_HANDLE *ConfigAccessHandles;\r
HII_DATABASE_RECORD *Database;\r
UINT8 *DevicePathPkg;\r
UINT8 *CurrentDevicePath;\r
- UINTN DevicePathLength;\r
+ BOOLEAN IfrDataParsedFlag;\r
\r
if (This == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
//\r
// Get DevicePath and HiiHandle for this ConfigAccess driver handle\r
//\r
+ IfrDataParsedFlag = FALSE;\r
Progress = NULL;\r
HiiHandle = NULL;\r
- ConfigRequest = NULL;\r
DefaultResults = NULL;\r
+ Database = NULL;\r
+ ConfigRequest = NULL;\r
DevicePath = DevicePathFromHandle (ConfigAccessHandles[Index]);\r
- DevicePathLength = GetDevicePathSize (DevicePath);\r
if (DevicePath != NULL) {\r
for (Link = Private->DatabaseList.ForwardLink;\r
Link != &Private->DatabaseList;\r
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);\r
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if ((DevicePathLength == GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)) &&\r
- (CompareMem (\r
+ if (CompareMem (\r
DevicePath,\r
CurrentDevicePath,\r
- DevicePathLength\r
- ) == 0)) {\r
+ GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)\r
+ ) == 0) {\r
HiiHandle = Database->Handle;\r
break;\r
}\r
}\r
}\r
\r
- //\r
- // Update AccessResults by getting default setting from IFR when HiiPackage is registered to HiiHandle \r
- //\r
- if (HiiHandle != NULL && DevicePath != NULL) {\r
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &DefaultResults);\r
- }\r
- //\r
- // Can't parse IFR data to get the request string and default string.\r
- //\r
- if (EFI_ERROR (Status)) {\r
- ConfigRequest = NULL;\r
- DefaultResults = NULL;\r
- }\r
- \r
Status = ConfigAccess->ExtractConfig (\r
ConfigAccess,\r
- ConfigRequest,\r
+ NULL,\r
&Progress,\r
&AccessResults\r
);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Update AccessResults by getting default setting from IFR when HiiPackage is registered to HiiHandle \r
+ //\r
+ if (HiiHandle != NULL && DevicePath != NULL) {\r
+ IfrDataParsedFlag = TRUE;\r
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &DefaultResults, NULL);\r
+ //\r
+ // Get the full request string to get the Current setting again.\r
+ //\r
+ if (!EFI_ERROR (Status) && ConfigRequest != NULL) {\r
+ Status = ConfigAccess->ExtractConfig (\r
+ ConfigAccess,\r
+ ConfigRequest,\r
+ &Progress,\r
+ &AccessResults\r
+ );\r
+ FreePool (ConfigRequest);\r
+ } else {\r
+ Status = EFI_NOT_FOUND;\r
+ }\r
+ }\r
+ }\r
+\r
if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Update AccessResults by getting default setting from IFR when HiiPackage is registered to HiiHandle \r
+ //\r
+ if (!IfrDataParsedFlag && HiiHandle != NULL && DevicePath != NULL) {\r
+ StringPtr = StrStr (AccessResults, L"&GUID=");\r
+ if (StringPtr != NULL) {\r
+ *StringPtr = 0;\r
+ }\r
+ if (StrStr (AccessResults, L"&OFFSET=") != NULL) {\r
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &AccessResults, &DefaultResults, NULL);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ if (StringPtr != NULL) {\r
+ *StringPtr = L'&';\r
+ }\r
+ }\r
//\r
// Merge the default sting from IFR code into the got setting from driver.\r
//\r
if (DefaultResults != NULL) {\r
- MergeDefaultString (&AccessResults, DefaultResults);\r
+ Status = MergeDefaultString (&AccessResults, DefaultResults);\r
+ ASSERT_EFI_ERROR (Status);\r
FreePool (DefaultResults);\r
+ DefaultResults = NULL;\r
}\r
\r
//\r
EFI_HANDLE DriverHandle;\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
EFI_STRING AccessProgress;\r
- UINTN DevicePathLength;\r
+ EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;\r
+ BOOLEAN IsEfiVarstore;\r
\r
if (This == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
Private = CONFIG_ROUTING_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
StringPtr = Configuration;\r
*Progress = StringPtr;\r
+ Database = NULL;\r
+ AccessProgress = NULL;\r
+ EfiVarStoreInfo= NULL;\r
+ IsEfiVarstore = FALSE;\r
\r
//\r
// The first element of <MultiConfigResp> should be\r
// Find driver which matches the routing data.\r
//\r
DriverHandle = NULL;\r
- DevicePathLength = GetDevicePathSize (DevicePath);\r
for (Link = Private->DatabaseList.ForwardLink;\r
Link != &Private->DatabaseList;\r
Link = Link->ForwardLink\r
\r
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if ((DevicePathLength == GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)) &&\r
- (CompareMem (\r
+ if (CompareMem (\r
DevicePath,\r
CurrentDevicePath,\r
- DevicePathLength\r
- ) == 0)) {\r
+ GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)\r
+ ) == 0) {\r
DriverHandle = Database->DriverHandle;\r
break;\r
}\r
FreePool (DevicePath);\r
\r
//\r
- // Call corresponding ConfigAccess protocol to route settings\r
+ // Check whether this ConfigRequest is search from Efi varstore type storage.\r
//\r
- Status = gBS->HandleProtocol (\r
- DriverHandle,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- (VOID **) &ConfigAccess\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ Status = GetVarStoreType(Database, ConfigResp, &IsEfiVarstore, &EfiVarStoreInfo);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
- Status = ConfigAccess->RouteConfig (\r
- ConfigAccess,\r
- ConfigResp,\r
- &AccessProgress\r
- );\r
+ if (IsEfiVarstore) {\r
+ //\r
+ // Call the SetVariable function to route settings.\r
+ // \r
+ Status = RouteConfigRespForEfiVarStore(This, EfiVarStoreInfo, ConfigResp, &AccessProgress);\r
+ FreePool (EfiVarStoreInfo);\r
+ } else {\r
+ //\r
+ // Call corresponding ConfigAccess protocol to route settings\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ DriverHandle,\r
+ &gEfiHiiConfigAccessProtocolGuid,\r
+ (VOID **) &ConfigAccess\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
\r
+ Status = ConfigAccess->RouteConfig (\r
+ ConfigAccess,\r
+ ConfigResp,\r
+ &AccessProgress\r
+ );\r
+ }\r
if (EFI_ERROR (Status)) {\r
//\r
// AccessProgress indicates the parsing progress on <ConfigResp>.\r
UINTN Index;\r
UINT8 *TemBuffer;\r
CHAR16 *TemString;\r
+ CHAR16 TemChar;\r
\r
if (This == NULL || Progress == NULL || Config == NULL) {\r
return EFI_INVALID_PARAMETER;\r
StringPtr++;\r
}\r
if (*StringPtr == 0) {\r
- *Progress = StringPtr - 1;\r
- Status = EFI_INVALID_PARAMETER;\r
+ *Progress = StringPtr;\r
+ Status = EFI_SUCCESS;\r
+\r
+ AppendToMultiString(Config, ConfigRequest);\r
+ HiiToLower (*Config);\r
+\r
goto Exit;\r
}\r
//\r
//\r
// Copy <ConfigHdr> and an additional '&' to <ConfigResp>\r
//\r
- Length = StringPtr - ConfigRequest;\r
- CopyMem (*Config, ConfigRequest, Length * sizeof (CHAR16));\r
+ TemChar = *StringPtr;\r
+ *StringPtr = '\0';\r
+ AppendToMultiString(Config, ConfigRequest);\r
+ *StringPtr = TemChar;\r
\r
//\r
// Parse each <RequestElement> if exists\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
goto Exit;\r
}\r
\r
- *Progress = StringPtr;\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