]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add support for newly defined VarStore type EFI_IFR_TYPE_UNDEFINED, EFI_IFR_TYPE_ACTI...
authorxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 26 Oct 2009 03:03:47 +0000 (03:03 +0000)
committerxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 26 Oct 2009 03:03:47 +0000 (03:03 +0000)
Note: with this update, the limitation for "OrderedList should use array of data type UINT8 as its storage" is removed; now OrderedList could use any data type (UINT8/UINT16/UINT32/UINT64) as its storage array.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9360 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg/Universal/SetupBrowserDxe/Ui.h

index 7d31ed5e9fcfb3f0c94b9882e6d99bc24f2aa52c..3285cfe5aae6acc59c1363219affea71f84066ca 100644 (file)
@@ -810,6 +810,7 @@ ParseOpCodes (
   FORMSET_DEFAULTSTORE    *DefaultStore;\r
   QUESTION_DEFAULT        *CurrentDefault;\r
   QUESTION_OPTION         *CurrentOption;\r
+  UINT8                   Width;\r
   CHAR8                   *AsciiString;\r
   UINT16                  NumberOfStatement;\r
   UINT16                  NumberOfExpression;\r
@@ -1019,7 +1020,7 @@ ParseOpCodes (
         break;\r
 \r
       case EFI_IFR_UNDEFINED_OP:\r
-        Value->Type = EFI_IFR_TYPE_OTHER;\r
+        Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
         break;\r
 \r
       case EFI_IFR_VERSION_OP:\r
@@ -1214,6 +1215,7 @@ ParseOpCodes (
     case EFI_IFR_ACTION_OP:\r
       CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);\r
       ASSERT (CurrentStatement != NULL);\r
+      CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_ACTION;\r
 \r
       if (OpCodeLength == sizeof (EFI_IFR_ACTION_1)) {\r
         //\r
@@ -1228,6 +1230,7 @@ ParseOpCodes (
     case EFI_IFR_REF_OP:\r
       CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);\r
       ASSERT (CurrentStatement != NULL);\r
+      CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_UNDEFINED;\r
       CopyMem (&CurrentStatement->RefFormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));\r
       if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {\r
         CopyMem (&CurrentStatement->RefQuestionId, &((EFI_IFR_REF2 *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));\r
@@ -1300,16 +1303,8 @@ ParseOpCodes (
       \r
       CurrentStatement->Flags = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->Flags;\r
       CurrentStatement->MaxContainers = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->MaxContainers;\r
-      CurrentStatement->StorageWidth = (UINT16)(CurrentStatement->MaxContainers * sizeof (UINT8));\r
-      InitializeRequestElement (FormSet, CurrentStatement);\r
 \r
-      //\r
-      // No buffer type is defined in EFI_IFR_TYPE_VALUE, so a Configuration Driver\r
-      // has to use FormBrowser2.Callback() to retrieve the uncommited data for\r
-      // an interactive orderedlist (i.e. with EFI_IFR_FLAG_CALLBACK flag set).\r
-      //\r
-      CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_OTHER;\r
-      CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);\r
+      CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BUFFER;\r
 \r
       if (Scope != 0) {\r
         SuppressForOption = TRUE;\r
@@ -1459,6 +1454,42 @@ ParseOpCodes (
       // Insert to Option list of current Question\r
       //\r
       InsertTailList (&CurrentStatement->OptionListHead, &CurrentOption->Link);\r
+\r
+      //\r
+      // Now we know the Storage width of nested Ordered List\r
+      //\r
+      if ((CurrentStatement->Operand == EFI_IFR_ORDERED_LIST_OP) && (CurrentStatement->BufferValue == NULL)) {\r
+        Width = 1;\r
+        switch (CurrentOption->Value.Type) {\r
+        case EFI_IFR_TYPE_NUM_SIZE_8:\r
+          Width = 1;\r
+          break;\r
+\r
+        case EFI_IFR_TYPE_NUM_SIZE_16:\r
+          Width = 2;\r
+          break;\r
+\r
+        case EFI_IFR_TYPE_NUM_SIZE_32:\r
+          Width = 4;\r
+          break;\r
+\r
+        case EFI_IFR_TYPE_NUM_SIZE_64:\r
+          Width = 8;\r
+          break;\r
+\r
+        default:\r
+          //\r
+          // Invalid type for Ordered List\r
+          //\r
+          break;\r
+        }\r
+\r
+        CurrentStatement->StorageWidth = (UINT16) (CurrentStatement->MaxContainers * Width);\r
+        CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);\r
+        CurrentStatement->ValueType = CurrentOption->Value.Type;\r
+\r
+        InitializeRequestElement (FormSet, CurrentStatement);\r
+      }\r
       break;\r
 \r
     //\r
index cb45a0b580a9b195f28ff12399deab85e7dd005b..bef096c0eb5c06ea133524d09d04d62b709916a1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation for handling user input from the User Interfaces.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -707,6 +707,7 @@ GetSelectionInputPopUp (
   LIST_ENTRY              *Link;\r
   BOOLEAN                 OrderedList;\r
   UINT8                   *ValueArray;\r
+  UINT8                   ValueType;\r
   EFI_HII_VALUE           HiiValue;\r
   EFI_HII_VALUE           *HiiValueArray;\r
   UINTN                   OptionCount;\r
@@ -717,6 +718,7 @@ GetSelectionInputPopUp (
   DimensionsWidth   = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;\r
 \r
   ValueArray        = NULL;\r
+  ValueType         = 0;\r
   CurrentOption     = NULL;\r
   ShowDownArrow     = FALSE;\r
   ShowUpArrow       = FALSE;\r
@@ -737,7 +739,7 @@ GetSelectionInputPopUp (
   //\r
   if (OrderedList) {\r
     for (Index = 0; Index < Question->MaxContainers; Index++) {\r
-      if (ValueArray[Index] == 0) {\r
+      if (GetArrayData (ValueArray, ValueType, Index) == 0) {\r
         break;\r
       }\r
     }\r
@@ -763,8 +765,8 @@ GetSelectionInputPopUp (
   Link = GetFirstNode (&Question->OptionListHead);\r
   for (Index = 0; Index < OptionCount; Index++) {\r
     if (OrderedList) {\r
-      HiiValueArray[Index].Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
-      HiiValueArray[Index].Value.u8 = ValueArray[Index];\r
+      HiiValueArray[Index].Type = ValueType;\r
+      HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
     } else {\r
       OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
       CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE));\r
@@ -1060,11 +1062,11 @@ TheKey:
         // Restore link list order for orderedlist\r
         //\r
         if (OrderedList) {\r
-          HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
+          HiiValue.Type = ValueType;\r
           HiiValue.Value.u64 = 0;\r
           for (Index = 0; Index < Question->MaxContainers; Index++) {\r
-            HiiValue.Value.u8 = ValueArray[Index];\r
-            if (HiiValue.Value.u8 != 0) {\r
+            HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
+            if (HiiValue.Value.u64 == 0) {\r
               break;\r
             }\r
 \r
@@ -1097,7 +1099,7 @@ TheKey:
         while (!IsNull (&Question->OptionListHead, Link)) {\r
           OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
 \r
-          Question->BufferValue[Index] = OneOfOption->Value.Value.u8;\r
+          SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64);\r
 \r
           Index++;\r
           if (Index > Question->MaxContainers) {\r
index 364bc9d0218647a3f0f2829349f3609269744c24..bb9514c315f7ed3e4d65b46c97c2bac83f90049f 100644 (file)
@@ -876,11 +876,6 @@ SetupBrowser (
   }\r
 \r
   do {\r
-    //\r
-    // Displays the Header and Footer borders\r
-    //\r
-    DisplayPageFrame ();\r
-\r
     //\r
     // Initialize Selection->Form\r
     //\r
@@ -911,6 +906,11 @@ SetupBrowser (
       return Status;\r
     }\r
 \r
+    //\r
+    // Displays the Header and Footer borders\r
+    //\r
+    DisplayPageFrame ();\r
+\r
     //\r
     // Display form\r
     //\r
index 447e6a2718d94f07b072aa57d8da862d495e43ef..3dfb567c0faa3ed1e27b917279659b0dc717dd56 100644 (file)
@@ -2,7 +2,7 @@
 Implementation for handling the User Interface option processing.\r
 \r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -101,6 +101,96 @@ ValueToOption (
 }\r
 \r
 \r
+/**\r
+  Return data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+\r
+  @retval Value                  The data to be returned\r
+\r
+**/\r
+UINT64\r
+GetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index\r
+  )\r
+{\r
+  UINT64 Data;\r
+\r
+  ASSERT (Array != NULL);\r
+\r
+  Data = 0;\r
+  switch (Type) {\r
+  case EFI_IFR_TYPE_NUM_SIZE_8:\r
+    Data = (UINT64) *(((UINT8 *) Array) + Index);\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_16:\r
+    Data = (UINT64) *(((UINT16 *) Array) + Index);\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_32:\r
+    Data = (UINT64) *(((UINT32 *) Array) + Index);\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_64:\r
+    Data = (UINT64) *(((UINT64 *) Array) + Index);\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  return Data;\r
+}\r
+\r
+\r
+/**\r
+  Set value of a data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+  @param  Value                  The value to be set.\r
+\r
+**/\r
+VOID\r
+SetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index,\r
+  IN UINT64                   Value\r
+  )\r
+{\r
+\r
+  ASSERT (Array != NULL);\r
+\r
+  switch (Type) {\r
+  case EFI_IFR_TYPE_NUM_SIZE_8:\r
+    *(((UINT8 *) Array) + Index) = (UINT8) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_16:\r
+    *(((UINT16 *) Array) + Index) = (UINT16) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_32:\r
+    *(((UINT32 *) Array) + Index) = (UINT32) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_64:\r
+    *(((UINT64 *) Array) + Index) = (UINT64) Value;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+}\r
+\r
+\r
 /**\r
   Print Question Value according to it's storage width and display attributes.\r
 \r
@@ -311,6 +401,8 @@ ProcessOptions (
   UINT16                          Maximum;\r
   QUESTION_OPTION                 *Option;\r
   UINTN                           Index2;\r
+  UINT8                           *ValueArray;\r
+  UINT8                           ValueType;\r
 \r
   Status        = EFI_SUCCESS;\r
 \r
@@ -325,13 +417,15 @@ ProcessOptions (
   QuestionValue = &Question->HiiValue;\r
   Maximum = (UINT16) Question->Maximum;\r
 \r
+  ValueArray = Question->BufferValue;\r
+  ValueType = Question->ValueType;\r
+\r
   switch (Question->Operand) {\r
   case EFI_IFR_ORDERED_LIST_OP:\r
     //\r
     // Initialize Option value array\r
     //\r
-\r
-    if (Question->BufferValue[0] == 0) {\r
+    if (GetArrayData (ValueArray, ValueType, 0) == 0) {\r
       GetQuestionDefault (Selection->FormSet, Selection->Form, Question, 0);\r
     }\r
 \r
@@ -348,11 +442,11 @@ ProcessOptions (
       *OptionString = AllocateZeroPool (Question->MaxContainers * BufferSize);\r
       ASSERT (*OptionString);\r
 \r
-      HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
+      HiiValue.Type = ValueType;\r
       HiiValue.Value.u64 = 0;\r
       for (Index = 0; Index < Question->MaxContainers; Index++) {\r
-        HiiValue.Value.u8 = Question->BufferValue[Index];\r
-        if (HiiValue.Value.u8 == 0) {\r
+        HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
+        if (HiiValue.Value.u64 == 0) {\r
           //\r
           // Values for the options in ordered lists should never be a 0\r
           //\r
@@ -375,10 +469,11 @@ ProcessOptions (
           Index2 = 0;\r
           while (!IsNull (&Question->OptionListHead, Link) && Index2 < Question->MaxContainers) {\r
             Option = QUESTION_OPTION_FROM_LINK (Link);\r
-            Question->BufferValue[Index2++] = Option->Value.Value.u8;\r
+            SetArrayData (ValueArray, ValueType, Index2, Option->Value.Value.u64);\r
+            Index2++;\r
             Link = GetNextNode (&Question->OptionListHead, Link);\r
           }\r
-          Question->BufferValue[Index2] = 0;\r
+          SetArrayData (ValueArray, ValueType, Index2, 0);\r
 \r
           Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
           UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
index a8393aa502019a6b8b3f64c5cdcceef78dfe2903..153dbf4aa44c9cd6de6d18f8881451f3a72e3ec9 100644 (file)
@@ -1909,7 +1909,7 @@ GetQuestionDefault (
     while (!IsNull (&Question->OptionListHead, Link)) {\r
       Option = QUESTION_OPTION_FROM_LINK (Link);\r
 \r
-      Question->BufferValue[Index] = Option->Value.Value.u8;\r
+      SetArrayData (Question->BufferValue, Question->ValueType, Index, Option->Value.Value.u64);\r
 \r
       Index++;\r
       if (Index >= Question->MaxContainers) {\r
index 91b5aaee40e6334b8d281396ac2d25abd3aa984d..61e2131f335cc2a61e3fb12b85d60abea2520579 100644 (file)
@@ -346,6 +346,7 @@ typedef struct {
 \r
   EFI_HII_VALUE         HiiValue;         // Edit copy for checkbox, numberic, oneof\r
   UINT8                 *BufferValue;     // Edit copy for string, password, orderedlist\r
+  UINT8                 ValueType;        // Data type for orderedlist value array\r
 \r
   //\r
   // OpCode specific members\r
index f7d4ad1d7fdecf31424f84430055a72031dc2717..da1ddc4ada88fb2f6cf4e23e5eabb5c06f5e0121 100644 (file)
@@ -516,6 +516,40 @@ ValueToOption (
   IN EFI_HII_VALUE            *OptionValue\r
   );\r
 \r
+/**\r
+  Return data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+\r
+  @retval Value                  The data to be returned\r
+\r
+**/\r
+UINT64\r
+GetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index\r
+  );\r
+\r
+/**\r
+  Set value of a data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+  @param  Value                  The value to be set.\r
+\r
+**/\r
+VOID\r
+SetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index,\r
+  IN UINT64                   Value\r
+  );\r
+\r
 /**\r
   Process a Question's Option (whether selected or un-selected).\r
 \r