summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C/VfrCompile
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-26 07:46:26 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-26 07:46:26 +0000
commit4234283c3acb8c35014acc1546621fbc2621b095 (patch)
tree208a4f87b2820ec1f3a414508ca1c215c5deed18 /BaseTools/Source/C/VfrCompile
parentba944801a988dddf3ed217c72c8d880d0f03d150 (diff)
downloadedk2-platforms-4234283c3acb8c35014acc1546621fbc2621b095.tar.xz
Sync BaseTools Branch (version r2271) to EDKII main trunk.
BaseTool Branch: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/branches/Releases/BaseTools_r2100 Signed-off-by: lgao4 Reviewed-by: hchen30 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12214 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C/VfrCompile')
-rw-r--r--BaseTools/Source/C/VfrCompile/EfiVfr.h4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrCompiler.cpp40
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrCompiler.h7
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h94
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g275
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp538
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.h32
8 files changed, 932 insertions, 62 deletions
diff --git a/BaseTools/Source/C/VfrCompile/EfiVfr.h b/BaseTools/Source/C/VfrCompile/EfiVfr.h
index 406a12491d..aad9417156 100644
--- a/BaseTools/Source/C/VfrCompile/EfiVfr.h
+++ b/BaseTools/Source/C/VfrCompile/EfiVfr.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -23,7 +23,6 @@ Abstract:
#define _EFIVFR_H_
#include "Common/UefiBaseTypes.h"
-#include "Protocol/DevicePath.h"
#include "Common/UefiInternalFormRepresentation.h"
#include "Common/MdeModuleHii.h"
@@ -43,6 +42,7 @@ typedef enum {
QUESTION_NORMAL,
QUESTION_DATE,
QUESTION_TIME,
+ QUESTION_REF,
} EFI_QUESION_TYPE;
typedef enum {
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 5985a7ad5d..926561760a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
PACKAGE_DATA gCBuffer;
PACKAGE_DATA gRBuffer;
+CVfrStringDB gCVfrStringDB;
VOID
CVfrCompiler::DebugError (
@@ -62,7 +63,9 @@ CVfrCompiler::OptionInitialization (
)
{
INT32 Index;
-
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
SetUtilityName ((CHAR8*) PROGRAM_NAME);
mOptions.VfrFileName[0] = '\0';
@@ -78,6 +81,8 @@ CVfrCompiler::OptionInitialization (
mOptions.SkipCPreprocessor = TRUE;
mOptions.CPreprocessorOptions = NULL;
mOptions.CompatibleMode = FALSE;
+ mOptions.HasOverrideClassGuid = FALSE;
+ memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID));
if (Argc == 1) {
Usage ();
@@ -132,6 +137,22 @@ CVfrCompiler::OptionInitialization (
AppendCPreprocessorOptions (Argv[Index]);
} else if (stricmp(Argv[Index], "-c") == 0 || stricmp(Argv[Index], "--compatible-framework") == 0) {
mOptions.CompatibleMode = TRUE;
+ } else if (stricmp(Argv[Index], "-s") == 0|| stricmp(Argv[Index], "--string-db") == 0) {
+ Index++;
+ if ((Index >= Argc) || (Argv[Index][0] == '-')) {
+ DebugError (NULL, 0, 1001, "Missing option", "-s missing input string file name");
+ goto Fail;
+ }
+ gCVfrStringDB.SetStringFileName(Argv[Index]);
+ DebugMsg (NULL, 0, 9, (CHAR8 *) "Input string file path", Argv[Index]);
+ } else if ((stricmp (Argv[Index], "-g") == 0) || (stricmp (Argv[Index], "--guid") == 0)) {
+ Index++;
+ Status = StringToGuid (Argv[Index], &mOptions.OverrideClassGuid);
+ if (EFI_ERROR (Status)) {
+ DebugError (NULL, 0, 1000, "Invalid format:", "%s", Argv[Index]);
+ goto Fail;
+ }
+ mOptions.HasOverrideClassGuid = TRUE;
} else {
DebugError (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
goto Fail;
@@ -399,6 +420,11 @@ CVfrCompiler::Usage (
" do not preprocessing input file",
" -c, --compatible-framework",
" compatible framework vfr file",
+ " -s, --string-db",
+ " input uni string package file",
+ " -g, --guid",
+ " override class guid input",
+ " format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
NULL
};
for (Index = 0; Help[Index] != NULL; Index++) {
@@ -472,7 +498,7 @@ Fail:
delete PreProcessCmd;
}
-extern UINT8 VfrParserStart (IN FILE *, IN BOOLEAN);
+extern UINT8 VfrParserStart (IN FILE *, IN INPUT_INFO_TO_SYNTAX *);
VOID
CVfrCompiler::Compile (
@@ -481,6 +507,7 @@ CVfrCompiler::Compile (
{
FILE *pInFile = NULL;
CHAR8 *InFileName = NULL;
+ INPUT_INFO_TO_SYNTAX InputInfo;
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
@@ -495,7 +522,14 @@ CVfrCompiler::Compile (
goto Fail;
}
- if (VfrParserStart (pInFile, mOptions.CompatibleMode) != 0) {
+ InputInfo.CompatibleMode = mOptions.CompatibleMode;
+ if (mOptions.HasOverrideClassGuid) {
+ InputInfo.OverrideClassGuid = &mOptions.OverrideClassGuid;
+ } else {
+ InputInfo.OverrideClassGuid = NULL;
+ }
+
+ if (VfrParserStart (pInFile, &InputInfo) != 0) {
goto Fail;
}
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source/C/VfrCompile/VfrCompiler.h
index 7525bb5603..1c83e87f5f 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h
@@ -20,10 +20,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "EfiVfr.h"
#include "VfrFormPkg.h"
#include "VfrUtilityLib.h"
+#include "ParseInf.h"
#define PROGRAM_NAME "VfrCompile"
-#define VFR_COMPILER_VERSION " 1.95 (UEFI 2.1)"
-#define VFR_COMPILER_UPDATE_TIME " updated on 2011/02/25"
+#define VFR_COMPILER_VERSION " 2.00 (UEFI 2.3.1)"
+#define VFR_COMPILER_UPDATE_TIME " updated on 2011/07/15"
//
// This is how we invoke the C preprocessor on the VFR source file
// to resolve #defines, #includes, etc. To make C source files
@@ -54,6 +55,8 @@ typedef struct {
bool SkipCPreprocessor;
CHAR8 *CPreprocessorOptions;
BOOLEAN CompatibleMode;
+ BOOLEAN HasOverrideClassGuid;
+ EFI_GUID OverrideClassGuid;
} OPTIONS;
typedef enum {
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 571af91b0a..6401e71f4d 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -1305,6 +1305,8 @@ static struct {
{ sizeof (EFI_IFR_CATENATE), 0 }, // EFI_IFR_CATENATE_OP
{ sizeof (EFI_IFR_GUID), 0 }, // EFI_IFR_GUID_OP
{ sizeof (EFI_IFR_SECURITY), 0 }, // EFI_IFR_SECURITY_OP - 0x60
+ { sizeof (EFI_IFR_MODAL), 0}, // EFI_IFR_MODAL_OP - 0x61
+ { sizeof (EFI_IFR_REFRESH_ID), 0}, // EFI_IFR_REFRESH_ID_OP - 0x62
};
#ifdef CIFROBJ_DEUBG
@@ -1327,7 +1329,7 @@ static struct {
"EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2", "EFI_IFR_CONDITIONAL", "EFI_IFR_QUESTION_REF3", "EFI_IFR_ZERO", "EFI_IFR_ONE",
"EFI_IFR_ONES", "EFI_IFR_UNDEFINED", "EFI_IFR_LENGTH", "EFI_IFR_DUP", "EFI_IFR_THIS", "EFI_IFR_SPAN",
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_FORM_MAP", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
- "EFI_IFR_SECURITY",
+ "EFI_IFR_SECURITY", "EFI_IFR_MODAL", "EFI_IFR_REFRESH_ID",
};
VOID
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 4cdd1cc5db..f908718c02 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -96,6 +96,11 @@ struct SBufferNode {
struct SBufferNode *mNext;
};
+typedef struct {
+ BOOLEAN CompatibleMode;
+ EFI_GUID *OverrideClassGuid;
+} INPUT_INFO_TO_SYNTAX;
+
class CFormPkg {
private:
UINT32 mBufferSize;
@@ -144,7 +149,8 @@ public:
);
};
-extern CFormPkg gCFormPkg;
+extern CFormPkg gCFormPkg;
+extern CVfrStringDB gCVfrStringDB;
struct SIfrRecord {
UINT32 mLineNo;
@@ -233,6 +239,15 @@ public:
return FALSE;
}
}
+
+ inline bool ShrinkObjBin (IN UINT8 Size) {
+ if ((mDelayEmit == TRUE) && (mObjBinLen > Size)) {
+ mObjBinLen -= Size;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
};
/*
@@ -254,7 +269,7 @@ public:
VOID DecLength (UINT8 Size) {
if (mHeader->Length >= Size) {
- mHeader -= Size;
+ mHeader->Length -= Size;
}
}
@@ -755,10 +770,12 @@ private:
EFI_IFR_VARSTORE_EFI *mVarStoreEfi;
public:
- CIfrVarStoreEfi () : CIfrObj (EFI_IFR_VARSTORE_EFI_OP, (CHAR8 **)&mVarStoreEfi),
+ CIfrVarStoreEfi () : CIfrObj (EFI_IFR_VARSTORE_EFI_OP, (CHAR8 **)&mVarStoreEfi, sizeof (EFI_IFR_VARSTORE_EFI), TRUE),
CIfrOpHeader (EFI_IFR_VARSTORE_EFI_OP, &mVarStoreEfi->Header) {
mVarStoreEfi->VarStoreId = EFI_VAROFFSET_INVALID;
+ mVarStoreEfi->Size = 0;
memset (&mVarStoreEfi->Guid, 0, sizeof (EFI_GUID));
+ mVarStoreEfi->Name[0] = '\0';
}
VOID SetGuid (IN EFI_GUID *Guid) {
@@ -772,6 +789,36 @@ public:
VOID SetAttributes (IN UINT32 Attributes) {
mVarStoreEfi->Attributes = Attributes;
}
+ VOID SetSize (IN UINT16 Size) {
+ mVarStoreEfi->Size = Size;
+ }
+
+ VOID SetName (IN CHAR8 *Name) {
+ UINT8 Len;
+
+ if (Name != NULL) {
+ Len = (UINT8) strlen (Name);
+ if (Len != 0) {
+ if (ExpendObjBin (Len) == TRUE) {
+ IncLength (Len);
+ strcpy ((CHAR8 *)(mVarStoreEfi->Name), Name);
+ }
+ }
+ }
+ }
+
+ VOID SetBinaryLength (IN UINT16 Size) {
+ UINT16 Len;
+
+ Len = sizeof (EFI_IFR_VARSTORE_EFI);
+ if (Size > Len) {
+ ExpendObjBin(Size - Len);
+ IncLength(Size - Len);
+ } else {
+ ShrinkObjBin(Len - Size);
+ DecLength(Len - Size);
+ }
+ }
};
class CIfrVarStoreNameValue : public CIfrObj, public CIfrOpHeader {
@@ -809,6 +856,17 @@ public:
}
};
+class CIfrModal : public CIfrObj, public CIfrOpHeader {
+private:
+ EFI_IFR_MODAL *mModal;
+
+public:
+ CIfrModal () : CIfrObj (EFI_IFR_MODAL_TAG_OP, (CHAR8 **)&mModal),
+ CIfrOpHeader (EFI_IFR_MODAL_TAG_OP, &mModal->Header) {
+ }
+};
+
+
class CIfrLocked : public CIfrObj, public CIfrOpHeader {
private:
EFI_IFR_LOCKED *mLocked;
@@ -1043,8 +1101,8 @@ private:
EFI_IFR_REF4 *mRef4;
public:
- CIfrRef4 () : CIfrObj (EFI_IFR_REF_OP, (CHAR8 **)&mRef4, sizeof(EFI_IFR_REF3)),
- CIfrOpHeader (EFI_IFR_REF_OP, &mRef4->Header, sizeof (EFI_IFR_REF3)),
+ CIfrRef4 () : CIfrObj (EFI_IFR_REF_OP, (CHAR8 **)&mRef4, sizeof(EFI_IFR_REF4)),
+ CIfrOpHeader (EFI_IFR_REF_OP, &mRef4->Header, sizeof(EFI_IFR_REF4)),
CIfrQuestionHeader (&mRef4->Question) {
mRef4->FormId = 0;
mRef4->QuestionId = EFI_QUESTION_ID_INVALID;
@@ -1069,6 +1127,17 @@ public:
}
};
+class CIfrRef5 : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {
+private:
+ EFI_IFR_REF5 *mRef5;
+
+public:
+ CIfrRef5 () : CIfrObj (EFI_IFR_REF_OP, (CHAR8 **)&mRef5, sizeof (EFI_IFR_REF5)),
+ CIfrOpHeader (EFI_IFR_REF_OP, &mRef5->Header, sizeof (EFI_IFR_REF5)),
+ CIfrQuestionHeader (&mRef5->Question) {
+ }
+};
+
class CIfrResetButton : public CIfrObj, public CIfrOpHeader, public CIfrStatementHeader {
private:
EFI_IFR_RESET_BUTTON *mResetButton;
@@ -1481,6 +1550,21 @@ public:
}
};
+class CIfrRefreshId : public CIfrObj, public CIfrOpHeader {
+private:
+ EFI_IFR_REFRESH_ID *mRefreshId;
+
+public:
+ CIfrRefreshId () : CIfrObj (EFI_IFR_REFRESH_ID_OP, (CHAR8 **)&mRefreshId),
+ CIfrOpHeader (EFI_IFR_REFRESH_ID_OP, &mRefreshId->Header) {
+ memset (&mRefreshId->RefreshEventGroupId, 0, sizeof (EFI_GUID));
+ }
+
+ VOID SetRefreshEventGroutId (IN EFI_GUID *RefreshEventGroupId) {
+ memcpy (&mRefreshId->RefreshEventGroupId, RefreshEventGroupId, sizeof (EFI_GUID));
+ }
+};
+
class CIfrVarStoreDevice : public CIfrObj, public CIfrOpHeader {
private:
EFI_IFR_VARSTORE_DEVICE *mVarStoreDevice;
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 02a7b5c1f4..081c67d715 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -51,11 +51,12 @@ public:
UINT8
VfrParserStart (
IN FILE *File,
- IN BOOLEAN CompatibleMode
+ IN INPUT_INFO_TO_SYNTAX *InputInfo
)
{
ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File);
- VfrParser.parser()->SetCompatibleMode (CompatibleMode);
+ VfrParser.parser()->SetCompatibleMode (InputInfo->CompatibleMode);
+ VfrParser.parser()->SetOverrideClassGuid (InputInfo->OverrideClassGuid);
return VfrParser.parser()->vfrProgram();
}
>>
@@ -237,6 +238,7 @@ VfrParserStart (
#token EndGuidOp("endguidop") "endguidop"
#token DataType("datatype") "datatype"
#token Data("data") "data"
+#token Modal("modal") "modal"
//
// Define the class and subclass tokens
@@ -340,6 +342,7 @@ vfrDataStructFields :
dataStructFieldString |
dataStructFieldDate |
dataStructFieldTime |
+ dataStructFieldRef |
dataStructFieldUser
)*
;
@@ -426,6 +429,16 @@ dataStructFieldTime :
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
;
+dataStructFieldRef :
+ << UINT32 ArrayNum = 0; >>
+ D:"EFI_HII_REF"
+ N:StringIdentifier
+ {
+ OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
+ }
+ ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
+ ;
+
dataStructFieldUser :
<< UINT32 ArrayNum = 0; >>
T:StringIdentifier
@@ -497,19 +510,42 @@ vfrFormSetDefinition :
","
}
<<
+ if (mOverrideClassGuid != NULL && ClassGuidNum >= 3) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Already has 3 class guids, can't add extra class guid!");
+ }
switch (ClassGuidNum) {
case 0:
- FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));
+ if (mOverrideClassGuid != NULL) {
+ ClassGuidNum = 2;
+ } else {
+ ClassGuidNum = 1;
+ }
+ FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
FSObj->SetClassGuid(&DefaultClassGuid);
+ if (mOverrideClassGuid != NULL) {
+ FSObj->SetClassGuid(mOverrideClassGuid);
+ }
break;
case 1:
+ if (mOverrideClassGuid != NULL) {
+ ClassGuidNum ++;
+ }
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
FSObj->SetClassGuid(&ClassGuid1);
+ if (mOverrideClassGuid != NULL) {
+ FSObj->SetClassGuid(mOverrideClassGuid);
+ }
break;
case 2:
+ if (mOverrideClassGuid != NULL) {
+ ClassGuidNum ++;
+ }
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
FSObj->SetClassGuid(&ClassGuid1);
FSObj->SetClassGuid(&ClassGuid2);
+ if (mOverrideClassGuid != NULL) {
+ FSObj->SetClassGuid(mOverrideClassGuid);
+ }
break;
case 3:
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
@@ -602,7 +638,9 @@ vfrStatementExtension:
<< TypeName = D->getText(); LineNum = D->getLine(); IsStruct = TRUE;>>
| T:"EFI_HII_TIME" {OpenBracket AN8:Number CloseBracket <<ArrayNum = _STOU32(AN8->getText());>>}
<< TypeName = T->getText(); LineNum = T->getLine(); IsStruct = TRUE;>>
- | TN:StringIdentifier {OpenBracket AN9:Number CloseBracket <<ArrayNum = _STOU32(AN9->getText());>>}
+ | R:"EFI_HII_REF" {OpenBracket AN9:Number CloseBracket <<ArrayNum = _STOU32(AN9->getText());>>}
+ << TypeName = R->getText(); LineNum = R->getLine(); IsStruct = TRUE;>>
+ | TN:StringIdentifier {OpenBracket AN10:Number CloseBracket <<ArrayNum = _STOU32(AN10->getText());>>}
<< TypeName = TN->getText(); LineNum = TN->getLine(); IsStruct = TRUE;>>
)
<<
@@ -794,6 +832,7 @@ vfrStatementVarStoreLinear :
| U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
| D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
| T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
+ | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
)
{ Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
if (mCompatibleMode) {
@@ -838,22 +877,102 @@ vfrStatementVarStoreLinear :
vfrStatementVarStoreEfi :
<<
+ BOOLEAN IsUEFI23EfiVarstore = TRUE;
EFI_GUID Guid;
CIfrVarStoreEfi VSEObj;
- EFI_VARSTORE_ID VarStoreId;
+ EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
UINT32 Attr = 0;
+ UINT32 Size;
+ CHAR8 *TypeName;
+ UINT32 LineNum;
+ CHAR8 *StoreName = NULL;
>>
E:Efivarstore << VSEObj.SetLineNo(E->getLine()); >>
- SN:StringIdentifier ","
+ (
+ TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
+ | U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
+ | U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
+ | C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
+ | U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
+ | U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
+ | D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
+ | T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
+ | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
+ )
+ {
+ VarId "=" ID:Number "," <<
+ _PCATCH(
+ (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
+ (INTN)TRUE,
+ ID,
+ "varid 0 is not allowed."
+ );
+ >>
+ }
Attribute "=" vfrVarStoreEfiAttr[Attr] ( "\|" vfrVarStoreEfiAttr[Attr] )* ","
<< VSEObj.SetAttributes (Attr); >>
- Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
- VarSize "=" N:Number ","
- Uuid "=" guidDefinition[Guid] << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
- <<
- VSEObj.SetGuid (&Guid);
- _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
+
+ (
+ Name "=" SN:StringIdentifier "," << StoreName = SN->getText(); >>
+ |
+ Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
+ VarSize "=" N:Number "," <<
+ IsUEFI23EfiVarstore = FALSE;
+ StoreName = gCVfrStringDB.GetVarStoreNameFormStringId(_STOSID(VN->getText()));
+ if (StoreName == NULL) {
+ _PCATCH (VFR_RETURN_UNSUPPORTED, VN->getLine(), "Can't get varstore name for this StringId!");
+ }
+ Size = _STOU32(N->getText());
+ switch (Size) {
+ case 1:
+ TypeName = (CHAR8 *) "UINT8";
+ break;
+ case 2:
+ TypeName = (CHAR8 *) "UINT16";
+ break;
+ case 4:
+ TypeName = (CHAR8 *) "UINT32";
+ break;
+ case 8:
+ TypeName = (CHAR8 *) "UINT64";
+ break;
+ default:
+ _PCATCH (VFR_RETURN_UNSUPPORTED, N);
+ break;
+ }
+ >>
+ )
+
+ Uuid "=" guidDefinition[Guid] <<
+ if (IsUEFI23EfiVarstore) {
+ _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId
+ ), LineNum);
+ _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);
+ _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
+ } else {
+ _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
+ TN->getText(),
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId
+ ), LineNum);
+ _PCATCH(mCVfrDataStorage.GetVarStoreId(TN->getText(), &VarStoreId), VN);
+ _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine());
+ }
+ VSEObj.SetGuid (&Guid);
VSEObj.SetVarStoreId (VarStoreId);
+
+ VSEObj.SetSize ((UINT16) Size);
+ VSEObj.SetName (StoreName);
+ if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
+ delete StoreName;
+ }
>>
";"
;
@@ -978,39 +1097,31 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
case QUESTION_TIME:
mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);
break;
+ case QUESTION_REF:
+ //
+ // VarIdStr != NULL stand for question with storagae.
+ //
+ if (VarIdStr != NULL) {
+ mCVfrQuestionDB.RegisterRefQuestion (QName, VarIdStr, QId);
+ } else {
+ mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
+ }
+ break;
default:
_PCATCH(VFR_RETURN_FATAL_ERROR);
}
$QHObj.SetQuestionId (QId);
- $QHObj.SetVarStoreInfo (&Info);
+ if (VarIdStr != NULL) {
+ $QHObj.SetVarStoreInfo (&Info);
+ }
>>
vfrStatementHeader[&$QHObj]
- << _SAVE_CURRQEST_VARINFO (Info); >>
- << if (VarIdStr != NULL) delete VarIdStr; >>
- ;
-
-vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
- <<
- EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
- CHAR8 *QName = NULL;
- >>
- {
- Name "=" QN:StringIdentifier "," <<
- QName = QN->getText();
- _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");
- >>
- }
- {
- QuestionId "=" ID:Number "," <<
- QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
- >>
- }
- <<
- mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
- $QHObj->SetQuestionId (QId);
+ <<
+ if (VarIdStr != NULL) {
+ delete VarIdStr;
+ _SAVE_CURRQEST_VARINFO (Info);
+ }
>>
- vfrStatementHeader[$QHObj]
;
questionheaderFlagsField[UINT8 & Flags] :
@@ -1060,6 +1171,8 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
_PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
}
+
+ QuestVarIdStr = VarIdStr;
>>
)
|
@@ -1194,6 +1307,9 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr,
;
vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
+ <<
+ EFI_GUID Guid;
+ >>
N1:Number <<
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
@@ -1216,6 +1332,7 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
break;
case EFI_IFR_TYPE_TIME :
case EFI_IFR_TYPE_DATE :
+ case EFI_IFR_TYPE_REF :
default :
break;
}
@@ -1227,6 +1344,8 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
| Z:Zero << $Value.u8 = _STOU8(Z->getText()); >>
| HOUR:Number ":" MINUTE:Number ":" SECOND:Number << $Value.time = _STOT(HOUR->getText(), MINUTE->getText(), SECOND->getText()); >>
| YEAR:Number "/" MONTH:Number "/" DAY:Number << $Value.date = _STOD(YEAR->getText(), MONTH->getText(), DAY->getText()); >>
+ | QI:Number";" FI:Number";" guidDefinition[Guid] ";" "STRING_TOKEN" "\(" DP:Number "\)"
+ << $Value.ref = _STOR(QI->getText(), FI->getText(), &Guid, DP->getText()); >>
| "STRING_TOKEN" "\(" S1:Number "\)" << $Value.string = _STOSID(S1->getText()); >>
;
@@ -1251,7 +1370,8 @@ vfrFormDefinition :
vfrStatementBanner |
// Just for framework vfr compatibility
vfrStatementInvalid |
- vfrStatementExtension
+ vfrStatementExtension |
+ vfrStatementModal
)*
E:EndForm <<
if (mCompatibleMode) {
@@ -1310,7 +1430,8 @@ vfrFormMapDefinition :
vfrStatementConditional |
vfrStatementLabel |
vfrStatementBanner |
- vfrStatementExtension
+ vfrStatementExtension |
+ vfrStatementModal
)*
E:EndForm << CRT_END_OP (E); >>
";"
@@ -1516,7 +1637,7 @@ vfrStatementCrossReference :
vfrStatementGoto :
<<
- UINT8 RefType = 1;
+ UINT8 RefType = 5;
EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
EFI_GUID FSId = {0,};
EFI_FORM_ID FId;
@@ -1527,9 +1648,10 @@ vfrStatementGoto :
CIfrRef2 *R2Obj = NULL;
CIfrRef3 *R3Obj = NULL;
CIfrRef4 *R4Obj = NULL;
+ CIfrRef5 *R5Obj = NULL;
>>
G:Goto
- (
+ {
(
DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
FormSetGuid "=" guidDefinition[FSId] ","
@@ -1569,9 +1691,16 @@ vfrStatementGoto :
FId = _STOFID(F4->getText());
>>
)
- )
+ }
<<
switch (RefType) {
+ case 5:
+ {
+ R5Obj = new CIfrRef5;
+ QHObj = R5Obj;
+ R5Obj->SetLineNo(G->getLine());
+ break;
+ }
case 4:
{
R4Obj = new CIfrRef4;
@@ -1613,13 +1742,13 @@ vfrStatementGoto :
default: break;
}
>>
- vfrQuestionHeaderWithNoStorage[QHObj]
+ vfrQuestionHeader[*QHObj, QUESTION_REF]
{ "," vfrStatementStatTagList }
{ "," F:FLAGS "=" vfrGotoFlags[QHObj, F->getLine()] }
{
"," Key "=" KN:Number << AssignQuestionKey (*QHObj, KN); >>
}
- ";" << if (R1Obj != NULL) {delete R1Obj;} if (R2Obj != NULL) {delete R2Obj;} if (R3Obj != NULL) {delete R3Obj;} if (R4Obj != NULL) {delete R4Obj;} >>
+ ";" << if (R1Obj != NULL) {delete R1Obj;} if (R2Obj != NULL) {delete R2Obj;} if (R3Obj != NULL) {delete R3Obj;} if (R4Obj != NULL) {delete R4Obj;} if (R5Obj != NULL) {delete R5Obj;}>>
;
vfrGotoFlags [CIfrQuestionHeader *QHObj, UINT32 LineNum] :
@@ -1792,7 +1921,7 @@ checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :
vfrStatementAction :
<< CIfrAction AObj; >>
L:Action << AObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeaderWithNoStorage[&AObj] ","
+ vfrQuestionHeader[AObj] ","
{ F:FLAGS "=" vfrActionFlags[AObj, F->getLine()] "," }
Config "=" "STRING_TOKEN" "\(" S:Number "\)" "," << AObj.SetQuestionConfig (_STOSID(S->getText())); >>
vfrStatementQuestionTagList
@@ -2339,7 +2468,8 @@ vfrStatementQuestionTag :
vfrStatementDisableIfQuest |
vfrStatementRefresh |
vfrStatementVarstoreDevice |
- vfrStatementExtension
+ vfrStatementExtension |
+ vfrStatementRefreshEvent
;
vfrStatementQuestionTagList :
@@ -2490,6 +2620,11 @@ vfrLockedTag :
L:Locked << LObj.SetLineNo(L->getLine()); >>
;
+vfrModalTag :
+ << CIfrModal MObj; >>
+ L:Modal << MObj.SetLineNo(L->getLine()); >>
+ ;
+
vfrStatementStatTag :
vfrImageTag |
vfrLockedTag
@@ -2504,6 +2639,11 @@ vfrStatementImage :
";"
;
+vfrStatementModal :
+ vfrModalTag
+ ";"
+ ;
+
vfrStatementLocked :
vfrLockedTag
";"
@@ -2543,6 +2683,15 @@ vfrStatementRefresh :
Interval "=" I:Number << RObj.SetRefreshInterval (_STOU8(I->getText())); >>
;
+vfrStatementRefreshEvent :
+ <<
+ CIfrRefreshId RiObj;
+ EFI_GUID Guid;
+ >>
+ L:RefreshGuid << RiObj.SetLineNo(L->getLine()); >>
+ "=" guidDefinition[Guid] "," << RiObj.SetRefreshEventGroutId (&Guid); >>
+ ;
+
vfrStatementVarstoreDevice :
<< CIfrVarStoreDevice VDObj; >>
L:VarstoreDevice << VDObj.SetLineNo(L->getLine()); >>
@@ -2811,6 +2960,7 @@ vfrStatementInvalidSaveRestoreDefaults :
#token QuestionRefVal("questionrefval") "questionrefval"
#token StringRefVal("stringrefval") "stringrefval"
#token Map("map") "map"
+#token RefreshGuid("refreshguid") "refreshguid"
//
// Root expression extension function called by other function.
@@ -3687,6 +3837,7 @@ private:
EFI_VARSTORE_INFO mCurrQestVarInfo;
+ EFI_GUID *mOverrideClassGuid;
//
// For framework vfr compatibility
@@ -3720,6 +3871,7 @@ public:
UINT64 _STOU64 (IN CHAR8 *);
EFI_HII_DATE _STOD (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);
EFI_HII_TIME _STOT (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);
+ EFI_HII_REF _STOR (IN CHAR8 *, IN CHAR8 *, IN EFI_GUID *, IN CHAR8 *);
EFI_STRING_ID _STOSID (IN CHAR8 *);
EFI_FORM_ID _STOFID (IN CHAR8 *);
@@ -3737,6 +3889,7 @@ public:
VOID IdEqValDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN EFI_COMPARE_TYPE);
VOID IdEqIdDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE);
VOID IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *);
+ VOID SetOverrideClassGuid (IN EFI_GUID *);
//
// For framework vfr compatibility
//
@@ -4158,6 +4311,25 @@ EfiVfrParser::_STRCAT (
*Dest = NewStr;
}
+EFI_HII_REF
+EfiVfrParser::_STOR (
+ IN CHAR8 *QuestionId,
+ IN CHAR8 *FormId,
+ IN EFI_GUID *FormSetGuid,
+ IN CHAR8 *DevicePath
+ )
+{
+ EFI_HII_REF Ref;
+ UINT32 Index;
+
+ memcpy (&Ref.FormSetGuid, FormSetGuid, sizeof (EFI_GUID));
+ Ref.QuestionId = _STOQID (QuestionId);
+ Ref.FormId = _STOFID (FormId);
+ Ref.DevicePath = _STOSID (DevicePath);
+
+ return Ref;
+}
+
//
// framework vfr to default declare varstore for each structure
//
@@ -4225,6 +4397,9 @@ EfiVfrParser::_DeclareDefaultFrameworkVarStore (
VSEObj.SetAttributes (0x00000002); //hardcode EFI_VARIABLE_BOOTSERVICE_ACCESS attribute
VSEObj.SetGuid (&pNode->mGuid);
VSEObj.SetVarStoreId (pNode->mVarStoreId);
+ // Generate old efi varstore storage structure for compatiable with old "VarEqVal" opcode,
+ // which is 3 bytes less than new structure define in UEFI Spec 2.3.1.
+ VSEObj.SetBinaryLength (sizeof (EFI_IFR_VARSTORE_EFI) - 3);
#ifdef VFREXP_DEBUG
printf ("undefined Efi VarStoreName is %s and Id is 0x%x\n", pNode->mVarStoreName, pNode->mVarStoreId);
#endif
@@ -4523,6 +4698,12 @@ EfiVfrParser::IdEqListDoSpecial (
}
}
+VOID
+EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *OverrideClassGuid)
+{
+ mOverrideClassGuid = OverrideClassGuid;
+}
+
//
// For framework vfr compatibility
//
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index b839a0ab0e..c3a729eabf 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -468,6 +468,7 @@ static struct {
{"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)},
+ {"EFI_HII_REF", EFI_IFR_TYPE_REF, sizeof (EFI_HII_REF), sizeof (EFI_GUID)},
{NULL, EFI_IFR_TYPE_OTHER, 0, 0}
};
@@ -635,7 +636,7 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetTypeField (
- IN CHAR8 *FName,
+ IN CONST CHAR8 *FName,
IN SVfrDataType *Type,
OUT SVfrDataField *&Field
)
@@ -647,6 +648,20 @@ CVfrVarDataTypeDB::GetTypeField (
}
for (pField = Type->mMembers; pField != NULL; pField = pField->mNext) {
+ //
+ // For type EFI_IFR_TYPE_TIME, because field name is not correctly wrote,
+ // add code to adjust it.
+ //
+ if (Type->mType == EFI_IFR_TYPE_TIME) {
+ if (strcmp (FName, "Hour") == 0) {
+ FName = "Hours";
+ } else if (strcmp (FName, "Minute") == 0) {
+ FName = "Minuts";
+ } else if (strcmp (FName, "Second") == 0) {
+ FName = "Seconds";
+ }
+ }
+
if (strcmp (pField->mFieldName, FName) == 0) {
Field = pField;
return VFR_RETURN_SUCCESS;
@@ -789,6 +804,37 @@ CVfrVarDataTypeDB::InternalTypesListInit (
pSecondsField->mArrayNum = 0;
New->mMembers = pHoursField;
+ } else if (strcmp (gInternalTypesTable[Index].mTypeName, "EFI_HII_REF") == 0) {
+ SVfrDataField *pQuestionIdField = new SVfrDataField;
+ SVfrDataField *pFormIdField = new SVfrDataField;
+ SVfrDataField *pFormSetGuidField = new SVfrDataField;
+ SVfrDataField *pDevicePathField = new SVfrDataField;
+
+ strcpy (pQuestionIdField->mFieldName, "QuestionId");
+ GetDataType ((CHAR8 *)"UINT16", &pQuestionIdField->mFieldType);
+ pQuestionIdField->mOffset = 0;
+ pQuestionIdField->mNext = pFormIdField;
+ pQuestionIdField->mArrayNum = 0;
+
+ strcpy (pFormIdField->mFieldName, "FormId");
+ GetDataType ((CHAR8 *)"UINT16", &pFormIdField->mFieldType);
+ pFormIdField->mOffset = 2;
+ pFormIdField->mNext = pFormSetGuidField;
+ pFormIdField->mArrayNum = 0;
+
+ strcpy (pFormSetGuidField->mFieldName, "FormSetGuid");
+ GetDataType ((CHAR8 *)"EFI_GUID", &pFormSetGuidField->mFieldType);
+ pFormSetGuidField->mOffset = 4;
+ pFormSetGuidField->mNext = pDevicePathField;
+ pFormSetGuidField->mArrayNum = 0;
+
+ strcpy (pDevicePathField->mFieldName, "DevicePath");
+ GetDataType ((CHAR8 *)"EFI_STRING_ID", &pDevicePathField->mFieldType);
+ pDevicePathField->mOffset = 20;
+ pDevicePathField->mNext = NULL;
+ pDevicePathField->mArrayNum = 0;
+
+ New->mMembers = pQuestionIdField;
} else {
New->mMembers = NULL;
}
@@ -2770,6 +2816,100 @@ Err:
}
}
+VOID
+CVfrQuestionDB::RegisterRefQuestion (
+ IN CHAR8 *Name,
+ IN CHAR8 *BaseVarId,
+ IN OUT EFI_QUESTION_ID &QuestionId
+ )
+{
+ SVfrQuestionNode *pNode[4] = {NULL, };
+ UINT32 Len;
+ CHAR8 *VarIdStr[4] = {NULL, };
+ CHAR8 Index;
+
+ if (BaseVarId == NULL) {
+ return;
+ }
+
+ Len = strlen (BaseVarId);
+
+ VarIdStr[0] = new CHAR8[Len + strlen (".QuestionId") + 1];
+ if (VarIdStr[0] != NULL) {
+ strcpy (VarIdStr[0], BaseVarId);
+ strcat (VarIdStr[0], ".QuestionId");
+ }
+ VarIdStr[1] = new CHAR8[Len + strlen (".FormId") + 1];
+ if (VarIdStr[1] != NULL) {
+ strcpy (VarIdStr[1], BaseVarId);
+ strcat (VarIdStr[1], ".FormId");
+ }
+ VarIdStr[2] = new CHAR8[Len + strlen (".FormSetGuid") + 1];
+ if (VarIdStr[2] != NULL) {
+ strcpy (VarIdStr[2], BaseVarId);
+ strcat (VarIdStr[2], ".FormSetGuid");
+ }
+ VarIdStr[3] = new CHAR8[Len + strlen (".DevicePath") + 1];
+ if (VarIdStr[3] != NULL) {
+ strcpy (VarIdStr[3], BaseVarId);
+ strcat (VarIdStr[3], ".DevicePath");
+ }
+
+ if ((pNode[0] = new SVfrQuestionNode (Name, VarIdStr[0])) == NULL) {
+ goto Err;
+ }
+ if ((pNode[1] = new SVfrQuestionNode (Name, VarIdStr[1])) == NULL) {
+ goto Err;
+ }
+ if ((pNode[2] = new SVfrQuestionNode (Name, VarIdStr[2])) == NULL) {
+ goto Err;
+ }
+ if ((pNode[3] = new SVfrQuestionNode (Name, VarIdStr[3])) == NULL) {
+ goto Err;
+ }
+
+ if (QuestionId == EFI_QUESTION_ID_INVALID) {
+ QuestionId = GetFreeQuestionId ();
+ } else {
+ if (ChekQuestionIdFree (QuestionId) == FALSE) {
+ goto Err;
+ }
+ MarkQuestionIdUsed (QuestionId);
+ }
+
+ pNode[0]->mQuestionId = QuestionId;
+ pNode[1]->mQuestionId = QuestionId;
+ pNode[2]->mQuestionId = QuestionId;
+ pNode[3]->mQuestionId = QuestionId;
+ pNode[0]->mQtype = QUESTION_REF;
+ pNode[1]->mQtype = QUESTION_REF;
+ pNode[2]->mQtype = QUESTION_REF;
+ pNode[3]->mQtype = QUESTION_REF;
+ pNode[0]->mNext = pNode[1];
+ pNode[1]->mNext = pNode[2];
+ pNode[2]->mNext = pNode[3];
+ pNode[3]->mNext = mQuestionList;
+ mQuestionList = pNode[0];
+
+ gCFormPkg.DoPendingAssign (VarIdStr[0], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID));
+ gCFormPkg.DoPendingAssign (VarIdStr[1], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID));
+ gCFormPkg.DoPendingAssign (VarIdStr[2], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID));
+ gCFormPkg.DoPendingAssign (VarIdStr[3], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID));
+
+ return;
+
+ Err:
+ for (Index = 0; Index < 4; Index++) {
+ if (pNode[Index] != NULL) {
+ delete pNode[Index];
+ }
+
+ if (VarIdStr[Index] != NULL) {
+ delete VarIdStr[Index];
+ }
+ }
+}
+
EFI_VFR_RETURN_CODE
CVfrQuestionDB::UpdateQuestionId (
IN EFI_QUESTION_ID QId,
@@ -2894,6 +3034,402 @@ CVfrQuestionDB::FindQuestion (
return VFR_RETURN_UNDEFINED;
}
+CVfrStringDB::CVfrStringDB ()
+{
+ mStringFileName = NULL;
+}
+
+CVfrStringDB::~CVfrStringDB ()
+{
+ if (mStringFileName != NULL) {
+ delete mStringFileName;
+ }
+ mStringFileName = NULL;
+}
+
+
+VOID
+CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName)
+{
+ UINT32 FileLen = 0;
+
+ if (StringFileName == NULL) {
+ return;
+ }
+
+ FileLen = strlen (StringFileName) + 1;
+ mStringFileName = new CHAR8[FileLen];
+ if (mStringFileName == NULL) {
+ return;
+ }
+
+ strcpy (mStringFileName, StringFileName);
+ mStringFileName[FileLen - 1] = '\0';
+}
+
+CHAR8 *
+CVfrStringDB::GetVarStoreNameFormStringId (
+ IN EFI_STRING_ID StringId
+ )
+{
+ FILE *pInFile = NULL;
+ UINT32 NameOffset;
+ UINT32 Length;
+ UINT8 *StringPtr;
+ CHAR8 *StringName;
+ CHAR16 *UnicodeString;
+ CHAR8 *VarStoreName = NULL;
+ CHAR8 *DestTmp;
+ UINT8 *Current;
+ EFI_STATUS Status;
+ CHAR8 LineBuf[EFI_IFR_MAX_LENGTH];
+ UINT8 BlockType;
+ EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
+
+ if (mStringFileName == '\0' ) {
+ return NULL;
+ }
+
+ if ((pInFile = fopen (mStringFileName, "rb")) == NULL) {
+ return NULL;
+ }
+
+ //
+ // Get file length.
+ //
+ fseek (pInFile, 0, SEEK_END);
+ Length = ftell (pInFile);
+ fseek (pInFile, 0, SEEK_SET);
+
+ //
+ // Get file data.
+ //
+ StringPtr = new UINT8[Length];
+ if (StringPtr == NULL) {
+ fclose (pInFile);
+ return NULL;
+ }
+ fread ((char *)StringPtr, sizeof (UINT8), Length, pInFile);
+ fclose (pInFile);
+
+ PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) StringPtr;
+ //
+ // Check the String package.
+ //
+ if (PkgHeader->Header.Type != EFI_HII_PACKAGE_STRINGS) {
+ delete StringPtr;
+ return NULL;
+ }
+
+ //
+ // Search the language, only search the "en-US".
+ //
+ Current = StringPtr;
+ while (strcmp (PkgHeader->Language, "en-US") != 0) {
+ Current += PkgHeader->Header.Length;
+ PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) Current;
+ //
+ // If can't find "en-US" string package, just return the first string package.
+ //
+ if (Current - StringPtr >= Length) {
+ Current = StringPtr;
+ break;
+ }
+ }
+
+ Current += PkgHeader->HdrSize;
+ //
+ // Find the string block according the stringId.
+ //
+ Status = FindStringBlock(Current, StringId, &NameOffset, &BlockType);
+ if (Status != EFI_SUCCESS) {
+ delete StringPtr;
+ return NULL;
+ }
+
+ //
+ // Get varstore name according the string type.
+ //
+ switch (BlockType) {
+ case EFI_HII_SIBT_STRING_SCSU:
+ case EFI_HII_SIBT_STRING_SCSU_FONT:
+ case EFI_HII_SIBT_STRINGS_SCSU:
+ case EFI_HII_SIBT_STRINGS_SCSU_FONT:
+ StringName = (CHAR8*)(Current + NameOffset);
+ VarStoreName = new CHAR8[strlen(StringName) + 1];
+ strcpy (VarStoreName, StringName);
+ break;
+ case EFI_HII_SIBT_STRING_UCS2:
+ case EFI_HII_SIBT_STRING_UCS2_FONT:
+ case EFI_HII_SIBT_STRINGS_UCS2:
+ case EFI_HII_SIBT_STRINGS_UCS2_FONT:
+ UnicodeString = (CHAR16*)(Current + NameOffset);
+ Length = GetUnicodeStringTextSize ((UINT8*)UnicodeString) ;
+ DestTmp = new CHAR8[Length / 2 + 1];
+ VarStoreName = DestTmp;
+ while (*UnicodeString != '\0') {
+ *(DestTmp++) = (CHAR8) *(UnicodeString++);
+ }
+ *DestTmp = '\0';
+ break;
+ default:
+ break;
+ }
+
+ delete StringPtr;
+
+ return VarStoreName;
+}
+
+EFI_STATUS
+CVfrStringDB::FindStringBlock (
+ IN UINT8 *StringData,
+ IN EFI_STRING_ID StringId,
+ OUT UINT32 *StringTextOffset,
+ OUT UINT8 *BlockType
+ )
+{
+ UINT8 *BlockHdr;
+ EFI_STRING_ID CurrentStringId;
+ UINT32 BlockSize;
+ UINT32 Index;
+ UINT8 *StringTextPtr;
+ UINT32 Offset;
+ UINT16 StringCount;
+ UINT16 SkipCount;
+ UINT8 Length8;
+ EFI_HII_SIBT_EXT2_BLOCK Ext2;
+ UINT32 Length32;
+ UINT32 StringSize;
+
+ CurrentStringId = 1;
+
+ //
+ // Parse the string blocks to get the string text and font.
+ //
+ BlockHdr = StringData;
+ BlockSize = 0;
+ Offset = 0;
+ while (*BlockHdr != EFI_HII_SIBT_END) {
+ switch (*BlockHdr) {
+ case EFI_HII_SIBT_STRING_SCSU:
+ Offset = sizeof (EFI_HII_STRING_BLOCK);
+ StringTextPtr = BlockHdr + Offset;
+ BlockSize += Offset + strlen ((CHAR8 *) StringTextPtr) + 1;
+ CurrentStringId++;
+ break;
+
+ case EFI_HII_SIBT_STRING_SCSU_FONT:
+ Offset = sizeof (EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK) - sizeof (UINT8);
+ StringTextPtr = BlockHdr + Offset;
+ BlockSize += Offset + strlen ((CHAR8 *) StringTextPtr) + 1;
+ CurrentStringId++;
+ break;
+
+ case EFI_HII_SIBT_STRINGS_SCSU:
+ memcpy (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
+ StringTextPtr = BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8);
+ BlockSize += StringTextPtr - BlockHdr;
+
+ for (Index = 0; Index < StringCount; Index++) {
+ BlockSize += strlen ((CHAR8 *) StringTextPtr) + 1;
+ if (CurrentStringId == StringId) {
+ *BlockType = *BlockHdr;
+ *StringTextOffset = StringTextPtr - StringData;
+ return EFI_SUCCESS;
+ }
+ StringTextPtr = StringTextPtr + strlen ((CHAR8 *) StringTextPtr) + 1;
+ CurrentStringId++;
+ }
+ break;
+
+ case EFI_HII_SIBT_STRINGS_SCSU_FONT:
+ memcpy (
+ &StringCount,
+ BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),
+ sizeof (UINT16)
+ );
+ StringTextPtr = BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8);
+ BlockSize += StringTextPtr - BlockHdr;
+
+ for (Index = 0; Index < StringCount; Index++) {
+ BlockSize += strlen ((CHAR8 *) StringTextPtr) + 1;
+ if (CurrentStringId == StringId) {
+ *BlockType = *BlockHdr;
+ *StringTextOffset = StringTextPtr - StringData;
+ return EFI_SUCCESS;
+ }
+ StringTextPtr = StringTextPtr + strlen ((CHAR8 *) StringTextPtr) + 1;
+ CurrentStringId++;
+ }
+ break;
+
+ case EFI_HII_SIBT_STRING_UCS2:
+ Offset = sizeof (EFI_HII_STRING_BLOCK);
+ StringTextPtr = BlockHdr + Offset;
+ //
+ // Use StringSize to store the size of the specified string, including the NULL
+ // terminator.
+ //
+ StringSize = GetUnicodeStringTextSize (StringTextPtr);
+ BlockSize += Offset + StringSize;
+ CurrentStringId++;
+ break;
+
+ case EFI_HII_SIBT_STRING_UCS2_FONT:
+ Offset = sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) - sizeof (CHAR16);
+ StringTextPtr = BlockHdr + Offset;
+ //
+ // Use StrSize to store the size of the specified string, including the NULL
+ // terminator.
+ //
+ StringSize = GetUnicodeStringTextSize (StringTextPtr);
+ BlockSize += Offset + StringSize;
+ CurrentStringId++;
+ break;
+
+ case EFI_HII_SIBT_STRINGS_UCS2:
+ Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_BLOCK) - sizeof (CHAR16);
+ StringTextPtr = BlockHdr + Offset;
+ BlockSize += Offset;
+ memcpy (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
+ for (Index = 0; Index < StringCount; Index++) {
+ StringSize = GetUnicodeStringTextSize (StringTextPtr);
+ BlockSize += StringSize;
+ if (CurrentStringId == StringId) {
+ *BlockType = *BlockHdr;
+ *StringTextOffset = StringTextPtr - StringData;
+ return EFI_SUCCESS;
+ }
+ StringTextPtr = StringTextPtr + StringSize;
+ CurrentStringId++;
+ }
+ break;
+
+ case EFI_HII_SIBT_STRINGS_UCS2_FONT:
+ Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK) - sizeof (CHAR16);
+ StringTextPtr = BlockHdr + Offset;
+ BlockSize += Offset;
+ memcpy (
+ &StringCount,
+ BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),
+ sizeof (UINT16)
+ );
+ for (Index = 0; Index < StringCount; Index++) {
+ StringSize = GetUnicodeStringTextSize (StringTextPtr);
+ BlockSize += StringSize;
+ if (CurrentStringId == StringId) {
+ *BlockType = *BlockHdr;
+ *StringTextOffset = StringTextPtr - StringData;
+ return EFI_SUCCESS;
+ }
+ StringTextPtr = StringTextPtr + StringSize;
+ CurrentStringId++;
+ }
+ break;
+
+ case EFI_HII_SIBT_DUPLICATE:
+ if (CurrentStringId == StringId) {
+ //
+ // Incoming StringId is an id of a duplicate string block.
+ // Update the StringId to be the previous string block.
+ // Go back to the header of string block to search.
+ //
+ memcpy (
+ &StringId,
+ BlockHdr + sizeof (EFI_HII_STRING_BLOCK),
+ sizeof (EFI_STRING_ID)
+ );
+ CurrentStringId = 1;
+ BlockSize = 0;
+ } else {
+ BlockSize += sizeof (EFI_HII_SIBT_DUPLICATE_BLOCK);
+ CurrentStringId++;
+ }
+ break;
+
+ case EFI_HII_SIBT_SKIP1:
+ SkipCount = (UINT16) (*(BlockHdr + sizeof (EFI_HII_STRING_BLOCK)));
+ CurrentStringId = (UINT16) (CurrentStringId + SkipCount);
+ BlockSize += sizeof (EFI_HII_SIBT_SKIP1_BLOCK);
+ break;
+
+ case EFI_HII_SIBT_SKIP2:
+ memcpy (&SkipCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
+ CurrentStringId = (UINT16) (CurrentStringId + SkipCount);
+ BlockSize += sizeof (EFI_HII_SIBT_SKIP2_BLOCK);
+ break;
+
+ case EFI_HII_SIBT_EXT1:
+ memcpy (
+ &Length8,
+ BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),
+ sizeof (UINT8)
+ );
+ BlockSize += Length8;
+ break;
+
+ case EFI_HII_SIBT_EXT2:
+ memcpy (&Ext2, BlockHdr, sizeof (EFI_HII_SIBT_EXT2_BLOCK));
+ BlockSize += Ext2.Length;
+ break;
+
+ case EFI_HII_SIBT_EXT4:
+ memcpy (
+ &Length32,
+ BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),
+ sizeof (UINT32)
+ );
+
+ BlockSize += Length32;
+ break;
+
+ default:
+ break;
+ }
+
+ if (StringId > 0 && StringId != (EFI_STRING_ID)(-1)) {
+ *StringTextOffset = BlockHdr - StringData + Offset;
+ *BlockType = *BlockHdr;
+
+ if (StringId == CurrentStringId - 1) {
+ //
+ // if only one skip item, return EFI_NOT_FOUND.
+ //
+ if(*BlockType == EFI_HII_SIBT_SKIP2 || *BlockType == EFI_HII_SIBT_SKIP1) {
+ return EFI_NOT_FOUND;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
+
+ if (StringId < CurrentStringId - 1) {
+ return EFI_NOT_FOUND;
+ }
+ }
+ BlockHdr = StringData + BlockSize;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+UINT32
+CVfrStringDB::GetUnicodeStringTextSize (
+ IN UINT8 *StringSrc
+ )
+{
+ UINT32 StringSize;
+ CHAR16 *StringPtr;
+
+ StringSize = sizeof (CHAR16);
+ StringPtr = (UINT16*)StringSrc;
+ while (*StringPtr++ != L'\0') {
+ StringSize += sizeof (CHAR16);
+ }
+
+ return StringSize;
+}
+
BOOLEAN VfrCompatibleMode = FALSE;
CVfrVarDataTypeDB gCVfrVarDataTypeDB;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index b921115b0a..9facce8149 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -175,7 +175,7 @@ private:
VOID RegisterNewType (IN SVfrDataType *);
EFI_VFR_RETURN_CODE ExtractStructTypeName (IN CHAR8 *&, OUT CHAR8 *);
- EFI_VFR_RETURN_CODE GetTypeField (IN CHAR8 *, IN SVfrDataType *, IN SVfrDataField *&);
+ EFI_VFR_RETURN_CODE GetTypeField (IN CONST CHAR8 *, IN SVfrDataType *, IN SVfrDataField *&);
EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT UINT32 &);
UINT8 GetFieldWidth (IN SVfrDataField *);
UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32);
@@ -359,6 +359,7 @@ public:
VOID RegisterNewDateQuestion (IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
VOID RegisterOldTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
VOID RegisterNewTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
+ VOID RegisterRefQuestion (IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
EFI_VFR_RETURN_CODE UpdateQuestionId (IN EFI_QUESTION_ID, IN EFI_QUESTION_ID);
VOID GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &, OUT EFI_QUESION_TYPE *QType = NULL);
EFI_VFR_RETURN_CODE FindQuestion (IN EFI_QUESTION_ID);
@@ -423,4 +424,33 @@ public:
UINT8 GetRuleId (IN CHAR8 *);
};
+class CVfrStringDB {
+private:
+ CHAR8 *mStringFileName;
+
+ EFI_STATUS FindStringBlock (
+ IN UINT8 *StringData,
+ IN EFI_STRING_ID StringId,
+ OUT UINT32 *StringTextOffset,
+ OUT UINT8 *BlockType
+ );
+
+ UINT32 GetUnicodeStringTextSize (
+ IN UINT8 *StringSrc
+ );
+
+public:
+ CVfrStringDB ();
+ ~CVfrStringDB ();
+
+ VOID SetStringFileName (
+ IN CHAR8 *StringFileName
+ );
+
+ CHAR8 * GetVarStoreNameFormStringId (
+ IN EFI_STRING_ID StringId
+ );
+
+};
+
#endif