FORMSET_STORAGE *Storage;\r
CHAR16 *Name;\r
\r
+ if (ConfigString == NULL) {\r
+ return NULL;\r
+ }\r
+\r
StorageList = GetFirstNode (&FormSet->StorageListHead);\r
\r
while (!IsNull (&FormSet->StorageListHead, StorageList)) {\r
StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);\r
}\r
\r
- return NULL;\r
+ return NULL;\r
}\r
\r
/**\r
OUT EFI_STRING *Results\r
)\r
{\r
- EFI_STATUS Status;\r
- CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
- FORMSET_STORAGE *BufferStorage;\r
- VOID *Data;\r
- UINTN DataSize;\r
-\r
- if (Request == NULL) {\r
+ EFI_STATUS Status;\r
+ CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
+ FORMSET_STORAGE *BufferStorage;\r
+ VOID *Data;\r
+ UINTN DataSize;\r
+ FORM_BROWSER_FORMSET *FormSetContext;\r
+ CHAR16 *VarStoreName;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ UINTN Size;\r
+ BOOLEAN AllocatedRequest;\r
+ LIST_ENTRY *StorageList;\r
+ EFI_STRING SingleResult;\r
+ EFI_STRING FinalResults;\r
+ EFI_STRING StrPointer;\r
+\r
+ if (Progress == NULL || Results == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ *Progress = Request;\r
+\r
+ Status = EFI_SUCCESS;\r
+ Data = NULL;\r
+ StrPointer = NULL;\r
+ SingleResult = NULL;\r
+ FinalResults = NULL;\r
+ ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
+ FormSetContext = ConfigAccess->ThunkContext->FormSet;\r
+ if (IsListEmpty (&FormSetContext->StorageListHead)) {\r
+ //\r
+ // No VarStorage does exist in this form.\r
+ //\r
return EFI_NOT_FOUND;\r
}\r
+ StorageList = GetFirstNode (&FormSetContext->StorageListHead);\r
\r
- Data = NULL;\r
- ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
+ do {\r
+ if (Request != NULL) {\r
+ BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);\r
+ if (BufferStorage == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ } else {\r
+ if (IsNull (&FormSetContext->StorageListHead, StorageList)) {\r
+ //\r
+ // No Storage to be extracted into the results.\r
+ //\r
+ break;\r
+ }\r
+ BufferStorage = FORMSET_STORAGE_FROM_LINK (StorageList);\r
+ StorageList = GetNextNode (&FormSetContext->StorageListHead, StorageList);\r
+ }\r
+ \r
+ VarStoreName = NULL;\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ Size = 0;\r
+ AllocatedRequest = FALSE;\r
\r
- BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);\r
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
+ //\r
+ // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.\r
+ //\r
+ if (ConfigAccess->FormCallbackProtocol == NULL ||\r
+ ConfigAccess->FormCallbackProtocol->NvRead == NULL) {\r
+ Status = GetUefiVariable (\r
+ BufferStorage,\r
+ &Data,\r
+ &DataSize\r
+ );\r
+ } else {\r
+ Status = CallFormCallBack (\r
+ BufferStorage,\r
+ ConfigAccess->FormCallbackProtocol,\r
+ &Data,\r
+ &DataSize\r
+ );\r
+ }\r
+ } else {\r
+ //\r
+ // Use the NvMapOverride.\r
+ //\r
+ DataSize = BufferStorage->Size;\r
+ Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);\r
+ \r
+ if (Data != NULL) {\r
+ Status = EFI_SUCCESS;\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ \r
+ if (!EFI_ERROR (Status)) {\r
+ ConfigRequest = Request;\r
+ if (Request == NULL || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request is without any request element, construct full request string.\r
+ //\r
\r
- if (BufferStorage == NULL) {\r
- *Progress = (EFI_STRING) Request;\r
- return EFI_NOT_FOUND;\r
- }\r
+ if ((BufferStorage->VarStoreId == FormSetContext->DefaultVarStoreId) && (FormSetContext->OriginalDefaultVarStoreName != NULL)) {\r
+ VarStoreName = FormSetContext->OriginalDefaultVarStoreName;\r
+ } else {\r
+ VarStoreName = BufferStorage->Name;\r
+ }\r
\r
- if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
+ //\r
+ // First Set ConfigRequestHdr string.\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&BufferStorage->Guid, VarStoreName, ConfigAccess->ThunkContext->UefiHiiDriverHandle);\r
+ ASSERT (ConfigRequestHdr != NULL);\r
+\r
+ //\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template \r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)DataSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
+ Status = mHiiConfigRoutingProtocol->BlockToConfig (\r
+ mHiiConfigRoutingProtocol,\r
+ ConfigRequest,\r
+ Data,\r
+ DataSize,\r
+ &SingleResult,\r
+ Progress\r
+ );\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+ }\r
//\r
- // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.\r
+ // Free the allocated Data\r
//\r
- if (ConfigAccess->FormCallbackProtocol == NULL ||\r
- ConfigAccess->FormCallbackProtocol->NvRead == NULL) {\r
- Status = GetUefiVariable (\r
- BufferStorage,\r
- &Data,\r
- &DataSize\r
- );\r
- } else {\r
- Status = CallFormCallBack (\r
- BufferStorage,\r
- ConfigAccess->FormCallbackProtocol,\r
- &Data,\r
- &DataSize\r
- );\r
+ if (Data != NULL) {\r
+ FreePool (Data);\r
}\r
- } else {\r
//\r
- // Use the NvMapOverride.\r
+ // Directly return when meet with error\r
//\r
- DataSize = BufferStorage->Size;\r
- Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);\r
- \r
- if (Data != NULL) {\r
- Status = EFI_SUCCESS;\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
+ //\r
+ // Merge result into the final results.\r
+ //\r
+ if (FinalResults == NULL) {\r
+ FinalResults = SingleResult;\r
+ SingleResult = NULL;\r
} else {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ Size = StrLen (FinalResults);\r
+ Size = Size + 1;\r
+ Size = Size + StrLen (SingleResult) + 1;\r
+ StrPointer = AllocateZeroPool (Size * sizeof (CHAR16));\r
+ ASSERT (StrPointer != NULL);\r
+ StrCpy (StrPointer, FinalResults);\r
+ FreePool (FinalResults);\r
+ FinalResults = StrPointer;\r
+ StrPointer = StrPointer + StrLen (StrPointer);\r
+ *StrPointer = L'&';\r
+ StrCpy (StrPointer + 1, SingleResult);\r
+ FreePool (SingleResult);\r
}\r
- }\r
- \r
+ } while (Request == NULL);\r
+\r
if (!EFI_ERROR (Status)) {\r
- Status = mHiiConfigRoutingProtocol->BlockToConfig (\r
- mHiiConfigRoutingProtocol,\r
- Request,\r
- Data,\r
- DataSize,\r
- Results,\r
- Progress\r
- );\r
+ *Results = FinalResults;\r
+ } else {\r
+ if (FinalResults != NULL) {\r
+ FreePool (FinalResults);\r
+ }\r
}\r
-\r
- if (Data != NULL) {\r
- FreePool (Data);\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
}\r
+\r
return Status;\r
}\r
\r
UefiLib\r
PcdLib\r
LanguageLib\r
+ PrintLib\r
\r
[Guids]\r
gEfiIfrTianoGuid\r
#include <Library/UefiLib.h>\r
#include <Library/PcdLib.h>\r
#include <Library/LanguageLib.h>\r
+#include <Library/PrintLib.h>\r
\r
#include <Guid/MdeModuleHii.h>\r
\r
/** @file\r
The functions for Boot Maintainence Main menu.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation. <BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. <BR>\r
All rights reserved. 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
EFI_STATUS Status;\r
UINTN BufferSize;\r
BMM_CALLBACK_DATA *Private;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
\r
- if (Request == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
+ *Progress = Request;\r
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mBootMaintGuid, mBootMaintStorageName)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ AllocatedRequest = FALSE;\r
+ Size = 0;\r
+\r
+ Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
//\r
BufferSize = sizeof (BMM_FAKE_NV_DATA);\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mBootMaintGuid, mBootMaintStorageName, Private->BmmDriverHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
+\r
Status = gHiiConfigRouting->BlockToConfig (\r
gHiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) &Private->BmmFakeNvData,\r
BufferSize,\r
Results,\r
Progress\r
);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+\r
return Status;\r
}\r
\r
\r
@retval EFI_SUCCESS The Results is filled with the requested values.\r
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
- @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r
+ @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
\r
**/\r
OUT EFI_STRING *Results\r
)\r
{\r
- if (Request == NULL || Progress == NULL || Results == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
*Progress = Request;\r
EFI_IFR_GUID_LABEL *StartLabel;\r
EFI_IFR_GUID_LABEL *EndLabel;\r
BOOLEAN FirstFlag;\r
+ EFI_STRING_ID Temp;\r
\r
if (InitializeHiiData) {\r
//\r
GetNextLanguage (&LangCode, Lang);\r
OptionCount ++;\r
}\r
- gFrontPagePrivate.LanguageToken = AllocatePool (OptionCount * sizeof (EFI_STRING_ID));\r
+ gFrontPagePrivate.LanguageToken = AllocatePool ((OptionCount + 1) * sizeof (EFI_STRING_ID));\r
ASSERT (gFrontPagePrivate.LanguageToken != NULL);\r
FirstFlag = TRUE;\r
}\r
\r
+ Status = gHiiString->NewString (gHiiString, HiiHandle, &Temp, "de-DE", L"Dedede", L"TEST", NULL);\r
+\r
OptionCount = 0;\r
LangCode = LanguageString;\r
while (*LangCode != 0) {\r
This is an example of how a driver might export data to the HII protocol to be\r
later utilized by the Setup Protocol\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation\r
+Copyright (c) 2004 - 2010, Intel Corporation\r
All rights reserved. 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
UINTN ValueStrLen;\r
CHAR16 BackupChar;\r
CHAR16 *StrPointer;\r
+ BOOLEAN AllocatedRequest;\r
\r
-\r
- if (Progress == NULL || Results == NULL || Request == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
ConfigRequest = NULL;\r
Size = 0;\r
*Progress = Request;\r
+ AllocatedRequest = FALSE;\r
\r
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r
HiiConfigRouting = PrivateData->HiiConfigRouting;\r
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
//\r
ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, VariableName, PrivateData->DriverHandle[0]);\r
- Size = (StrLen (ConfigRequest) + 32 + 1) * sizeof (CHAR16);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
ConfigRequest = AllocateZeroPool (Size);\r
+ AllocatedRequest = TRUE;\r
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
FreePool (ConfigRequestHdr);\r
} else {\r
if (!HiiIsConfigHdrMatch (Request, &mFormSetGuid, NULL)) {\r
return EFI_NOT_FOUND;\r
}\r
+ //\r
+ // Set Request to the unified request string.\r
+ //\r
ConfigRequest = Request;\r
-\r
//\r
- // Check if requesting Name/Value storage\r
+ // Check whether Request includes Request Element.\r
//\r
if (StrStr (Request, L"OFFSET") == NULL) {\r
//\r
- // Update Name/Value storage Names\r
+ // Check Request Element does exist in Reques String\r
//\r
- Status = LoadNameValueNames (PrivateData);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
+ StrPointer = StrStr (Request, L"PATH");\r
+ if (StrPointer == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
}\r
+ if (StrStr (StrPointer, L"&") == NULL) {\r
+ Size = (StrLen (Request) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", Request, (UINT64)BufferSize);\r
+ }\r
+ }\r
+ }\r
\r
- //\r
- // Allocate memory for <ConfigResp>, e.g. Name0=0x11, Name1=0x1234, Name2="ABCD"\r
- // <Request> ::=<ConfigHdr>&Name0&Name1&Name2\r
- // <ConfigResp>::=<ConfigHdr>&Name0=11&Name1=1234&Name2=0041004200430044\r
- //\r
- BufferSize = (StrLen (Request) +\r
- 1 + sizeof (PrivateData->Configuration.NameValueVar0) * 2 +\r
- 1 + sizeof (PrivateData->Configuration.NameValueVar1) * 2 +\r
- 1 + sizeof (PrivateData->Configuration.NameValueVar2) * 2 + 1) * sizeof (CHAR16);\r
- *Results = AllocateZeroPool (BufferSize);\r
- ASSERT (*Results != NULL);\r
- StrCpy (*Results, Request);\r
- Value = *Results;\r
+ //\r
+ // Check if requesting Name/Value storage\r
+ //\r
+ if (StrStr (ConfigRequest, L"OFFSET") == NULL) {\r
+ //\r
+ // Update Name/Value storage Names\r
+ //\r
+ Status = LoadNameValueNames (PrivateData);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
- //\r
- // Append value of NameValueVar0, type is UINT8\r
- //\r
- if ((Value = StrStr (*Results, PrivateData->NameValueName[0])) != NULL) {\r
- Value += StrLen (PrivateData->NameValueName[0]);\r
- ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar0) * 2) + 1);\r
- CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
-\r
- BackupChar = Value[ValueStrLen];\r
- *Value++ = L'=';\r
- Value += UnicodeValueToString (\r
- Value, \r
- PREFIX_ZERO | RADIX_HEX, \r
- PrivateData->Configuration.NameValueVar0, \r
- sizeof (PrivateData->Configuration.NameValueVar0) * 2\r
- );\r
- *Value = BackupChar;\r
- }\r
+ //\r
+ // Allocate memory for <ConfigResp>, e.g. Name0=0x11, Name1=0x1234, Name2="ABCD"\r
+ // <Request> ::=<ConfigHdr>&Name0&Name1&Name2\r
+ // <ConfigResp>::=<ConfigHdr>&Name0=11&Name1=1234&Name2=0041004200430044\r
+ //\r
+ BufferSize = (StrLen (ConfigRequest) +\r
+ 1 + sizeof (PrivateData->Configuration.NameValueVar0) * 2 +\r
+ 1 + sizeof (PrivateData->Configuration.NameValueVar1) * 2 +\r
+ 1 + sizeof (PrivateData->Configuration.NameValueVar2) * 2 + 1) * sizeof (CHAR16);\r
+ *Results = AllocateZeroPool (BufferSize);\r
+ ASSERT (*Results != NULL);\r
+ StrCpy (*Results, ConfigRequest);\r
+ Value = *Results;\r
\r
- //\r
- // Append value of NameValueVar1, type is UINT16\r
- //\r
- if ((Value = StrStr (*Results, PrivateData->NameValueName[1])) != NULL) {\r
- Value += StrLen (PrivateData->NameValueName[1]);\r
- ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar1) * 2) + 1);\r
- CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
-\r
- BackupChar = Value[ValueStrLen];\r
- *Value++ = L'=';\r
- Value += UnicodeValueToString (\r
- Value, \r
- PREFIX_ZERO | RADIX_HEX, \r
- PrivateData->Configuration.NameValueVar1, \r
- sizeof (PrivateData->Configuration.NameValueVar1) * 2\r
- );\r
- *Value = BackupChar;\r
- }\r
+ //\r
+ // Append value of NameValueVar0, type is UINT8\r
+ //\r
+ if ((Value = StrStr (*Results, PrivateData->NameValueName[0])) != NULL) {\r
+ Value += StrLen (PrivateData->NameValueName[0]);\r
+ ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar0) * 2) + 1);\r
+ CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
+\r
+ BackupChar = Value[ValueStrLen];\r
+ *Value++ = L'=';\r
+ Value += UnicodeValueToString (\r
+ Value, \r
+ PREFIX_ZERO | RADIX_HEX, \r
+ PrivateData->Configuration.NameValueVar0, \r
+ sizeof (PrivateData->Configuration.NameValueVar0) * 2\r
+ );\r
+ *Value = BackupChar;\r
+ }\r
+\r
+ //\r
+ // Append value of NameValueVar1, type is UINT16\r
+ //\r
+ if ((Value = StrStr (*Results, PrivateData->NameValueName[1])) != NULL) {\r
+ Value += StrLen (PrivateData->NameValueName[1]);\r
+ ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar1) * 2) + 1);\r
+ CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
+\r
+ BackupChar = Value[ValueStrLen];\r
+ *Value++ = L'=';\r
+ Value += UnicodeValueToString (\r
+ Value, \r
+ PREFIX_ZERO | RADIX_HEX, \r
+ PrivateData->Configuration.NameValueVar1, \r
+ sizeof (PrivateData->Configuration.NameValueVar1) * 2\r
+ );\r
+ *Value = BackupChar;\r
+ }\r
+\r
+ //\r
+ // Append value of NameValueVar2, type is CHAR16 *\r
+ //\r
+ if ((Value = StrStr (*Results, PrivateData->NameValueName[2])) != NULL) {\r
+ Value += StrLen (PrivateData->NameValueName[2]);\r
+ ValueStrLen = StrLen (PrivateData->Configuration.NameValueVar2) * 4 + 1;\r
+ CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
\r
+ *Value++ = L'=';\r
//\r
- // Append value of NameValueVar2, type is CHAR16 *\r
+ // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"\r
//\r
- if ((Value = StrStr (*Results, PrivateData->NameValueName[2])) != NULL) {\r
- Value += StrLen (PrivateData->NameValueName[2]);\r
- ValueStrLen = StrLen (PrivateData->Configuration.NameValueVar2) * 4 + 1;\r
- CopyMem (Value + ValueStrLen, Value, StrSize (Value));\r
-\r
- *Value++ = L'=';\r
- //\r
- // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"\r
- //\r
- StrPointer = (CHAR16 *) PrivateData->Configuration.NameValueVar2;\r
- for (; *StrPointer != L'\0'; StrPointer++) {\r
- Value += UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *StrPointer, 4);\r
- }\r
+ StrPointer = (CHAR16 *) PrivateData->Configuration.NameValueVar2;\r
+ for (; *StrPointer != L'\0'; StrPointer++) {\r
+ Value += UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *StrPointer, 4);\r
}\r
-\r
- Progress = (EFI_STRING *) Request + StrLen (Request);\r
- return EFI_SUCCESS;\r
}\r
+ \r
+ Status = EFI_SUCCESS;\r
+ } else {\r
+ //\r
+ // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ //\r
+ Status = HiiConfigRouting->BlockToConfig (\r
+ HiiConfigRouting,\r
+ ConfigRequest,\r
+ (UINT8 *) &PrivateData->Configuration,\r
+ BufferSize,\r
+ Results,\r
+ Progress\r
+ );\r
}\r
\r
//\r
- // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ // Free the allocated config request string.\r
//\r
- Status = HiiConfigRouting->BlockToConfig (\r
- HiiConfigRouting,\r
- ConfigRequest,\r
- (UINT8 *) &PrivateData->Configuration,\r
- BufferSize,\r
- Results,\r
- Progress\r
- );\r
-\r
- if (Request == NULL) {\r
+ if (AllocatedRequest) {\r
FreePool (ConfigRequest);\r
+ }\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
*Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
}\r
\r
return Status;\r
/** @file\r
Helper functions for configuring or getting the parameters relating to iSCSI.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation.<BR>\r
All rights reserved. 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
ISCSI_CONFIG_IFR_NVDATA *IfrNvData;\r
ISCSI_FORM_CALLBACK_INFO *Private;\r
EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
\r
- if (Request == NULL || Progress == NULL || Results == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
+\r
*Progress = Request;\r
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mVendorGuid, mVendorStorageName)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ AllocatedRequest = FALSE;\r
+ Size = 0;\r
\r
if (!mIScsiDeviceListUpdated) {\r
//\r
//\r
HiiConfigRouting = Private->ConfigRouting;\r
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mVendorGuid, mVendorStorageName, Private->DriverHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
Status = HiiConfigRouting->BlockToConfig (\r
HiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) IfrNvData,\r
BufferSize,\r
Results,\r
Progress\r
);\r
FreePool (IfrNvData);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+\r
return Status;\r
}\r
\r
NIC_IP4_CONFIG_INFO *IfrDeviceNvData;\r
IP4_CONFIG_INSTANCE *Ip4ConfigInstance;\r
IP4_CONFIG_IFR_NVDATA *IfrFormNvData;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ EFI_STRING DeviceResult;\r
+ EFI_STRING FormResult;\r
+ CHAR16 *StrPointer;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
+ UINTN BufferSize;\r
\r
- if (Request == NULL || Progress == NULL || Results == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- *Progress = Request;\r
-\r
+ *Progress = Request;\r
+ Size = 0;\r
+ DeviceResult = NULL;\r
+ FormResult = NULL;\r
+ ConfigRequest = NULL;\r
+ Status = EFI_SUCCESS;\r
+ AllocatedRequest = FALSE;\r
Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This);\r
\r
//\r
// Check Request data in <ConfigHdr>.\r
//\r
- if (HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
if (IfrDeviceNvData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
return EFI_NOT_FOUND;\r
}\r
\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ BufferSize = NIC_ITEM_CONFIG_SIZE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
+\r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
//\r
Status = gHiiConfigRouting->BlockToConfig (\r
gHiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) IfrDeviceNvData,\r
NIC_ITEM_CONFIG_SIZE,\r
- Results,\r
+ &DeviceResult,\r
Progress\r
);\r
\r
FreePool (IfrDeviceNvData);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
\r
- } else if (HiiIsConfigHdrMatch (Request, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ if (EFI_ERROR (Status)) {\r
+ goto Failure;\r
+ }\r
+ } \r
+ \r
+ if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
\r
IfrFormNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
if (IfrFormNvData == NULL) {\r
\r
Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData);\r
\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ BufferSize = sizeof (IP4_CONFIG_IFR_NVDATA);\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
+ \r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
//\r
Status = gHiiConfigRouting->BlockToConfig (\r
gHiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) IfrFormNvData,\r
sizeof (IP4_CONFIG_IFR_NVDATA),\r
- Results,\r
+ &FormResult,\r
Progress\r
);\r
\r
FreePool (IfrFormNvData);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto Failure;\r
+ }\r
+ }\r
\r
+ if (Request == NULL) {\r
+ Size = StrLen (DeviceResult);\r
+ Size = Size + 1;\r
+ Size = Size + StrLen (FormResult) + 1;\r
+ *Results = AllocateZeroPool (Size * sizeof (CHAR16));\r
+ ASSERT (*Results != NULL);\r
+ StrPointer = *Results;\r
+ StrCpy (StrPointer, DeviceResult);\r
+ StrPointer = StrPointer + StrLen (StrPointer);\r
+ *StrPointer = L'&';\r
+ StrCpy (StrPointer + 1, FormResult);\r
+ FreePool (DeviceResult);\r
+ FreePool (FormResult);\r
+ } else if (HiiIsConfigHdrMatch (ConfigRequest, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ *Results = DeviceResult;\r
+ } else if (HiiIsConfigHdrMatch (ConfigRequest, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ *Results = FormResult;\r
} else {\r
return EFI_NOT_FOUND;\r
}\r
\r
-\r
+Failure:\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+ \r
return Status;\r
}\r
\r
OUT EFI_STRING *Results\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN BufferSize;\r
- VLAN_CONFIGURATION Configuration;\r
+ EFI_STATUS Status;\r
+ UINTN BufferSize;\r
+ VLAN_CONFIGURATION Configuration;\r
+ VLAN_CONFIG_PRIVATE_DATA *PrivateData;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
\r
- if (Request == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ *Progress = Request;\r
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mVlanFormSetGuid, mVlanStorageName)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ AllocatedRequest = FALSE;\r
+ Size = 0;\r
+\r
//\r
// Retrieve the pointer to the UEFI HII Config Routing Protocol\r
//\r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
//\r
+ PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION));\r
BufferSize = sizeof (VLAN_CONFIG_PRIVATE_DATA);\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mVlanFormSetGuid, mVlanStorageName, PrivateData->DriverHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
+\r
Status = mHiiConfigRouting->BlockToConfig (\r
mHiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) &Configuration,\r
BufferSize,\r
Results,\r
Progress\r
);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+\r
return Status;\r
}\r
\r
4. It save all the mapping info in NV variables which will be consumed\r
by platform override protocol driver to publish the platform override protocol.\r
\r
-Copyright (c) 2007 - 2009, Intel Corporation\r
+Copyright (c) 2007 - 2010, Intel Corporation\r
All rights reserved. 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
EFI_STATUS Status;\r
EFI_CALLBACK_INFO *Private;\r
EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
+ UINTN BufferSize;\r
\r
- if (Progress == NULL || Results == NULL || Request == NULL) {\r
+ if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- *Progress = Request;\r
+\r
+ *Progress = Request;\r
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mPlatformOverridesManagerGuid, mVariableName)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ Size = 0;\r
+ AllocatedRequest = FALSE;\r
+\r
Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
HiiConfigRouting = Private->HiiConfigRouting;\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mPlatformOverridesManagerGuid, mVariableName, Private->DriverHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ BufferSize = sizeof (PLAT_OVER_MNGR_DATA);\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
\r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
//\r
Status = HiiConfigRouting->BlockToConfig (\r
HiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) &Private->FakeNvData,\r
sizeof (PLAT_OVER_MNGR_DATA),\r
Results,\r
Progress\r
);\r
+\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+\r
return Status;\r
}\r
\r