/** @file\r
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.\r
\r
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, 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
\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_OUT_OF_RESOURCES Lake of resources to store necessary structures.\r
@retval EFI_SUCCESS The device path is retrieved and translated to\r
binary format.\r
\r
Str = AllocateZeroPool (Length * sizeof (CHAR16));\r
ASSERT (Str != NULL);\r
\r
- StrCpy (Str, String);\r
- Length = (BufferLen * 2 + 1) * sizeof (CHAR16);\r
+ StrCpyS (Str, Length, String);\r
\r
StringHeader = Str + StrLen (String);\r
TemString = (CHAR16 *) StringHeader;\r
//\r
// Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.\r
//\r
- StrCat (Str, L"&"); \r
+ StrCatS (Str, Length, L"&"); \r
HiiToLower (Str);\r
\r
*SubStr = Str;\r
}\r
\r
Length = TmpPtr - String;\r
+ if (Length == 0) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
Result = AllocateCopyPool (Length * sizeof (CHAR16), String);\r
if (Result == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
{\r
UINTN AppendStringSize;\r
UINTN MultiStringSize;\r
+ UINTN MaxLen;\r
\r
if (MultiString == NULL || *MultiString == NULL || AppendString == NULL) {\r
return EFI_INVALID_PARAMETER;\r
\r
AppendStringSize = StrSize (AppendString);\r
MultiStringSize = StrSize (*MultiString);\r
+ MaxLen = MAX_STRING_LENGTH / sizeof (CHAR16);\r
\r
//\r
// Enlarge the buffer each time when length exceeds MAX_STRING_LENGTH.\r
MultiStringSize + AppendStringSize,\r
(VOID *) (*MultiString)\r
);\r
+ MaxLen = (MultiStringSize + AppendStringSize) / sizeof (CHAR16);\r
ASSERT (*MultiString != NULL);\r
}\r
//\r
// Append the incoming string\r
//\r
- StrCat (*MultiString, AppendString);\r
+ StrCatS (*MultiString, MaxLen, AppendString);\r
\r
return EFI_SUCCESS;\r
}\r
to free memory.\r
@param Len Length of the <Number>, in characters.\r
\r
- @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store necessary\r
structures.\r
@retval EFI_SUCCESS Value of <Number> is outputted in Number\r
successfully.\r
return Status;\r
}\r
\r
+/**\r
+ To find the BlockName in the string with same value.\r
+\r
+ @param String Pointer to a Null-terminated Unicode string.\r
+ @param BlockName Pointer to a Null-terminated Unicode string to search for.\r
+ @param Buffer Pointer to the value correspond to the BlockName.\r
+ @param Found The Block whether has been found.\r
+ @param BufferLen The length of the buffer.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store necessary structures.\r
+ @retval EFI_SUCCESS The function finishes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+FindSameBlockElement(\r
+ IN EFI_STRING String,\r
+ IN EFI_STRING BlockName,\r
+ IN UINT8 *Buffer,\r
+ OUT BOOLEAN *Found,\r
+ IN UINTN BufferLen\r
+ )\r
+{\r
+ EFI_STRING BlockPtr;\r
+ UINTN Length;\r
+ UINT8 *TempBuffer;\r
+ EFI_STATUS Status;\r
+\r
+ TempBuffer = NULL;\r
+ *Found = FALSE;\r
+ BlockPtr = StrStr (String, BlockName);\r
+\r
+ while (BlockPtr != NULL) {\r
+ BlockPtr += StrLen (BlockName);\r
+ Status = GetValueOfNumber (BlockPtr, &TempBuffer, &Length);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ ASSERT (TempBuffer != NULL);\r
+ if ((BufferLen == Length) && (0 == CompareMem (Buffer, TempBuffer, Length))) {\r
+ *Found = TRUE;\r
+ FreePool (TempBuffer);\r
+ TempBuffer = NULL;\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ FreePool (TempBuffer);\r
+ TempBuffer = NULL;\r
+ BlockPtr = StrStr (BlockPtr + 1, BlockName);\r
+ }\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Compare the <AltResp> in ConfigAltResp and DefaultAltCfgResp, if the <AltResp>\r
+ in DefaultAltCfgResp but not in ConfigAltResp,add it to the ConfigAltResp.\r
+\r
+ @param DefaultAltCfgResp Pointer to a null-terminated Unicode string in\r
+ <MultiConfigAltResp> format. The default value\r
+ string may contain more than one ConfigAltResp\r
+ string for the different varstore buffer.\r
+ @param ConfigAltResp Pointer to a null-terminated Unicode string in\r
+ <ConfigAltResp> format.\r
+ @param AltConfigHdr Pointer to a Unicode string in <AltConfigHdr> format.\r
+ @param ConfigAltRespChanged Whether the ConfigAltResp has been changed.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store necessary structures.\r
+ @retval EFI_SUCCESS The function finishes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+CompareBlockElementDefault (\r
+ IN EFI_STRING DefaultAltCfgResp,\r
+ IN OUT EFI_STRING *ConfigAltResp,\r
+ IN EFI_STRING AltConfigHdr,\r
+ IN OUT BOOLEAN *ConfigAltRespChanged\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STRING BlockPtr;\r
+ EFI_STRING BlockPtrStart;\r
+ EFI_STRING StringPtr;\r
+ EFI_STRING AppendString;\r
+ EFI_STRING AltConfigHdrPtr;\r
+ UINT8 *TempBuffer;\r
+ UINTN OffsetLength;\r
+ UINTN AppendSize;\r
+ UINTN TotalSize;\r
+ BOOLEAN FoundOffset;\r
+\r
+ AppendString = NULL;\r
+ TempBuffer = NULL;\r
+ //\r
+ // Make BlockPtr point to the first <BlockConfig> with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ AltConfigHdrPtr = StrStr (DefaultAltCfgResp, AltConfigHdr);\r
+ ASSERT (AltConfigHdrPtr != NULL);\r
+ BlockPtr = StrStr (AltConfigHdrPtr, L"&OFFSET=");\r
+ //\r
+ // Make StringPtr point to the AltConfigHdr in ConfigAltResp.\r
+ //\r
+ StringPtr = StrStr (*ConfigAltResp, AltConfigHdr);\r
+ ASSERT (StringPtr != NULL);\r
+\r
+ while (BlockPtr != NULL) {\r
+ //\r
+ // Find the "&OFFSET=<Number>" block and get the value of the Number with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ BlockPtrStart = BlockPtr;\r
+ BlockPtr += StrLen (L"&OFFSET=");\r
+ Status = GetValueOfNumber (BlockPtr, &TempBuffer, &OffsetLength);\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ //\r
+ // To find the same "&OFFSET=<Number>" block in ConfigAltResp.\r
+ //\r
+ Status = FindSameBlockElement (StringPtr, L"&OFFSET=", TempBuffer, &FoundOffset, OffsetLength);\r
+ if (TempBuffer != NULL) {\r
+ FreePool (TempBuffer);\r
+ TempBuffer = NULL;\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ if (!FoundOffset) {\r
+ //\r
+ // Don't find the same "&OFFSET=<Number>" block in ConfigAltResp.\r
+ // Calculate the size of <BlockConfig>.\r
+ // <BlockConfig>::='OFFSET='<Number>'&WIDTH='<Number>'&VALUE='<Number>.\r
+ //\r
+ BlockPtr = StrStr (BlockPtr + 1, L"&OFFSET=");\r
+ if (BlockPtr != NULL) {\r
+ AppendSize = (BlockPtr - BlockPtrStart) * sizeof (CHAR16);\r
+ } else {\r
+ AppendSize = StrSize (BlockPtrStart);\r
+ }\r
+ //\r
+ // Copy the <BlockConfig> to AppendString.\r
+ //\r
+ if (AppendString == NULL) {\r
+ AppendString = (EFI_STRING) AllocateZeroPool (AppendSize + sizeof (CHAR16));\r
+ StrnCatS (AppendString, AppendSize / sizeof (CHAR16) + 1, BlockPtrStart, AppendSize / sizeof (CHAR16));\r
+ } else {\r
+ TotalSize = StrSize (AppendString) + AppendSize + sizeof (CHAR16);\r
+ AppendString = (EFI_STRING) ReallocatePool (\r
+ StrSize (AppendString),\r
+ TotalSize,\r
+ AppendString\r
+ );\r
+ if (AppendString == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ StrnCatS (AppendString, TotalSize / sizeof (CHAR16), BlockPtrStart, AppendSize / sizeof (CHAR16));\r
+ }\r
+ } else {\r
+ //\r
+ // To find next "&OFFSET=<Number>" block with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ BlockPtr = StrStr (BlockPtr + 1, L"&OFFSET=");\r
+ }\r
+ }\r
+\r
+ if (AppendString != NULL) {\r
+ //\r
+ // Reallocate ConfigAltResp to copy the AppendString.\r
+ //\r
+ TotalSize = StrSize (*ConfigAltResp) + StrSize (AppendString) + sizeof (CHAR16);\r
+ *ConfigAltResp = (EFI_STRING) ReallocatePool (\r
+ StrSize (*ConfigAltResp),\r
+ TotalSize,\r
+ *ConfigAltResp\r
+ );\r
+ if (*ConfigAltResp == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ StrCatS (*ConfigAltResp, TotalSize / sizeof (CHAR16), AppendString);\r
+ *ConfigAltRespChanged = TRUE;\r
+ }\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+Exit:\r
+ if (AppendString != NULL) {\r
+ FreePool (AppendString);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Compare the <AltResp> in ConfigAltResp and DefaultAltCfgResp, if the <AltResp>\r
+ in DefaultAltCfgResp but not in ConfigAltResp,add it to the ConfigAltResp.\r
+\r
+ @param DefaultAltCfgResp Pointer to a null-terminated Unicode string in\r
+ <MultiConfigAltResp> format. The default value\r
+ string may contain more than one ConfigAltResp\r
+ string for the different varstore buffer.\r
+ @param ConfigAltResp Pointer to a null-terminated Unicode string in\r
+ <ConfigAltResp> format.\r
+ @param AltConfigHdr Pointer to a Unicode string in <AltConfigHdr> format.\r
+ @param ConfigAltRespChanged Whether the ConfigAltResp has been changed.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store necessary structures.\r
+ @retval EFI_SUCCESS The function finishes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+CompareNameElementDefault (\r
+ IN EFI_STRING DefaultAltCfgResp,\r
+ IN OUT EFI_STRING *ConfigAltResp,\r
+ IN EFI_STRING AltConfigHdr,\r
+ IN OUT BOOLEAN *ConfigAltRespChanged\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STRING NvConfigPtr;\r
+ EFI_STRING NvConfigStart;\r
+ EFI_STRING NvConfigValuePtr;\r
+ EFI_STRING StringPtr;\r
+ EFI_STRING NvConfigExist;\r
+ EFI_STRING AppendString;\r
+ CHAR16 TempChar;\r
+ UINTN AppendSize;\r
+ UINTN TotalSize;\r
+\r
+ AppendString = NULL;\r
+ NvConfigExist = NULL;\r
+ //\r
+ // Make NvConfigPtr point to the first <NvConfig> with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ NvConfigPtr = StrStr (DefaultAltCfgResp, AltConfigHdr);\r
+ ASSERT (NvConfigPtr != NULL);\r
+ NvConfigPtr = StrStr (NvConfigPtr + StrLen(AltConfigHdr),L"&");\r
+ //\r
+ // Make StringPtr point to the first <NvConfig> with AltConfigHdr in ConfigAltResp.\r
+ //\r
+ StringPtr = StrStr (*ConfigAltResp, AltConfigHdr);\r
+ ASSERT (StringPtr != NULL);\r
+ StringPtr = StrStr (StringPtr + StrLen (AltConfigHdr), L"&");\r
+ ASSERT (StringPtr != NULL);\r
+\r
+ while (NvConfigPtr != NULL) {\r
+ //\r
+ // <NvConfig> ::= <Label>'='<String> | <Label>'='<Number>.\r
+ // Get the <Label> with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ NvConfigStart = NvConfigPtr;\r
+ NvConfigValuePtr = StrStr (NvConfigPtr + 1, L"=");\r
+ ASSERT (NvConfigValuePtr != NULL);\r
+ TempChar = *NvConfigValuePtr;\r
+ *NvConfigValuePtr = L'\0';\r
+ //\r
+ // Get the <Label> with AltConfigHdr in ConfigAltResp.\r
+ //\r
+ NvConfigExist = StrStr (StringPtr, NvConfigPtr);\r
+ if (NvConfigExist == NULL) {\r
+ //\r
+ // Don't find same <Label> in ConfigAltResp.\r
+ // Calculate the size of <NvConfig>.\r
+ //\r
+ *NvConfigValuePtr = TempChar;\r
+ NvConfigPtr = StrStr (NvConfigPtr + 1, L"&");\r
+ if (NvConfigPtr != NULL) {\r
+ AppendSize = (NvConfigPtr - NvConfigStart) * sizeof (CHAR16);\r
+ } else {\r
+ AppendSize = StrSize (NvConfigStart);\r
+ }\r
+ //\r
+ // Copy the <NvConfig> to AppendString.\r
+ //\r
+ if (AppendString == NULL) {\r
+ AppendString = (EFI_STRING) AllocateZeroPool (AppendSize + sizeof (CHAR16));\r
+ StrnCatS (AppendString, AppendSize / sizeof (CHAR16) + 1, NvConfigStart, AppendSize / sizeof (CHAR16));\r
+ } else {\r
+ TotalSize = StrSize (AppendString) + AppendSize + sizeof (CHAR16);\r
+ AppendString = (EFI_STRING) ReallocatePool (\r
+ StrSize (AppendString),\r
+ TotalSize,\r
+ AppendString\r
+ );\r
+ if (AppendString == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ StrnCatS (AppendString, TotalSize / sizeof (CHAR16), NvConfigStart, AppendSize / sizeof (CHAR16));\r
+ }\r
+ } else {\r
+ //\r
+ // To find next <Label> in DefaultAltCfgResp.\r
+ //\r
+ *NvConfigValuePtr = TempChar;\r
+ NvConfigPtr = StrStr (NvConfigPtr + 1, L"&");\r
+ }\r
+ }\r
+ if (AppendString != NULL) {\r
+ //\r
+ // Reallocate ConfigAltResp to copy the AppendString.\r
+ //\r
+ TotalSize = StrSize (*ConfigAltResp) + StrSize (AppendString) + sizeof (CHAR16);\r
+ *ConfigAltResp = (EFI_STRING) ReallocatePool (\r
+ StrSize (*ConfigAltResp),\r
+ StrSize (*ConfigAltResp) + StrSize (AppendString) + sizeof (CHAR16),\r
+ *ConfigAltResp\r
+ );\r
+ if (*ConfigAltResp == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ StrCatS (*ConfigAltResp, TotalSize / sizeof (CHAR16), AppendString);\r
+ *ConfigAltRespChanged = TRUE;\r
+ }\r
+ Status = EFI_SUCCESS;\r
+\r
+Exit:\r
+ if (AppendString != NULL) {\r
+ FreePool (AppendString);\r
+ }\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Compare the <AltResp> in AltCfgResp and DefaultAltCfgResp, if the <AltResp>\r
+ in DefaultAltCfgResp but not in AltCfgResp,add it to the AltCfgResp.\r
+\r
+ @param AltCfgResp Pointer to a null-terminated Unicode string in\r
+ <ConfigAltResp> format.\r
+ @param DefaultAltCfgResp Pointer to a null-terminated Unicode string in\r
+ <MultiConfigAltResp> format. The default value\r
+ string may contain more than one ConfigAltResp\r
+ string for the different varstore buffer.\r
+ @param AltConfigHdr Pointer to a Unicode string in <AltConfigHdr> format.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store necessary\r
+ structures.\r
+ @retval EFI_SUCCESS The function finishes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+CompareAndMergeDefaultString (\r
+ IN OUT EFI_STRING *AltCfgResp,\r
+ IN EFI_STRING DefaultAltCfgResp,\r
+ IN EFI_STRING AltConfigHdr\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STRING AltCfgRespBackup;\r
+ EFI_STRING AltConfigHdrPtr;\r
+ EFI_STRING AltConfigHdrPtrNext;\r
+ EFI_STRING ConfigAltResp;\r
+ EFI_STRING StringPtr;\r
+ EFI_STRING StringPtrNext;\r
+ EFI_STRING BlockPtr;\r
+ UINTN ReallocateSize;\r
+ CHAR16 TempChar;\r
+ CHAR16 TempCharA;\r
+ BOOLEAN ConfigAltRespChanged;\r
+\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ BlockPtr = NULL;\r
+ AltConfigHdrPtrNext = NULL;\r
+ StringPtrNext = NULL;\r
+ ConfigAltResp = NULL;\r
+ AltCfgRespBackup = NULL;\r
+ TempChar = L'\0';\r
+ TempCharA = L'\0';\r
+ ConfigAltRespChanged = FALSE;\r
+\r
+ //\r
+ //To find the <AltResp> with AltConfigHdr in DefaultAltCfgResp, ignore other <AltResp> which follow it.\r
+ //\r
+ AltConfigHdrPtr = StrStr (DefaultAltCfgResp, AltConfigHdr);\r
+ ASSERT (AltConfigHdrPtr != NULL);\r
+ AltConfigHdrPtrNext = StrStr (AltConfigHdrPtr + 1, L"&GUID");\r
+ if (AltConfigHdrPtrNext != NULL) {\r
+ TempChar = *AltConfigHdrPtrNext;\r
+ *AltConfigHdrPtrNext = L'\0';\r
+ }\r
+ //\r
+ // To find the <AltResp> with AltConfigHdr in AltCfgResp, ignore other <AltResp> which follow it.\r
+ //\r
+ StringPtr = StrStr (*AltCfgResp, AltConfigHdr);\r
+ StringPtrNext = StrStr (StringPtr + 1, L"&GUID");\r
+ if (StringPtrNext != NULL) {\r
+ TempCharA = *StringPtrNext;\r
+ *StringPtrNext = L'\0';\r
+ }\r
+ //\r
+ // Copy the content of <ConfigAltResp> which contain current AltConfigHdr in AltCfgResp.\r
+ //\r
+ ConfigAltResp = AllocateCopyPool (StrSize (*AltCfgResp), *AltCfgResp);\r
+ if (ConfigAltResp == NULL) {\r
+ goto Exit;\r
+ }\r
+ //\r
+ // To find the <ConfigBody> with AltConfigHdr in DefaultAltCfgResp.\r
+ //\r
+ BlockPtr = StrStr (AltConfigHdrPtr, L"&OFFSET=");\r
+ if (BlockPtr != NULL) {\r
+ //\r
+ // <BlockConfig>::='OFFSET='<Number>'&WIDTH='<Number>'&VALUE='<Number> style.\r
+ // Call function CompareBlockElementDefault to compare the <BlockConfig> in DefaultAltCfgResp and ConfigAltResp.\r
+ // The ConfigAltResp which may contain the new <BlockConfig> get from DefaultAltCfgResp.\r
+ //\r
+ Status = CompareBlockElementDefault (DefaultAltCfgResp, &ConfigAltResp, AltConfigHdr, &ConfigAltRespChanged);\r
+ if (EFI_ERROR(Status)) {\r
+ goto Exit;\r
+ }\r
+ } else {\r
+ //\r
+ // <NvConfig> ::= <Label>'='<String> | <Label>'='<Number> style.\r
+ // Call function CompareNameElementDefault to compare the <NvConfig> in DefaultAltCfgResp and ConfigAltResp.\r
+ // The ConfigAltResp which may contain the new <NvConfig> get from DefaultAltCfgResp.\r
+ //\r
+ Status = CompareNameElementDefault (DefaultAltCfgResp, &ConfigAltResp, AltConfigHdr, &ConfigAltRespChanged);\r
+ if (EFI_ERROR(Status)) {\r
+ goto Exit;\r
+ }\r
+ }\r
+ //\r
+ // Restore the AltCfgResp.\r
+ //\r
+ if (StringPtrNext != NULL) {\r
+ *StringPtrNext = TempCharA;\r
+ }\r
+\r
+ //\r
+ // If the ConfigAltResp has no change,no need to update the content in AltCfgResp.\r
+ //\r
+ if (!ConfigAltRespChanged) {\r
+ Status = EFI_SUCCESS;\r
+ goto Exit;\r
+ }\r
+ //\r
+ // ConfigAltResp has been changed, need to update the content in AltCfgResp.\r
+ //\r
+ if (StringPtrNext != NULL) {\r
+ ReallocateSize = StrSize (ConfigAltResp) + StrSize (StringPtrNext) + sizeof (CHAR16);\r
+ } else {\r
+ ReallocateSize = StrSize (ConfigAltResp) + sizeof (CHAR16);\r
+ }\r
+\r
+ AltCfgRespBackup = (EFI_STRING) AllocateZeroPool (ReallocateSize);\r
+ if (AltCfgRespBackup == NULL) {\r
+ goto Exit;\r
+ }\r
+\r
+ StrCatS (AltCfgRespBackup, ReallocateSize / sizeof (CHAR16), ConfigAltResp);\r
+ if (StringPtrNext != NULL) {\r
+ StrCatS (AltCfgRespBackup, ReallocateSize / sizeof (CHAR16), StringPtrNext);\r
+ }\r
+\r
+ FreePool (*AltCfgResp);\r
+ *AltCfgResp = AltCfgRespBackup;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+Exit:\r
+ if (ConfigAltResp != NULL) {\r
+ FreePool(ConfigAltResp);\r
+ }\r
+ //\r
+ // Restore the DefaultAltCfgResp.\r
+ //\r
+ if ( AltConfigHdrPtrNext != NULL) {\r
+ *AltConfigHdrPtrNext = TempChar;\r
+ AltConfigHdrPtrNext = NULL;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
/**\r
This function merges DefaultAltCfgResp string into AltCfgResp string for\r
the missing AltCfgId in AltCfgResq.\r
EFI_STRING AltConfigHdr;\r
UINTN HeaderLength;\r
UINTN SizeAltCfgResp;\r
+ UINTN MaxLen;\r
+ UINTN TotalSize;\r
\r
if (*AltCfgResp == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
//\r
- // Get the requestr ConfigHdr\r
+ // Get the request ConfigHdr\r
//\r
SizeAltCfgResp = 0;\r
StringPtr = *AltCfgResp;\r
// Construct AltConfigHdr string "&<ConfigHdr>&ALTCFG=XXXX\0"\r
// |1| StrLen (ConfigHdr) | 8 | 4 | 1 |\r
//\r
- AltConfigHdr = AllocateZeroPool ((1 + HeaderLength + 8 + 4 + 1) * sizeof (CHAR16));\r
+ MaxLen = 1 + HeaderLength + 8 + 4 + 1;\r
+ AltConfigHdr = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
if (AltConfigHdr == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- StrCpy (AltConfigHdr, L"&");\r
- StrnCat (AltConfigHdr, *AltCfgResp, HeaderLength);\r
- StrCat (AltConfigHdr, L"&ALTCFG=");\r
+ StrCpyS (AltConfigHdr, MaxLen, L"&");\r
+ StrnCatS (AltConfigHdr, MaxLen, *AltCfgResp, HeaderLength);\r
+ StrCatS (AltConfigHdr, MaxLen, L"&ALTCFG=");\r
HeaderLength = StrLen (AltConfigHdr);\r
\r
StringPtrDefault = StrStr (DefaultAltCfgResp, AltConfigHdr);\r
//\r
// Get AltCfg Name\r
//\r
- StrnCat (AltConfigHdr, StringPtrDefault + HeaderLength, 4);\r
+ StrnCatS (AltConfigHdr, MaxLen, StringPtrDefault + HeaderLength, 4);\r
StringPtr = StrStr (*AltCfgResp, AltConfigHdr); \r
\r
//\r
//\r
// No more default string is found.\r
//\r
+ TotalSize = SizeAltCfgResp + StrSize (StringPtrDefault);\r
*AltCfgResp = (EFI_STRING) ReallocatePool (\r
SizeAltCfgResp,\r
- SizeAltCfgResp + StrSize (StringPtrDefault),\r
+ TotalSize,\r
(VOID *) (*AltCfgResp)\r
);\r
if (*AltCfgResp == NULL) {\r
FreePool (AltConfigHdr);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- StrCat (*AltCfgResp, StringPtrDefault);\r
+ StrCatS (*AltCfgResp, TotalSize / sizeof (CHAR16), StringPtrDefault);\r
break;\r
} else {\r
TempChar = *StringPtrEnd;\r
*StringPtrEnd = L'\0';\r
+ TotalSize = SizeAltCfgResp + StrSize (StringPtrDefault);\r
*AltCfgResp = (EFI_STRING) ReallocatePool (\r
SizeAltCfgResp,\r
- SizeAltCfgResp + StrSize (StringPtrDefault),\r
+ TotalSize,\r
(VOID *) (*AltCfgResp)\r
);\r
if (*AltCfgResp == NULL) {\r
FreePool (AltConfigHdr);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- StrCat (*AltCfgResp, StringPtrDefault);\r
+ StrCatS (*AltCfgResp, TotalSize / sizeof (CHAR16), StringPtrDefault);\r
*StringPtrEnd = TempChar;\r
}\r
+ } else {\r
+ //\r
+ // The AltCfgResp contains <AltCfgResp>.\r
+ // If the <ConfigElement> in <AltCfgResp> in the DefaultAltCfgResp but not in the\r
+ // related <AltCfgResp> in AltCfgResp, merge it to AltCfgResp. else no need to merge.\r
+ //\r
+ CompareAndMergeDefaultString (AltCfgResp, DefaultAltCfgResp, AltConfigHdr);\r
}\r
\r
//\r
if (DefaultValueArray->DefaultId == DefaultValueData->DefaultId) {\r
//\r
// DEFAULT_VALUE_FROM_OPCODE has high priority, DEFAULT_VALUE_FROM_DEFAULT has low priority.\r
+ // When default types are DEFAULT_VALUE_FROM_OTHER_DEFAULT, the default value can be overrode.\r
//\r
- if (DefaultValueData->Type > DefaultValueArray->Type) {\r
+ if ((DefaultValueData->Type > DefaultValueArray->Type) || (DefaultValueData->Type == DefaultValueArray->Type && DefaultValueData->Type == DefaultValueFromOtherDefault)) {\r
//\r
// Update the default value array in BlockData.\r
//\r
@param[in] HiiHandle A handle that was previously registered in the HII Database.\r
\r
@retval NULL HiiHandle is not registered in the HII database\r
- @retval NULL There are not enough resources available to retrieve the suported \r
+ @retval NULL There are not enough resources available to retrieve the supported\r
languages.\r
- @retval NULL The list of suported languages could not be retrieved.\r
+ @retval NULL The list of supported languages could not be retrieved.\r
@retval Other A pointer to the Null-terminated ASCII string of supported languages.\r
\r
**/\r
{\r
EFI_STATUS Status;\r
UINTN IfrOffset;\r
+ UINTN PackageOffset;\r
EFI_IFR_OP_HEADER *IfrOpHdr;\r
CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
EFI_STRING GuidStr;\r
EFI_STRING NameStr;\r
EFI_STRING TempStr;\r
UINT8 *HiiFormPackage;\r
UINTN PackageSize;\r
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
+ EFI_HII_PACKAGE_HEADER *PackageHeader;\r
\r
HiiFormPackage = NULL;\r
LengthString = 0;\r
GuidStr = NULL;\r
NameStr = NULL;\r
TempStr = NULL;\r
+ *IsEfiVarstore = FALSE;\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
+ IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ PackageOffset = IfrOffset;\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage;\r
+\r
while (IfrOffset < PackageSize) {\r
- IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); \r
+ //\r
+ // More than one form packages exist.\r
+ //\r
+ if (PackageOffset >= PackageHeader->Length) {\r
+ //\r
+ // Process the new form package.\r
+ //\r
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ IfrOffset += PackageOffset;\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset);\r
+ }\r
+\r
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);\r
IfrOffset += IfrOpHdr->Length;\r
+ PackageOffset += IfrOpHdr->Length;\r
\r
if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) {\r
IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
continue;\r
}\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName, NameSize);\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
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- StrCpy (TempStr, GuidStr);\r
- StrCat (TempStr, NameStr);\r
+ StrCpyS (TempStr, LengthString, GuidStr);\r
+ StrCatS (TempStr, LengthString, 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
} \r
\r
//\r
- // Free alllocated temp string.\r
+ // Free allocated temp string.\r
//\r
FreePool (VarStoreName);\r
FreePool (GuidStr);\r
FreePool (NameStr);\r
FreePool (TempStr);\r
+\r
+ //\r
+ // Already found the varstore, break;\r
+ //\r
+ if (*IsEfiVarstore) {\r
+ break;\r
+ }\r
}\r
}\r
Done:\r
@param Name Varstore name.\r
@param ConfigHdr Current configRequest info.\r
\r
- @retval TRUE This varstore is the requst one.\r
- @retval FALSE This varstore is not the requst one.\r
+ @retval TRUE This varstore is the request one.\r
+ @retval FALSE This varstore is not the request one.\r
\r
**/\r
BOOLEAN\r
GuidStr = NULL;\r
TempStr = NULL;\r
\r
+ //\r
+ // If ConfigHdr has name field and varstore not has name, return FALSE.\r
+ //\r
+ if (Name == NULL && ConfigHdr != NULL && StrStr (ConfigHdr, L"NAME=&") == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *)VarstoreGuid, 1, &GuidStr);\r
if (Name != NULL) {\r
GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr);\r
goto Done;\r
}\r
\r
- StrCpy (TempStr, GuidStr);\r
- StrCat (TempStr, NameStr);\r
+ StrCpyS (TempStr, LengthString, GuidStr);\r
+ StrCatS (TempStr, LengthString, NameStr);\r
\r
if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) {\r
RetVal = TRUE;\r
return RetVal;\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
+ @retval TRUE This hii package is the request one.\r
+ @retval FALSE This hii package is not the request one.\r
+**/ \r
+BOOLEAN\r
+IsThisPackageList (\r
+ IN HII_DATABASE_RECORD *DataBaseRecord,\r
+ IN EFI_STRING ConfigHdr\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN IfrOffset;\r
+ UINTN PackageOffset;\r
+ EFI_IFR_OP_HEADER *IfrOpHdr;\r
+ CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
+ UINT8 *HiiFormPackage;\r
+ UINTN PackageSize;\r
+ EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
+ EFI_HII_PACKAGE_HEADER *PackageHeader;\r
+ EFI_IFR_VARSTORE *IfrVarStore;\r
+ EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;\r
+ BOOLEAN FindVarstore;\r
+\r
+ HiiFormPackage = NULL;\r
+ VarStoreName = NULL;\r
+ Status = EFI_SUCCESS;\r
+ FindVarstore = FALSE;\r
+\r
+ Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ PackageOffset = IfrOffset;\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage;\r
+\r
+ while (IfrOffset < PackageSize) {\r
+ //\r
+ // More than one form packages exist.\r
+ //\r
+ if (PackageOffset >= PackageHeader->Length) {\r
+ //\r
+ // Process the new form package.\r
+ //\r
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ IfrOffset += PackageOffset;\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset);\r
+ }\r
+\r
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);\r
+ IfrOffset += IfrOpHdr->Length;\r
+ PackageOffset += IfrOpHdr->Length;\r
+\r
+ switch (IfrOpHdr->OpCode) {\r
+ \r
+ case EFI_IFR_VARSTORE_OP:\r
+ IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;\r
+\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize);\r
+\r
+ if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {\r
+ FindVarstore = TRUE;\r
+ goto Done;\r
+ } else {\r
+ FreePool (VarStoreName);\r
+ VarStoreName = NULL;\r
+ }\r
+ break;\r
+\r
+ case EFI_IFR_VARSTORE_EFI_OP:\r
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
+ if (VarStoreName == NULL) {\r
+ goto Done;\r
+ }\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize);\r
+\r
+ if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {\r
+ FindVarstore = TRUE;\r
+ goto Done;\r
+ } else {\r
+ FreePool (VarStoreName);\r
+ VarStoreName = NULL;\r
+ }\r
+ break;\r
+\r
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP:\r
+ IfrNameValueVarStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr;\r
+\r
+ if (IsThisVarstore (&IfrNameValueVarStore->Guid, NULL, ConfigHdr)) {\r
+ FindVarstore = TRUE;\r
+ goto Done;\r
+ }\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
+ goto Done;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+Done:\r
+ if (HiiFormPackage != NULL) {\r
+ FreePool (HiiFormPackage);\r
+ }\r
+\r
+ if (VarStoreName != NULL) {\r
+ FreePool (VarStoreName);\r
+ }\r
+\r
+ return FindVarstore;\r
+}\r
+\r
/**\r
Check whether the this op code is required.\r
\r
@param RequestBlockArray The array includes all the request info or NULL.\r
@param HiiHandle The hii handle for this form package.\r
- @param VarStorageData The varstore data strucure.\r
+ @param VarStorageData The varstore data structure.\r
@param IfrOpHdr Ifr opcode header for this opcode.\r
@param VarWidth The buffer width for this opcode.\r
@param ReturnData The data block added for this opcode.\r
\r
@retval EFI_SUCCESS This opcode is required.\r
- @retval Others This opcode is not required or error occur.\r
+ @retval EFI_NOT_FOUND This opcode is not required.\r
+ @retval Others Contain some error.\r
\r
**/\r
EFI_STATUS\r
//\r
// This question is not in the requested string. Skip it.\r
//\r
- return EFI_SUCCESS;\r
+ return EFI_NOT_FOUND;\r
}\r
} else {\r
VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;\r
//\r
// This question is not in the requested string. Skip it.\r
//\r
- return EFI_SUCCESS;\r
+ return EFI_NOT_FOUND;\r
}\r
\r
//\r
\r
@param HiiHandle Hii Handle for this hii package.\r
@param Package Pointer to the form package data.\r
- @param PackageLength Length of the pacakge.\r
+ @param PackageLength Length of the package.\r
@param ConfigHdr Request string ConfigHdr. If it is NULL,\r
the first found varstore will be as ConfigHdr.\r
@param RequestBlockArray The block array is retrieved from the request string.\r
@param DefaultIdArray Point to the got default id and default name array.\r
\r
@retval EFI_SUCCESS The block array and the default value array are got.\r
- @retval EFI_INVALID_PARAMETER The varstore defintion in the differnt form pacakges\r
+ @retval EFI_INVALID_PARAMETER The varstore definition in the different form packages\r
are conflicted. \r
@retval EFI_OUT_OF_RESOURCES No enough memory.\r
**/\r
{\r
EFI_STATUS Status;\r
UINTN IfrOffset;\r
+ UINTN PackageOffset;\r
EFI_IFR_VARSTORE *IfrVarStore;\r
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
EFI_IFR_OP_HEADER *IfrOpHdr;\r
IFR_DEFAULT_DATA *DefaultDataPtr;\r
IFR_BLOCK_DATA *BlockData;\r
CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
UINT16 VarWidth;\r
UINT16 VarDefaultId;\r
- EFI_STRING GuidStr;\r
- EFI_STRING NameStr;\r
- EFI_STRING TempStr;\r
- UINTN LengthString;\r
BOOLEAN FirstOneOfOption;\r
+ BOOLEAN FirstOrderedList;\r
LIST_ENTRY *LinkData;\r
LIST_ENTRY *LinkDefault;\r
EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;\r
+ EFI_HII_PACKAGE_HEADER *PackageHeader;\r
+ EFI_VARSTORE_ID VarStoreId;\r
+ UINT16 SmallestDefaultId;\r
+ BOOLEAN SmallestIdFromFlag;\r
+ BOOLEAN FromOtherDefaultOpcode;\r
\r
- LengthString = 0;\r
Status = EFI_SUCCESS;\r
- GuidStr = NULL;\r
- NameStr = NULL;\r
- TempStr = NULL;\r
BlockData = NULL;\r
DefaultDataPtr = NULL;\r
FirstOneOfOption = FALSE;\r
+ VarStoreId = 0;\r
+ FirstOrderedList = FALSE;\r
+ VarStoreName = NULL;\r
ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));\r
+ SmallestDefaultId = 0xFFFF;\r
+ FromOtherDefaultOpcode = FALSE;\r
+\r
+ //\r
+ // Go through the form package to parse OpCode one by one.\r
+ //\r
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) Package;\r
+ IfrOffset = PackageOffset;\r
+ while (IfrOffset < PackageLength) {\r
+\r
+ //\r
+ // More than one form package found.\r
+ //\r
+ if (PackageOffset >= PackageHeader->Length) {\r
+ //\r
+ // Already found varstore for this request, break;\r
+ //\r
+ if (VarStoreId != 0) {\r
+ VarStoreId = 0;\r
+ }\r
+\r
+ //\r
+ // Get next package header info.\r
+ //\r
+ IfrOffset += sizeof (EFI_HII_PACKAGE_HEADER);\r
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);\r
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) (Package + IfrOffset);\r
+ }\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 < PackageLength) {\r
IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset);\r
switch (IfrOpHdr->OpCode) {\r
case EFI_IFR_VARSTORE_OP:\r
//\r
// VarStore is found. Don't need to search any more.\r
//\r
- if (VarStorageData->VarStoreId != 0) {\r
+ if (VarStoreId != 0) {\r
break;\r
}\r
\r
IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {\r
//\r
// Find the matched VarStore\r
//\r
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid);\r
- VarStorageData->VarStoreId = IfrVarStore->VarStoreId;\r
VarStorageData->Size = IfrVarStore->Size;\r
VarStorageData->Name = VarStoreName;\r
VarStorageData->Type = EFI_HII_VARSTORE_BUFFER;\r
+ VarStoreId = IfrVarStore->VarStoreId;\r
+ } else {\r
+ FreePool (VarStoreName);\r
+ VarStoreName = NULL;\r
}\r
break;\r
\r
//\r
// VarStore is found. Don't need to search any more.\r
//\r
- if (VarStorageData->VarStoreId != 0) {\r
+ if (VarStoreId != 0) {\r
break;\r
}\r
\r
break;\r
}\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {\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
VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;\r
+ VarStoreId = IfrEfiVarStore->VarStoreId;\r
+ } else {\r
+ FreePool (VarStoreName);\r
+ VarStoreName = NULL;\r
}\r
break;\r
\r
//\r
// VarStore is found. Don't need to search any more.\r
//\r
- if (VarStorageData->VarStoreId != 0) {\r
+ if (VarStoreId != 0) {\r
break;\r
}\r
\r
// Find the matched VarStore\r
//\r
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid);\r
- VarStorageData->VarStoreId = IfrNameValueVarStore->VarStoreId;\r
VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE;\r
+ VarStoreId = IfrNameValueVarStore->VarStoreId;\r
}\r
break;\r
\r
//\r
// No matched varstore is found and directly return.\r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if ( VarStoreId == 0) {\r
Status = EFI_SUCCESS;\r
goto Done;\r
}\r
//\r
// Ref question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if ( VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrRef = (EFI_IFR_REF4 *) IfrOpHdr;\r
- if (IfrRef->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrRef->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
VarWidth = (UINT16) (sizeof (EFI_HII_REF));\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
break;\r
//\r
// Numeric and OneOf question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;\r
- if (IfrOneOf->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrOneOf->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
\r
- if (BlockData == NULL) {\r
- //\r
- // BlockData == NULL means this opcode is not in the requst array.\r
- //\r
- break;\r
- }\r
+ //\r
+ //when go to there,BlockData can't be NULLL.\r
+ //\r
+ ASSERT (BlockData != NULL);\r
\r
if (IfrOpHdr->OpCode == EFI_IFR_ONE_OF_OP) {\r
//\r
//\r
// offset by question header\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
+ FirstOrderedList = TRUE;\r
//\r
// OrderedList question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\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
+ if (IfrOrderedList->Question.VarStoreId != VarStoreId) {\r
BlockData = NULL;\r
break;\r
}\r
VarWidth = IfrOrderedList->MaxContainers;\r
+\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
break;\r
//\r
// CheckBox question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;\r
- if (IfrCheckBox->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrCheckBox->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
VarWidth = (UINT16) sizeof (BOOLEAN);\r
+\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
\r
- if (BlockData == NULL) {\r
- //\r
- // BlockData == NULL means this opcode is not in the requst array.\r
- //\r
- break;\r
- }\r
+ //\r
+ //when go to there,BlockData can't be NULLL.\r
+ //\r
+ ASSERT (BlockData != NULL);\r
+\r
+ SmallestIdFromFlag = FALSE;\r
\r
//\r
// Add default value for standard ID by CheckBox Flag\r
DefaultData.DefaultId = VarDefaultId;\r
if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT) == EFI_IFR_CHECKBOX_DEFAULT) {\r
//\r
- // When flag is set, defautl value is TRUE.\r
+ // When flag is set, default value is TRUE.\r
//\r
DefaultData.Type = DefaultValueFromFlag;\r
DefaultData.Value.b = TRUE;\r
- } else {\r
- //\r
- // When flag is not set, defautl value is FASLE.\r
- //\r
- DefaultData.Type = DefaultValueFromDefault;\r
- DefaultData.Value.b = FALSE;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+\r
+ if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) {\r
+ //\r
+ // Record the SmallestDefaultId and update the SmallestIdFromFlag.\r
+ //\r
+ SmallestDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+ SmallestIdFromFlag = TRUE;\r
+ }\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
DefaultData.DefaultId = VarDefaultId;\r
if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) == EFI_IFR_CHECKBOX_DEFAULT_MFG) {\r
//\r
- // When flag is set, defautl value is TRUE.\r
+ // When flag is set, default value is TRUE.\r
//\r
DefaultData.Type = DefaultValueFromFlag;\r
DefaultData.Value.b = TRUE;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+\r
+ if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) {\r
+ //\r
+ // Record the SmallestDefaultId and update the SmallestIdFromFlag.\r
+ //\r
+ SmallestDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
+ SmallestIdFromFlag = TRUE;\r
+ }\r
+ }\r
+ if (SmallestIdFromFlag) {\r
+ //\r
+ // When smallest default Id is given by the flag of CheckBox, set default value with TRUE for other default Id in the DefaultId list.\r
+ //\r
+ DefaultData.Type = DefaultValueFromOtherDefault;\r
+ DefaultData.Value.b = TRUE;\r
+ //\r
+ // Set default value for all the default id in the DefaultId list.\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
} else {\r
//\r
- // When flag is not set, defautl value is FASLE.\r
+ // When flag is not set, default value is FASLE.\r
//\r
DefaultData.Type = DefaultValueFromDefault;\r
DefaultData.Value.b = FALSE;\r
+ //\r
+ // Set default value for all the default id in the DefaultId list.\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
- //\r
- // Add DefaultValue into current BlockData\r
- //\r
- InsertDefaultValue (BlockData, &DefaultData);\r
break;\r
\r
case EFI_IFR_DATE_OP:\r
//\r
// Date question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrDate = (EFI_IFR_DATE *) IfrOpHdr;\r
- if (IfrDate->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrDate->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
VarWidth = (UINT16) sizeof (EFI_HII_DATE);\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
break;\r
//\r
// Time question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrTime = (EFI_IFR_TIME *) IfrOpHdr;\r
- if (IfrTime->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrTime->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
VarWidth = (UINT16) sizeof (EFI_HII_TIME);\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
break;\r
//\r
// String question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrString = (EFI_IFR_STRING *) IfrOpHdr;\r
- if (IfrString->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrString->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
VarWidth = (UINT16) (IfrString->MaxSize * sizeof (UINT16));\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
-\r
- //\r
- // No default value for string.\r
- //\r
- BlockData = NULL;\r
break;\r
\r
case EFI_IFR_PASSWORD_OP:\r
//\r
// Password question is not in IFR Form. This IFR form is not valid. \r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStoreId == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
// Check whether this question is for the requested varstore.\r
//\r
IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr;\r
- if (IfrPassword->Question.VarStoreId != VarStorageData->VarStoreId) {\r
+ if (IfrPassword->Question.VarStoreId != VarStoreId) {\r
break;\r
}\r
\r
+ //\r
+ // The BlockData may allocate by other opcode,need to clean.\r
+ //\r
+ if (BlockData != NULL){\r
+ BlockData = NULL;\r
+ }\r
+\r
VarWidth = (UINT16) (IfrPassword->MaxSize * sizeof (UINT16));\r
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);\r
if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_NOT_FOUND){\r
+ //\r
+ //The opcode is not required,exit and parse other opcode.\r
+ //\r
+ break;\r
+ }\r
goto Done;\r
}\r
\r
\r
IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpHdr;\r
if (BlockData->OpCode == EFI_IFR_ORDERED_LIST_OP) {\r
+\r
+ if (!FirstOrderedList){\r
+ break;\r
+ }\r
//\r
// Get ordered list option data type.\r
//\r
// Add Block Data into VarStorageData BlockEntry\r
//\r
InsertBlockData (&VarStorageData->BlockEntry, &BlockData);\r
- //\r
- // No default data for OrderedList.\r
- //\r
- BlockData = NULL;\r
+\r
+ FirstOrderedList = FALSE;\r
+\r
break;\r
}\r
\r
//\r
// 1. Set default value for OneOf option when flag field has default attribute.\r
+ // And set the default value with the smallest default id for other default id in the DefaultId list.\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
// The first oneof option value will be used as default value when no default value is specified. \r
//\r
FirstOneOfOption = FALSE;\r
+\r
+ SmallestIdFromFlag = FALSE;\r
\r
// Prepare new DefaultValue\r
//\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 (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) {\r
+ //\r
+ // Record the SmallestDefaultId and update the SmallestIdFromFlag.\r
+ //\r
+ SmallestDefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+ SmallestIdFromFlag = TRUE;\r
+ }\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
+ if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) {\r
+ //\r
+ // Record the SmallestDefaultId and update the SmallestIdFromFlag.\r
+ //\r
+ SmallestDefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
+ SmallestIdFromFlag = TRUE;\r
+ }\r
+ }\r
+\r
+ if (SmallestIdFromFlag) {\r
+ //\r
+ // When smallest default Id is given by the flag of oneofOption, set this option value for other default Id in the DefaultId list.\r
+ //\r
+ DefaultData.Type = DefaultValueFromOtherDefault;\r
+ //\r
+ // Set default value for other default id in the DefaultId list.\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
}\r
\r
break;\r
}\r
\r
- if (BlockData->OpCode == EFI_IFR_ORDERED_LIST_OP) {\r
- //\r
- // OrderedList Opcode is no default value.\r
- //\r
- break;\r
- }\r
//\r
// Get the DefaultId\r
//\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
+ // Set default value for other default id in the DefaultId list.\r
+ // when SmallestDefaultId == VarDefaultId means there are two defaults with same default Id.\r
+ // If the two defaults are both from default opcode, use the first default as the default value of other default Id.\r
+ // If one from flag and the other form default opcode, use the default opcode value as the default value of other default Id.\r
+ //\r
+ if ((SmallestDefaultId > VarDefaultId) || (SmallestDefaultId == VarDefaultId && !FromOtherDefaultOpcode)) {\r
+ FromOtherDefaultOpcode = TRUE;\r
+ SmallestDefaultId = VarDefaultId;\r
+ for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {\r
+ DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry);\r
+ if (DefaultDataPtr->DefaultId != DefaultData.DefaultId){\r
+ DefaultData.Type = DefaultValueFromOtherDefault;\r
+ DefaultData.DefaultId = DefaultDataPtr->DefaultId;\r
+ InsertDefaultValue (BlockData, &DefaultData);\r
+ }\r
+ }\r
+ }\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 every time.\r
// use it.\r
//\r
DefaultData.Cleaned = FALSE;\r
//\r
// End Opcode is for Var question.\r
//\r
- if (BlockData != NULL && BlockData->Scope > 0) {\r
- BlockData->Scope--;\r
+ if (BlockData != NULL) {\r
+ if (BlockData->Scope > 0) {\r
+ BlockData->Scope--;\r
+ }\r
+ if (BlockData->Scope == 0) {\r
+ BlockData = NULL;\r
+ //\r
+ // when finishing parsing a question, clean the SmallestDefaultId and GetDefaultFromDefaultOpcode.\r
+ //\r
+ SmallestDefaultId = 0xFFFF;\r
+ FromOtherDefaultOpcode = FALSE;\r
+ }\r
}\r
+\r
break;\r
\r
default:\r
- if (BlockData != NULL && BlockData->Scope > 0) {\r
- BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);\r
+ if (BlockData != NULL) {\r
+ if (BlockData->Scope > 0) {\r
+ BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);\r
+ }\r
+\r
+ if (BlockData->Scope == 0) {\r
+ BlockData = NULL;\r
+ }\r
}\r
break;\r
}\r
\r
- IfrOffset += IfrOpHdr->Length;\r
+ IfrOffset += IfrOpHdr->Length;\r
+ PackageOffset += IfrOpHdr->Length;\r
+ }\r
+\r
+ //\r
+ //if Status == EFI_NOT_FOUND, just means the opcode is not required,not contain any error,\r
+ //so set the Status to EFI_SUCCESS.\r
+ //\r
+ if (Status == EFI_NOT_FOUND){\r
+ Status = EFI_SUCCESS;\r
}\r
\r
Done:\r
IFR_BLOCK_DATA *NextBlockData;\r
UINTN Length;\r
\r
+ TmpBuffer = NULL;\r
+\r
//\r
// Init RequestBlockArray\r
//\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\r
-\r
+ FreePool (TmpBuffer);\r
StringPtr += Length;\r
if (*StringPtr != 0 && *StringPtr != L'&') {\r
goto Done;\r
//\r
// Start with <ConfigHdr>\r
//\r
- StrCpy (StringPtr, ConfigHdr);\r
+ StrCpyS (StringPtr, Length, ConfigHdr);\r
StringPtr += StrLen (StringPtr);\r
\r
//\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- StrCpy (*ConfigHdr, GuidStr);\r
- StrCat (*ConfigHdr, NameStr);\r
+ StrCpyS (*ConfigHdr, Length, GuidStr);\r
+ StrCatS (*ConfigHdr, Length, NameStr);\r
if (VarStorageData->Name == NULL) {\r
- StrCat (*ConfigHdr, L"&");\r
+ StrCatS (*ConfigHdr, Length, L"&");\r
}\r
- StrCat (*ConfigHdr, PathStr);\r
+ StrCatS (*ConfigHdr, Length, PathStr);\r
\r
//\r
// Remove the last character L'&'\r
/**\r
Generate ConfigAltResp string base on the varstore info.\r
\r
+ @param HiiHandle Hii Handle for this hii package.\r
@param ConfigHdr The config header for this varstore.\r
@param VarStorageData The varstore info.\r
@param DefaultIdArray The Default id array.\r
**/\r
EFI_STATUS\r
GenerateAltConfigResp (\r
+ IN EFI_HII_HANDLE HiiHandle,\r
IN CHAR16 *ConfigHdr,\r
IN IFR_VARSTORAGE_DATA *VarStorageData,\r
IN IFR_DEFAULT_DATA *DefaultIdArray,\r
IFR_DEFAULT_DATA *DefaultValueData;\r
UINTN Width;\r
UINT8 *TmpBuffer;\r
+ CHAR16 *DefaultString;\r
\r
BlockData = NULL;\r
DataExist = FALSE;\r
-\r
+ DefaultString = NULL;\r
//\r
// Add length for <ConfigHdr> + '\0'\r
//\r
//\r
// Start with <ConfigHdr>\r
//\r
- StrCpy (StringPtr, ConfigHdr);\r
+ StrCpyS (StringPtr, Length, ConfigHdr);\r
StringPtr += StrLen (StringPtr);\r
\r
for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) {\r
// Convert Value to a hex string in "%x" format\r
// NOTE: This is in the opposite byte that GUID and PATH use\r
//\r
- TmpBuffer = (UINT8 *) &(DefaultValueData->Value);\r
- for (; Width > 0; Width--) {\r
+ if (BlockData->OpCode == EFI_IFR_STRING_OP){\r
+ DefaultString = InternalGetString(HiiHandle, DefaultValueData->Value.string);\r
+ TmpBuffer = (UINT8 *) DefaultString;\r
+ } else {\r
+ TmpBuffer = (UINT8 *) &(DefaultValueData->Value);\r
+ }\r
+ for (; Width > 0 && (TmpBuffer != NULL); Width--) {\r
StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2);\r
}\r
+ if (DefaultString != NULL){\r
+ FreePool(DefaultString);\r
+ DefaultString = NULL;\r
+ }\r
}\r
}\r
}\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
+ @param PointerProgress Optional parameter, it can 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
EFI_STRING ConfigHdr;\r
EFI_STRING StringPtr;\r
EFI_STRING Progress;\r
- BOOLEAN DataExist;\r
\r
if (DataBaseRecord == NULL || DevicePath == NULL || Request == NULL || AltCfgResp == NULL) {\r
return EFI_INVALID_PARAMETER;\r
ConfigHdr = NULL;\r
HiiFormPackage = NULL;\r
PackageSize = 0;\r
- DataExist = FALSE;\r
Progress = *Request;\r
\r
Status = GetFormPackageData (DataBaseRecord, &HiiFormPackage, &PackageSize);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto Done;\r
}\r
\r
//\r
- // 1. Get the request block array by Request String when Request string containts the block array.\r
+ // 1. Get the request block array by Request String when Request string contains the block array.\r
//\r
StringPtr = NULL;\r
if (*Request != NULL) {\r
//\r
\r
//\r
- // Parse the opcode in form pacakge to get the default setting.\r
+ // Parse the opcode in form package to get the default setting.\r
//\r
Status = ParseIfrData (DataBaseRecord->Handle,\r
HiiFormPackage,\r
//\r
// No requested varstore in IFR data and directly return\r
//\r
- if (VarStorageData->VarStoreId == 0) {\r
+ if (VarStorageData->Type == 0 && VarStorageData->Name == NULL) {\r
Status = EFI_SUCCESS;\r
goto Done;\r
}\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
- Status = GenerateAltConfigResp (ConfigHdr, VarStorageData, DefaultIdArray, &DefaultAltCfgResp);\r
+ Status = GenerateAltConfigResp (DataBaseRecord->Handle,ConfigHdr, VarStorageData, DefaultIdArray, &DefaultAltCfgResp);\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\r
\r
//\r
- // 5. Merge string into the input AltCfgResp if the iput *AltCfgResp is not NULL.\r
+ // 5. Merge string into the input AltCfgResp if the input *AltCfgResp is not NULL.\r
//\r
if (*AltCfgResp != NULL && DefaultAltCfgResp != NULL) {\r
Status = MergeDefaultString (AltCfgResp, DefaultAltCfgResp);\r
}\r
FreePool (BlockData);\r
}\r
+ if (VarStorageData ->Name != NULL) {\r
+ FreePool (VarStorageData ->Name);\r
+ VarStorageData ->Name = NULL;\r
+ }\r
FreePool (VarStorageData);\r
}\r
\r
}\r
\r
//\r
- // Free Pacakge data\r
+ // Free Package data\r
//\r
if (HiiFormPackage != NULL) {\r
FreePool (HiiFormPackage);\r
{\r
EFI_STATUS Status;\r
EFI_STRING VarStoreName;\r
+ UINTN NameSize;\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
+ Status = EFI_SUCCESS;\r
+ BufferSize = 0;\r
+ VarStore = NULL;\r
+ VarStoreName = NULL;\r
+ *AccessProgress = Request;\r
+\r
+ NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize);\r
\r
\r
Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
{\r
EFI_STATUS Status;\r
EFI_STRING VarStoreName;\r
+ UINTN NameSize;\r
UINT8 *VarStore;\r
UINTN BufferSize;\r
UINTN BlockSize;\r
BufferSize = 0;\r
VarStore = NULL;\r
VarStoreName = NULL;\r
+ *Result = RequestResp;\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize);\r
\r
Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r
+ DEBUG ((DEBUG_ERROR, "The variable does not exist!"));\r
goto Done;\r
}\r
\r
\r
Status = gRT->SetVariable (VarStoreName, &EfiVarStoreInfo->Guid, EfiVarStoreInfo->Attributes, BufferSize, VarStore);\r
if (EFI_ERROR (Status)) {\r
+ *Result = RequestResp;\r
goto Done;\r
}\r
\r
Progress parameter is set to NULL.\r
@retval EFI_INVALID_PARAMETER Illegal syntax. Progress set to most recent &\r
before the error or the beginning of the string.\r
- @retval EFI_INVALID_PARAMETER Unknown name. Progress points to the & before the\r
- name in question.\r
+ @retval EFI_INVALID_PARAMETER The ExtractConfig function of the underlying HII\r
+ Configuration Access Protocol returned \r
+ EFI_INVALID_PARAMETER. Progress set to most recent\r
+ & before the error or the beginning of the string.\r
\r
**/\r
EFI_STATUS\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
EFI_STRING AccessProgress;\r
EFI_STRING AccessResults;\r
+ EFI_STRING AccessProgressBackup;\r
+ EFI_STRING AccessResultsBackup;\r
EFI_STRING DefaultResults;\r
BOOLEAN FirstElement;\r
BOOLEAN IfrDataParsedFlag;\r
BOOLEAN IsEfiVarStore;\r
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;\r
EFI_STRING ErrorPtr;\r
+ UINTN DevicePathSize;\r
+ UINTN ConigStringSize;\r
+ UINTN ConigStringSizeNewsize;\r
+ EFI_STRING ConfigStringPtr;\r
\r
if (This == NULL || Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
Status = EFI_SUCCESS;\r
AccessResults = NULL;\r
AccessProgress = NULL;\r
+ AccessResultsBackup = NULL;\r
+ AccessProgressBackup = NULL;\r
DevicePath = NULL;\r
IfrDataParsedFlag = FALSE;\r
IsEfiVarStore = FALSE;\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 (CompareMem (\r
- DevicePath,\r
- CurrentDevicePath,\r
- GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)\r
- ) == 0) {\r
+ DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);\r
+ if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, ConfigRequest)) {\r
DriverHandle = Database->DriverHandle;\r
HiiHandle = Database->Handle;\r
break;\r
//\r
Status = GetConfigRespFromEfiVarStore(This, EfiVarStoreInfo, ConfigRequest, &AccessResults, &AccessProgress);\r
FreePool (EfiVarStoreInfo);\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
+ // For EfiVarstore, call corresponding ConfigAccess protocol to get the AltCfgResp from driver.\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ DriverHandle,\r
+ &gEfiHiiConfigAccessProtocolGuid,\r
+ (VOID **) &ConfigAccess\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // The driver has EfiVarStore, may not install ConfigAccess protocol.\r
+ // So ignore the error status in this case.\r
+ //\r
+ Status = EFI_SUCCESS;\r
+ } else {\r
+ Status = ConfigAccess->ExtractConfig (\r
+ ConfigAccess,\r
+ ConfigRequest,\r
+ &AccessProgressBackup,\r
+ &AccessResultsBackup\r
+ );\r
+ if (!EFI_ERROR(Status)) {\r
+ //\r
+ //Merge the AltCfgResp in AccessResultsBackup to AccessResults\r
+ //\r
+ if ((AccessResultsBackup != NULL) && (StrStr (AccessResultsBackup, L"&ALTCFG=") != NULL)) {\r
+ ConigStringSize = StrSize (AccessResults);\r
+ ConfigStringPtr = StrStr (AccessResultsBackup, L"&GUID=");\r
+ ConigStringSizeNewsize = StrSize (ConfigStringPtr) + ConigStringSize + sizeof (CHAR16);\r
+ AccessResults = (EFI_STRING) ReallocatePool (\r
+ ConigStringSize,\r
+ ConigStringSizeNewsize,\r
+ AccessResults);\r
+ StrCatS (AccessResults, ConigStringSizeNewsize / sizeof (CHAR16), ConfigStringPtr);\r
+ }\r
+ } else {\r
+ //\r
+ // In the ExtractConfig function of some driver may not support EfiVarStore,\r
+ // may return error status, just ignore the error status in this case.\r
+ //\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ if (AccessResultsBackup != NULL) {\r
+ FreePool (AccessResultsBackup);\r
+ AccessResultsBackup = NULL;\r
+ }\r
+ }\r
} else {\r
//\r
// Call corresponding ConfigAccess protocol to extract settings\r
&gEfiHiiConfigAccessProtocolGuid,\r
(VOID **) &ConfigAccess\r
);\r
- ASSERT_EFI_ERROR (Status);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
\r
Status = ConfigAccess->ExtractConfig (\r
ConfigAccess,\r
\r
//\r
// Attach this <ConfigAltResp> to a <MultiConfigAltResp>. There is a '&'\r
- // which seperates the first <ConfigAltResp> and the following ones.\r
+ // which separates the first <ConfigAltResp> and the following ones.\r
//\r
ASSERT (*AccessProgress == 0);\r
\r
instance.\r
@param Results Null-terminated Unicode string in\r
<MultiConfigAltResp> format which has all values\r
- filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
- De-allocation is up to the caller.\r
+ filled in for the entirety of the current HII \r
+ database. String to be allocated by the called \r
+ function. De-allocation is up to the caller.\r
\r
@retval EFI_SUCCESS The Results string is filled with the values\r
corresponding to all requested names.\r
\r
//\r
// Attach this <ConfigAltResp> to a <MultiConfigAltResp>. There is a '&'\r
- // which seperates the first <ConfigAltResp> and the following ones. \r
+ // which separates the first <ConfigAltResp> and the following ones.\r
//\r
if (!FirstElement) {\r
Status = AppendToMultiString (Results, L"&");\r
EFI_STRING AccessProgress;\r
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;\r
BOOLEAN IsEfiVarstore;\r
+ UINTN DevicePathSize;\r
\r
if (This == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
\r
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if (CompareMem (\r
- DevicePath,\r
- CurrentDevicePath,\r
- GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)\r
- ) == 0) {\r
+ DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);\r
+ if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, ConfigResp)) {\r
DriverHandle = Database->DriverHandle;\r
break;\r
}\r
&gEfiHiiConfigAccessProtocolGuid,\r
(VOID **) &ConfigAccess\r
);\r
- ASSERT_EFI_ERROR (Status);\r
+ if (EFI_ERROR (Status)) {\r
+ *Progress = StringPtr;\r
+ FreePool (ConfigResp);\r
+ return EFI_NOT_FOUND;\r
+ }\r
\r
Status = ConfigAccess->RouteConfig (\r
ConfigAccess,\r
);\r
}\r
if (EFI_ERROR (Status)) {\r
+ ASSERT (AccessProgress != NULL);\r
//\r
// AccessProgress indicates the parsing progress on <ConfigResp>.\r
// Map it to the progress on <MultiConfigResp> then return it.\r
CHAR16 *TemString;\r
CHAR16 TemChar;\r
\r
+ TmpBuffer = NULL;\r
+\r
if (This == NULL || Progress == NULL || Config == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
if (*StringPtr == 0) {\r
*Progress = StringPtr;\r
- Status = EFI_SUCCESS;\r
\r
AppendToMultiString(Config, ConfigRequest);\r
HiiToLower (*Config);\r
\r
- goto Exit;\r
+ return EFI_SUCCESS;\r
}\r
//\r
// Skip '&'\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
if (EFI_ERROR (Status)) {\r
- *Progress = ConfigRequest;\r
+ *Progress = TmpPtr - 1;\r
goto Exit;\r
}\r
Offset = 0;\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
- *Progress = StringPtr - Length - StrLen (L"OFFSET=") - 1;\r
+ *Progress = TmpPtr - 1;\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
if (EFI_ERROR (Status)) {\r
- *Progress = ConfigRequest;\r
+ *Progress = TmpPtr - 1;\r
goto Exit;\r
}\r
Width = 0;\r
\r
StringPtr += Length;\r
if (*StringPtr != 0 && *StringPtr != L'&') {\r
- *Progress = StringPtr - Length - StrLen (L"&WIDTH=");\r
+ *Progress = TmpPtr - 1;\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
*(ConfigElement + (StringPtr - TmpPtr)) = L'&';\r
}\r
*(ConfigElement + (StringPtr - TmpPtr) + 1) = 0;\r
- StrCat (ConfigElement, L"VALUE=");\r
- StrCat (ConfigElement, ValueStr);\r
+ StrCatS (ConfigElement, Length, L"VALUE=");\r
+ StrCatS (ConfigElement, Length, ValueStr);\r
\r
AppendToMultiString (Config, ConfigElement);\r
\r
(see below) is returned.\r
@param BlockSize The length of the Block in units of UINT8. On\r
input, this is the size of the Block. On output,\r
- if successful, contains the index of the last\r
- modified byte in the Block.\r
+ if successful, contains the largest index of the\r
+ modified byte in the Block, or the required buffer\r
+ size if the Block is not large enough.\r
@param Progress On return, points to an element of the ConfigResp\r
string filled in with the offset of the most\r
recent '&' before the first failing name / value\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_BUFFER_TOO_SMALL Block not large enough. Progress undefined. \r
+ BlockSize is updated with the required buffer size.\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
HII_DATABASE_PRIVATE_DATA *Private;\r
EFI_STRING StringPtr;\r
+ EFI_STRING TmpPtr;\r
UINTN Length;\r
EFI_STATUS Status;\r
UINT8 *TmpBuffer;\r
UINTN BufferSize;\r
UINTN MaxBlockSize;\r
\r
+ TmpBuffer = NULL;\r
+\r
if (This == NULL || BlockSize == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
// <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE='<Number>\r
//\r
while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) {\r
+ TmpPtr = StringPtr;\r
StringPtr += StrLen (L"&OFFSET=");\r
//\r
// Get Offset\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
if (EFI_ERROR (Status)) {\r
- *Progress = ConfigResp;\r
+ *Progress = TmpPtr;\r
goto Exit;\r
}\r
Offset = 0;\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
- *Progress = StringPtr - Length - StrLen (L"&OFFSET=");\r
+ *Progress = TmpPtr;\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
//\r
Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
if (EFI_ERROR (Status)) {\r
- *Progress = ConfigResp;\r
+ *Progress = TmpPtr;\r
goto Exit;\r
}\r
Width = 0;\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) {\r
- *Progress = StringPtr - Length - StrLen (L"&WIDTH=");\r
+ *Progress = TmpPtr;\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
//\r
Status = GetValueOfNumber (StringPtr, &Value, &Length);\r
if (EFI_ERROR (Status)) {\r
- *Progress = ConfigResp;\r
+ *Progress = TmpPtr;\r
goto Exit;\r
}\r
\r
StringPtr += Length;\r
if (*StringPtr != 0 && *StringPtr != L'&') {\r
- *Progress = StringPtr - Length - StrLen (L"&VALUE=");\r
+ *Progress = TmpPtr;\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
if (MaxBlockSize > BufferSize) {\r
*BlockSize = MaxBlockSize;\r
if (Block != NULL) {\r
- return EFI_DEVICE_ERROR;\r
+ return EFI_BUFFER_TOO_SMALL;\r
}\r
}\r
\r
if (*AltCfgResp == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
} else {\r
- StrnCpy (*AltCfgResp, HdrStart, HdrEnd - HdrStart);\r
- StrCat (*AltCfgResp, Result);\r
+ StrnCpyS (*AltCfgResp, Length, HdrStart, HdrEnd - HdrStart);\r
+ StrCatS (*AltCfgResp, Length, Result);\r
Status = EFI_SUCCESS;\r
}\r
}\r