summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2014-04-08 06:17:33 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2014-04-08 06:17:33 +0000
commit9d34cac819eb5b36bf28728ef6f65d6e0439dac2 (patch)
treee296c5ce582845bfc9ddca01739a706dca8bdcba
parentad43bc6b2e3507187f48e21aa6fc95f4cee222f3 (diff)
downloadedk2-platforms-9d34cac819eb5b36bf28728ef6f65d6e0439dac2.tar.xz
Refine the load form sets process for BrowserCallback function.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming, Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15434 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c94
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h19
2 files changed, 68 insertions, 45 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index f86f369ff2..a456a2b21d 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -608,14 +608,6 @@ BrowserCallback (
Found = FALSE;
Status = EFI_SUCCESS;
- //
- // If set browser data, pre load all hii formset to avoid set the varstore which is not
- // saved in browser.
- //
- if (!RetrieveData && (gBrowserSettingScope == SystemLevel)) {
- LoadAllHiiFormset();
- }
-
if (VariableGuid != NULL) {
//
// Try to find target storage in the current formset.
@@ -661,6 +653,10 @@ BrowserCallback (
return Status;
}
+ if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ ConfigRequestAdjust (Storage, ResultsData, TRUE);
+ }
+
//
// Different formsets may have same varstore, so here just set the flag
// not exit the circle.
@@ -3707,7 +3703,6 @@ CleanBrowserStorage (
{
LIST_ENTRY *Link;
FORMSET_STORAGE *Storage;
- CHAR16 *ConfigRequest;
Link = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, Link)) {
@@ -3719,8 +3714,7 @@ CleanBrowserStorage (
continue;
}
- ConfigRequest = FormSet->QuestionInited ? Storage->ConfigRequest : Storage->ConfigElements;
- RemoveConfigRequest (Storage->BrowserStorage, ConfigRequest);
+ RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest);
} else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
if (Storage->BrowserStorage->ConfigRequest != NULL) {
@@ -3799,6 +3793,8 @@ AppendConfigRequest (
Adjust the config request info, remove the request elements which already in AllConfigRequest string.
@param Storage Form set Storage.
+ @param Request The input request string.
+ @param RespString Whether the input is ConfigRequest or ConfigResp format.
@retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
@retval FALSE All elements covered by current used elements.
@@ -3806,30 +3802,37 @@ AppendConfigRequest (
**/
BOOLEAN
ConfigRequestAdjust (
- IN FORMSET_STORAGE *Storage
+ IN BROWSER_STORAGE *Storage,
+ IN CHAR16 *Request,
+ IN BOOLEAN RespString
)
{
CHAR16 *RequestElement;
CHAR16 *NextRequestElement;
- CHAR16 *RetBuf;
+ CHAR16 *NextElementBakup;
UINTN SpareBufLen;
CHAR16 *SearchKey;
+ CHAR16 *ValueKey;
BOOLEAN RetVal;
+ CHAR16 *ConfigRequest;
SpareBufLen = 0;
- RetBuf = NULL;
RetVal = FALSE;
+ NextElementBakup = NULL;
+ ValueKey = NULL;
- if (Storage->BrowserStorage->ConfigRequest == NULL) {
- Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
- if (Storage->ConfigElements != NULL) {
- FreePool (Storage->ConfigElements);
- }
- Storage->ConfigElements = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
+ if (Request != NULL) {
+ ConfigRequest = Request;
+ } else {
+ ConfigRequest = Storage->ConfigRequest;
+ }
+
+ if (Storage->ConfigRequest == NULL) {
+ Storage->ConfigRequest = AllocateCopyPool (StrSize (ConfigRequest), ConfigRequest);
return TRUE;
}
- if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
//
// "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
//
@@ -3839,26 +3842,22 @@ ConfigRequestAdjust (
// "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
//
SearchKey = L"&OFFSET";
+ ValueKey = L"&VALUE";
}
//
- // Prepare the config header.
- //
- RetBuf = AllocateCopyPool(StrSize (Storage->BrowserStorage->ConfigHdr), Storage->BrowserStorage->ConfigHdr);
- ASSERT (RetBuf != NULL);
-
- //
// Find SearchKey storage
//
- if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
- RequestElement = StrStr (Storage->ConfigRequest, L"PATH");
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ RequestElement = StrStr (ConfigRequest, L"PATH");
ASSERT (RequestElement != NULL);
RequestElement = StrStr (RequestElement, SearchKey);
} else {
- RequestElement = StrStr (Storage->ConfigRequest, SearchKey);
+ RequestElement = StrStr (ConfigRequest, SearchKey);
}
while (RequestElement != NULL) {
+
//
// +1 to avoid find header itself.
//
@@ -3868,18 +3867,30 @@ ConfigRequestAdjust (
// The last Request element in configRequest string.
//
if (NextRequestElement != NULL) {
+ if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
+ NextElementBakup = NextRequestElement;
+ NextRequestElement = StrStr (RequestElement, ValueKey);
+ }
//
// Replace "&" with '\0'.
//
*NextRequestElement = L'\0';
+ } else {
+ if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
+ NextElementBakup = NextRequestElement;
+ NextRequestElement = StrStr (RequestElement, ValueKey);
+ //
+ // Replace "&" with '\0'.
+ //
+ *NextRequestElement = L'\0';
+ }
}
- if (!ElementValidation (Storage->BrowserStorage, RequestElement)) {
+ if (!ElementValidation (Storage, RequestElement)) {
//
// Add this element to the Storage->BrowserStorage->AllRequestElement.
//
- AppendConfigRequest(&Storage->BrowserStorage->ConfigRequest, &Storage->BrowserStorage->SpareStrLen, RequestElement);
- AppendConfigRequest (&RetBuf, &SpareBufLen, RequestElement);
+ AppendConfigRequest(&Storage->ConfigRequest, &Storage->SpareStrLen, RequestElement);
RetVal = TRUE;
}
@@ -3890,16 +3901,11 @@ ConfigRequestAdjust (
*NextRequestElement = L'&';
}
- RequestElement = NextRequestElement;
- }
-
- if (RetVal) {
- if (Storage->ConfigElements != NULL) {
- FreePool (Storage->ConfigElements);
+ if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
+ RequestElement = NextElementBakup;
+ } else {
+ RequestElement = NextRequestElement;
}
- Storage->ConfigElements = RetBuf;
- } else {
- FreePool (RetBuf);
}
return RetVal;
@@ -4082,7 +4088,7 @@ LoadStorage (
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
if (Storage->BrowserStorage->ConfigRequest != NULL) {
- ConfigRequestAdjust(Storage);
+ ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE);
return;
}
break;
@@ -4100,7 +4106,7 @@ LoadStorage (
// Just update the ConfigRequest, if storage already initialized.
//
if (Storage->BrowserStorage->Initialized) {
- ConfigRequestAdjust(Storage);
+ ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE);
return;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index cfbe348d61..50ab1fa6fd 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -169,7 +169,6 @@ typedef struct {
BROWSER_STORAGE *BrowserStorage;
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
- CHAR16 *ConfigElements;// Elements need to load initial data.
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
} FORMSET_STORAGE;
@@ -1657,4 +1656,22 @@ DevicePathToHiiHandle (
IN EFI_GUID *FormsetGuid
);
+/**
+ Adjust the config request info, remove the request elements which already in AllConfigRequest string.
+
+ @param Storage Form set Storage.
+ @param Request The input request string.
+ @param RespString Whether the input is ConfigRequest or ConfigResp format.
+
+ @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
+ @retval FALSE All elements covered by current used elements.
+
+**/
+BOOLEAN
+ConfigRequestAdjust (
+ IN BROWSER_STORAGE *Storage,
+ IN CHAR16 *Request,
+ IN BOOLEAN RespString
+ );
+
#endif