From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [RFC V2 1/5] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore
Date: Sat, 27 May 2017 16:34:16 +0800 [thread overview]
Message-ID: <1495874060-331108-2-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1495874060-331108-1-git-send-email-dandan.bi@intel.com>
Enhance VfrCompiler to parse following case:
1. EFI/Buffer VarStore can contain bit fields in their structure.
2. For question Oneof/Checkbox/numeric, their storage can be
bit fields of an EFI VarStore/Buffer VarStore.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
BaseTools/Source/C/Include/Common/MdeModuleHii.h | 10 +
BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 +-
BaseTools/Source/C/VfrCompile/VfrError.h | 3 +-
BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 46 +-
BaseTools/Source/C/VfrCompile/VfrSyntax.g | 587 ++++++++++++++++++-----
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 390 ++++++++++++++-
BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 25 +-
7 files changed, 920 insertions(+), 144 deletions(-)
diff --git a/BaseTools/Source/C/Include/Common/MdeModuleHii.h b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
index 21c8387..866a855 100644
--- a/BaseTools/Source/C/Include/Common/MdeModuleHii.h
+++ b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
@@ -42,10 +42,20 @@
#define EFI_IFR_EXTEND_OP_TIMEOUT 0x2
#define EFI_IFR_EXTEND_OP_CLASS 0x3
#define EFI_IFR_EXTEND_OP_SUBCLASS 0x4
///
+/// EDKII implementation extension flags, used to indaicate the disply style and bit width for bit filed storage.
+///
+#define EFI_IFR_DISPLAY_BIT 0xC0
+#define EFI_IFR_DISPLAY_INT_DEC_BIT 0x00
+#define EFI_IFR_DISPLAY_UINT_DEC_BIT 0x40
+#define EFI_IFR_DISPLAY_UINT_HEX_BIT 0x80
+
+#define EFI_IFR_NUMERIC_SIZE_BIT 0x3F
+
+///
/// Label opcode.
///
typedef struct _EFI_IFR_GUID_LABEL {
EFI_IFR_OP_HEADER Header;
///
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index 285e175..0f8f7dd 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -1,10 +1,10 @@
/** @file
VfrCompiler error handler.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -44,10 +44,11 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_ERROR_ARRARY_NUM, ": array number error, the valid value is in (0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr" },
{ 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_VARSTORE_NAME_REDEFINED_ERROR, ": Varstore name is defined by more than one varstores, it can't be referred as varstore, only varstore strucure name could be used."},
+ { VFR_RETURN_BIT_WIDTH_ERROR, ": bit width must be <= sizeof (type) * 8 and the max width can not > 32" },
{ VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
};
static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = {
{ VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/VfrCompile/VfrError.h
index 4dbc54c..8bae049 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.h
+++ b/BaseTools/Source/C/VfrCompile/VfrError.h
@@ -1,10 +1,10 @@
/** @file
VfrCompiler Error definition
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -42,10 +42,11 @@ typedef enum {
VFR_RETURN_ERROR_ARRARY_NUM,
VFR_RETURN_DATA_STRING_ERROR,
VFR_RETURN_DEFAULT_VALUE_REDEFINED,
VFR_RETURN_CONSTANT_ONLY,
VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR,
+ VFR_RETURN_BIT_WIDTH_ERROR,
VFR_RETURN_CODEUNDEFINED
} EFI_VFR_RETURN_CODE;
typedef enum {
VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0,
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 17ab14c..3ed6748 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -1,10 +1,10 @@
/** @file
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -565,12 +565,16 @@ public:
}
}
mMinMaxStepData->u8.Step = Step;
}
- UINT64 GetMinData (UINT8 VarType) {
+ UINT64 GetMinData (UINT8 VarType, BOOLEAN IsBitVar) {
UINT64 MinValue = 0;
+ if (IsBitVar) {
+ MinValue = mMinMaxStepData->u32.MinValue;
+ return MinValue;
+ }
switch (VarType) {
case EFI_IFR_TYPE_NUM_SIZE_64:
MinValue = mMinMaxStepData->u64.MinValue;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
@@ -586,12 +590,16 @@ public:
break;
}
return MinValue;
}
- UINT64 GetMaxData (UINT8 VarType) {
+ UINT64 GetMaxData (UINT8 VarType, BOOLEAN IsBitVar) {
UINT64 MaxValue = 0;
+ if (IsBitVar) {
+ MaxValue = mMinMaxStepData->u32.MaxValue;
+ return MaxValue;
+ }
switch (VarType) {
case EFI_IFR_TYPE_NUM_SIZE_64:
MaxValue = mMinMaxStepData->u64.MaxValue;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
@@ -1405,10 +1413,26 @@ public:
mNumeric->Flags = LFlags;
}
return VFR_RETURN_SUCCESS;
}
+ EFI_VFR_RETURN_CODE SetFlagsForBitField (IN UINT8 HFlags, IN UINT8 LFlags, BOOLEAN DisplaySettingsSpecified = FALSE) {
+ EFI_VFR_RETURN_CODE Ret;
+
+ Ret = CIfrQuestionHeader::SetFlags (HFlags);
+ if (Ret != VFR_RETURN_SUCCESS) {
+ return Ret;
+ }
+
+ if (DisplaySettingsSpecified == FALSE) {
+ mNumeric->Flags = LFlags | EFI_IFR_DISPLAY_UINT_DEC_BIT;
+ } else {
+ mNumeric->Flags = LFlags;
+ }
+ return VFR_RETURN_SUCCESS;
+ }
+
UINT8 GetNumericFlags () {
return mNumeric->Flags;
}
};
@@ -1445,10 +1469,26 @@ public:
mOneOf->Flags = LFlags | EFI_IFR_DISPLAY_UINT_DEC;
}
return VFR_RETURN_SUCCESS;
}
+ EFI_VFR_RETURN_CODE SetFlagsForBitField (IN UINT8 HFlags, IN UINT8 LFlags) {
+ EFI_VFR_RETURN_CODE Ret;
+
+ Ret = CIfrQuestionHeader::SetFlags (HFlags);
+ if (Ret != VFR_RETURN_SUCCESS) {
+ return Ret;
+ }
+
+ if (LFlags & EFI_IFR_DISPLAY) {
+ mOneOf->Flags = LFlags;
+ } else {
+ mOneOf->Flags = LFlags | EFI_IFR_DISPLAY_UINT_DEC_BIT;
+ }
+ return VFR_RETURN_SUCCESS;
+ }
+
VOID ShrinkBinSize (IN UINT16 Size) {
//
// Update the buffer size which is truly be used later.
//
ShrinkObjBin(Size);
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 406dbc5..9bd1c28 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -344,11 +344,15 @@ vfrDataStructFields :
dataStructFieldBool |
dataStructFieldString |
dataStructFieldDate |
dataStructFieldTime |
dataStructFieldRef |
- dataStructFieldUser
+ dataStructFieldUser |
+ vfr64BitsStructField |
+ vfr32BitsStructField |
+ vfr16BitsStructField |
+ vfr8BitsStructField
)*
;
dataStructField64 :
<< UINT32 ArrayNum = 0; >>
@@ -450,10 +454,50 @@ dataStructFieldUser :
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText(), I->getLine()); >>
}
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >>
;
+vfr64BitsStructField:
+ << UINT32 Width = 0;>>
+ D:"UINT64"
+ N:StringIdentifier
+ {
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+ }
+ ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width), N); >>
+ ;
+
+vfr32BitsStructField:
+ << UINT32 Width = 0;>>
+ D:"UINT32"
+ N:StringIdentifier
+ {
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+ }
+ ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width), N); >>
+ ;
+
+vfr16BitsStructField:
+ << UINT32 Width = 0;>>
+ D:"UINT16"
+ N:StringIdentifier
+ {
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+ }
+ ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width), N); >>
+ ;
+
+vfr8BitsStructField:
+ << UINT32 Width = 0;>>
+ D:"UINT8"
+ N:StringIdentifier
+ {
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+ }
+ ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width), N); >>
+ ;
+
//*****************************************************************************
//
// the syntax of GUID definition
//
guidSubDefinition [EFI_GUID &Guid] :
@@ -855,10 +899,11 @@ vfrStatementVarStoreLinear :
CHAR8 *TypeName;
CHAR8 *StoreName;
UINT32 LineNum;
EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
UINT32 Size;
+ BOOLEAN IsBitVarStore = FALSE;
>>
V:Varstore << VSObj.SetLineNo(V->getLine()); >>
(
TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
| U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
@@ -868,10 +913,11 @@ 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(); >>
)
+ << IsBitVarStore = gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText());>>
{ Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
if (mCompatibleMode) {
VarStoreId = _STOU16(FID->getText(), FID->getLine());
}
>>
@@ -892,17 +938,27 @@ vfrStatementVarStoreLinear :
if (mCompatibleMode) {
StoreName = TypeName;
} else {
StoreName = SN->getText();
}
- _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
+ if (IsBitVarStore) {
+ _PCATCH(gCVfrDataStorage.DeclareBitsBufferVarStore (
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId
+ ), LineNum);
+ } else {
+ _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
StoreName,
&Guid,
&gCVfrVarDataTypeDB,
TypeName,
VarStoreId
), LineNum);
+ }
VSObj.SetGuid (&Guid);
_PCATCH(gCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
VSObj.SetVarStoreId (VarStoreId);
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
VSObj.SetSize ((UINT16) Size);
@@ -921,10 +977,11 @@ vfrStatementVarStoreEfi :
UINT32 Size;
CHAR8 *TypeName;
UINT32 LineNum;
CHAR8 *StoreName = NULL;
BOOLEAN CustomizedName = FALSE;
+ BOOLEAN IsBitVarStore = FALSE;
>>
E:Efivarstore << VSEObj.SetLineNo(E->getLine()); >>
(
TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); CustomizedName = TRUE; >>
| U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
@@ -934,10 +991,11 @@ vfrStatementVarStoreEfi :
| 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(); >>
)
+ << IsBitVarStore = gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText());>>
{
VarId "=" ID:Number "," <<
_PCATCH(
(INTN)(VarStoreId = _STOU16(ID->getText(), ID->getLine())) != 0,
(INTN)TRUE,
@@ -984,17 +1042,27 @@ vfrStatementVarStoreEfi :
>>
)
Uuid "=" guidDefinition[Guid] <<
if (IsUEFI23EfiVarstore) {
- _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
- StoreName,
- &Guid,
- &gCVfrVarDataTypeDB,
- TypeName,
- VarStoreId
- ), LineNum);
+ if (IsBitVarStore) {
+ _PCATCH(gCVfrDataStorage.DeclareBitsBufferVarStore (
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId
+ ), LineNum);
+ } else {
+ _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId
+ ), LineNum);
+ }
_PCATCH(gCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
} else {
_PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
TN->getText(),
@@ -1129,10 +1197,11 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
EFI_VARSTORE_INFO Info;
Info.mVarType = EFI_IFR_TYPE_OTHER;
Info.mVarTotalSize = 0;
Info.mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
Info.mVarStoreId = EFI_VARSTORE_ID_INVALID;
+ Info.mIsBitVar = FALSE;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
CHAR8 *QName = NULL;
CHAR8 *VarIdStr = NULL;
mUsedDefaultCount = 0;
>>
@@ -1185,10 +1254,62 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
}
_SAVE_CURRQEST_VARINFO (Info);
>>
;
+ vfrQuestionBaseInfo[EFI_VARSTORE_INFO & Info, EFI_QUESTION_ID & QId,EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
+ <<
+ CHAR8 *QName = NULL;
+ CHAR8 *VarIdStr = NULL;
+ mUsedDefaultCount = 0;
+ >>
+ {
+ Name "=" QN:StringIdentifier "," <<
+ QName = QN->getText();
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");
+ >>
+ }
+ { V:VarId "=" vfrStorageVarId[Info, VarIdStr] "," }
+ {
+ QuestionId "=" ID:Number "," <<
+ QId = _STOQID(ID->getText(), ID->getLine());
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
+ >>
+ }
+ <<
+ switch (QType) {
+ case QUESTION_NORMAL:
+ mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
+ break;
+ case QUESTION_DATE:
+ mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);
+ break;
+ 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);
+ }
+ >>
+ <<
+ if (VarIdStr != NULL) {
+ delete VarIdStr;
+ }
+ _SAVE_CURRQEST_VARINFO (Info);
+ >>
+ ;
+
questionheaderFlagsField[UINT8 & Flags] :
ReadOnlyFlag << $Flags |= 0x01; >>
| InteractiveFlag << $Flags |= 0x04; >>
| ResetRequiredFlag << $Flags |= 0x10; >>
| ReconnectRequiredFlag << $Flags |= 0x40; >>
@@ -1282,21 +1403,21 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
VfrReturnCode = gCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid);
}
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
_PCATCH(VfrReturnCode, SN2);
VarStoreType = gCVfrDataStorage.GetVarStoreType ($Info.mVarStoreId);
- if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_BUFFER_BITS) {
_PCATCH(gCVfrDataStorage.GetBufferVarStoreDataTypeName(Info.mVarStoreId, &TName), SN2);
_STRCAT(&VarStr, TName);
}
}
>>
(
"." <<
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
- _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
+ _PCATCH((((VarStoreType != EFI_VFR_VARSTORE_BUFFER)&& (VarStoreType != EFI_VFR_VARSTORE_BUFFER_BITS))? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
}
_STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");
>>
SF:StringIdentifier << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>
{
@@ -1338,11 +1459,32 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
$Info.mVarType,
$Info.mInfo.mVarOffset,
$Info.mVarTotalSize,
Dummy),
SN2->getLine());
- _PCATCH(gCVfrDataStorage.AddBufferVarStoreFieldInfo(&$Info ),SN2->getLine());
+ _PCATCH(gCVfrDataStorage.AddBufferVarStoreFieldInfo(&$Info),SN2->getLine());
+ break;
+ case EFI_VFR_VARSTORE_BUFFER_BITS:
+ _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);
+ VarGuid = gCVfrDataStorage.GetVarStoreGuid($Info.mVarStoreId);
+ _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
+ SName,
+ VarGuid,
+ NULL),
+ SN2->getLine());
+ _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (
+ 'a',
+ SName,
+ VarGuid,
+ NULL,
+ $Info.mVarType,
+ $Info.mInfo.mVarOffset,
+ $Info.mVarTotalSize,
+ Dummy),
+ SN2->getLine());
+ _PCATCH(gCVfrDataStorage.AddBufferVarStoreFieldInfo(&$Info),SN2->getLine());
+ Info.mIsBitVar = gCVfrVarDataTypeDB.IsThisBitField (VarStr);
break;
case EFI_VFR_VARSTORE_NAME:
default: break;
}
@@ -1419,10 +1561,13 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALUE &Value, BOOLEAN &ListType]
>>
{
"\-" << Negative = TRUE; >>
}
N1:Number <<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $Value.u32 = _STOU32(N1->getText(), N1->getLine());
+ } else {
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
$Value.u8 = _STOU8(N1->getText(), N1->getLine());
if (IntDecStyle) {
if (Negative) {
@@ -1500,10 +1645,11 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALUE &Value, BOOLEAN &ListType]
case EFI_IFR_TYPE_DATE :
case EFI_IFR_TYPE_REF :
default :
break;
}
+ }
>>
| B1:True << $Value.b = TRUE; >>
| B2:False << $Value.b = FALSE; >>
| O1:One << $Value.u8 = _STOU8(O1->getText(), O1->getLine()); >>
| O2:Ones << $Value.u64 = _STOU64(O2->getText(), O2->getLine()); >>
@@ -1672,42 +1818,48 @@ vfrStatementDefault :
"=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayType] ","
<<
if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {
//check default value is valid for Numeric Opcode
NumericQst = (CIfrNumeric *) gCurrentQuestion;
- if ((NumericQst->GetNumericFlags() & EFI_IFR_DISPLAY) == 0) {
+ if ((NumericQst->GetNumericFlags() & EFI_IFR_DISPLAY) == 0 && !(_GET_CURRQEST_VARTINFO().mIsBitVar)) {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_8:
- if (((INT8) Val->u8 < (INT8) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE())) ||
- ((INT8) Val->u8 > (INT8) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()))) {
+ if (((INT8) Val->u8 < (INT8) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE)) ||
+ ((INT8) Val->u8 > (INT8) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE))) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
- if (((INT16) Val->u16 < (INT16) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE())) ||
- ((INT16) Val->u16 > (INT16) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()))) {
+ if (((INT16) Val->u16 < (INT16) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE)) ||
+ ((INT16) Val->u16 > (INT16) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE))) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
- if (((INT32) Val->u32 < (INT32) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE())) ||
- ((INT32) Val->u32 > (INT32) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()))) {
+ if (((INT32) Val->u32 < (INT32) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE)) ||
+ ((INT32) Val->u32 > (INT32) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE))) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
- if (((INT64) Val->u64 < (INT64) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE())) ||
- ((INT64) Val->u64 > (INT64) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()))) {
+ if (((INT64) Val->u64 < (INT64) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE)) ||
+ ((INT64) Val->u64 > (INT64) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE))) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
break;
default:
break;
}
} else {
- if (Val->u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val->u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ if (Val->u32 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), TRUE) || Val->u32 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), TRUE)) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
+ }
+ } else {
+ if (Val->u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE) || Val->u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE)) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
+ }
}
}
}
if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
_PCATCH (VFR_RETURN_FATAL_ERROR, D->getLine(), "Default data type error.");
@@ -1742,21 +1894,29 @@ vfrStatementDefault :
default:
break;
}
} else {
- _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size), D->getLine());
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ Size = sizeof (UINT32);
+ } else {
+ _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size), D->getLine());
+ }
}
Size += OFFSET_OF (EFI_IFR_DEFAULT, Value);
DObj = new CIfrDefault ((UINT8)Size);
DObj->SetLineNo(D->getLine());
if (ArrayType) {
DObj->SetType (EFI_IFR_TYPE_BUFFER);
} else if (gIsStringOp) {
DObj->SetType (EFI_IFR_TYPE_STRING);
} else {
- DObj->SetType (_GET_CURRQEST_DATATYPE());
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ DObj->SetType (EFI_IFR_TYPE_NUM_SIZE_32);
+ } else {
+ DObj->SetType (_GET_CURRQEST_DATATYPE());
+ }
}
DObj->SetValue(*Val);
>>
| << IsExp = TRUE; DObj2 = new CIfrDefault2; DObj2->SetLineNo(D->getLine()); DObj2->SetScope (1); >>
vfrStatementValue "," << CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
@@ -2159,39 +2319,70 @@ vfrStatementBooleanType :
// default value = TRUE, defaultstore = MyDefaultStore,
// endcheckbox;
//
vfrStatementCheckBox :
<<
- CIfrCheckBox CBObj;
+ CIfrCheckBox *CBObj = NULL;
EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
CHAR8 *VarStoreName = NULL;
UINT32 DataTypeSize;
EFI_GUID *VarStoreGuid = NULL;
+ CIfrGuid *GuidObj = NULL;
+ EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;;
+ EFI_VARSTORE_INFO Info;
+ Info.mVarType = EFI_IFR_TYPE_OTHER;
+ Info.mVarTotalSize = 0;
+ Info.mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
+ Info.mVarStoreId = EFI_VARSTORE_ID_INVALID;
+ Info.mIsBitVar = FALSE;
>>
- L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[CBObj] "," << //check data type
+ L:CheckBox
+ vfrQuestionBaseInfo[Info, QId] <<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gBitVarstoreGuid);
+ GuidObj->SetLineNo(L->getLine());
+ }
+ CBObj = new CIfrCheckBox;
+ CBObj->SetLineNo(L->getLine());
+ CBObj->SetQuestionId (QId);
+ CBObj->SetVarStoreInfo (&Info);
+ >>
+ vfrStatementHeader[CBObj]"," << //check data type
if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
_GET_CURRQEST_VARTINFO().mVarType = EFI_IFR_TYPE_BOOLEAN;
}
if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
- _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
- if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support array");
- } else if ((gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&
- (_GET_CURRQEST_VARSIZE() != sizeof (BOOLEAN))) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");
+ //
+ // Check whether the question refers to a bit field, if yes. create a Guid to
+ // indicate the question refers to a bit field.
+ //
+ if (_GET_CURRQEST_VARTINFO ().mIsBitVar) {
+ _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
+ if ((gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER_BITS) &&
+ (_GET_CURRQEST_VARSIZE() != 1)) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only occupy 1 bit in Bit Varstore");
+ }
+ } else {
+ _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
+ if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support array");
+ } else if ((gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&
+ (_GET_CURRQEST_VARSIZE() != sizeof (BOOLEAN))) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");
+ }
}
}
>>
{
- F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
+ F:FLAGS "=" vfrCheckBoxFlags[*CBObj, F->getLine()] ","
<<
if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
_PCATCH(gCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
VarStoreGuid = gCVfrDataStorage.GetVarStoreGuid(_GET_CURRQEST_VARTINFO().mVarStoreId);
Val.b = TRUE;
- if (CBObj.GetFlags () & 0x01) {
+ if (CBObj->GetFlags () & 0x01) {
CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_STANDARD, F);
_PCATCH(
gCVfrDefaultStore.BufferVarStoreAltConfigAdd (
EFI_HII_DEFAULT_CLASS_STANDARD,
_GET_CURRQEST_VARTINFO(),
@@ -2203,11 +2394,11 @@ vfrStatementCheckBox :
VFR_RETURN_SUCCESS,
L,
"No standard default storage found"
);
}
- if (CBObj.GetFlags () & 0x02) {
+ if (CBObj->GetFlags () & 0x02) {
CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_MANUFACTURING, F);
_PCATCH(
gCVfrDefaultStore.BufferVarStoreAltConfigAdd (
EFI_HII_DEFAULT_CLASS_MANUFACTURING,
_GET_CURRQEST_VARTINFO(),
@@ -2223,14 +2414,21 @@ vfrStatementCheckBox :
}
}
>>
}
{
- Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
+ Key "=" KN:Number "," << AssignQuestionKey (*CBObj, KN); >>
}
vfrStatementQuestionOptionList
- E:EndCheckBox << CRT_END_OP (E); >>
+ E:EndCheckBox << CRT_END_OP (E);
+ if (GuidObj != NULL) {
+ GuidObj->SetScope(1);
+ CRT_END_OP (E);
+ delete GuidObj;
+ }
+ if (CBObj != NULL) delete CBObj;
+ >>
";"
;
vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
<<
@@ -2422,24 +2620,33 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;
UINT16 MaxU2 = 0, MinU2 = 0, StepU2 = 0;
UINT8 MaxU1 = 0, MinU1 = 0, StepU1 = 0;
BOOLEAN IntDecStyle = FALSE;
CIfrNumeric *NObj = (CIfrNumeric *) (&MMSDObj);
- if ((NObj->GetOpCode() == EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY) == 0)) {
- IntDecStyle = TRUE;
- }
BOOLEAN MinNegative = FALSE;
BOOLEAN MaxNegative = FALSE;
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ if ((NObj->GetOpCode() == EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY_BIT) == 0)) {
+ IntDecStyle = TRUE;
+ }
+ } else {
+ if ((NObj->GetOpCode() == EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY) == 0)) {
+ IntDecStyle = TRUE;
+ }
+ }
>>
Minimum "="
{
"\-" << MinNegative = TRUE; >>
}
I:Number "," <<
if (!IntDecStyle && MinNegative) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "\"-\" can't be used when not in int decimal type. ");
}
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ MinU4 = _STOU32(I->getText(), I->getLine());
+ } else {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 :
MinU8 = _STOU64(I->getText(), I->getLine());
if (IntDecStyle) {
if (MinNegative) {
@@ -2506,20 +2713,26 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
if (MinNegative) {
MinU1 = ~MinU1 + 1;
}
break;
}
+ }
>>
Maximum "="
{
"\-" << MaxNegative = TRUE; >>
}
A:Number "," <<
if (!IntDecStyle && MaxNegative) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "\"-\" can't be used when not in int decimal type. ");
}
-
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ MaxU4 = _STOU32(A->getText(), A->getLine());
+ if (!IntDecStyle && MaxU4 > pow (2,_GET_CURRQEST_VARTINFO().mVarTotalSize) -1) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "BIT type maximum can't big than 2^BitWidth -1");
+ }
+ } else {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 :
MaxU8 = _STOU64(A->getText(), A->getLine());
if (IntDecStyle) {
if (MaxNegative) {
@@ -2622,144 +2835,261 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
_PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
}
break;
}
+ }
>>
{
STEP "=" S:Number ","
<<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ StepU4 = _STOU32(S->getText(), S->getLine());
+ } else {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText(), S->getLine()); break;
case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText(), S->getLine()); break;
case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText(), S->getLine()); break;
case EFI_IFR_TYPE_NUM_SIZE_8 : StepU1 = _STOU8(S->getText(), S->getLine()); break;
}
+ }
>>
}
<<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4);
+ } else {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;
case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;
case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;
case EFI_IFR_TYPE_NUM_SIZE_8 : $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1); break;
}
+ }
>>
;
vfrStatementNumeric :
<<
- CIfrNumeric NObj;
+ CIfrNumeric *NObj = NULL;
UINT32 DataTypeSize;
BOOLEAN IsSupported = TRUE;
UINT8 ShrinkSize = 0;
+ CIfrGuid *GuidObj = NULL;
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
+ EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;;
+ EFI_VARSTORE_INFO Info;
+ Info.mVarType = EFI_IFR_TYPE_OTHER;
+ Info.mVarTotalSize = 0;
+ Info.mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
+ Info.mVarStoreId = EFI_VARSTORE_ID_INVALID;
+ Info.mIsBitVar = FALSE;
>>
- L:Numeric << NObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[NObj] "," << // check data type
+ L:Numeric << >>
+ vfrQuestionBaseInfo[Info, QId] <<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gBitVarstoreGuid);
+ GuidObj->SetLineNo(L->getLine());
+ }
+ NObj = new CIfrNumeric;
+ NObj->SetLineNo(L->getLine());
+ NObj->SetQuestionId (QId);
+ NObj->SetVarStoreInfo (&Info);
+ >>
+ vfrStatementHeader[NObj]","
+ <<
+ // check data type
if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
- _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");
- if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support array");
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ LFlags = (EFI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE()));
+ _PCATCH(NObj->SetFlagsForBitField (NObj->FLAGS(), LFlags), L->getLine());
+ } else {
+ _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");
+ if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support array");
+ }
+ _PCATCH(NObj->SetFlags (NObj->FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
}
- _PCATCH(NObj.SetFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
}
>>
- { F:FLAGS "=" vfrNumericFlags[NObj, F->getLine()] "," }
+ { F:FLAGS "=" vfrNumericFlags[*NObj, F->getLine()] "," }
{
- Key "=" KN:Number "," << AssignQuestionKey (NObj, KN); >>
+ Key "=" KN:Number "," << AssignQuestionKey (*NObj, KN); >>
}
- vfrSetMinMaxStep[NObj] <<
- switch (_GET_CURRQEST_DATATYPE()) {
- //
- // Base on the type to know the actual used size,shrink the buffer
- // size allocate before.
- //
- case EFI_IFR_TYPE_NUM_SIZE_8: ShrinkSize = 21;break;
- case EFI_IFR_TYPE_NUM_SIZE_16:ShrinkSize = 18;break;
- case EFI_IFR_TYPE_NUM_SIZE_32:ShrinkSize = 12;break;
- case EFI_IFR_TYPE_NUM_SIZE_64:break;
- default:
- IsSupported = FALSE;
- break;
+ vfrSetMinMaxStep[*NObj] <<
+ if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ switch (_GET_CURRQEST_DATATYPE()) {
+ //
+ // Base on the type to know the actual used size,shrink the buffer
+ // size allocate before.
+ //
+ case EFI_IFR_TYPE_NUM_SIZE_8: ShrinkSize = 21;break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:ShrinkSize = 18;break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:ShrinkSize = 12;break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:break;
+ default:
+ IsSupported = FALSE;
+ break;
+ }
+ } else {
+ ShrinkSize = 0;
}
- NObj.ShrinkBinSize (ShrinkSize);
+ NObj->ShrinkBinSize (ShrinkSize);
+
if (!IsSupported) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric question only support UINT8, UINT16, UINT32 and UINT64 data type.");
}
>>
vfrStatementQuestionOptionList
E:EndNumeric <<
- CRT_END_OP (E);
+ CRT_END_OP (E);
+ if (GuidObj != NULL) {
+ GuidObj->SetScope(1);
+ CRT_END_OP (E);
+ delete GuidObj;
+ }
+ if (NObj != NULL) delete NObj;
>>
";"
;
vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
<<
UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
- EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
BOOLEAN IsSetType = FALSE;
BOOLEAN IsDisplaySpecified = FALSE;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
>>
- numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified ] )*
+ numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum] )*
<<
//check data type flag
- if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
- VarStoreType = gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
- if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
- if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
- _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
+
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for name/value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
}
- } else {
- // update data type for name/value store
- UINT32 DataTypeSize;
+ } else if (IsSetType){
_GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
- gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
- _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
}
- } else if (IsSetType){
- _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ _PCATCH(NObj.SetFlags (HFlags, LFlags, IsDisplaySpecified), LineNum);
+ } else if ((_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) && (_GET_CURRQEST_VARTINFO().mIsBitVar)) {
+ LFlags |= (EFI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE()));
+ _PCATCH(NObj.SetFlagsForBitField (HFlags, LFlags, IsDisplaySpecified), LineNum);
}
- _PCATCH(NObj.SetFlags (HFlags, LFlags, IsDisplaySpecified), LineNum);
>>
;
-numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, BOOLEAN & IsSetType, BOOLEAN & IsDisplaySpecified] :
+numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, BOOLEAN & IsSetType, BOOLEAN & IsDisplaySpecified, UINT32 LineNum] :
N:Number << _PCATCH(_STOU8(N->getText(), N->getLine()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
- | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; IsSetType = TRUE;>>
- | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; IsSetType = TRUE;>>
- | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; IsSetType = TRUE;>>
- | "NUMERIC_SIZE_8" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; IsSetType = TRUE;>>
- | "DISPLAY_INT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; IsDisplaySpecified = TRUE;>>
- | "DISPLAY_UINT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; IsDisplaySpecified = TRUE;>>
- | "DISPLAY_UINT_HEX" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; IsDisplaySpecified = TRUE;>>
+ | "NUMERIC_SIZE_1" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1;IsSetType = TRUE;
+ } else {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Can not specifie the size of the numeric value for BIT field");
+ }
+ >>
+ | "NUMERIC_SIZE_2" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2;IsSetType = TRUE;
+ } else {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Can not specifie the size of the numeric value for BIT field");
+ }
+ >>
+ | "NUMERIC_SIZE_4" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; IsSetType = TRUE;
+ } else {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Can not specifie the size of the numeric value for BIT field");
+ }
+ >>
+ | "NUMERIC_SIZE_8" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; IsSetType = TRUE;
+ } else {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Can not specifie the size of the numeric value for BIT field");
+ }
+ >>
+ | "DISPLAY_INT_DEC" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC;
+ } else {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_INT_DEC_BIT;
+ }
+ IsDisplaySpecified = TRUE;
+ >>
+ | "DISPLAY_UINT_DEC" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC;
+ } else {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_UINT_DEC_BIT;
+ }
+ IsDisplaySpecified = TRUE;
+ >>
+ | "DISPLAY_UINT_HEX" << if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX;
+ } else {
+ $LFlags = ($LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_UINT_HEX_BIT;
+ }
+ IsDisplaySpecified = TRUE;
+ >>
| questionheaderFlagsField[HFlags]
;
vfrStatementOneOf :
<<
- CIfrOneOf OObj;
+ CIfrOneOf *OObj = NULL;
UINT32 DataTypeSize;
BOOLEAN IsSupported = TRUE;
UINT8 ShrinkSize = 0;
+ CIfrGuid *GuidObj = NULL;
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
+ EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;;
+ EFI_VARSTORE_INFO Info;
+ Info.mVarType = EFI_IFR_TYPE_OTHER;
+ Info.mVarTotalSize = 0;
+ Info.mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
+ Info.mVarStoreId = EFI_VARSTORE_ID_INVALID;
+ Info.mIsBitVar = FALSE;
>>
- L:OneOf << OObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[OObj] "," << //check data type
+ L:OneOf
+ vfrQuestionBaseInfo[Info, QId] <<
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gBitVarstoreGuid);
+ GuidObj->SetLineNo(L->getLine());
+ }
+ OObj = new CIfrOneOf;
+ OObj->SetLineNo(L->getLine());
+ OObj->SetQuestionId (QId);
+ OObj->SetVarStoreInfo (&Info);
+ >>
+ vfrStatementHeader[OObj]","
+ << //check data type
if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
- _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");
- if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array");
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ LFlags = (EFI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE()));
+ _PCATCH(OObj->SetFlagsForBitField (OObj->FLAGS(), LFlags), L->getLine());
+ } else {
+ _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");
+ if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array");
+ }
+ _PCATCH(OObj->SetFlags (OObj->FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
}
- _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
}
>>
- { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
+ { F:FLAGS "=" vfrOneofFlagsField[*OObj, F->getLine()] "," }
{
- vfrSetMinMaxStep[OObj]
+ vfrSetMinMaxStep[*OObj]
}
<<
+ if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
switch (_GET_CURRQEST_DATATYPE()) {
//
// Base on the type to know the actual used size,shrink the buffer
// size allocate before.
//
@@ -2769,50 +3099,63 @@ vfrStatementOneOf :
case EFI_IFR_TYPE_NUM_SIZE_64:break;
default:
IsSupported = FALSE;
break;
}
- OObj.ShrinkBinSize (ShrinkSize);
+ } else {
+ ShrinkSize = 0;
+ }
+ OObj->ShrinkBinSize (ShrinkSize);
+
if (!IsSupported) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf question only support UINT8, UINT16, UINT32 and UINT64 data type.");
}
>>
vfrStatementQuestionOptionList
E:EndOneOf <<
- CRT_END_OP (E);
+ CRT_END_OP (E);
+ if (GuidObj != NULL) {
+ GuidObj->SetScope(1);
+ CRT_END_OP (E);
+ delete GuidObj;
+ }
+ if (OObj != NULL) delete OObj;
>>
";"
;
vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
<<
UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
- EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
BOOLEAN IsSetType = FALSE;
BOOLEAN IsDisplaySpecified = FALSE;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
>>
- numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] )*
+ numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum] )*
<<
//check data type flag
- if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
- VarStoreType = gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
- if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
- if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
- _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ if (!_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for Name/Value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
}
- } else {
- // update data type for Name/Value store
- UINT32 DataTypeSize;
+ } else if (IsSetType){
_GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
- gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
- _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
}
- } else if (IsSetType){
- _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
+ } else if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
+ _PCATCH(OObj.SetFlagsForBitField (HFlags, LFlags), LineNum);
}
- _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
>>
;
vfrStatementStringType :
vfrStatementString |
@@ -3363,10 +3706,13 @@ vfrStatementOneOfOption :
Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayType] ","
<<
if (gCurrentMinMaxData != NULL) {
//set min/max value for oneof opcode
UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ gCurrentMinMaxData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step);
+ } else {
switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64:
gCurrentMinMaxData->SetMinMaxStepData(Val->u64, Val->u64, Step);
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
@@ -3379,10 +3725,11 @@ vfrStatementOneOfOption :
gCurrentMinMaxData->SetMinMaxStepData(Val->u8, Val->u8, (UINT8) Step);
break;
default:
break;
}
+ }
}
if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
Size = sizeof (EFI_IFR_TYPE_VALUE);
} else if (ArrayType) {
switch (_GET_CURRQEST_DATATYPE()) {
@@ -3411,11 +3758,15 @@ vfrStatementOneOfOption :
break;
default:
break;
}
} else {
- ReturnCode = gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size);
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ Size = sizeof (UINT32);
+ } else {
+ ReturnCode = gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size);
+ }
}
if (ReturnCode != VFR_RETURN_SUCCESS) {
_PCATCH (ReturnCode, L->getLine());
}
@@ -3424,11 +3775,15 @@ vfrStatementOneOfOption :
OOOObj->SetLineNo(L->getLine());
OOOObj->SetOption (_STOSID(S->getText(), S->getLine()));
if (ArrayType) {
OOOObj->SetType (EFI_IFR_TYPE_BUFFER);
} else {
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ OOOObj->SetType ( EFI_IFR_TYPE_NUM_SIZE_32);
+ } else {
OOOObj->SetType (_GET_CURRQEST_DATATYPE());
+ }
}
OOOObj->SetValue (*Val);
>>
F:FLAGS "=" vfrOneOfOptionFlags[*OOOObj, F->getLine()]
<<
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 2f97975..7ebf95a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -1,10 +1,10 @@
/** @file
Vfr common library functions.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -575,10 +575,19 @@ CVfrVarDataTypeDB::RegisterNewType (
{
New->mNext = mDataTypeList;
mDataTypeList = New;
}
+VOID
+CVfrVarDataTypeDB::RegisterNewBitsType (
+ IN SVfrDataType *New
+ )
+{
+ New->mNext = mBitsTypeList;
+ mBitsTypeList = New;
+}
+
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractStructTypeName (
IN CHAR8 *&VarStr,
OUT CHAR8 *TName
)
@@ -598,10 +607,53 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
}
return VFR_RETURN_SUCCESS;
}
+BOOLEAN
+CVfrVarDataTypeDB::DataTypeHasBitField (
+ IN CHAR8 *TypeName
+ )
+{
+ SVfrDataType *pType = NULL;
+ SVfrDataField *pTmp;
+
+ GetDataType (TypeName, &pType);
+ for (pTmp = pType->mMembers; pTmp!= NULL; pTmp = pTmp->mNext) {
+ if (pTmp->mIsBitField) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOLEAN
+CVfrVarDataTypeDB::IsThisBitField (
+ IN CHAR8 *VarStr
+ )
+{
+ CHAR8 FName[MAX_NAME_LEN];
+ CHAR8 TName[MAX_NAME_LEN];
+ UINT32 ArrayIdx;
+ SVfrDataType *pType = NULL;
+ SVfrDataField *pField = NULL;
+
+ CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SUCCESS);
+ CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS);
+
+ while (*VarStr != '\0') {
+ CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
+ CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
+ pType = pField->mFieldType;
+ }
+ if (pField->mIsBitField) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
IN CHAR8 *&VarStr,
IN CHAR8 *FName,
OUT UINT32 &ArrayIdx
@@ -695,11 +747,13 @@ CVfrVarDataTypeDB::GetTypeField (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetFieldOffset (
IN SVfrDataField *Field,
IN UINT32 ArrayIdx,
- OUT UINT32 &Offset
+ OUT UINT32 &Offset,
+ IN BOOLEAN IsBitField,
+ IN BOOLEAN IsBitVarStore
)
{
if (Field == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
@@ -727,12 +781,17 @@ CVfrVarDataTypeDB::GetFieldOffset (
//
// if ((ArrayIdx == INVALID_ARRAY_INDEX) && (Field->mArrayNum > 0)) {
// return VFR_RETURN_ERROR_ARRARY_NUM;
// }
//
-
- Offset = Field->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx == INVALID_ARRAY_INDEX) ? 0 : ArrayIdx);
+ if (IsBitField) {
+ Offset = Field->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx == INVALID_ARRAY_INDEX) ? 0 : ArrayIdx) * 8;
+ } else if (IsBitVarStore) {
+ Offset = (Field->mOffset / 8) + Field->mFieldType->mTotalSize * ((ArrayIdx == INVALID_ARRAY_INDEX) ? 0 : ArrayIdx);
+ } else {
+ Offset = Field->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx == INVALID_ARRAY_INDEX) ? 0 : ArrayIdx);
+ }
return VFR_RETURN_SUCCESS;
}
UINT8
CVfrVarDataTypeDB::GetFieldWidth (
@@ -747,21 +806,26 @@ CVfrVarDataTypeDB::GetFieldWidth (
}
UINT32
CVfrVarDataTypeDB::GetFieldSize (
IN SVfrDataField *Field,
- IN UINT32 ArrayIdx
+ IN UINT32 ArrayIdx,
+ IN BOOLEAN IsBitField
)
{
if (Field == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
if ((ArrayIdx == INVALID_ARRAY_INDEX) && (Field->mArrayNum != 0)) {
- return Field->mFieldType->mTotalSize * Field->mArrayNum;
+ return Field->mFieldType->mTotalSize * Field->mArrayNum;
} else {
- return Field->mFieldType->mTotalSize;
+ if (IsBitField) {
+ return Field->mBitWidth;
+ } else {
+ return Field->mFieldType->mTotalSize;
+ }
}
}
VOID
CVfrVarDataTypeDB::InternalTypesListInit (
@@ -786,22 +850,25 @@ CVfrVarDataTypeDB::InternalTypesListInit (
strcpy (pYearField->mFieldName, "Year");
GetDataType ((CHAR8 *)"UINT16", &pYearField->mFieldType);
pYearField->mOffset = 0;
pYearField->mNext = pMonthField;
pYearField->mArrayNum = 0;
+ pYearField->mIsBitField = FALSE;
strcpy (pMonthField->mFieldName, "Month");
GetDataType ((CHAR8 *)"UINT8", &pMonthField->mFieldType);
pMonthField->mOffset = 2;
pMonthField->mNext = pDayField;
pMonthField->mArrayNum = 0;
+ pMonthField->mIsBitField = FALSE;
strcpy (pDayField->mFieldName, "Day");
GetDataType ((CHAR8 *)"UINT8", &pDayField->mFieldType);
pDayField->mOffset = 3;
pDayField->mNext = NULL;
pDayField->mArrayNum = 0;
+ pDayField->mIsBitField = FALSE;
New->mMembers = pYearField;
} else if (strcmp (gInternalTypesTable[Index].mTypeName, "EFI_HII_TIME") == 0) {
SVfrDataField *pHoursField = new SVfrDataField;
SVfrDataField *pMinutesField = new SVfrDataField;
@@ -810,22 +877,25 @@ CVfrVarDataTypeDB::InternalTypesListInit (
strcpy (pHoursField->mFieldName, "Hours");
GetDataType ((CHAR8 *)"UINT8", &pHoursField->mFieldType);
pHoursField->mOffset = 0;
pHoursField->mNext = pMinutesField;
pHoursField->mArrayNum = 0;
+ pHoursField->mIsBitField = FALSE;
strcpy (pMinutesField->mFieldName, "Minutes");
GetDataType ((CHAR8 *)"UINT8", &pMinutesField->mFieldType);
pMinutesField->mOffset = 1;
pMinutesField->mNext = pSecondsField;
pMinutesField->mArrayNum = 0;
+ pMinutesField->mIsBitField = FALSE;
strcpy (pSecondsField->mFieldName, "Seconds");
GetDataType ((CHAR8 *)"UINT8", &pSecondsField->mFieldType);
pSecondsField->mOffset = 2;
pSecondsField->mNext = NULL;
pSecondsField->mArrayNum = 0;
+ pSecondsField->mIsBitField = FALSE;
New->mMembers = pHoursField;
} else if (strcmp (gInternalTypesTable[Index].mTypeName, "EFI_HII_REF") == 0) {
SVfrDataField *pQuestionIdField = new SVfrDataField;
SVfrDataField *pFormIdField = new SVfrDataField;
@@ -835,28 +905,32 @@ CVfrVarDataTypeDB::InternalTypesListInit (
strcpy (pQuestionIdField->mFieldName, "QuestionId");
GetDataType ((CHAR8 *)"UINT16", &pQuestionIdField->mFieldType);
pQuestionIdField->mOffset = 0;
pQuestionIdField->mNext = pFormIdField;
pQuestionIdField->mArrayNum = 0;
+ pQuestionIdField->mIsBitField = FALSE;
strcpy (pFormIdField->mFieldName, "FormId");
GetDataType ((CHAR8 *)"UINT16", &pFormIdField->mFieldType);
pFormIdField->mOffset = 2;
pFormIdField->mNext = pFormSetGuidField;
pFormIdField->mArrayNum = 0;
+ pFormIdField->mIsBitField = FALSE;
strcpy (pFormSetGuidField->mFieldName, "FormSetGuid");
GetDataType ((CHAR8 *)"EFI_GUID", &pFormSetGuidField->mFieldType);
pFormSetGuidField->mOffset = 4;
pFormSetGuidField->mNext = pDevicePathField;
pFormSetGuidField->mArrayNum = 0;
+ pFormSetGuidField->mIsBitField = FALSE;
strcpy (pDevicePathField->mFieldName, "DevicePath");
GetDataType ((CHAR8 *)"EFI_STRING_ID", &pDevicePathField->mFieldType);
pDevicePathField->mOffset = 20;
pDevicePathField->mNext = NULL;
pDevicePathField->mArrayNum = 0;
+ pDevicePathField->mIsBitField = FALSE;
New->mMembers = pQuestionIdField;
} else {
New->mMembers = NULL;
}
@@ -870,10 +944,11 @@ CVfrVarDataTypeDB::InternalTypesListInit (
CVfrVarDataTypeDB::CVfrVarDataTypeDB (
VOID
)
{
mDataTypeList = NULL;
+ mBitsTypeList = NULL;
mNewDataType = NULL;
mCurrDataField = NULL;
mPackAlign = DEFAULT_PACK_ALIGN;
mPackStack = NULL;
mFirstNewDataTypeName = NULL;
@@ -899,11 +974,22 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
while(pType->mMembers != NULL) {
pField = pType->mMembers;
pType->mMembers = pType->mMembers->mNext;
delete pField;
}
- delete pType;
+ delete pType;
+ }
+
+ while (mBitsTypeList != NULL) {
+ pType = mBitsTypeList;
+ mBitsTypeList = mBitsTypeList->mNext;
+ while(pType->mMembers != NULL) {
+ pField = pType->mMembers;
+ pType->mMembers = pType->mMembers->mNext;
+ delete pField;
+ }
+ delete pType;
}
while (mPackStack != NULL) {
pPack = mPackStack;
mPackStack = mPackStack->mNext;
@@ -976,10 +1062,11 @@ CVfrVarDataTypeDB::DeclareDataTypeBegin (
pNewType->mType = EFI_IFR_TYPE_OTHER;
pNewType->mAlign = DEFAULT_ALIGN;
pNewType->mTotalSize = 0;
pNewType->mMembers = NULL;
pNewType->mNext = NULL;
+ pNewType->mHasBitField = FALSE;
mNewDataType = pNewType;
}
EFI_VFR_RETURN_CODE
@@ -1008,10 +1095,67 @@ CVfrVarDataTypeDB::SetNewTypeName (
strcpy(mNewDataType->mTypeName, TypeName);
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
+CVfrVarDataTypeDB::DataTypeAddBitField (
+ IN CHAR8 *FieldName,
+ IN CHAR8 *TypeName,
+ IN UINT32 Width
+ )
+{
+ SVfrDataField *pNewField = NULL;
+ SVfrDataType *pFieldType = NULL;
+ SVfrDataField *pTmp;
+ UINT32 Align;
+
+ CHECK_ERROR_RETURN (GetDataType (TypeName, &pFieldType), VFR_RETURN_SUCCESS);
+
+ if (Width > MAX_BIT_WIDTH) {
+ return VFR_RETURN_BIT_WIDTH_ERROR;
+ }
+
+ if (Width > pFieldType->mTotalSize * 8) {
+ return VFR_RETURN_BIT_WIDTH_ERROR;
+ }
+
+ if (strlen (FieldName) >= MAX_NAME_LEN) {
+ return VFR_RETURN_INVALID_PARAMETER;
+ }
+
+ for (pTmp = mNewDataType->mMembers; pTmp != NULL; pTmp = pTmp->mNext) {
+ if (strcmp (pTmp->mFieldName, FieldName) == 0) {
+ return VFR_RETURN_REDEFINED;
+ }
+ }
+
+ if ((pNewField = new SVfrDataField) == NULL) {
+ return VFR_RETURN_OUT_FOR_RESOURCES;
+ }
+
+ strcpy (pNewField->mFieldName, FieldName);
+ pNewField->mFieldType = pFieldType;
+ pNewField->mIsBitField = TRUE;
+ pNewField->mBitWidth = Width;
+
+ if (mNewDataType->mMembers == NULL) {
+ mNewDataType->mMembers = pNewField;
+ pNewField->mNext = NULL;
+ pNewField->mOffset = 0;
+ } else {
+ for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
+ ;
+ pTmp->mNext = pNewField;
+ pNewField->mNext = NULL;
+ }
+
+ mNewDataType->mHasBitField = TRUE;
+
+ return VFR_RETURN_SUCCESS;
+}
+
+EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::DataTypeAddField (
IN CHAR8 *FieldName,
IN CHAR8 *TypeName,
IN UINT32 ArrayNum
)
@@ -1039,10 +1183,11 @@ CVfrVarDataTypeDB::DataTypeAddField (
return VFR_RETURN_OUT_FOR_RESOURCES;
}
strcpy (pNewField->mFieldName, FieldName);
pNewField->mFieldType = pFieldType;
pNewField->mArrayNum = ArrayNum;
+ pNewField->mIsBitField = FALSE;
if ((mNewDataType->mTotalSize % Align) == 0) {
pNewField->mOffset = mNewDataType->mTotalSize;
} else {
pNewField->mOffset = mNewDataType->mTotalSize + ALIGN_STUFF(mNewDataType->mTotalSize, Align);
}
@@ -1061,20 +1206,112 @@ CVfrVarDataTypeDB::DataTypeAddField (
return VFR_RETURN_SUCCESS;
}
VOID
+CVfrVarDataTypeDB::ChangeFieldToBitRepresentation(
+ IN SVfrDataType *DataType
+ )
+{
+
+ SVfrDataField *pTmp;
+ SVfrDataField *pSTmp;
+ UINT32 Offset;
+ UINT8 Width;
+ UINT32 TotalSize;
+
+ Offset = 0;
+ Width = 0;
+ TotalSize = 0;
+
+ for (pTmp = DataType->mMembers; pTmp != NULL; pTmp = pTmp->mNext) {
+ if (pTmp->mIsBitField) {
+ pSTmp = pTmp;
+ while (pSTmp != NULL && pSTmp->mIsBitField) {
+ pSTmp->mOffset = Offset;
+ pTmp = pSTmp;
+ if ((pSTmp->mNext != NULL) &&!(pSTmp->mNext->mIsBitField)) {
+ //
+ // Currect field is bit field, but next field is not bit field
+ //
+ if (Width > 0){
+ TotalSize += pSTmp->mFieldType->mTotalSize;
+ Width += pSTmp->mBitWidth;
+ if (Width >= pSTmp->mFieldType->mTotalSize * 8) {
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ pSTmp->mOffset = Offset;
+ } else {
+ pSTmp->mOffset += (Width - pSTmp->mBitWidth);
+ }
+ Width = 0;
+ }
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ TotalSize += pSTmp->mFieldType->mTotalSize;
+ break;
+ } else if ((pSTmp->mNext != NULL) && strcmp (pSTmp->mFieldType->mTypeName,pSTmp->mNext->mFieldType->mTypeName) !=0) {
+ //
+ // Currect field is bit field, and next field is also bit field,
+ // but they have different type name.
+ //
+ if (Width > 0){
+ Width += pSTmp->mBitWidth;
+ if (Width >= pSTmp->mFieldType->mTotalSize * 8) {
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ pSTmp->mOffset = Offset;
+ } else {
+ pSTmp->mOffset += (Width - pSTmp->mBitWidth);
+ }
+ Width = 0;
+ }
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ TotalSize += pSTmp->mFieldType->mTotalSize;
+ break;
+ }else {
+ pSTmp->mOffset += Width;
+ Width += pSTmp->mBitWidth;
+ if (Width >= pSTmp->mFieldType->mTotalSize * 8) {
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ TotalSize += pSTmp->mFieldType->mTotalSize;
+ pSTmp->mOffset = Offset;
+ Width = pSTmp->mBitWidth;;
+ break;
+ }
+ }
+ if (pSTmp->mNext == NULL) {
+ Offset += pSTmp->mFieldType->mTotalSize * 8;
+ TotalSize += pSTmp->mFieldType->mTotalSize;
+ Width = 0;
+ break;
+ }
+ pSTmp = pSTmp->mNext;
+ }
+ } else {
+ pTmp->mOffset = Offset;
+ pTmp->mBitWidth = pTmp->mFieldType->mTotalSize * 8;
+ Offset += (pTmp->mFieldType->mTotalSize *((pTmp->mArrayNum == 0) ? 1 : pTmp->mArrayNum)) * 8;
+ TotalSize += (pTmp->mFieldType->mTotalSize *((pTmp->mArrayNum == 0) ? 1 : pTmp->mArrayNum));
+ }
+ }
+
+ DataType->mTotalSize = TotalSize;
+}
+
+VOID
CVfrVarDataTypeDB::DeclareDataTypeEnd (
VOID
)
{
if (mNewDataType->mTypeName[0] == '\0') {
return;
}
- if ((mNewDataType->mTotalSize % mNewDataType->mAlign) !=0) {
- mNewDataType->mTotalSize += ALIGN_STUFF (mNewDataType->mTotalSize, mNewDataType->mAlign);
+ if (mNewDataType->mHasBitField) {
+ ChangeFieldToBitRepresentation (mNewDataType);
+ } else {
+ if ((mNewDataType->mTotalSize % mNewDataType->mAlign) !=0) {
+ mNewDataType->mTotalSize += ALIGN_STUFF (mNewDataType->mTotalSize, mNewDataType->mAlign);
+ }
}
RegisterNewType (mNewDataType);
if (mFirstNewDataTypeName == NULL) {
mFirstNewDataTypeName = mNewDataType->mTypeName;
@@ -1177,36 +1414,53 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
{
CHAR8 TName[MAX_NAME_LEN], FName[MAX_NAME_LEN];
UINT32 ArrayIdx, Tmp;
SVfrDataType *pType = NULL;
SVfrDataField *pField = NULL;
+ BOOLEAN IsNestBitField;
+ BOOLEAN IsBitVarStore;
+ BOOLEAN IsBitField;
+ CHAR8 *VarStrName;
Offset = 0;
Type = EFI_IFR_TYPE_OTHER;
Size = 0;
+ VarStrName = VarStr;
CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SUCCESS);
CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS);
+ IsBitVarStore = DataTypeHasBitField (TName);
+
+ IsBitField = IsThisBitField (VarStrName);
+
//
// if it is not struct data type
//
Type = pType->mType;
Size = pType->mTotalSize;
while (*VarStr != '\0') {
- CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
+ CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
pType = pField->mFieldType;
- CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp), VFR_RETURN_SUCCESS);
- Offset = (UINT16) (Offset + Tmp);
+ IsNestBitField = pField->mIsBitField;
+ if (!IsBitField && IsNestBitField) {
+ CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsNestBitField, IsBitVarStore), VFR_RETURN_SUCCESS);
+ Offset = (UINT16) (Offset * 8 + Tmp);
+ Size = GetFieldSize (pField, ArrayIdx, IsNestBitField);
+ } else {
+ CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsBitField, IsBitVarStore), VFR_RETURN_SUCCESS);
+ Offset = (UINT16) (Offset + Tmp);
+ Size = GetFieldSize (pField, ArrayIdx, IsBitField);
+ }
Type = GetFieldWidth (pField);
- Size = GetFieldSize (pField, ArrayIdx);
}
return VFR_RETURN_SUCCESS;
}
+
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetUserDefinedTypeNameList (
OUT CHAR8 ***NameList,
OUT UINT32 *ListSize
)
@@ -1347,10 +1601,11 @@ SVfrVarStorageNode::SVfrVarStorageNode (
SVfrVarStorageNode::SVfrVarStorageNode (
IN EFI_GUID *Guid,
IN CHAR8 *StoreName,
IN EFI_VARSTORE_ID VarStoreId,
IN SVfrDataType *DataType,
+ IN BOOLEAN BitsVarstore,
IN BOOLEAN Flag
)
{
if (Guid != NULL) {
mGuid = *Guid;
@@ -1363,11 +1618,15 @@ SVfrVarStorageNode::SVfrVarStorageNode (
} else {
mVarStoreName = NULL;
}
mNext = NULL;
mVarStoreId = VarStoreId;
- mVarStoreType = EFI_VFR_VARSTORE_BUFFER;
+ if (BitsVarstore) {
+ mVarStoreType = EFI_VFR_VARSTORE_BUFFER_BITS;
+ } else {
+ mVarStoreType = EFI_VFR_VARSTORE_BUFFER;
+ }
mStorageInfo.mDataType = DataType;
mAssignedFlag = Flag;
}
SVfrVarStorageNode::SVfrVarStorageNode (
@@ -1415,10 +1674,11 @@ CVfrDataStorage::CVfrDataStorage (
mFreeVarStoreIdBitMap[0] = 0x80000000;
mBufferVarStoreList = NULL;
mEfiVarStoreList = NULL;
mNameVarStoreList = NULL;
+ mBitsBufferStoreList = NULL;
mCurrVarStorageNode = NULL;
mNewVarStorageNode = NULL;
mBufferFieldInfoListHead = NULL;
mBufferFieldInfoListTail = NULL;
}
@@ -1442,10 +1702,15 @@ CVfrDataStorage::~CVfrDataStorage (
while (mNameVarStoreList != NULL) {
pNode = mNameVarStoreList;
mNameVarStoreList = mNameVarStoreList->mNext;
delete pNode;
}
+ while ( mBitsBufferStoreList != NULL) {
+ pNode = mBitsBufferStoreList;
+ mBitsBufferStoreList = mBitsBufferStoreList->mNext;
+ delete pNode;
+ }
if (mNewVarStorageNode != NULL) {
delete mNewVarStorageNode;
}
}
@@ -1661,11 +1926,11 @@ CVfrDataStorage::DeclareBufferVarStore (
return VFR_RETURN_VARSTOREID_REDEFINED;
}
MarkVarStoreIdUsed (VarStoreId);
}
- if ((pNew = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pDataType, Flag)) == NULL) {
+ if ((pNew = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pDataType, FALSE, Flag)) == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
pNew->mNext = mBufferVarStoreList;
mBufferVarStoreList = pNew;
@@ -1676,10 +1941,57 @@ CVfrDataStorage::DeclareBufferVarStore (
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
+CVfrDataStorage::DeclareBitsBufferVarStore (
+ IN CHAR8 *StoreName,
+ IN EFI_GUID *Guid,
+ IN CVfrVarDataTypeDB *DataTypeDB,
+ IN CHAR8 *TypeName,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN BOOLEAN Flag
+ )
+{
+ SVfrVarStorageNode *pNew = NULL;
+ SVfrDataType *pDataType = NULL;
+ EFI_VARSTORE_ID TempVarStoreId;
+
+ if ((StoreName == NULL) || (Guid == NULL) || (DataTypeDB == NULL)) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+
+ if (GetVarStoreId (StoreName, &TempVarStoreId, Guid) == VFR_RETURN_SUCCESS) {
+ return VFR_RETURN_REDEFINED;
+ }
+
+ CHECK_ERROR_RETURN(DataTypeDB->GetDataType (TypeName, &pDataType), VFR_RETURN_SUCCESS);
+
+ if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
+ VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_BUFFER);
+ } else {
+ if (ChekVarStoreIdFree (VarStoreId) == FALSE) {
+ return VFR_RETURN_VARSTOREID_REDEFINED;
+ }
+ MarkVarStoreIdUsed (VarStoreId);
+ }
+
+ if ((pNew = new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pDataType, TRUE, Flag)) == NULL) {
+ return VFR_RETURN_OUT_FOR_RESOURCES;
+ }
+
+ pNew->mNext = mBitsBufferStoreList;
+ mBitsBufferStoreList = pNew;
+
+ if (gCVfrBufferConfig.Register(StoreName, Guid) != 0) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+
+ return VFR_RETURN_SUCCESS;
+}
+
+EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreByDataType (
IN CHAR8 *DataTypeName,
OUT SVfrVarStorageNode **VarNode,
IN EFI_GUID *VarGuid
)
@@ -1813,10 +2125,18 @@ CVfrDataStorage::GetVarStoreId (
*VarStoreId = mCurrVarStorageNode->mVarStoreId;
return ReturnCode;
}
}
}
+ for (pNode = mBitsBufferStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (strcmp (pNode->mVarStoreName, StoreName) == 0) {
+ if (CheckGuidField(pNode, StoreGuid, &HasFoundOne, &ReturnCode)) {
+ *VarStoreId = mCurrVarStorageNode->mVarStoreId;
+ return ReturnCode;
+ }
+ }
+ }
if (HasFoundOne) {
*VarStoreId = mCurrVarStorageNode->mVarStoreId;
return VFR_RETURN_SUCCESS;
}
@@ -1852,10 +2172,17 @@ CVfrDataStorage::GetBufferVarStoreDataTypeName (
*DataTypeName = pNode->mStorageInfo.mDataType->mTypeName;
return VFR_RETURN_SUCCESS;
}
}
+ for (pNode = mBitsBufferStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ *DataTypeName = pNode->mStorageInfo.mDataType->mTypeName;
+ return VFR_RETURN_SUCCESS;
+ }
+ }
+
return VFR_RETURN_UNDEFINED;
}
EFI_VFR_VARSTORE_TYPE
CVfrDataStorage::GetVarStoreType (
@@ -1890,10 +2217,17 @@ CVfrDataStorage::GetVarStoreType (
VarStoreType = pNode->mVarStoreType;
return VarStoreType;
}
}
+ for (pNode = mBitsBufferStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
return VarStoreType;
}
EFI_GUID *
CVfrDataStorage::GetVarStoreGuid (
@@ -1928,10 +2262,17 @@ CVfrDataStorage::GetVarStoreGuid (
VarGuid = &pNode->mGuid;
return VarGuid;
}
}
+ for (pNode = mBitsBufferStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarGuid = &pNode->mGuid;
+ return VarGuid;
+ }
+ }
+
return VarGuid;
}
EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreName (
@@ -1964,10 +2305,18 @@ CVfrDataStorage::GetVarStoreName (
*VarStoreName = pNode->mVarStoreName;
return VFR_RETURN_SUCCESS;
}
}
+ for (pNode = mBitsBufferStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ *VarStoreName = pNode->mVarStoreName;
+ return VFR_RETURN_SUCCESS;
+ }
+ }
+
+
*VarStoreName = NULL;
return VFR_RETURN_UNDEFINED;
}
EFI_VFR_RETURN_CODE
@@ -2375,10 +2724,11 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
mVarStoreId = EFI_VARSTORE_ID_INVALID;
mInfo.mVarName = EFI_STRING_ID_INVALID;
mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
mVarType = EFI_IFR_TYPE_OTHER;
mVarTotalSize = 0;
+ mIsBitVar = FALSE;
}
EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
IN EFI_VARSTORE_INFO &Info
)
@@ -2386,10 +2736,11 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
mVarStoreId = Info.mVarStoreId;
mInfo.mVarName = Info.mInfo.mVarName;
mInfo.mVarOffset = Info.mInfo.mVarOffset;
mVarType = Info.mVarType;
mVarTotalSize = Info.mVarTotalSize;
+ mIsBitVar = Info.mIsBitVar;
}
EFI_VARSTORE_INFO&
EFI_VARSTORE_INFO::operator= (
IN CONST EFI_VARSTORE_INFO &Info
@@ -2399,10 +2750,11 @@ EFI_VARSTORE_INFO::operator= (
mVarStoreId = Info.mVarStoreId;
mInfo.mVarName = Info.mInfo.mVarName;
mInfo.mVarOffset = Info.mInfo.mVarOffset;
mVarType = Info.mVarType;
mVarTotalSize = Info.mVarTotalSize;
+ mIsBitVar = Info.mIsBitVar;
}
return *this;
}
@@ -2413,11 +2765,12 @@ EFI_VARSTORE_INFO::operator == (
{
if ((mVarStoreId == Info->mVarStoreId) &&
(mInfo.mVarName == Info->mInfo.mVarName) &&
(mInfo.mVarOffset == Info->mInfo.mVarOffset) &&
(mVarType == Info->mVarType) &&
- (mVarTotalSize == Info->mVarTotalSize)) {
+ (mVarTotalSize == Info->mVarTotalSize) &&
+ (mIsBitVar == Info->mIsBitVar)) {
return TRUE;
}
return FALSE;
}
@@ -3715,11 +4068,12 @@ CVfrStringDB::GetUnicodeStringTextSize (
}
return StringSize;
}
-BOOLEAN VfrCompatibleMode = FALSE;
+BOOLEAN VfrCompatibleMode = FALSE;
+EFI_GUID gBitVarstoreGuid = {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 0xA8, 0xFD, 0x60 ,0xA7 , 0x1D}};
CVfrVarDataTypeDB gCVfrVarDataTypeDB;
CVfrDefaultStore gCVfrDefaultStore;
CVfrDataStorage gCVfrDataStorage;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index 59509c3..4a73130 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -1,10 +1,10 @@
/** @file
Vfr common library functions.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, 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
@@ -20,11 +20,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Common/UefiBaseTypes.h"
#include "EfiVfr.h"
#include "VfrError.h"
extern BOOLEAN VfrCompatibleMode;
+extern EFI_GUID gBitVarstoreGuid;
+#define MAX_BIT_WIDTH 32
#define MAX_NAME_LEN 64
#define MAX_STRING_LEN 0x100
#define DEFAULT_ALIGN 1
#define DEFAULT_PACK_ALIGN 0x8
#define DEFAULT_NAME_TABLE_ITEMS 1024
@@ -114,18 +116,21 @@ struct SVfrDataType;
struct SVfrDataField {
CHAR8 mFieldName[MAX_NAME_LEN];
SVfrDataType *mFieldType;
UINT32 mOffset;
UINT32 mArrayNum;
+ BOOLEAN mIsBitField;
+ UINT8 mBitWidth;
SVfrDataField *mNext;
};
struct SVfrDataType {
CHAR8 mTypeName[MAX_NAME_LEN];
UINT8 mType;
UINT32 mAlign;
UINT32 mTotalSize;
+ BOOLEAN mHasBitField;
SVfrDataField *mMembers;
SVfrDataType *mNext;
};
#define VFR_PACK_ASSIGN 0x01
@@ -183,40 +188,46 @@ private:
public:
EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN CHAR8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);
private:
SVfrDataType *mDataTypeList;
+ SVfrDataType *mBitsTypeList;
SVfrDataType *mNewDataType;
SVfrDataType *mCurrDataType;
SVfrDataField *mCurrDataField;
VOID InternalTypesListInit (VOID);
VOID RegisterNewType (IN SVfrDataType *);
+ VOID RegisterNewBitsType (IN SVfrDataType *);
EFI_VFR_RETURN_CODE ExtractStructTypeName (IN CHAR8 *&, OUT CHAR8 *);
EFI_VFR_RETURN_CODE GetTypeField (IN CONST CHAR8 *, IN SVfrDataType *, IN SVfrDataField *&);
- EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT UINT32 &);
+ EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT UINT32 &, IN BOOLEAN, IN BOOLEAN);
UINT8 GetFieldWidth (IN SVfrDataField *);
- UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32);
+ UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32, IN BOOLEAN);
public:
CVfrVarDataTypeDB (VOID);
~CVfrVarDataTypeDB (VOID);
VOID DeclareDataTypeBegin (VOID);
EFI_VFR_RETURN_CODE SetNewTypeName (IN CHAR8 *);
EFI_VFR_RETURN_CODE DataTypeAddField (IN CHAR8 *, IN CHAR8 *, IN UINT32);
+ EFI_VFR_RETURN_CODE DataTypeAddBitField (IN CHAR8 *, IN CHAR8 *, IN UINT32);
VOID DeclareDataTypeEnd (VOID);
+ VOID ChangeFieldToBitRepresentation( IN SVfrDataType *);
EFI_VFR_RETURN_CODE GetDataType (IN CHAR8 *, OUT SVfrDataType **);
EFI_VFR_RETURN_CODE GetDataTypeSize (IN CHAR8 *, OUT UINT32 *);
EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT CHAR8 ***, OUT UINT32 *);
EFI_VFR_RETURN_CODE ExtractFieldNameAndArrary (IN CHAR8 *&, OUT CHAR8 *, OUT UINT32 &);
+ BOOLEAN DataTypeHasBitField (IN CHAR8 *);
+ BOOLEAN IsThisBitField (IN CHAR8 *);
BOOLEAN IsTypeNameDefined (IN CHAR8 *);
VOID Dump(IN FILE *);
//
@@ -236,11 +247,12 @@ extern CVfrVarDataTypeDB gCVfrVarDataTypeDB;
typedef enum {
EFI_VFR_VARSTORE_INVALID,
EFI_VFR_VARSTORE_BUFFER,
EFI_VFR_VARSTORE_EFI,
- EFI_VFR_VARSTORE_NAME
+ EFI_VFR_VARSTORE_NAME,
+ EFI_VFR_VARSTORE_BUFFER_BITS
} EFI_VFR_VARSTORE_TYPE;
struct SVfrVarStorageNode {
EFI_GUID mGuid;
CHAR8 *mVarStoreName;
@@ -266,11 +278,11 @@ struct SVfrVarStorageNode {
} mNameSpace;
} mStorageInfo;
public:
SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN EFI_STRING_ID, IN UINT32, IN BOOLEAN Flag = TRUE);
- SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SVfrDataType *, IN BOOLEAN Flag = TRUE);
+ SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SVfrDataType *,IN BOOLEAN, IN BOOLEAN Flag = TRUE);
SVfrVarStorageNode (IN CHAR8 *, IN EFI_VARSTORE_ID);
~SVfrVarStorageNode (VOID);
private:
SVfrVarStorageNode (IN CONST SVfrVarStorageNode&); // Prevent copy-construction
@@ -283,10 +295,11 @@ struct EFI_VARSTORE_INFO {
EFI_STRING_ID mVarName;
UINT16 mVarOffset;
} mInfo;
UINT8 mVarType;
UINT32 mVarTotalSize;
+ BOOLEAN mIsBitVar;
EFI_VARSTORE_INFO (VOID);
EFI_VARSTORE_INFO (IN EFI_VARSTORE_INFO &);
EFI_VARSTORE_INFO& operator=(IN CONST EFI_VARSTORE_INFO &);
BOOLEAN operator == (IN EFI_VARSTORE_INFO *);
@@ -308,10 +321,11 @@ private:
UINT32 mFreeVarStoreIdBitMap[EFI_FREE_VARSTORE_ID_BITMAP_SIZE];
struct SVfrVarStorageNode *mBufferVarStoreList;
struct SVfrVarStorageNode *mEfiVarStoreList;
struct SVfrVarStorageNode *mNameVarStoreList;
+ struct SVfrVarStorageNode *mBitsBufferStoreList;
struct SVfrVarStorageNode *mCurrVarStorageNode;
struct SVfrVarStorageNode *mNewVarStorageNode;
BufferVarStoreFieldInfoNode *mBufferFieldInfoListHead;
BufferVarStoreFieldInfoNode *mBufferFieldInfoListTail;
@@ -342,10 +356,11 @@ public:
EFI_VFR_RETURN_CODE DeclareNameVarStoreEnd (EFI_GUID *);
EFI_VFR_RETURN_CODE DeclareEfiVarStore (IN CHAR8 *, IN EFI_GUID *, IN EFI_STRING_ID, IN UINT32, IN BOOLEAN Flag = TRUE);
EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN Flag = TRUE);
+ EFI_VFR_RETURN_CODE DeclareBitsBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN Flag = TRUE);
EFI_VFR_RETURN_CODE GetVarStoreId (IN CHAR8 *, OUT EFI_VARSTORE_ID *, IN EFI_GUID *VarGuid = NULL);
EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
EFI_GUID * GetVarStoreGuid (IN EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT CHAR8 **);
--
1.9.5.msysgit.1
next prev parent reply other threads:[~2017-05-27 8:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-27 8:34 [RFC V2 0/5] Support Bit fields in EFI/Buffer VarStore Dandan Bi
2017-05-27 8:34 ` Dandan Bi [this message]
2017-05-27 8:34 ` [RFC V2 2/5] MdeModulePkg: Add guid/flags to implement BitFiled support Dandan Bi
2017-05-27 8:34 ` [RFC V2 3/5] MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore Dandan Bi
2017-05-27 8:34 ` [RFC V2 4/5] MdeModulePkg/HiiDatabase: " Dandan Bi
2017-05-27 8:34 ` [RFC V2 5/5] MdeModulePkg/DriverSample: Add sample questions with bit VarStore Dandan Bi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495874060-331108-2-git-send-email-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox