MdeModulePkg/Browser: Share default if some default value are not specified

Add a new implementation policy of getting default value in SetupBrowser.
The new policy is only for the situation that a question has default
value but doesn't have default value for all supported default type.
In this case, we will choose the smallest default id from the existing
defaults, and share its value to other default id which has no
default value.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Dandan Bi 2016-08-10 19:54:21 +08:00 committed by Star Zeng
parent 22f63ff641
commit 7559672687
2 changed files with 43 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Parser for IFR binary encoding. Parser for IFR binary encoding.
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -1311,6 +1311,9 @@ ParseOpCodes (
INTN ConditionalExprCount; INTN ConditionalExprCount;
BOOLEAN InUnknownScope; BOOLEAN InUnknownScope;
UINT8 UnknownDepth; UINT8 UnknownDepth;
FORMSET_DEFAULTSTORE *PreDefaultStore;
LIST_ENTRY *DefaultLink;
BOOLEAN HaveInserted;
SuppressForQuestion = FALSE; SuppressForQuestion = FALSE;
SuppressForOption = FALSE; SuppressForOption = FALSE;
@ -1875,17 +1878,31 @@ ParseOpCodes (
// DefaultStore // DefaultStore
// //
case EFI_IFR_DEFAULTSTORE_OP: case EFI_IFR_DEFAULTSTORE_OP:
HaveInserted = FALSE;
DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE)); DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));
ASSERT (DefaultStore != NULL); ASSERT (DefaultStore != NULL);
DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE; DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;
CopyMem (&DefaultStore->DefaultId, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId, sizeof (UINT16)); CopyMem (&DefaultStore->DefaultId, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId, sizeof (UINT16));
CopyMem (&DefaultStore->DefaultName, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultName, sizeof (EFI_STRING_ID)); CopyMem (&DefaultStore->DefaultName, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultName, sizeof (EFI_STRING_ID));
// //
// Insert to DefaultStore list of this Formset // Insert it to the DefaultStore list of this Formset with ascending order.
// //
InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link); if (!IsListEmpty (&FormSet->DefaultStoreListHead)) {
DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);
while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) {
PreDefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);
DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead, DefaultLink);
if (DefaultStore->DefaultId < PreDefaultStore->DefaultId) {
InsertTailList (&PreDefaultStore->Link, &DefaultStore->Link);
HaveInserted = TRUE;
break;
}
}
}
if (!HaveInserted) {
InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);
}
break; break;
// //

View File

@ -4050,9 +4050,14 @@ GetQuestionDefault (
INTN Action; INTN Action;
CHAR16 *NewString; CHAR16 *NewString;
EFI_IFR_TYPE_VALUE *TypeValue; EFI_IFR_TYPE_VALUE *TypeValue;
UINT16 OriginalDefaultId;
FORMSET_DEFAULTSTORE *DefaultStore;
LIST_ENTRY *DefaultLink;
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
StrValue = NULL; StrValue = NULL;
OriginalDefaultId = DefaultId;
DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);
// //
// Statement don't have storage, skip them // Statement don't have storage, skip them
@ -4069,6 +4074,7 @@ GetQuestionDefault (
// 4, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default) // 4, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default)
// 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority) // 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)
// //
ReGetDefault:
HiiValue = &Question->HiiValue; HiiValue = &Question->HiiValue;
TypeValue = &HiiValue->Value; TypeValue = &HiiValue->Value;
if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) { if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
@ -4235,7 +4241,22 @@ GetQuestionDefault (
} }
// //
// For Questions without default // For question without default value for current default Id, we try to re-get the default value form other default id in the DefaultStoreList.
// If get, will exit the function, if not, will choose next default id in the DefaultStoreList.
// The default id in DefaultStoreList are in ascending order to make sure choose the smallest default id every time.
//
while (!IsNull(&FormSet->DefaultStoreListHead, DefaultLink)) {
DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);
DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead,DefaultLink);
DefaultId = DefaultStore->DefaultId;
if (DefaultId == OriginalDefaultId) {
continue;
}
goto ReGetDefault;
}
//
// For Questions without default value for all the default id in the DefaultStoreList.
// //
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
switch (Question->Operand) { switch (Question->Operand) {