summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-21 08:23:20 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-21 08:23:20 +0000
commit9776099ffa70add6fdb289075a4f8054de594d19 (patch)
tree2c02195a3befc54c37eba53103e791ac25705a2f /MdeModulePkg
parent09c990aeb1d4def43f5f0df167f0a8b8ea659e06 (diff)
downloadedk2-platforms-9776099ffa70add6fdb289075a4f8054de594d19.tar.xz
Patch includes:
1.Enable Retrieve callback type for all questions before show these questions. 2.Enable retrieve callback type for all questions without storage when initial these questions. 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@13655 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c51
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c191
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h26
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Ui.c4
4 files changed, 213 insertions, 59 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index 6e46e0e961..b8612e8c42 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -1323,6 +1323,57 @@ ProcessCallBackFunction (
}
/**
+ Call the retrieve type call back function for one question to get the initialize data.
+
+ This function only used when in the initialize stage, because in this stage, the
+ Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
+
+ @param ConfigAccess The config access protocol produced by the hii driver.
+ @param Statement The Question which need to call.
+
+ @retval EFI_SUCCESS The call back function excutes successfully.
+ @return Other value if the call back function failed to excute.
+**/
+EFI_STATUS
+ProcessRetrieveForQuestion (
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
+ IN FORM_BROWSER_STATEMENT *Statement
+ )
+{
+ EFI_STATUS Status;
+ EFI_BROWSER_ACTION_REQUEST ActionRequest;
+ EFI_HII_VALUE *HiiValue;
+ EFI_IFR_TYPE_VALUE *TypeValue;
+
+ Status = EFI_SUCCESS;
+ ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
+
+ if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HiiValue = &Statement->HiiValue;
+ TypeValue = &HiiValue->Value;
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
+ //
+ // For OrderedList, passing in the value buffer to Callback()
+ //
+ TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;
+ }
+
+ ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
+ Status = ConfigAccess->Callback (
+ ConfigAccess,
+ EFI_BROWSER_ACTION_RETRIEVE,
+ Statement->QuestionId,
+ HiiValue->Type,
+ TypeValue,
+ &ActionRequest
+ );
+ return Status;
+}
+
+/**
The worker function that send the displays to the screen. On output,
the selection made by user is returned.
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 79829e6643..c471a232a0 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -3119,7 +3119,7 @@ GetQuestionDefault (
/**
- Reset Questions to their default value in a Form, Formset or System.
+ Reset Questions to their initial value or default value in a Form, Formset or System.
GetDefaultValueScope parameter decides which questions will reset
to its default value.
@@ -3130,6 +3130,9 @@ GetQuestionDefault (
@param SettingScope Setting Scope for Default action.
@param GetDefaultValueScope Get default value scope.
@param Storage Get default value only for this storage.
+ @param RetrieveValueFirst Whether call the retrieve call back to
+ get the initial value before get default
+ value.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_UNSUPPORTED Unsupport SettingScope.
@@ -3142,7 +3145,8 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
- IN FORMSET_STORAGE *Storage OPTIONAL
+ IN FORMSET_STORAGE *Storage OPTIONAL,
+ IN BOOLEAN RetrieveValueFirst
)
{
EFI_STATUS Status;
@@ -3155,6 +3159,8 @@ ExtractDefault (
UINTN Index;
EFI_GUID ZeroGuid;
+ Status = EFI_SUCCESS;
+
//
// Check the supported setting level.
//
@@ -3197,15 +3203,24 @@ ExtractDefault (
continue;
}
}
-
+
+ if (RetrieveValueFirst) {
+ //
+ // Call the Retrieve call back to get the initial question value.
+ //
+ Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question);
+ }
+
//
- // Reset Question to its default value
+ // If not request to get the initial value or get initial value fail, then get default value.
//
- Status = GetQuestionDefault (FormSet, Form, Question, DefaultId);
- if (EFI_ERROR (Status)) {
- continue;
+ if (!RetrieveValueFirst || EFI_ERROR (Status)) {
+ Status = GetQuestionDefault (FormSet, Form, Question, DefaultId);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
}
-
+
//
// Synchronize Buffer storage's Edit buffer
//
@@ -3222,7 +3237,7 @@ ExtractDefault (
FormLink = GetFirstNode (&FormSet->FormListHead);
while (!IsNull (&FormSet->FormListHead, FormLink)) {
Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
- ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage);
+ ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);
FormLink = GetNextNode (&FormSet->FormListHead, FormLink);
}
} else if (SettingScope == SystemLevel) {
@@ -3293,7 +3308,7 @@ ExtractDefault (
Link = GetFirstNode (&gBrowserFormSetList);
while (!IsNull (&gBrowserFormSetList, Link)) {
LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link);
- ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage);
+ ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);
Link = GetNextNode (&gBrowserFormSetList, Link);
}
}
@@ -3344,26 +3359,10 @@ LoadFormConfig (
}
//
- // According the spec, ref opcode try to get value from call back with "retrieve" type.
- //
- if ((Question->Operand == EFI_IFR_REF_OP) && (FormSet->ConfigAccess != NULL) && (Selection != NULL)) {
- Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- //
- // Check whether EfiVarstore with CallBack can be got.
+ // Call the Retrieve call back function for all questions.
//
- if ((FormSet->ConfigAccess != NULL) &&
- (Selection != NULL) &&
- (Selection->Action != UI_ACTION_REFRESH_FORMSET) &&
- (Question->QuestionId != 0) &&
- (Question->Storage != NULL) &&
- (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) &&
+ if ((FormSet->ConfigAccess != NULL) && (Selection != NULL) &&
((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {
-
//
// Check QuestionValue does exist.
//
@@ -3373,17 +3372,21 @@ LoadFormConfig (
} else {
BufferValue = (UINT8 *) &Question->HiiValue.Value;
}
- Status = gRT->GetVariable (
- Question->VariableName,
- &Question->Storage->Guid,
- NULL,
- &StorageWidth,
- BufferValue
- );
- if (!EFI_ERROR (Status)) {
- Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);
+ //
+ // For efivarstore storage, initial question value first.
+ //
+ if ((Question->Storage != NULL) && (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {
+ Status = gRT->GetVariable (
+ Question->VariableName,
+ &Question->Storage->Guid,
+ NULL,
+ &StorageWidth,
+ BufferValue
+ );
}
+
+ Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);
}
Link = GetNextNode (&Form->StatementListHead, Link);
@@ -3555,6 +3558,79 @@ CopyStorage (
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.
@@ -3579,11 +3655,6 @@ InitializeCurrentSetting (
EFI_STATUS Status;
//
- // Extract default from IFR binary for no storage questions.
- //
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL);
-
- //
// Request current settings from Configuration Driver
//
Link = GetFirstNode (&FormSet->StorageListHead);
@@ -3618,7 +3689,7 @@ InitializeCurrentSetting (
//
// If get last time changed value failed, extract default from IFR binary
//
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage);
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);
//
// ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag
// in current situation.
@@ -3645,23 +3716,33 @@ InitializeCurrentSetting (
// If has old formset, get the old nv update status.
//
if (gOldFormSet != NULL) {
- Link = GetFirstNode (&FormSet->FormListHead);
- while (!IsNull (&FormSet->FormListHead, Link)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (Link);
+ //
+ // Restore question value for questions without storage.
+ //
+ CopyOldValueForNoStorageQst (FormSet, gOldFormSet);
- Link2 = GetFirstNode (&gOldFormSet->FormListHead);
- while (!IsNull (&gOldFormSet->FormListHead, Link2)) {
- Form2 = FORM_BROWSER_FORM_FROM_LINK (Link2);
+ Link = GetFirstNode (&FormSet->FormListHead);
+ while (!IsNull (&FormSet->FormListHead, Link)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);
- if (Form->FormId == Form2->FormId) {
- Form->NvUpdateRequired = Form2->NvUpdateRequired;
- break;
- }
+ Link2 = GetFirstNode (&gOldFormSet->FormListHead);
+ while (!IsNull (&gOldFormSet->FormListHead, Link2)) {
+ Form2 = FORM_BROWSER_FORM_FROM_LINK (Link2);
- Link2 = GetNextNode (&gOldFormSet->FormListHead, Link2);
+ if (Form->FormId == Form2->FormId) {
+ Form->NvUpdateRequired = Form2->NvUpdateRequired;
+ break;
}
- Link = GetNextNode (&FormSet->FormListHead, Link);
+
+ Link2 = GetNextNode (&gOldFormSet->FormListHead, Link2);
}
+ Link = GetNextNode (&FormSet->FormListHead, Link);
+ }
+ } else {
+ //
+ // Extract default from IFR binary for no storage questions.
+ //
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE);
}
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index 12ffc523f8..e11cdc16d7 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -1081,7 +1081,7 @@ InitializeFormSet (
);
/**
- Reset Questions to their default value in a Form, Formset or System.
+ Reset Questions to their initial value or default value in a Form, Formset or System.
GetDefaultValueScope parameter decides which questions will reset
to its default value.
@@ -1092,6 +1092,9 @@ InitializeFormSet (
@param SettingScope Setting Scope for Default action.
@param GetDefaultValueScope Get default value scope.
@param Storage Get default value only for this storage.
+ @param RetrieveValueFirst Whether call the retrieve call back to
+ get the initial value before get default
+ value.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_UNSUPPORTED Unsupport SettingScope.
@@ -1104,7 +1107,8 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
- IN FORMSET_STORAGE *Storage OPTIONAL
+ IN FORMSET_STORAGE *Storage,
+ IN BOOLEAN RetrieveValueFirst
);
/**
@@ -1384,6 +1388,24 @@ ProcessCallBackFunction (
IN EFI_BROWSER_ACTION Action,
IN BOOLEAN SkipSaveOrDiscard
);
+
+/**
+ Call the retrieve type call back function for one question to get the initialize data.
+
+ This function only used when in the initialize stage, because in this stage, the
+ Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
+
+ @param ConfigAccess The config access protocol produced by the hii driver.
+ @param Statement The Question which need to call.
+
+ @retval EFI_SUCCESS The call back function excutes successfully.
+ @return Other value if the call back function failed to excute.
+**/
+EFI_STATUS
+ProcessRetrieveForQuestion (
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
+ IN FORM_BROWSER_STATEMENT *Statement
+ );
/**
Find the matched FormSet context in the backup maintain list based on HiiHandle.
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
index f3019a8408..1b39ed7f2a 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
@@ -3809,7 +3809,7 @@ UiDisplayMenu (
// Reterieve default setting. After it. NV flag will be showed.
//
if ((HotKey->Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) {
- Status = ExtractDefault (Selection->FormSet, Selection->Form, HotKey->DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL);
+ Status = ExtractDefault (Selection->FormSet, Selection->Form, HotKey->DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE);
if (!EFI_ERROR (Status)) {
Selection->Action = UI_ACTION_REFRESH_FORM;
Selection->Statement = NULL;
@@ -3887,7 +3887,7 @@ UiDisplayMenu (
//
// Reset to default value for all forms in the whole system.
//
- Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, GetDefaultForAll, NULL);
+ Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, GetDefaultForAll, NULL, FALSE);
if (!EFI_ERROR (Status)) {
Selection->Action = UI_ACTION_REFRESH_FORM;