Update VfrCompiler to parse Form classguid.
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 17 Apr 2009 05:26:30 +0000 (05:26 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 17 Apr 2009 05:26:30 +0000 (05:26 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1550 7335b38e-4728-0410-8992-fb3ffe349368

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

index b99d30c..a127c95 100644 (file)
 #ifndef __UEFI_INTERNAL_FORMREPRESENTATION_H__\r
 #define __UEFI_INTERNAL_FORMREPRESENTATION_H__\r
 \r
+\r
+#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \\r
+  { 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }\r
+\r
 //\r
 // The following types are currently defined:\r
 //\r
@@ -741,6 +745,8 @@ typedef struct _EFI_IFR_FORM_SET {
   EFI_GUID                 Guid;\r
   EFI_STRING_ID            FormSetTitle;\r
   EFI_STRING_ID            Help;\r
+  UINT8                    Flags;\r
+  EFI_GUID                 ClassGuid[1];\r
 } EFI_IFR_FORM_SET;\r
 \r
 typedef struct _EFI_IFR_END {\r
index 3fb865b..654daed 100644 (file)
@@ -1226,7 +1226,7 @@ static struct {
   { sizeof (EFI_IFR_DATE), 1 },                // EFI_IFR_DATE_OP\r
   { sizeof (EFI_IFR_TIME), 1 },                // EFI_IFR_TIME_OP\r
   { sizeof (EFI_IFR_STRING), 1 },              // EFI_IFR_STRING_OP\r
-  { sizeof (EFI_IFR_REFRESH), 1 },             // EFI_IFR_REFRESH_OP\r
+  { sizeof (EFI_IFR_REFRESH), 0 },             // EFI_IFR_REFRESH_OP\r
   { sizeof (EFI_IFR_DISABLE_IF), 1 },          // EFI_IFR_DISABLE_IF_OP - 0x1E\r
   { 0, 0 },                                    // 0x1F\r
   { sizeof (EFI_IFR_TO_LOWER), 0 },            // EFI_IFR_TO_LOWER_OP - 0x20\r
index 58b1a8b..aec2286 100644 (file)
@@ -444,10 +444,11 @@ private:
   EFI_IFR_FORM_SET *mFormSet;\r
 \r
 public:\r
-  CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),\r
-                   CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {\r
+  CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),\r
+                   CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {\r
     mFormSet->Help         = EFI_STRING_ID_INVALID;\r
     mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;\r
+    mFormSet->Flags        = 0;\r
     memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));\r
   }\r
 \r
@@ -462,6 +463,14 @@ public:
   VOID SetHelp (IN EFI_STRING_ID Help) {\r
     mFormSet->Help = Help;\r
   }\r
+\r
+  VOID SetClassGuid (IN EFI_GUID *Guid) {\r
+    memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));\r
+  }\r
+\r
+  UINT8 GetFlags() {\r
+    return mFormSet->Flags;\r
+  }\r
 };\r
 \r
 class CIfrEnd : public CIfrObj, public CIfrOpHeader {\r
index d0c7154..0ba4586 100644 (file)
@@ -193,6 +193,7 @@ VfrParserStart (
 #token OptionOnlyFlag("OPTIONS_ONLY")           "OPTIONS_ONLY"\r
 #token Class("class")                           "class"\r
 #token Subclass("subclass")                     "subclass"\r
+#token ClassGuid("classguid")                   "classguid"\r
 #token TypeDef("typedef")                       "typedef"\r
 #token Restore("restore")                       "restore"\r
 #token Save("save")                             "save"\r
@@ -462,26 +463,65 @@ guidDefinition [EFI_GUID &Guid] :
 vfrFormSetDefinition :\r
   <<\r
      EFI_GUID    Guid;\r
-     CIfrFormSet FSObj;\r
+     EFI_GUID    DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;\r
+     EFI_GUID    ClassGuid1, ClassGuid2, ClassGuid3;\r
+     UINT8       ClassGuidNum = 0;\r
+     CIfrFormSet *FSObj = NULL;\r
      UINT16      C, SC;\r
   >>\r
-  L:FormSet                                         << SET_LINE_INFO (FSObj, L); >>\r
-  Uuid "=" guidDefinition[Guid] ","                 <<\r
-                                                       FSObj.SetGuid (&Guid);\r
-                                                       //\r
-                                                       // for framework vfr to store formset guid used by varstore and efivarstore\r
-                                                       //\r
-                                                       if (mCompatibleMode) {\r
-                                                         memcpy (&mFormsetGuid, &Guid, sizeof (EFI_GUID));\r
-                                                       }\r
+  L:FormSet\r
+  Uuid "=" guidDefinition[Guid] ","\r
+  Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","\r
+  Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","\r
+  {\r
+    ClassGuid "=" guidDefinition[ClassGuid1]        << ++ClassGuidNum; >>\r
+                  {\r
+                   "\|" guidDefinition[ClassGuid2]  << ++ClassGuidNum; >>\r
+                  }\r
+                  {\r
+                   "\|" guidDefinition[ClassGuid3]  << ++ClassGuidNum; >>\r
+                  }\r
+                  ","\r
+  }\r
+                                                    <<\r
+                                                      switch (ClassGuidNum) {\r
+                                                      case 0:\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
+                                                        FSObj->SetClassGuid(&DefaultClassGuid);\r
+                                                        break;\r
+                                                      case 1:\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
+                                                        FSObj->SetClassGuid(&ClassGuid1);\r
+                                                        break;\r
+                                                      case 2:\r
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 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
+                                                        FSObj->SetClassGuid(&ClassGuid1);\r
+                                                        FSObj->SetClassGuid(&ClassGuid2);\r
+                                                        FSObj->SetClassGuid(&ClassGuid3);\r
+                                                        break;\r
+                                                      }\r
+\r
+                                                      SET_LINE_INFO (*FSObj, L);\r
+                                                      FSObj->SetGuid (&Guid);\r
+                                                      //\r
+                                                      // for framework vfr to store formset guid used by varstore and efivarstore\r
+                                                      //\r
+                                                      if (mCompatibleMode) {\r
+                                                        memcpy (&mFormsetGuid, &Guid, sizeof (EFI_GUID));\r
+                                                      }\r
+                                                      FSObj->SetFormSetTitle (_STOSID(S1->getText()));\r
+                                                      FSObj->SetHelp (_STOSID(S2->getText()));\r
                                                     >>\r
-  Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","  << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>\r
-  Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","  << FSObj.SetHelp (_STOSID(S2->getText())); >>\r
   {\r
-    FC:Class "=" classDefinition[C] ","                << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>\r
+    FC:Class "=" classDefinition[C] ","             << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>\r
   }\r
   {\r
-    FSC:Subclass "=" subclassDefinition[SC] ","         << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>\r
+    FSC:Subclass "=" subclassDefinition[SC] ","     << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>\r
   }\r
                                                     <<\r
                                                        _DeclareStandardDefaultStorage (GET_LINENO (L));\r
@@ -494,7 +534,7 @@ vfrFormSetDefinition :
                                                         //\r
                                                         _DeclareDefaultFrameworkVarStore (GET_LINENO(E));\r
                                                       }\r
-                                                      CRT_END_OP (E);\r
+                                                      CRT_END_OP (E); if (FSObj != NULL) delete FSObj;\r
                                                     >>\r
   ";"\r
   ;\r
@@ -776,7 +816,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
      CHAR8                 *SName       = NULL;\r
      CHAR8                 *TName       = NULL;\r
      EFI_VFR_RETURN_CODE   VfrReturnCode = VFR_RETURN_SUCCESS;\r
-     EFI_IFR_TYPE_VALUE    Dummy        = {0};\r
+     EFI_IFR_TYPE_VALUE    Dummy        = gZeroEfiIfrTypeValue;\r
   >>\r
   (\r
     SN1:StringIdentifier                            << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>\r
@@ -1034,7 +1074,7 @@ vfrStatementRules :
 vfrStatementDefault :\r
   <<\r
      BOOLEAN               IsExp         = FALSE;\r
-     EFI_IFR_TYPE_VALUE    Val;\r
+     EFI_IFR_TYPE_VALUE    Val = gZeroEfiIfrTypeValue;\r
      CIfrDefault           DObj;\r
      EFI_DEFAULT_ID        DefaultId     = EFI_HII_DEFAULT_CLASS_STANDARD;\r
      CHAR8                 *VarStoreName = NULL;\r
@@ -1359,7 +1399,7 @@ vfrStatementBooleanType :
 vfrStatementCheckBox :\r
   <<\r
      CIfrCheckBox       CBObj;\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
      CHAR8              *VarStoreName = NULL;\r
      UINT32             DataTypeSize;\r
   >>\r
@@ -2113,7 +2153,7 @@ vfrStatementOptions :
 \r
 vfrStatementOneOfOption :\r
   <<\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
      CIfrOneOfOption    OOOObj;\r
      CHAR8              *VarStoreName = NULL;\r
   >>\r
index b167d1f..df17922 100644 (file)
@@ -1841,7 +1841,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
   CHAR8                 NewReqElt[128] = {'\0',};\r
   CHAR8                 *OldReqElt = NULL;\r
   SVfrVarStorageNode    *pNode = NULL;\r
-  EFI_IFR_TYPE_VALUE    Value;\r
+  EFI_IFR_TYPE_VALUE    Value = gZeroEfiIfrTypeValue;\r
 \r
   for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {\r
     if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {\r