diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-16 10:53:22 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-16 10:53:22 +0000 |
commit | 94f3aae730d22aa46dd589f2c8e1ac870204b4b7 (patch) | |
tree | eca91923d195d8df96519b2ee21c5f9440357f27 /MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | |
parent | d9a1844ed39a9ccea94e3526e1fad332c8bd96ff (diff) | |
download | edk2-platforms-94f3aae730d22aa46dd589f2c8e1ac870204b4b7.tar.xz |
Update the browser logic, make the storage as browser level instead of form set level.
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14280 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/SetupBrowserDxe/Setup.c')
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 231 |
1 files changed, 47 insertions, 184 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 6c019f0454..b077a3c0a0 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -38,6 +38,7 @@ UINTN gBrowserContextCount = 0; LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList);
LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFormSetList);
LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList);
+LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList);
BANNER_DATA *gBannerData;
EFI_HII_HANDLE gFrontPageHandle;
@@ -475,9 +476,9 @@ BrowserCallback ( Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
- if (CompareGuid (&Storage->Guid, (EFI_GUID *) VariableGuid)) {
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
- Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ if (CompareGuid (&Storage->BrowserStorage->Guid, (EFI_GUID *) VariableGuid)) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
+ Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
//
// Buffer storage require both GUID and Name
//
@@ -485,7 +486,7 @@ BrowserCallback ( return EFI_NOT_FOUND;
}
- if (StrCmp (Storage->Name, (CHAR16 *) VariableName) != 0) {
+ if (StrCmp (Storage->BrowserStorage->Name, (CHAR16 *) VariableName) != 0) {
continue;
}
}
@@ -515,7 +516,7 @@ BrowserCallback ( //
// Generate <ConfigResp>
//
- Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
+ Status = StorageToConfigResp (Storage->BrowserStorage, &ConfigResp, Storage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -523,7 +524,7 @@ BrowserCallback ( //
// Skip <ConfigHdr> and '&' to point to <ConfigBody>
//
- StrPtr = ConfigResp + StrLen (Storage->ConfigHdr) + 1;
+ StrPtr = ConfigResp + StrLen (Storage->BrowserStorage->ConfigHdr) + 1;
BufferSize = StrSize (StrPtr);
if (*ResultsDataSize < BufferSize) {
@@ -542,18 +543,18 @@ BrowserCallback ( // Prepare <ConfigResp>
//
TmpSize = StrLen (ResultsData);
- BufferSize = (TmpSize + StrLen (Storage->ConfigHdr) + 2) * sizeof (CHAR16);
+ BufferSize = (TmpSize + StrLen (Storage->BrowserStorage->ConfigHdr) + 2) * sizeof (CHAR16);
ConfigResp = AllocateZeroPool (BufferSize);
ASSERT (ConfigResp != NULL);
- StrCpy (ConfigResp, Storage->ConfigHdr);
+ StrCpy (ConfigResp, Storage->BrowserStorage->ConfigHdr);
StrCat (ConfigResp, L"&");
StrCat (ConfigResp, ResultsData);
//
// Update Browser uncommited data
//
- Status = ConfigRespToStorage (Storage, ConfigResp);
+ Status = ConfigRespToStorage (Storage->BrowserStorage, ConfigResp);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -826,7 +827,7 @@ NewStringCat ( **/
VOID
SynchronizeStorage (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN BOOLEAN SyncOrRestore
)
{
@@ -879,7 +880,7 @@ SynchronizeStorage ( **/
EFI_STATUS
GetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
@@ -928,7 +929,7 @@ GetValueByName ( **/
EFI_STATUS
SetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN CHAR16 *Value,
IN GET_SET_QUESTION_VALUE_WITH SetValueTo
@@ -975,9 +976,9 @@ SetValueByName ( /**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
- @param Buffer The Storage to be conveted.
+ @param Storage The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
- @param SingleForm Whether update data for single form or formset level.
+ @param ConfigRequest The ConfigRequest string.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
@@ -985,28 +986,17 @@ SetValueByName ( **/
EFI_STATUS
StorageToConfigResp (
- IN VOID *Buffer,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 **ConfigResp,
- IN BOOLEAN SingleForm
+ IN CHAR16 *ConfigRequest
)
{
- EFI_STATUS Status;
- EFI_STRING Progress;
+ EFI_STATUS Status;
+ EFI_STRING Progress;
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
- CHAR16 *ConfigRequest;
- FORMSET_STORAGE *Storage;
- FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
Status = EFI_SUCCESS;
- if (SingleForm) {
- ConfigInfo = (FORM_BROWSER_CONFIG_REQUEST *) Buffer;
- Storage = ConfigInfo->Storage;
- ConfigRequest = ConfigInfo->ConfigRequest;
- } else {
- Storage = (FORMSET_STORAGE *) Buffer;
- ConfigRequest = Storage->ConfigRequest;
- }
switch (Storage->Type) {
case EFI_HII_VARSTORE_BUFFER:
@@ -1061,7 +1051,7 @@ StorageToConfigResp ( **/
EFI_STATUS
ConfigRespToStorage (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *ConfigResp
)
{
@@ -1153,7 +1143,7 @@ GetQuestionValue ( UINT8 *Dst;
UINTN StorageWidth;
EFI_TIME EfiTime;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
@@ -1578,7 +1568,7 @@ SetQuestionValue ( EFI_TIME EfiTime;
UINTN BufferLen;
UINTN StorageWidth;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigResp;
CHAR16 *Progress;
@@ -2304,7 +2294,7 @@ DiscardForm ( Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
continue;
}
@@ -2315,7 +2305,7 @@ DiscardForm ( continue;
}
- SynchronizeStorage(Storage, FALSE);
+ SynchronizeStorage(Storage->BrowserStorage, FALSE);
}
Link = GetFirstNode (&FormSet->FormListHead);
@@ -2381,7 +2371,8 @@ SubmitForm ( LIST_ENTRY *Link;
EFI_STRING ConfigResp;
EFI_STRING Progress;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormSetStorage;
UINTN BufferSize;
UINT8 *TmpBuf;
FORM_BROWSER_FORMSET *LocalFormSet;
@@ -2429,7 +2420,7 @@ SubmitForm ( //
// 1. Prepare <ConfigResp>
//
- Status = StorageToConfigResp (ConfigInfo, &ConfigResp, TRUE);
+ Status = StorageToConfigResp (ConfigInfo->Storage, &ConfigResp, ConfigInfo->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2518,7 +2509,8 @@ SubmitForm ( //
Link = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, Link)) {
- Storage = FORMSET_STORAGE_FROM_LINK (Link);
+ FormSetStorage = (FORMSET_STORAGE_FROM_LINK (Link));
+ Storage = FormSetStorage->BrowserStorage;
Link = GetNextNode (&FormSet->StorageListHead, Link);
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
@@ -2528,14 +2520,14 @@ SubmitForm ( //
// Skip if there is no RequestElement
//
- if (Storage->ElementCount == 0) {
+ if (FormSetStorage->ElementCount == 0) {
continue;
}
//
// 1. Prepare <ConfigResp>
//
- Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
+ Status = StorageToConfigResp (Storage, &ConfigResp, FormSetStorage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2663,7 +2655,7 @@ GetDefaultValueFromAltCfg ( BOOLEAN IsBufferStorage;
BOOLEAN IsString;
UINTN Length;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
CHAR16 *Result;
@@ -3151,7 +3143,7 @@ ExtractDefault ( IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
- IN FORMSET_STORAGE *Storage OPTIONAL,
+ IN BROWSER_STORAGE *Storage OPTIONAL,
IN BOOLEAN RetrieveValueFirst
)
{
@@ -3464,17 +3456,17 @@ LoadStorage ( EFI_STRING Result;
CHAR16 *StrPtr;
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
return EFI_SUCCESS;
}
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
Status = gRT->GetVariable (
- Storage->Name,
- &Storage->Guid,
+ Storage->BrowserStorage->Name,
+ &Storage->BrowserStorage->Guid,
NULL,
- (UINTN*)&Storage->Size,
- Storage->EditBuffer
+ (UINTN*)&Storage->BrowserStorage->Size,
+ Storage->BrowserStorage->EditBuffer
);
return Status;
}
@@ -3511,136 +3503,11 @@ LoadStorage ( *StrPtr = L'\0';
}
- Status = ConfigRespToStorage (Storage, Result);
+ Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
FreePool (Result);
return Status;
}
-
-/**
- Copy uncommitted data from source Storage to destination Storage.
-
- @param Dst Target Storage for uncommitted data.
- @param Src Source Storage for uncommitted data.
-
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type.
-
-**/
-EFI_STATUS
-CopyStorage (
- IN OUT FORMSET_STORAGE *Dst,
- IN FORMSET_STORAGE *Src
- )
-{
- LIST_ENTRY *Link;
- NAME_VALUE_NODE *Node;
-
- if ((Dst->Type != Src->Type) || (Dst->Size != Src->Size)) {
- return EFI_INVALID_PARAMETER;
- }
-
- switch (Src->Type) {
- case EFI_HII_VARSTORE_BUFFER:
- case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
- CopyMem (Dst->EditBuffer, Src->EditBuffer, Src->Size);
- CopyMem (Dst->Buffer, Src->Buffer, Src->Size);
- break;
-
- case EFI_HII_VARSTORE_NAME_VALUE:
- Link = GetFirstNode (&Src->NameValueListHead);
- while (!IsNull (&Src->NameValueListHead, Link)) {
- Node = NAME_VALUE_NODE_FROM_LINK (Link);
-
- SetValueByName (Dst, Node->Name, Node->EditValue, GetSetValueWithEditBuffer);
- SetValueByName (Dst, Node->Name, Node->Value, GetSetValueWithBuffer);
-
- Link = GetNextNode (&Src->NameValueListHead, Link);
- }
- break;
-
- case EFI_HII_VARSTORE_EFI_VARIABLE:
- default:
- break;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Get old question value from the saved formset.
-
- @param Statement The question which need to get old question value.
- @param OldFormSet FormSet data structure saved in the list.
-
-**/
-VOID
-GetOldQuestionValue (
- IN OUT FORM_BROWSER_STATEMENT *Statement,
- IN FORM_BROWSER_FORMSET *OldFormSet
- )
-{
- LIST_ENTRY *FormLink;
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
- FORM_BROWSER_FORM *Form;
-
- FormLink = GetFirstNode (&OldFormSet->FormListHead);
- while (!IsNull (&OldFormSet->FormListHead, FormLink)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
- FormLink = GetNextNode (&OldFormSet->FormListHead, FormLink);
-
- Link = GetFirstNode (&Form->StatementListHead);
- while (!IsNull (&Form->StatementListHead, Link)) {
- Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&Form->StatementListHead, Link);
-
- if (Question->QuestionId != Statement->QuestionId) {
- continue;
- }
-
- CopyMem (&Statement->HiiValue, &Question->HiiValue, sizeof (EFI_HII_VALUE));
- return;
- }
- }
-}
-
-/**
- Get old question value from the saved formset, all these questions not have
- storage.
-
- @param FormSet FormSet data structure which is used now.
- @param OldFormSet FormSet data structure saved in the list.
-
-**/
-VOID
-CopyOldValueForNoStorageQst (
- IN OUT FORM_BROWSER_FORMSET *FormSet,
- IN FORM_BROWSER_FORMSET *OldFormSet
- )
-{
- LIST_ENTRY *FormLink;
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
- FORM_BROWSER_FORM *Form;
-
- FormLink = GetFirstNode (&FormSet->FormListHead);
- while (!IsNull (&FormSet->FormListHead, FormLink)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
- FormLink = GetNextNode (&FormSet->FormListHead, FormLink);
-
- Link = GetFirstNode (&Form->StatementListHead);
- while (!IsNull (&Form->StatementListHead, Link)) {
- Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&Form->StatementListHead, Link);
-
- if (Question->Storage == NULL) {
- GetOldQuestionValue (Question, OldFormSet);
- }
- }
- }
-}
-
/**
Get current setting of Questions.
@@ -3693,17 +3560,18 @@ InitializeCurrentSetting ( }
}
- if (OldStorage == NULL) {
- //
- // Storage is not found in backup formset, request it from ConfigDriver
- //
+ //
+ // Storage is not found in backup formset and current global storage not has other driver used,
+ // request it from ConfigDriver
+ //
+ if (OldStorage == NULL && Storage->BrowserStorage->ReferenceCount == 1) {
Status = LoadStorage (FormSet, Storage);
if (EFI_ERROR (Status)) {
//
// If get last time changed value failed, extract default from IFR binary
//
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE);
//
// ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag
// in current situation.
@@ -3715,12 +3583,7 @@ InitializeCurrentSetting ( // Now Edit Buffer is filled with default values(lower priority) or current
// settings(higher priority), sychronize it to shadow Buffer
//
- SynchronizeStorage (Storage, TRUE);
- } else {
- //
- // Storage found in backup formset, use it
- //
- Status = CopyStorage (Storage, OldStorage);
+ SynchronizeStorage (Storage->BrowserStorage, TRUE);
}
Link = GetNextNode (&FormSet->StorageListHead, Link);
|