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
This commit is contained in:
lgao4
2010-11-26 01:54:49 +00:00
parent 68bb5ce77e
commit 3e99020dbf
183 changed files with 15250 additions and 2636 deletions

View File

@@ -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_

View File

@@ -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
)
{

View File

@@ -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;

View File

@@ -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_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_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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);
}
}
};

View File

@@ -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,54 +124,54 @@ 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 (Name != NULL) {
if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
strcpy (mName, Name);
}
}
if (Id != NULL) {
if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
strcpy (mId, Id);
}
}
if (Info != NULL) {
if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
strcpy (mInfo, Info);
}
}
}
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 (Name != NULL) {
if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
strcpy (mName, Name);
}
}
if (Id != NULL) {
if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
strcpy (mId, Id);
}
}
if (Info != NULL) {
if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
strcpy (mInfo, Info);
}
}
mInfoStrList = new SConfigInfo(Type, Offset, Width, Value);
}
@@ -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->mId != NULL) {
delete mItemListPos->mId;
}
if (mItemListPos->mInfo != NULL) {
delete mItemListPos->mInfo;
}
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,32 +909,66 @@ 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);
}
if (Action & VFR_PACK_PUSH) {
SVfrPackStackNode *pNew = NULL;
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
CVfrVarDataTypeDB::UnPack (
VOID
)
{
mPackAlign = DEFAULT_PACK_ALIGN;
}
VOID
CVfrVarDataTypeDB::DeclareDataTypeBegin (
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;
@@ -1049,6 +1113,38 @@ CVfrVarDataTypeDB::GetDataType (
return VFR_RETURN_UNDEFINED;
}
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,
@@ -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
)

View File

@@ -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 **);

View File

@@ -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