From 0b567d184dbfd3baa75370df8c8f3b24da5d9a70 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Wed, 6 May 2015 09:36:40 +0000 Subject: [PATCH] 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 Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17336 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/IfrParse.c | 35 ++++++++++++++++++- .../Universal/SetupBrowserDxe/Setup.c | 7 +++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index a4a2478c48..7b77634973 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -902,6 +902,9 @@ DestroyStatement ( Default = QUESTION_DEFAULT_FROM_LINK (Link); RemoveEntryList (&Default->Link); + if (Default->Value.Buffer != NULL) { + FreePool (Default->Value.Buffer); + } FreePool (Default); } @@ -2113,7 +2116,11 @@ ParseOpCodes ( CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type; 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)); ExtendValueToU64 (&CurrentDefault->Value); } @@ -2132,6 +2139,32 @@ ParseOpCodes ( // Option // 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. // It create a selection for use in current Question. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 964682399c..5cf13cec59 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -3859,7 +3859,12 @@ GetQuestionDefault ( // // 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) { -- 2.39.2