Enhance VfrCompiler to support HiiFormMap feature.
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Wed, 24 Feb 2010 09:18:03 +0000 (09:18 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Wed, 24 Feb 2010 09:18:03 +0000 (09:18 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1896 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/C/Include/Common/UefiInternalFormRepresentation.h
Source/C/VfrCompile/EfiVfr.h
Source/C/VfrCompile/VfrFormPkg.cpp
Source/C/VfrCompile/VfrFormPkg.h
Source/C/VfrCompile/VfrSyntax.g
Source/C/VfrCompile/VfrUtilityLib.cpp
Source/C/VfrCompile/VfrUtilityLib.h

index e76ffd3..9f38247 100644 (file)
@@ -3,7 +3,7 @@
   IFR is primarily consumed by the EFI presentation engine, and produced by EFI\r
   internal application and drivers as well as all add-in card option-ROM drivers\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation  All rights reserved.\r
+  Copyright (c) 2006 - 2010, Intel Corporation  All rights reserved.\r
 \r
   This program and the accompanying materials are licensed and made available\r
   under the terms and conditions of the BSD License which accompanies this\r
@@ -618,6 +618,7 @@ typedef union {
 #define EFI_IFR_DISABLE_IF_OP          0x1E\r
 #define EFI_IFR_TO_LOWER_OP            0x20\r
 #define EFI_IFR_TO_UPPER_OP            0x21\r
+#define EFI_IFR_MAP_OP                 0x22\r
 #define EFI_IFR_ORDERED_LIST_OP        0x23\r
 #define EFI_IFR_VARSTORE_OP            0x24\r
 #define EFI_IFR_VARSTORE_NAME_VALUE_OP 0x25\r
@@ -626,6 +627,10 @@ typedef union {
 #define EFI_IFR_VERSION_OP             0x28\r
 #define EFI_IFR_END_OP                 0x29\r
 #define EFI_IFR_MATCH_OP               0x2A\r
+#define EFI_IFR_GET_OP                 0x2B\r
+#define EFI_IFR_SET_OP                 0x2C\r
+#define EFI_IFR_READ_OP                0x2D\r
+#define EFI_IFR_WRITE_OP               0x2E\r
 #define EFI_IFR_EQUAL_OP               0x2F\r
 #define EFI_IFR_NOT_EQUAL_OP           0x30\r
 #define EFI_IFR_GREATER_THAN_OP        0x31\r
@@ -672,6 +677,7 @@ typedef union {
 #define EFI_IFR_VALUE_OP               0x5A\r
 #define EFI_IFR_DEFAULT_OP             0x5B\r
 #define EFI_IFR_DEFAULTSTORE_OP        0x5C\r
+#define EFI_IFR_FORM_MAP_OP            0x5D\r
 #define EFI_IFR_CATENATE_OP            0x5E\r
 #define EFI_IFR_GUID_OP                0x5F\r
 #define EFI_IFR_SECURITY_OP            0x60\r
@@ -730,14 +736,14 @@ typedef struct _EFI_IFR_VARSTORE {
 \r
 typedef struct _EFI_IFR_VARSTORE_EFI {\r
   EFI_IFR_OP_HEADER        Header;\r
-  UINT16                   VarStoreId;\r
+  EFI_VARSTORE_ID          VarStoreId;\r
   EFI_GUID                 Guid;\r
   UINT32                   Attributes;\r
 } EFI_IFR_VARSTORE_EFI;\r
 \r
 typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {\r
   EFI_IFR_OP_HEADER        Header;\r
-  UINT16                   VarStoreId;\r
+  EFI_VARSTORE_ID          VarStoreId;\r
   EFI_GUID                 Guid;\r
 } EFI_IFR_VARSTORE_NAME_VALUE;\r
 \r
@@ -747,7 +753,7 @@ typedef struct _EFI_IFR_FORM_SET {
   EFI_STRING_ID            FormSetTitle;\r
   EFI_STRING_ID            Help;\r
   UINT8                    Flags;\r
-  EFI_GUID                 ClassGuid[1];\r
+  // EFI_GUID              ClassGuid[];\r
 } EFI_IFR_FORM_SET;\r
 \r
 typedef struct _EFI_IFR_END {\r
@@ -1009,6 +1015,9 @@ typedef struct _EFI_IFR_ONE_OF_OPTION {
 #define EFI_IFR_TYPE_DATE              0x06\r
 #define EFI_IFR_TYPE_STRING            0x07\r
 #define EFI_IFR_TYPE_OTHER             0x08\r
+#define EFI_IFR_TYPE_UNDEFINED         0x09\r
+#define EFI_IFR_TYPE_ACTION            0x0A\r
+#define EFI_IFR_TYPE_BUFFER            0x0B\r
 \r
 #define EFI_IFR_OPTION_DEFAULT         0x10\r
 #define EFI_IFR_OPTION_DEFAULT_MFG     0x20\r
@@ -1288,6 +1297,100 @@ typedef struct _EFI_IFR_SECURITY {
   EFI_GUID                 Permissions;\r
 } EFI_IFR_SECURITY;\r
 \r
+typedef struct _EFI_IFR_FORM_MAP_METHOD {\r
+  ///\r
+  /// The string identifier which provides the human-readable name of \r
+  /// the configuration method for this standards map form.\r
+  ///\r
+  EFI_STRING_ID            MethodTitle;\r
+  ///\r
+  /// Identifier which uniquely specifies the configuration methods \r
+  /// associated with this standards map form.\r
+  ///\r
+  EFI_GUID                 MethodIdentifier;\r
+} EFI_IFR_FORM_MAP_METHOD;\r
+\r
+typedef struct _EFI_IFR_FORM_MAP {\r
+  ///\r
+  /// The sequence that defines the type of opcode as well as the length \r
+  /// of the opcode being defined. Header.OpCode = EFI_IFR_FORM_MAP_OP. \r
+  ///\r
+  EFI_IFR_OP_HEADER        Header;\r
+  ///\r
+  /// The unique identifier for this particular form.\r
+  ///\r
+  EFI_FORM_ID              FormId;\r
+  ///\r
+  /// One or more configuration method's name and unique identifier.\r
+  ///\r
+  // EFI_IFR_FORM_MAP_METHOD  Methods[];\r
+} EFI_IFR_FORM_MAP;\r
+\r
+typedef struct _EFI_IFR_SET {\r
+  ///\r
+  /// The sequence that defines the type of opcode as well as the length \r
+  /// of the opcode being defined. Header.OpCode = EFI_IFR_SET_OP. \r
+  ///\r
+  EFI_IFR_OP_HEADER  Header;\r
+  ///\r
+  /// Specifies the identifier of a previously declared variable store to \r
+  /// use when storing the question's value. \r
+  ///\r
+  EFI_VARSTORE_ID    VarStoreId;\r
+  union {\r
+    ///\r
+    /// A 16-bit Buffer Storage offset.\r
+    ///\r
+    EFI_STRING_ID    VarName;\r
+    ///\r
+    /// A Name Value or EFI Variable name (VarName).\r
+    ///\r
+    UINT16           VarOffset;\r
+  }                  VarStoreInfo;\r
+  ///\r
+  /// Specifies the type used for storage. \r
+  ///\r
+  UINT8              VarStoreType;\r
+} EFI_IFR_SET;\r
+\r
+typedef struct _EFI_IFR_GET {\r
+  ///\r
+  /// The sequence that defines the type of opcode as well as the length \r
+  /// of the opcode being defined. Header.OpCode = EFI_IFR_GET_OP. \r
+  ///\r
+  EFI_IFR_OP_HEADER  Header;\r
+  ///\r
+  /// Specifies the identifier of a previously declared variable store to \r
+  /// use when retrieving the value. \r
+  ///\r
+  EFI_VARSTORE_ID    VarStoreId;\r
+  union {\r
+    ///\r
+    /// A 16-bit Buffer Storage offset.\r
+    ///\r
+    EFI_STRING_ID    VarName;\r
+    ///\r
+    /// A Name Value or EFI Variable name (VarName).\r
+    ///\r
+    UINT16           VarOffset;\r
+  }                  VarStoreInfo;\r
+  ///\r
+  /// Specifies the type used for storage. \r
+  ///\r
+  UINT8              VarStoreType;\r
+} EFI_IFR_GET;\r
+\r
+typedef struct _EFI_IFR_READ {\r
+  EFI_IFR_OP_HEADER       Header;\r
+} EFI_IFR_READ;\r
+\r
+typedef struct _EFI_IFR_WRITE {\r
+  EFI_IFR_OP_HEADER      Header;\r
+} EFI_IFR_WRITE;\r
+\r
+typedef struct _EFI_IFR_MAP {\r
+  EFI_IFR_OP_HEADER      Header;\r
+} EFI_IFR_MAP;\r
 //\r
 // Keyboard Package\r
 //\r
index a88b101..809ca9e 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2010, 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
@@ -31,6 +31,7 @@ Abstract:
 #define MAX_VFR_LINE_LEN         4096\r
 \r
 #define EFI_IFR_MAX_LENGTH       0xFF\r
+#define MAX_IFR_EXPRESSION_DEPTH 0x9\r
 \r
 #define EFI_VARSTORE_ID_INVALID  0\r
 #define EFI_VAROFFSET_INVALID    0xFFFF\r
index c679ba6..ccbc044 100644 (file)
@@ -2,7 +2,7 @@
   \r
   The definition of CFormPkg's member function\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2010, 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
@@ -1242,7 +1242,7 @@ static struct {
   { 0, 0 },                                    // 0x1F\r
   { sizeof (EFI_IFR_TO_LOWER), 0 },            // EFI_IFR_TO_LOWER_OP - 0x20\r
   { sizeof (EFI_IFR_TO_UPPER), 0 },            // EFI_IFR_TO_UPPER_OP - 0x21\r
-  { 0, 0 },                                    // 0x22\r
+  { sizeof (EFI_IFR_MAP), 1 },                 // EFI_IFR_MAP - 0x22\r
   { sizeof (EFI_IFR_ORDERED_LIST), 1 },        // EFI_IFR_ORDERED_LIST_OP - 0x23\r
   { sizeof (EFI_IFR_VARSTORE), 0 },            // EFI_IFR_VARSTORE_OP\r
   { sizeof (EFI_IFR_VARSTORE_NAME_VALUE), 0 }, // EFI_IFR_VARSTORE_NAME_VALUE_OP\r
@@ -1250,8 +1250,11 @@ static struct {
   { sizeof (EFI_IFR_VARSTORE_DEVICE), 1 },     // EFI_IFR_VARSTORE_DEVICE_OP\r
   { sizeof (EFI_IFR_VERSION), 0 },             // EFI_IFR_VERSION_OP - 0x28\r
   { sizeof (EFI_IFR_END), 0 },                 // EFI_IFR_END_OP\r
-  { sizeof (EFI_IFR_MATCH), 1 },               // EFI_IFR_MATCH_OP - 0x2A\r
-  { 0, 0 }, { 0, 0} , { 0, 0} , { 0, 0} ,      // 0x2B ~ 0x2E\r
+  { sizeof (EFI_IFR_MATCH), 0 },               // EFI_IFR_MATCH_OP - 0x2A\r
+  { sizeof (EFI_IFR_GET), 0 },                 // EFI_IFR_GET - 0x2B\r
+  { sizeof (EFI_IFR_SET), 0 },                 // EFI_IFR_SET - 0x2C\r
+  { sizeof (EFI_IFR_READ), 0 },                // EFI_IFR_READ - 0x2D\r
+  { sizeof (EFI_IFR_WRITE), 0 },               // EFI_IFR_WRITE - 0x2E\r
   { sizeof (EFI_IFR_EQUAL), 0 },               // EFI_IFR_EQUAL_OP - 0x2F\r
   { sizeof (EFI_IFR_NOT_EQUAL), 0 },           // EFI_IFR_NOT_EQUAL_OP\r
   { sizeof (EFI_IFR_GREATER_THAN), 0 },        // EFI_IFR_GREATER_THAN_OP\r
@@ -1298,7 +1301,7 @@ static struct {
   { sizeof (EFI_IFR_VALUE), 1 },               // EFI_IFR_VALUE_OP\r
   { sizeof (EFI_IFR_DEFAULT), 0 },             // EFI_IFR_DEFAULT_OP\r
   { sizeof (EFI_IFR_DEFAULTSTORE), 0 },        // EFI_IFR_DEFAULTSTORE_OP - 0x5C\r
-  { 0, 0},                                     // 0x5D\r
+  { sizeof (EFI_IFR_FORM_MAP), 1},             // EFI_IFR_FORM_MAP_OP - 0x5D\r
   { sizeof (EFI_IFR_CATENATE), 0 },            // EFI_IFR_CATENATE_OP\r
   { sizeof (EFI_IFR_GUID), 0 },                // EFI_IFR_GUID_OP\r
   { sizeof (EFI_IFR_SECURITY), 0 },            // EFI_IFR_SECURITY_OP - 0x60\r
@@ -1313,9 +1316,9 @@ static struct {
   "EFI_IFR_ACTION",     "EFI_IFR_RESET_BUTTON",         "EFI_IFR_FORM_SET",      "EFI_IFR_REF",             "EFI_IFR_NO_SUBMIT_IF",  "EFI_IFR_INCONSISTENT_IF",\r
   "EFI_IFR_EQ_ID_VAL",  "EFI_IFR_EQ_ID_ID",             "EFI_IFR_EQ_ID_LIST",    "EFI_IFR_AND",             "EFI_IFR_OR",            "EFI_IFR_NOT",\r
   "EFI_IFR_RULE",       "EFI_IFR_GRAY_OUT_IF",          "EFI_IFR_DATE",          "EFI_IFR_TIME",            "EFI_IFR_STRING",        "EFI_IFR_REFRESH",\r
-  "EFI_IFR_DISABLE_IF", "EFI_IFR_INVALID",              "EFI_IFR_TO_LOWER",      "EFI_IFR_TO_UPPER",        "EFI_IFR_INVALID",       "EFI_IFR_ORDERED_LIST",\r
+  "EFI_IFR_DISABLE_IF", "EFI_IFR_INVALID",              "EFI_IFR_TO_LOWER",      "EFI_IFR_TO_UPPER",        "EFI_IFR_MAP",           "EFI_IFR_ORDERED_LIST",\r
   "EFI_IFR_VARSTORE",   "EFI_IFR_VARSTORE_NAME_VALUE",  "EFI_IFR_VARSTORE_EFI",  "EFI_IFR_VARSTORE_DEVICE", "EFI_IFR_VERSION",       "EFI_IFR_END",\r
-  "EFI_IFR_MATCH",      "EFI_IFR_INVALID",              "EFI_IFR_INVALID",       "EFI_IFR_INVALID",         "EFI_IFR_INVALID",       "EFI_IFR_EQUAL",\r
+  "EFI_IFR_MATCH",      "EFI_IFR_GET",                  "EFI_IFR_SET",           "EFI_IFR_READ",            "EFI_IFR_WRITE",         "EFI_IFR_EQUAL",\r
   "EFI_IFR_NOT_EQUAL",  "EFI_IFR_GREATER_THAN",         "EFI_IFR_GREATER_EQUAL", "EFI_IFR_LESS_THAN",       "EFI_IFR_LESS_EQUAL",    "EFI_IFR_BITWISE_AND",\r
   "EFI_IFR_BITWISE_OR", "EFI_IFR_BITWISE_NOT",          "EFI_IFR_SHIFT_LEFT",    "EFI_IFR_SHIFT_RIGHT",     "EFI_IFR_ADD",           "EFI_IFR_SUBTRACT",\r
   "EFI_IFR_MULTIPLY",   "EFI_IFR_DIVIDE",               "EFI_IFR_MODULO",        "EFI_IFR_RULE_REF",        "EFI_IFR_QUESTION_REF1", "EFI_IFR_QUESTION_REF2",\r
@@ -1323,7 +1326,7 @@ static struct {
   "EFI_IFR_TO_UINT",    "EFI_IFR_TO_STRING",            "EFI_IFR_TO_BOOLEAN",    "EFI_IFR_MID",             "EFI_IFR_FIND",          "EFI_IFR_TOKEN",\r
   "EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2",          "EFI_IFR_CONDITIONAL",   "EFI_IFR_QUESTION_REF3",   "EFI_IFR_ZERO",          "EFI_IFR_ONE",\r
   "EFI_IFR_ONES",       "EFI_IFR_UNDEFINED",            "EFI_IFR_LENGTH",        "EFI_IFR_DUP",             "EFI_IFR_THIS",          "EFI_IFR_SPAN",\r
-  "EFI_IFR_VALUE",      "EFI_IFR_DEFAULT",              "EFI_IFR_DEFAULTSTORE",  "EFI_IFR_INVALID",         "EFI_IFR_CATENATE",      "EFI_IFR_GUID",\r
+  "EFI_IFR_VALUE",      "EFI_IFR_DEFAULT",              "EFI_IFR_DEFAULTSTORE",  "EFI_IFR_FORM_MAP",        "EFI_IFR_CATENATE",      "EFI_IFR_GUID",\r
   "EFI_IFR_SECURITY",\r
 };\r
 \r
@@ -1396,4 +1399,4 @@ CIfrOpHeader::CIfrOpHeader (
   mHeader = OpHdr.mHeader;\r
 }\r
 \r
-UINT32 CIfrForm::FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE] = {0, };\r
+UINT32 CIfrFormId::FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE] = {0, };\r
index 12dc388..38422e1 100644 (file)
@@ -2,7 +2,7 @@
   \r
   The definition of CFormPkg's member function\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2010, 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
@@ -557,6 +557,7 @@ static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
 class CIfrFormSet : public CIfrObj, public CIfrOpHeader {\r
 private:\r
   EFI_IFR_FORM_SET *mFormSet;\r
+  EFI_GUID *mClassGuid;\r
 \r
 public:\r
   CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),\r
@@ -565,6 +566,7 @@ public:
     mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;\r
     mFormSet->Flags        = 0;\r
     memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));\r
+    mClassGuid = (EFI_GUID *) (mFormSet + 1);\r
   }\r
 \r
   VOID SetGuid (IN EFI_GUID *Guid) {\r
@@ -580,7 +582,7 @@ public:
   }\r
 \r
   VOID SetClassGuid (IN EFI_GUID *Guid) {\r
-    memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));\r
+    memcpy (&(mClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));\r
   }\r
 \r
   UINT8 GetFlags() {\r
@@ -620,10 +622,8 @@ public:
 #define EFI_FORM_ID_MAX                    0xFFFF\r
 #define EFI_FREE_FORM_ID_BITMAP_SIZE     ((EFI_FORM_ID_MAX + 1) / EFI_BITS_PER_UINT32)\r
 \r
-class CIfrForm : public CIfrObj, public CIfrOpHeader {\r
-private:\r
-  EFI_IFR_FORM  *mForm;\r
-\r
+class CIfrFormId {\r
+public:\r
   STATIC UINT32 FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE];\r
 \r
   STATIC BOOLEAN ChekFormIdFree (IN EFI_FORM_ID FormId) {\r
@@ -639,6 +639,11 @@ private:
 \r
     FormIdBitMap[Index] |= (0x80000000 >> Offset);\r
   }\r
+};\r
+\r
+class CIfrForm : public CIfrObj, public CIfrOpHeader {\r
+private:\r
+  EFI_IFR_FORM  *mForm;\r
 \r
 public:\r
   CIfrForm () : CIfrObj (EFI_IFR_FORM_OP, (CHAR8 **)&mForm), \r
@@ -654,11 +659,11 @@ public:
       //\r
       return VFR_RETURN_INVALID_PARAMETER;\r
     }\r
-    if (CIfrForm::ChekFormIdFree (FormId) == FALSE) {\r
+    if (CIfrFormId::ChekFormIdFree (FormId) == FALSE) {\r
       return VFR_RETURN_FORMID_REDEFINED;\r
     }\r
     mForm->FormId = FormId;\r
-    CIfrForm::MarkFormIdUsed (FormId);\r
+    CIfrFormId::MarkFormIdUsed (FormId);\r
     return VFR_RETURN_SUCCESS;\r
   }\r
 \r
@@ -667,6 +672,44 @@ public:
   }\r
 };\r
 \r
+class CIfrFormMap : public CIfrObj, public CIfrOpHeader {\r
+private:\r
+  EFI_IFR_FORM_MAP        *mFormMap;\r
+  EFI_IFR_FORM_MAP_METHOD *mMethodMap;\r
+\r
+public:\r
+  CIfrFormMap () : CIfrObj (EFI_IFR_FORM_MAP_OP, (CHAR8 **)&mFormMap, sizeof (EFI_IFR_FORM_MAP), TRUE), \r
+                   CIfrOpHeader (EFI_IFR_FORM_MAP_OP, &mFormMap->Header) {\r
+    mFormMap->FormId = 0;\r
+    mMethodMap       = (EFI_IFR_FORM_MAP_METHOD *) (mFormMap + 1);\r
+  }\r
+\r
+  EFI_VFR_RETURN_CODE SetFormId (IN EFI_FORM_ID FormId) {\r
+    if (FormId == 0) {\r
+      //\r
+      // FormId can't be 0.\r
+      //\r
+      return VFR_RETURN_INVALID_PARAMETER;\r
+    }\r
+    if (CIfrFormId::ChekFormIdFree (FormId) == FALSE) {\r
+      return VFR_RETURN_FORMID_REDEFINED;\r
+    }\r
+    mFormMap->FormId = FormId;\r
+    CIfrFormId::MarkFormIdUsed (FormId);\r
+    return VFR_RETURN_SUCCESS;\r
+  }\r
+\r
+  VOID SetFormMapMethod (IN EFI_STRING_ID MethodTitle, IN EFI_GUID *MethodGuid) {\r
+    if (ExpendObjBin (sizeof (EFI_IFR_FORM_MAP_METHOD))) {\r
+      IncLength (sizeof (EFI_IFR_FORM_MAP_METHOD));\r
+\r
+      mMethodMap->MethodTitle = MethodTitle;\r
+      memcpy (&(mMethodMap->MethodIdentifier), MethodGuid, sizeof (EFI_GUID));\r
+      mMethodMap ++;\r
+    }\r
+  }\r
+};\r
+\r
 class CIfrVarStore : public CIfrObj, public CIfrOpHeader {\r
 private:\r
   EFI_IFR_VARSTORE *mVarStore;\r
@@ -832,6 +875,66 @@ public:
 \r
 };\r
 \r
+class CIfrRead : public CIfrObj, public CIfrOpHeader{\r
+private:\r
+  EFI_IFR_READ *mRead;\r
+\r
+public:\r
+  CIfrRead () : CIfrObj (EFI_IFR_READ_OP, (CHAR8 **)&mRead),\r
+                CIfrOpHeader (EFI_IFR_READ_OP, &mRead->Header) {}\r
+\r
+};\r
+\r
+class CIfrWrite : public CIfrObj, public CIfrOpHeader{\r
+private:\r
+  EFI_IFR_WRITE *mWrite;\r
+\r
+public:\r
+  CIfrWrite () : CIfrObj (EFI_IFR_WRITE_OP, (CHAR8 **)&mWrite),\r
+                CIfrOpHeader (EFI_IFR_WRITE_OP, &mWrite->Header) {}\r
+\r
+};\r
+\r
+class CIfrGet : public CIfrObj, public CIfrOpHeader{\r
+private:\r
+  EFI_IFR_GET *mGet;\r
+\r
+public:\r
+  CIfrGet (\r
+  IN UINT32 LineNo  \r
+  ) : CIfrObj (EFI_IFR_GET_OP, (CHAR8 **)&mGet),\r
+      CIfrOpHeader (EFI_IFR_GET_OP, &mGet->Header) {\r
+    SetLineNo (LineNo);\r
+  }\r
+\r
+  VOID SetVarInfo (IN EFI_VARSTORE_INFO *Info) {\r
+    mGet->VarStoreId             = Info->mVarStoreId;\r
+    mGet->VarStoreInfo.VarName   = Info->mInfo.mVarName;\r
+    mGet->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset;\r
+    mGet->VarStoreType           = Info->mVarType;\r
+  }\r
+};\r
+\r
+class CIfrSet : public CIfrObj, public CIfrOpHeader{\r
+private:\r
+  EFI_IFR_SET *mSet;\r
+\r
+public:\r
+  CIfrSet (\r
+  IN UINT32 LineNo\r
+  ) : CIfrObj (EFI_IFR_SET_OP, (CHAR8 **)&mSet),\r
+      CIfrOpHeader (EFI_IFR_SET_OP, &mSet->Header) {\r
+    SetLineNo (LineNo);\r
+  }\r
+\r
+  VOID SetVarInfo (IN EFI_VARSTORE_INFO *Info) {\r
+    mSet->VarStoreId             = Info->mVarStoreId;\r
+    mSet->VarStoreInfo.VarName   = Info->mInfo.mVarName;\r
+    mSet->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset;\r
+    mSet->VarStoreType           = Info->mVarType;\r
+  }\r
+};\r
+\r
 class CIfrSubtitle : public CIfrObj, public CIfrOpHeader, public CIfrStatementHeader {\r
 private:\r
   EFI_IFR_SUBTITLE   *mSubtitle;\r
@@ -2310,6 +2413,19 @@ public:
   }\r
 };\r
 \r
+class CIfrMap : public CIfrObj, public CIfrOpHeader{\r
+private:\r
+  EFI_IFR_MAP *mMap;\r
+\r
+public:\r
+  CIfrMap (\r
+  IN UINT32 LineNo  \r
+  ) : CIfrObj (EFI_IFR_MAP_OP, (CHAR8 **)&mMap),\r
+      CIfrOpHeader (EFI_IFR_MAP_OP, &mMap->Header) {\r
+    SetLineNo (LineNo);\r
+  }\r
+};\r
+\r
 class CIfrMatch : public CIfrObj, public CIfrOpHeader {\r
 private:\r
   EFI_IFR_MATCH *mMatch;\r
index c4511fd..2a4f7b6 100644 (file)
@@ -131,6 +131,9 @@ VfrParserStart (
 #token EndList("endlist")                       "endlist"\r
 #token EndForm("endform")                       "endform"\r
 #token Form("form")                             "form"\r
+#token FormMap("formmap")                       "formmap"\r
+#token MapTitle("maptitle")                     "maptitle"\r
+#token MapGuid("mapguid")                       "mapguid"\r
 #token Subtitle("subtitle")                     "subtitle"\r
 #token Help("help")                             "help"\r
 #token Text("text")                             "text"\r
@@ -214,6 +217,8 @@ VfrParserStart (
 #token Rule("rule")                             "rule"\r
 #token EndRule("endrule")                       "endrule"\r
 #token Value("value")                           "value"\r
+#token Read("read")                             "read"\r
+#token Write("write")                           "write"\r
 #token ResetButton("resetbutton")               "resetbutton"\r
 #token EndResetButton("endresetbutton")         "endresetbutton"\r
 #token DefaultStore("defaultstore")             "defaultstore"\r
@@ -250,7 +255,8 @@ VfrParserStart (
 \r
 vfrProgram > [UINT8 Return] :\r
   <<\r
-     mParserStatus = 0;\r
+     mParserStatus   = 0;\r
+     mCIfrOpHdrIndex = 0;\r
      mConstantOnlyInExpression = FALSE;\r
   >>\r
   (\r
@@ -488,24 +494,26 @@ vfrFormSetDefinition :
                                                     <<\r
                                                       switch (ClassGuidNum) {\r
                                                       case 0:\r
-                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));\r
                                                         FSObj->SetClassGuid(&DefaultClassGuid);\r
                                                         break;\r
                                                       case 1:\r
-                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));\r
                                                         FSObj->SetClassGuid(&ClassGuid1);\r
                                                         break;\r
                                                       case 2:\r
-                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));\r
                                                         FSObj->SetClassGuid(&ClassGuid1);\r
                                                         FSObj->SetClassGuid(&ClassGuid2);\r
                                                         break;\r
-                                                      default:\r
-                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID));\r
+                                                      case 3:\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));\r
                                                         FSObj->SetClassGuid(&ClassGuid1);\r
                                                         FSObj->SetClassGuid(&ClassGuid2);\r
                                                         FSObj->SetClassGuid(&ClassGuid3);\r
                                                         break;\r
+                                                      default:\r
+                                                        break;\r
                                                       }\r
 \r
                                                       SET_LINE_INFO (*FSObj, L);\r
@@ -544,6 +552,7 @@ vfrFormSetDefinition :
 vfrFormSetList :\r
   (\r
     vfrFormDefinition             |\r
+    vfrFormMapDefinition          |\r
     vfrStatementImage             |\r
     vfrStatementVarStoreLinear    |\r
     vfrStatementVarStoreEfi       |\r
@@ -774,11 +783,11 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
                                                          mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
                                                          break;\r
                                                        case QUESTION_DATE:\r
-                                                       mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
-                                                       break;\r
+                                                         mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
+                                                         break;\r
                                                        case QUESTION_TIME:\r
-                                                       mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
-                                                       break;\r
+                                                         mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
+                                                         break;\r
                                                        default:\r
                                                        _PCATCH(VFR_RETURN_FATAL_ERROR);\r
                                                        }\r
@@ -823,7 +832,7 @@ questionheaderFlagsField[UINT8 & Flags] :
   | LateCheckFlag\r
   ;\r
 \r
-vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :\r
+vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFlag = TRUE] :\r
   <<\r
      UINT32                Idx;\r
      UINT32                LineNo;\r
@@ -856,9 +865,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
                                                                              );\r
                                                           VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
                                                        }\r
-                                                       _PCATCH(VfrReturnCode, SN1);\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
-                                                       _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
+                                                       if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {\r
+                                                         _PCATCH(VfrReturnCode, SN1);\r
+                                                         _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
+                                                         _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
+                                                       }\r
                                                     >>\r
   )\r
   |\r
@@ -877,17 +888,21 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
                                                                              );\r
                                                           VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
                                                        }\r
-                                                       _PCATCH(VfrReturnCode, SN2);\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);\r
-                                                       if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
-                                                         _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);\r
-                                                         _STRCAT(&VarStr, TName);\r
+                                                       if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {\r
+                                                         _PCATCH(VfrReturnCode, SN2);\r
+                                                         _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);\r
+                                                         if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
+                                                           _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);\r
+                                                           _STRCAT(&VarStr, TName);\r
+                                                         }\r
                                                        }\r
                                                     >>\r
 \r
     (\r
       "."                                           <<\r
-                                                       _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);\r
+                                                       if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {\r
+                                                         _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);\r
+                                                       }\r
                                                        _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");\r
                                                     >>\r
       SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>\r
@@ -1082,6 +1097,33 @@ vfrFormDefinition :
   ";"\r
   ;\r
 \r
+vfrFormMapDefinition :\r
+  << \r
+    CIfrFormMap *FMapObj = NULL;\r
+    UINT32      FormMapMethodNumber = 0;\r
+    EFI_GUID    Guid;\r
+  >>\r
+  F:FormMap                                         << FMapObj = new CIfrFormMap(); FMapObj->SetLineNo(F->getLine()); >>\r
+  FormId "=" S1:Number ","                          << _PCATCH(FMapObj->SetFormId (_STOFID(S1->getText())), S1); >>\r
+  (\r
+    MapTitle "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"\r
+    MapGuid  "=" guidDefinition[Guid] ";"           << FMapObj->SetFormMapMethod (_STOFID(S2->getText()), &Guid); FormMapMethodNumber ++; >>\r
+  )*                                                << if (FormMapMethodNumber == 0) {_PCATCH (VFR_RETURN_INVALID_PARAMETER, F->getLine(), "No MapMethod is set for FormMap!");} delete FMapObj;>>\r
+  (\r
+    vfrStatementImage                        |\r
+    vfrStatementLocked                       |\r
+    vfrStatementRules                        |\r
+    vfrStatementDefault                      |\r
+    vfrStatementStat                         |\r
+    vfrStatementQuestions                    |\r
+    vfrStatementConditional                  |\r
+    vfrStatementLabel                        |\r
+    vfrStatementBanner\r
+  )*\r
+  E:EndForm                                         << CRT_END_OP (E); >>\r
+  ";"\r
+  ;\r
+\r
 vfrStatementRules :\r
   << CIfrRule RObj; >>\r
   R:Rule                                            << RObj.SetLineNo(R->getLine()); >>\r
@@ -1197,6 +1239,18 @@ vfrStatementValue :
   "=" vfrStatementExpression[0]                        << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >>\r
   ;\r
 \r
+vfrStatementRead :\r
+  << CIfrRead RObj; >>\r
+  R:Read                                               << RObj.SetLineNo(R->getLine()); >>\r
+  vfrStatementExpression[0] ";" \r
+  ;\r
+\r
+vfrStatementWrite :\r
+  << CIfrWrite WObj; >>\r
+  W:Write                                              << WObj.SetLineNo(W->getLine()); >>\r
+  vfrStatementExpression[0] ";" \r
+  ;\r
+\r
 vfrStatementSubTitle :\r
   << CIfrSubtitle SObj; >>\r
   L:Subtitle                                           << SObj.SetLineNo(L->getLine()); >>\r
@@ -2049,6 +2103,8 @@ vfrStatementQuestionOptionTag :
   vfrStatementGrayOutIfQuest    |\r
   vfrStatementValue             |\r
   vfrStatementDefault           |\r
+  vfrStatementRead              |\r
+  vfrStatementWrite             |\r
   vfrStatementOptions\r
   ;\r
 \r
@@ -2482,6 +2538,7 @@ vfrStatementInvalidSaveRestoreDefaults :
 #token StringRef("stringref")                   "stringref"\r
 #token PushThis("pushthis")                     "pushthis"\r
 #token Security("security")                     "security"\r
+#token Get("get")                               "get"\r
 #token True("TRUE")                             "TRUE"\r
 #token False("FALSE")                           "FALSE"\r
 #token One("ONE")                               "ONE"\r
@@ -2493,6 +2550,7 @@ vfrStatementInvalidSaveRestoreDefaults :
 #token AND("AND")                               "AND"\r
 #token OR("OR")                                 "OR"\r
 #token NOT("NOT")                               "NOT"\r
+#token Set("set")                               "set"\r
 #token BitWiseNot("~")                          "\~"\r
 #token BoolVal("boolval")                       "boolval"\r
 #token StringVal("stringval")                   "stringval"\r
@@ -2503,12 +2561,13 @@ vfrStatementInvalidSaveRestoreDefaults :
 #token Catenate("catenate")                     "catenate"\r
 #token QuestionRefVal("questionrefval")         "questionrefval"\r
 #token StringRefVal("stringrefval")             "stringrefval"\r
+#token Map("map")                               "map"\r
 \r
 //\r
 // Root expression extension function called by other function.\r
 //\r
 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
-  << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
+  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>\r
   andTerm[$RootLevel, $ExpOpCount]\r
   (\r
     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
@@ -2520,11 +2579,15 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
                                                           if ($ExpOpCount > 1 && $RootLevel == 0) {\r
                                                             if (_SET_SAVED_OPHDR_SCOPE()) {\r
                                                               CIfrEnd EObj;\r
-                                                              if (mCIfrOpHdrLineNo != 0) {\r
-                                                                EObj.SetLineNo (mCIfrOpHdrLineNo);\r
+                                                              if (mCIfrOpHdrLineNo[mCIfrOpHdrIndex] != 0) {\r
+                                                                EObj.SetLineNo (mCIfrOpHdrLineNo[mCIfrOpHdrIndex]);\r
                                                               }\r
                                                             }\r
                                                           }\r
+                                                          \r
+                                                          if ($RootLevel == 0) {\r
+                                                            mCIfrOpHdrIndex --;\r
+                                                          }\r
                                                        >>\r
   ;\r
 \r
@@ -2667,6 +2730,7 @@ atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
   | vfrExpressionConstant[$RootLevel, $ExpOpCount]\r
   | vfrExpressionUnaryOp[$RootLevel, $ExpOpCount]\r
   | vfrExpressionTernaryOp[$RootLevel, $ExpOpCount]\r
+  | vfrExpressionMap[$RootLevel, $ExpOpCount]\r
   | (\r
       L:NOT\r
       atomTerm[$RootLevel, $ExpOpCount]                 << { CIfrNot NObj(L->getLine()); $ExpOpCount++; } >>\r
@@ -2708,6 +2772,7 @@ vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
   | stringref1Exp[$RootLevel, $ExpOpCount]\r
   | pushthisExp[$RootLevel, $ExpOpCount]\r
   | securityExp[$RootLevel, $ExpOpCount]\r
+  | getExp[$RootLevel, $ExpOpCount]\r
   ;\r
 \r
 dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -3020,6 +3085,84 @@ securityExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   "\(" guidDefinition[Guid] "\)"                       << { CIfrSecurity SObj(L->getLine()); _SAVE_OPHDR_COND (SObj, ($ExpOpCount == 0), L->getLine()); SObj.SetPermissions (&Guid); } $ExpOpCount++; >>\r
   ;\r
 \r
+numericVarStoreType [UINT8 & VarType] :\r
+    "NUMERIC_SIZE_1"                                   << $VarType = EFI_IFR_NUMERIC_SIZE_1; >>\r
+  | "NUMERIC_SIZE_2"                                   << $VarType = EFI_IFR_NUMERIC_SIZE_2; >>\r
+  | "NUMERIC_SIZE_4"                                   << $VarType = EFI_IFR_NUMERIC_SIZE_4; >>\r
+  | "NUMERIC_SIZE_8"                                   << $VarType = EFI_IFR_NUMERIC_SIZE_8; >>\r
+  ;\r
+\r
+getExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
+  <<\r
+     EFI_VARSTORE_INFO Info;\r
+     CHAR8             *VarIdStr = NULL;\r
+     EFI_QUESTION_ID   QId = EFI_QUESTION_ID_INVALID;\r
+     UINT32            Mask = 0;\r
+     EFI_QUESION_TYPE  QType = QUESTION_NORMAL;\r
+     UINT8             VarType = EFI_IFR_TYPE_UNDEFINED;\r
+     UINT32            VarSize = 0;\r
+     Info.mVarStoreId = 0;\r
+  >>\r
+  L:Get\r
+  "\(" \r
+      vfrStorageVarId[Info, VarIdStr, FALSE]\r
+      {"\|" FLAGS "=" numericVarStoreType [VarType] }\r
+  "\)"                                                 << \r
+                                                          {\r
+                                                            if (Info.mVarStoreId == 0) {\r
+                                                              // support Date/Time question\r
+                                                              mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);\r
+                                                              if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");\r
+                                                              }\r
+                                                              if (QType == QUESTION_DATE) {\r
+                                                                Info.mVarType = EFI_IFR_TYPE_DATE;\r
+                                                              } else if (QType == QUESTION_TIME) {\r
+                                                                Info.mVarType = EFI_IFR_TYPE_TIME;\r
+                                                              }\r
+                                                              switch (Mask) {\r
+                                                              case DATE_YEAR_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 0;\r
+                                                                break;\r
+                                                              case DATE_DAY_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 3;\r
+                                                                break;\r
+                                                              case TIME_HOUR_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 0;\r
+                                                                break;\r
+                                                              case TIME_MINUTE_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 1;\r
+                                                                break;\r
+                                                              case TIME_SECOND_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 2;\r
+                                                                break;\r
+                                                              default:\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");\r
+                                                                break;\r
+                                                              }\r
+                                                            } else {\r
+                                                              if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");\r
+                                                              }\r
+                                                              if (VarType != EFI_IFR_TYPE_UNDEFINED) {\r
+                                                                Info.mVarType = VarType;\r
+                                                                _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");\r
+                                                                Info.mVarTotalSize = VarSize;\r
+                                                              }\r
+                                                              _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");\r
+                                                              if (VarSize != Info.mVarTotalSize) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");\r
+                                                              }\r
+                                                            }\r
+                                                            CIfrGet GObj(L->getLine()); \r
+                                                            _SAVE_OPHDR_COND (GObj, ($ExpOpCount == 0), L->getLine()); \r
+                                                            GObj.SetVarInfo (&Info); \r
+                                                            delete VarIdStr; \r
+                                                            $ExpOpCount++;\r
+                                                          }\r
+                                                       >>\r
+  ;\r
+\r
 vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
     L1:True                                            << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>\r
   | L2:False                                           << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>\r
@@ -3040,6 +3183,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   | unintExp[$RootLevel, $ExpOpCount]\r
   | toupperExp[$RootLevel, $ExpOpCount]\r
   | tolwerExp[$RootLevel, $ExpOpCount]\r
+  | setExp[$RootLevel, $ExpOpCount]\r
   ;\r
 \r
 lengthExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -3100,6 +3244,78 @@ tolwerExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                        << { CIfrToLower TLObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
+setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
+  <<\r
+     EFI_VARSTORE_INFO Info;\r
+     CHAR8             *VarIdStr = NULL;\r
+     EFI_QUESTION_ID   QId = EFI_QUESTION_ID_INVALID;\r
+     UINT32            Mask = 0;\r
+     EFI_QUESION_TYPE  QType = QUESTION_NORMAL;\r
+     UINT8             VarType = EFI_IFR_TYPE_UNDEFINED;\r
+     UINT32            VarSize = 0;\r
+     Info.mVarStoreId = 0;\r
+  >>\r
+  L:Set\r
+  "\("\r
+     vfrStorageVarId[Info, VarIdStr, FALSE]\r
+     {"\|" FLAG "=" numericVarStoreType [VarType] }\r
+     "," vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] \r
+  "\)"\r
+                                                       << \r
+                                                          {\r
+                                                            if (Info.mVarStoreId == 0) {\r
+                                                              // support Date/Time question\r
+                                                              mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);\r
+                                                              if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");\r
+                                                              }\r
+                                                              if (QType == QUESTION_DATE) {\r
+                                                                Info.mVarType = EFI_IFR_TYPE_DATE;\r
+                                                              } else if (QType == QUESTION_TIME) {\r
+                                                                Info.mVarType = EFI_IFR_TYPE_TIME;\r
+                                                              }\r
+                                                              switch (Mask) {\r
+                                                              case DATE_YEAR_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 0;\r
+                                                                break;\r
+                                                              case DATE_DAY_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 3;\r
+                                                                break;\r
+                                                              case TIME_HOUR_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 0;\r
+                                                                break;\r
+                                                              case TIME_MINUTE_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 1;\r
+                                                                break;\r
+                                                              case TIME_SECOND_BITMASK:\r
+                                                                Info.mInfo.mVarOffset = 2;\r
+                                                                break;\r
+                                                              default:\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");\r
+                                                                break;\r
+                                                              }\r
+                                                            } else {\r
+                                                              if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");\r
+                                                              }\r
+                                                              if (VarType != EFI_IFR_TYPE_UNDEFINED) {\r
+                                                                Info.mVarType = VarType;\r
+                                                                _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");\r
+                                                                Info.mVarTotalSize = VarSize;\r
+                                                              }\r
+                                                              _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");\r
+                                                              if (VarSize != Info.mVarTotalSize) {\r
+                                                                _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");\r
+                                                              }\r
+                                                            }\r
+                                                            CIfrSet TSObj(L->getLine()); \r
+                                                            TSObj.SetVarInfo (&Info); \r
+                                                            delete VarIdStr; \r
+                                                            $ExpOpCount++;\r
+                                                          }\r
+                                                       >>\r
+  ;\r
+\r
 vfrExpressionTernaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
     conditionalExp[$RootLevel, $ExpOpCount]\r
   | findExp[$RootLevel, $ExpOpCount]\r
@@ -3175,6 +3391,20 @@ spanExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   "\)"                                                 << { CIfrSpan SObj(S->getLine()); SObj.SetFlags(Flags); $ExpOpCount++; } >>\r
   ;\r
 \r
+vfrExpressionMap [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
+  L:Map                                                   \r
+  "\(" \r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]  \r
+  ":"                                                     << { CIfrMap MObj(L->getLine()); } >>\r
+  (\r
+    vfrStatementExpression[0]\r
+    ","\r
+    vfrStatementExpression[0]\r
+    ";"\r
+  ) *\r
+  E:"\)"                                                  << { CIfrEnd EObj; EObj.SetLineNo(E->getLine()); $ExpOpCount++; } >>\r
+  ;\r
+\r
 spanFlags [UINT8 & Flags] :\r
     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
   | "LAST_NON_MATCH"                                   << $Flags |= 0x00; >>\r
@@ -3199,8 +3429,9 @@ private:
   CVfrQuestionDB      mCVfrQuestionDB;\r
   CVfrRulesDB         mCVfrRulesDB;\r
 \r
-  CIfrOpHeader        *mCIfrOpHdr;\r
-  UINT32              mCIfrOpHdrLineNo;\r
+  CIfrOpHeader *      mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];\r
+  UINT32              mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];\r
+  UINT8               mCIfrOpHdrIndex;\r
   VOID                _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0);\r
   VOID                _CLEAR_SAVED_OPHDR (VOID);\r
   BOOLEAN             _SET_SAVED_OPHDR_SCOPE (VOID);\r
@@ -3273,11 +3504,11 @@ EfiVfrParser::_SAVE_OPHDR_COND (
   )\r
 {\r
   if (Cond == TRUE) {\r
-    if (mCIfrOpHdr != NULL) {\r
+    if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {\r
       return ;\r
     }\r
-    mCIfrOpHdr       = new CIfrOpHeader(OpHdr);\r
-    mCIfrOpHdrLineNo = LineNo;\r
+    mCIfrOpHdr[mCIfrOpHdrIndex]       = new CIfrOpHeader(OpHdr);\r
+    mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;\r
   }\r
 }\r
 \r
@@ -3286,8 +3517,8 @@ EfiVfrParser::_CLEAR_SAVED_OPHDR (
   VOID\r
   )\r
 {\r
-  mCIfrOpHdr       = NULL;\r
-  mCIfrOpHdrLineNo = 0;\r
+  mCIfrOpHdr[mCIfrOpHdrIndex]       = NULL;\r
+  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;\r
 }\r
 \r
 BOOLEAN\r
@@ -3295,10 +3526,11 @@ EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
   VOID\r
   )\r
 {\r
-  if (mCIfrOpHdr != NULL) {\r
-    mCIfrOpHdr->SetScope (1);\r
+  if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {\r
+    mCIfrOpHdr[mCIfrOpHdrIndex]->SetScope (1);\r
     return TRUE;\r
   }\r
+\r
   //\r
   // IfrOpHdr is not set, FALSE is return.\r
   //\r
index 41ecd51..cae0479 100644 (file)
@@ -2260,6 +2260,7 @@ SVfrQuestionNode::SVfrQuestionNode (
   mQuestionId = EFI_QUESTION_ID_INVALID;\r
   mBitMask    = BitMask;\r
   mNext       = NULL;\r
+  mQtype      = QUESTION_NORMAL;\r
 \r
   if (Name == NULL) {\r
     mName = new CHAR8[strlen ("$DEFAULT") + 1];\r
@@ -2429,6 +2430,9 @@ CVfrQuestionDB::RegisterOldDateQuestion (
   pNode[0]->mQuestionId = QuestionId;\r
   pNode[1]->mQuestionId = QuestionId;\r
   pNode[2]->mQuestionId = QuestionId;\r
+  pNode[0]->mQtype      = QUESTION_DATE;\r
+  pNode[1]->mQtype      = QUESTION_DATE;\r
+  pNode[2]->mQtype      = QUESTION_DATE;\r
   pNode[0]->mNext       = pNode[1];\r
   pNode[1]->mNext       = pNode[2];\r
   pNode[2]->mNext       = mQuestionList;\r
@@ -2505,6 +2509,9 @@ CVfrQuestionDB::RegisterNewDateQuestion (
   pNode[0]->mQuestionId = QuestionId;\r
   pNode[1]->mQuestionId = QuestionId;\r
   pNode[2]->mQuestionId = QuestionId;\r
+  pNode[0]->mQtype      = QUESTION_DATE;\r
+  pNode[1]->mQtype      = QUESTION_DATE;\r
+  pNode[2]->mQtype      = QUESTION_DATE;\r
   pNode[0]->mNext       = pNode[1];\r
   pNode[1]->mNext       = pNode[2];\r
   pNode[2]->mNext       = mQuestionList;\r
@@ -2571,6 +2578,9 @@ CVfrQuestionDB::RegisterOldTimeQuestion (
   pNode[0]->mQuestionId = QuestionId;\r
   pNode[1]->mQuestionId = QuestionId;\r
   pNode[2]->mQuestionId = QuestionId;\r
+  pNode[0]->mQtype      = QUESTION_TIME;\r
+  pNode[1]->mQtype      = QUESTION_TIME;\r
+  pNode[2]->mQtype      = QUESTION_TIME;\r
   pNode[0]->mNext       = pNode[1];\r
   pNode[1]->mNext       = pNode[2];\r
   pNode[2]->mNext       = mQuestionList;\r
@@ -2647,6 +2657,9 @@ CVfrQuestionDB::RegisterNewTimeQuestion (
   pNode[0]->mQuestionId = QuestionId;\r
   pNode[1]->mQuestionId = QuestionId;\r
   pNode[2]->mQuestionId = QuestionId;\r
+  pNode[0]->mQtype      = QUESTION_TIME;\r
+  pNode[1]->mQtype      = QUESTION_TIME;\r
+  pNode[2]->mQtype      = QUESTION_TIME;\r
   pNode[0]->mNext       = pNode[1];\r
   pNode[1]->mNext       = pNode[2];\r
   pNode[2]->mNext       = mQuestionList;\r
@@ -2720,13 +2733,17 @@ CVfrQuestionDB::GetQuestionId (
   IN  CHAR8             *Name,\r
   IN  CHAR8             *VarIdStr,\r
   OUT EFI_QUESTION_ID   &QuestionId,\r
-  OUT UINT32            &BitMask\r
+  OUT UINT32            &BitMask,\r
+  OUT EFI_QUESION_TYPE  *QType\r
   )\r
 {\r
   SVfrQuestionNode *pNode;\r
 \r
   QuestionId = EFI_QUESTION_ID_INVALID;\r
   BitMask    = 0x00000000;\r
+  if (QType != NULL) {\r
+    *QType = QUESTION_NORMAL;\r
+  }\r
 \r
   if ((Name == NULL) && (VarIdStr == NULL)) {\r
     return ;\r
@@ -2747,6 +2764,9 @@ CVfrQuestionDB::GetQuestionId (
 \r
     QuestionId = pNode->mQuestionId;\r
     BitMask    = pNode->mBitMask;\r
+    if (QType != NULL) {\r
+      *QType     = pNode->mQtype;\r
+    }\r
     break;\r
   }\r
 \r
index 8cfb8c8..27ec3d9 100644 (file)
@@ -2,7 +2,7 @@
   \r
   Vfr common library functions.\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2010, 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
@@ -332,6 +332,7 @@ struct SVfrQuestionNode {
   EFI_QUESTION_ID           mQuestionId;\r
   UINT32                    mBitMask;\r
   SVfrQuestionNode          *mNext;\r
+  EFI_QUESION_TYPE          mQtype;\r
 \r
   SVfrQuestionNode (IN CHAR8 *, IN CHAR8 *, IN UINT32 BitMask = 0);\r
   ~SVfrQuestionNode ();\r
@@ -358,7 +359,7 @@ public:
   VOID                RegisterOldTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);\r
   VOID                RegisterNewTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);\r
   EFI_VFR_RETURN_CODE UpdateQuestionId (IN EFI_QUESTION_ID, IN EFI_QUESTION_ID);\r
-  VOID                GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &);\r
+  VOID                GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &, OUT EFI_QUESION_TYPE *QType = NULL);\r
   EFI_VFR_RETURN_CODE FindQuestion (IN EFI_QUESTION_ID);\r
   EFI_VFR_RETURN_CODE FindQuestion (IN CHAR8 *);\r
   VOID                PrintAllQuestion (IN VOID);\r