/*++
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
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:
VfrSyntax.g
Abstract:
--*/
#header<<
#include "EfiVfr.h"
#include "VfrFormPkg.h"
#include "VfrError.h"
#include "VfrUtilityLib.h"
#include "AToken.h"
#include "ATokPtr.h"
>>
<<
#include "stdio.h"
#include "PBlackBox.h"
#include "DLexerBase.h"
#include "VfrLexer.h"
#include "AToken.h"
#define CRT_END_OP(Obj) {CIfrEnd EObj; if (Obj != NULL) EObj.SetLineNo ((Obj)->getLine());} while (0)
class CVfrDLGLexer : public VfrLexer
{
public:
{
}
};
)
{
}
>>
//
// Define a lexical class for parsing quoted strings. Basically
// starts with a double quote, and ends with a double quote that
// is not preceeded with a backslash.
//
//
// Define a lexclass for skipping over C++ style comments
//
//
// Standard lexclass is START
//
//
// Find start of C++ style comments
//
//
// Skip whitespace
//
//
// Skip over newlines, but count them
//
//
// Skip over 'extern' in any included .H file
//
//
// Tokens for the different keywords. Syntax is:
// TokenName("ErrorMessageText") "TokenString"
// where:
// TokenName is the token name (must be capitalized) that is used in the rules
// ErrorMessageText is the string the compiler emits when it detects a syntax error
// TokenString is the actual matching string used in the user script
//
#token LineDefinition "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << gCVfrErrorHandle.ParseFileScopeRecord (begexpr (), line ()); skip (); newline (); >>
//
// Define the class and subclass tokens
//
//
// This is the overall definition of a VFR form definition script.
//
<<
mParserStatus = 0;
mCIfrOpHdrIndex = 0;
>>
(
)*
<< $Return = mParserStatus; >>
;
;
<<
>>
(
)
{
}
{
}
;
<<
>>
;
"\#pragma" "pack" "\("
{
}
"\)"
;
{ NonNvDataMap }
{
}
{
}
;
(
)*
;
D:"UINT64"
{
}
;
D:"UINT32"
{
}
;
<<
>>
("UINT16" | "CHAR16")
{
}
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum), N); >>
;
D:"UINT8"
{
}
;
D:"BOOLEAN"
{
}
;
D:"EFI_STRING_ID"
{
}
;
D:"EFI_HII_DATE"
{
}
;
D:"EFI_HII_TIME"
{
}
;
D:"EFI_HII_REF"
{
}
;
{
}
;
//*****************************************************************************
//
// the syntax of GUID definition
//
G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
<<
>>
;
<<
>>
(
)
;
//*****************************************************************************
//
// the syntax of form set definition
//
<<
>>
L:FormSet
{
{
}
{
}
","
}
<<
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Already has 3 class guids, can't add extra class guid!");
}
switch (ClassGuidNum) {
case 0:
if (mOverrideClassGuid != NULL) {
ClassGuidNum = 2;
} else {
ClassGuidNum = 1;
}
if (mOverrideClassGuid != NULL) {
}
break;
case 1:
if (mOverrideClassGuid != NULL) {
ClassGuidNum ++;
}
if (mOverrideClassGuid != NULL) {
}
break;
case 2:
if (mOverrideClassGuid != NULL) {
ClassGuidNum ++;
}
if (mOverrideClassGuid != NULL) {
}
break;
case 3:
break;
default:
break;
}
SET_LINE_INFO (*FSObj, L);
//
// for framework vfr to store formset guid used by varstore and efivarstore
//
if (mCompatibleMode) {
}
>>
{
FC:Class "=" classDefinition[C] "," << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>
}
{
FSC:Subclass "=" subclassDefinition[SC] "," << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>
}
<<
>>
E:EndFormSet <<
if (mCompatibleMode) {
//
// declare all undefined varstore and efivarstore
//
}
>>
";"
;
(
)*
;
<<
>>
L:GuidOp
(
| TN:StringIdentifier {OpenBracket AN10:Number CloseBracket <<ArrayNum = _STOU32(AN10->getText());>>}
)
<<
if (ArrayNum > 0) {
} else {
}
}
>>
}
<<
{
}
}
}
>>
{","
(
)*
}
<<
>>
";"
;
vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, BOOLEAN IsStruct, UINT32 ArrayNum]:
<<
>>
(
<<
ArrayIdx = 0;
}
}
>>
<<
}
>>
{
<<
}
>>
}
)*
<<
}
} else {
switch (FieldType) {
case EFI_IFR_TYPE_NUM_SIZE_8:
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
break;
case EFI_IFR_TYPE_BOOLEAN:
break;
case EFI_IFR_TYPE_STRING:
break;
default:
break;
}
}
>>
)*
)
;
{
}
<<
_PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
} else {
_PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();
}
>>
";"
;
<<
>>
(
)
{ Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
if (mCompatibleMode) {
}
>>
}
{
ID,
"varid 0 is not allowed."
);
>>
}
<<
if (mCompatibleMode) {
} else {
}
&Guid,
), LineNum);
>>
";"
;
<<
>>
(
)
{
ID,
"varid 0 is not allowed."
);
>>
}
(
|
}
switch (Size) {
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
default:
break;
}
>>
)
if (IsUEFI23EfiVarstore) {
&Guid,
), LineNum);
} else {
&Guid,
), LineNum);
}
}
>>
";"
;
;
<<
>>
SN:StringIdentifier "," << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>
(
Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
)+
<<
>>
";"
;
//
// keep classDeinition and validClassNames for compatibility but not generate
// any IFR object
//
<< $Class = 0; >>
;
;
<< $SubClass = 0; >>
;
<<
>>
E:EndIf << CRT_END_OP (E); >>
";"
;
<< CIfrSuppressIf SIObj;>>
L:SuppressIf <<
if (mCompatibleMode) {
}
>>
E: EndIf
";" << CRT_END_OP (E); >>
;
//*****************************************************************************
//
// the syntax of question header and statement header
//
;
<<
>>
{
_PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");
>>
}
{
_PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
>>
}
<<
switch (QType) {
case QUESTION_NORMAL:
break;
case QUESTION_DATE:
break;
case QUESTION_TIME:
break;
case QUESTION_REF:
//
// VarIdStr != NULL stand for question with storagae.
//
} else {
}
break;
default:
}
}
>>
<<
}
>>
;
;
<<
>>
(
>>
<<
);
}
}
>>
)
|
(
<<
);
}
if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
}
}
>>
(
"." <<
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
}
>>
{
if (mCompatibleMode) Idx --;
if (Idx > 0) {
//
// Idx == 0, [0] can be ignored.
// Array[0] is same to Array for unify the varid name to cover [0]
//
}
>>
}
)* <<
switch (VarStoreType) {
case EFI_VFR_VARSTORE_EFI:
break;
case EFI_VFR_VARSTORE_BUFFER:
_PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);
NULL),
'a',
NULL,
Dummy),
break;
case EFI_VFR_VARSTORE_NAME:
default: break;
}
>>
)
;
<<
>>
(
if (mConstantOnlyInExpression) {
}
>>
)
|
(
(
"." <<
if (mConstantOnlyInExpression) {
}
>>
{
if (mCompatibleMode) Idx --;
if (Idx > 0) {
//
// Idx == 0, [0] can be ignored.
// Array[0] is same to Array
//
}
>>
}
)*
)
;
<<
>>
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
break;
case EFI_IFR_TYPE_NUM_SIZE_16 :
break;
case EFI_IFR_TYPE_NUM_SIZE_32 :
break;
case EFI_IFR_TYPE_NUM_SIZE_64 :
break;
case EFI_IFR_TYPE_BOOLEAN :
break;
case EFI_IFR_TYPE_STRING :
break;
case EFI_IFR_TYPE_TIME :
case EFI_IFR_TYPE_DATE :
case EFI_IFR_TYPE_REF :
default :
break;
}
>>
| 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()); >>
;
//*****************************************************************************
//
// the syntax of form definition
//
(
// Just for framework vfr compatibility
)*
E:EndForm <<
if (mCompatibleMode) {
//
// Add Label for Framework Vfr
//
}
//
// Declare undefined Question so that they can be used in expression.
//
if (gCFormPkg.HavePendingUnassigned()) {
E->getLine()
);
}
//
// mCVfrQuestionDB.PrintAllQuestion();
//
CRT_END_OP (E);
>>
";"
;
<<
>>
(
MapGuid "=" guidDefinition[Guid] ";" << FMapObj->SetFormMapMethod (_STOFID(S2->getText()), &Guid); FormMapMethodNumber ++; >>
)* << if (FormMapMethodNumber == 0) {_PCATCH (VFR_RETURN_INVALID_PARAMETER, F->getLine(), "No MapMethod is set for FormMap!");} delete FMapObj;>>
(
)*
E:EndForm << CRT_END_OP (E); >>
";"
;
>>
E:EndRule << CRT_END_OP (E); >>
";"
;
<<
>>
(
(
vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
//check default value is valid for Numeric Opcode
if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
}
>>
)
{
DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>
}
<<
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
Val),
D->getLine()
);
}
>>
)
;
;
;
vfrStatementSuppressIfStat | //enhance to be compatible for framework endif
vfrStatementInconsistentIfStat //to be compatible for framework
;
vfrStatementInconsistentIfStat //to be compatible for framework
;
;
;
(
)
;
;
;
;
;
<< CIfrSubtitle SObj; >>
{
}
{ vfrStatementStatTagList "," }
E:";" << CRT_END_OP (E); >>
;
;
;
<<
>>
T:Text
{
}
{
}
<<
if (Flags & EFI_IFR_FLAG_CALLBACK) {
CRT_END_OP (KN);
} else {
}
>>
{ "," vfrStatementStatTagList }
";"
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
;
<<
>>
G:Goto
{
(
<<
RefType = 4;
>>
)
|
(
<<
RefType = 3;
>>
)
|
(
Question "="
(
if (QId == EFI_QUESTION_ID_INVALID) {
}
>>
)
)
|
(
RefType = 1;
>>
)
}
<<
switch (RefType) {
case 5:
{
break;
}
case 4:
{
break;
}
case 3:
{
break;
}
case 2:
{
break;
}
case 1:
{
break;
}
default: break;
}
>>
{
}
{
E:","
}
";" << 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;}>>
;
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
"STRING_TOKEN" "\("
"\)"
;
<<
>>
>>
{ vfrStatementStatTagList "," }
E:EndResetButton << CRT_END_OP (E); >>
";"
;
;
//*****************************************************
// Syntax of checkbox
//
// Example:
// checkbox
// varid = MySTestData.mField1,
// prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
// help = STRING_TOKEN(STR_CHECK_BOX_HELP),
// flags = CHECKBOX_DEFAULT | CALLBACK,
// default value = TRUE, defaultstore = MyDefaultStore,
// endcheckbox;
//
<<
>>
_PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
} else if ((mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");
}
>>
{
<<
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
),
L,
"No standard default storage found"
);
}
),
L,
"No manufacturing default storage found"
);
}
>>
}
{
}
E:EndCheckBox << CRT_END_OP (E); >>
";"
;
<<
>>
;
N:Number <<
if (mCompatibleMode) {
//
// set question flag
//
} else {
}
>>
| D:"DEFAULT" <<
if (mCompatibleMode) {
//
// set question Default flag
//
$LFlags |= 0x01;
} else {
}
>>
| M:"MANUFACTURING" <<
if (mCompatibleMode) {
//
// set question MFG flag
//
$LFlags |= 0x02;
} else {
}
>>
;
//*****************************************************
// Syntax of action
//
// Example:
// action
// prompt = STRING_TOKEN(STR_ACTION_PROMPT),
// help = STRING_TOKEN(STR_ACTION_HELP),
// flags = CALLBACK,
// config = STRING_TOKEN(STR_ACTION_CONFIG),
// endaction;
//
<< CIfrAction AObj; >>
Config "=" "STRING_TOKEN" "\(" S:Number "\)" "," << AObj.SetQuestionConfig (_STOSID(S->getText())); >>
E:EndAction << CRT_END_OP (E); >>
";"
;
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
<<
>>
(
(
)
|
(
<< _STRCAT(&VarIdStr[0], D1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], D1Y->getText()); >>
<< _STRCAT(&VarIdStr[1], D2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], D2M->getText()); >>
<< _STRCAT(&VarIdStr[2], D3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], D3D->getText()); >>
<<
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
<< {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DefaultObj.SetLineNo(L->getLine());} >>
)
)
E:EndDate << CRT_END_OP (E); >>
";"
;
{
switch (KeyValue) {
case 0:
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Year default value must be between Min year and Max year.");
}
break;
case 1:
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Month default value must be between 1 and 12.");
}
break;
case 2:
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Day default value must be between 1 and 31.");
}
break;
}
>>
}
;
;
;
;
<<
>>
<<
switch (_GET_CURRQEST_DATATYPE()) {
}
>>
<<
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 :
}
break;
case EFI_IFR_TYPE_NUM_SIZE_32 :
}
break;
case EFI_IFR_TYPE_NUM_SIZE_16 :
}
break;
case EFI_IFR_TYPE_NUM_SIZE_8 :
}
break;
}
>>
{
<<
switch (_GET_CURRQEST_DATATYPE()) {
}
>>
}
<<
switch (_GET_CURRQEST_DATATYPE()) {
}
>>
;
<<
>>
_PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");
}
>>
{
}
E:EndNumeric <<
IsSupported = FALSE;
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_8:
case EFI_IFR_TYPE_NUM_SIZE_16:
case EFI_IFR_TYPE_NUM_SIZE_32:
case EFI_IFR_TYPE_NUM_SIZE_64:
IsSupported = TRUE;
break;
default:
break;
}
if (!IsSupported) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric question only support UINT8, UINT16, UINT32 and UINT64 data type.");
}
CRT_END_OP (E);
>>
";"
;
<<
>>
<<
//check data type flag
}
} else {
}
>>
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
<<
>>
_PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");
}
>>
{
}
E:EndOneOf <<
IsSupported = FALSE;
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_8:
case EFI_IFR_TYPE_NUM_SIZE_16:
case EFI_IFR_TYPE_NUM_SIZE_32:
case EFI_IFR_TYPE_NUM_SIZE_64:
IsSupported = TRUE;
break;
default:
break;
}
if (!IsSupported) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf question only support UINT8, UINT16, UINT32 and UINT64 data type.");
}
CRT_END_OP (E);
>>
";"
;
<<
>>
<<
//check data type flag
}
} else {
}
>>
;
;
<<
>>
{
}
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize takes only one byte, which can't be larger than 0xFF.");
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize can't be larger than the max number of elements in string array.");
}
>>
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize takes only one byte, which can't be larger than 0xFF.");
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be larger than the max number of elements in string array.");
} else if (StringMaxSize < StringMinSize) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be less than String MinSize.");
}
>>
E:EndString << CRT_END_OP (E); >>
";"
;
<<
>>
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
<<
>>
{
}
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize takes only two byte, which can't be larger than 0xFFFF.");
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize can't be larger than the max number of elements in password array.");
}
>>
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize takes only two byte, which can't be larger than 0xFFFF.");
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be larger than the max number of elements in password array.");
} else if (PasswordMaxSize < PasswordMinSize) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be less than Password MinSize.");
}
>>
E:EndPassword << CRT_END_OP (E); >>
";"
;
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
<<
>>
<<
>>
{
_PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers takes only one byte, which can't be larger than 0xFF.");
_PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers can't be larger than the max number of elements in array.");
}
>>
}
E:EndList << CRT_END_OP (E); >>
";"
;
<<
>>
;
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
;
<<
>>
(
(
)
|
(
<< _STRCAT(&VarIdStr[0], T1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], T1H->getText()); >>
<< _STRCAT(&VarIdStr[1], T2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], T2M->getText()); >>
<< _STRCAT(&VarIdStr[2], T3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], T3S->getText()); >>
<<
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
<< {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DefaultObj.SetLineNo(L->getLine());} >>
)
)
E:EndTime << CRT_END_OP (E); >>
";"
;
{
switch (KeyValue) {
case 0:
if (T.Hour > 23) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Hour default value must be between 0 and 23.");
}
break;
case 1:
if (T.Minute > 59) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Minute default value must be between 0 and 59.");
}
break;
case 2:
if (T.Second > 59) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Second default value must be between 0 and 59.");
}
break;
}
>>
}
;
;
;
vfrStatementStatTag "," |
;
;
;
(
)*
;
// Just for framework vfr compatibility
;
// Just for framework vfr compatibility
;
<<
>>
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
<< CIfrInconsistentIf IIObj; >>
L:InconsistentIf <<
if (!mCompatibleMode) {
}
>>
E:EndIf << CRT_END_OP (E); >>
";"
;
//
// Compatible for framework vfr file
//
<< CIfrSuppressIf SIObj; >>
";"
;
<< CIfrGrayOutIf GOIObj; >>
";"
;
<< CIfrSuppressIf SIObj;>>
";"
( vfrStatementStatList )*
;
<< CIfrGrayOutIf GOIObj;>>
";"
( vfrStatementStatList )*
;
<<
>>
";"
{
<< GrayOutExist = TRUE; >>
}
;
<<
>>
";"
{
<< SuppressExist = TRUE; >>
}
;
L:Image "=" "IMAGE_TOKEN" "\(" S1:Number "\)" << IObj.SetImageId (_STOSID(S1->getText())); IObj.SetLineNo(L->getLine()); >>
;
<< CIfrLocked LObj; >>
;
;
;
;
";"
;
";"
;
";"
;
<< CIfrInconsistentIf IIObj; >>
E:EndIf << CRT_END_OP (E); >>
;
<< CIfrNoSubmitIf NSIObj; >>
E:EndIf << CRT_END_OP (E); >>
;
<<
>>
E:EndIf << CRT_END_OP (E); >>
;
<< CIfrRefresh RObj; >>
;
<<
>>
;
<< CIfrVarStoreDevice VDObj; >>
;
<< CIfrSuppressIf SIObj; >>
E:EndIf << CRT_END_OP (E); >>
;
<< CIfrGrayOutIf GOIObj; >>
E:EndIf << CRT_END_OP (E); >>
;
;
<<
>>
<<
if (gCurrentMinMaxData != NULL) {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64:
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
break;
case EFI_IFR_TYPE_NUM_SIZE_8:
break;
default:
break;
}
}
>>
<<
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
), L->getLine());
}
), L->getLine());
}
>>
{
if (!mCompatibleMode) {
}
//
// Guid Option Key
//
Val,
);
>>
}
(
)*
";"
;
<<
>>
;
;
L:Label
N:Number <<
if (mCompatibleMode) {
//
// Add end Label for Framework Vfr
//
}
{
}
>>
";"
;
<< CIfrBanner BObj; >>
(
(
(
) ";"
)
|
(
)
)
;
//******************************************************************************
//
// keep some syntax for compatibility but not generate any IFR object
//
L:Hidden <<
if (!mCompatibleMode) {
}
>>
;
";"
;
L:Inventory <<
if (!mCompatibleMode) {
}
>>
{
}
";"
;
(
L:Save <<
if (!mCompatibleMode) {
}
>>
|
K:Restore <<
if (!mCompatibleMode) {
}
>>
)
Defaults ","
";"
;
//******************************************************************************
//
// The syntax of expression
//
//
// Root expression extension function called by other function.
//
<< if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>
(
)*
<<
//
// Extend OpCode Scope only for the root expression.
//
if (_SET_SAVED_OPHDR_SCOPE()) {
}
}
}
if ($RootLevel == 0) {
mCIfrOpHdrIndex --;
}
>>
;
//
// Add new sub function for the sub expression extension to remember the ExpOpCount
// This funciton is only called by sub expression.
//
(
)*
;
(
)*
;
(
L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
)*
;
(
)*
;
(
(
)
|
(
L2:"!=" compareTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrNotEqual NEObj(L2->getLine()); >>
)
)*
;
(
(
)
|
(
)
|
(
L3:">" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterThan GTObj(L3->getLine()); >>
)
|
(
L4:">=" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterEqual GEObj(L4->getLine()); >>
)
)*
;
(
(
L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
)
|
(
L2:"\>>" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftRight SRObj(L2->getLine()); >>
)
)*
;
(
(
)
|
(
L2:"\-" multdivmodTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrSubtract SObj(L2->getLine()); >>
)
)*
;
(
(
)
|
(
)
|
(
)
)*
;
(
L:"\("
(
)
"\)"
)*
<<
switch (CastType) {
}
>>
;
| (
L:NOT
)
;
L:Catenate
"\("
","
;
L:Match
"\("
","
;
"\("
"\)"
;
;
L:Dup << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
;
<<
>>
L:VarEqVal <<
if (!mCompatibleMode) {
}
>>
if (VfrReturnCode == VFR_RETURN_UNDEFINED) {
0x2, //default type is UINT16
), VN);
} else {
}
>>
(
(
"=="
<<
if (Mask == 0) {
$ExpOpCount++;
} else {
}
>>
)
|
(
"<="
)
|
(
"<"
)
|
(
">="
)
|
(
">"
)
)
;
<<
>>
L:IdEqVal
(
(
"=="
<<
if (Mask == 0) {
$ExpOpCount++;
} else {
}
>>
)
|
(
"<="
)
|
(
"<"
)
|
(
">="
)
|
(
">"
)
)
;
<<
>>
L:IdEqId
(
(
"=="
<<
IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);
} else {
$ExpOpCount++;
}
>>
)
|
(
"<="
<< IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_EQUAL); >>
)
|
(
"<"
<< IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_THAN); >>
)
|
(
">="
<< IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_EQUAL); >>
)
|
(
">"
<< IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_THAN); >>
)
)
;
<<
>>
"=="
(
)+
<<
if (Mask != 0) {
} else {
if (QId != EFI_QUESTION_ID_INVALID) {
}
}
if (QId == EFI_QUESTION_ID_INVALID) {
}
$ExpOpCount++;
}
>>
;
<<
>>
"\("
(
>>
)
"\)"
<<
{ CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0), L->getLine()); QR1Obj.SetQuestionId (QId, QName, LineNo); } $ExpOpCount++; >>
;
L:RuleRef
"\(" RN:StringIdentifier "\)" << { CIfrRuleRef RRObj(L->getLine()); _SAVE_OPHDR_COND (RRObj, ($ExpOpCount == 0), L->getLine()); RRObj.SetRuleId (mCVfrRulesDB.GetRuleId (RN->getText())); } $ExpOpCount++; >>
;
//******************************************************
// PARSE:
// stringref (STR_FORM_SET_TITLE)
//
<<
>>
"\("
(
"STRING_TOKEN"
"\("
"\)"
)
"\)" << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0), L->getLine()); SR1Obj.SetStringId (RefStringId); $ExpOpCount++; } >>
;
L:PushThis << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
;
<<
>>
L:Security
"\(" guidDefinition[Guid] "\)" << { CIfrSecurity SObj(L->getLine()); _SAVE_OPHDR_COND (SObj, ($ExpOpCount == 0), L->getLine()); SObj.SetPermissions (&Guid); } $ExpOpCount++; >>
;
;
<<
>>
L:Get
"\("
"\)" <<
{
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
}
if (QType == QUESTION_DATE) {
} else if (QType == QUESTION_TIME) {
}
switch (Mask) {
case DATE_YEAR_BITMASK:
break;
case DATE_DAY_BITMASK:
break;
case TIME_HOUR_BITMASK:
break;
case TIME_MINUTE_BITMASK:
break;
case TIME_SECOND_BITMASK:
break;
default:
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
break;
}
} else {
if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
}
if (VarType != EFI_IFR_TYPE_UNDEFINED) {
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
}
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
}
}
$ExpOpCount++;
}
>>
;
L1:True << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>
| L2:False << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>
| L3:One << CIfrOne OObj(L3->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L3->getLine()); $ExpOpCount++; >>
| L4:Ones << CIfrOnes OObj(L4->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L4->getLine()); $ExpOpCount++; >>
| L5:Zero << CIfrZero ZObj(L5->getLine()); _SAVE_OPHDR_COND (ZObj, ($ExpOpCount == 0), L5->getLine()); $ExpOpCount++; >>
| L6:Undefined << CIfrUndefined UObj(L6->getLine()); _SAVE_OPHDR_COND (UObj, ($ExpOpCount == 0), L6->getLine()); $ExpOpCount++; >>
| L7:Version << CIfrVersion VObj(L7->getLine()); _SAVE_OPHDR_COND (VObj, ($ExpOpCount == 0), L7->getLine()); $ExpOpCount++; >>
| V:Number << CIfrUint64 U64Obj(V->getLine()); U64Obj.SetValue (_STOU64(V->getText())); _SAVE_OPHDR_COND (U64Obj, ($ExpOpCount == 0), V->getLine()); $ExpOpCount++; >>
;
;
L:Length
;
;
<<
>>
"\("
{
DevicePath "=" "STRING_TOKEN" "\(" S:Number "\)" "," << Type = 0x2; DevPath = _STOSID(S->getText()); >>
}
{
}
"\)"
<<
switch (Type) {
case 0x1: {CIfrQuestionRef2 QR2Obj(L->getLine()); _SAVE_OPHDR_COND (QR2Obj, ($ExpOpCount == 0), L->getLine()); break;}
case 0x2: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0), L->getLine()); QR3_2Obj.SetDevicePath (DevPath); break;}
case 0x3: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0), L->getLine()); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;}
}
$ExpOpCount++;
>>
;
;
L:BoolVal
;
{
}
;
L:UnIntVal
;
L:ToUpper
;
L:ToLower
;
<<
>>
L:Set
"\("
"\)"
<<
{
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
}
if (QType == QUESTION_DATE) {
} else if (QType == QUESTION_TIME) {
}
switch (Mask) {
case DATE_YEAR_BITMASK:
break;
case DATE_DAY_BITMASK:
break;
case TIME_HOUR_BITMASK:
break;
case TIME_MINUTE_BITMASK:
break;
case TIME_SECOND_BITMASK:
break;
default:
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
break;
}
} else {
if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
}
if (VarType != EFI_IFR_TYPE_UNDEFINED) {
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
}
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
}
}
$ExpOpCount++;
}
>>
;
;
L:Cond "\("
"?"
":"
;
L:Find "\("
","
","
","
;
;
L:Mid "\("
","
","
;
L:Tok "\("
","
","
;
S:Span "\("
","
","
","
;
L:Map
"\("
(
","
";"
) *
;
;
//******************************************************************************
//
// Parser class definition.
//
class EfiVfrParser {
<<
private:
//
// For framework vfr compatibility
//
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 *);
//
// For framework vfr compatibility
//
>>
}
<<
)
{
return ;
}
}
}
)
{
}
)
{
return TRUE;
}
//
// IfrOpHdr is not set, FALSE is return.
//
return FALSE;
}
)
{
}
)
{
}
)
{
return mCurrQestVarInfo;
}
)
{
switch (mCurrQestVarInfo.mVarType) {
case EFI_IFR_TYPE_NUM_SIZE_8:
Size = 1;
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
Size = 2;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
Size = 4;
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
Size = 8;
break;
default:
break;
}
}
)
{
return mCurrQestVarInfo.mVarType;
}
)
{
return mCurrQestVarInfo.mVarTotalSize;
}
)
{
if (ReturnCode != ExpectCode) {
}
}
)
{
}
)
{
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, Tok->getLine(), Tok->getText());
}
)
{
}
)
{
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, (CHAR8 *) ErrorMsg);
}
EfiVfrParser::syn (
)
{
mParserStatus += 1;
}
CHAR8 *
)
{
Str++;
}
Str++;
}
Str++;
}
return Str;
}
CHAR8 *
)
{
return Str;
}
)
{
CHAR8 c;
//
// BUG: does not handle overflow here
//
}
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
}
}
return Value;
}
)
{
CHAR8 c;
//
// BUG: does not handle overflow here
//
}
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
}
}
return Value;
}
)
{
CHAR8 c;
//
// BUG: does not handle overflow here
//
}
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
}
}
return Value;
}
)
{
CHAR8 c;
//
// BUG: does not handle overflow here
//
}
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
}
}
return Value;
}
)
{
return Date;
}
)
{
return Time;
}
)
{
}
)
{
}
)
{
}
)
{
return;
}
return;
}
}
}
)
{
return Ref;
}
//
// framework vfr to default declare varstore for each structure
//
)
{
//
// Create the default Buffer Var Store when no VarStore is defined.
// its name should be "Setup"
//
//VSObj.SetName (gCVfrVarDataTypeDB.mFirstNewDataTypeName);
} else {
//
// create the default varstore opcode for not declared varstore
// the first varstore name should be "Setup"
//
if (!pNode->mAssignedFlag) {
if (FirstNode) {
} else {
}
}
}
}
//
// create the default efi varstore opcode for not exist varstore
//
if (!pNode->mAssignedFlag) {
// 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.
printf ("undefined Efi VarStoreName is %s and Id is 0x%x\n", pNode->mVarStoreName, pNode->mVarStoreId);
}
}
}
)
{
);
}
//
// not required to declare Date and Time VarStore,
// because code to support old format Data and Time
//
);
}
);
}
}
)
{
//
// Default Store is declared.
//
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), (CHAR8 *) "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
//
// Default MANUFACTURING Store is declared.
//
mCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr(), (CHAR8 *) "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
}
)
{
return;
}
/*
* if the question is not CALLBACK ignore the key.
*/
}
}
)
{
if (BitMask != 0) {
switch (BitMask) {
}
}
ExpOpCount += 4;
}
)
{
if (ConstVal > 0xFF) {
} else {
}
switch (CompareType) {
case EQUAL :
{
break;
}
case LESS_EQUAL :
{
break;
}
case LESS_THAN :
{
break;
}
case GREATER_EQUAL :
{
break;
}
case GREATER_THAN :
{
break;
}
}
ExpOpCount += 2;
}
)
{
switch (CompareType) {
case EQUAL :
{
break;
}
case LESS_EQUAL :
{
break;
}
case LESS_THAN :
{
break;
}
case GREATER_EQUAL :
{
break;
}
case GREATER_THAN :
{
break;
}
}
ExpOpCount++;
}
)
{
if (ListLen == 0) {
return;
}
ExpOpCount++;
}
}
{
}
//
// For framework vfr compatibility
//
{
}
>>