Update the logic to get default value for question without storage.

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@13474 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2012-06-26 08:57:44 +00:00
parent d9bbabfd13
commit 09cdd7d264
3 changed files with 43 additions and 7 deletions

View File

@ -2970,10 +2970,14 @@ GetQuestionDefault (
/** /**
Reset Questions to their default value in a Form, Formset or System. 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 FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param DefaultId The Class of the default. @param DefaultId The Class of the default.
@param SettingScope Setting Scope for Default action. @param SettingScope Setting Scope for Default action.
@param GetDefaultValueScope Get default value scope.
@param Storage Get default value only for this storage. @param Storage Get default value only for this storage.
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@ -2986,6 +2990,7 @@ ExtractDefault (
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN UINT16 DefaultId, IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope, IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
IN FORMSET_STORAGE *Storage OPTIONAL IN FORMSET_STORAGE *Storage OPTIONAL
) )
{ {
@ -3002,7 +3007,11 @@ ExtractDefault (
// //
// Check the supported setting level. // Check the supported setting level.
// //
if (SettingScope >= MaxLevel) { if (SettingScope >= MaxLevel || GetDefaultValueScope >= GetDefaultForMax) {
return EFI_UNSUPPORTED;
}
if (GetDefaultValueScope == GetDefaultForStorage && Storage == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -3018,7 +3027,14 @@ ExtractDefault (
// //
// If get default value only for this storage, check the storage first. // 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; continue;
} }
@ -3055,7 +3071,7 @@ ExtractDefault (
FormLink = GetFirstNode (&FormSet->FormListHead); FormLink = GetFirstNode (&FormSet->FormListHead);
while (!IsNull (&FormSet->FormListHead, FormLink)) { while (!IsNull (&FormSet->FormListHead, FormLink)) {
Form = FORM_BROWSER_FORM_FROM_LINK (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); FormLink = GetNextNode (&FormSet->FormListHead, FormLink);
} }
} else if (SettingScope == SystemLevel) { } else if (SettingScope == SystemLevel) {
@ -3126,7 +3142,7 @@ ExtractDefault (
Link = GetFirstNode (&gBrowserFormSetList); Link = GetFirstNode (&gBrowserFormSetList);
while (!IsNull (&gBrowserFormSetList, Link)) { while (!IsNull (&gBrowserFormSetList, Link)) {
LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (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); Link = GetNextNode (&gBrowserFormSetList, Link);
} }
} }
@ -3411,6 +3427,11 @@ InitializeCurrentSetting (
FORM_BROWSER_FORM *Form2; FORM_BROWSER_FORM *Form2;
EFI_STATUS Status; 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 // Request current settings from Configuration Driver
// //
@ -3446,7 +3467,7 @@ InitializeCurrentSetting (
// //
// If get last time changed value failed, extract default from IFR binary // 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 // ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag
// in current situation. // in current situation.

View File

@ -574,6 +574,16 @@ typedef struct {
#define BROWSER_HOT_KEY_FROM_LINK(a) CR (a, BROWSER_HOT_KEY, Link, BROWSER_HOT_KEY_SIGNATURE) #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_DATABASE_PROTOCOL *mHiiDatabase;
extern EFI_HII_STRING_PROTOCOL *mHiiString; extern EFI_HII_STRING_PROTOCOL *mHiiString;
extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
@ -1063,10 +1073,14 @@ InitializeFormSet (
/** /**
Reset Questions to their default value in a Form, Formset or System. 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 FormSet FormSet data structure.
@param Form Form data structure. @param Form Form data structure.
@param DefaultId The Class of the default. @param DefaultId The Class of the default.
@param SettingScope Setting Scope for Default action. @param SettingScope Setting Scope for Default action.
@param GetDefaultValueScope Get default value scope.
@param Storage Get default value only for this storage. @param Storage Get default value only for this storage.
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
@ -1079,6 +1093,7 @@ ExtractDefault (
IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_FORM *Form,
IN UINT16 DefaultId, IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope, IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
IN FORMSET_STORAGE *Storage OPTIONAL IN FORMSET_STORAGE *Storage OPTIONAL
); );

View File

@ -3787,7 +3787,7 @@ UiDisplayMenu (
// Reterieve default setting. After it. NV flag will be showed. // Reterieve default setting. After it. NV flag will be showed.
// //
if ((HotKey->Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) { 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)) { if (!EFI_ERROR (Status)) {
Selection->Action = UI_ACTION_REFRESH_FORM; Selection->Action = UI_ACTION_REFRESH_FORM;
Selection->Statement = NULL; Selection->Statement = NULL;
@ -3865,7 +3865,7 @@ UiDisplayMenu (
// //
// Reset to default value for all forms in the whole system. // 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)) { if (!EFI_ERROR (Status)) {
Selection->Action = UI_ACTION_REFRESH_FORM; Selection->Action = UI_ACTION_REFRESH_FORM;