From 09cdd7d264589d806a33fdc18b2ea933e3b01206 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Tue, 26 Jun 2012 08:57:44 +0000 Subject: [PATCH] Update the logic to get default value for question without storage. Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13474 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/Setup.c | 31 ++++++++++++++++--- .../Universal/SetupBrowserDxe/Setup.h | 15 +++++++++ MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 4 +-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 9f01cd3f1a..1389f261ae 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -2970,10 +2970,14 @@ GetQuestionDefault ( /** Reset Questions to their default value in a Form, Formset or System. + GetDefaultValueScope parameter decides which questions will reset + to its default value. + @param FormSet FormSet data structure. @param Form Form data structure. @param DefaultId The Class of the default. @param SettingScope Setting Scope for Default action. + @param GetDefaultValueScope Get default value scope. @param Storage Get default value only for this storage. @retval EFI_SUCCESS The function completed successfully. @@ -2986,6 +2990,7 @@ ExtractDefault ( IN FORM_BROWSER_FORM *Form, IN UINT16 DefaultId, IN BROWSER_SETTING_SCOPE SettingScope, + IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope, IN FORMSET_STORAGE *Storage OPTIONAL ) { @@ -3002,7 +3007,11 @@ ExtractDefault ( // // Check the supported setting level. // - if (SettingScope >= MaxLevel) { + if (SettingScope >= MaxLevel || GetDefaultValueScope >= GetDefaultForMax) { + return EFI_UNSUPPORTED; + } + + if (GetDefaultValueScope == GetDefaultForStorage && Storage == NULL) { return EFI_UNSUPPORTED; } @@ -3018,7 +3027,14 @@ ExtractDefault ( // // If get default value only for this storage, check the storage first. // - if ((Storage != NULL) && (Question->Storage != Storage)) { + if ((GetDefaultValueScope == GetDefaultForStorage) && (Question->Storage != Storage)) { + continue; + } + + // + // If get default value only for no storage question, just skip the question which has storage. + // + if ((GetDefaultValueScope == GetDefaultForNoStorage) && (Question->Storage != NULL)) { continue; } @@ -3055,7 +3071,7 @@ ExtractDefault ( FormLink = GetFirstNode (&FormSet->FormListHead); while (!IsNull (&FormSet->FormListHead, FormLink)) { Form = FORM_BROWSER_FORM_FROM_LINK (FormLink); - ExtractDefault (FormSet, Form, DefaultId, FormLevel, Storage); + ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage); FormLink = GetNextNode (&FormSet->FormListHead, FormLink); } } else if (SettingScope == SystemLevel) { @@ -3126,7 +3142,7 @@ ExtractDefault ( Link = GetFirstNode (&gBrowserFormSetList); while (!IsNull (&gBrowserFormSetList, Link)) { LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link); - ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, Storage); + ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage); Link = GetNextNode (&gBrowserFormSetList, Link); } } @@ -3411,6 +3427,11 @@ InitializeCurrentSetting ( FORM_BROWSER_FORM *Form2; 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 // @@ -3446,7 +3467,7 @@ InitializeCurrentSetting ( // // If get last time changed value failed, extract default from IFR binary // - ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, Storage); + ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage); // // ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag // in current situation. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index f043a6bbcd..fcc17254ed 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -574,6 +574,16 @@ typedef struct { #define BROWSER_HOT_KEY_FROM_LINK(a) CR (a, BROWSER_HOT_KEY, Link, BROWSER_HOT_KEY_SIGNATURE) +// +// Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll. +// +typedef enum { + GetDefaultForNoStorage, // Get default value for question which not has storage. + GetDefaultForStorage, // Get default value for question which has storage. + GetDefaultForAll, // Get default value for all questions. + GetDefaultForMax // Invalid value. +} BROWSER_GET_DEFAULT_VALUE; + extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; extern EFI_HII_STRING_PROTOCOL *mHiiString; extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; @@ -1063,10 +1073,14 @@ InitializeFormSet ( /** Reset Questions to their default value in a Form, Formset or System. + GetDefaultValueScope parameter decides which questions will reset + to its default value. + @param FormSet FormSet data structure. @param Form Form data structure. @param DefaultId The Class of the default. @param SettingScope Setting Scope for Default action. + @param GetDefaultValueScope Get default value scope. @param Storage Get default value only for this storage. @retval EFI_SUCCESS The function completed successfully. @@ -1079,6 +1093,7 @@ ExtractDefault ( IN FORM_BROWSER_FORM *Form, IN UINT16 DefaultId, IN BROWSER_SETTING_SCOPE SettingScope, + IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope, IN FORMSET_STORAGE *Storage OPTIONAL ); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 137115196c..7e846a2926 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -3787,7 +3787,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, NULL); + Status = ExtractDefault (Selection->FormSet, Selection->Form, HotKey->DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL); if (!EFI_ERROR (Status)) { Selection->Action = UI_ACTION_REFRESH_FORM; Selection->Statement = NULL; @@ -3865,7 +3865,7 @@ UiDisplayMenu ( // // Reset to default value for all forms in the whole system. // - Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, NULL); + Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, GetDefaultForAll, NULL); if (!EFI_ERROR (Status)) { Selection->Action = UI_ACTION_REFRESH_FORM;