MdeModulePkg: Enable buffer type value for default and oneofoption opcode.

In order to support default value for orderedlist opcode, support buffer type value for default/oneofoption opcode.
If oneofoption used as a default value, it will not be added to normal option list.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17336 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong 2015-05-06 09:36:40 +00:00 committed by ydong10
parent ddaf640f50
commit 0b567d184d
2 changed files with 40 additions and 2 deletions

View File

@ -902,6 +902,9 @@ DestroyStatement (
Default = QUESTION_DEFAULT_FROM_LINK (Link); Default = QUESTION_DEFAULT_FROM_LINK (Link);
RemoveEntryList (&Default->Link); RemoveEntryList (&Default->Link);
if (Default->Value.Buffer != NULL) {
FreePool (Default->Value.Buffer);
}
FreePool (Default); FreePool (Default);
} }
@ -2113,7 +2116,11 @@ ParseOpCodes (
CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type; CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;
CopyMem (&CurrentDefault->DefaultId, &((EFI_IFR_DEFAULT *) OpCodeData)->DefaultId, sizeof (UINT16)); CopyMem (&CurrentDefault->DefaultId, &((EFI_IFR_DEFAULT *) OpCodeData)->DefaultId, sizeof (UINT16));
if (OpCodeLength > OFFSET_OF (EFI_IFR_DEFAULT, Value)) { if (CurrentDefault->Value.Type == EFI_IFR_TYPE_BUFFER) {
CurrentDefault->Value.BufferLen = (UINT16) (OpCodeLength - OFFSET_OF (EFI_IFR_DEFAULT, Value));
CurrentDefault->Value.Buffer = AllocateCopyPool (CurrentDefault->Value.BufferLen, &((EFI_IFR_DEFAULT *) OpCodeData)->Value);
ASSERT (CurrentDefault->Value.Buffer != NULL);
} else {
CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, OpCodeLength - OFFSET_OF (EFI_IFR_DEFAULT, Value)); CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, OpCodeLength - OFFSET_OF (EFI_IFR_DEFAULT, Value));
ExtendValueToU64 (&CurrentDefault->Value); ExtendValueToU64 (&CurrentDefault->Value);
} }
@ -2132,6 +2139,32 @@ ParseOpCodes (
// Option // Option
// //
case EFI_IFR_ONE_OF_OPTION_OP: case EFI_IFR_ONE_OF_OPTION_OP:
if (ParentStatement->Operand == EFI_IFR_ORDERED_LIST_OP && ((((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG)) != 0)) {
//
// It's keep the default value for ordered list opcode.
//
CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));
ASSERT (CurrentDefault != NULL);
CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;
CurrentDefault->Value.Type = EFI_IFR_TYPE_BUFFER;
if ((((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags & EFI_IFR_OPTION_DEFAULT) != 0) {
CurrentDefault->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
} else {
CurrentDefault->DefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;
}
CurrentDefault->Value.BufferLen = (UINT16) (OpCodeLength - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));
CurrentDefault->Value.Buffer = AllocateCopyPool (CurrentDefault->Value.BufferLen, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Value);
ASSERT (CurrentDefault->Value.Buffer != NULL);
//
// Insert to Default Value list of current Question
//
InsertTailList (&ParentStatement->DefaultListHead, &CurrentDefault->Link);
break;
}
// //
// EFI_IFR_ONE_OF_OPTION appear in scope of a Question. // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
// It create a selection for use in current Question. // It create a selection for use in current Question.

View File

@ -3859,7 +3859,12 @@ GetQuestionDefault (
// //
// Default value is embedded in EFI_IFR_DEFAULT // Default value is embedded in EFI_IFR_DEFAULT
// //
CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE)); if (Default->Value.Type == EFI_IFR_TYPE_BUFFER) {
ASSERT (HiiValue->Buffer != NULL);
CopyMem (HiiValue->Buffer, Default->Value.Buffer, Default->Value.BufferLen);
} else {
CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));
}
} }
if (HiiValue->Type == EFI_IFR_TYPE_STRING) { if (HiiValue->Type == EFI_IFR_TYPE_STRING) {