From 27c304f442538e3aeb1bcc5a6e52194a577dcde0 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Tue, 18 Feb 2014 10:53:57 +0000 Subject: Update configrequest string at runtime for dynamic created question. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15247 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/Presentation.c | 64 ---------------------- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 52 +++++++++++------- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 13 ----- 3 files changed, 32 insertions(+), 97 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 5ca0700bb2..488087e011 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1957,70 +1957,6 @@ IsNvUpdateRequiredForForm ( return FALSE; } -/** - Check whether the storage data for current form set is changed. - - @param FormSet FormSet data structure. - - @retval TRUE Data is changed. - @retval FALSE Data is not changed. -**/ -BOOLEAN -IsStorageDataChangedForFormSet ( - IN FORM_BROWSER_FORMSET *FormSet - ) -{ - LIST_ENTRY *Link; - FORMSET_STORAGE *Storage; - BROWSER_STORAGE *BrowserStorage; - CHAR16 *ConfigRespNew; - CHAR16 *ConfigRespOld; - BOOLEAN RetVal; - - RetVal = FALSE; - ConfigRespNew = NULL; - ConfigRespOld = NULL; - - // - // Request current settings from Configuration Driver - // - Link = GetFirstNode (&FormSet->StorageListHead); - while (!IsNull (&FormSet->StorageListHead, Link)) { - Storage = FORMSET_STORAGE_FROM_LINK (Link); - Link = GetNextNode (&FormSet->StorageListHead, Link); - - BrowserStorage = Storage->BrowserStorage; - - if (BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) { - continue; - } - - if (Storage->ElementCount == 0) { - continue; - } - - StorageToConfigResp (BrowserStorage, &ConfigRespNew, Storage->ConfigRequest, TRUE); - StorageToConfigResp (BrowserStorage, &ConfigRespOld, Storage->ConfigRequest, FALSE); - ASSERT (ConfigRespNew != NULL && ConfigRespOld != NULL); - - if (StrCmp (ConfigRespNew, ConfigRespOld) != 0) { - RetVal = TRUE; - } - - FreePool (ConfigRespNew); - ConfigRespNew = NULL; - - FreePool (ConfigRespOld); - ConfigRespOld = NULL; - - if (RetVal) { - break; - } - } - - return RetVal; -} - /** Find menu which will show next time. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index d1c6961a05..5ce0b84ed6 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -417,7 +417,7 @@ SendForm ( // // If no data is changed, don't need to save current FormSet into the maintain list. // - if (!IsNvUpdateRequiredForFormSet (FormSet) && !IsStorageDataChangedForFormSet(FormSet)) { + if (!IsNvUpdateRequiredForFormSet (FormSet)) { CleanBrowserStorage(FormSet); RemoveEntryList (&FormSet->Link); DestroyFormSet (FormSet); @@ -4081,39 +4081,51 @@ LoadStorage ( ConfigRequestAdjust(Storage); return; } - - // - // Create the config request string to get all fields for this storage. - // Allocate and fill a buffer large enough to hold the template - // followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator - // - StrLen = StrSize (Storage->BrowserStorage->ConfigHdr) + 20 * sizeof (CHAR16); - ConfigRequest = AllocateZeroPool (StrLen); - ASSERT (ConfigRequest != NULL); - UnicodeSPrint ( - ConfigRequest, - StrLen, - L"%s&OFFSET=0&WIDTH=%04x", - Storage->BrowserStorage->ConfigHdr, - Storage->BrowserStorage->Size); break; case EFI_HII_VARSTORE_BUFFER: case EFI_HII_VARSTORE_NAME_VALUE: // - // Skip if there is no RequestElement or data has initilized. + // Skip if there is no RequestElement. // - if (Storage->ElementCount == 0 || Storage->BrowserStorage->Initialized) { + if (Storage->ElementCount == 0) { return; } + + // + // Just update the ConfigRequest, if storage already initialized. + // + if (Storage->BrowserStorage->Initialized) { + ConfigRequestAdjust(Storage); + return; + } + Storage->BrowserStorage->Initialized = TRUE; - ConfigRequest = Storage->ConfigRequest; break; default: return; } + if (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE) { + // + // Create the config request string to get all fields for this storage. + // Allocate and fill a buffer large enough to hold the template + // followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator + // + StrLen = StrSize (Storage->BrowserStorage->ConfigHdr) + 20 * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (StrLen); + ASSERT (ConfigRequest != NULL); + UnicodeSPrint ( + ConfigRequest, + StrLen, + L"%s&OFFSET=0&WIDTH=%04x", + Storage->BrowserStorage->ConfigHdr, + Storage->BrowserStorage->Size); + } else { + ConfigRequest = Storage->ConfigRequest; + } + // // Request current settings from Configuration Driver // @@ -4149,7 +4161,7 @@ LoadStorage ( // SynchronizeStorage(FormSet, Storage->BrowserStorage, NULL, TRUE); - if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { + if (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE) { if (ConfigRequest != NULL) { FreePool (ConfigRequest); } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 8fe9e98e63..cfbe348d61 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -1172,19 +1172,6 @@ IsNvUpdateRequiredForFormSet ( IN FORM_BROWSER_FORMSET *FormSet ); -/** - Check whether the storage data for current form set is changed. - - @param FormSet FormSet data structure. - - @retval TRUE Data is changed. - @retval FALSE Data is not changed. -**/ -BOOLEAN -IsStorageDataChangedForFormSet ( - IN FORM_BROWSER_FORMSET *FormSet - ); - /** Call the call back function for the question and process the return action. -- cgit v1.2.3