Enhance VfrCompiler to handle framework vfr file, and print more debug information...
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 12 Aug 2008 09:48:20 +0000 (09:48 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 12 Aug 2008 09:48:20 +0000 (09:48 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1302 7335b38e-4728-0410-8992-fb3ffe349368

Source/C/VfrCompile/VfrCompiler.cpp
Source/C/VfrCompile/VfrCompiler.h
Source/C/VfrCompile/VfrError.cpp
Source/C/VfrCompile/VfrError.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 2620576..30b9071 100644 (file)
@@ -18,8 +18,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "string.h"\r
 //#include "process.h"\r
 #include "VfrCompiler.h"\r
+#include "CommonLib.h"\r
 #include "EfiUtilityMsgs.h"\r
 \r
+PACKAGE_DATA  gCBuffer;\r
+PACKAGE_DATA  gRBuffer;\r
+\r
+VOID \r
+CVfrCompiler::DebugError () {\r
+  Error (NULL, 0, 0001, "Error parsing vfr file", " %s", mOptions.VfrFileName);\r
+  //_asm int 3;\r
+}\r
+\r
 VOID\r
 CVfrCompiler::SET_RUN_STATUS (\r
   IN COMPILER_RUN_STATUS Status\r
@@ -58,16 +68,17 @@ CVfrCompiler::OptionInitialization (
   mOptions.IncludePaths                  = NULL;\r
   mOptions.SkipCPreprocessor             = FALSE;\r
   mOptions.CPreprocessorOptions          = NULL;\r
+  mOptions.CompatibleMode                = FALSE;\r
 \r
   for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {\r
-    if ((strcmp(Argv[Index], "-h") == 0) || (strcmp(Argv[Index], "--help") == 0)) {\r
+    if ((stricmp(Argv[Index], "-h") == 0) || (stricmp(Argv[Index], "--help") == 0)) {\r
       Usage ();\r
       SET_RUN_STATUS (STATUS_DEAD);\r
       return;\r
-    } else if (strcmp(Argv[Index], "-l") == 0) {\r
+    } else if (stricmp(Argv[Index], "-l") == 0) {\r
       mOptions.CreateRecordListFile = TRUE;\r
       gCIfrRecordInfoDB.TurnOn ();\r
-    } else if (strcmp(Argv[Index], "-i") == 0) {\r
+    } else if (stricmp(Argv[Index], "-i") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
         Error (NULL, 0, 1001, "Missing option", "-i missing path argument"); \r
@@ -75,10 +86,10 @@ CVfrCompiler::OptionInitialization (
       }\r
 \r
       AppendIncludePath(Argv[Index]);\r
-    } else if (strcmp(Argv[Index], "-o") == 0 || strcmp(Argv[Index], "--output-directory") == 0) {\r
+    } else if (stricmp(Argv[Index], "-o") == 0 || stricmp(Argv[Index], "--output-directory") == 0 || stricmp(Argv[Index], "-od") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
-        Error (NULL, 0, 1001, "Missing option", "-od missing output directory name");\r
+        Error (NULL, 0, 1001, "Missing option", "-o missing output directory name");\r
         goto Fail;\r
       }\r
       strcpy (mOptions.OutputDirectory, Argv[Index]);\r
@@ -91,13 +102,12 @@ CVfrCompiler::OptionInitialization (
           strcat (mOptions.OutputDirectory, "\\");\r
         }\r
       }\r
-      printf("Debug! %s\n", mOptions.OutputDirectory);\r
-    } else if (strcmp(Argv[Index], "-b") == 0 || strcmp(Argv[Index], "--create-ifr-package") == 0) {\r
+      DebugMsg (NULL, 0, 9, "Output Directory", mOptions.OutputDirectory);\r
+    } else if (stricmp(Argv[Index], "-b") == 0 || stricmp(Argv[Index], "--create-ifr-package") == 0 || stricmp(Argv[Index], "-ibin") == 0) {\r
       mOptions.CreateIfrPkgFile = TRUE;\r
-    } else if (strcmp(Argv[Index], "--no-strings") == 0) {\r
-    } else if (strcmp(Argv[Index], "-n") == 0 || strcmp(Argv[Index], "--no-pre-processing") == 0) {\r
+    } else if (stricmp(Argv[Index], "-n") == 0 || stricmp(Argv[Index], "--no-pre-processing") == 0 || stricmp(Argv[Index], "-nopp") == 0) {\r
       mOptions.SkipCPreprocessor = TRUE;\r
-    } else if (strcmp(Argv[Index], "-f") == 0 || strcmp(Argv[Index], "--pre-processing-flag") == 0) {\r
+    } else if (stricmp(Argv[Index], "-f") == 0 || stricmp(Argv[Index], "--pre-processing-flag") == 0 || stricmp(Argv[Index], "-ppflag") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
         Error (NULL, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");\r
@@ -105,6 +115,8 @@ CVfrCompiler::OptionInitialization (
       }\r
 \r
       AppendCPreprocessorOptions (Argv[Index]);\r
+    } else if (stricmp(Argv[Index], "-c") == 0 || stricmp(Argv[Index], "--compatible-framework") == 0) {\r
+      mOptions.CompatibleMode = TRUE;\r
     } else {\r
       Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);\r
       Usage ();\r
@@ -373,6 +385,8 @@ CVfrCompiler::Usage (
     "                 do not preprocessing input file",\r
     "  -f, --pre-processing-flag",\r
     "                 Preprocessing flags",\r
+    "  -c, --compatible-framework",\r
+    "                 compatible framework vfr file",\r
     NULL\r
     };\r
   for (Index = 0; Help[Index] != NULL; Index++) {\r
@@ -446,7 +460,7 @@ Fail:
   delete PreProcessCmd;\r
 }\r
 \r
-extern UINT8 VfrParserStart (IN FILE *);\r
+extern UINT8 VfrParserStart (IN FILE *, IN BOOLEAN);\r
 \r
 VOID\r
 CVfrCompiler::Compile (\r
@@ -469,7 +483,7 @@ CVfrCompiler::Compile (
     goto Fail;\r
   }\r
 \r
-  if (VfrParserStart (pInFile) != 0) {\r
+  if (VfrParserStart (pInFile, mOptions.CompatibleMode) != 0) {\r
     goto Fail;\r
   }\r
 \r
@@ -493,6 +507,69 @@ Fail:
   }\r
 }\r
 \r
+VOID\r
+CVfrCompiler::AdjustBin (\r
+  VOID\r
+  )\r
+{\r
+  EFI_VFR_RETURN_CODE Status;\r
+  //\r
+  // Check Binary Code consistent between Form and IfrRecord\r
+  //\r
+\r
+  //\r
+  // Get Package Data and IfrRecord Data\r
+  //\r
+  gCFormPkg.BuildPkg (gCBuffer);\r
+  gCIfrRecordInfoDB.IfrRecordOutput (gRBuffer); \r
+\r
+  //\r
+  // Compare Form and Record data\r
+  //\r
+  if (gCBuffer.Buffer != NULL && gRBuffer.Buffer != NULL) {\r
+    UINT32 Index;\r
+    if (gCBuffer.Size != gRBuffer.Size) {\r
+      Error (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);\r
+    }\r
+    for (Index = 0; Index < gCBuffer.Size; Index ++) {\r
+      if (gCBuffer.Buffer[Index] != gRBuffer.Buffer[Index]) {\r
+        break;\r
+      }\r
+    }\r
+    if (Index != gCBuffer.Size) {\r
+      Error (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);\r
+    }\r
+    DebugMsg (NULL, 0, 9, "IFR Buffer", "Form Buffer same to Record Buffer and Size is 0x%X", Index);\r
+  } else if (gCBuffer.Buffer == NULL && gRBuffer.Buffer == NULL) {\r
+    //ok\r
+  } else {\r
+    Error (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);\r
+  }\r
+\r
+  //\r
+  // For UEFI mode, not do OpCode Adjust\r
+  //\r
+  if (mOptions.CompatibleMode) {\r
+    //\r
+    // Adjust Opcode to be compatible with framework vfr\r
+    //\r
+    Status = gCIfrRecordInfoDB.IfrRecordAdjust ();\r
+    if (Status != VFR_RETURN_SUCCESS) {\r
+      //\r
+      // Record List Adjust Failed\r
+      //\r
+      SET_RUN_STATUS (STATUS_FAILED);\r
+      return;\r
+    }\r
+    //\r
+    // Re get the IfrRecord Buffer.\r
+    //\r
+    gCIfrRecordInfoDB.IfrRecordOutput (gRBuffer); \r
+  }\r
+\r
+  return;\r
+}\r
+\r
 VOID\r
 CVfrCompiler::GenBinary (\r
   VOID\r
@@ -509,7 +586,7 @@ CVfrCompiler::GenBinary (
       Error (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);\r
       goto Fail;\r
     }\r
-    if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {\r
+    if (gCFormPkg.BuildPkg (pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {\r
       fclose (pFile);\r
       goto Fail;\r
     }\r
@@ -517,6 +594,7 @@ CVfrCompiler::GenBinary (
   }\r
 \r
   SET_RUN_STATUS (STATUS_GENBINARY);\r
+\r
   return;\r
 \r
 Fail:\r
@@ -557,7 +635,7 @@ CVfrCompiler::GenCFile (
 \r
   gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName);\r
 \r
-  if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile) != VFR_RETURN_SUCCESS) {\r
+  if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {\r
     fclose (pFile);\r
     goto Fail;\r
   }\r
@@ -609,6 +687,9 @@ CVfrCompiler::GenRecordListFile (
         gCIfrRecordInfoDB.IfrRecordOutput (pOutFile, LineNo);\r
       }\r
     }\r
+    \r
+    fprintf (pOutFile, "\n//\n// All Opcode Record List \n//\n");\r
+    gCIfrRecordInfoDB.IfrRecordOutput (pOutFile, 0);\r
 \r
     fclose (pOutFile);\r
     fclose (pInFile);\r
@@ -631,6 +712,7 @@ main (
   \r
   Compiler.PreProcess();\r
   Compiler.Compile();\r
+  Compiler.AdjustBin();\r
   Compiler.GenBinary();\r
   Compiler.GenCFile();\r
   Compiler.GenRecordListFile ();\r
@@ -640,6 +722,14 @@ main (
     return 2;\r
   }\r
 \r
-  return 0;\r
+  if (gCBuffer.Buffer != NULL) {\r
+    delete gCBuffer.Buffer;\r
+  }\r
+  \r
+  if (gRBuffer.Buffer != NULL) {\r
+    delete gRBuffer.Buffer;\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
 }\r
 \r
index c40e5d6..32d2e54 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-\r
+  \r
   VfrCompiler internal defintions.\r
 \r
-Copyright (c) 2004 - 2008, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2008, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
@@ -22,7 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "VfrUtilityLib.h"\r
 \r
 #define PROGRAM_NAME                       "VfrCompile"\r
-#define VFR_COMPILER_VERSION               "1.90 (UEFI 2.1)"\r
+#define VFR_COMPILER_VERSION               "1.95 (UEFI 2.1)"\r
 \r
 //\r
 // This is how we invoke the C preprocessor on the VFR source file\r
@@ -53,6 +53,7 @@ typedef struct {
   CHAR8   *IncludePaths;\r
   bool    SkipCPreprocessor;\r
   CHAR8   *CPreprocessorOptions;\r
+  BOOLEAN CompatibleMode;\r
 } OPTIONS;\r
 \r
 typedef enum {\r
@@ -97,9 +98,11 @@ public:
 \r
   VOID                PreProcess (VOID);\r
   VOID                Compile (VOID);\r
+  VOID                AdjustBin (VOID);\r
   VOID                GenBinary (VOID);\r
   VOID                GenCFile (VOID);\r
   VOID                GenRecordListFile (VOID);\r
+  VOID                DebugError (VOID);\r
 };\r
 \r
 #endif\r
index 6021de3..58b15aa 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-\r
+  \r
   VfrCompiler error handler.\r
 \r
-Copyright (c) 2004 - 2008, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2008, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
@@ -38,8 +38,8 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
   { VFR_RETURN_EFIVARSTORE_USE_ERROR, "can not use the efi varstore like this" },\r
   { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, "unsupport efi varstore size should be <= 8 bytes" },\r
   { VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },\r
-  { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },\r
-  { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },\r
+  { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" }, \r
+  { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" }, \r
   { VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },\r
   { VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},\r
   { VFR_RETURN_DEFAULT_VALUE_REDEFINED, "Default value re-defined with different value"},\r
@@ -89,7 +89,7 @@ CVfrErrorHandle::SetInputFile (
 }\r
 \r
 SVfrFileScopeRecord::SVfrFileScopeRecord (\r
-  IN CHAR8    *Record,\r
+  IN CHAR8    *Record, \r
   IN UINT32   LineNum\r
   )\r
 {\r
@@ -130,7 +130,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
 \r
 VOID\r
 CVfrErrorHandle::ParseFileScopeRecord (\r
-  IN CHAR8     *Record,\r
+  IN CHAR8     *Record, \r
   IN UINT32    WholeScopeLine\r
   )\r
 {\r
index a2aa3fa..6e26611 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-\r
+  \r
   VfrCompiler Error definition\r
 \r
-Copyright (c) 2004 - 2008, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2008, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
index 842c699..06aa552 100644 (file)
@@ -279,12 +279,47 @@ CFormPkg::BuildPkgHdr (
 \r
   (*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;\r
   (*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);\r
+\r
+  return VFR_RETURN_SUCCESS;\r
+}\r
+\r
+EFI_VFR_RETURN_CODE\r
+CFormPkg::BuildPkg (\r
+  OUT PACKAGE_DATA &TBuffer\r
+  )\r
+{\r
+  \r
+  CHAR8  *Temp;\r
+  UINT32 Size;\r
+  CHAR8  Buffer[1024];\r
+\r
+  if (TBuffer.Buffer != NULL) {\r
+    delete TBuffer.Buffer;\r
+  }\r
+\r
+  TBuffer.Size = mPkgLength;\r
+  TBuffer.Buffer = NULL;\r
+  if (TBuffer.Size != 0) {\r
+    TBuffer.Buffer = new CHAR8[TBuffer.Size];\r
+  } else {\r
+    return VFR_RETURN_SUCCESS;\r
+  }\r
+\r
+  Temp = TBuffer.Buffer;\r
+  Open ();\r
+  while ((Size = Read (Buffer, 1024)) != 0) {\r
+    memcpy (Temp, Buffer, Size);\r
+    Temp += Size;\r
+  }\r
+  Close ();\r
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
+\r
 EFI_VFR_RETURN_CODE\r
 CFormPkg::BuildPkg (\r
-  IN FILE  *Output\r
+  IN FILE  *Output,\r
+  IN PACKAGE_DATA *PkgData\r
   )\r
 {\r
   EFI_VFR_RETURN_CODE     Ret;\r
@@ -301,12 +336,16 @@ CFormPkg::BuildPkg (
   }\r
   fwrite (PkgHdr, sizeof (EFI_HII_PACKAGE_HEADER), 1, Output);\r
   delete PkgHdr;\r
-\r
-  Open ();\r
-  while ((Size = Read (Buffer, 1024)) != 0) {\r
-    fwrite (Buffer, Size, 1, Output);\r
+  \r
+  if (PkgData == NULL) {\r
+    Open ();\r
+    while ((Size = Read (Buffer, 1024)) != 0) {\r
+      fwrite (Buffer, Size, 1, Output);\r
+    }\r
+    Close ();\r
+  } else {\r
+    fwrite (PkgData->Buffer, PkgData->Size, 1, Output);\r
   }\r
-  Close ();\r
 \r
   return VFR_RETURN_SUCCESS;\r
 }\r
@@ -367,7 +406,8 @@ CFormPkg::_WRITE_PKG_END (
 EFI_VFR_RETURN_CODE \r
 CFormPkg::GenCFile (\r
   IN CHAR8 *BaseName,\r
-  IN FILE *pFile\r
+  IN FILE *pFile,\r
+  IN PACKAGE_DATA *PkgData\r
   )\r
 {\r
   EFI_VFR_RETURN_CODE          Ret;\r
@@ -395,16 +435,29 @@ CFormPkg::GenCFile (
   PkgLength = sizeof (EFI_HII_PACKAGE_HEADER);\r
 \r
   fprintf (pFile, "\n\n  // PACKAGE DATA\n");\r
-  Open ();\r
-  while ((ReadSize = Read ((CHAR8 *)Buffer, BYTES_PRE_LINE * 8)) != 0) {\r
-    PkgLength += ReadSize;\r
-    if (PkgLength < PkgHdr->Length) {\r
-      _WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, "  ", Buffer, ReadSize);\r
+  \r
+  if (PkgData == NULL) {\r
+    Open ();\r
+    while ((ReadSize = Read ((CHAR8 *)Buffer, BYTES_PRE_LINE * 8)) != 0) {\r
+      PkgLength += ReadSize;\r
+      if (PkgLength < PkgHdr->Length) {\r
+        _WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, "  ", Buffer, ReadSize);\r
+      } else {\r
+        _WRITE_PKG_END (pFile, BYTES_PRE_LINE, "  ", Buffer, ReadSize);\r
+      }\r
+    }\r
+    Close ();\r
+  } else {\r
+    if (PkgData->Size % BYTES_PRE_LINE != 0) {\r
+      PkgLength = PkgData->Size - (PkgData->Size % BYTES_PRE_LINE);\r
+      _WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, "  ", PkgData->Buffer, PkgLength);\r
+      _WRITE_PKG_END (pFile, BYTES_PRE_LINE, "  ", PkgData->Buffer + PkgLength, PkgData->Size % BYTES_PRE_LINE);\r
     } else {\r
-      _WRITE_PKG_END (pFile, BYTES_PRE_LINE, "  ", Buffer, ReadSize);\r
+      PkgLength = PkgData->Size - BYTES_PRE_LINE;\r
+      _WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, "  ", PkgData->Buffer, PkgLength);\r
+      _WRITE_PKG_END (pFile, BYTES_PRE_LINE, "  ", PkgData->Buffer + PkgLength, BYTES_PRE_LINE);\r
     }\r
   }\r
-  Close ();\r
 \r
   delete PkgHdr;\r
   fprintf (pFile, "\n};\n");\r
@@ -483,6 +536,104 @@ CFormPkg::PendingAssignPrintAll (
   }\r
 }\r
 \r
+EFI_VFR_RETURN_CODE\r
+CFormPkg::DeclarePendingQuestion (\r
+  IN CVfrVarDataTypeDB   &lCVfrVarDataTypeDB,\r
+  IN CVfrDataStorage     &lCVfrDataStorage,\r
+  IN CVfrQuestionDB      &lCVfrQuestionDB,\r
+  IN UINT32 LineNo\r
+  )\r
+{\r
+  SPendingAssign *pNode;\r
+  CHAR8          *VarStr;\r
+  UINT32         ArrayIdx;\r
+  CHAR8          FName[MAX_NAME_LEN];\r
+  EFI_VFR_RETURN_CODE  ReturnCode;\r
+  EFI_VFR_VARSTORE_TYPE VarStoreType  = EFI_VFR_VARSTORE_INVALID;\r
+\r
+  for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {\r
+    if (pNode->mFlag == PENDING) {\r
+      //\r
+      //  declare this question as checkbox in SuppressIf True\r
+      //\r
+      // SuppressIf\r
+      CIfrSuppressIf SIObj;\r
+      SIObj.SetLineNo (LineNo);\r
+      \r
+      //TrueOpcode\r
+      CIfrTrue TObj (LineNo);\r
+      \r
+      //CheckBox qeustion\r
+      CIfrCheckBox CBObj;\r
+      EFI_VARSTORE_INFO Info; \r
+         EFI_QUESTION_ID   QId   = EFI_QUESTION_ID_INVALID;\r
+\r
+      CBObj.SetLineNo (LineNo);\r
+      CBObj.SetPrompt (0x0);\r
+      CBObj.SetHelp (0x0);\r
+\r
+      //\r
+      // Register this question, assume it is normal question, not date or time question\r
+      //\r
+      VarStr = pNode->mKey;\r
+      ReturnCode = lCVfrQuestionDB.RegisterQuestion (NULL, VarStr, QId);\r
+      if (ReturnCode != VFR_RETURN_SUCCESS) {\r
+        return ReturnCode;\r
+      }\r
\r
+#ifdef VFREXP_DEBUG\r
+      printf ("Undefined Question name is %s and Id is 0x%x\n", VarStr, QId);\r
+#endif\r
+      //\r
+      // Get Question Info, framework vfr VarName == StructName\r
+      //\r
+      ReturnCode = lCVfrVarDataTypeDB.ExtractFieldNameAndArrary (VarStr, FName, ArrayIdx);\r
+      if (ReturnCode != VFR_RETURN_SUCCESS) {\r
+        return ReturnCode;\r
+      }\r
+      lCVfrDataStorage.GetVarStoreType (FName, VarStoreType);\r
+      lCVfrDataStorage.GetVarStoreId (FName, &Info.mVarStoreId);\r
+\r
+      if (*VarStr == '\0' && ArrayIdx != INVALID_ARRAY_INDEX) {\r
+        lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayIdx);\r
+      } else {\r
+        if (VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
+          lCVfrDataStorage.GetEfiVarStoreInfo (&Info);\r
+        } else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
+          VarStr = pNode->mKey;\r
+          lCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);\r
+        } else {\r
+          return VFR_RETURN_UNSUPPORTED;\r
+        }\r
+      }\r
+\r
+      CBObj.SetQuestionId (QId);\r
+      CBObj.SetVarStoreInfo (&Info);\r
+\r
+      //\r
+      // For undefined Efi VarStore type question\r
+      // Append the extended guided opcode to contain VarName\r
+      //\r
+      if (VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
+        CIfrVarEqName CVNObj (QId, Info.mInfo.mVarName);\r
+        CVNObj.SetLineNo (LineNo);\r
+      }\r
+      \r
+      //\r
+      // End for checkbox\r
+      //\r
+      CIfrEnd CEObj; \r
+      CEObj.SetLineNo (LineNo);\r
+      //\r
+      // End for SuppressIf\r
+      //\r
+      CIfrEnd SEObj;\r
+      SEObj.SetLineNo (LineNo);\r
+    }\r
+  }\r
+  return VFR_RETURN_SUCCESS;\r
+}\r
+\r
 CFormPkg gCFormPkg;\r
 \r
 SIfrRecord::SIfrRecord (\r
@@ -501,7 +652,9 @@ SIfrRecord::~SIfrRecord (
   )\r
 {\r
   if (mIfrBinBuf != NULL) {\r
-    delete mIfrBinBuf;\r
+    //\r
+    // IfrRecord to point to form data buffer.\r
+    //\r
     mIfrBinBuf = NULL;\r
   }\r
   mLineNo      = 0xFFFFFFFF;\r
@@ -514,7 +667,7 @@ CIfrRecordInfoDB::CIfrRecordInfoDB (
   VOID\r
   )\r
 {\r
-  mSwitch            = FALSE;\r
+  mSwitch            = TRUE;\r
   mRecordCount       = EFI_IFR_RECORDINFO_IDX_START;\r
   mIfrRecordListHead = NULL;\r
   mIfrRecordListTail = NULL;\r
@@ -601,16 +754,51 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate (
   pNode->mLineNo    = LineNo;\r
   pNode->mOffset    = Offset;\r
   pNode->mBinBufLen = BinBufLen;\r
-  if (BinBuf != NULL) {\r
-    if (pNode->mIfrBinBuf != NULL) {\r
-      delete pNode->mIfrBinBuf;\r
-    }\r
-    pNode->mIfrBinBuf = new CHAR8[BinBufLen];\r
+  pNode->mIfrBinBuf = BinBuf;\r
+\r
+}\r
+\r
+VOID\r
+CIfrRecordInfoDB::IfrRecordOutput (\r
+  OUT PACKAGE_DATA &TBuffer\r
+  )\r
+{\r
+  CHAR8      *Temp;\r
+  SIfrRecord *pNode; \r
+\r
+  if (TBuffer.Buffer != NULL) {\r
+    delete TBuffer.Buffer;\r
+  }\r
+\r
+  TBuffer.Size = 0;\r
+  TBuffer.Buffer = NULL;\r
+\r
+\r
+  if (mSwitch == FALSE) {\r
+    return;\r
+  } \r
+   \r
+  for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {\r
+    TBuffer.Size += pNode->mBinBufLen;\r
+  }\r
+  \r
+  if (TBuffer.Size != 0) {\r
+    TBuffer.Buffer = new CHAR8[TBuffer.Size];\r
+  } else {\r
+    return;\r
+  }\r
+  \r
+  Temp = TBuffer.Buffer;\r
+\r
+  for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {\r
     if (pNode->mIfrBinBuf != NULL) {\r
-      memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);\r
+      memcpy (Temp, pNode->mIfrBinBuf, pNode->mBinBufLen);\r
+      Temp += pNode->mBinBufLen;\r
     }\r
   }\r
-}\r
+\r
+  return;   \r
+}   \r
 \r
 VOID\r
 CIfrRecordInfoDB::IfrRecordOutput (\r
@@ -620,6 +808,7 @@ CIfrRecordInfoDB::IfrRecordOutput (
 {\r
   SIfrRecord *pNode;\r
   UINT8      Index;\r
+  UINT32     TotalSize;\r
 \r
   if (mSwitch == FALSE) {\r
     return;\r
@@ -629,17 +818,296 @@ CIfrRecordInfoDB::IfrRecordOutput (
     return;\r
   }\r
 \r
+  TotalSize = 0;\r
+\r
   for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {\r
-    if (pNode->mLineNo == LineNo) {\r
+    if (pNode->mLineNo == LineNo || LineNo == 0) {\r
       fprintf (File, ">%08X: ", pNode->mOffset);\r
+      TotalSize += pNode->mBinBufLen;\r
       if (pNode->mIfrBinBuf != NULL) {\r
         for (Index = 0; Index < pNode->mBinBufLen; Index++) {\r
-          fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));\r
+          fprintf (File, "%02X ", (UINT8) pNode->mIfrBinBuf[Index]);\r
         }\r
       }\r
       fprintf (File, "\n");\r
     }\r
   }\r
+  \r
+  if (LineNo == 0) {\r
+    fprintf (File, "\nTotal Size of all record is 0x%08X\n", TotalSize);\r
+  }\r
+}\r
+\r
+//\r
+// for framework vfr file\r
+// adjust opcode sequence for uefi IFR format\r
+// adjust inconsistent and varstore into the right position.\r
+//\r
+BOOLEAN\r
+CIfrRecordInfoDB::CheckQuestionOpCode (\r
+  IN UINT8 OpCode\r
+  )\r
+{\r
+  switch (OpCode) {\r
+  case EFI_IFR_CHECKBOX_OP:\r
+  case EFI_IFR_NUMERIC_OP:\r
+  case EFI_IFR_PASSWORD_OP:\r
+  case EFI_IFR_ONE_OF_OP:\r
+  case EFI_IFR_ACTION_OP:\r
+  case EFI_IFR_STRING_OP:\r
+  case EFI_IFR_DATE_OP:\r
+  case EFI_IFR_TIME_OP:\r
+  case EFI_IFR_ORDERED_LIST_OP:\r
+    return TRUE;\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+CIfrRecordInfoDB::CheckIdOpCode (\r
+  IN UINT8 OpCode\r
+  )\r
+{\r
+  switch (OpCode) {\r
+  case EFI_IFR_EQ_ID_VAL_OP:\r
+  case EFI_IFR_EQ_ID_ID_OP:\r
+  case EFI_IFR_EQ_ID_LIST_OP:\r
+  case EFI_IFR_QUESTION_REF1_OP:\r
+    return TRUE;\r
+  default:\r
+    return FALSE;\r
+  }\r
+} \r
+\r
+EFI_QUESTION_ID\r
+CIfrRecordInfoDB::GetOpcodeQuestionId (\r
+  IN EFI_IFR_OP_HEADER *OpHead\r
+  )\r
+{\r
+  EFI_IFR_QUESTION_HEADER *QuestionHead;\r
+  \r
+  QuestionHead = (EFI_IFR_QUESTION_HEADER *) (OpHead + 1);\r
+  \r
+  return QuestionHead->QuestionId;\r
+}\r
+\r
+EFI_VFR_RETURN_CODE\r
+CIfrRecordInfoDB::IfrRecordAdjust (\r
+  VOID\r
+  )\r
+{\r
+  SIfrRecord *pNode, *preNode;\r
+  SIfrRecord *uNode, *tNode;\r
+  EFI_IFR_OP_HEADER  *OpHead, *tOpHead;\r
+  EFI_QUESTION_ID    QuestionId;\r
+  UINT32             StackCount;\r
+  UINT32             QuestionScope;\r
+  UINT32             OpcodeOffset;\r
+  EFI_VFR_RETURN_CODE  Status;\r
+\r
+  //\r
+  // Init local variable\r
+  //\r
+  Status = VFR_RETURN_SUCCESS;\r
+  pNode = mIfrRecordListHead;\r
+  preNode = pNode;\r
+  QuestionScope = 0;\r
+  while (pNode != NULL) {\r
+    OpHead = (EFI_IFR_OP_HEADER *) pNode->mIfrBinBuf;\r
+    \r
+    //\r
+    // make sure the inconsistent opcode in question scope\r
+    //\r
+    if (QuestionScope > 0) {\r
+      QuestionScope += OpHead->Scope;\r
+      if (OpHead->OpCode == EFI_IFR_END_OP) {\r
+        QuestionScope --;\r
+      }\r
+    }\r
+    \r
+    if (CheckQuestionOpCode (OpHead->OpCode)) {\r
+      QuestionScope = 1;\r
+    }\r
+    //\r
+    // for the inconsistent opcode not in question scope, adjust it\r
+    //\r
+    if (OpHead->OpCode == EFI_IFR_INCONSISTENT_IF_OP && QuestionScope == 0) {\r
+      //\r
+      // for inconsistent opcode not in question scope\r
+      //\r
+\r
+      //\r
+      // Count inconsistent opcode Scope \r
+      //\r
+      StackCount = OpHead->Scope;\r
+      QuestionId = EFI_QUESTION_ID_INVALID;\r
+      tNode = pNode;\r
+      while (tNode != NULL && StackCount > 0) {\r
+        tNode = tNode->mNext;\r
+        tOpHead = (EFI_IFR_OP_HEADER *) tNode->mIfrBinBuf;\r
+        //\r
+        // Calculate Scope Number\r
+        //\r
+        StackCount += tOpHead->Scope;\r
+        if (tOpHead->OpCode == EFI_IFR_END_OP) {\r
+          StackCount --;\r
+        }\r
+        //\r
+        // by IdEqual opcode to get QuestionId\r
+        //\r
+        if (QuestionId == EFI_QUESTION_ID_INVALID && \r
+            CheckIdOpCode (tOpHead->OpCode)) {\r
+          QuestionId = *(EFI_QUESTION_ID *) (tOpHead + 1);\r
+        }\r
+      }\r
+      if (tNode == NULL || QuestionId == EFI_QUESTION_ID_INVALID) {\r
+        //\r
+        // report error; not found\r
+        //\r
+        printf ("Inconsistent OpCode Record list invalid QuestionId is 0x%X\n", QuestionId);\r
+        Status = VFR_RETURN_MISMATCHED;\r
+        break;\r
+      }\r
+      //\r
+      // extract inconsistent opcode list\r
+      // pNode is Incosistent opcode, tNode is End Opcode\r
+      //\r
+      \r
+      //\r
+      // insert inconsistent opcode list into the right question scope by questionid\r
+      //\r
+      for (uNode = mIfrRecordListHead; uNode != NULL; uNode = uNode->mNext) {\r
+        tOpHead = (EFI_IFR_OP_HEADER *) uNode->mIfrBinBuf;\r
+        if (CheckQuestionOpCode (tOpHead->OpCode) && \r
+            (QuestionId == GetOpcodeQuestionId (tOpHead))) {\r
+          break;\r
+        }\r
+      }\r
+      //\r
+      // insert inconsistent opcode list and check LATE_CHECK flag\r
+      //\r
+      if (uNode != NULL) {\r
+        if ((((EFI_IFR_QUESTION_HEADER *)(tOpHead + 1))->Flags & 0x20) != 0) {\r
+          //\r
+          // if LATE_CHECK flag is set, change inconsistent to nosumbit\r
+          //\r
+          OpHead->OpCode = EFI_IFR_NO_SUBMIT_IF_OP;\r
+        }\r
+        \r
+        //\r
+        // skip the default storage for Date and Time\r
+        //\r
+        if ((uNode->mNext != NULL) && (*uNode->mNext->mIfrBinBuf == EFI_IFR_DEFAULT_OP)) {\r
+          uNode = uNode->mNext;\r
+        }\r
+\r
+        preNode->mNext = tNode->mNext;\r
+        tNode->mNext = uNode->mNext;\r
+        uNode->mNext = pNode;\r
+        //\r
+        // reset pNode to head list, scan the whole list again.\r
+        //\r
+        pNode = mIfrRecordListHead;\r
+        preNode = pNode;\r
+        QuestionScope = 0;\r
+        continue;\r
+      } else {\r
+        //\r
+        // not found matched question id, report error\r
+        //\r
+        printf ("QuestionId required by Inconsistent OpCode is not found. QuestionId is 0x%X\n", QuestionId);\r
+        Status = VFR_RETURN_MISMATCHED;\r
+        break;\r
+      }\r
+    } else if (OpHead->OpCode == EFI_IFR_VARSTORE_OP || \r
+               OpHead->OpCode == EFI_IFR_VARSTORE_EFI_OP) {\r
+      //\r
+      // for new added group of varstore opcode\r
+      //\r
+      tNode = pNode;\r
+      while (tNode->mNext != NULL) {\r
+        tOpHead = (EFI_IFR_OP_HEADER *) tNode->mNext->mIfrBinBuf;\r
+        if (tOpHead->OpCode != EFI_IFR_VARSTORE_OP && \r
+            tOpHead->OpCode != EFI_IFR_VARSTORE_EFI_OP) {\r
+          break;    \r
+        }\r
+        tNode = tNode->mNext;\r
+      }\r
+\r
+      if (tNode->mNext == NULL) {\r
+        //\r
+        // invalid IfrCode, IfrCode end by EndOpCode\r
+        // \r
+        printf ("No found End Opcode in the end\n");\r
+        Status = VFR_RETURN_MISMATCHED;\r
+        break;\r
+      }\r
+      \r
+      if (tOpHead->OpCode != EFI_IFR_END_OP) {\r
+          //\r
+          // not new added varstore, which are not needed to be adjust.\r
+          //\r
+          preNode = tNode;\r
+          pNode   = tNode->mNext;\r
+          continue;        \r
+      } else {\r
+        //\r
+        // move new added varstore opcode to the position befor form opcode \r
+        // varstore opcode between pNode and tNode\r
+        //\r
+\r
+        //\r
+        // search form opcode from begin\r
+        //\r
+        for (uNode = mIfrRecordListHead; uNode->mNext != NULL; uNode = uNode->mNext) {\r
+          tOpHead = (EFI_IFR_OP_HEADER *) uNode->mNext->mIfrBinBuf;\r
+          if (tOpHead->OpCode == EFI_IFR_FORM_OP) {\r
+            break;\r
+          }\r
+        }\r
+        //\r
+        // Insert varstore opcode beform form opcode if form opcode is found\r
+        //\r
+        if (uNode->mNext != NULL) {\r
+          preNode->mNext = tNode->mNext;\r
+          tNode->mNext = uNode->mNext;\r
+          uNode->mNext = pNode;\r
+          //\r
+          // reset pNode to head list, scan the whole list again.\r
+          //\r
+          pNode = mIfrRecordListHead;\r
+          preNode = pNode;\r
+          QuestionScope = 0;\r
+          continue;\r
+        } else {\r
+          //\r
+          // not found form, continue scan IfrRecord list\r
+          //\r
+          preNode = tNode;\r
+          pNode   = tNode->mNext;\r
+          continue;\r
+        }\r
+      }\r
+    }\r
+    //\r
+    // next node\r
+    //\r
+    preNode = pNode;\r
+    pNode = pNode->mNext; \r
+  }\r
+  \r
+  //\r
+  // Update Ifr Opcode Offset\r
+  //\r
+  if (Status == VFR_RETURN_SUCCESS) {\r
+    OpcodeOffset = 0;\r
+    for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {\r
+      pNode->mOffset = OpcodeOffset;\r
+      OpcodeOffset += pNode->mBinBufLen;\r
+    }\r
+  }\r
+  return Status;\r
 }\r
 \r
 CIfrRecordInfoDB gCIfrRecordInfoDB;\r
@@ -650,15 +1118,32 @@ CIfrObj::_EMIT_PENDING_OBJ (
   )\r
 {\r
   CHAR8  *ObjBinBuf = NULL;\r
+  \r
+  //\r
+  // do nothing\r
+  //\r
+  if (!mDelayEmit || !gCreateOp) {\r
+    return;\r
+  }\r
 \r
-  ObjBinBuf = gCFormPkg.IfrBinBufferGet (mObjBinLen);\r
+  mPkgOffset = gCFormPkg.GetPkgLength ();\r
+  //\r
+  // update data buffer to package data\r
+  //\r
+  ObjBinBuf  = gCFormPkg.IfrBinBufferGet (mObjBinLen);\r
   if (ObjBinBuf != NULL) {\r
     memcpy (ObjBinBuf, mObjBinBuf, mObjBinLen);\r
   }\r
-\r
+  \r
+  //\r
+  // update bin buffer to package data buffer\r
+  //\r
   if (mObjBinBuf != NULL) {\r
     delete mObjBinBuf;\r
+    mObjBinBuf = ObjBinBuf;\r
   }\r
+  \r
+  mDelayEmit = FALSE;\r
 }\r
 \r
 /*\r
@@ -824,11 +1309,11 @@ CIfrObj::~CIfrObj (
   VOID\r
   )\r
 {\r
-  gCIfrRecordInfoDB.IfrRecordInfoUpdate (mRecordIdx, mLineNo, mObjBinBuf, mObjBinLen, mPkgOffset);\r
-\r
   if ((mDelayEmit == TRUE) && ((gCreateOp == TRUE))) {\r
     _EMIT_PENDING_OBJ ();\r
   }\r
+\r
+  gCIfrRecordInfoDB.IfrRecordInfoUpdate (mRecordIdx, mLineNo, mObjBinBuf, mObjBinLen, mPkgOffset);\r
 }\r
 \r
 /*\r
index cb2ea8d..b474bf0 100644 (file)
@@ -23,6 +23,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define NO_QST_REFED "no question refered"\r
 \r
+struct PACKAGE_DATA {\r
+  CHAR8   *Buffer;\r
+  UINT32  Size;\r
+};\r
+\r
 /*\r
  * The functions below are used for flags setting\r
  */\r
@@ -121,14 +126,21 @@ public:
   VOID                Close ();\r
 \r
   EFI_VFR_RETURN_CODE BuildPkgHdr (OUT EFI_HII_PACKAGE_HEADER **);\r
-  EFI_VFR_RETURN_CODE BuildPkg (IN FILE *);\r
-  EFI_VFR_RETURN_CODE GenCFile (IN CHAR8 *, IN FILE *);\r
+  EFI_VFR_RETURN_CODE BuildPkg (IN FILE *, IN PACKAGE_DATA *PkgData = NULL);\r
+  EFI_VFR_RETURN_CODE BuildPkg (OUT PACKAGE_DATA &);\r
+  EFI_VFR_RETURN_CODE GenCFile (IN CHAR8 *, IN FILE *, IN PACKAGE_DATA *PkgData = NULL);\r
 \r
 public:\r
   EFI_VFR_RETURN_CODE AssignPending (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CHAR8 *Msg = NULL);\r
   VOID                DoPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32);\r
   bool                HavePendingUnassigned (VOID);\r
   VOID                PendingAssignPrintAll (VOID);\r
+  EFI_VFR_RETURN_CODE   DeclarePendingQuestion (\r
+    IN CVfrVarDataTypeDB   &lCVfrVarDataTypeDB,\r
+    IN CVfrDataStorage     &lCVfrDataStorage,\r
+    IN CVfrQuestionDB      &lCVfrQuestionDB,\r
+    IN UINT32 LineNo\r
+    );\r
 };\r
 \r
 extern CFormPkg gCFormPkg;\r
@@ -155,6 +167,9 @@ private:
   SIfrRecord *mIfrRecordListTail;\r
 \r
   SIfrRecord * GetRecordInfoFromIdx (IN UINT32);\r
+  BOOLEAN          CheckQuestionOpCode (IN UINT8);\r
+  BOOLEAN          CheckIdOpCode (IN UINT8);\r
+  EFI_QUESTION_ID  GetOpcodeQuestionId (IN EFI_IFR_OP_HEADER *);\r
 public:\r
   CIfrRecordInfoDB (VOID);\r
   ~CIfrRecordInfoDB (VOID);\r
@@ -170,6 +185,8 @@ public:
   UINT32      IfrRecordRegister (IN UINT32, IN CHAR8 *, IN UINT8, IN UINT32);\r
   VOID        IfrRecordInfoUpdate (IN UINT32, IN UINT32, IN CHAR8*, IN UINT8, IN UINT32);\r
   VOID        IfrRecordOutput (IN FILE *, IN UINT32 LineNo);\r
+  VOID        IfrRecordOutput (OUT PACKAGE_DATA &);\r
+  EFI_VFR_RETURN_CODE  IfrRecordAdjust (VOID);   \r
 };\r
 \r
 extern CIfrRecordInfoDB gCIfrRecordInfoDB;\r
@@ -189,12 +206,12 @@ private:
   UINT32  mRecordIdx;\r
   UINT32  mPkgOffset;\r
 \r
-  VOID    _EMIT_PENDING_OBJ (VOID);\r
-\r
 public:\r
   CIfrObj (IN UINT8 OpCode, OUT CHAR8 **IfrObj = NULL, IN UINT8 ObjBinLen = 0, IN BOOLEAN DelayEmit = FALSE);\r
   virtual ~CIfrObj(VOID);\r
 \r
+  VOID    _EMIT_PENDING_OBJ (VOID);\r
+  \r
   inline VOID    SetLineNo (IN UINT32 LineNo) {\r
     mLineNo = LineNo;\r
   }\r
@@ -336,7 +353,7 @@ public:
 \r
   VOID SetVarStoreInfo (IN EFI_VARSTORE_INFO *Info) {\r
     mHeader->VarStoreId             = Info->mVarStoreId;\r
-       mHeader->VarStoreInfo.VarName   = Info->mInfo.mVarName;\r
+         mHeader->VarStoreInfo.VarName   = Info->mInfo.mVarName;\r
     mHeader->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset;\r
   }\r
 \r
@@ -350,14 +367,23 @@ public:
     if (_FLAG_TEST_AND_CLEAR (Flags, EFI_IFR_FLAG_CALLBACK)) {\r
       mHeader->Flags |= EFI_IFR_FLAG_CALLBACK;\r
     }\r
-\r
+    \r
+    //\r
+    // ignore NVAccessFlag\r
+    //\r
     _FLAG_CLEAR (Flags, 0x08);\r
 \r
     if (_FLAG_TEST_AND_CLEAR (Flags, EFI_IFR_FLAG_RESET_REQUIRED)) {\r
       mHeader->Flags |= EFI_IFR_FLAG_RESET_REQUIRED;\r
     }\r
-\r
-    _FLAG_CLEAR (Flags, 0x20);\r
+    \r
+    //\r
+    //  Set LateCheck Flag to compatible for framework flag\r
+    //  but it uses 0x20 as its flag, if in the future UEFI may take this flag\r
+    //\r
+    if (_FLAG_TEST_AND_CLEAR (Flags, 0x20)) {\r
+      mHeader->Flags |= 0x20;\r
+    }\r
 \r
     if (_FLAG_TEST_AND_CLEAR (Flags, EFI_IFR_FLAG_OPTIONS_ONLY)) {\r
       mHeader->Flags |= EFI_IFR_FLAG_OPTIONS_ONLY;\r
@@ -648,7 +674,7 @@ public:
     ) : CIfrObj (EFI_IFR_DEFAULT_OP, (CHAR8 **)&mDefault),\r
         CIfrOpHeader (EFI_IFR_DEFAULT_OP, &mDefault->Header) {\r
     mDefault->Type      = Type;\r
-       mDefault->Value     = Value;\r
+         mDefault->Value     = Value;\r
     mDefault->DefaultId = DefaultId;\r
   }\r
 \r
@@ -1303,7 +1329,8 @@ public:
   }\r
 };\r
 \r
-static EFI_GUID IfrTianoGuid = EFI_IFR_TIANO_GUID;\r
+static EFI_GUID IfrTianoGuid     = EFI_IFR_TIANO_GUID;\r
+static EFI_GUID IfrFrameworkGuid = EFI_IFR_FRAMEWORK_GUID;\r
 \r
 class CIfrClass : public CIfrObj, public CIfrOpHeader {\r
 private:\r
@@ -1379,6 +1406,42 @@ public:
   }\r
 };\r
 \r
+class CIfrOptionKey : public CIfrObj, public CIfrOpHeader {\r
+private:\r
+  EFI_IFR_GUID_OPTIONKEY *mOptionKey;\r
+\r
+public:\r
+  CIfrOptionKey (\r
+    IN EFI_QUESTION_ID QuestionId,\r
+    IN EFI_IFR_TYPE_VALUE &OptionValue,\r
+    IN EFI_QUESTION_ID KeyValue\r
+  ) : CIfrObj (EFI_IFR_GUID_OP, (CHAR8 **)&mOptionKey, sizeof (EFI_IFR_GUID_OPTIONKEY)),\r
+      CIfrOpHeader (EFI_IFR_GUID_OP, &mOptionKey->Header, sizeof (EFI_IFR_GUID_OPTIONKEY)) {\r
+    mOptionKey->ExtendOpCode = EFI_IFR_EXTEND_OP_OPTIONKEY;\r
+    mOptionKey->Guid         = IfrFrameworkGuid;\r
+    mOptionKey->QuestionId   = QuestionId;\r
+    mOptionKey->OptionValue  = OptionValue;\r
+    mOptionKey->KeyValue     = KeyValue;\r
+  }\r
+};\r
+\r
+class CIfrVarEqName : public CIfrObj, public CIfrOpHeader {\r
+private:\r
+  EFI_IFR_GUID_VAREQNAME *mVarEqName;\r
+\r
+public:\r
+  CIfrVarEqName (\r
+    IN EFI_QUESTION_ID QuestionId,\r
+    IN EFI_STRING_ID   NameId\r
+  ) : CIfrObj (EFI_IFR_GUID_OP, (CHAR8 **)&mVarEqName, sizeof (EFI_IFR_GUID_VAREQNAME)),\r
+      CIfrOpHeader (EFI_IFR_GUID_OP, &mVarEqName->Header, sizeof (EFI_IFR_GUID_VAREQNAME)) {\r
+    mVarEqName->ExtendOpCode = EFI_IFR_EXTEND_OP_VAREQNAME;\r
+    mVarEqName->Guid         = IfrFrameworkGuid;\r
+    mVarEqName->QuestionId   = QuestionId;\r
+    mVarEqName->NameId       = NameId;\r
+  }\r
+};\r
+\r
 class CIfrTimeout : public CIfrObj, public CIfrOpHeader {\r
 private:\r
   EFI_IFR_GUID_TIMEOUT *mTimeout;\r
@@ -1492,6 +1555,12 @@ public:
     mEqIdVList->ListLength   = 0;\r
     mEqIdVList->ValueList[0] = 0;\r
   }\r
+  \r
+  VOID UpdateIfrBuffer ( \r
+  ) {\r
+    _EMIT_PENDING_OBJ();\r
+    mEqIdVList = (EFI_IFR_EQ_ID_LIST *) GetObjBinAddr();\r
+  }\r
 \r
   VOID SetQuestionId (\r
   IN EFI_QUESTION_ID QuestionId,\r
index cbc7f29..9641017 100644 (file)
@@ -29,12 +29,12 @@ Abstract:
 #include "stdio.h"\r
 #include "PBlackBox.h"\r
 #include "DLexerBase.h"\r
-#include "VfrLexer.h"\r
+#include "VfrLexer.h"    \r
 #include "AToken.h"\r
 \r
 #define GET_LINENO(Obj)       ((Obj)->getLine())\r
 #define SET_LINE_INFO(Obj, L) {(Obj).SetLineNo((L)->getLine());} while (0)\r
-#define CRT_END_OP(Obj)       {CIfrEnd EObj; EObj.SetLineNo ((Obj)->getLine());} while (0)\r
+#define CRT_END_OP(Obj)       {CIfrEnd EObj; if (Obj != NULL) EObj.SetLineNo ((Obj)->getLine());} while (0)\r
 \r
 typedef ANTLRCommonToken ANTLRToken;\r
 \r
@@ -42,18 +42,20 @@ class CVfrDLGLexer : public VfrLexer
 {\r
 public:\r
   CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};\r
-  INT32 errstd (char *Text)\r
-  {\r
-    printf ("unrecognized input '%s'\n", Text);\r
+  INT32 errstd (char *Text) \r
+  { \r
+    printf ("unrecognized input '%s'\n", Text); \r
   }\r
 };\r
 \r
 UINT8\r
 VfrParserStart (\r
-  IN FILE *File\r
+  IN FILE *File,\r
+  IN BOOLEAN CompatibleMode\r
   )\r
 {\r
   ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File);\r
+  VfrParser.parser()->SetCompatibleMode (CompatibleMode);\r
   return VfrParser.parser()->vfrProgram();\r
 }\r
 >>\r
@@ -64,7 +66,7 @@ VfrParserStart (
 // is not preceeded with a backslash.\r
 //\r
 #lexclass QUOTED_STRING\r
-#token TheString            "~[\"]*\"" << mode (START); >>\r
+#token TheString            "~[\"]*\"" << mode (START); >>     \r
 \r
 //\r
 // Define a lexclass for skipping over C++ style comments\r
@@ -86,7 +88,7 @@ VfrParserStart (
 //\r
 // Skip whitespace\r
 //\r
-#token "[\ \t]"   << skip (); >>\r
+#token "[\ \t]"   << skip (); >> \r
 \r
 //\r
 // Skip over newlines, but count them\r
@@ -113,7 +115,6 @@ VfrParserStart (
 #token CloseParen(")")                          "\)"\r
 #token OpenBracket("[")                         "\["\r
 #token CloseBracket("]")                        "\]"\r
-\r
 #token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << gCVfrErrorHandle.ParseFileScopeRecord (begexpr (), line ()); skip (); newline (); >>\r
 #token DevicePath("devicepath")                 "devicepath"\r
 #token FormSet("formset")                       "formset"\r
@@ -160,17 +161,17 @@ VfrParserStart (
 #token CheckBox("checkbox")                     "checkbox"\r
 #token EndCheckBox("endcheckbox")               "endcheckbox"\r
 #token Numeric("numeric")                       "numeric"\r
-#token EndNumeric("endnumeric")                 "endnumeric"\r
-#token Minimum("minimum")                       "minimum"\r
-#token Maximum("maximum")                       "maximum"\r
-#token STEP("step")                             "step"\r
-#token Default("default")                       "default"\r
-#token Password("password")                     "password"\r
-#token EndPassword("endpassword")               "endpassword"\r
+#token EndNumeric("endnumeric")                 "endnumeric"            \r
+#token Minimum("minimum")                       "minimum"         \r
+#token Maximum("maximum")                       "maximum"         \r
+#token STEP("step")                             "step"      \r
+#token Default("default")                       "default"         \r
+#token Password("password")                     "password"          \r
+#token EndPassword("endpassword")               "endpassword"             \r
 #token String("string")                         "string"\r
-#token EndString("endstring")                   "endstring"\r
-#token MinSize("minsize")                       "minsize"\r
-#token MaxSize("maxsize")                       "maxsize"\r
+#token EndString("endstring")                   "endstring"           \r
+#token MinSize("minsize")                       "minsize"         \r
+#token MaxSize("maxsize")                       "maxsize"         \r
 #token Encoding("encoding")                     "encoding"\r
 #token SuppressIf("suppressif")                 "suppressif"\r
 #token DisableIf("disableif")                   "disableif"\r
@@ -188,7 +189,6 @@ VfrParserStart (
 #token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
 #token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
 #token ReadOnlyFlag("READ_ONLY")                "READ_ONLY"\r
-#token CallBackFlag("INTERACTIVE")              "INTERACTIVE"\r
 #token OptionOnlyFlag("OPTIONS_ONLY")           "OPTIONS_ONLY"\r
 #token Class("class")                           "class"\r
 #token Subclass("subclass")                     "subclass"\r
@@ -270,10 +270,10 @@ pragmaPackStackDef :
   (\r
       L1:"push"                                     << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>\r
     | L2:"pop"                                      << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>\r
-  )\r
+  ) \r
   {\r
     "," ID:StringIdentifier                         << Identifier = ID->getText(); >>\r
-  }\r
+  } \r
   {\r
     "," N:Number                                    << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>\r
   }\r
@@ -290,7 +290,7 @@ pragmaPackNumber :
   ;\r
 \r
 vfrPragmaPackDefinition :\r
-  "\#pragma" "pack" "\("\r
+  "\#pragma" "pack" "\(" \r
   {\r
       pragmaPackShowDef\r
     | pragmaPackStackDef\r
@@ -305,10 +305,10 @@ vfrDataStructDefinition :
   {\r
     N1:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>\r
   }\r
-  OpenBrace\r
+  OpenBrace \r
     vfrDataStructFields\r
-  CloseBrace\r
-  {\r
+  CloseBrace \r
+  { \r
     N2:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>\r
   }\r
   ";"                                               << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>\r
@@ -316,13 +316,13 @@ vfrDataStructDefinition :
 \r
 vfrDataStructFields :\r
   (\r
-     dataStructField64     |\r
-        dataStructField32     |\r
-        dataStructField16     |\r
-        dataStructField8      |\r
+     dataStructField64     | \r
+        dataStructField32     | \r
+        dataStructField16     | \r
+        dataStructField8      | \r
      dataStructFieldBool   |\r
         dataStructFieldString |\r
-        dataStructFieldDate   |\r
+        dataStructFieldDate   | \r
         dataStructFieldTime   |\r
      dataStructFieldUser\r
   )*\r
@@ -330,8 +330,8 @@ vfrDataStructFields :
 \r
 dataStructField64 :\r
   << UINT32 ArrayNum = 0; >>\r
-  "UINT64"\r
-  N:StringIdentifier\r
+  "UINT64" \r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -340,8 +340,8 @@ dataStructField64 :
 \r
 dataStructField32 :\r
   << UINT32 ArrayNum = 0; >>\r
-  "UINT32"\r
-  N:StringIdentifier\r
+  "UINT32" \r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -351,7 +351,7 @@ dataStructField32 :
 dataStructField16 :\r
   << UINT32 ArrayNum = 0; >>\r
   ("UINT16" | "CHAR16")\r
-  N:StringIdentifier\r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -361,7 +361,7 @@ dataStructField16 :
 dataStructField8 :\r
   << UINT32 ArrayNum = 0; >>\r
   "UINT8"\r
-  N:StringIdentifier\r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -371,7 +371,7 @@ dataStructField8 :
 dataStructFieldBool :\r
   << UINT32 ArrayNum = 0; >>\r
   "BOOLEAN"\r
-  N:StringIdentifier\r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -381,7 +381,7 @@ dataStructFieldBool :
 dataStructFieldString :\r
   << UINT32 ArrayNum = 0; >>\r
   "EFI_STRING_ID"\r
-  N:StringIdentifier\r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -390,8 +390,8 @@ dataStructFieldString :
 \r
 dataStructFieldDate :\r
   << UINT32 ArrayNum = 0; >>\r
-  "EFI_HII_DATE"\r
-  N:StringIdentifier\r
+  "EFI_HII_DATE" \r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -400,8 +400,8 @@ dataStructFieldDate :
 \r
 dataStructFieldTime :\r
   << UINT32 ArrayNum = 0; >>\r
-  "EFI_HII_TIME"\r
-  N:StringIdentifier\r
+  "EFI_HII_TIME" \r
+  N:StringIdentifier \r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -447,7 +447,7 @@ guidDefinition [EFI_GUID &Guid] :
     (\r
         OpenBrace guidSubDefinition[Guid] CloseBrace\r
       | guidSubDefinition[Guid]\r
-    )\r
+    ) \r
   CloseBrace\r
   ;\r
 \r
@@ -462,21 +462,36 @@ vfrFormSetDefinition :
      UINT16      C, SC;\r
   >>\r
   L:FormSet                                         << SET_LINE_INFO (FSObj, L); >>\r
-  Uuid "=" guidDefinition[Guid] ","                 << FSObj.SetGuid (&Guid); >>\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
+                                                    >>\r
   Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","  << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>\r
   Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","  << FSObj.SetHelp (_STOSID(S2->getText())); >>\r
   {\r
-    Class "=" classDefinition[C] ","                << {CIfrClass CObj; CObj.SetClass(C);} >>\r
+    FC:Class "=" classDefinition[C] ","                << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>\r
   }\r
   {\r
-    Subclass "=" subclassDefinition[SC] ","         << {CIfrSubClass SCObj; 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
-                                                       //_DeclareDefaultLinearVarStore (GET_LINENO (L));\r
                                                     >>\r
   vfrFormSetList\r
-  E:EndFormSet                                      << CRT_END_OP (E); >>\r
+  E:EndFormSet                                      << \r
+                                                      if (mCompatibleMode) {\r
+                                                        //\r
+                                                        // declare all undefined varstore and efivarstore\r
+                                                        //\r
+                                                        _DeclareDefaultFrameworkVarStore (GET_LINENO(E));\r
+                                                      }\r
+                                                      CRT_END_OP (E); \r
+                                                    >>\r
   ";"\r
   ;\r
 \r
@@ -499,32 +514,33 @@ vfrStatementDefaultStore :
   {\r
     "," Attribute "=" A:Number                      << DefaultId = _STOU16(A->getText()); >>\r
   }\r
-                                                    <<\r
+                                                    << \r
                                                        if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {\r
                                                          CIfrDefaultStore DSObj;\r
                                                          _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();\r
-                                                                                                                DSObj.SetLineNo(D->getLine());\r
+                                                                                                                                            DSObj.SetLineNo(D->getLine());\r
                                                          DSObj.SetDefaultName (_STOSID(S->getText()));\r
                                                          DSObj.SetDefaultId (DefaultId);\r
-                                                                                                          } else {\r
+                                                                                                                                    } else {\r
                                                          _PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();\r
-                                                                                                          }\r
+                                                                                                                                    }\r
                                                     >>\r
   ";"\r
   ;\r
 \r
 vfrStatementVarStoreLinear :\r
   <<\r
-     EFI_GUID        Guid;\r
+     EFI_GUID        Guid; \r
      CIfrVarStore    VSObj;\r
      CHAR8           *TypeName;\r
-        UINT32          LineNum;\r
+     CHAR8           *StoreName;\r
+          UINT32          LineNum;\r
      EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;\r
      UINT32          Size;\r
   >>\r
   V:Varstore                                        << VSObj.SetLineNo(V->getLine()); >>\r
   (\r
-      TN:StringIdentifier ","                       << TypeName = TN->getText(); LineNum = TN->getLine(); >>\r
+    TN:StringIdentifier ","                       << TypeName = TN->getText(); LineNum = TN->getLine(); >>\r
        | U8:"UINT8" ","                                << TypeName = "UINT8"; LineNum = U8->getLine(); >>\r
        | U16:"UINT16" ","                              << TypeName = "UINT16"; LineNum = U16->getLine(); >>\r
        | U32:"UINT32" ","                              << TypeName = "UINT32"; LineNum = U32->getLine(); >>\r
@@ -532,7 +548,12 @@ vfrStatementVarStoreLinear :
        | D:"EFI_HII_DATE" ","                          << TypeName = "EFI_HII_DATE"; LineNum = D->getLine(); >>\r
        | T:"EFI_HII_TIME" ","                          << TypeName = "EFI_HII_TIME"; LineNum = T->getLine(); >>\r
   )\r
-  { Key "=" Number "," }                            // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR\r
+  { Key "=" FID:Number ","                       << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR\r
+                                                     if (mCompatibleMode) {\r
+                                                       VarStoreId = _STOU16(FID->getText()); \r
+                                                     }\r
+                                                  >>\r
+  }\r
   {\r
     VarId "=" ID:Number ","                         <<\r
                                                        _PCATCH(\r
@@ -546,21 +567,26 @@ vfrStatementVarStoreLinear :
   Name "=" SN:StringIdentifier ","\r
   Uuid "=" guidDefinition[Guid]\r
                                                     <<\r
+                                                       if (mCompatibleMode) {\r
+                                                         StoreName = TypeName;\r
+                                                       } else {\r
+                                                         StoreName = SN->getText();\r
+                                                       }\r
                                                        _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (\r
-                                                                                  SN->getText(),\r
-                                                                                  &Guid,\r
-                                                                                  &mCVfrVarDataTypeDB,\r
+                                                                                  StoreName, \r
+                                                                                  &Guid, \r
+                                                                                  &mCVfrVarDataTypeDB, \r
                                                                                   TypeName,\r
-                                                                                                                                                                 VarStoreId\r
+                                                                                                                                                                                                         VarStoreId\r
                                                                                   ), LineNum);\r
                                                     >>\r
-                                                    <<\r
-                                                       VSObj.SetGuid (&Guid);\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
+                                                    << \r
+                                                       VSObj.SetGuid (&Guid); \r
+                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);\r
                                                        VSObj.SetVarStoreId (VarStoreId);\r
                                                        _PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);\r
                                                        VSObj.SetSize (Size);\r
-                                                       VSObj.SetName (SN->getText());\r
+                                                       VSObj.SetName (StoreName);\r
                                                     >>\r
   ";"\r
   ;\r
@@ -579,10 +605,10 @@ vfrStatementVarStoreEfi :
   Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","\r
   VarSize "=" N:Number ","\r
   Uuid "=" guidDefinition[Guid]                     << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>\r
-                                                    <<\r
+                                                    << \r
                                                        VSEObj.SetGuid (&Guid);\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
-                                                       VSEObj.SetVarStoreId (VarStoreId);\r
+                                                       VSEObj.SetVarStoreId (VarStoreId); \r
                                                     >>\r
   ";"\r
   ;\r
@@ -593,7 +619,7 @@ vfrVarStoreEfiAttr [UINT32 & Attr] :
 \r
 vfrStatementVarStoreNameValue :\r
   <<\r
-     EFI_GUID              Guid;\r
+     EFI_GUID              Guid; \r
      CIfrVarStoreNameValue VSNVObj;\r
      EFI_VARSTORE_ID       VarStoreId;\r
   >>\r
@@ -603,10 +629,10 @@ vfrStatementVarStoreNameValue :
     Name "=" "STRING_TOKEN" "\(" N:Number "\)" ","  << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>\r
   )+\r
   Uuid "=" guidDefinition[Guid]                     << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>\r
-                                                    <<\r
+                                                    << \r
                                                        VSNVObj.SetGuid (&Guid);\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
-                                                       VSNVObj.SetVarStoreId (VarStoreId);\r
+                                                       VSNVObj.SetVarStoreId (VarStoreId); \r
                                                     >>\r
   ";"\r
   ;\r
@@ -619,7 +645,7 @@ classDefinition[UINT16 & Class] :
   << $Class = 0; >>\r
   validClassNames[$Class] ( "\|" validClassNames[$Class] )*\r
   ;\r
-\r
+  \r
 validClassNames[UINT16 & Class] :\r
     ClassNonDevice                                  << $Class |= EFI_NON_DEVICE_CLASS; >>\r
   | ClassDiskDevice                                 << $Class |= EFI_DISK_DEVICE_CLASS; >>\r
@@ -660,8 +686,8 @@ vfrStatementHeader[CIfrStatementHeader *SHObj] :
 \r
 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:\r
   <<\r
-     EFI_VARSTORE_INFO Info;\r
-        EFI_QUESTION_ID   QId       = EFI_QUESTION_ID_INVALID;\r
+     EFI_VARSTORE_INFO Info; \r
+          EFI_QUESTION_ID   QId       = EFI_QUESTION_ID_INVALID;\r
      CHAR8             *QName    = NULL;\r
      CHAR8             *VarIdStr = NULL;\r
   >>\r
@@ -675,29 +701,29 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
   {\r
     QuestionId "=" ID:Number ","                    <<\r
                                                        QId = _STOQID(ID->getText());\r
-                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");\r
+                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number"); \r
                                                     >>\r
   }\r
-                                                    <<\r
+                                                    << \r
                                                        switch (QType) {\r
                                                        case QUESTION_NORMAL:\r
-                                                         mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
-                                                         break;\r
-                                                                                                          case QUESTION_DATE:\r
-                                                                                                                mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
-                                                                                                                break;\r
-                                                                                                          case QUESTION_TIME:\r
-                                                                                                                mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
-                                                                                                                break;\r
-                                                                                                          default:\r
-                                                                                                                _PCATCH(VFR_RETURN_FATAL_ERROR);\r
-                                                                                                          }\r
+                                                       mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
+                                                       break;\r
+                                                                                                                                  case QUESTION_DATE:\r
+                                                                                                                                        mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
+                                                                                                                                        break;\r
+                                                                                                                                  case QUESTION_TIME:\r
+                                                                                                                                        mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
+                                                                                                                                        break;\r
+                                                                                                                                  default:\r
+                                                                                                                                        _PCATCH(VFR_RETURN_FATAL_ERROR);\r
+                                                                                                                                  }\r
                                                        $QHObj.SetQuestionId (QId);\r
                                                        $QHObj.SetVarStoreInfo (&Info);\r
                                                     >>\r
   vfrStatementHeader[&$QHObj]\r
                                                     << _SAVE_CURRQEST_VARINFO (Info); >>\r
-                                                                                                       << if (VarIdStr != NULL) delete VarIdStr; >>\r
+                                                                                                                               << if (VarIdStr != NULL) delete VarIdStr; >>\r
   ;\r
 \r
 vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :\r
@@ -714,10 +740,10 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
   {\r
     QuestionId "=" ID:Number ","                    <<\r
                                                        QId = _STOQID(ID->getText());\r
-                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");\r
+                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID"); \r
                                                     >>\r
   }\r
-                                                    <<\r
+                                                    << \r
                                                        mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);\r
                                                        $QHObj->SetQuestionId (QId);\r
                                                     >>\r
@@ -726,9 +752,11 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
 \r
 questionheaderFlagsField[UINT8 & Flags] :\r
     ReadOnlyFlag                                    << $Flags |= 0x01; >>\r
-  | CallBackFlag                                    << $Flags |= 0x04; >>\r
+  | InteractiveFlag                                 << $Flags |= 0x04; >>\r
   | ResetRequiredFlag                               << $Flags |= 0x10; >>\r
   | OptionOnlyFlag                                  << $Flags |= 0x80; >>\r
+  | NVAccessFlag\r
+  | LateCheckFlag\r
   ;\r
 \r
 vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :\r
@@ -740,46 +768,71 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
      CHAR8                 *VarStr      = NULL;\r
      CHAR8                 *SName       = NULL;\r
      CHAR8                 *TName       = NULL;\r
+     CHAR8                 *SValue      = NULL;\r
+     EFI_VFR_RETURN_CODE   VfrReturnCode = VFR_RETURN_SUCCESS;\r
   >>\r
   (\r
     SN1:StringIdentifier                            << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>\r
-    OpenBracket I1:Number CloseBracket              << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
+    OpenBracket I1:Number CloseBracket              << Idx = _STOU32(I1->getText()); if (mCompatibleMode) Idx--; SValue = _U32TOS (Idx); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, SValue); _STRCAT(&VarIdStr, "]"); delete SValue; >>\r
                                                     <<\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
-                                                                                                          _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
-                                                                                                       >>\r
+                                                       VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
+                                                       if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {\r
+                                                          mCVfrDataStorage.DeclareBufferVarStore (\r
+                                                                             SName, \r
+                                                                             &mFormsetGuid, \r
+                                                                             &mCVfrVarDataTypeDB, \r
+                                                                             SName,\r
+                                                                             EFI_VARSTORE_ID_INVALID,\r
+                                                                             FALSE\r
+                                                                             );\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
+                                                                                                                               >>\r
   )\r
   |\r
   (\r
     SN2:StringIdentifier                            << SName = SN2->getText(); _STRCAT(&VarIdStr, SName); >>\r
                                                     <<\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN2);\r
+                                                       VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
+                                                       if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {\r
+                                                          mCVfrDataStorage.DeclareBufferVarStore (\r
+                                                                             SName, \r
+                                                                             &mFormsetGuid, \r
+                                                                             &mCVfrVarDataTypeDB, \r
+                                                                             SName,\r
+                                                                             EFI_VARSTORE_ID_INVALID,\r
+                                                                             FALSE\r
+                                                                             );\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
+                                                                                                                                  if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
                                                          _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);\r
-                                                                                                                _STRCAT(&VarStr, TName);\r
-                                                                                                          }\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
-                                                                                                          _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");\r
-                                                                                                       >>\r
+                                                                                                                                  _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");\r
+                                                                                                                               >>\r
       SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>\r
       {\r
-        OpenBracket I2:Number CloseBracket          << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>\r
+        OpenBracket I2:Number CloseBracket          << Idx = _STOU32(I2->getText()); if (mCompatibleMode) Idx--; SValue = _U32TOS (Idx); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, SValue); _STRCAT(&VarIdStr, "]"); delete SValue; >>\r
                                                     << _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>\r
       }\r
-    )*                                              <<\r
+    )*                                              << \r
                                                        switch (VarStoreType) {\r
                                                        case EFI_VFR_VARSTORE_EFI:\r
                                                          _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);\r
                                                          break;\r
                                                        case EFI_VFR_VARSTORE_BUFFER:\r
-                                                         _PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());\r
-                                                         //_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);\r
+                                                         _PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);\r
                                                          break;\r
                                                        case EFI_VFR_VARSTORE_NAME:\r
                                                        default: break;\r
@@ -792,10 +845,14 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
   ;\r
 \r
 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :\r
-                                                    << VarIdStr = NULL; LineNo = 0; >>\r
+                                                    << \r
+                                                      CHAR8   *SValue      = NULL;\r
+                                                      UINT32  Idx;\r
+                                                      VarIdStr = NULL; LineNo = 0; \r
+                                                    >>\r
   (\r
     SN1:StringIdentifier                            << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>\r
-    OpenBracket I1:Number CloseBracket              << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
+    OpenBracket I1:Number CloseBracket              << Idx = _STOU32(I1->getText()); if (mCompatibleMode) Idx--; SValue = _U32TOS (Idx); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, SValue); _STRCAT(&VarIdStr, "]"); delete SValue; >>\r
                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
   )\r
   |\r
@@ -803,9 +860,9 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr,
     SN2:StringIdentifier                            << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>\r
     (\r
       "."                                           << _STRCAT (&VarIdStr, "."); >>\r
-      SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); >>\r
+      SF:StringIdentifier                           << _STRCAT (&VarIdStr, SF->getText()); >>\r
       {\r
-        OpenBracket I2:Number CloseBracket          << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>\r
+        OpenBracket I2:Number CloseBracket          << Idx = _STOU32(I2->getText());if (mCompatibleMode) Idx--;  SValue = _U32TOS (Idx); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, SValue); _STRCAT(&VarIdStr, "]"); delete SValue; >>\r
       }\r
     )*\r
                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
@@ -813,31 +870,31 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr,
   ;\r
 \r
 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :\r
-    N1:Number                                       <<\r
+    N1:Number                                       << \r
                                                        switch ($Type) {\r
                                                        case EFI_IFR_TYPE_NUM_SIZE_8 :\r
-                                                                                                            $Value.u8     = _STOU8(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_NUM_SIZE_16 :\r
-                                                                                                            $Value.u16    = _STOU16(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_NUM_SIZE_32 :\r
-                                                                                                            $Value.u32    = _STOU32(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_NUM_SIZE_64 :\r
-                                                                                                            $Value.u64    = _STOU64(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_BOOLEAN :\r
-                                                                                                            $Value.b      = _STOU8(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_STRING :\r
-                                                                                                            $Value.string = _STOU16(N1->getText());\r
-                                                                                                                break;\r
-                                                                                                          case EFI_IFR_TYPE_TIME :\r
-                                                                                                          case EFI_IFR_TYPE_DATE :\r
-                                                                                                          default :\r
-                                                                                                                break;\r
-                                                                                                          }\r
+                                                                                                                                    $Value.u8     = _STOU8(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_NUM_SIZE_16 :\r
+                                                                                                                                    $Value.u16    = _STOU16(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_NUM_SIZE_32 :\r
+                                                                                                                                    $Value.u32    = _STOU32(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_NUM_SIZE_64 :\r
+                                                                                                                                    $Value.u64    = _STOU64(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_BOOLEAN :\r
+                                                                                                                                    $Value.b      = _STOU8(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_STRING :\r
+                                                                                                                                    $Value.string = _STOU16(N1->getText());\r
+                                                                                                                                        break;\r
+                                                                                                                                  case EFI_IFR_TYPE_TIME :\r
+                                                                                                                                  case EFI_IFR_TYPE_DATE :\r
+                                                                                                                                  default :\r
+                                                                                                                                        break;\r
+                                                                                                                                  } \r
                                                     >>\r
   | B1:True                                         << $Value.b      = TRUE; >>\r
   | B2:False                                        << $Value.b      = FALSE; >>\r
@@ -867,20 +924,44 @@ vfrFormDefinition :
     vfrStatementQuestions                    |\r
     vfrStatementConditional                  |\r
     vfrStatementLabel                        |\r
-    vfrStatementBanner\r
+    vfrStatementBanner                       | \r
     // Just for framework vfr compatibility\r
-    //vfrStatementInvalid\r
+    vfrStatementInvalid\r
   )*\r
-  E:EndForm                                         << CRT_END_OP (E); >>\r
+  E:EndForm                                         << \r
+                                                      if (mCompatibleMode) {\r
+                                                        //\r
+                                                        // Add Label for Framework Vfr \r
+                                                        //\r
+                                                        CIfrLabel LObj; \r
+                                                        LObj.SetLineNo(E->getLine());\r
+                                                        LObj.SetNumber (0x0);  //add dummy label for UEFI, label number hardcode 0x0\r
+                                                        //\r
+                                                        // Declare undefined Question\r
+                                                        //\r
+                                                        if (gCFormPkg.HavePendingUnassigned()) {\r
+                                                          gCFormPkg.DeclarePendingQuestion (\r
+                                                                      mCVfrVarDataTypeDB, \r
+                                                                      mCVfrDataStorage, \r
+                                                                      mCVfrQuestionDB,\r
+                                                                      E->getLine()\r
+                                                                    );\r
+                                                        }\r
+                                                      }\r
+                                                      // \r
+                                                      // mCVfrQuestionDB.PrintAllQuestion();\r
+                                                      //\r
+                                                      CRT_END_OP (E); \r
+                                                    >>\r
   ";"\r
   ;\r
 \r
-vfrStatementRules :\r
+vfrStatementRules : \r
   << CIfrRule RObj; >>\r
   R:Rule                                            << RObj.SetLineNo(R->getLine()); >>\r
   S1:StringIdentifier ","                           <<\r
                                                        mCVfrRulesDB.RegisterRule (S1->getText());\r
-                                                       RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));\r
+                                                       RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText())); \r
                                                     >>\r
   vfrStatementExpression[0]\r
   E:EndRule                                         << CRT_END_OP (E); >>\r
@@ -890,7 +971,7 @@ vfrStatementRules :
 vfrStatementDefault :\r
   <<\r
      BOOLEAN               IsExp         = FALSE;\r
-     EFI_IFR_TYPE_VALUE    Val;\r
+     EFI_IFR_TYPE_VALUE    Val; \r
      CIfrDefault           DObj;\r
      EFI_DEFAULT_ID        DefaultId     = EFI_HII_DEFAULT_CLASS_STANDARD;\r
      CHAR8                 *VarStoreName = NULL;\r
@@ -900,29 +981,31 @@ vfrStatementDefault :
   (\r
     (\r
         vfrStatementValue ","                       << IsExp = TRUE; DObj.SetScope (1); >>\r
-      | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","\r
+      | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","  \r
                                                     << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>\r
     )\r
     {\r
       DefaultStore "=" SN:StringIdentifier ","      << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>\r
     }\r
-                                                    <<\r
-                                                                                                          _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
-                                                                                                          _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
-                                                                                                          if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {\r
-                                                                                                            _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
-                                                                                                                                                    DefaultId,\r
-                                                                                                                                                                        _GET_CURRQEST_VARTINFO(),\r
-                                                                                                                                                                        VarStoreName,\r
-                                                                                                                                                                        _GET_CURRQEST_DATATYPE (),\r
-                                                                                                                                                                        Val), D);\r
-                                                                                                          }\r
+                                                    << \r
+                                                                                                                                  _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
+                                                                                                                                  _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
+                                                                                                                                  if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) { \r
+                                                                                                                                    _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
+                                                                                                                                                                  DefaultId, \r
+                                                                                                                                                                                                _GET_CURRQEST_VARTINFO(), \r
+                                                                                                                                                                                                VarStoreName, \r
+                                                                                                                                                                                                _GET_CURRQEST_DATATYPE (), \r
+                                                                                                                                                                                                Val), \r
+                                                                                                                                                                                                D->getLine()\r
+                                                                                                                                                                                                ); \r
+                                                                                                                                  }\r
                                                                                                        >>\r
   )\r
   ;\r
 \r
 vfrStatementStat :\r
-  vfrStatementSubTitle        |\r
+  vfrStatementSubTitle        | \r
   vfrStatementStaticText      |\r
   vfrStatementCrossReference\r
   ;\r
@@ -938,15 +1021,31 @@ vfrStatementQuestions :
 \r
 vfrStatementConditional :\r
   vfrStatementDisableIfStat   |\r
-  vfrStatementSuppressIfStat  |\r
-  vfrStatementGrayOutIfStat\r
+  vfrStatementSuppressIfStat  |    //enhance to be compatible for framework endif\r
+  vfrStatementGrayOutIfStat   |\r
+  vfrStatementInconsistentIfStat   //to be compatible for framework\r
+  ;\r
+\r
+vfrStatementConditionalNew :\r
+  vfrStatementDisableIfStat      |\r
+  vfrStatementSuppressIfStatNew  |  \r
+  vfrStatementGrayOutIfStatNew   |\r
+  vfrStatementInconsistentIfStat   //to be compatible for framework\r
+  ;\r
+\r
+vfrStatementSuppressIfStat :\r
+  <<mCompatibleMode>>? vfrStatementSuppressIfStatOld\r
+  | vfrStatementSuppressIfStatNew\r
+  ;\r
+\r
+vfrStatementGrayOutIfStat :\r
+  <<mCompatibleMode>>? vfrStatementGrayOutIfStatOld\r
+  | vfrStatementGrayOutIfStatNew\r
   ;\r
 \r
 vfrStatementInvalid :\r
-                                                       << _CRT_OP (FALSE); >>\r
   (\r
     vfrStatementInvalidHidden          |\r
-    vfrStatementInvalidInconsistentIf  |\r
     vfrStatementInvalidInventory       |\r
     vfrStatementInvalidSaveRestoreDefaults\r
   )\r
@@ -954,7 +1053,7 @@ vfrStatementInvalid :
   ;\r
 \r
 flagsField :\r
-  Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |\r
+  Number | InteractiveFlag | ManufacturingFlag | DefaultFlag | \r
   NVAccessFlag | ResetRequiredFlag | LateCheckFlag\r
   ;\r
 \r
@@ -987,7 +1086,7 @@ subtitleFlagsField [UINT8 & Flags] :
   ;\r
 \r
 vfrStatementStaticText :\r
-  <<\r
+  << \r
      UINT8           Flags   = 0;\r
      EFI_QUESTION_ID QId     = EFI_QUESTION_ID_INVALID;\r
      EFI_STRING_ID   TxtTwo  = EFI_STRING_ID_INVALID;\r
@@ -1006,19 +1105,20 @@ vfrStatementStaticText :
                                                           if (Flags & EFI_IFR_FLAG_CALLBACK) {\r
                                                             CIfrAction AObj;\r
                                                             mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);\r
+                                                            AObj.SetLineNo (F->getLine());\r
                                                             AObj.SetQuestionId (QId);\r
                                                             AObj.SetPrompt (_STOSID(S2->getText()));\r
                                                             AObj.SetHelp (_STOSID(S1->getText()));\r
                                                             _PCATCH(AObj.SetFlags (Flags), F->getLine());\r
                                                             AssignQuestionKey (AObj, KN);\r
-                                                            CRT_END_OP (T);\r
+                                                            CRT_END_OP (KN);\r
                                                           } else {\r
-                                                                                                                   CIfrText TObj;\r
-                                                                                                                   TObj.SetLineNo (T->getLine());\r
-                                                                                                                       TObj.SetHelp (_STOSID(S1->getText()));\r
-                                                                                                                       TObj.SetPrompt (_STOSID(S2->getText()));\r
-                                                                                                                       TObj.SetTextTwo (TxtTwo);\r
-                                                                                                                 }\r
+                                                                                                                                           CIfrText TObj;\r
+                                                                                                                                           TObj.SetLineNo (T->getLine());\r
+                                                                                                                                                 TObj.SetHelp (_STOSID(S1->getText()));\r
+                                                                                                                                                 TObj.SetPrompt (_STOSID(S2->getText()));\r
+                                                                                                                                                 TObj.SetTextTwo (TxtTwo);\r
+                                                                                                                                           }\r
                                                        >>\r
   { "," vfrStatementStatTagList }\r
   ";"\r
@@ -1035,12 +1135,12 @@ vfrStatementCrossReference :
   ;\r
 \r
 vfrStatementGoto :\r
-  <<\r
+  << \r
      UINT8               RefType = 1;\r
      EFI_STRING_ID       DevPath;\r
      EFI_GUID            FSId;\r
      EFI_FORM_ID         FId;\r
-        EFI_QUESTION_ID     QId    = EFI_QUESTION_ID_INVALID;\r
+          EFI_QUESTION_ID     QId    = EFI_QUESTION_ID_INVALID;\r
      UINT32              BitMask;\r
      CIfrQuestionHeader  *QHObj = NULL;\r
      CIfrRef             *R1Obj = NULL;\r
@@ -1055,9 +1155,9 @@ vfrStatementGoto :
       FormSetGuid "=" guidDefinition[FSId] ","\r
       FormId "=" F1:Number ","\r
       Question "=" QN1:Number ","\r
-                                                       <<\r
+                                                       << \r
                                                           RefType = 4;\r
-                                                          DevPath = _STOSID(P->getText());\r
+                                                          DevPath = _STOSID(P->getText()); \r
                                                           FId = _STOFID(F1->getText());\r
                                                           QId = _STOQID(QN1->getText());\r
                                                        >>\r
@@ -1076,7 +1176,7 @@ vfrStatementGoto :
     |\r
     (\r
       FormId "=" F3:Number ","                         << RefType = 2; FId = _STOFID(F3->getText()); >>\r
-      Question "="\r
+      Question "=" \r
       (\r
           QN3:StringIdentifier ","                     << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>\r
         | QN4:Number ","                               << QId = _STOQID(QN4->getText()); >>\r
@@ -1084,7 +1184,7 @@ vfrStatementGoto :
     )\r
     |\r
     (\r
-      F4:Number ","                                    <<\r
+      F4:Number ","                                    << \r
                                                           RefType = 1;\r
                                                           FId = _STOFID(F4->getText());\r
                                                        >>\r
@@ -1094,31 +1194,31 @@ vfrStatementGoto :
                                                           switch (RefType) {\r
                                                           case 4:\r
                                                             {\r
-                                                              R4Obj = new CIfrRef4;\r
-                                                              QHObj = R4Obj;\r
-                                                              R4Obj->SetLineNo(G->getLine());\r
-                                                              R4Obj->SetDevicePath (DevPath);\r
-                                                              R4Obj->SetFormSetId (FSId);\r
-                                                              R4Obj->SetFormId (FId);\r
-                                                              R4Obj->SetQuestionId (QId);\r
+                                                              R4Obj = new CIfrRef4; \r
+                                                              QHObj = R4Obj; \r
+                                                              R4Obj->SetLineNo(G->getLine()); \r
+                                                              R4Obj->SetDevicePath (DevPath); \r
+                                                              R4Obj->SetFormSetId (FSId); \r
+                                                              R4Obj->SetFormId (FId); \r
+                                                              R4Obj->SetQuestionId (QId); \r
                                                               break;\r
                                                             }\r
                                                           case 3:\r
                                                             {\r
-                                                              R3Obj = new CIfrRef3;\r
-                                                              QHObj = R3Obj;\r
-                                                              R3Obj->SetLineNo(G->getLine());\r
-                                                              R3Obj->SetFormSetId (FSId);\r
-                                                              R3Obj->SetFormId (FId);\r
-                                                              R3Obj->SetQuestionId (QId);\r
+                                                              R3Obj = new CIfrRef3; \r
+                                                              QHObj = R3Obj; \r
+                                                              R3Obj->SetLineNo(G->getLine()); \r
+                                                              R3Obj->SetFormSetId (FSId); \r
+                                                              R3Obj->SetFormId (FId); \r
+                                                              R3Obj->SetQuestionId (QId); \r
                                                               break;\r
                                                             }\r
                                                           case 2:\r
                                                             {\r
-                                                              R2Obj = new CIfrRef2;\r
-                                                              QHObj = R2Obj;\r
-                                                              R2Obj->SetLineNo(G->getLine());\r
-                                                              R2Obj->SetFormId (FId);\r
+                                                              R2Obj = new CIfrRef2; \r
+                                                              QHObj = R2Obj; \r
+                                                              R2Obj->SetLineNo(G->getLine()); \r
+                                                              R2Obj->SetFormId (FId); \r
                                                               _PCATCH(R2Obj->SetQuestionId (QId), QN3);\r
                                                               break;\r
                                                             }\r
@@ -1161,12 +1261,12 @@ getStringId :
 \r
 vfrStatementResetButton :\r
   <<\r
-     CIfrResetButton RBObj;\r
+     CIfrResetButton RBObj; \r
      UINT16          DefaultId;\r
   >>\r
   L:ResetButton                                        << RBObj.SetLineNo(L->getLine()); >>\r
-  DefaultStore\r
-  "=" N:StringIdentifier ","                           <<\r
+  DefaultStore \r
+  "=" N:StringIdentifier ","                           << \r
                                                           _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());\r
                                                           RBObj.SetDefaultId (DefaultId);\r
                                                        >>\r
@@ -1190,7 +1290,7 @@ vfrStatementBooleanType :
 //     prompt      = STRING_TOKEN(STR_CHECK_BOX_PROMPT),\r
 //     help        = STRING_TOKEN(STR_CHECK_BOX_HELP),\r
 //     flags       = CHECKBOX_DEFAULT | CALLBACK,\r
-//     default value = TRUE, defaultstore = MyDefaultStore,\r
+//     default value = TRUE, defaultstore = MyDefaultStore, \r
 //   endcheckbox;\r
 //\r
 vfrStatementCheckBox :\r
@@ -1233,8 +1333,8 @@ vfrStatementCheckBox :
                                                               L,\r
                                                               "No manufacturing default storage found"\r
                                                               );\r
-                                                                                                                 }\r
-                                                                                                          >>\r
+                                                                                                                                         }\r
+                                                                                                                                  >>\r
   }\r
   {\r
     Key "=" KN:Number  ","                             << AssignQuestionKey (CBObj, KN); >>\r
@@ -1254,7 +1354,16 @@ vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
   ;\r
 \r
 checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :\r
-    N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
+    N:Number                                           << \r
+                                                          if (mCompatibleMode) {\r
+                                                            //\r
+                                                            // set question flag\r
+                                                            //\r
+                                                            $LFlags |= _STOU8(N->getText());\r
+                                                          } else {\r
+                                                            _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine());\r
+                                                          }\r
+                                                       >>  \r
   | "CHECKBOX_DEFAULT"                                 << $LFlags |= 0x01; >>\r
   | "CHECKBOX_DEFAULT_MFG"                             << $LFlags |= 0x02; >>\r
   | questionheaderFlagsField[HFlags]\r
@@ -1298,7 +1407,7 @@ vfrStatementDate :
      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
      CHAR8              *VarIdStr[3] = {NULL, };\r
      CIfrDate           DObj;\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
   >>\r
   L:Date                                               << DObj.SetLineNo(L->getLine()); >>\r
   (\r
@@ -1327,16 +1436,16 @@ vfrStatementDate :
       Help   "=" "STRING_TOKEN" "\(" DH:Number "\)" ","\r
       minMaxDateStepDefault[Val.date, 2]\r
                                                        <<\r
-                                                          mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
+                                                          mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); \r
                                                           DObj.SetQuestionId (QId);\r
                                                           DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);\r
-                                                                                                                 DObj.SetPrompt (_STOSID(YP->getText()));\r
-                                                                                                                 DObj.SetHelp (_STOSID(YH->getText()));\r
-                                                                                                                 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
+                                                                                                                                         DObj.SetPrompt (_STOSID(YP->getText()));\r
+                                                                                                                                         DObj.SetHelp (_STOSID(YH->getText()));\r
+                                                                                                                                         if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
                                                        >>\r
-                                                          << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>\r
-      ( vfrStatementInconsistentIf )*\r
+                                                          << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DefaultObj.SetLineNo(L->getLine());} >>\r
     )\r
+    ( vfrStatementInconsistentIf )*\r
   )\r
   E:EndDate                                            << CRT_END_OP (E); >>\r
   ";"\r
@@ -1349,10 +1458,10 @@ minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
   {\r
     "default" "=" N:Number ","                         <<\r
                                                           switch (KeyValue) {\r
-                                                          case 0: D.Year  = _STOU16(N->getText()); break;\r
-                                                          case 1: D.Month = _STOU8(N->getText()); break;\r
+                                                          case 0: D.Year  = _STOU16(N->getText()); break; \r
+                                                          case 1: D.Month = _STOU8(N->getText()); break; \r
                                                           case 2: D.Day   = _STOU8(N->getText()); break;\r
-                                                                                                                 }\r
+                                                                                                                 } \r
                                                        >>\r
   }\r
   ;\r
@@ -1464,7 +1573,7 @@ vfrStatementOneOf :
   L:OneOf                                              << OObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[OObj] ","                          << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>\r
   { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }\r
-  {\r
+  { \r
     vfrSetMinMaxStep[OObj]\r
   }\r
   vfrStatementQuestionOptionList\r
@@ -1520,7 +1629,7 @@ stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
 \r
 vfrStatementPassword :\r
   <<\r
-     CIfrPassword PObj;\r
+     CIfrPassword PObj; \r
   >>\r
   L:Password                                           << PObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[PObj] ","\r
@@ -1549,12 +1658,12 @@ passwordFlagsField [UINT8 & HFlags] :
 \r
 vfrStatementOrderedList :\r
   <<\r
-     CIfrOrderedList OLObj;\r
+     CIfrOrderedList OLObj; \r
   >>\r
   L:OrderedList                                        << OLObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[OLObj] ","\r
                                                        << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>\r
-  {\r
+  { \r
     MaxContainers "=" M:Number ","                     << OLObj.SetMaxContainers (_STOU8(M->getText())); >>\r
   }\r
   { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }\r
@@ -1584,7 +1693,7 @@ vfrStatementTime :
      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
      CHAR8              *VarIdStr[3] = {NULL, };\r
      CIfrTime           TObj;\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
   >>\r
   L:Time                                               << TObj.SetLineNo(L->getLine()); >>\r
   (\r
@@ -1613,15 +1722,16 @@ vfrStatementTime :
       Help   "=" "STRING_TOKEN" "\(" SH:Number "\)" ","\r
       minMaxTimeStepDefault[Val.time, 2]\r
                                                        <<\r
-                                                          mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
+                                                          mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); \r
                                                           TObj.SetQuestionId (QId);\r
                                                           TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);\r
-                                                                                                                 TObj.SetPrompt (_STOSID(HP->getText()));\r
-                                                                                                                 TObj.SetHelp (_STOSID(HH->getText()));\r
-                                                                                                                 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
+                                                                                                                                         TObj.SetPrompt (_STOSID(HP->getText()));\r
+                                                                                                                                         TObj.SetHelp (_STOSID(HH->getText()));\r
+                                                                                                                                         if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
                                                        >>\r
-                                                       << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>\r
+                                                       << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DefaultObj.SetLineNo(L->getLine());} >>\r
     )\r
+    ( vfrStatementInconsistentIf )*\r
   )\r
   E:EndTime                                            << CRT_END_OP (E); >>\r
   ";"\r
@@ -1634,10 +1744,10 @@ minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
   {\r
     "default" "=" N:Number ","                         <<\r
                                                           switch (KeyValue) {\r
-                                                          case 0: T.Hour   = _STOU8(N->getText()); break;\r
-                                                          case 1: T.Minute = _STOU8(N->getText()); break;\r
+                                                          case 0: T.Hour   = _STOU8(N->getText()); break; \r
+                                                          case 1: T.Minute = _STOU8(N->getText()); break; \r
                                                           case 2: T.Second = _STOU8(N->getText()); break;\r
-                                                                                                                 }\r
+                                                                                                                 } \r
                                                        >>\r
   }\r
   ;\r
@@ -1664,7 +1774,7 @@ vfrStatementQuestionTag :
   vfrStatementNoSubmitIf        |\r
   vfrStatementDisableIfQuest    |\r
   vfrStatementRefresh           |\r
-  vfrStatementVarstoreDevice\r
+  vfrStatementVarstoreDevice \r
   ;\r
 \r
 vfrStatementQuestionTagList :\r
@@ -1673,6 +1783,7 @@ vfrStatementQuestionTagList :
 \r
 vfrStatementQuestionOptionTag :\r
   vfrStatementSuppressIfQuest   |\r
+  vfrStatementGrayOutIfQuest    |\r
   vfrStatementValue             |\r
   vfrStatementDefault           |\r
   vfrStatementOptions\r
@@ -1681,17 +1792,25 @@ vfrStatementQuestionOptionTag :
 vfrStatementQuestionOptionList :\r
   (\r
     vfrStatementQuestionTag     |\r
-    vfrStatementQuestionOptionTag\r
+    vfrStatementQuestionOptionTag \r
   )*\r
   ;\r
 \r
 vfrStatementStatList :\r
   vfrStatementStat                        |\r
   vfrStatementQuestions                   |\r
-  vfrStatementConditional                 |\r
+  vfrStatementConditionalNew              |\r
+  vfrStatementLabel                       |\r
   // Just for framework vfr compatibility\r
-  vfrStatementLabel\r
-  //vfrStatementInvalid\r
+  vfrStatementInvalid\r
+  ;\r
+\r
+vfrStatementStatListOld :\r
+  vfrStatementStat                        |\r
+  vfrStatementQuestions                   |\r
+  vfrStatementLabel                       |\r
+  // Just for framework vfr compatibility\r
+  vfrStatementInvalid\r
   ;\r
 \r
 vfrStatementDisableIfStat :\r
@@ -1703,25 +1822,92 @@ vfrStatementDisableIfStat :
   ";"\r
   ;\r
 \r
-vfrStatementSuppressIfStat :\r
+vfrStatementInconsistentIfStat :\r
+  << CIfrInconsistentIf IIObj; >>\r
+  L:InconsistentIf                                     << \r
+                                                          if (!mCompatibleMode) {\r
+                                                            _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
+                                                          }\r
+                                                          IIObj.SetLineNo(L->getLine()); \r
+                                                       >>\r
+  Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << IIObj.SetError (_STOSID(S->getText())); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0]\r
+  E:EndIf                                              << CRT_END_OP (E); >>\r
+  ";"\r
+  ;\r
+\r
+//\r
+// Compatible for framework vfr file\r
+//\r
+vfrStatementgrayoutIfSuppressIf:\r
   << CIfrSuppressIf SIObj; >>\r
   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0] ";"\r
-  ( vfrStatementStatList )*\r
-  E:EndIf                                              << CRT_END_OP (E); >>\r
+  vfrStatementExpression[0] \r
   ";"\r
   ;\r
 \r
-vfrStatementGrayOutIfStat :\r
+vfrStatementsuppressIfGrayOutIf:\r
   << CIfrGrayOutIf GOIObj; >>\r
   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
   vfrStatementExpression[0]\r
   ";"\r
+  ;\r
+\r
+vfrStatementSuppressIfStatNew :\r
+  << CIfrSuppressIf SIObj;>>\r
+  L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0] \r
+  ";"\r
   ( vfrStatementStatList )*\r
-  E:EndIf                                              << CRT_END_OP (E); >>\r
+  E: EndIf ";"                                       << CRT_END_OP (E); >>\r
+  ;\r
+\r
+vfrStatementGrayOutIfStatNew :\r
+  << CIfrGrayOutIf GOIObj;>>\r
+  L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0]\r
+  ";"\r
+  ( vfrStatementStatList )*\r
+  E: EndIf ";"                                       << CRT_END_OP (E); >>\r
+  ;\r
+\r
+vfrStatementSuppressIfStatOld :\r
+  << \r
+    CIfrSuppressIf SIObj;\r
+    BOOLEAN        GrayOutExist = FALSE;\r
+  >>\r
+  L:SuppressIf                                       << SIObj.SetLineNo(L->getLine()); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0] \r
   ";"\r
+  { \r
+    vfrStatementsuppressIfGrayOutIf \r
+                                                     << GrayOutExist = TRUE; >>\r
+  }\r
+  ( vfrStatementStatListOld )*\r
+  E: EndIf ";"                                       << if (GrayOutExist) CRT_END_OP (E); CRT_END_OP (E);>>\r
+  ;\r
+\r
+vfrStatementGrayOutIfStatOld :\r
+  << \r
+    CIfrGrayOutIf  GOIObj;\r
+    BOOLEAN        SuppressExist = FALSE;   \r
+  >>\r
+  L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0]\r
+  ";"\r
+  { \r
+    vfrStatementgrayoutIfSuppressIf \r
+                                                       << SuppressExist = TRUE; >>\r
+  }\r
+  ( vfrStatementStatListOld )*\r
+  E: EndIf ";"                                         << if (SuppressExist) CRT_END_OP (E); CRT_END_OP (E); >>\r
   ;\r
 \r
 vfrImageTag :\r
@@ -1800,6 +1986,15 @@ vfrStatementSuppressIfQuest :
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ;\r
 \r
+vfrStatementGrayOutIfQuest :\r
+  << CIfrGrayOutIf GOIObj; >>\r
+  L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
+  { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
+  vfrStatementExpression[0] ";"\r
+  vfrStatementQuestionOptionList\r
+  E:EndIf                                              << CRT_END_OP (E); >>\r
+  ;\r
+\r
 vfrStatementOptions :\r
   vfrStatementOneOfOption\r
   ;\r
@@ -1809,26 +2004,50 @@ vfrStatementOneOfOption :
      EFI_IFR_TYPE_VALUE Val;\r
      CIfrOneOfOption    OOOObj;\r
      CHAR8              *VarStoreName = NULL;\r
-\r
   >>\r
   L:Option                                             << OOOObj.SetLineNo(L->getLine()); >>\r
   Text  "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << OOOObj.SetOption (_STOSID(S->getText())); >>\r
   Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","    << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>\r
   F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]\r
                                                        <<\r
+                                                          _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());\r
                                                           if (OOOObj.GetFlags () & 0x10) {\r
-                                                            _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());\r
                                                             _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
-                                                                                                                                                   EFI_HII_DEFAULT_CLASS_STANDARD,\r
-                                                                                                                                                                       _GET_CURRQEST_VARTINFO(),\r
-                                                                                                                                                                       VarStoreName,\r
-                                                                                                                                                                   _GET_CURRQEST_DATATYPE (),\r
-                                                                                                                                                                       Val\r
-                                                                                                                                                                       ), L->getLine());\r
+                                                                                                                                                               EFI_HII_DEFAULT_CLASS_STANDARD, \r
+                                                                                                                                                                                       _GET_CURRQEST_VARTINFO(), \r
+                                                                                                                                                                                         VarStoreName, \r
+                                                                                                                                                                                   _GET_CURRQEST_DATATYPE (), \r
+                                                                                                                                                                                         Val\r
+                                                                                                                                                                                         ), L->getLine());\r
                                                           }\r
+                                                          if (OOOObj.GetFlags () & 0x20) {\r
+                                                            _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
+                                                                                                                                                               EFI_HII_DEFAULT_CLASS_MANUFACTURING, \r
+                                                                                                                                                                                       _GET_CURRQEST_VARTINFO(), \r
+                                                                                                                                                                                         VarStoreName, \r
+                                                                                                                                                                                   _GET_CURRQEST_DATATYPE (), \r
+                                                                                                                                                                                         Val\r
+                                                                                                                                                                                         ), L->getLine());\r
+                                                          }\r
+                                                       >>\r
+  { \r
+    "," Key "=" KN:Number                              << \r
+                                                         if (!mCompatibleMode) {\r
+                                                           _PCATCH (VFR_RETURN_UNSUPPORTED, KN);\r
+                                                         }\r
+                                                         //\r
+                                                         // Guid Option Key\r
+                                                         //\r
+                                                         CIfrOptionKey IfrOptionKey (\r
+                                                                         gCurrentQuestion->QUESTION_ID(),\r
+                                                                         Val,\r
+                                                                         _STOQID(KN->getText())\r
+                                                                         );\r
+                                                         SET_LINE_INFO (IfrOptionKey, KN);\r
                                                        >>\r
+  }\r
   (\r
-    "," vfrImageTag                                    << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>\r
+    T:"," vfrImageTag                                  << OOOObj.SetScope (1); CRT_END_OP (T); >>\r
   )*\r
   ";"\r
   ;\r
@@ -1887,8 +2106,12 @@ vfrStatementBanner :
 //\r
 // keep some syntax for compatibility but not generate any IFR object\r
 //\r
-vfrStatementInvalidHidden :\r
-  Hidden\r
+vfrStatementInvalidHidden : \r
+  L:Hidden               <<\r
+                            if (!mCompatibleMode) {\r
+                              _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
+                            }\r
+                         >>\r
   Value "=" Number ","\r
   Key "=" Number ";"\r
   ;\r
@@ -1903,21 +2126,37 @@ vfrStatementInvalidInconsistentIf :
   ;\r
 \r
 vfrStatementInvalidInventory :\r
-  Inventory\r
+  L:Inventory                                      <<\r
+                                                      if (!mCompatibleMode) {\r
+                                                        _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
+                                                      }\r
+                                                   >>\r
   Help "=" "STRING_TOKEN" "\(" Number "\)" ","\r
   Text "=" "STRING_TOKEN" "\(" Number "\)" ","\r
   {\r
     Text  "=" "STRING_TOKEN" "\(" Number "\)"\r
   }\r
-  ";"\r
+  ";" \r
   ;\r
 \r
-vfrStatementInvalidSaveRestoreDefaults :\r
-  (Save | Restore)\r
+vfrStatementInvalidSaveRestoreDefaults : \r
+  (\r
+   L:Save                                          <<\r
+                                                      if (!mCompatibleMode) {\r
+                                                        _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
+                                                      }\r
+                                                   >>\r
+  |\r
+   K:Restore                                       <<\r
+                                                      if (!mCompatibleMode) {\r
+                                                        _PCATCH (VFR_RETURN_UNSUPPORTED, K);\r
+                                                      }\r
+                                                   >>\r
+  )\r
   Defaults ","\r
   FormId "=" Number  ","\r
   Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","\r
-  Help   "=" "STRING_TOKEN" "\(" Number "\)"\r
+  Help   "=" "STRING_TOKEN" "\(" Number "\)" \r
   { "," FLAGS "=" flagsField ( "\|" flagsField )* }\r
   { "," Key   "=" Number }\r
   ";"\r
@@ -1965,7 +2204,7 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
   (\r
     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
   )*\r
-                                                       << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>\r
+                                                       << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj;} >>\r
   ;\r
 \r
 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -1976,7 +2215,7 @@ andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   ;\r
 \r
 bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
-  bitwiseandTerm[$RootLevel, $ExpOpCount]\r
+  bitwiseandTerm[$RootLevel, $ExpOpCount]          \r
   (\r
     L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount]      << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>\r
   )*\r
@@ -2024,7 +2263,7 @@ compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
   ;\r
 \r
 shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
-  addMinusTerm[$RootLevel, $ExpOpCount]\r
+  addMinusTerm[$RootLevel, $ExpOpCount]           \r
   (\r
     (\r
       L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount]    << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>\r
@@ -2051,7 +2290,7 @@ addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
 \r
 multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
   castTerm[$RootLevel, $ExpOpCount]\r
-  (\r
+  ( \r
     (\r
       L1:"\*" castTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>\r
     )\r
@@ -2062,7 +2301,7 @@ multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
     |\r
     (\r
       L3:"%" castTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>\r
-    )\r
+    ) \r
   )*\r
   ;\r
 \r
@@ -2128,6 +2367,7 @@ vfrExpressionParen [UINT32 & RootLevel, UINT32 & ExpOpCount]:
 \r
 vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
     dupExp[$RootLevel, $ExpOpCount]\r
+  | vareqvalExp[$RootLevel, $ExpOpCount]  //Compatible for Framework vareqval \r
   | ideqvalExp[$RootLevel, $ExpOpCount]\r
   | ideqidExp[$RootLevel, $ExpOpCount]\r
   | ideqvallistExp[$RootLevel, $ExpOpCount]\r
@@ -2141,6 +2381,84 @@ dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
   L:Dup                                                << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0)); $ExpOpCount++; } >>\r
   ;\r
 \r
+vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
+  <<\r
+     EFI_QUESTION_ID QId;\r
+     UINT32          Mask;\r
+     UINT16          ConstVal;\r
+     CHAR8           *VarIdStr;\r
+     UINT32          LineNo;\r
+     EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
+     EFI_VFR_RETURN_CODE   VfrReturnCode = VFR_RETURN_SUCCESS;\r
+  >>\r
+  L:VarEqVal                                          << \r
+                                                        if (!mCompatibleMode) {\r
+                                                          _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
+                                                        }\r
+                                                      >>\r
+  VK:Var\r
+  OpenParen \r
+  VN:Number                                           <<\r
+                                                          VarIdStr = NULL; _STRCAT(&VarIdStr, VK->getText()); _STRCAT(&VarIdStr, VN->getText()); \r
+                                                          VfrReturnCode = mCVfrDataStorage.GetVarStoreType (VarIdStr, VarStoreType);\r
+                                                          if (VfrReturnCode == VFR_RETURN_UNDEFINED) {\r
+                                                            _PCATCH (mCVfrDataStorage.DeclareEfiVarStore (\r
+                                                                                        VarIdStr, \r
+                                                                                        &mFormsetGuid, \r
+                                                                                        _STOSID(VN->getText()), \r
+                                                                                        0x2,   //default type is UINT16\r
+                                                                                        FALSE\r
+                                                                                        ), VN);\r
+                                                          } else {\r
+                                                            _PCATCH (VfrReturnCode, VN);\r
+                                                          }\r
+                                                          mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask);\r
+                                                          LineNo = GET_LINENO(VN);\r
+                                                      >>\r
+  CloseParen\r
+  (\r
+    (\r
+      "=="\r
+      V1:Number                                        << ConstVal = _STOU16(V1->getText()); >>\r
+                                                       <<\r
+                                                                                                                                     if (Mask == 0) {\r
+                                                                                                                                               CIfrEqIdVal EIVObj (L->getLine());\r
+                                                                                                                                               _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
+                                                                                                                                               EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
+                                                                                                                                               EIVObj.SetValue (ConstVal);\r
+                                                                                                                                               $ExpOpCount++;                                                                                                                  \r
+                                                                                                                                         } else {\r
+                                                                                                                                               IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);\r
+                                                                                                                                         }\r
+                                                                                                                                  >>\r
+    )\r
+    |\r
+    (\r
+      "<="\r
+      V2:Number                                        << ConstVal = _STOU16(V2->getText()); >>\r
+                                                       << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>\r
+    )\r
+    |\r
+    (\r
+      "<"\r
+      V3:Number                                        << ConstVal = _STOU16(V3->getText()); >>\r
+                                                       << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>\r
+    )\r
+    |\r
+    (\r
+      ">="\r
+      V4:Number                                        << ConstVal = _STOU16(V4->getText()); >>\r
+                                                       << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>\r
+    )\r
+    |\r
+    (\r
+      ">"\r
+      V5:Number                                        << ConstVal = _STOU16(V5->getText()); >>\r
+                                                       << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>\r
+    )\r
+  )\r
+  ;\r
+\r
 ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   <<\r
      EFI_QUESTION_ID QId;\r
@@ -2156,16 +2474,16 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
       "=="\r
       V1:Number                                        << ConstVal = _STOU16(V1->getText()); >>\r
                                                        <<\r
-                                                                                                             if (Mask == 0) {\r
-                                                                                                                       CIfrEqIdVal EIVObj (L->getLine());\r
-                                                                                                                       _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
-                                                                                                                       EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
-                                                                                                                       EIVObj.SetValue (ConstVal);\r
-                                                                                                                       $ExpOpCount++;\r
-                                                                                                                 } else {\r
-                                                                                                                       IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);\r
-                                                                                                                 }\r
-                                                                                                          >>\r
+                                                                                                                                     if (Mask == 0) {\r
+                                                                                                                                               CIfrEqIdVal EIVObj (L->getLine());\r
+                                                                                                                                               _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
+                                                                                                                                               EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
+                                                                                                                                               EIVObj.SetValue (ConstVal);\r
+                                                                                                                                               $ExpOpCount++;                                                                                                                  \r
+                                                                                                                                         } else {\r
+                                                                                                                                               IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);\r
+                                                                                                                                         }\r
+                                                                                                                                  >>\r
     )\r
     |\r
     (\r
@@ -2205,18 +2523,18 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]\r
   (\r
     (\r
-      "=="\r
+      "==" \r
       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
-                                                       <<\r
+                             <<\r
                                                                                                              if (Mask[0] & Mask[1]) {\r
-                                                                                                                       IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);\r
-                                                                                                                 } else {\r
-                                                            CIfrEqIdId      EIIObj(L->getLine());\r
-                                                                                                                       _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));\r
-                                                            EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);\r
-                                                                                                                       EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);\r
-                                                                                                                       $ExpOpCount++;\r
-                                                                                                                 }\r
+                                                                                                                       IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);\r
+                                                                                                                 } else {\r
+                                  CIfrEqIdId      EIIObj(L->getLine());\r
+                                                                                                                       _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));\r
+                                  EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);\r
+                                                                                                                       EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);\r
+                                                                                                                       $ExpOpCount++;                                                                                                                  \r
+                                                                                                                 }\r
                                                                                                           >>\r
     )\r
     |\r
@@ -2257,38 +2575,31 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   >>\r
   L:IdEqValList\r
   vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]\r
-  "=="\r
+  "==" \r
   (\r
     V:Number                                           << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>\r
   )+\r
                                                        <<\r
-                                                                                                             if (Mask != 0) {\r
+                                                                                                                                     if (Mask != 0) {\r
                                                             IdEqListDoSpecial ($ExpOpCount, LineNo, QId, VarIdStr, Mask, ListLen, ValueList);\r
-                                                                                                                 } else {\r
-                                                                                           UINT16       Index;\r
+                                                                                                                                         } else {\r
+                                                                                                       UINT16       Index;\r
                                                             CIfrEqIdList EILObj(L->getLine());\r
-                                                                                                                       _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0));\r
-                                                            EILObj.SetQuestionId (QId, VarIdStr, LineNo);\r
-                                                                                                                       EILObj.SetListLength (ListLen);\r
-                                                                                                                       for (Index = 0; Index < ListLen; Index++) {\r
-                                                                                                                         EILObj.SetValueList (Index, ValueList[Index]);\r
-                                                                                                                       }\r
-                                                                                                                       $ExpOpCount++;\r
-                                                                                                                 }\r
-                                                                                                          >>\r
-  ;\r
-\r
-vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
-  L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number    <<\r
-                                                          {\r
-                                                            CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());\r
-                                                            _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));\r
-                                                            U64Obj1.SetValue (_STOU64(V1->getText()));\r
-                                                            U64Obj2.SetValue (_STOU64(V2->getText()));\r
-                                                          }\r
-                                                       >>\r
-                                                       << {CIfrEqual EObj(L->getLine()); } >>\r
-                                                                                                          << $ExpOpCount += 3; >>\r
+                                                                                                                                               _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0));\r
+                                                                                                                                               if (QId != EFI_QUESTION_ID_INVALID) {\r
+                                                              EILObj.SetQuestionId (QId, VarIdStr, LineNo);\r
+                                                                                                                                               }\r
+                                                                                                                                               EILObj.SetListLength (ListLen);\r
+                                                                                                                                               for (Index = 0; Index < ListLen; Index++) {\r
+                                                                                                                                                 EILObj.SetValueList (Index, ValueList[Index]);\r
+                                                                                                                                               }\r
+                                                                                                                                               if (QId == EFI_QUESTION_ID_INVALID) {\r
+                                                                                                                                                 EILObj.UpdateIfrBuffer();\r
+                                                                                                                                                 EILObj.SetQuestionId (QId, VarIdStr, LineNo);\r
+                                                                                                                                               }\r
+                                                                                                                                               $ExpOpCount++;\r
+                                                                                                                                         }\r
+                                                                                                                                     >>\r
   ;\r
 \r
 questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -2316,7 +2627,7 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
     (\r
       "\("\r
          (\r
-          QN:StringIdentifier                          <<\r
+          QN:StringIdentifier                          << \r
                                                           QName  = QN->getText();\r
                                                                                                                  LineNo = QN->getLine();\r
                                                           mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);\r
@@ -2465,7 +2776,7 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   findFormat[Format] ( "\|" findFormat[Format] )*\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
-  ","\r
+  "," \r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
@@ -2492,7 +2803,7 @@ tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
-  ","\r
+  "," \r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
@@ -2521,8 +2832,8 @@ spanFlags [UINT8 & Flags] :
 \r
 //******************************************************************************\r
 //\r
-// Parser class definition.\r
-//\r
+// Parser class definition. \r
+//  \r
 class EfiVfrParser {\r
 <<\r
 private:\r
@@ -2542,6 +2853,12 @@ private:
 \r
   EFI_VARSTORE_INFO   mCurrQestVarInfo;\r
 \r
+//\r
+// For framework vfr compatibility\r
+//\r
+  BOOLEAN             mCompatibleMode;\r
+  EFI_GUID            mFormsetGuid;\r
+\r
   VOID                _CRT_OP (IN BOOLEAN);\r
 \r
   VOID                _SAVE_CURRQEST_VARINFO (IN EFI_VARSTORE_INFO &);\r
@@ -2555,10 +2872,12 @@ public:
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE);\r
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);\r
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);\r
+  VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CHAR8 *);\r
 \r
   VOID                syn     (ANTLRAbstractToken  *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);\r
 \r
   CHAR8*              TrimHex (IN CHAR8 *, OUT BOOLEAN *);\r
+  CHAR8*              _U32TOS (IN UINT32);\r
   UINT8               _STOU8  (IN CHAR8 *);\r
   UINT16              _STOU16 (IN CHAR8 *);\r
   UINT32              _STOU32 (IN CHAR8 *);\r
@@ -2575,7 +2894,7 @@ public:
   VOID                _CRGUID (EFI_GUID *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *);\r
   VOID                _DeclareDefaultLinearVarStore (IN UINT32);\r
   VOID                _DeclareStandardDefaultStorage (IN UINT32);\r
-\r
+  VOID                _DeclareDefaultFrameworkVarStore (IN UINT32);\r
 \r
   VOID                AssignQuestionKey (IN CIfrQuestionHeader &, IN ANTLRTokenPtr);\r
 \r
@@ -2583,22 +2902,26 @@ public:
   VOID                IdEqValDoSpecial      (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN EFI_COMPARE_TYPE);\r
   VOID                IdEqIdDoSpecial       (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE);\r
   VOID                IdEqListDoSpecial     (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *);\r
+//\r
+// For framework vfr compatibility\r
+//\r
+  VOID                SetCompatibleMode (IN BOOLEAN);  \r
 >>\r
 }\r
 \r
 <<\r
 VOID\r
 EfiVfrParser::_SAVE_OPHDR_COND (\r
-  IN CIfrOpHeader &OpHdr,\r
+  IN CIfrOpHeader &OpHdr, \r
   IN BOOLEAN      Cond\r
   )\r
 {\r
   if (Cond == TRUE) {\r
-#ifdef VFREXP_DEBUG\r
+#if 0\r
     printf ("######_SAVE_OPHDR_COND\n");\r
 #endif\r
     if (mCIfrOpHdr != NULL) {\r
-#ifdef VFREXP_DEBUG\r
+#if 0\r
       printf ("######_SAVE_OPHDR_COND Error\n");\r
 #endif\r
       return ;\r
@@ -2612,7 +2935,7 @@ EfiVfrParser::_CLEAR_SAVED_OPHDR (
   VOID\r
   )\r
 {\r
-#ifdef VFREXP_DEBUG\r
+#if 0\r
   printf ("######_CLEAR_SAVED_OPHDR\n");\r
 #endif\r
   mCIfrOpHdr = NULL;\r
@@ -2623,7 +2946,7 @@ EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
   VOID\r
   )\r
 {\r
-#ifdef VFREXP_DEBUG\r
+#if 0\r
   printf ("#######_SET_SAVED_OPHDR_SCOPE\n");\r
 #endif\r
   mCIfrOpHdr->SetScope (1);\r
@@ -2710,11 +3033,21 @@ EfiVfrParser::_PCATCH (
 }\r
 \r
 VOID\r
+EfiVfrParser::_PCATCH (\r
+  IN EFI_VFR_RETURN_CODE ReturnCode,\r
+  IN UINT32              LineNum,\r
+  IN CHAR8               *ErrorMsg\r
+  )\r
+{\r
+  mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);\r
+}\r
+\r
+VOID \r
 EfiVfrParser::syn (\r
-  ANTLRAbstractToken  *Tok,\r
-  ANTLRChar           *Egroup,\r
-  SetWordType         *Eset,\r
-  ANTLRTokenType      ETok,\r
+  ANTLRAbstractToken  *Tok, \r
+  ANTLRChar           *Egroup, \r
+  SetWordType         *Eset, \r
+  ANTLRTokenType      ETok, \r
   INT32               Huh\r
   )\r
 {\r
@@ -2745,6 +3078,17 @@ EfiVfrParser::TrimHex (
   return Str;\r
 }\r
 \r
+CHAR8 *\r
+EfiVfrParser::_U32TOS (\r
+  IN UINT32 Value\r
+  )\r
+{\r
+  CHAR8 *Str;\r
+  Str = new CHAR8[20];\r
+  sprintf (Str, "%d", Value);\r
+  return Str;\r
+}\r
+\r
 UINT8\r
 EfiVfrParser::_STOU8 (\r
   IN CHAR8*Str\r
@@ -2769,7 +3113,7 @@ EfiVfrParser::_STOU8 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    }\r
+    } \r
   }\r
 \r
   return Value;\r
@@ -2799,7 +3143,7 @@ EfiVfrParser::_STOU16 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    }\r
+    } \r
   }\r
 \r
   return Value;\r
@@ -2829,7 +3173,7 @@ EfiVfrParser::_STOU32 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    }\r
+    } \r
   }\r
 \r
   return Value;\r
@@ -2839,7 +3183,7 @@ UINT64
 EfiVfrParser::_STOU64 (\r
   IN CHAR8*Str\r
   )\r
-{\r
+{ \r
   BOOLEAN IsHex;\r
   UINT64  Value;\r
   CHAR8   c;\r
@@ -2859,16 +3203,16 @@ EfiVfrParser::_STOU64 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    }\r
+    } \r
   }\r
 \r
   return Value;\r
-}\r
+} \r
 \r
 EFI_HII_DATE\r
 EfiVfrParser::_STOD (\r
-  IN CHAR8 *Year,\r
-  IN CHAR8 *Month,\r
+  IN CHAR8 *Year, \r
+  IN CHAR8 *Month, \r
   IN CHAR8 *Day\r
   )\r
 {\r
@@ -2883,8 +3227,8 @@ EfiVfrParser::_STOD (
 \r
 EFI_HII_TIME\r
 EfiVfrParser::_STOT (\r
-  IN CHAR8 *Hour,\r
-  IN CHAR8 *Minute,\r
+  IN CHAR8 *Hour, \r
+  IN CHAR8 *Minute, \r
   IN CHAR8 *Second\r
   )\r
 {\r
@@ -2913,7 +3257,7 @@ EfiVfrParser::_STOFID (
   return (EFI_FORM_ID)_STOU16(Str);\r
 }\r
 \r
-EFI_QUESTION_ID\r
+EFI_QUESTION_ID \r
 EfiVfrParser::_STOQID (\r
   IN CHAR8 *Str\r
   )\r
@@ -2942,6 +3286,7 @@ EfiVfrParser::_STRCAT (
   NewStr[0] = '\0';\r
   if (*Dest != NULL) {\r
     strcpy (NewStr, *Dest);\r
+    delete *Dest;\r
   }\r
   strcat (NewStr, Src);\r
 \r
@@ -2950,17 +3295,17 @@ EfiVfrParser::_STRCAT (
 \r
 VOID\r
 EfiVfrParser::_CRGUID (\r
-  IN EFI_GUID *Guid,\r
-  IN CHAR8    *G1,\r
-  IN CHAR8    *G2,\r
-  IN CHAR8    *G3,\r
-  IN CHAR8    *G4,\r
-  IN CHAR8    *G5,\r
-  IN CHAR8    *G6,\r
-  IN CHAR8    *G7,\r
-  IN CHAR8    *G8,\r
-  IN CHAR8    *G9,\r
-  IN CHAR8    *G10,\r
+  IN EFI_GUID *Guid, \r
+  IN CHAR8    *G1, \r
+  IN CHAR8    *G2, \r
+  IN CHAR8    *G3, \r
+  IN CHAR8    *G4, \r
+  IN CHAR8    *G5, \r
+  IN CHAR8    *G6, \r
+  IN CHAR8    *G7, \r
+  IN CHAR8    *G8, \r
+  IN CHAR8    *G9, \r
+  IN CHAR8    *G10, \r
   IN CHAR8    *G11\r
   )\r
 {\r
@@ -2977,6 +3322,53 @@ EfiVfrParser::_CRGUID (
   Guid->Data4[7] = _STOU8(G11);\r
 }\r
 \r
+//\r
+// framework vfr to default declare varstore for each structure\r
+//\r
+VOID\r
+EfiVfrParser::_DeclareDefaultFrameworkVarStore (\r
+  IN UINT32 LineNo\r
+  )\r
+{\r
+  SVfrVarStorageNode    *pNode; \r
+\r
+  pNode = mCVfrDataStorage.GetBufferVarStoreList();\r
+  for (; pNode != NULL; pNode = pNode->mNext) {\r
+    //\r
+    // create the default varstore opcode for not exist varstore\r
+    //\r
+    if (!pNode->mAssignedFlag) {\r
+      CIfrVarStore      VSObj;\r
+      VSObj.SetLineNo (LineNo);\r
+      VSObj.SetVarStoreId (pNode->mVarStoreId);\r
+      VSObj.SetSize (pNode->mStorageInfo.mDataType->mTotalSize);\r
+      VSObj.SetName (pNode->mVarStoreName);\r
+      VSObj.SetGuid (&pNode->mGuid);\r
+#ifdef VFREXP_DEBUG\r
+      printf ("undefined VarStoreName is %s\n", pNode->mVarStoreName);\r
+#endif\r
+    }\r
+  }\r
+\r
+  pNode = mCVfrDataStorage.GetEfiVarStoreList();\r
+  for (; pNode != NULL; pNode = pNode->mNext) {\r
+    //\r
+    // create the default efi varstore opcode for not exist varstore\r
+    //\r
+    if (!pNode->mAssignedFlag) {\r
+      CIfrVarStoreEfi VSEObj;\r
+      VSEObj.SetLineNo (LineNo);\r
+      VSEObj.SetAttributes (0x00000002); //hardcode EFI_VARIABLE_BOOTSERVICE_ACCESS attribute\r
+      VSEObj.SetGuid (&pNode->mGuid);\r
+      VSEObj.SetVarStoreId (pNode->mVarStoreId); \r
+#ifdef VFREXP_DEBUG\r
+      printf ("undefined Efi VarStoreName is %s\n", pNode->mVarStoreName);\r
+#endif\r
+    }\r
+  }\r
+   \r
+}\r
+\r
 VOID\r
 EfiVfrParser::_DeclareDefaultLinearVarStore (\r
   IN UINT32 LineNo\r
@@ -2985,7 +3377,6 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
   UINT32            Index;\r
   CHAR8             **TypeNameList;\r
   UINT32            ListSize;\r
-  EFI_GUID          DefaultGuid =  { 0x9db3c415, 0xda00, 0x4233, { 0xae, 0xc6, 0x79, 0xb, 0x4f, 0x5b, 0x45, 0x66 } };\r
 \r
   mCVfrVarDataTypeDB.GetUserDefinedTypeNameList (&TypeNameList, &ListSize);\r
 \r
@@ -2996,9 +3387,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       TypeNameList[Index],\r
-                       &DefaultGuid,\r
-                       &mCVfrVarDataTypeDB,\r
+                       TypeNameList[Index], \r
+                       &mFormsetGuid, \r
+                       &mCVfrVarDataTypeDB, \r
                        TypeNameList[Index],\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
@@ -3007,9 +3398,13 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
     mCVfrVarDataTypeDB.GetDataTypeSize(TypeNameList[Index], &Size);\r
     VSObj.SetSize (Size);\r
     VSObj.SetName (TypeNameList[Index]);\r
-    VSObj.SetGuid (&DefaultGuid);\r
+    VSObj.SetGuid (&mFormsetGuid);\r
   }\r
 \r
+//\r
+// not required to declare Date and Time VarStore, \r
+// because code to support old format Data and Time\r
+//\r
   if (mCVfrVarDataTypeDB.IsTypeNameDefined ("Date") == FALSE) {\r
     UINT32            Size;\r
     EFI_VARSTORE_ID   VarStoreId;\r
@@ -3017,10 +3412,10 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       "Date",\r
-                                          &DefaultGuid,\r
-                                          &mCVfrVarDataTypeDB,\r
-                                          "EFI_HII_DATE",\r
+                       "Date", \r
+                                                  &mFormsetGuid, \r
+                                                  &mCVfrVarDataTypeDB, \r
+                                                  "EFI_HII_DATE",\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
     mCVfrDataStorage.GetVarStoreId("Date", &VarStoreId);\r
@@ -3028,7 +3423,7 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
     mCVfrVarDataTypeDB.GetDataTypeSize("EFI_HII_DATE", &Size);\r
     VSObj.SetSize (Size);\r
     VSObj.SetName ("Date");\r
-    VSObj.SetGuid (&DefaultGuid);\r
+    VSObj.SetGuid (&mFormsetGuid);\r
   }\r
 \r
   if (mCVfrVarDataTypeDB.IsTypeNameDefined ("Time") == FALSE) {\r
@@ -3038,9 +3433,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       "Time",\r
-                       &DefaultGuid,\r
-                       &mCVfrVarDataTypeDB,\r
+                       "Time", \r
+                       &mFormsetGuid, \r
+                       &mCVfrVarDataTypeDB, \r
                        "EFI_HII_TIME",\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
@@ -3048,8 +3443,8 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
     VSObj.SetVarStoreId (VarStoreId);\r
     mCVfrVarDataTypeDB.GetDataTypeSize("EFI_HII_TIME", &Size);\r
     VSObj.SetSize (Size);\r
-       VSObj.SetName ("Time");\r
-    VSObj.SetGuid (&DefaultGuid);\r
+         VSObj.SetName ("Time");\r
+    VSObj.SetGuid (&mFormsetGuid);\r
   }\r
 }\r
 \r
@@ -3058,7 +3453,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
   IN UINT32 LineNo\r
   )\r
 {\r
-  CIfrDefaultStore DSObj;\r
+  CIfrDefaultStore DSObj; \r
 \r
   mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);\r
   DSObj.SetLineNo (LineNo);\r
@@ -3068,7 +3463,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
 \r
 VOID\r
 EfiVfrParser::AssignQuestionKey (\r
-  IN CIfrQuestionHeader   &QHObj,\r
+  IN CIfrQuestionHeader   &QHObj, \r
   IN ANTLRTokenPtr        KeyTok\r
   )\r
 {\r
@@ -3081,9 +3476,9 @@ EfiVfrParser::AssignQuestionKey (
   KeyValue = _STOU16 (KeyTok->getText());\r
 \r
   if (QHObj.FLAGS () & EFI_IFR_FLAG_CALLBACK) {\r
-  /*\r
-   * if the question is not CALLBACK ignore the key.\r
-   */\r
+    /*\r
+     * if the question is not CALLBACK ignore the key.\r
+    */\r
     _PCATCH(mCVfrQuestionDB.UpdateQuestionId (QHObj.QUESTION_ID(), KeyValue), KeyTok);\r
     QHObj.SetQuestionId (KeyValue);\r
   }\r
@@ -3091,7 +3486,7 @@ EfiVfrParser::AssignQuestionKey (
 \r
 VOID\r
 EfiVfrParser::ConvertIdExpr (\r
-  IN UINT32          &ExpOpCount,\r
+  IN UINT32          &ExpOpCount, \r
   IN UINT32          LineNo,\r
   IN EFI_QUESTION_ID QId,\r
   IN CHAR8           *VarIdStr,\r
@@ -3125,7 +3520,7 @@ EfiVfrParser::ConvertIdExpr (
 \r
 VOID\r
 EfiVfrParser::IdEqValDoSpecial (\r
-  IN UINT32           &ExpOpCount,\r
+  IN UINT32           &ExpOpCount, \r
   IN UINT32           LineNo,\r
   IN EFI_QUESTION_ID  QId,\r
   IN CHAR8            *VarIdStr,\r
@@ -3177,7 +3572,7 @@ EfiVfrParser::IdEqValDoSpecial (
 \r
 VOID\r
 EfiVfrParser::IdEqIdDoSpecial (\r
-  IN UINT32           &ExpOpCount,\r
+  IN UINT32           &ExpOpCount, \r
   IN UINT32           LineNo,\r
   IN EFI_QUESTION_ID  QId1,\r
   IN CHAR8            *VarId1Str,\r
@@ -3224,7 +3619,7 @@ EfiVfrParser::IdEqIdDoSpecial (
 \r
 VOID\r
 EfiVfrParser::IdEqListDoSpecial (\r
-  IN UINT32          &ExpOpCount,\r
+  IN UINT32          &ExpOpCount, \r
   IN UINT32          LineNo,\r
   IN EFI_QUESTION_ID QId,\r
   IN CHAR8           *VarIdStr,\r
@@ -3247,4 +3642,13 @@ EfiVfrParser::IdEqListDoSpecial (
   }\r
 }\r
 \r
+//\r
+// For framework vfr compatibility\r
+//\r
+VOID\r
+EfiVfrParser::SetCompatibleMode (IN BOOLEAN Mode)\r
+{\r
+  mCompatibleMode = Mode;\r
+  mCVfrQuestionDB.SetCompatibleMode (Mode);\r
+}\r
 >>\r
index 8be70e8..29741c8 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-\r
+  \r
   Vfr common library functions.\r
 \r
-Copyright (c) 2004 - 2008, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2008, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
@@ -70,9 +70,9 @@ CVfrBinaryOutput::WriteEnd (
 }\r
 \r
 SConfigInfo::SConfigInfo (\r
-  IN UINT8              Type,\r
-  IN UINT16             Offset,\r
-  IN UINT32             Width,\r
+  IN UINT8              Type, \r
+  IN UINT16             Offset, \r
+  IN UINT32             Width, \r
   IN EFI_IFR_TYPE_VALUE Value\r
   )\r
 {\r
@@ -278,10 +278,6 @@ CVfrBufferConfig::Write (
   SConfigItem   *pItem;\r
   SConfigInfo   *pInfo;\r
 \r
-  if ((Ret = Select (Name)) != 0) {\r
-    return Ret;\r
-  }\r
-\r
   switch (Mode) {\r
   case 'a' : // add\r
     if (Select (Name, Id) != 0) {\r
@@ -316,6 +312,10 @@ CVfrBufferConfig::Write (
     break;\r
 \r
   case 'd' : // delete\r
+    if ((Ret = Select (Name, Id)) != 0) {\r
+      return Ret;\r
+    }\r
+\r
     if (mItemListHead == mItemListPos) {\r
       mItemListHead = mItemListPos->mNext;\r
       delete mItemListPos;\r
@@ -334,6 +334,10 @@ CVfrBufferConfig::Write (
     break;\r
 \r
   case 'i' : // set info\r
+    if ((Ret = Select (Name, Id)) != 0) {\r
+      return Ret;\r
+    }\r
+\r
     if (mItemListPos->mId != NULL) {\r
       delete mItemListPos->mId;\r
     }\r
@@ -353,103 +357,6 @@ CVfrBufferConfig::Write (
   return 0;\r
 }\r
 \r
-#if 0\r
-UINT8\r
-CVfrBufferConfig::ReadId (\r
-  OUT CHAR8  **Name,\r
-  OUT CHAR8  **Id\r
-  )\r
-{\r
-  if (mInfoStrItemListPos == NULL) {\r
-    return 1; // end read or some error occur\r
-  }\r
-\r
-  if (Name != NULL) {\r
-    *Name = new CHAR8 (strlen (mInfoStrItemListPos->mName + 1));\r
-    strcpy (*Name, mInfoStrItemListPos->mName);\r
-  }\r
-  if (Id != NULL) {\r
-    *Id = new CHAR8 (strlen (mInfoStrItemListPos->mId + 1));\r
-    strcpy (*Id, mInfoStrItemListPos->mId);\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-UINT8\r
-CVfrBufferConfig::ReadInfo (\r
-  IN  CHAR8     *Name,\r
-  IN  UINT32    Index,\r
-  IN OUT UINT32 &Number,\r
-  OUT CHAR8     *Offset,\r
-  OUT CHAR8     *Width,\r
-  OUT CHAR8     *Value\r
-  )\r
-{\r
-  UINT8         ret;\r
-  SConfigInfo   *p;\r
-  UINT32        idx;\r
-  UINT32        num;\r
-\r
-  if (Name != NULL) {\r
-    if ((ret = Select (Name)) != 0) {\r
-      return ret;\r
-    }\r
-  }\r
-\r
-  if (mInfoStrItemListPos == NULL) {\r
-    return 1; // end read or some error occur\r
-  }\r
-\r
-  p = mInfoStrItemListPos->mInfoStrList;\r
-  for (idx = 0; (idx < Index) && (p != NULL); idx++) {\r
-    p = p->mNext;\r
-  }\r
-  if (p == NULL) {\r
-    return 1;\r
-  }\r
-\r
-  if (Offset != NULL) {\r
-    Offset[0] = '\0';\r
-  }\r
-  if (Width != NULL) {\r
-    Width[0] = '\0';\r
-  }\r
-  if (Value != NULL) {\r
-    Value[0] = '\0';\r
-  }\r
-\r
-  while (num < Number) {\r
-    if (Offset != NULL) {\r
-      strcat (Offset, p->mOffset);\r
-    }\r
-    if (Width != NULL) {\r
-      strcat (Width, p->mWidth);\r
-    }\r
-    if (Value != NULL) {\r
-      strcat (Value, p->mValue);\r
-    }\r
-\r
-    num++;\r
-    if ((p = p->mNext) == NULL) {\r
-      break;\r
-    }\r
-  }\r
-  Number = num;\r
-\r
-  return 0;\r
-}\r
-\r
-VOID\r
-CVfrBufferConfig::ReadNext (\r
-  VOID\r
-  )\r
-{\r
-  if (mItemListPos != NULL) {\r
-    mItemListPos = mItemListPos->mNext;\r
-  }\r
-}\r
-#endif\r
 \r
 VOID\r
 CVfrBufferConfig::Close (\r
@@ -494,9 +401,9 @@ CVfrBufferConfig::OutputCFile (
         } else {\r
           Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)Info->mValue, Info->mWidth);\r
         }\r
-        fprintf (pFile, "\n");\r
+        fprintf (pFile, "\n"); \r
       }\r
-      fprintf (pFile, "};\n");\r
+      fprintf (pFile, "};\n"); \r
     }\r
   }\r
 }\r
@@ -614,7 +521,7 @@ _STR2U32 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    }\r
+    } \r
   }\r
 \r
   return Value;\r
@@ -631,7 +538,7 @@ CVfrVarDataTypeDB::RegisterNewType (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::ExtractStructTypeName (\r
-  IN  CHAR8 *&VarStr,\r
+  IN  CHAR8 *&VarStr, \r
   OUT CHAR8 *TName\r
   )\r
 {\r
@@ -654,7 +561,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::ExtractFieldNameAndArrary (\r
-  IN  CHAR8   *&VarStr,\r
+  IN  CHAR8   *&VarStr, \r
   IN  CHAR8   *FName,\r
   OUT UINT32 &ArrayIdx\r
   )\r
@@ -662,15 +569,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
   UINT32 Idx;\r
   CHAR8   ArrayStr[MAX_NAME_LEN + 1];\r
 \r
-  ArrayIdx = INVALID_ARRAY_INDEX;\r
+  ArrayIdx = INVALID_ARRAY_INDEX; \r
 \r
   if (FName == NULL) {\r
     return VFR_RETURN_FATAL_ERROR;\r
   }\r
 \r
   while((*VarStr != '\0') &&\r
-        (*VarStr != '.') &&\r
-        (*VarStr != '[') &&\r
+        (*VarStr != '.') && \r
+        (*VarStr != '[') && \r
         (*VarStr != ']')) {\r
     *FName = *VarStr;\r
     VarStr++;\r
@@ -707,8 +614,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetTypeField (\r
-  IN  CHAR8          *FName,\r
-  IN  SVfrDataType  *Type,\r
+  IN  CHAR8          *FName, \r
+  IN  SVfrDataType  *Type, \r
   OUT SVfrDataField *&Field\r
   )\r
 {\r
@@ -730,7 +637,7 @@ CVfrVarDataTypeDB::GetTypeField (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetFieldOffset (\r
-  IN  SVfrDataField *Field,\r
+  IN  SVfrDataField *Field, \r
   IN  UINT32        ArrayIdx,\r
   OUT UINT32        &Offset\r
   )\r
@@ -838,7 +745,7 @@ CVfrVarDataTypeDB::InternalTypesListInit (
         pSecondsField->mNext     = NULL;\r
         pSecondsField->mArrayNum = 0;\r
 \r
-        New->mMembers            = pHoursField;\r
+        New->mMembers            = pHoursField;      \r
       } else {\r
         New->mMembers            = NULL;\r
       }\r
@@ -895,8 +802,8 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::Pack (\r
   IN UINT32         LineNum,\r
-  IN UINT8          Action,\r
-  IN CHAR8          *Identifier,\r
+  IN UINT8          Action, \r
+  IN CHAR8          *Identifier, \r
   IN UINT32         Number\r
   )\r
 {\r
@@ -992,8 +899,8 @@ CVfrVarDataTypeDB::SetNewTypeName (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::DataTypeAddField (\r
-  IN CHAR8   *FieldName,\r
-  IN CHAR8   *TypeName,\r
+  IN CHAR8   *FieldName, \r
+  IN CHAR8   *TypeName, \r
   IN UINT32 ArrayNum\r
   )\r
 {\r
@@ -1031,7 +938,7 @@ CVfrVarDataTypeDB::DataTypeAddField (
     mNewDataType->mMembers = pNewField;\r
     pNewField->mNext       = NULL;\r
   } else {\r
-    for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)\r
+    for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext) \r
       ;\r
     pTmp->mNext            = pNewField;\r
     pNewField->mNext       = NULL;\r
@@ -1115,9 +1022,9 @@ CVfrVarDataTypeDB::GetDataTypeSize (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetDataFieldInfo (\r
-  IN  CHAR8     *VarStr,\r
-  OUT UINT16   &Offset,\r
-  OUT UINT8    &Type,\r
+  IN  CHAR8     *VarStr, \r
+  OUT UINT16   &Offset, \r
+  OUT UINT8    &Type, \r
   OUT UINT32   &Size\r
   )\r
 {\r
@@ -1153,7 +1060,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetUserDefinedTypeNameList  (\r
-  OUT CHAR8     ***NameList,\r
+  OUT CHAR8     ***NameList, \r
   OUT UINT32    *ListSize\r
   )\r
 {\r
@@ -1239,7 +1146,8 @@ SVfrVarStorageNode::SVfrVarStorageNode (
   IN CHAR8                 *StoreName,\r
   IN EFI_VARSTORE_ID       VarStoreId,\r
   IN EFI_STRING_ID         VarName,\r
-  IN UINT32                VarSize\r
+  IN UINT32                VarSize,\r
+  IN BOOLEAN               Flag\r
   )\r
 {\r
   if (Guid != NULL) {\r
@@ -1258,13 +1166,15 @@ SVfrVarStorageNode::SVfrVarStorageNode (
   mVarStoreType                    = EFI_VFR_VARSTORE_EFI;\r
   mStorageInfo.mEfiVar.mEfiVarName = VarName;\r
   mStorageInfo.mEfiVar.mEfiVarSize = VarSize;\r
+  mAssignedFlag                    = Flag;\r
 }\r
 \r
 SVfrVarStorageNode::SVfrVarStorageNode (\r
   IN EFI_GUID              *Guid,\r
   IN CHAR8                 *StoreName,\r
   IN EFI_VARSTORE_ID       VarStoreId,\r
-  IN SVfrDataType          *DataType\r
+  IN SVfrDataType          *DataType,\r
+  IN BOOLEAN               Flag\r
   )\r
 {\r
   if (Guid != NULL) {\r
@@ -1282,6 +1192,7 @@ SVfrVarStorageNode::SVfrVarStorageNode (
   mVarStoreId              = VarStoreId;\r
   mVarStoreType            = EFI_VFR_VARSTORE_BUFFER;\r
   mStorageInfo.mDataType   = DataType;\r
+  mAssignedFlag            = Flag;\r
 }\r
 \r
 SVfrVarStorageNode::SVfrVarStorageNode (\r
@@ -1484,12 +1395,13 @@ CVfrDataStorage::DeclareNameVarStoreEnd (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE\r
+EFI_VFR_RETURN_CODE \r
 CVfrDataStorage::DeclareEfiVarStore (\r
-  IN CHAR8          *StoreName,\r
-  IN EFI_GUID       *Guid,\r
+  IN CHAR8          *StoreName, \r
+  IN EFI_GUID       *Guid, \r
   IN EFI_STRING_ID  NameStrId,\r
-  IN UINT32         VarSize\r
+  IN UINT32         VarSize,\r
+  IN BOOLEAN        Flag\r
   )\r
 {\r
   SVfrVarStorageNode *pNode;\r
@@ -1510,23 +1422,24 @@ CVfrDataStorage::DeclareEfiVarStore (
   }\r
 \r
   VarStoreId = GetFreeVarStoreId ();\r
-  if ((pNode = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, NameStrId, VarSize)) == NULL) {\r
+  if ((pNode = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, NameStrId, VarSize, Flag)) == NULL) {\r
     return VFR_RETURN_OUT_FOR_RESOURCES;\r
   }\r
 \r
-  pNode->mNext       = mNameVarStoreList;\r
-  mNameVarStoreList  = pNode;\r
+  pNode->mNext       = mEfiVarStoreList;\r
+  mEfiVarStoreList   = pNode;\r
 \r
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE\r
+EFI_VFR_RETURN_CODE \r
 CVfrDataStorage::DeclareBufferVarStore (\r
-  IN CHAR8             *StoreName,\r
-  IN EFI_GUID          *Guid,\r
+  IN CHAR8             *StoreName, \r
+  IN EFI_GUID          *Guid, \r
   IN CVfrVarDataTypeDB *DataTypeDB,\r
   IN CHAR8             *TypeName,\r
-  IN EFI_VARSTORE_ID   VarStoreId\r
+  IN EFI_VARSTORE_ID   VarStoreId,\r
+  IN BOOLEAN           Flag\r
   )\r
 {\r
   SVfrVarStorageNode   *pNew = NULL;\r
@@ -1547,7 +1460,7 @@ CVfrDataStorage::DeclareBufferVarStore (
     MarkVarStoreIdUsed (VarStoreId);\r
   }\r
 \r
-  if ((pNew = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pDataType)) == NULL) {\r
+  if ((pNew = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pDataType, Flag)) == NULL) {\r
     return VFR_RETURN_OUT_FOR_RESOURCES;\r
   }\r
 \r
@@ -1561,7 +1474,7 @@ CVfrDataStorage::DeclareBufferVarStore (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE\r
+EFI_VFR_RETURN_CODE \r
 CVfrDataStorage::GetVarStoreId (\r
   IN  CHAR8           *StoreName,\r
   OUT EFI_VARSTORE_ID *VarStoreId\r
@@ -1667,7 +1580,7 @@ CVfrDataStorage::GetVarStoreType (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrDataStorage::GetVarStoreName (\r
-  IN  EFI_VARSTORE_ID VarStoreId,\r
+  IN  EFI_VARSTORE_ID VarStoreId, \r
   OUT CHAR8           **VarStoreName\r
   )\r
 {\r
@@ -1789,8 +1702,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
 \r
 SVfrDefaultStoreNode::SVfrDefaultStoreNode (\r
   IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,\r
-  IN CHAR8                *RefName,\r
-  IN EFI_STRING_ID        DefaultStoreNameId,\r
+  IN CHAR8                *RefName, \r
+  IN EFI_STRING_ID        DefaultStoreNameId, \r
   IN UINT16               DefaultId\r
   )\r
 {\r
@@ -1868,7 +1781,7 @@ CVfrDefaultStore::RegisterDefaultStore (
 }\r
 \r
 /*\r
- * assign new reference name or new default store name id only if\r
+ * assign new reference name or new default store name id only if \r
  * the original is invalid\r
  */\r
 EFI_VFR_RETURN_CODE\r
@@ -1951,8 +1864,8 @@ CVfrDefaultStore::GetDefaultId (
 STATIC\r
 EFI_VFR_RETURN_CODE\r
 AltCfgItemPrintToBuffer (\r
-  IN CHAR8              *NewAltCfg,\r
-  IN EFI_VARSTORE_INFO  Info,\r
+  IN CHAR8              *NewAltCfg, \r
+  IN EFI_VARSTORE_INFO  Info, \r
   IN UINT8              Type,\r
   IN EFI_IFR_TYPE_VALUE Value\r
   )\r
@@ -1963,9 +1876,9 @@ AltCfgItemPrintToBuffer (
 \r
   if (NewAltCfg != NULL) {\r
     Count = sprintf (\r
-              NewAltCfg,\r
-              "&OFFSET=%x&WIDTH=%x&VALUE=",\r
-              Info.mInfo.mVarOffset,\r
+              NewAltCfg, \r
+              "&OFFSET=%x&WIDTH=%x&VALUE=", \r
+              Info.mInfo.mVarOffset, \r
               Info.mVarTotalSize\r
               );\r
     NewAltCfg += Count;\r
@@ -2024,7 +1937,7 @@ AltCfgItemPrintToBuffer (
        }\r
   }\r
 \r
-  return VFR_RETURN_FATAL_ERROR;\r
+  return VFR_RETURN_FATAL_ERROR;    \r
 }\r
 \r
 EFI_VFR_RETURN_CODE\r
@@ -2062,7 +1975,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
       goto WriteError;\r
     }\r
   }\r
-\r
+  \r
   gCVfrBufferConfig.Close ();\r
 \r
   return VFR_RETURN_SUCCESS;\r
@@ -2073,7 +1986,7 @@ WriteError:
 }\r
 \r
 SVfrRuleNode::SVfrRuleNode (\r
-  IN CHAR8       *RuleName,\r
+  IN CHAR8       *RuleName, \r
   IN UINT8       RuleId\r
   )\r
 {\r
@@ -2179,7 +2092,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
   mVarTotalSize    = Info.mVarTotalSize;\r
 }\r
 \r
-BOOLEAN\r
+BOOLEAN \r
 EFI_VARSTORE_INFO::operator == (\r
   IN EFI_VARSTORE_INFO  *Info\r
   )\r
@@ -2231,7 +2144,7 @@ CVfrQuestionDB::ChekQuestionIdFree (
   return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;\r
 }\r
 \r
-VOID\r
+VOID \r
 CVfrQuestionDB::MarkQuestionIdUsed (\r
   IN EFI_QUESTION_ID QId\r
   )\r
@@ -2242,7 +2155,7 @@ CVfrQuestionDB::MarkQuestionIdUsed (
   mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);\r
 }\r
 \r
-VOID\r
+VOID \r
 CVfrQuestionDB::MarkQuestionIdUnused (\r
   IN EFI_QUESTION_ID QId\r
   )\r
@@ -2306,7 +2219,7 @@ CVfrQuestionDB::CVfrQuestionDB ()
   // Question ID 0 is reserved.\r
   mFreeQIdBitMap[0] = 0x80000000;\r
   mQuestionList     = NULL;\r
-}\r
+} \r
 \r
 CVfrQuestionDB::~CVfrQuestionDB ()\r
 {\r
@@ -2319,6 +2232,44 @@ CVfrQuestionDB::~CVfrQuestionDB ()
   }\r
 }\r
 \r
+//\r
+// Reset to init state\r
+//\r
+VOID\r
+CVfrQuestionDB::ResetInit(\r
+  IN VOID\r
+  )\r
+{\r
+  UINT32               Index;\r
+  SVfrQuestionNode     *pNode;\r
+\r
+  while (mQuestionList != NULL) {\r
+    pNode = mQuestionList;\r
+    mQuestionList = mQuestionList->mNext;\r
+    delete pNode;\r
+  }\r
+\r
+  for (Index = 0; Index < EFI_FREE_QUESTION_ID_BITMAP_SIZE; Index++) {\r
+    mFreeQIdBitMap[Index] = 0;\r
+  }\r
+\r
+  // Question ID 0 is reserved.\r
+  mFreeQIdBitMap[0] = 0x80000000;\r
+  mQuestionList     = NULL;   \r
+}\r
+\r
+VOID\r
+CVfrQuestionDB::PrintAllQuestion (\r
+  VOID\r
+  )\r
+{\r
+  SVfrQuestionNode *pNode = NULL;\r
+\r
+  for (pNode = mQuestionList; pNode != NULL; pNode = pNode->mNext) {\r
+    printf ("Question VarId is %s and QuesitonId is 0x%x\n", pNode->mVarIdStr, pNode->mQuestionId);\r
+  }\r
+}\r
+\r
 EFI_VFR_RETURN_CODE\r
 CVfrQuestionDB::RegisterQuestion (\r
   IN     CHAR8             *Name,\r
@@ -2339,7 +2290,10 @@ CVfrQuestionDB::RegisterQuestion (
   if (QuestionId == EFI_QUESTION_ID_INVALID) {\r
     QuestionId = GetFreeQuestionId ();\r
   } else {\r
-    if (ChekQuestionIdFree (QuestionId) == FALSE) {\r
+    //\r
+    // For Framework Vfr, don't check question ID conflict.\r
+    //\r
+    if (!mCompatibleMode && ChekQuestionIdFree (QuestionId) == FALSE) {\r
       delete pNode;\r
       return VFR_RETURN_QUESTIONID_REDEFINED;\r
     }\r
@@ -2357,9 +2311,9 @@ CVfrQuestionDB::RegisterQuestion (
 \r
 VOID\r
 CVfrQuestionDB::RegisterOldDateQuestion (\r
-  IN     CHAR8           *YearVarId,\r
-  IN     CHAR8           *MonthVarId,\r
-  IN     CHAR8           *DayVarId,\r
+  IN     CHAR8           *YearVarId, \r
+  IN     CHAR8           *MonthVarId, \r
+  IN     CHAR8           *DayVarId, \r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2415,7 +2369,7 @@ Err:
 VOID\r
 CVfrQuestionDB::RegisterNewDateQuestion (\r
   IN     CHAR8           *Name,\r
-  IN     CHAR8           *BaseVarId,\r
+  IN     CHAR8           *BaseVarId, \r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2499,9 +2453,9 @@ Err:
 \r
 VOID\r
 CVfrQuestionDB::RegisterOldTimeQuestion (\r
-  IN     CHAR8           *HourVarId,\r
-  IN     CHAR8           *MinuteVarId,\r
-  IN     CHAR8           *SecondVarId,\r
+  IN     CHAR8           *HourVarId, \r
+  IN     CHAR8           *MinuteVarId, \r
+  IN     CHAR8           *SecondVarId, \r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2646,8 +2600,16 @@ CVfrQuestionDB::UpdateQuestionId (
   )\r
 {\r
   SVfrQuestionNode *pNode = NULL;\r
-\r
-  if (ChekQuestionIdFree (NewQId) == FALSE) {\r
+  \r
+  if (QId == NewQId) {\r
+    // don't update\r
+    return VFR_RETURN_SUCCESS;\r
+  }\r
+  \r
+  //\r
+  // For Framework Vfr, don't check question ID conflict.\r
+  //  \r
+  if (!mCompatibleMode && ChekQuestionIdFree (NewQId) == FALSE) {\r
     return VFR_RETURN_REDEFINED;\r
   }\r
 \r
@@ -2670,7 +2632,7 @@ CVfrQuestionDB::UpdateQuestionId (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-VOID\r
+VOID \r
 CVfrQuestionDB::GetQuestionId (\r
   IN  CHAR8             *Name,\r
   IN  CHAR8             *VarIdStr,\r
@@ -2708,7 +2670,7 @@ CVfrQuestionDB::GetQuestionId (
   return ;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE\r
+EFI_VFR_RETURN_CODE \r
 CVfrQuestionDB::FindQuestion (\r
   IN EFI_QUESTION_ID QuestionId\r
   )\r
@@ -2728,7 +2690,7 @@ CVfrQuestionDB::FindQuestion (
   return VFR_RETURN_UNDEFINED;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE\r
+EFI_VFR_RETURN_CODE \r
 CVfrQuestionDB::FindQuestion (\r
   IN CHAR8 *Name\r
   )\r
index a639ff6..21ac0fb 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-\r
+  \r
   Vfr common library functions.\r
 \r
-Copyright (c) 2004 - 2008, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2008, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
@@ -172,7 +172,6 @@ private:
   VOID RegisterNewType (IN SVfrDataType *);\r
 \r
   EFI_VFR_RETURN_CODE ExtractStructTypeName (IN CHAR8 *&, OUT CHAR8 *);\r
-  EFI_VFR_RETURN_CODE ExtractFieldNameAndArrary (IN CHAR8 *&, OUT CHAR8 *, OUT UINT32 &);\r
   EFI_VFR_RETURN_CODE GetTypeField (IN CHAR8 *, IN SVfrDataType *, IN SVfrDataField *&);\r
   EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT UINT32 &);\r
   UINT8               GetFieldWidth (IN SVfrDataField *);\r
@@ -192,6 +191,8 @@ public:
   EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);\r
 \r
   EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT CHAR8 ***, OUT UINT32 *);\r
+  EFI_VFR_RETURN_CODE ExtractFieldNameAndArrary (IN CHAR8 *&, OUT CHAR8 *, OUT UINT32 &);\r
+\r
   BOOLEAN             IsTypeNameDefined (IN CHAR8 *);\r
 \r
 #ifdef CVFR_VARDATATYPEDB_DEBUG\r
@@ -210,6 +211,7 @@ struct SVfrVarStorageNode {
   EFI_GUID                  mGuid;\r
   CHAR8                     *mVarStoreName;\r
   EFI_VARSTORE_ID           mVarStoreId;\r
+  BOOLEAN                   mAssignedFlag; //Create varstore opcode\r
   struct SVfrVarStorageNode *mNext;\r
 \r
   EFI_VFR_VARSTORE_TYPE     mVarStoreType;\r
@@ -231,8 +233,8 @@ struct SVfrVarStorageNode {
   } mStorageInfo;\r
 \r
 public:\r
-  SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN EFI_STRING_ID, IN UINT32);\r
-  SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SVfrDataType *);\r
+  SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN EFI_STRING_ID, IN UINT32, IN BOOLEAN Flag = TRUE);\r
+  SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SVfrDataType *, IN BOOLEAN Flag = TRUE);\r
   SVfrVarStorageNode (IN CHAR8 *, IN EFI_VARSTORE_ID);\r
   ~SVfrVarStorageNode (VOID);\r
 };\r
@@ -275,14 +277,20 @@ private:
 public:\r
   CVfrDataStorage ();\r
   ~CVfrDataStorage ();\r
-\r
+  \r
+  SVfrVarStorageNode * GetBufferVarStoreList () {\r
+    return mBufferVarStoreList;\r
+  }\r
+  SVfrVarStorageNode * GetEfiVarStoreList () {\r
+    return mEfiVarStoreList;\r
+  }\r
   EFI_VFR_RETURN_CODE DeclareNameVarStoreBegin (CHAR8 *);\r
   EFI_VFR_RETURN_CODE NameTableAddItem (EFI_STRING_ID);\r
   EFI_VFR_RETURN_CODE DeclareNameVarStoreEnd (EFI_GUID *);\r
 \r
-  EFI_VFR_RETURN_CODE DeclareEfiVarStore (IN CHAR8 *, IN EFI_GUID *, IN EFI_STRING_ID, IN UINT32);\r
+  EFI_VFR_RETURN_CODE DeclareEfiVarStore (IN CHAR8 *, IN EFI_GUID *, IN EFI_STRING_ID, IN UINT32, IN BOOLEAN Flag = TRUE);\r
 \r
-  EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID);\r
+  EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN Flag = TRUE);\r
 \r
   EFI_VFR_RETURN_CODE GetVarStoreId (IN CHAR8 *, OUT EFI_VARSTORE_ID *);\r
   EFI_VFR_RETURN_CODE GetVarStoreType (IN CHAR8 *, OUT EFI_VFR_VARSTORE_TYPE &);\r
@@ -321,6 +329,7 @@ class CVfrQuestionDB {
 private:\r
   SVfrQuestionNode          *mQuestionList;\r
   UINT32                    mFreeQIdBitMap[EFI_FREE_QUESTION_ID_BITMAP_SIZE];\r
+  BOOLEAN                   mCompatibleMode;\r
 \r
 private:\r
   EFI_QUESTION_ID GetFreeQuestionId (VOID);\r
@@ -341,7 +350,13 @@ public:
   VOID                GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &);\r
   EFI_VFR_RETURN_CODE FindQuestion (IN EFI_QUESTION_ID);\r
   EFI_VFR_RETURN_CODE FindQuestion (IN CHAR8 *);\r
- };\r
+  VOID                PrintAllQuestion (IN VOID);\r
+  VOID                ResetInit (IN VOID); \r
+\r
+  VOID SetCompatibleMode (IN BOOLEAN Mode) {\r
+    mCompatibleMode = Mode;\r
+  }\r
+};\r
 \r
 struct SVfrDefaultStoreNode {\r
   EFI_IFR_DEFAULTSTORE      *mObjBinAddr;\r