]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Enable buffer type value for default and oneofoption opcode.
authorEric Dong <eric.dong@intel.com>
Wed, 6 May 2015 09:36:40 +0000 (09:36 +0000)
committerydong10 <ydong10@Edk2>
Wed, 6 May 2015 09:36:40 +0000 (09:36 +0000)
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

MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c

index a4a2478c48b932e8970dd66c11cbff1f7ea0ea7d..7b77634973ec8b1a47006c7d226ac60ed3a41423 100644 (file)
@@ -902,6 +902,9 @@ DestroyStatement (
     Default = QUESTION_DEFAULT_FROM_LINK (Link);\r
     RemoveEntryList (&Default->Link);\r
 \r
+    if (Default->Value.Buffer != NULL) {\r
+      FreePool (Default->Value.Buffer);\r
+    }\r
     FreePool (Default);\r
   }\r
 \r
@@ -2113,7 +2116,11 @@ ParseOpCodes (
 \r
       CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;\r
       CopyMem (&CurrentDefault->DefaultId, &((EFI_IFR_DEFAULT *) OpCodeData)->DefaultId, sizeof (UINT16));\r
-      if (OpCodeLength > OFFSET_OF (EFI_IFR_DEFAULT, Value)) {\r
+      if (CurrentDefault->Value.Type == EFI_IFR_TYPE_BUFFER) {\r
+        CurrentDefault->Value.BufferLen = (UINT16) (OpCodeLength - OFFSET_OF (EFI_IFR_DEFAULT, Value));\r
+        CurrentDefault->Value.Buffer = AllocateCopyPool (CurrentDefault->Value.BufferLen, &((EFI_IFR_DEFAULT *) OpCodeData)->Value);\r
+        ASSERT (CurrentDefault->Value.Buffer != NULL);\r
+      } else {\r
         CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, OpCodeLength - OFFSET_OF (EFI_IFR_DEFAULT, Value));\r
         ExtendValueToU64 (&CurrentDefault->Value);\r
       }\r
@@ -2132,6 +2139,32 @@ ParseOpCodes (
     // Option\r
     //\r
     case EFI_IFR_ONE_OF_OPTION_OP:\r
+      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)) {\r
+        //\r
+        // It's keep the default value for ordered list opcode.\r
+        //\r
+        CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));\r
+        ASSERT (CurrentDefault != NULL);\r
+        CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;\r
+\r
+        CurrentDefault->Value.Type = EFI_IFR_TYPE_BUFFER;\r
+        if ((((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags & EFI_IFR_OPTION_DEFAULT) != 0) {\r
+          CurrentDefault->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
+        } else {\r
+          CurrentDefault->DefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;\r
+        }\r
+\r
+        CurrentDefault->Value.BufferLen = (UINT16) (OpCodeLength - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));\r
+        CurrentDefault->Value.Buffer = AllocateCopyPool (CurrentDefault->Value.BufferLen, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Value);\r
+        ASSERT (CurrentDefault->Value.Buffer != NULL);\r
+\r
+        //\r
+        // Insert to Default Value list of current Question\r
+        //\r
+        InsertTailList (&ParentStatement->DefaultListHead, &CurrentDefault->Link);\r
+        break;\r
+      }\r
+\r
       //\r
       // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.\r
       // It create a selection for use in current Question.\r
index 964682399c54fc38ffa62dc1f5e5e622765868cc..5cf13cec590761420af41aaa7bc6de5755abc440 100644 (file)
@@ -3859,7 +3859,12 @@ GetQuestionDefault (
           //\r
           // Default value is embedded in EFI_IFR_DEFAULT\r
           //\r
-          CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));\r
+          if (Default->Value.Type == EFI_IFR_TYPE_BUFFER) {\r
+            ASSERT (HiiValue->Buffer != NULL);\r
+            CopyMem (HiiValue->Buffer, Default->Value.Buffer, Default->Value.BufferLen);\r
+          } else {\r
+            CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));\r
+          }\r
         }\r
 \r
         if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r