diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-26 01:54:49 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-26 01:54:49 +0000 |
commit | 3e99020dbf0a159e34b84e7ae9125f2e368d5390 (patch) | |
tree | 0eb6339318f7bf7da1b679b8009cf267b2234566 /EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile | |
parent | 68bb5ce77e51cf35791e46f2202e36da97e5e6be (diff) | |
download | edk2-platforms-3e99020dbf0a159e34b84e7ae9125f2e368d5390.tar.xz |
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile')
11 files changed, 1335 insertions, 704 deletions
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h index 55830c9907..b4a849db7b 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -15,8 +15,6 @@ Module Name: Abstract:
- Defines and prototypes for the UEFI VFR compiler internal use.
-
--*/
#ifndef _EFIVFR_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp index 6adef8a41b..2972e1692a 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
-VfrCompiler.cpp
+ VfrCompiler.cpp
Abstract:
@@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS ( VOID
CVfrCompiler::OptionInitialization (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization ( mOptions.PreprocessorOutputFileName[0] = '\0';
mOptions.VfrBaseFileName[0] = '\0';
mOptions.IncludePaths = NULL;
+ mOptions.SkipCPreprocessor = FALSE;
mOptions.CPreprocessorOptions = NULL;
for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {
@@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization ( } else if (_stricmp(Argv[Index], "-i") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -i - missing path argument\n", PROGRAM_NAME);
+ printf ("%s -i - missing path argument\n", UTILITY_NAME);
goto Fail;
}
@@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization ( } else if (_stricmp(Argv[Index], "-od") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing output directory name\n", PROGRAM_NAME);
+ printf ("%s -od - missing output directory name\n", UTILITY_NAME);
goto Fail;
}
strcpy (mOptions.OutputDirectory, Argv[Index]);
+ strcat (mOptions.OutputDirectory, "\\");
} else if (_stricmp(Argv[Index], "-ibin") == 0) {
mOptions.CreateIfrPkgFile = TRUE;
} else if (_stricmp(Argv[Index], "-nostrings") == 0) {
+ } else if (_stricmp(Argv[Index], "-nopp") == 0) {
+ mOptions.SkipCPreprocessor = TRUE;
} else if (_stricmp(Argv[Index], "-ppflag") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);
+ printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);
goto Fail;
}
AppendCPreprocessorOptions (Argv[Index]);
} else {
- printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);
+ printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);
Usage ();
goto Fail;
}
}
if (Index != Argc - 1) {
- printf ("%s must specify VFR file name", PROGRAM_NAME);
+ printf ("%s must specify VFR file name\n", UTILITY_NAME);
Usage ();
goto Fail;
} else {
@@ -140,7 +144,7 @@ Fail: if (mOptions.IncludePaths != NULL) {
delete mOptions.IncludePaths;
mOptions.IncludePaths = NULL;
- }
+ }
if (mOptions.CPreprocessorOptions != NULL) {
delete mOptions.CPreprocessorOptions;
mOptions.CPreprocessorOptions = NULL;
@@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath ( }
IncludePaths = new INT8[Len];
if (IncludePaths == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
IncludePaths[0] = '\0';
@@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions ( }
Opt = new INT8[Len];
if (Opt == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
Opt[0] = 0;
@@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName ( }
pFileName = mOptions.VfrFileName;
- while ((pPath = strchr (pFileName, '\\')) != NULL) {
+ while (
+ ((pPath = strchr (pFileName, '\\')) != NULL) ||
+ ((pPath = strchr (pFileName, '/')) != NULL)
+ )
+ {
pFileName = pPath + 1;
}
@@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName ( }
CVfrCompiler::CVfrCompiler (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler ( SET_RUN_STATUS(STATUS_DEAD);
}
-VOID
+VOID
CVfrCompiler::Usage (
VOID
)
{
- UINT32 Index;
- CONST INT8 *Help[] = {
- " ",
- "VfrCompile version " VFR_COMPILER_VERSION,
- " ",
- " Usage: VfrCompile {options} [VfrFile]",
- " ",
- " where options include:",
- " -? or -h prints this help",
- " -l create an output IFR listing file",
- " -i IncPath add IncPath to the search path for VFR included files",
- " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
- " -ibin create an IFR HII pack file"
- " -ppflag C-preprocessor argument",
- " where parameters include:",
- " VfrFile name of the input VFR script file",
- " ",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] VFRFILE",
+ "Description:",
+ " Compile VFRFILE.",
+ "Options:",
+ " -? or -h print this help",
+ " -l create an output IFR listing file",
+ " -i IncPath add IncPath to the search path for VFR included files",
+ " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
+ " -ibin create an IFR HII pack file",
+ " -ppflag CFlags pass Flags as C-preprocessor-flag",
+ " -v or -version print version information",
NULL
- };
- for (Index = 0; Help[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Help[Index]);
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
+
VOID
CVfrCompiler::PreProcess (
VOID
@@ -375,8 +388,12 @@ CVfrCompiler::PreProcess ( goto Fail;
}
+ if (mOptions.SkipCPreprocessor == TRUE) {
+ goto Out;
+ }
+
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
- printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);
+ printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);
goto Fail;
}
fclose (pVfrFile);
@@ -392,7 +409,7 @@ CVfrCompiler::PreProcess ( PreProcessCmd = new INT8[CmdLen + 10];
if (PreProcessCmd == NULL) {
- printf ("%s could not allocate memory\n", PROGRAM_NAME);
+ printf ("%s could not allocate memory\n", UTILITY_NAME);
goto Fail;
}
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
@@ -407,11 +424,13 @@ CVfrCompiler::PreProcess ( strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
if (system (PreProcessCmd) != 0) {
- printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);
+ printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);
goto Fail;
}
delete PreProcessCmd;
+
+Out:
SET_RUN_STATUS (STATUS_PREPROCESSED);
return;
@@ -429,22 +448,27 @@ CVfrCompiler::Compile ( VOID
)
{
- FILE *VfrFile = NULL;
+ FILE *pInFile = NULL;
+ INT8 *InFileName = NULL;
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
}
- if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
+ gCVfrErrorHandle.SetInputFile (InFileName);
+
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);
goto Fail;
}
- if (VfrParserStart (VfrFile) != 0) {
+ if (VfrParserStart (pInFile) != 0) {
goto Fail;
}
- fclose (VfrFile);
+ fclose (pInFile);
if (gCFormPkg.HavePendingUnassigned () == TRUE) {
gCFormPkg.PendingAssignPrintAll ();
@@ -456,11 +480,11 @@ CVfrCompiler::Compile ( Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
- printf ("%s compile error!\n", PROGRAM_NAME);
+ printf ("%s compile error!\n", UTILITY_NAME);
SET_RUN_STATUS (STATUS_FAILED);
}
- if (VfrFile != NULL) {
- fclose (VfrFile);
+ if (pInFile != NULL) {
+ fclose (pInFile);
}
}
@@ -477,7 +501,7 @@ CVfrCompiler::GenBinary ( if (mOptions.CreateIfrPkgFile == TRUE) {
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
- printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);
+ printf ("can not open %s\n", mOptions.PkgOutputFileName);
goto Fail;
}
if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {
@@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile ( VOID
)
{
- FILE *pInFile = NULL;
- FILE *pOutFile = NULL;
+ INT8 *InFileName = NULL;
+ FILE *pInFile = NULL;
+ FILE *pOutFile = NULL;
INT8 LineBuf[MAX_LINE_LEN];
UINT32 LineNo;
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
if (mOptions.CreateRecordListFile == TRUE) {
- if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
+ if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
return;
}
- if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);
return;
}
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
- printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);
+ printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);
goto Err1;
}
- fprintf (pOutFile, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
LineNo = 0;
while (!feof (pInFile)) {
if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {
@@ -590,7 +617,7 @@ Err1: INT32
main (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h index 0410f84252..bc487f88ba 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h @@ -1,17 +1,17 @@ /*++ -Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: -VfrCompiler.h + VfrCompiler.h Abstract: @@ -26,8 +26,8 @@ Abstract: #include "VfrFormPkg.h"
#include "VfrUtilityLib.h"
-#define PROGRAM_NAME "VfrCompile"
-#define VFR_COMPILER_VERSION "UEFI 2.1"
+#define UTILITY_NAME "VfrCompile"
+#define UTILITY_VERSION "v1.1"
//
// This is how we invoke the C preprocessor on the VFR source file
@@ -56,6 +56,7 @@ typedef struct { INT8 PreprocessorOutputFileName[MAX_PATH];
INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension
INT8 *IncludePaths;
+ bool SkipCPreprocessor; INT8 *CPreprocessorOptions;
} OPTIONS;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp index 4a366136bf..d6fc7cf909 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
-VfrError.cpp
+ VfrError.cpp
Abstract:
@@ -25,33 +25,36 @@ Abstract: static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_SUCCESS, NULL },
{ VFR_RETURN_ERROR_SKIPED, NULL },
- { VFR_RETURN_FATAL_ERROR, "fatal error!!" },
-
- { VFR_RETURN_MISMATCHED, "unexpected token" },
- { VFR_RETURN_INVALID_PARAMETER, "Invalid parameter" },
- { VFR_RETURN_OUT_FOR_RESOURCES, "system out of memory" },
- { VFR_RETURN_UNSUPPORTED, "unsupported" },
- { VFR_RETURN_REDEFINED, "already defined" },
- { VFR_RETURN_FORMID_REDEFINED, "form id already defined" },
- { VFR_RETURN_QUESTIONID_REDEFINED, "question id already defined" },
- { VFR_RETURN_VARSTOREID_REDEFINED, "varstore id already defined" },
- { VFR_RETURN_UNDEFINED, "undefined" },
- { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, "some variable has not defined by a question"},
- { VFR_RETURN_GET_EFIVARSTORE_ERROR, "get efi varstore error"},
- { VFR_RETURN_EFIVARSTORE_USE_ERROR, "can not use the efi varstore like this" },
- { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, "unsupport efi varstore size should be <= 8 bytes" },
- { VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },
- { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },
- { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },
- { VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },
- { VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},
- { VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }
+ { VFR_RETURN_FATAL_ERROR, ": fatal error!!" },
+
+ { VFR_RETURN_MISMATCHED, ": unexpected token" },
+ { VFR_RETURN_INVALID_PARAMETER, ": invalid parameter" },
+ { VFR_RETURN_OUT_FOR_RESOURCES, ": system out of memory" },
+ { VFR_RETURN_UNSUPPORTED, ": unsupported" },
+ { VFR_RETURN_REDEFINED, ": already defined" },
+ { VFR_RETURN_FORMID_REDEFINED, ": form id already defined" },
+ { VFR_RETURN_QUESTIONID_REDEFINED, ": question id already defined" },
+ { VFR_RETURN_VARSTOREID_REDEFINED, ": varstore id already defined" },
+ { VFR_RETURN_UNDEFINED, ": undefined" },
+ { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, ": some variable has not defined by a question"},
+ { VFR_RETURN_GET_EFIVARSTORE_ERROR, ": get efi varstore error"},
+ { VFR_RETURN_EFIVARSTORE_USE_ERROR, ": can not use the efi varstore like this" },
+ { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, ": unsupport efi varstore size should be <= 8 bytes" },
+ { VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },
+ { VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },
+ { VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },
+ { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error" },
+ { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
+ { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
+ { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
+ { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
};
CVfrErrorHandle::CVfrErrorHandle (
VOID
)
{
+ mInputFileName = NULL;
mScopeRecordListHead = NULL;
mScopeRecordListTail = NULL;
mVfrErrorHandleTable = VFR_ERROR_HANDLE_TABLE;
@@ -63,6 +66,10 @@ CVfrErrorHandle::~CVfrErrorHandle ( {
SVfrFileScopeRecord *pNode = NULL;
+ if (mInputFileName != NULL) {
+ delete mInputFileName;
+ }
+
while (mScopeRecordListHead != NULL) {
pNode = mScopeRecordListHead;
mScopeRecordListHead = mScopeRecordListHead->mNext;
@@ -74,8 +81,19 @@ CVfrErrorHandle::~CVfrErrorHandle ( mVfrErrorHandleTable = NULL;
}
+VOID
+CVfrErrorHandle::SetInputFile (
+ IN INT8 *InputFile
+ )
+{
+ if (InputFile != NULL) {
+ mInputFileName = new INT8[strlen(InputFile) + 1];
+ strcpy (mInputFileName, InputFile);
+ }
+}
+
SVfrFileScopeRecord::SVfrFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 LineNum
)
{
@@ -116,7 +134,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord ( VOID
CVfrErrorHandle::ParseFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 WholeScopeLine
)
{
@@ -155,6 +173,15 @@ CVfrErrorHandle::GetFileNameLineNum ( *FileName = NULL;
*FileLine = 0xFFFFFFFF;
+ //
+ // Some errors occur before scope record list been built.
+ //
+ if (mScopeRecordListHead == NULL) {
+ *FileLine = LineNum;
+ *FileName = mInputFileName;
+ return ;
+ }
+
for (pNode = mScopeRecordListHead; pNode->mNext != NULL; pNode = pNode->mNext) {
if ((LineNum > pNode->mWholeScopeLine) && (pNode->mNext->mWholeScopeLine > LineNum)) {
*FileName = pNode->mFileName;
@@ -168,9 +195,10 @@ CVfrErrorHandle::GetFileNameLineNum ( }
VOID
-CVfrErrorHandle::PrintError (
+CVfrErrorHandle::PrintMsg (
IN UINT32 LineNum,
IN INT8 *TokName,
+ IN INT8 *MsgType,
IN INT8 *ErrorMsg
)
{
@@ -178,7 +206,7 @@ CVfrErrorHandle::PrintError ( UINT32 FileLine;
GetFileNameLineNum (LineNum, &FileName, &FileLine);
- printf ("%s line %d: error %s %s\n", FileName, FileLine, TokName, ErrorMsg);
+ printf ("%s line %d: %s %s %s\n", FileName, FileLine, MsgType, TokName, ErrorMsg);
}
UINT8
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h index 3becd9b6e1..8c0e4c9a47 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
-VfrError.h
+ VfrError.h
Abstract:
@@ -45,6 +45,8 @@ typedef enum { VFR_RETURN_FLAGS_UNSUPPORTED,
VFR_RETURN_ERROR_ARRARY_NUM,
VFR_RETURN_DATA_STRING_ERROR,
+ VFR_RETURN_DEFAULT_VALUE_REDEFINED,
+ VFR_RETURN_CONSTANT_ONLY,
VFR_RETURN_CODEUNDEFINED
} EFI_VFR_RETURN_CODE;
@@ -65,6 +67,7 @@ struct SVfrFileScopeRecord { class CVfrErrorHandle {
private:
+ INT8 *mInputFileName;
SVFR_ERROR_HANDLE *mVfrErrorHandleTable;
SVfrFileScopeRecord *mScopeRecordListHead;
SVfrFileScopeRecord *mScopeRecordListTail;
@@ -73,10 +76,11 @@ public: CVfrErrorHandle (VOID);
~CVfrErrorHandle (VOID);
+ VOID SetInputFile (IN INT8 *);
VOID ParseFileScopeRecord (IN INT8 *, IN UINT32);
VOID GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");
- VOID PrintError (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *ErrorMsg = "\0");
+ VOID PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");
};
#define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp index ddae865498..50398c6317 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
-VfrFormPkg.cpp
+ VfrFormPkg.cpp
Abstract:
@@ -25,25 +25,34 @@ Abstract: */
SPendingAssign::SPendingAssign (
- IN INT8 *Key,
- IN VOID *Addr,
- IN UINT32 Len,
- IN UINT32 LineNo
+ IN INT8 *Key,
+ IN VOID *Addr,
+ IN UINT32 Len,
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
+ mKey = NULL;
+ mAddr = Addr;
+ mLen = Len;
+ mFlag = PENDING;
+ mLineNo = LineNo;
+ mMsg = NULL;
+ mNext = NULL;
+
if (Key != NULL) {
mKey = new INT8[strlen (Key) + 1];
if (mKey != NULL) {
strcpy (mKey, Key);
}
- } else {
- mKey = NULL;
}
- mAddr = Addr;
- mLen = Len;
- mFlag = PENDING;
- mLineNo = LineNo;
- mNext = NULL;
+
+ if (Msg != NULL) {
+ mMsg = new INT8[strlen (Msg) + 1];
+ if (mMsg != NULL) {
+ strcpy (mMsg, Msg);
+ }
+ }
}
SPendingAssign::~SPendingAssign (
@@ -56,12 +65,15 @@ SPendingAssign::~SPendingAssign ( mAddr = NULL;
mLen = 0;
mLineNo = 0;
+ if (mMsg != NULL) {
+ delete mMsg;
+ }
mNext = NULL;
}
VOID
SPendingAssign::SetAddrAndLen (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 LineNo
)
{
@@ -71,7 +83,7 @@ SPendingAssign::SetAddrAndLen ( VOID
SPendingAssign::AssignValue (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 Len
)
{
@@ -227,7 +239,7 @@ CFormPkg::Close ( UINT32
CFormPkg::Read (
- IN CHAR8 *Buffer,
+ IN CHAR8 *Buffer,
IN UINT32 Size
)
{
@@ -270,7 +282,7 @@ CFormPkg::BuildPkgHdr ( return VFR_RETURN_OUT_FOR_RESOURCES;
}
- (*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;
+ (*PkgHdr)->Type = EFI_HII_PACKAGE_FORMS;
(*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);
return VFR_RETURN_SUCCESS;
}
@@ -357,7 +369,7 @@ CFormPkg::_WRITE_PKG_END ( #define BYTES_PRE_LINE 0x10
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CFormPkg::GenCFile (
IN INT8 *BaseName,
IN FILE *pFile
@@ -407,15 +419,16 @@ CFormPkg::GenCFile ( EFI_VFR_RETURN_CODE
CFormPkg::AssignPending (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen,
- IN UINT32 LineNo
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
SPendingAssign *pNew;
- pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo);
+ pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);
if (pNew == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
@@ -427,8 +440,8 @@ CFormPkg::AssignPending ( VOID
CFormPkg::DoPendingAssign (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen
)
{
@@ -470,7 +483,7 @@ CFormPkg::PendingAssignPrintAll ( for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
- gCVfrErrorHandle.PrintError (pNode->mLineNo, pNode->mKey, "can not assign value because not defined");
+ gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);
}
}
}
@@ -492,10 +505,7 @@ SIfrRecord::~SIfrRecord ( VOID
)
{
- if (mIfrBinBuf != NULL) {
- delete mIfrBinBuf;
- mIfrBinBuf = NULL;
- }
+ mIfrBinBuf = NULL;
mLineNo = 0xFFFFFFFF;
mOffset = 0xFFFFFFFF;
mBinBufLen = 0;
@@ -537,8 +547,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx ( return NULL;
}
- for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
- (Idx != RecordIdx) && (pNode != NULL);
+ for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
+ (Idx != RecordIdx) && (pNode != NULL);
Idx++, pNode = pNode->mNext)
;
@@ -547,8 +557,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx ( UINT32
CIfrRecordInfoDB::IfrRecordRegister (
- IN UINT32 LineNo,
- IN CHAR8 *IfrBinBuf,
+ IN UINT32 LineNo,
+ IN CHAR8 *IfrBinBuf,
IN UINT8 BinBufLen,
IN UINT32 Offset
)
@@ -577,7 +587,7 @@ CIfrRecordInfoDB::IfrRecordRegister ( VOID
CIfrRecordInfoDB::IfrRecordInfoUpdate (
- IN UINT32 RecordIdx,
+ IN UINT32 RecordIdx,
IN UINT32 LineNo,
IN CHAR8 *BinBuf,
IN UINT8 BinBufLen,
@@ -585,23 +595,25 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate ( )
{
SIfrRecord *pNode;
+ SIfrRecord *Prev;
if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {
return;
}
+ if (LineNo == 0) {
+ //
+ // Line number is not specified explicitly, try to use line number of previous opcode
+ //
+ Prev = GetRecordInfoFromIdx (RecordIdx - 1);
+ if (Prev != NULL) {
+ LineNo = Prev->mLineNo;
+ }
+ }
pNode->mLineNo = LineNo;
pNode->mOffset = Offset;
pNode->mBinBufLen = BinBufLen;
- if (BinBuf != NULL) {
- if (pNode->mIfrBinBuf != NULL) {
- delete pNode->mIfrBinBuf;
- }
- pNode->mIfrBinBuf = new CHAR8[BinBufLen];
- if (pNode->mIfrBinBuf != NULL) {
- memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);
- }
- }
+ pNode->mIfrBinBuf = BinBuf;
}
VOID
@@ -626,7 +638,7 @@ CIfrRecordInfoDB::IfrRecordOutput ( fprintf (File, ">%08X: ", pNode->mOffset);
if (pNode->mIfrBinBuf != NULL) {
for (Index = 0; Index < pNode->mBinBufLen; Index++) {
- fprintf (File, "%02X ", pNode->mIfrBinBuf[Index]);
+ fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));
}
}
fprintf (File, "\n");
@@ -650,6 +662,7 @@ CIfrObj::_EMIT_PENDING_OBJ ( if (mObjBinBuf != NULL) {
delete mObjBinBuf;
+ mObjBinBuf = ObjBinBuf;
}
}
@@ -689,7 +702,7 @@ static struct { { sizeof (EFI_IFR_DATE), 1 }, // EFI_IFR_DATE_OP
{ sizeof (EFI_IFR_TIME), 1 }, // EFI_IFR_TIME_OP
{ sizeof (EFI_IFR_STRING), 1 }, // EFI_IFR_STRING_OP
- { sizeof (EFI_IFR_REFRESH), 1 }, // EFI_IFR_REFRESH_OP
+ { sizeof (EFI_IFR_REFRESH), 0 }, // EFI_IFR_REFRESH_OP
{ sizeof (EFI_IFR_DISABLE_IF), 1 }, // EFI_IFR_DISABLE_IF_OP - 0x1E
{ 0, 0 }, // 0x1F
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
@@ -829,10 +842,10 @@ CIfrObj::~CIfrObj ( UINT8 gScopeCount = 0;
CIfrOpHeader::CIfrOpHeader (
- IN UINT8 OpCode,
+ IN UINT8 OpCode,
IN VOID *StartAddr,
- IN UINT8 Length
- ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
+ IN UINT8 Length
+ ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
{
mHeader->OpCode = OpCode;
mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h index b890b27a25..c8e7d98756 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
-VfrFormPkg.h
+ VfrFormPkg.h
Abstract:
@@ -25,6 +25,8 @@ Abstract: #include "VfrError.h"
#include "VfrUtilityLib.h"
+#define NO_QST_REFED "no question refered"
+
/*
* The functions below are used for flags setting
*/
@@ -75,9 +77,10 @@ struct SPendingAssign { UINT32 mLen;
ASSIGN_FLAG mFlag;
UINT32 mLineNo;
+ INT8 *mMsg;
struct SPendingAssign *mNext;
- SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *);
~SPendingAssign ();
VOID SetAddrAndLen (IN VOID *, IN UINT32);
@@ -126,7 +129,7 @@ public: EFI_VFR_RETURN_CODE GenCFile (IN INT8 *, IN FILE *);
public:
- EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *Msg = NULL);
VOID DoPendingAssign (IN INT8 *, IN VOID *, IN UINT32);
bool HavePendingUnassigned (VOID);
VOID PendingAssignPrintAll (VOID);
@@ -368,48 +371,159 @@ public: }
};
-static CIfrQuestionHeader *gCurrentQuestion = NULL;
-
/*
* The definition of CIfrMinMaxStepData
*/
class CIfrMinMaxStepData {
private:
MINMAXSTEP_DATA *mMinMaxStepData;
+ BOOLEAN ValueIsSet;
+ BOOLEAN IsNumeric;
public:
- CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) {
+ CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) {
mMinMaxStepData->u64.MinValue = 0;
mMinMaxStepData->u64.MaxValue = 0;
mMinMaxStepData->u64.Step = 0;
+ ValueIsSet = FALSE;
+ IsNumeric = NumericOpcode;
}
VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) {
- mMinMaxStepData->u64.MinValue = MinValue;
- mMinMaxStepData->u64.MaxValue = MaxValue;
- mMinMaxStepData->u64.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u64.MinValue) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u64.MaxValue) {
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u64.Step = Step;
}
VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) {
- mMinMaxStepData->u32.MinValue = MinValue;
- mMinMaxStepData->u32.MaxValue = MaxValue;
- mMinMaxStepData->u32.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u32.MinValue) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u32.MaxValue) {
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u32.Step = Step;
}
VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) {
- mMinMaxStepData->u16.MinValue = MinValue;
- mMinMaxStepData->u16.MaxValue = MaxValue;
- mMinMaxStepData->u16.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u16.MinValue) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u16.MaxValue) {
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u16.Step = Step;
}
VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) {
- mMinMaxStepData->u8.MinValue = MinValue;
- mMinMaxStepData->u8.MaxValue = MaxValue;
- mMinMaxStepData->u8.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u8.MinValue) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u8.MaxValue) {
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u8.Step = Step;
+ }
+
+ UINT64 GetMinData (UINT8 VarType) {
+ UINT64 MinValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MinValue = mMinMaxStepData->u64.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MinValue = (UINT64) mMinMaxStepData->u32.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MinValue = (UINT64) mMinMaxStepData->u16.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MinValue = (UINT64) mMinMaxStepData->u8.MinValue;
+ break;
+ default:
+ break;
+ }
+ return MinValue;
+ }
+
+ UINT64 GetMaxData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
+ }
+
+ UINT64 GetStepData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.Step;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
}
+ BOOLEAN IsNumericOpcode () {
+ return IsNumeric;
+ }
};
+static CIfrQuestionHeader *gCurrentQuestion = NULL;
+static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
+
/*
* The definition of all of the UEFI IFR Objects
*/
@@ -418,10 +532,11 @@ private: EFI_IFR_FORM_SET *mFormSet;
public:
- CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),
- CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {
+ CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),
+ CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {
mFormSet->Help = EFI_STRING_ID_INVALID;
mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;
+ mFormSet->Flags = 0;
memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));
}
@@ -436,6 +551,17 @@ public: VOID SetHelp (IN EFI_STRING_ID Help) {
mFormSet->Help = Help;
}
+
+ VOID SetClassGuid (IN EFI_GUID *Guid) {
+ if (mFormSet->Flags > 0 && ExpendObjBin(sizeof(EFI_GUID))) {
+ IncLength (sizeof (EFI_GUID));
+ }
+ memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
+ }
+
+ UINT8 GetFlags() {
+ return mFormSet->Flags;
+ }
};
class CIfrEnd : public CIfrObj, public CIfrOpHeader {
@@ -817,7 +943,7 @@ private: public:
CIfrResetButton () : CIfrObj (EFI_IFR_RESET_BUTTON_OP, (CHAR8 **)&mResetButton),
CIfrOpHeader (EFI_IFR_RESET_BUTTON_OP, &mResetButton->Header),
- CIfrStatementHeader (&mResetButton->Question.Header) {
+ CIfrStatementHeader (&mResetButton->Statement) {
mResetButton->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
}
@@ -834,7 +960,7 @@ public: CIfrCheckBox () : CIfrObj (EFI_IFR_CHECKBOX_OP, (CHAR8 **)&mCheckBox),
CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header),
CIfrQuestionHeader (&mCheckBox->Question) {
- mCheckBox->Flags = EFI_IFR_CHECKBOX_DEFAULT;
+ mCheckBox->Flags = 0;
gCurrentQuestion = this;
}
@@ -860,6 +986,10 @@ public: return _FLAGS_ZERO (LFlags) ? VFR_RETURN_SUCCESS : VFR_RETURN_FLAGS_UNSUPPORTED;
}
+
+ UINT8 GetFlags (VOID) {
+ return mCheckBox->Flags;
+ }
};
class CIfrAction : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {
@@ -929,13 +1059,15 @@ public: CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric),
CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header),
CIfrQuestionHeader (&mNumeric->Question),
- CIfrMinMaxStepData (&mNumeric->data) {
+ CIfrMinMaxStepData (&mNumeric->data, TRUE) {
mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
- gCurrentQuestion = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrNumeric () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -965,11 +1097,13 @@ public: CIfrQuestionHeader (&mOneOf->Question),
CIfrMinMaxStepData (&mOneOf->data) {
mOneOf->Flags = 0;
- gCurrentQuestion = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrOneOf () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -1428,7 +1562,7 @@ public: if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId1 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1440,7 +1574,7 @@ public: if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId2 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
@@ -1466,7 +1600,7 @@ public: if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVal->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1498,7 +1632,7 @@ public: if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVList->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1540,7 +1674,7 @@ public: if (QuestionId != EFI_QUESTION_ID_INVALID) {
mQuestionRef1->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g index 1a31b2e41d..85060c8e84 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g @@ -29,7 +29,7 @@ Abstract: #include "stdio.h"
#include "PBlackBox.h"
#include "DLexerBase.h"
-#include "VfrLexer.h"
+#include "VfrLexer.h"
#include "AToken.h"
#define GET_LINENO(Obj) ((Obj)->getLine())
@@ -42,9 +42,9 @@ class CVfrDLGLexer : public VfrLexer {
public:
CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};
- INT32 errstd (char *Text)
- {
- printf ("unrecognized input '%s'\n", Text);
+ INT32 errstd (char *Text)
+ {
+ printf ("unrecognized input '%s'\n", Text);
}
};
@@ -70,7 +70,7 @@ VfrParserStart ( // is not preceeded with a backslash.
//
#lexclass QUOTED_STRING
-#token TheString "~[\"]*\"" << mode (START); >>
+#token TheString "~[\"]*\"" << mode (START); >>
//
// Define a lexclass for skipping over C++ style comments
@@ -92,7 +92,7 @@ VfrParserStart ( //
// Skip whitespace
//
-#token "[\ \t]" << skip (); >>
+#token "[\ \t]" << skip (); >>
//
// Skip over newlines, but count them
@@ -128,13 +128,12 @@ VfrParserStart ( #token Title("title") "title"
#token FormId("formid") "formid"
#token OneOf("oneof") "oneof"
-#token EndoneOf("endoneof") "endoneof"
+#token EndOneOf("endoneof") "endoneof"
#token Prompt("prompt") "prompt"
#token OrderedList("orderedlist") "orderedlist"
#token MaxContainers("maxcontainers") "maxcontainers"
#token EndList("endlist") "endlist"
#token EndForm("endform") "endform"
-#token EndOneOf("endoneof") "endoneof"
#token Form("form") "form"
#token Subtitle("subtitle") "subtitle"
#token Help("help") "help"
@@ -157,26 +156,27 @@ VfrParserStart ( #token Inventory("inventory") "inventory"
#token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP"
#token Struct("struct") "struct"
+#token Boolean("BOOLEAN") "BOOLEAN" #token Uint64("UINT64") "UINT64"
#token Uint32("UINT32") "UINT32"
#token Uint16("UINT16") "UINT16"
#token Char16("CHAR16") "CHAR16"
#token Uint8("UINT8") "UINT8"
-#token GUID("guid") "guid"
+#token Uuid("guid") "guid"
#token CheckBox("checkbox") "checkbox"
#token EndCheckBox("endcheckbox") "endcheckbox"
#token Numeric("numeric") "numeric"
-#token EndNumeric("endnumeric") "endnumeric"
-#token Minimum("minimum") "minimum"
-#token Maximum("maximum") "maximum"
-#token STEP("step") "step"
-#token Default("default") "default"
-#token Password("password") "password"
-#token EndPassword("endpassword") "endpassword"
+#token EndNumeric("endnumeric") "endnumeric"
+#token Minimum("minimum") "minimum"
+#token Maximum("maximum") "maximum"
+#token STEP("step") "step"
+#token Default("default") "default"
+#token Password("password") "password"
+#token EndPassword("endpassword") "endpassword"
#token String("string") "string"
-#token EndString("endstring") "endstring"
-#token MinSize("minsize") "minsize"
-#token MaxSize("maxsize") "maxsize"
+#token EndString("endstring") "endstring"
+#token MinSize("minsize") "minsize"
+#token MaxSize("maxsize") "maxsize"
#token Encoding("encoding") "encoding"
#token SuppressIf("suppressif") "suppressif"
#token DisableIf("disableif") "disableif"
@@ -198,6 +198,7 @@ VfrParserStart ( #token OptionOnlyFlag("OPTIONS_ONLY") "OPTIONS_ONLY"
#token Class("class") "class"
#token Subclass("subclass") "subclass"
+#token ClassGuid("classguid") "classguid" #token TypeDef("typedef") "typedef"
#token Restore("restore") "restore"
#token Save("save") "save"
@@ -253,36 +254,71 @@ VfrParserStart ( //
vfrProgram > [UINT8 Return] :
- << mParserStatus = 0; >>
+ << + mParserStatus = 0;
+ mConstantOnlyInExpression = FALSE; + >>
(
- (
- "\#pragma" "pack" "\(" A:Number "\)" << _PCATCH(mCVfrVarDataTypeDB.Pack (_STOU32(A->getText())), A); >>
- vfrDataStructDefinition
- "\#pragma" "pack" "\(" "\)" << mCVfrVarDataTypeDB.UnPack (); >>
- )
- |
- (
- vfrDataStructDefinition
- )
+ vfrPragmaPackDefinition
+ | vfrDataStructDefinition
)*
- vfrFromSetDefinition
+ vfrFormSetDefinition
<< $Return = mParserStatus; >>
;
-//*****************************************************************************
-//
-// the syntax of data struct definition
-//
+pragmaPackShowDef :
+ L:"show" << mCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >> + ; +
+pragmaPackStackDef :
+ << + UINT32 LineNum; + UINT8 PackAction; + INT8 *Identifier = NULL; + UINT32 PackNumber = DEFAULT_PACK_ALIGN; + >> + ( + L1:"push" << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >> + | L2:"pop" << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >> + ) + { + "," ID:StringIdentifier << Identifier = ID->getText(); >> + } + { + "," N:Number << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >> + } + << mCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >> + ; +
+pragmaPackNumber : + << + UINT32 LineNum; + UINT32 PackNumber = DEFAULT_PACK_ALIGN; + >> + N:Number << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >> + << mCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >> + ; + +vfrPragmaPackDefinition : + "\#pragma" "pack" "\(" + { + pragmaPackShowDef + | pragmaPackStackDef + | pragmaPackNumber + } + "\)" + ; + vfrDataStructDefinition :
{ TypeDef } Struct << mCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>
- { NonNVDataMap }
+ { NonNvDataMap }
{
N1:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>
}
- OpenBrace
+ OpenBrace
vfrDataStructFields
- CloseBrace
- {
+ CloseBrace
+ {
N2:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>
}
";" << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>
@@ -290,13 +326,13 @@ vfrDataStructDefinition : vfrDataStructFields :
(
- dataStructField64 |
- dataStructField32 |
- dataStructField16 |
- dataStructField8 |
+ dataStructField64 |
+ dataStructField32 |
+ dataStructField16 |
+ dataStructField8 |
dataStructFieldBool |
dataStructFieldString |
- dataStructFieldDate |
+ dataStructFieldDate |
dataStructFieldTime |
dataStructFieldUser
)*
@@ -304,8 +340,8 @@ vfrDataStructFields : dataStructField64 :
<< UINT32 ArrayNum = 0; >>
- "UINT64"
- N:StringIdentifier
+ "UINT64"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -314,8 +350,8 @@ dataStructField64 : dataStructField32 :
<< UINT32 ArrayNum = 0; >>
- "UINT32"
- N:StringIdentifier
+ "UINT32"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -325,7 +361,7 @@ dataStructField32 : dataStructField16 :
<< UINT32 ArrayNum = 0; >>
("UINT16" | "CHAR16")
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -335,7 +371,7 @@ dataStructField16 : dataStructField8 :
<< UINT32 ArrayNum = 0; >>
"UINT8"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -345,7 +381,7 @@ dataStructField8 : dataStructFieldBool :
<< UINT32 ArrayNum = 0; >>
"BOOLEAN"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -355,7 +391,7 @@ dataStructFieldBool : dataStructFieldString :
<< UINT32 ArrayNum = 0; >>
"EFI_STRING_ID"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -364,8 +400,8 @@ dataStructFieldString : dataStructFieldDate :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_DATE"
- N:StringIdentifier
+ "EFI_HII_DATE"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -374,8 +410,8 @@ dataStructFieldDate : dataStructFieldTime :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_TIME"
- N:StringIdentifier
+ "EFI_HII_TIME"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -394,30 +430,89 @@ dataStructFieldUser : //*****************************************************************************
//
-// the syntax of from set definition
+// the syntax of GUID definition
//
-vfrFromSetDefinition :
+guidSubDefinition [EFI_GUID &Guid] :
+ G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number + <<
+ Guid.Data4[0] = _STOU8(G4->getText());
+ Guid.Data4[1] = _STOU8(G5->getText());
+ Guid.Data4[2] = _STOU8(G6->getText());
+ Guid.Data4[3] = _STOU8(G7->getText()); + Guid.Data4[4] = _STOU8(G8->getText()); + Guid.Data4[5] = _STOU8(G9->getText()); + Guid.Data4[6] = _STOU8(G10->getText()); + Guid.Data4[7] = _STOU8(G11->getText()); + >>
+ ;
+
+guidDefinition [EFI_GUID &Guid] : + OpenBrace
+ G1:Number "," G2:Number "," G3:Number ","
+ << + Guid.Data1 = _STOU32 (G1->getText()); + Guid.Data2 = _STOU16 (G2->getText()); + Guid.Data3 = _STOU16 (G3->getText()); + >> + ( + OpenBrace guidSubDefinition[Guid] CloseBrace + | guidSubDefinition[Guid] + ) + CloseBrace
+ ; + +//***************************************************************************** +// +// the syntax of form set definition +// +vfrFormSetDefinition : <<
EFI_GUID Guid;
- CIfrFormSet FSObj;
- UINT16 C, SC;
+ EFI_GUID DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;
+ EFI_GUID ClassGuids[10];
+ UINT8 ClassGuidNum = 0;
+ CIfrFormSet *FSObj = NULL;
+ UINT16 C, SC; >>
- L:FormSet << SET_LINE_INFO (FSObj, L); >>
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- FSObj.SetGuid (&Guid);
- >>
- ","
- Title "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>
- Help "=" "STRING_TOKEN" "\(" S2:Number "\)" "," << FSObj.SetHelp (_STOSID(S2->getText())); >>
+ L:FormSet + Uuid "=" guidDefinition[Guid] "," + Title "=" "STRING_TOKEN" "\(" S1:Number "\)" "," + Help "=" "STRING_TOKEN" "\(" S2:Number "\)" "," + { + ClassGuid "=" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >> + ( + "\|" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >> + )* + ","
+ } + << + switch (ClassGuidNum) { + case 0: + FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET)); + FSObj->SetClassGuid(&DefaultClassGuid); + break; + case 1: + FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET)); + FSObj->SetClassGuid(&ClassGuids[0]); + break; + case 2: + FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID)); + FSObj->SetClassGuid(&ClassGuids[0]); + FSObj->SetClassGuid(&ClassGuids[1]); + break; + default: + FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID)); + FSObj->SetClassGuid(&ClassGuids[0]); + FSObj->SetClassGuid(&ClassGuids[1]); + FSObj->SetClassGuid(&ClassGuids[2]); + break; + } + + SET_LINE_INFO (*FSObj, L); + FSObj->SetGuid (&Guid); + FSObj->SetFormSetTitle (_STOSID(S1->getText()));
+ FSObj->SetHelp (_STOSID(S2->getText()));
+ >> {
Class "=" classDefinition[C] "," << {CIfrClass CObj; CObj.SetClass(C);} >>
}
@@ -429,7 +524,7 @@ vfrFromSetDefinition : //_DeclareDefaultLinearVarStore (GET_LINENO (L));
>>
vfrFormSetList
- E:EndFormSet << CRT_END_OP (E); >>
+ E:EndFormSet << CRT_END_OP (E); if (FSObj != NULL) {delete FSObj;}>>
";"
;
@@ -441,7 +536,7 @@ vfrFormSetList : vfrStatementVarStoreEfi |
vfrStatementVarStoreNameValue |
vfrStatementDefaultStore |
- vfrStatementDisableIfFromSet
+ vfrStatementDisableIfFormSet
)*
;
@@ -452,7 +547,7 @@ vfrStatementDefaultStore : {
"," Attribute "=" A:Number << DefaultId = _STOU16(A->getText()); >>
}
- <<
+ <<
if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
CIfrDefaultStore DSObj;
_PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
@@ -468,7 +563,7 @@ vfrStatementDefaultStore : vfrStatementVarStoreLinear :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStore VSObj;
INT8 *TypeName;
UINT32 LineNum;
@@ -487,31 +582,28 @@ vfrStatementVarStoreLinear : )
{ Key "=" Number "," } // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
{
- VarId "=" ID:Number "," << VarStoreId = _STOU16(ID->getText()); >>
+ VarId "=" ID:Number "," << + _PCATCH( + (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
+ (INTN)TRUE, + ID, + "varid 0 is not allowed." + ); + >> }
Name "=" SN:StringIdentifier ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid]
<<
_PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
- SN->getText(),
- &Guid,
- &mCVfrVarDataTypeDB,
+ SN->getText(),
+ &Guid,
+ &mCVfrVarDataTypeDB,
TypeName,
VarStoreId
), LineNum);
>>
- <<
- VSObj.SetGuid (&Guid);
+ <<
+ VSObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
VSObj.SetVarStoreId (VarStoreId);
_PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
@@ -534,22 +626,11 @@ vfrStatementVarStoreEfi : << VSEObj.SetAttributes (Attr); >>
Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
VarSize "=" N:Number ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
- <<
+ Uuid "=" guidDefinition[Guid] << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
+ <<
VSEObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSEObj.SetVarStoreId (VarStoreId);
+ VSEObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -560,7 +641,7 @@ vfrVarStoreEfiAttr [UINT32 & Attr] : vfrStatementVarStoreNameValue :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStoreNameValue VSNVObj;
EFI_VARSTORE_ID VarStoreId;
>>
@@ -569,22 +650,11 @@ vfrStatementVarStoreNameValue : (
Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
)+
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
- <<
+ Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
+ <<
VSNVObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSNVObj.SetVarStoreId (VarStoreId);
+ VSNVObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -597,7 +667,7 @@ classDefinition[UINT16 & Class] : << $Class = 0; >>
validClassNames[$Class] ( "\|" validClassNames[$Class] )*
;
-
+
validClassNames[UINT16 & Class] :
ClassNonDevice << $Class |= EFI_NON_DEVICE_CLASS; >>
| ClassDiskDevice << $Class |= EFI_DISK_DEVICE_CLASS; >>
@@ -618,10 +688,13 @@ subclassDefinition[UINT16 & SubClass] : | N:Number << $SubClass |= _STOU16(N->getText()); >>
;
-vfrStatementDisableIfFromSet :
- << CIfrDisableIf DIObj; >>
+vfrStatementDisableIfFormSet :
+ << + CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0; + >> D:DisableIf << DIObj.SetLineNo(D->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrFormSetList
E:EndIf << CRT_END_OP (E); >>
";"
@@ -638,7 +711,7 @@ vfrStatementHeader[CIfrStatementHeader *SHObj] : vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
<<
- EFI_VARSTORE_INFO Info;
+ EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *QName = NULL;
INT8 *VarIdStr = NULL;
@@ -653,10 +726,10 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_ {
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
>>
}
- <<
+ <<
switch (QType) {
case QUESTION_NORMAL:
mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
@@ -692,10 +765,10 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] : {
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
>>
}
- <<
+ <<
mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
$QHObj->SetQuestionId (QId);
>>
@@ -718,13 +791,14 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] : INT8 *VarStr = NULL;
INT8 *SName = NULL;
INT8 *TName = NULL;
+ EFI_IFR_TYPE_VALUE Dummy = {0}; >>
(
SN1:StringIdentifier << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>
OpenBracket I1:Number CloseBracket << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<<
_PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);
- _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
+ _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
>>
)
@@ -739,7 +813,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] : _STRCAT(&VarStr, TName);
}
>>
-
+
(
"." <<
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
@@ -750,7 +824,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] : OpenBracket I2:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>
<< _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>
}
- )* <<
+ )* <<
switch (VarStoreType) {
case EFI_VFR_VARSTORE_EFI:
_PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
@@ -758,6 +832,19 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] : case EFI_VFR_VARSTORE_BUFFER:
_PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());
//_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);
+ _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register ( + SName, + NULL), + SN2->getLine()); + _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write ( + 'a', + SName, + NULL, + $Info.mVarType, + $Info.mInfo.mVarOffset, + $Info.mVarTotalSize, + Dummy), + SN2->getLine()); break;
case EFI_VFR_VARSTORE_NAME:
default: break;
@@ -775,7 +862,11 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U SN1:StringIdentifier << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>
OpenBracket I1:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) { + _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo); + } + >> |
(
SN2:StringIdentifier << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>
@@ -787,11 +878,15 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U }
)*
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) { + _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo); + } + >> ;
vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
- N1:Number <<
+ N1:Number <<
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
$Value.u8 = _STOU8(N1->getText());
@@ -815,7 +910,7 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] : case EFI_IFR_TYPE_DATE :
default :
break;
- }
+ }
>>
| B1:True << $Value.b = TRUE; >>
| B2:False << $Value.b = FALSE; >>
@@ -845,7 +940,7 @@ vfrFormDefinition : vfrStatementQuestions |
vfrStatementConditional |
vfrStatementLabel |
- vfrStatementBanner
+ vfrStatementBanner
// Just for framework vfr compatibility
//vfrStatementInvalid
)*
@@ -853,14 +948,17 @@ vfrFormDefinition : ";"
;
-vfrStatementRules :
- << CIfrRule RObj; >>
+vfrStatementRules :
+ << + CIfrRule RObj;
+ UINT32 ExpOpCount = 0; + >> R:Rule << RObj.SetLineNo(R->getLine()); >>
S1:StringIdentifier "," <<
mCVfrRulesDB.RegisterRule (S1->getText());
- RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
+ RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
>>
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndRule << CRT_END_OP (E); >>
";"
;
@@ -868,7 +966,7 @@ vfrStatementRules : vfrStatementDefault :
<<
BOOLEAN IsExp = FALSE;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrDefault DObj;
EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
INT8 *VarStoreName = NULL;
@@ -877,30 +975,40 @@ vfrStatementDefault : D:Default << DObj.SetLineNo(D->getLine()); >>
(
(
- vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); >>
- | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","
- << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>
+ vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
+ | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," <<
+ if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) { + //check default value is valid for Numeric Opcode + if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + } + DObj.SetType (_GET_CURRQEST_DATATYPE());
+ DObj.SetValue(Val); + >> )
{
DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>
}
- <<
- _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
- _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
- if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
- _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- DefaultId,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
- Val), D->getLine());
- }
- >>
+ <<
+ _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
+ _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
+ if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
+ _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+ DefaultId,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
+ Val), + D->getLine()
+ ); + }
+ >>
)
;
vfrStatementStat :
- vfrStatementSubTitle |
+ vfrStatementSubTitle |
vfrStatementStaticText |
vfrStatementCrossReference
;
@@ -932,14 +1040,18 @@ vfrStatementInvalid : ;
flagsField :
- Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
+ Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
NVAccessFlag | ResetRequiredFlag | LateCheckFlag
;
vfrStatementValue :
- << CIfrValue VObj; >>
+ << + CIfrValue VObj;
+ UINT32 ExpOpCount = 0; + >> V:Value << VObj.SetLineNo(V->getLine()); >>
- "=" vfrStatementExpression[0]
+ "=" vfrStatementExpression[0, ExpOpCount]
+ << { CIfrEnd EndObj; EndObj.SetLineNo(0); } >> ;
vfrStatementSubTitle :
@@ -965,7 +1077,7 @@ subtitleFlagsField [UINT8 & Flags] : ;
vfrStatementStaticText :
- <<
+ <<
UINT8 Flags = 0;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
EFI_STRING_ID TxtTwo = EFI_STRING_ID_INVALID;
@@ -983,6 +1095,7 @@ vfrStatementStaticText : <<
if (Flags & EFI_IFR_FLAG_CALLBACK) {
CIfrAction AObj;
+ AObj.SetLineNo (T->getLine()); mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);
AObj.SetQuestionId (QId);
AObj.SetPrompt (_STOSID(S2->getText()));
@@ -1013,7 +1126,7 @@ vfrStatementCrossReference : ;
vfrStatementGoto :
- <<
+ <<
UINT8 RefType = 1;
EFI_STRING_ID DevPath;
EFI_GUID FSId;
@@ -1030,39 +1143,23 @@ vfrStatementGoto : (
(
DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
- FormSetGuid "="
- OpenBrace
- G11:Number "," G12:Number "," G13:Number "," G14:Number "," G15:Number "," G16:Number ","
- G17:Number "," G18:Number "," G19:Number "," G110:Number "," G111:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F1:Number ","
Question "=" QN1:Number ","
- <<
+ <<
RefType = 4;
- _CRGUID (&FSId, G11->getText (), G12->getText (), G13->getText (),
- G14->getText (), G15->getText (), G16->getText (),
- G17->getText (), G18->getText (), G19->getText (),
- G110->getText (), G111->getText ());
- DevPath = _STOSID(P->getText());
+ DevPath = _STOSID(P->getText());
FId = _STOFID(F1->getText());
QId = _STOQID(QN1->getText());
>>
)
|
(
- FormSetGuid "="
- OpenBrace
- G21:Number "," G22:Number "," G23:Number "," G24:Number "," G25:Number "," G26:Number ","
- G27:Number "," G28:Number "," G29:Number "," G210:Number "," G211:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F2:Number ","
Question "=" QN2:Number ","
<<
RefType = 3;
- _CRGUID (&FSId, G21->getText (), G22->getText (), G23->getText (),
- G24->getText (), G25->getText (), G26->getText (),
- G27->getText (), G28->getText (), G29->getText (),
- G210->getText (), G211->getText ());
FId = _STOFID(F2->getText());
QId = _STOQID(QN2->getText());
>>
@@ -1070,7 +1167,7 @@ vfrStatementGoto : |
(
FormId "=" F3:Number "," << RefType = 2; FId = _STOFID(F3->getText()); >>
- Question "="
+ Question "="
(
QN3:StringIdentifier "," << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>
| QN4:Number "," << QId = _STOQID(QN4->getText()); >>
@@ -1078,7 +1175,7 @@ vfrStatementGoto : )
|
(
- F4:Number "," <<
+ F4:Number "," <<
RefType = 1;
FId = _STOFID(F4->getText());
>>
@@ -1088,31 +1185,31 @@ vfrStatementGoto : switch (RefType) {
case 4:
{
- R4Obj = new CIfrRef4;
- QHObj = R4Obj;
- R4Obj->SetLineNo(G->getLine());
- R4Obj->SetDevicePath (DevPath);
- R4Obj->SetFormSetId (FSId);
- R4Obj->SetFormId (FId);
- R4Obj->SetQuestionId (QId);
+ R4Obj = new CIfrRef4;
+ QHObj = R4Obj;
+ R4Obj->SetLineNo(G->getLine());
+ R4Obj->SetDevicePath (DevPath);
+ R4Obj->SetFormSetId (FSId);
+ R4Obj->SetFormId (FId);
+ R4Obj->SetQuestionId (QId);
break;
}
case 3:
{
- R3Obj = new CIfrRef3;
- QHObj = R3Obj;
- R3Obj->SetLineNo(G->getLine());
- R3Obj->SetFormSetId (FSId);
- R3Obj->SetFormId (FId);
- R3Obj->SetQuestionId (QId);
+ R3Obj = new CIfrRef3;
+ QHObj = R3Obj;
+ R3Obj->SetLineNo(G->getLine());
+ R3Obj->SetFormSetId (FSId);
+ R3Obj->SetFormId (FId);
+ R3Obj->SetQuestionId (QId);
break;
}
case 2:
{
- R2Obj = new CIfrRef2;
- QHObj = R2Obj;
- R2Obj->SetLineNo(G->getLine());
- R2Obj->SetFormId (FId);
+ R2Obj = new CIfrRef2;
+ QHObj = R2Obj;
+ R2Obj->SetLineNo(G->getLine());
+ R2Obj->SetFormId (FId);
_PCATCH(R2Obj->SetQuestionId (QId), QN3);
break;
}
@@ -1155,12 +1252,12 @@ getStringId : vfrStatementResetButton :
<<
- CIfrResetButton RBObj;
+ CIfrResetButton RBObj;
UINT16 DefaultId;
>>
L:ResetButton << RBObj.SetLineNo(L->getLine()); >>
- DefaultStore
- "=" N:StringIdentifier "," <<
+ DefaultStore
+ "=" N:StringIdentifier "," <<
_PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());
RBObj.SetDefaultId (DefaultId);
>>
@@ -1184,23 +1281,59 @@ vfrStatementBooleanType : // prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
// help = STRING_TOKEN(STR_CHECK_BOX_HELP),
// flags = CHECKBOX_DEFAULT | CALLBACK,
-// default value = TRUE, defaultstore = MyDefaultStore,
+// default value = TRUE, defaultstore = MyDefaultStore,
// endcheckbox;
//
vfrStatementCheckBox :
<<
- CIfrCheckBox CBObj;
+ CIfrCheckBox CBObj;
+ EFI_IFR_TYPE_VALUE Val = {0}; + INT8 *VarStoreName = NULL; >>
L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[CBObj] ","
- { F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] "," }
+ { + F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
+ << + _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name"); + Val.b = TRUE; + if (CBObj.GetFlags () & 0x01) { + _PCATCH( + mCVfrDefaultStore.BufferVarStoreAltConfigAdd ( + EFI_HII_DEFAULT_CLASS_STANDARD, + _GET_CURRQEST_VARTINFO(), + VarStoreName, + _GET_CURRQEST_DATATYPE (), + Val + ), + VFR_RETURN_SUCCESS, + L, + "No standard default storage found" + ); + } + if (CBObj.GetFlags () & 0x02) { + _PCATCH( + mCVfrDefaultStore.BufferVarStoreAltConfigAdd ( + EFI_HII_DEFAULT_CLASS_MANUFACTURING, + _GET_CURRQEST_VARTINFO(), + VarStoreName, + _GET_CURRQEST_DATATYPE (), + Val + ), + VFR_RETURN_SUCCESS, + L, + "No manufacturing default storage found" + ); + } + >> + } {
Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
}
vfrStatementQuestionOptionList
E:EndCheckBox << CRT_END_OP (E); >>
";"
- ;
+ ;
vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
<<
@@ -1256,7 +1389,7 @@ vfrStatementDate : EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrDate DObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Date << DObj.SetLineNo(L->getLine()); >>
(
@@ -1285,14 +1418,14 @@ vfrStatementDate : Help "=" "STRING_TOKEN" "\(" DH:Number "\)" ","
minMaxDateStepDefault[Val.date, 2]
<<
- mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
DObj.SetQuestionId (QId);
DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);
DObj.SetPrompt (_STOSID(YP->getText()));
DObj.SetHelp (_STOSID(YH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DObj.SetLineNo (D1Y->getLine());} >>
( vfrStatementInconsistentIf )*
)
)
@@ -1307,10 +1440,10 @@ minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] : {
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: D.Year = _STOU16(N->getText()); break;
- case 1: D.Month = _STOU8(N->getText()); break;
+ case 0: D.Year = _STOU16(N->getText()); break;
+ case 1: D.Month = _STOU8(N->getText()); break;
case 2: D.Day = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1400,18 +1533,38 @@ vfrStatementNumeric : vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID; >>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>
+ << + //check data type flag + VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); + if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) { + if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type"); + } + } else { + // update data type for name/value store + UINT32 DataTypeSize; + _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE; + mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize; + } + _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);
+ >> ;
numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
- | "DISPLAY_INT_DEC" << $LFlags |= 0x00; >>
- | "DISPLAY_UINT_DEC" << $LFlags |= 0x10; >>
- | "DISPLAY_UINT_HEX" << $LFlags |= 0x20; >>
+ | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>
+ | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>
+ | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>
+ | "NUMERIC_SIZE_8" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; >> + | "DISPLAY_INT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >> + | "DISPLAY_UINT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >> + | "DISPLAY_UINT_HEX" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >> | questionheaderFlagsField[HFlags]
;
@@ -1420,9 +1573,9 @@ vfrStatementOneOf : CIfrOneOf OObj;
>>
L:OneOf << OObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[OObj] ","
+ vfrQuestionHeader[OObj] "," << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
{ F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
- {
+ {
vfrSetMinMaxStep[OObj]
}
vfrStatementQuestionOptionList
@@ -1432,11 +1585,27 @@ vfrStatementOneOf : vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID; >>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>
+ << + //check data type flag + VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); + if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) { + if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type"); + } + } else { + // update data type for Name/Value store + UINT32 DataTypeSize; + _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE; + mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize; + } + _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
+ >> ;
vfrStatementStringType :
@@ -1449,7 +1618,7 @@ vfrStatementString : CIfrString SObj;
>>
L:String << SObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[SObj] "," << _PCATCH(SObj.SetFlags (SObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
+ vfrQuestionHeader[SObj] ","
{ F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }
{
Key "=" KN:Number "," << AssignQuestionKey (SObj, KN); >>
@@ -1478,7 +1647,7 @@ stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] : vfrStatementPassword :
<<
- CIfrPassword PObj;
+ CIfrPassword PObj;
>>
L:Password << PObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[PObj] ","
@@ -1507,12 +1676,12 @@ passwordFlagsField [UINT8 & HFlags] : vfrStatementOrderedList :
<<
- CIfrOrderedList OLObj;
+ CIfrOrderedList OLObj;
>>
L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[OLObj] ","
- << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>
- {
+ << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_ARRAY_SIZE()); >>
+ {
MaxContainers "=" M:Number "," << OLObj.SetMaxContainers (_STOU8(M->getText())); >>
}
{ F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }
@@ -1542,14 +1711,14 @@ vfrStatementTime : EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrTime TObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Time << TObj.SetLineNo(L->getLine()); >>
(
(
vfrQuestionHeader[TObj, QUESTION_TIME] ","
{ F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }
- vfrStatementDefault
+ vfrStatementQuestionOptionList
)
|
(
@@ -1571,14 +1740,14 @@ vfrStatementTime : Help "=" "STRING_TOKEN" "\(" SH:Number "\)" ","
minMaxTimeStepDefault[Val.time, 2]
<<
- mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
TObj.SetQuestionId (QId);
TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);
TObj.SetPrompt (_STOSID(HP->getText()));
TObj.SetHelp (_STOSID(HH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DObj.SetLineNo (T1H->getLine());} >>
)
)
E:EndTime << CRT_END_OP (E); >>
@@ -1592,10 +1761,10 @@ minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] : {
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: T.Hour = _STOU8(N->getText()); break;
- case 1: T.Minute = _STOU8(N->getText()); break;
+ case 0: T.Hour = _STOU8(N->getText()); break;
+ case 1: T.Minute = _STOU8(N->getText()); break;
case 2: T.Second = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1622,7 +1791,7 @@ vfrStatementQuestionTag : vfrStatementNoSubmitIf |
vfrStatementDisableIfQuest |
vfrStatementRefresh |
- vfrStatementVarstoreDevice
+ vfrStatementVarstoreDevice
;
vfrStatementQuestionTagList :
@@ -1639,7 +1808,7 @@ vfrStatementQuestionOptionTag : vfrStatementQuestionOptionList :
(
vfrStatementQuestionTag |
- vfrStatementQuestionOptionTag
+ vfrStatementQuestionOptionTag
)*
;
@@ -1648,34 +1817,43 @@ vfrStatementStatList : vfrStatementQuestions |
vfrStatementConditional |
// Just for framework vfr compatibility
- vfrStatementLabel
+ vfrStatementLabel
//vfrStatementInvalid
;
vfrStatementDisableIfStat :
- << CIfrDisableIf DIObj; >>
+ << + CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0; + >> L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementSuppressIfStat :
- << CIfrSuppressIf SIObj; >>
+ << + CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0; + >> L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementGrayOutIfStat :
- << CIfrGrayOutIf GOIObj; >>
+ << + CIfrGrayOutIf GOIObj;
+ UINT32 ExpOpCount = 0; + >> L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
@@ -1712,27 +1890,36 @@ vfrStatementLocked : ;
vfrStatementInconsistentIf :
- << CIfrInconsistentIf IIObj; >>
+ << + CIfrInconsistentIf IIObj;
+ UINT32 ExpOpCount = 0; + >> L:InconsistentIf << IIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementNoSubmitIf :
- << CIfrNoSubmitIf NSIObj; >>
+ << + CIfrNoSubmitIf NSIObj;
+ UINT32 ExpOpCount = 0; + >> L:NoSubmitIf << NSIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementDisableIfQuest :
- << CIfrDisableIf DIObj; >>
+ << + CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0; + >> L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1750,10 +1937,13 @@ vfrStatementVarstoreDevice : ;
vfrStatementSuppressIfQuest :
- << CIfrSuppressIf SIObj; >>
+ << + CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0; + >> L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1764,28 +1954,51 @@ vfrStatementOptions : vfrStatementOneOfOption :
<<
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrOneOfOption OOOObj;
INT8 *VarStoreName = NULL;
-
+
>>
L:Option << OOOObj.SetLineNo(L->getLine()); >>
Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >>
- Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] "," << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>
+ Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","
+ << + if (gCurrentMinMaxData != NULL) { + //set min/max value for oneof opcode + UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE()); + switch (_GET_CURRQEST_DATATYPE()) { + case EFI_IFR_TYPE_NUM_SIZE_64: + gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step); + break; + default: + break; + } + } + OOOObj.SetType (_GET_CURRQEST_DATATYPE()); + OOOObj.SetValue (Val); + >> F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]
<<
if (OOOObj.GetFlags () & 0x10) {
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
_PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- EFI_HII_DEFAULT_CLASS_STANDARD,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
+ EFI_HII_DEFAULT_CLASS_STANDARD,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
Val
), L->getLine());
}
>>
- { "," Key "=" Number } // no use in UEFI2.1 VFR
(
"," vfrImageTag << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>
)*
@@ -1794,7 +2007,7 @@ vfrStatementOneOfOption : vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = 0;
UINT8 HFlags = 0;
>>
oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*
@@ -1814,27 +2027,6 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] : | DefaultFlag << $LFlags |= 0x10; >>
;
-//vfrStatementGuid :
-// <<
-// EFI_GUID Guid;
-// CIfrGuid GObj;
-// >>
-// GuidAction
-// GUID "="
-// OpenBrace
-// G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
-// G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
-// CloseBrace
-// <<
-// _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
-// G4->getText (), G5->getText (), G6->getText (),
-// G7->getText (), G8->getText (), G9->getText (),
-// G10->getText (), G11->getText ());
-// >>
-// << GObj.SetGuid (&Guid); >>
-// ";"
-// ;
-
vfrStatementLabel :
<< CIfrLabel LObj; >>
L:Label << LObj.SetLineNo(L->getLine()); >>
@@ -1847,9 +2039,9 @@ vfrStatementBanner : B:Banner { "," } << BObj.SetLineNo(B->getLine()); >>
Title "=" "STRING_TOKEN" "\(" S:Number "\)" "," << BObj.SetTitle (_STOSID(S->getText())); >>
(
- (
+ (
Line L:Number "," << BObj.SetLine (_STOU16(L->getText())); >>
- Align
+ Align
(
Left << BObj.SetAlign (0); >>
| Center << BObj.SetAlign (1); >>
@@ -1867,17 +2059,18 @@ vfrStatementBanner : //
// keep some syntax for compatibility but not generate any IFR object
//
-vfrStatementInvalidHidden :
+vfrStatementInvalidHidden :
Hidden
Value "=" Number ","
Key "=" Number ";"
;
vfrStatementInvalidInconsistentIf :
+ << UINT32 ExpOpCount = 0; >> InconsistentIf
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
EndIf
";"
;
@@ -1889,15 +2082,15 @@ vfrStatementInvalidInventory : {
Text "=" "STRING_TOKEN" "\(" Number "\)"
}
- ";"
+ ";"
;
-vfrStatementInvalidSaveRestoreDefaults :
+vfrStatementInvalidSaveRestoreDefaults :
(Save | Restore)
Defaults ","
FormId "=" Number ","
Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","
- Help "=" "STRING_TOKEN" "\(" Number "\)"
+ Help "=" "STRING_TOKEN" "\(" Number "\)"
{ "," FLAGS "=" flagsField ( "\|" flagsField )* }
{ "," Key "=" Number }
";"
@@ -1939,13 +2132,13 @@ vfrStatementInvalidSaveRestoreDefaults : #token QuestionRefVal("questionrefval") "questionrefval"
#token StringRefVal("stringrefval") "stringrefval"
-vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
+vfrStatementExpression [UINT32 RootLevel, UINT32 & ExpOpCount] :
<< if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>
andTerm[$RootLevel, $ExpOpCount]
(
L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
)*
- << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>
+ << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; EObj.SetLineNo (0);} >>
;
andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
@@ -1956,7 +2149,7 @@ andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] : ;
bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- bitwiseandTerm[$RootLevel, $ExpOpCount]
+ bitwiseandTerm[$RootLevel, $ExpOpCount]
(
L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
)*
@@ -2004,7 +2197,7 @@ compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]: ;
shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- addMinusTerm[$RootLevel, $ExpOpCount]
+ addMinusTerm[$RootLevel, $ExpOpCount]
(
(
L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
@@ -2030,20 +2223,42 @@ addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]: ;
multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- atomTerm[$RootLevel, $ExpOpCount]
- (
+ castTerm[$RootLevel, $ExpOpCount]
+ (
(
- L1:"\*" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
+ L1:"\*" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
)
|
(
- L2:"/" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
+ L2:"/" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
)
|
(
- L3:"%" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
- )
+ L3:"%" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
+ )
)*
+ ; + +castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]: + << UINT8 CastType = 0xFF; >> + ( + L:"\(" + ( + Boolean << CastType = 0; >> + | Uint64 << CastType = 1; >> + | Uint32 << CastType = 1; >> + | Uint16 << CastType = 1; >> + | Uint8 << CastType = 1; >> + ) + "\)" + )* + atomTerm[$RootLevel, $ExpOpCount] + << + switch (CastType) { + case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break; + case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break; + } + >> ;
atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
@@ -2119,7 +2334,7 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));
EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
EIVObj.SetValue (ConstVal);
- $ExpOpCount++;
+ $ExpOpCount++;
} else {
IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
}
@@ -2163,7 +2378,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]
(
(
- "=="
+ "=="
vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
<<
if (Mask[0] & Mask[1]) {
@@ -2173,7 +2388,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));
EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);
EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);
- $ExpOpCount++;
+ $ExpOpCount++;
}
>>
)
@@ -2215,7 +2430,7 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : >>
L:IdEqValList
vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
- "=="
+ "=="
(
V:Number << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>
)+
@@ -2239,9 +2454,9 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number <<
{
- CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
- _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
- U64Obj1.SetValue (_STOU64(V1->getText()));
+ CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
+ _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
+ U64Obj1.SetValue (_STOU64(V1->getText()));
U64Obj2.SetValue (_STOU64(V2->getText()));
}
>>
@@ -2267,25 +2482,14 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : Path "=" "STRING_TOKEN" "\(" S:Number "\)" << Type = 0x4; DevPath = _STOSID(S->getText()); >>
}
{
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- Type = 0x5;
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid] << Type = 0x5; >>
}
)
|
(
"\("
(
- QN:StringIdentifier <<
+ QN:StringIdentifier <<
QName = QN->getText();
LineNo = QN->getLine();
mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);
@@ -2340,6 +2544,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] : | bitwisenotExp[$RootLevel, $ExpOpCount]
| question2refExp[$RootLevel, $ExpOpCount]
| stringref2Exp[$RootLevel, $ExpOpCount]
+ | toboolExp[$RootLevel, $ExpOpCount] | unintExp[$RootLevel, $ExpOpCount]
| toupperExp[$RootLevel, $ExpOpCount]
| tolwerExp[$RootLevel, $ExpOpCount]
@@ -2433,7 +2638,7 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : findFormat[Format] ( "\|" findFormat[Format] )*
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
@@ -2460,7 +2665,7 @@ tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
"\)" << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>
;
@@ -2489,12 +2694,13 @@ spanFlags [UINT8 & Flags] : //******************************************************************************
//
-// Parser class definition.
-//
+// Parser class definition.
+//
class EfiVfrParser {
<<
private:
UINT8 mParserStatus;
+ BOOLEAN mConstantOnlyInExpression; CVfrDefaultStore mCVfrDefaultStore;
CVfrVarDataTypeDB mCVfrVarDataTypeDB;
@@ -2517,12 +2723,14 @@ private: UINT8 _GET_CURRQEST_DATATYPE ();
UINT32 _GET_CURRQEST_VARSIZE ();
+ UINT32 _GET_CURRQEST_ARRAY_SIZE (); public:
- VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr, IN INT8 *);
+ VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN INT8 *);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);
+ VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN INT8 *); VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);
@@ -2557,7 +2765,7 @@ public: <<
VOID
EfiVfrParser::_SAVE_OPHDR_COND (
- IN CIfrOpHeader &OpHdr,
+ IN CIfrOpHeader &OpHdr,
IN BOOLEAN Cond
)
{
@@ -2637,17 +2845,48 @@ EfiVfrParser::_GET_CURRQEST_VARSIZE ( return mCurrQestVarInfo.mVarTotalSize;
}
+UINT32 +EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE ( + VOID + ) +{ + UINT8 Size = 1; + + switch (mCurrQestVarInfo.mVarType) { + case EFI_IFR_TYPE_NUM_SIZE_8: + Size = 1; + break; + + case EFI_IFR_TYPE_NUM_SIZE_16: + Size = 2; + break; + + case EFI_IFR_TYPE_NUM_SIZE_32: + Size = 4; + break; + + case EFI_IFR_TYPE_NUM_SIZE_64: + Size = 8; + break; + + default: + break; + } + + return (mCurrQestVarInfo.mVarTotalSize / Size); +} + VOID
EfiVfrParser::_PCATCH (
- IN EFI_VFR_RETURN_CODE ReturnCode,
- IN EFI_VFR_RETURN_CODE ExpectCode,
+ IN INTN ReturnCode,
+ IN INTN ExpectCode,
IN ANTLRTokenPtr Tok,
IN INT8 *ErrorMsg
)
{
if (ReturnCode != ExpectCode) {
mParserStatus++;
- gCVfrErrorHandle.PrintError (Tok->getLine(), Tok->getText(), ErrorMsg);
+ gCVfrErrorHandle.PrintMsg (Tok->getLine(), Tok->getText(), "Error", ErrorMsg);
}
}
@@ -2675,14 +2914,24 @@ EfiVfrParser::_PCATCH ( )
{
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
+} + +VOID +EfiVfrParser::_PCATCH ( + IN EFI_VFR_RETURN_CODE ReturnCode, + IN UINT32 LineNum, + IN INT8 *ErrorMsg + ) +{ + mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg); }
-VOID
+VOID
EfiVfrParser::syn (
- ANTLRAbstractToken *Tok,
- ANTLRChar *Egroup,
- SetWordType *Eset,
- ANTLRTokenType ETok,
+ ANTLRAbstractToken *Tok,
+ ANTLRChar *Egroup,
+ SetWordType *Eset,
+ ANTLRTokenType ETok,
INT32 Huh
)
{
@@ -2737,7 +2986,7 @@ EfiVfrParser::_STOU8 ( }
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2767,7 +3016,7 @@ EfiVfrParser::_STOU16 ( }
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2797,7 +3046,7 @@ EfiVfrParser::_STOU32 ( }
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2807,7 +3056,7 @@ UINT64 EfiVfrParser::_STOU64 (
IN INT8 *Str
)
-{
+{
BOOLEAN IsHex;
UINT64 Value;
INT8 c;
@@ -2827,16 +3076,16 @@ EfiVfrParser::_STOU64 ( }
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
-}
+}
EFI_HII_DATE
EfiVfrParser::_STOD (
- IN INT8 *Year,
- IN INT8 *Month,
+ IN INT8 *Year,
+ IN INT8 *Month,
IN INT8 *Day
)
{
@@ -2851,8 +3100,8 @@ EfiVfrParser::_STOD ( EFI_HII_TIME
EfiVfrParser::_STOT (
- IN INT8 *Hour,
- IN INT8 *Minute,
+ IN INT8 *Hour,
+ IN INT8 *Minute,
IN INT8 *Second
)
{
@@ -2881,7 +3130,7 @@ EfiVfrParser::_STOFID ( return (EFI_FORM_ID)_STOU16(Str);
}
-EFI_QUESTION_ID
+EFI_QUESTION_ID
EfiVfrParser::_STOQID (
IN INT8 *Str
)
@@ -2918,17 +3167,17 @@ EfiVfrParser::_STRCAT ( VOID
EfiVfrParser::_CRGUID (
- IN EFI_GUID *Guid,
- IN INT8 *G1,
- IN INT8 *G2,
- IN INT8 *G3,
- IN INT8 *G4,
- IN INT8 *G5,
- IN INT8 *G6,
- IN INT8 *G7,
- IN INT8 *G8,
- IN INT8 *G9,
- IN INT8 *G10,
+ IN EFI_GUID *Guid,
+ IN INT8 *G1,
+ IN INT8 *G2,
+ IN INT8 *G3,
+ IN INT8 *G4,
+ IN INT8 *G5,
+ IN INT8 *G6,
+ IN INT8 *G7,
+ IN INT8 *G8,
+ IN INT8 *G9,
+ IN INT8 *G10,
IN INT8 *G11
)
{
@@ -2964,9 +3213,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- TypeNameList[Index],
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ TypeNameList[Index],
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
TypeNameList[Index],
EFI_VARSTORE_ID_INVALID
);
@@ -2985,9 +3234,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Date",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Date",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_DATE",
EFI_VARSTORE_ID_INVALID
);
@@ -3006,9 +3255,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Time",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Time",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_TIME",
EFI_VARSTORE_ID_INVALID
);
@@ -3026,7 +3275,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage ( IN UINT32 LineNo
)
{
- CIfrDefaultStore DSObj;
+ CIfrDefaultStore DSObj;
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
DSObj.SetLineNo (LineNo);
@@ -3036,7 +3285,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage ( VOID
EfiVfrParser::AssignQuestionKey (
- IN CIfrQuestionHeader &QHObj,
+ IN CIfrQuestionHeader &QHObj,
IN ANTLRTokenPtr KeyTok
)
{
@@ -3059,7 +3308,7 @@ EfiVfrParser::AssignQuestionKey ( VOID
EfiVfrParser::ConvertIdExpr (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3093,7 +3342,7 @@ EfiVfrParser::ConvertIdExpr ( VOID
EfiVfrParser::IdEqValDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3145,7 +3394,7 @@ EfiVfrParser::IdEqValDoSpecial ( VOID
EfiVfrParser::IdEqIdDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId1,
IN INT8 *VarId1Str,
@@ -3192,7 +3441,7 @@ EfiVfrParser::IdEqIdDoSpecial ( VOID
EfiVfrParser::IdEqListDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp index caadc29da9..d6f5f437f2 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp @@ -1,5 +1,4 @@ /*++
-
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-
-VfrUtilityLib.cpp
+ VfrUtilityLib.cpp
Abstract:
@@ -74,12 +72,13 @@ CVfrBinaryOutput::WriteEnd ( }
SConfigInfo::SConfigInfo (
- IN UINT8 Type,
- IN UINT16 Offset,
- IN UINT32 Width,
+ IN UINT8 Type,
+ IN UINT16 Offset,
+ IN UINT32 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mNext = NULL;
mOffset = Offset;
mWidth = (UINT16)Width;
mValue = new UINT8[mWidth];
@@ -125,51 +124,51 @@ SConfigInfo::~SConfigInfo ( }
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
- mId = NULL;
- mInfo = NULL;
+ mName = NULL;
+ mId = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
}
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT16 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mName = NULL;
mId = NULL;
- mInfo = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
@@ -182,8 +181,8 @@ SConfigItem::~SConfigItem ( {
SConfigInfo *Info;
+ BUFFER_SAFE_FREE (mName);
BUFFER_SAFE_FREE (mId);
- BUFFER_SAFE_FREE (mInfo);
while (mInfoStrList != NULL) {
Info = mInfoStrList;
mInfoStrList = mInfoStrList->mNext;
@@ -194,17 +193,17 @@ SConfigItem::~SConfigItem ( UINT8
CVfrBufferConfig::Register (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *pNew;
- if (Select (Id) == 0) {
+ if (Select (Name) == 0) {
return 1;
}
- if ((pNew = new SConfigItem (Id, Info)) == NULL) {
+ if ((pNew = new SConfigItem (Name, Id)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -237,25 +236,27 @@ CVfrBufferConfig::Eof( UINT8
CVfrBufferConfig::Select (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *p;
- if (Id == NULL) {
+ if (Name == NULL) {
mItemListPos = mItemListHead;
return 0;
} else {
for (p = mItemListHead; p != NULL; p = p->mNext) {
- if (strcmp (p->mId, Id) != 0) {
+ if (strcmp (p->mName, Name) != 0) {
continue;
}
- if ((p->mInfo != NULL) && (Info != NULL)) {
- if (strcmp (p->mInfo, Info) != 0) {
+ if (Id != NULL) {
+ if (p->mId == NULL || strcmp (p->mId, Id) != 0) {
continue;
}
+ } else if (p->mId != NULL) {
+ continue;
}
mItemListPos = p;
@@ -269,8 +270,8 @@ CVfrBufferConfig::Select ( UINT8
CVfrBufferConfig::Write (
IN CONST CHAR8 Mode,
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT32 Width,
@@ -281,16 +282,14 @@ CVfrBufferConfig::Write ( SConfigItem *pItem;
SConfigInfo *pInfo;
+ if ((Ret = Select (Name)) != 0) {
+ return Ret;
+ }
+
switch (Mode) {
case 'a' : // add
- if (Select (Id) == 0) {
- if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
- return 2;
- }
- pInfo->mNext = mItemListPos->mInfoStrList;
- mItemListPos->mInfoStrList = pInfo;
- } else {
- if ((pItem = new SConfigItem (Id, Info, Type, Offset, Width, Value)) == NULL) {
+ if (Select (Name, Id) != 0) {
+ if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -301,14 +300,26 @@ CVfrBufferConfig::Write ( mItemListTail = pItem;
}
mItemListPos = pItem;
+ } else {
+ // tranverse the list to find out if there's already the value for the same offset
+ for (pInfo = mItemListPos->mInfoStrList; pInfo != NULL; pInfo = pInfo->mNext) {
+ if (pInfo->mOffset == Offset) {
+ // check if the value and width are the same; return error if not
+ if ((Id != NULL) && (pInfo->mWidth != Width || memcmp(pInfo->mValue, &Value, Width) != 0)) {
+ return VFR_RETURN_DEFAULT_VALUE_REDEFINED;
+ }
+ return 0;
+ }
+ }
+ if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
+ return 2;
+ }
+ pInfo->mNext = mItemListPos->mInfoStrList;
+ mItemListPos->mInfoStrList = pInfo;
}
break;
case 'd' : // delete
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
-
if (mItemListHead == mItemListPos) {
mItemListHead = mItemListPos->mNext;
delete mItemListPos;
@@ -327,18 +338,15 @@ CVfrBufferConfig::Write ( break;
case 'i' : // set info
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
- if (mItemListPos->mInfo != NULL) {
- delete mItemListPos->mInfo;
+ if (mItemListPos->mId != NULL) {
+ delete mItemListPos->mId;
}
- mItemListPos->mInfo = NULL;
- if (Info != NULL) {
- if ((mItemListPos->mInfo = new INT8[strlen (Info) + 1]) == NULL) {
+ mItemListPos->mId = NULL;
+ if (Id != NULL) {
+ if ((mItemListPos->mId = new INT8[strlen (Id) + 1]) == NULL) {
return 2;
}
- strcpy (mItemListPos->mInfo, Info);
+ strcpy (mItemListPos->mId, Id);
}
break;
@@ -352,29 +360,29 @@ CVfrBufferConfig::Write ( #if 0
UINT8
CVfrBufferConfig::ReadId (
- OUT INT8 **Id,
- OUT INT8 **Info
+ OUT INT8 **Name,
+ OUT INT8 **Id
)
{
if (mInfoStrItemListPos == NULL) {
return 1; // end read or some error occur
}
+ if (Name != NULL) {
+ *Name = new INT8 (strlen (mInfoStrItemListPos->mName + 1));
+ strcpy (*Name, mInfoStrItemListPos->mName);
+ }
if (Id != NULL) {
*Id = new INT8 (strlen (mInfoStrItemListPos->mId + 1));
strcpy (*Id, mInfoStrItemListPos->mId);
}
- if (Info != NULL) {
- *Info = new INT8 (strlen (mInfoStrItemListPos->mInfo + 1));
- strcpy (*Info, mInfoStrItemListPos->mInfo);
- }
return 0;
}
UINT8
CVfrBufferConfig::ReadInfo (
- IN INT8 *Id,
+ IN INT8 *Name,
IN UINT32 Index,
IN OUT UINT32 &Number,
OUT INT8 *Offset,
@@ -387,8 +395,8 @@ CVfrBufferConfig::ReadInfo ( UINT32 idx;
UINT32 num;
- if (Id != NULL) {
- if ((ret = Select (Id)) != 0) {
+ if (Name != NULL) {
+ if ((ret = Select (Name)) != 0) {
return ret;
}
}
@@ -473,8 +481,28 @@ CVfrBufferConfig::OutputCFile ( }
for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
- if (Item->mInfoStrList != NULL) {
- fprintf (pFile, "\nunsigned char %s%sDefault%04x[] = {", BaseName, Item->mId, Item->mInfo);
+ if (Item->mId != NULL || Item->mInfoStrList == NULL) {
+ continue;
+ }
+ fprintf (pFile, "\nunsigned char %s%sBlockName[] = {", BaseName, Item->mName);
+
+ TotalLen = sizeof (UINT32);
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ TotalLen += sizeof (UINT16) * 2;
+ }
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
+
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
+ }
+ fprintf (pFile, "\n};\n");
+ }
+
+ for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
+ if (Item->mId != NULL && Item->mInfoStrList != NULL) {
+ fprintf (pFile, "\nunsigned char %s%sDefault%s[] = {", BaseName, Item->mName, Item->mId);
TotalLen = sizeof (UINT32);
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
@@ -483,6 +511,7 @@ CVfrBufferConfig::OutputCFile ( Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
if (Info->mNext == NULL) {
@@ -490,9 +519,8 @@ CVfrBufferConfig::OutputCFile ( } else {
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)Info->mValue, Info->mWidth);
}
- fprintf (pFile, "\n");
}
- fprintf (pFile, "};\n");
+ fprintf (pFile, "\n};\n");
}
}
}
@@ -536,7 +564,7 @@ static struct { {"UINT16", EFI_IFR_TYPE_NUM_SIZE_16, sizeof (UINT16), sizeof (UINT16)},
{"UINT8", EFI_IFR_TYPE_NUM_SIZE_8, sizeof (UINT8), sizeof (UINT8)},
{"BOOLEAN", EFI_IFR_TYPE_BOOLEAN, sizeof (BOOLEAN), sizeof (BOOLEAN)},
- {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT8)},
+ {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT16)},
{"EFI_STRING_ID", EFI_IFR_TYPE_STRING, sizeof (EFI_STRING_ID),sizeof (EFI_STRING_ID)},
{"EFI_HII_TIME", EFI_IFR_TYPE_TIME, sizeof (EFI_HII_TIME), sizeof (UINT8)},
{NULL, EFI_IFR_TYPE_OTHER, 0, 0}
@@ -610,7 +638,7 @@ _STR2U32 ( }
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -627,7 +655,7 @@ CVfrVarDataTypeDB::RegisterNewType ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractStructTypeName (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
OUT INT8 *TName
)
{
@@ -650,7 +678,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
IN INT8 *FName,
OUT UINT32 &ArrayIdx
)
@@ -658,15 +686,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary ( UINT32 Idx;
INT8 ArrayStr[MAX_NAME_LEN + 1];
- ArrayIdx = INVALID_ARRAY_INDEX;
+ ArrayIdx = INVALID_ARRAY_INDEX;
if (FName == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
while((*VarStr != '\0') &&
- (*VarStr != '.') &&
- (*VarStr != '[') &&
+ (*VarStr != '.') &&
+ (*VarStr != '[') &&
(*VarStr != ']')) {
*FName = *VarStr;
VarStr++;
@@ -703,8 +731,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetTypeField (
- IN INT8 *FName,
- IN SVfrDataType *Type,
+ IN INT8 *FName,
+ IN SVfrDataType *Type,
OUT SVfrDataField *&Field
)
{
@@ -726,7 +754,7 @@ CVfrVarDataTypeDB::GetTypeField ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetFieldOffset (
- IN SVfrDataField *Field,
+ IN SVfrDataField *Field,
IN UINT32 ArrayIdx,
OUT UINT32 &Offset
)
@@ -834,7 +862,7 @@ CVfrVarDataTypeDB::InternalTypesListInit ( pSecondsField->mNext = NULL;
pSecondsField->mArrayNum = 0;
- New->mMembers = pHoursField;
+ New->mMembers = pHoursField;
} else {
New->mMembers = NULL;
}
@@ -853,6 +881,7 @@ CVfrVarDataTypeDB::CVfrVarDataTypeDB ( mNewDataType = NULL;
mCurrDataField = NULL;
mPackAlign = DEFAULT_PACK_ALIGN;
+ mPackStack = NULL;
InternalTypesListInit ();
}
@@ -861,8 +890,9 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB ( VOID
)
{
- SVfrDataType *pType;
- SVfrDataField *pField;
+ SVfrDataType *pType;
+ SVfrDataField *pField;
+ SVfrPackStackNode *pPack;
if (mNewDataType != NULL) {
delete mNewDataType;
@@ -879,30 +909,64 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB ( delete pType;
}
+ while (mPackStack != NULL) {
+ pPack = mPackStack;
+ mPackStack = mPackStack->mNext;
+ delete pPack;
+ }
}
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::Pack (
- IN UINT32 Align
+ IN UINT32 LineNum,
+ IN UINT8 Action,
+ IN INT8 *Identifier,
+ IN UINT32 Number
)
{
- if (Align == 0) {
- return VFR_RETURN_INVALID_PARAMETER;
- } else if (Align > 1) {
- mPackAlign = Align + Align % 2;
- } else {
- mPackAlign = Align;
+ UINT32 PackAlign;
+ INT8 Msg[64] = {0, };
+
+ if (Action & VFR_PACK_SHOW) {
+ sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);
}
- return VFR_RETURN_SUCCESS;
-}
+ if (Action & VFR_PACK_PUSH) {
+ SVfrPackStackNode *pNew = NULL;
-VOID
-CVfrVarDataTypeDB::UnPack (
- VOID
- )
-{
- mPackAlign = DEFAULT_PACK_ALIGN;
+ if ((pNew = new SVfrPackStackNode (Identifier, mPackAlign)) == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+ pNew->mNext = mPackStack;
+ mPackStack = pNew;
+ }
+
+ if (Action & VFR_PACK_POP) {
+ SVfrPackStackNode *pNode = NULL;
+
+ if (mPackStack == NULL) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes");
+ }
+
+ for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->Match (Identifier) == TRUE) {
+ mPackAlign = pNode->mNumber;
+ mPackStack = pNode->mNext;
+ }
+ }
+ }
+
+ if (Action & VFR_PACK_ASSIGN) {
+ PackAlign = (Number > 1) ? Number + Number % 2 : Number;
+ if ((PackAlign == 0) || (PackAlign > 16)) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
+ } else {
+ mPackAlign = PackAlign;
+ }
+ }
+
+ return VFR_RETURN_SUCCESS;
}
VOID
@@ -952,8 +1016,8 @@ CVfrVarDataTypeDB::SetNewTypeName ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::DataTypeAddField (
- IN INT8 *FieldName,
- IN INT8 *TypeName,
+ IN INT8 *FieldName,
+ IN INT8 *TypeName,
IN UINT32 ArrayNum
)
{
@@ -991,7 +1055,7 @@ CVfrVarDataTypeDB::DataTypeAddField ( mNewDataType->mMembers = pNewField;
pNewField->mNext = NULL;
} else {
- for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
+ for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
;
pTmp->mNext = pNewField;
pNewField->mNext = NULL;
@@ -1051,6 +1115,38 @@ CVfrVarDataTypeDB::GetDataType ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataTypeSize (
+ IN UINT8 DataType,
+ OUT UINT32 *Size
+ )
+{
+ SVfrDataType *pDataType = NULL;
+
+ if (Size == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+
+ *Size = 0;
+ DataType = DataType & 0x0F;
+
+ //
+ // For user defined data type, the size can't be got by this function.
+ //
+ if (DataType == EFI_IFR_TYPE_OTHER) {
+ return VFR_RETURN_SUCCESS;
+ }
+
+ for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) {
+ if (DataType == pDataType->mType) {
+ *Size = pDataType->mTotalSize;
+ return VFR_RETURN_SUCCESS;
+ }
+ }
+
+ return VFR_RETURN_UNDEFINED;
+}
+
+EFI_VFR_RETURN_CODE
+CVfrVarDataTypeDB::GetDataTypeSize (
IN INT8 *TypeName,
OUT UINT32 *Size
)
@@ -1075,9 +1171,9 @@ CVfrVarDataTypeDB::GetDataTypeSize ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataFieldInfo (
- IN INT8 *VarStr,
- OUT UINT16 &Offset,
- OUT UINT8 &Type,
+ IN INT8 *VarStr,
+ OUT UINT16 &Offset,
+ OUT UINT8 &Type,
OUT UINT32 &Size
)
{
@@ -1113,7 +1209,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo ( EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetUserDefinedTypeNameList (
- OUT INT8 ***NameList,
+ OUT INT8 ***NameList,
OUT UINT32 *ListSize
)
{
@@ -1444,10 +1540,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd ( return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareEfiVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN EFI_STRING_ID NameStrId,
IN UINT32 VarSize
)
@@ -1480,10 +1576,10 @@ CVfrDataStorage::DeclareEfiVarStore ( return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareBufferVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN CVfrVarDataTypeDB *DataTypeDB,
IN INT8 *TypeName,
IN EFI_VARSTORE_ID VarStoreId
@@ -1521,7 +1617,7 @@ CVfrDataStorage::DeclareBufferVarStore ( return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreId (
IN INT8 *StoreName,
OUT EFI_VARSTORE_ID *VarStoreId
@@ -1625,9 +1721,47 @@ CVfrDataStorage::GetVarStoreType ( return VFR_RETURN_UNDEFINED;
}
+EFI_VFR_VARSTORE_TYPE
+CVfrDataStorage::GetVarStoreType (
+ IN EFI_VARSTORE_ID VarStoreId
+ )
+{
+ SVfrVarStorageNode *pNode;
+ EFI_VFR_VARSTORE_TYPE VarStoreType;
+
+ VarStoreType = EFI_VFR_VARSTORE_INVALID;
+
+ if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
+ return VarStoreType;
+ }
+
+ for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ return VarStoreType;
+}
+
EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreName (
- IN EFI_VARSTORE_ID VarStoreId,
+ IN EFI_VARSTORE_ID VarStoreId,
OUT INT8 **VarStoreName
)
{
@@ -1725,7 +1859,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd ( INT8 NewReqElt[128] = {'\0',};
INT8 *OldReqElt = NULL;
SVfrVarStorageNode *pNode = NULL;
- EFI_IFR_TYPE_VALUE Value;
+ EFI_IFR_TYPE_VALUE Value = {0};
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {
@@ -1749,8 +1883,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd ( SVfrDefaultStoreNode::SVfrDefaultStoreNode (
IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,
- IN INT8 *RefName,
- IN EFI_STRING_ID DefaultStoreNameId,
+ IN INT8 *RefName,
+ IN EFI_STRING_ID DefaultStoreNameId,
IN UINT16 DefaultId
)
{
@@ -1828,7 +1962,7 @@ CVfrDefaultStore::RegisterDefaultStore ( }
/*
- * assign new reference name or new default store name id only if
+ * assign new reference name or new default store name id only if
* the original is invalid
*/
EFI_VFR_RETURN_CODE
@@ -1911,8 +2045,8 @@ CVfrDefaultStore::GetDefaultId ( STATIC
EFI_VFR_RETURN_CODE
AltCfgItemPrintToBuffer (
- IN INT8 *NewAltCfg,
- IN EFI_VARSTORE_INFO Info,
+ IN INT8 *NewAltCfg,
+ IN EFI_VARSTORE_INFO Info,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE Value
)
@@ -1923,9 +2057,9 @@ AltCfgItemPrintToBuffer ( if (NewAltCfg != NULL) {
Count = sprintf (
- NewAltCfg,
- "&OFFSET=%x&WIDTH=%x&VALUE=",
- Info.mInfo.mVarOffset,
+ NewAltCfg,
+ "&OFFSET=%x&WIDTH=%x&VALUE=",
+ Info.mInfo.mVarOffset,
Info.mVarTotalSize
);
NewAltCfg += Count;
@@ -1984,7 +2118,7 @@ AltCfgItemPrintToBuffer ( }
}
- return VFR_RETURN_FATAL_ERROR;
+ return VFR_RETURN_FATAL_ERROR;
}
EFI_VFR_RETURN_CODE
@@ -1998,6 +2132,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd ( {
SVfrDefaultStoreNode *pNode = NULL;
INT8 NewAltCfg[2 * 2 * sizeof (UINT16) + 1] = {0,};
+ INTN Returnvalue = 0;
if (VarStoreName == NULL) {
return VFR_RETURN_FATAL_ERROR;
@@ -2016,28 +2151,23 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd ( gCVfrBufferConfig.Open ();
sprintf (NewAltCfg, "%04x", pNode->mDefaultId);
- if ((gCVfrBufferConfig.Select(VarStoreName) == 0) &&
- (gCVfrBufferConfig.Select(VarStoreName, NewAltCfg) != 0)) {
- if (gCVfrBufferConfig.Write ('i', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Select(VarStoreName)) == 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Write ('a', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value)) != 0) {
goto WriteError;
}
}
- if (gCVfrBufferConfig.Write ('a', VarStoreName, NULL, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
- goto WriteError;
- }
-
gCVfrBufferConfig.Close ();
return VFR_RETURN_SUCCESS;
WriteError:
gCVfrBufferConfig.Close ();
- return VFR_RETURN_FATAL_ERROR;
+ return (EFI_VFR_RETURN_CODE)Returnvalue;
}
SVfrRuleNode::SVfrRuleNode (
- IN INT8 *RuleName,
+ IN INT8 *RuleName,
IN UINT8 RuleId
)
{
@@ -2143,7 +2273,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO ( mVarTotalSize = Info.mVarTotalSize;
}
-BOOLEAN
+BOOLEAN
EFI_VARSTORE_INFO::operator == (
IN EFI_VARSTORE_INFO *Info
)
@@ -2195,7 +2325,7 @@ CVfrQuestionDB::ChekQuestionIdFree ( return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUsed (
IN EFI_QUESTION_ID QId
)
@@ -2206,7 +2336,7 @@ CVfrQuestionDB::MarkQuestionIdUsed ( mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUnused (
IN EFI_QUESTION_ID QId
)
@@ -2321,9 +2451,9 @@ CVfrQuestionDB::RegisterQuestion ( VOID
CVfrQuestionDB::RegisterOldDateQuestion (
- IN INT8 *YearVarId,
- IN INT8 *MonthVarId,
- IN INT8 *DayVarId,
+ IN INT8 *YearVarId,
+ IN INT8 *MonthVarId,
+ IN INT8 *DayVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2379,7 +2509,7 @@ Err: VOID
CVfrQuestionDB::RegisterNewDateQuestion (
IN INT8 *Name,
- IN INT8 *BaseVarId,
+ IN INT8 *BaseVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2463,9 +2593,9 @@ Err: VOID
CVfrQuestionDB::RegisterOldTimeQuestion (
- IN INT8 *HourVarId,
- IN INT8 *MinuteVarId,
- IN INT8 *SecondVarId,
+ IN INT8 *HourVarId,
+ IN INT8 *MinuteVarId,
+ IN INT8 *SecondVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2634,7 +2764,7 @@ CVfrQuestionDB::UpdateQuestionId ( return VFR_RETURN_SUCCESS;
}
-VOID
+VOID
CVfrQuestionDB::GetQuestionId (
IN INT8 *Name,
IN INT8 *VarIdStr,
@@ -2672,7 +2802,7 @@ CVfrQuestionDB::GetQuestionId ( return ;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN EFI_QUESTION_ID QuestionId
)
@@ -2692,7 +2822,7 @@ CVfrQuestionDB::FindQuestion ( return VFR_RETURN_UNDEFINED;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN INT8 *Name
)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h index 38687b948d..fe37f83e16 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h @@ -1,5 +1,4 @@ /*++
-
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-
-VfrUtilityLib.h
+ VfrUtilityLib.h
Abstract:
@@ -28,7 +26,7 @@ Abstract: #define MAX_NAME_LEN 64
#define DEFAULT_ALIGN 1
-#define DEFAULT_PACK_ALIGN 0xFFFFFFFF
+#define DEFAULT_PACK_ALIGN 0x8
#define DEFAULT_NAME_TABLE_ITEMS 1024
#define EFI_BITS_SHIFT_PER_UINT32 0x5
@@ -58,9 +56,9 @@ struct SConfigInfo { };
struct SConfigItem {
- INT8 *mId;
- INT8 *mInfo;
- SConfigInfo *mInfoStrList;
+ INT8 *mName; // varstore name
+ INT8 *mId; // varstore ID
+ SConfigInfo *mInfoStrList; // list of Offset/Value in the varstore
SConfigItem *mNext;
public:
@@ -115,10 +113,59 @@ struct SVfrDataType { SVfrDataType *mNext;
};
+#define VFR_PACK_ASSIGN 0x01
+#define VFR_PACK_SHOW 0x02
+#define VFR_PACK_PUSH 0x04
+#define VFR_PACK_POP 0x08
+
+#define PACKSTACK_MAX_SIZE 0x400
+
+struct SVfrPackStackNode {
+ INT8 *mIdentifier;
+ UINT32 mNumber;
+ SVfrPackStackNode *mNext;
+
+ SVfrPackStackNode (IN INT8 *Identifier, IN UINT32 Number) {
+ mIdentifier = NULL;
+ mNumber = Number;
+ mNext = NULL;
+
+ if (Identifier != NULL) {
+ mIdentifier = new INT8[strlen (Identifier) + 1];
+ strcpy (mIdentifier, Identifier);
+ }
+ }
+
+ ~SVfrPackStackNode (VOID) {
+ if (mIdentifier != NULL) {
+ delete mIdentifier;
+ }
+ mNext = NULL;
+ }
+
+ bool Match (IN INT8 *Identifier) {
+ if (Identifier == NULL) {
+ return TRUE;
+ } else if (mIdentifier == NULL) {
+ return FALSE;
+ } else if (strcmp (Identifier, mIdentifier) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+};
+
class CVfrVarDataTypeDB {
private:
- SVfrDataType *mDataTypeList;
UINT32 mPackAlign;
+ SVfrPackStackNode *mPackStack;
+
+public:
+ EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN INT8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);
+
+private:
+ SVfrDataType *mDataTypeList;
SVfrDataType *mNewDataType;
SVfrDataType *mCurrDataType;
@@ -138,9 +185,6 @@ public: CVfrVarDataTypeDB (VOID);
~CVfrVarDataTypeDB (VOID);
- EFI_VFR_RETURN_CODE Pack (IN UINT32);
- VOID UnPack (VOID);
-
VOID DeclareDataTypeBegin (VOID);
EFI_VFR_RETURN_CODE SetNewTypeName (IN INT8 *);
EFI_VFR_RETURN_CODE DataTypeAddField (IN INT8 *, IN INT8 *, IN UINT32);
@@ -148,6 +192,7 @@ public: EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **);
EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *);
+ EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *);
@@ -245,6 +290,7 @@ public: EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *);
EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &);
+ EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **);
EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **);
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile index e4424fcc3f..b266cfe03c 100644 --- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile +++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile @@ -1,6 +1,6 @@ #/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -55,7 +55,8 @@ INC = -I $(SRC) \ ANTLR_FLAGS = -CC -e3 -ck 3 -k 2
DLG_FLAGS = -C2 -i -CC
LINK_FLAGS_PCCTS = /DEBUG /PDB:$*.pdb
-C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
+C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) \
+ $(BUILD_STRING_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
VFR_GRAMMER_FILE = $(SRC)\VfrSyntax.g
|