* [PATCH v2 0/6] Support bitfield in storage of vfr
@ 2017-09-12 3:44 Dandan Bi
2017-09-12 3:44 ` [PATCH v2 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore Dandan Bi
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
V2:
Pacth1: Support bit field for Guided extension and appending question.
Patch3: Add previous missing logic to handle question with Bit VarStore in UefiHiiLib.
Patch4: Merge block data value with same offset/width or offset/width has overlap region.
Patch6: Refine the new added questions and their field name in Varstore.
This patch series is to:
(1) Update VfrCompiler to parse bit field in data structure.
(2) Update HiiDatabase HiiLib and SetupBrowser to handle questions with Bit VarStore.
(3) Add sample questions with bit/union VarStore in DriverSample.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Dandan Bi (6):
BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore
MdeModulePkg: Add GUID/flags to implement BitField support
MdeModulePkg/UefiHiiLib: Add codes to validate question with bit
fields
MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore
MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore
MdeModulePkg/DriverSample: Add sample questions with bit/union
VarStore MdeModulePkg/DriverSample: Add sample questions with
bit/union VarStore
BaseTools/Source/C/Include/Common/MdeModuleHii.h | 13 +-
BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 +-
BaseTools/Source/C/VfrCompile/VfrError.h | 3 +-
BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 105 +-
BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 52 +-
BaseTools/Source/C/VfrCompile/VfrSyntax.g | 1238 +++++++++++++-------
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 241 +++-
BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 23 +-
MdeModulePkg/Include/Guid/MdeModuleHii.h | 20 +-
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 268 +++--
MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h | 4 +-
MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf | 5 +-
MdeModulePkg/MdeModulePkg.dec | 4 +
.../Universal/DriverSampleDxe/DriverSample.c | 120 ++
.../Universal/DriverSampleDxe/DriverSample.h | 2 +
.../Universal/DriverSampleDxe/NVDataStruc.h | 34 +-
MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 173 +++
.../Universal/DriverSampleDxe/VfrStrings.uni | 61 +
.../Universal/HiiDatabaseDxe/ConfigRouting.c | 247 +++-
.../Universal/HiiDatabaseDxe/HiiDatabase.h | 7 +-
.../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf | 3 +-
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 139 ++-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 120 +-
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 +
.../Universal/SetupBrowserDxe/SetupBrowserDxe.inf | 3 +-
25 files changed, 2249 insertions(+), 642 deletions(-)
--
1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
2017-09-12 3:44 ` [PATCH v2 2/6] MdeModulePkg: Add GUID/flags to implement BitField support Dandan Bi
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
V2: Also support bit field for Guided extension and appending question.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
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 | 13 +-
BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 +-
BaseTools/Source/C/VfrCompile/VfrError.h | 3 +-
BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 105 +-
BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 52 +-
BaseTools/Source/C/VfrCompile/VfrSyntax.g | 1238 ++++++++++++++--------
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 241 ++++-
BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 23 +-
8 files changed, 1188 insertions(+), 490 deletions(-)
diff --git a/BaseTools/Source/C/Include/Common/MdeModuleHii.h b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
index 21c8387..8f4e81b 100644
--- a/BaseTools/Source/C/Include/Common/MdeModuleHii.h
+++ b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
@@ -1,9 +1,9 @@
/** @file
EDK II specific HII relative definition.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
@@ -210,10 +210,21 @@ typedef struct _EFI_IFR_GUID_VAREQNAME {
/// The the Unicode String will be used as a EFI Variable Name.
///
UINT16 NameId;
} EFI_IFR_GUID_VAREQNAME;
+///
+/// EDKII implementation extension flags, used to indaicate the disply style and bit width for bit filed storage.
+/// Two high bits for display style and the low six bits for bit width.
+///
+#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
+
#pragma pack()
extern EFI_GUID gEfiIfrTianoGuid;
extern EFI_GUID gEfiIfrFrameworkGuid;
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.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 2be0c38..c7e7974 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -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
@@ -827,10 +827,13 @@ CFormPkg::DeclarePendingQuestion (
CHAR8 *SName;
CHAR8 *NewStr;
UINT32 ShrinkSize = 0;
EFI_VFR_RETURN_CODE ReturnCode;
EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
+ UINT8 LFlags;
+ UINT32 MaxValue;
+ CIfrGuid *GuidObj = NULL;
//
// Declare all questions as Numeric in DisableIf True
//
// DisableIf
@@ -842,18 +845,12 @@ CFormPkg::DeclarePendingQuestion (
CIfrTrue TObj (LineNo);
// Declare Numeric qeustion for each undefined question.
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
- CIfrNumeric CNObj;
EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
-
- CNObj.SetLineNo (LineNo);
- CNObj.SetPrompt (0x0);
- CNObj.SetHelp (0x0);
-
//
// Register this question, assume it is normal question, not date or time question
//
VarStr = pNode->mKey;
ReturnCode = lCVfrQuestionDB.RegisterQuestion (NULL, VarStr, QId);
@@ -886,63 +883,87 @@ CFormPkg::DeclarePendingQuestion (
if (*VarStr == '\0' && ArrayIdx != INVALID_ARRAY_INDEX) {
ReturnCode = lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayIdx);
} else {
if (VarStoreType == EFI_VFR_VARSTORE_EFI) {
ReturnCode = lCVfrDataStorage.GetEfiVarStoreInfo (&Info);
- } else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
+ } else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_BUFFER_BITS) {
VarStr = pNode->mKey;
//convert VarStr with store name to VarStr with structure name
ReturnCode = lCVfrDataStorage.GetBufferVarStoreDataTypeName (Info.mVarStoreId, &SName);
if (ReturnCode == VFR_RETURN_SUCCESS) {
NewStr = new CHAR8[strlen (VarStr) + strlen (SName) + 1];
NewStr[0] = '\0';
strcpy (NewStr, SName);
strcat (NewStr, VarStr + strlen (FName));
- ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
+ ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize, Info.mIsBitVar);
delete[] NewStr;
}
} else {
ReturnCode = VFR_RETURN_UNSUPPORTED;
}
}
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey);
return ReturnCode;
}
-
- CNObj.SetQuestionId (QId);
- CNObj.SetVarStoreInfo (&Info);
//
- // Numeric doesn't support BOOLEAN data type.
- // BOOLEAN type has the same data size to UINT8.
+ // If the storage is bit fields, create Guid opcode to wrap the numeric opcode.
//
- if (Info.mVarType == EFI_IFR_TYPE_BOOLEAN) {
- Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8;
+ if (Info.mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gEfiIfrBitvarstoreGuid);
+ GuidObj->SetLineNo(LineNo);
}
- CNObj.SetFlags (0, Info.mVarType);
+
+ CIfrNumeric CNObj;
+ CNObj.SetLineNo (LineNo);
+ CNObj.SetPrompt (0x0);
+ CNObj.SetHelp (0x0);
+ CNObj.SetQuestionId (QId);
+ CNObj.SetVarStoreInfo (&Info);
+
//
- // Use maximum value not to limit the vaild value for the undefined question.
+ // Set Min/Max/Step Data and flags for the question with bit fields.Min/Max/Step Data are saved as UINT32 type for bit question.
//
- switch (Info.mVarType) {
- case EFI_IFR_TYPE_NUM_SIZE_64:
- CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0);
- ShrinkSize = 0;
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32:
- CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0);
+ if (Info.mIsBitVar) {
+ MaxValue = (1 << Info.mVarTotalSize) -1;
+ CNObj.SetMinMaxStepData ((UINT32) 0, MaxValue, (UINT32) 0);
ShrinkSize = 12;
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16:
- CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0);
- ShrinkSize = 18;
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8:
- CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0);
- ShrinkSize = 21;
- break;
- default:
- break;
+ LFlags = (EFI_IFR_NUMERIC_SIZE_BIT & Info.mVarTotalSize);
+ CNObj.SetFlagsForBitField (0, LFlags);
+ } else {
+ //
+ // Numeric doesn't support BOOLEAN data type.
+ // BOOLEAN type has the same data size to UINT8.
+ //
+ if (Info.mVarType == EFI_IFR_TYPE_BOOLEAN) {
+ Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8;
+ }
+ CNObj.SetFlags (0, Info.mVarType);
+ //
+ // Use maximum value not to limit the vaild value for the undefined question.
+ //
+ switch (Info.mVarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0);
+ ShrinkSize = 0;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0);
+ ShrinkSize = 12;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0);
+ ShrinkSize = 18;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0);
+ ShrinkSize = 21;
+ break;
+ default:
+ break;
+ }
}
CNObj.ShrinkBinSize (ShrinkSize);
//
// For undefined Efi VarStore type question
@@ -954,12 +975,22 @@ CFormPkg::DeclarePendingQuestion (
}
//
// End for Numeric
//
- CIfrEnd CEObj;
+ CIfrEnd CEObj;
CEObj.SetLineNo (LineNo);
+ //
+ // End for Guided opcode
+ //
+ CIfrEnd CEObjGuid;
+ CEObjGuid.SetLineNo (LineNo);
+ if (GuidObj != NULL) {
+ GuidObj->SetScope(1);
+ delete GuidObj;
+ GuidObj = NULL;
+ }
}
}
//
// End for DisableIf
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 17ab14c..fec3743 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:
@@ -607,12 +615,16 @@ public:
break;
}
return MaxValue;
}
- UINT64 GetStepData (UINT8 VarType) {
+ UINT64 GetStepData (UINT8 VarType, BOOLEAN IsBitVar) {
UINT64 MaxValue = 0;
+ if (IsBitVar) {
+ MaxValue = mMinMaxStepData->u32.Step;
+ return MaxValue;
+ }
switch (VarType) {
case EFI_IFR_TYPE_NUM_SIZE_64:
MaxValue = mMinMaxStepData->u64.Step;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
@@ -1405,10 +1417,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 +1473,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 24e0538..a817d8f 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -361,11 +361,15 @@ vfrDataStructFields [BOOLEAN FieldInUnion]:
dataStructFieldBool [FieldInUnion] |
dataStructFieldString [FieldInUnion]|
dataStructFieldDate [FieldInUnion] |
dataStructFieldTime [FieldInUnion] |
dataStructFieldRef [FieldInUnion] |
- dataStructFieldUser [FieldInUnion]
+ dataStructFieldUser [FieldInUnion] |
+ dataStructBitField64 [FieldInUnion] |
+ dataStructBitField32 [FieldInUnion] |
+ dataStructBitField16 [FieldInUnion] |
+ dataStructBitField8 [FieldInUnion]
)*
;
dataStructField64 [BOOLEAN FieldInUnion]:
<< UINT32 ArrayNum = 0; >>
@@ -467,10 +471,87 @@ dataStructFieldUser [BOOLEAN FieldInUnion]:
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText(), I->getLine()); >>
}
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum, FieldInUnion), T); >>
;
+dataStructBitField64[BOOLEAN FieldInUnion]:
+ <<
+ UINT32 Width = 0;
+ BOOLEAN HasBitFieldName = FALSE;
+ >>
+ D:"UINT64"
+ {
+ N:StringIdentifier << HasBitFieldName = TRUE;>>
+ }
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+
+ ";" << if (HasBitFieldName) {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width, FieldInUnion), N);
+ } else {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (" ", D->getText(), Width, FieldInUnion), D);
+ }
+ >>
+ ;
+
+dataStructBitField32[BOOLEAN FieldInUnion]:
+ <<
+ UINT32 Width = 0;
+ BOOLEAN HasBitFieldName = FALSE;
+ >>
+ D:"UINT32"
+ {
+ N:StringIdentifier << HasBitFieldName = TRUE;>>
+ }
+
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+
+ ";" << if (HasBitFieldName) {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width, FieldInUnion), N);
+ } else {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (" ", D->getText(), Width, FieldInUnion), D);
+ }
+ >>
+ ;
+
+dataStructBitField16[BOOLEAN FieldInUnion]:
+ <<
+ UINT32 Width = 0;
+ BOOLEAN HasBitFieldName = FALSE;
+ >>
+ D:"UINT16"
+ {
+ N:StringIdentifier << HasBitFieldName = TRUE;>>
+ }
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+
+ ";" << if (HasBitFieldName) {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width, FieldInUnion), N);
+ } else {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (" ", D->getText(), Width, FieldInUnion), D);
+ }
+ >>
+ ;
+
+dataStructBitField8[BOOLEAN FieldInUnion]:
+ <<
+ UINT32 Width = 0;
+ BOOLEAN HasBitFieldName = FALSE;
+ >>
+ D:"UINT8"
+ {
+ N:StringIdentifier << HasBitFieldName = TRUE;>>
+ }
+ ":" I:Number << Width = _STOU32(I->getText(), I->getLine());>>
+
+ ";" << if (HasBitFieldName) {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (N->getText(), D->getText(), Width, FieldInUnion), N);
+ } else {
+ _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBitField (" ", D->getText(), Width, FieldInUnion), D);
+ }
+ >>
+ ;
+
//*****************************************************************************
//
// the syntax of GUID definition
//
guidSubDefinition [EFI_GUID &Guid] :
@@ -749,10 +830,15 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize,
UINT8 Data_U8 = 0;
BOOLEAN Data_BL = 0;
EFI_STRING_ID Data_SID = 0;
BOOLEAN IsArray = FALSE;
UINT8 *ByteOffset = NULL;
+ BOOLEAN BitField = FALSE;
+ UINT32 Value;
+ UINT32 Mask;
+ UINT16 Offset;
+ UINT8 PreBits;
>>
(
("," "data" {OpenBracket IDX1:Number CloseBracket <<IsArray = TRUE;>>}
<<
ArrayIdx = 0;
@@ -805,27 +891,73 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize,
}else if (strcmp ("EFI_STRING_ID", TypeName) == 0) {
Data_SID = _STOSID(RD->getText(), RD->getLine());
memcpy (ByteOffset, &Data_SID, TypeSize);
}
} else {
- gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, FieldType, FieldSize);
+ gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, FieldType, FieldSize, BitField);
+ if (BitField) {
+ Mask = (1 << FieldSize) - 1;
+ Offset = FieldOffset / 8;
+ PreBits = FieldOffset - Offset * 8;
+ Mask <<= PreBits;
+ }
switch (FieldType) {
case EFI_IFR_TYPE_NUM_SIZE_8:
Data_U8 = _STOU8(RD->getText(), RD->getLine());
- memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize);
+ if (BitField) {
+ //
+ // Set the value to the bit fileds.
+ //
+ memcpy (&Value, ByteOffset + Offset, sizeof (UINT8));
+ Data_U8 <<= PreBits;
+ Value = (Value & (~Mask)) | Data_U8;
+ memcpy (ByteOffset + Offset, &Value, sizeof (UINT8));
+ } else {
+ memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize);
+ }
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
Data_U16 = _STOU16(RD->getText(), RD->getLine());
- memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize);
+ if (BitField) {
+ //
+ // Set the value to the bit fileds.
+ //
+ memcpy (&Value, ByteOffset + Offset, sizeof (UINT16));
+ Data_U16 <<= PreBits;
+ Value = (Value & (~Mask)) | Data_U16;
+ memcpy (ByteOffset + Offset, &Value, sizeof (UINT16));
+ } else {
+ memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize);
+ }
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
Data_U32 = _STOU32(RD->getText(), RD->getLine());
- memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize);
+ if (BitField) {
+ //
+ // Set the value to the bit fileds.
+ //
+ memcpy (&Value, ByteOffset + Offset, sizeof (UINT32));
+ Data_U32 <<= PreBits;
+ Value = (Value & (~Mask)) | Data_U32;
+ memcpy (ByteOffset + Offset, &Value, sizeof (UINT32));
+ } else {
+ memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize);
+ }
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
Data_U64 = _STOU64(RD->getText(), RD->getLine());
- memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize);
+ if (BitField) {
+ //
+ // Set the value to the bit fileds.
+ //
+ memcpy (&Value, ByteOffset + Offset, sizeof (UINT64));
+ Data_U64 <<= PreBits;
+ Value = (Value & (~Mask)) | Data_U64;
+ memcpy (ByteOffset + Offset, &Value, sizeof (UINT64));
+ } else {
+ memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize);
+ }
break;
case EFI_IFR_TYPE_BOOLEAN:
Data_BL = _STOU8(RD->getText(), RD->getLine());
memcpy (ByteOffset + FieldOffset, &Data_BL, FieldSize);
break;
@@ -872,14 +1004,15 @@ 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(); >>
+ TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); IsBitVarStore = gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText());>>
| U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
| U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
| C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
| U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
| U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
@@ -910,16 +1043,17 @@ vfrStatementVarStoreLinear :
StoreName = TypeName;
} else {
StoreName = SN->getText();
}
_PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
- StoreName,
- &Guid,
- &gCVfrVarDataTypeDB,
- TypeName,
- VarStoreId
- ), LineNum);
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId,
+ IsBitVarStore
+ ), LineNum);
VSObj.SetGuid (&Guid);
_PCATCH(gCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
VSObj.SetVarStoreId (VarStoreId);
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
VSObj.SetSize ((UINT16) Size);
@@ -938,14 +1072,15 @@ 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; >>
+ TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); CustomizedName = TRUE; IsBitVarStore = gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText());>>
| U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
| U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
| C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
| U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
| U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
@@ -1002,30 +1137,32 @@ vfrStatementVarStoreEfi :
)
Uuid "=" guidDefinition[Guid] <<
if (IsUEFI23EfiVarstore) {
_PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
- StoreName,
- &Guid,
- &gCVfrVarDataTypeDB,
- TypeName,
- VarStoreId
- ), LineNum);
+ StoreName,
+ &Guid,
+ &gCVfrVarDataTypeDB,
+ TypeName,
+ VarStoreId,
+ IsBitVarStore
+ ), LineNum);
_PCATCH(gCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
} else {
- _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
+ _PCATCH(gCVfrDataStorage.DeclareBufferVarStore (
TN->getText(),
&Guid,
&gCVfrVarDataTypeDB,
TypeName,
- VarStoreId
- ), LineNum);
+ VarStoreId,
+ FALSE
+ ), LineNum);
_PCATCH(gCVfrDataStorage.GetVarStoreId(TN->getText(), &VarStoreId, &Guid), VN);
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine());
}
- VSEObj.SetGuid (&Guid);
+ VSEObj.SetGuid (&Guid);
VSEObj.SetVarStoreId (VarStoreId);
VSEObj.SetSize ((UINT16) Size);
VSEObj.SetName (StoreName);
if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
@@ -1139,71 +1276,79 @@ vfrStatementSuppressIfFormSet :
vfrStatementHeader[CIfrStatementHeader *SHObj] :
Prompt "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt (_STOSID(S1->getText(), S1->getLine())); >>
Help "=" "STRING_TOKEN" "\(" S2:Number "\)" << $SHObj->SetHelp (_STOSID(S2->getText(), S2->getLine())); >>
;
+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);
+ >>
+ ;
+
vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
<<
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;
>>
- {
- 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);
- }
- $QHObj.SetQuestionId (QId);
- if (VarIdStr != NULL) {
- $QHObj.SetVarStoreInfo (&Info);
- }
+ vfrQuestionBaseInfo[Info, QId, QType]
+ << $QHObj.SetQuestionId (QId);
+ if (Info.mVarStoreId != EFI_VARSTORE_ID_INVALID) {
+ $QHObj.SetVarStoreInfo (&Info);
+ }
>>
vfrStatementHeader[&$QHObj]
- <<
- if (VarIdStr != NULL) {
- delete VarIdStr;
- }
- _SAVE_CURRQEST_VARINFO (Info);
- >>
;
questionheaderFlagsField[UINT8 & Flags] :
ReadOnlyFlag << $Flags |= 0x01; >>
| InteractiveFlag << $Flags |= 0x04; >>
@@ -1268,10 +1413,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
SName,
&mFormsetGuid,
&gCVfrVarDataTypeDB,
SName,
EFI_VARSTORE_ID_INVALID,
+ FALSE,
FALSE
);
VfrReturnCode = gCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid);
}
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
@@ -1299,21 +1445,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 +1484,12 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
switch (VarStoreType) {
case EFI_VFR_VARSTORE_EFI:
_PCATCH(gCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
break;
case EFI_VFR_VARSTORE_BUFFER:
- _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);
+ case EFI_VFR_VARSTORE_BUFFER_BITS:
+ _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize, $Info.mIsBitVar), SN2->getLine(), VarStr);
VarGuid = gCVfrDataStorage.GetVarStoreGuid($Info.mVarStoreId);
_PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
SName,
VarGuid,
NULL),
@@ -1436,90 +1583,97 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALUE &Value, BOOLEAN &ListType]
>>
{
"\-" << Negative = TRUE; >>
}
N1:Number <<
- switch ($Type) {
- case EFI_IFR_TYPE_NUM_SIZE_8 :
- $Value.u8 = _STOU8(N1->getText(), N1->getLine());
- if (IntDecStyle) {
- if (Negative) {
- if ($Value.u8 > 0x80) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, small than -0x80");
- }
- } else {
- if ($Value.u8 > 0x7F) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, small than -0x80");
+ //
+ // The value stored in bit fields is always set to UINT32 type.
+ //
+ 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) {
+ if ($Value.u8 > 0x80) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, small than -0x80");
+ }
+ } else {
+ if ($Value.u8 > 0x7F) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, small than -0x80");
+ }
}
}
- }
- if (Negative) {
- $Value.u8 = ~$Value.u8 + 1;
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16 :
- $Value.u16 = _STOU16(N1->getText(), N1->getLine());
- if (IntDecStyle) {
if (Negative) {
- if ($Value.u16 > 0x8000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FFF, small than -0x8000");
- }
- } else {
- if ($Value.u16 > 0x7FFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FFF, small than -0x8000");
+ $Value.u8 = ~$Value.u8 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16 :
+ $Value.u16 = _STOU16(N1->getText(), N1->getLine());
+ if (IntDecStyle) {
+ if (Negative) {
+ if ($Value.u16 > 0x8000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FFF, small than -0x8000");
+ }
+ } else {
+ if ($Value.u16 > 0x7FFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FFF, small than -0x8000");
+ }
}
}
- }
- if (Negative) {
- $Value.u16 = ~$Value.u16 + 1;
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32 :
- $Value.u32 = _STOU32(N1->getText(), N1->getLine());
- if (IntDecStyle) {
if (Negative) {
- if ($Value.u32 > 0x80000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FFFFFFF, small than -0x80000000");
- }
- } else {
- if ($Value.u32 > 0X7FFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FFFFFFF, small than -0x80000000");
+ $Value.u16 = ~$Value.u16 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32 :
+ $Value.u32 = _STOU32(N1->getText(), N1->getLine());
+ if (IntDecStyle) {
+ if (Negative) {
+ if ($Value.u32 > 0x80000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FFFFFFF, small than -0x80000000");
+ }
+ } else {
+ if ($Value.u32 > 0X7FFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FFFFFFF, small than -0x80000000");
+ }
}
}
- }
- if (Negative) {
- $Value.u32 = ~$Value.u32 + 1;
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_64 :
- $Value.u64 = _STOU64(N1->getText(), N1->getLine());
- if (IntDecStyle) {
if (Negative) {
- if ($Value.u64 > 0x8000000000000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FFFFFFFFFFFFFFF, small than -0x8000000000000000");
- }
- } else {
- if ($Value.u64 > 0x7FFFFFFFFFFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FFFFFFFFFFFFFFF, small than -0x8000000000000000");
+ $Value.u32 = ~$Value.u32 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64 :
+ $Value.u64 = _STOU64(N1->getText(), N1->getLine());
+ if (IntDecStyle) {
+ if (Negative) {
+ if ($Value.u64 > 0x8000000000000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FFFFFFFFFFFFFFF, small than -0x8000000000000000");
+ }
+ } else {
+ if ($Value.u64 > 0x7FFFFFFFFFFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FFFFFFFFFFFFFFF, small than -0x8000000000000000");
+ }
}
}
+ if (Negative) {
+ $Value.u64 = ~$Value.u64 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_BOOLEAN :
+ $Value.b = _STOU8(N1->getText(), N1->getLine());
+ break;
+ case EFI_IFR_TYPE_STRING :
+ $Value.string = _STOU16(N1->getText(), N1->getLine());
+ break;
+ case EFI_IFR_TYPE_TIME :
+ case EFI_IFR_TYPE_DATE :
+ case EFI_IFR_TYPE_REF :
+ default :
+ break;
}
- if (Negative) {
- $Value.u64 = ~$Value.u64 + 1;
- }
- break;
- case EFI_IFR_TYPE_BOOLEAN :
- $Value.b = _STOU8(N1->getText(), N1->getLine());
- break;
- case EFI_IFR_TYPE_STRING :
- $Value.string = _STOU16(N1->getText(), N1->getLine());
- break;
- case EFI_IFR_TYPE_TIME :
- 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()); >>
@@ -1689,42 +1843,51 @@ 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())) {
+ //
+ // Value for question stored in bit fields is always set to UINT32 type.
+ //
+ 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.");
@@ -1759,21 +1922,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()); >>
@@ -2176,39 +2347,72 @@ 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] <<
+ //
+ // Create a GUID opcode to wrap the checkbox opcode, if it refer to bit varstore.
+ //
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gEfiIfrBitvarstoreGuid);
+ 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(),
@@ -2220,11 +2424,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(),
@@ -2240,14 +2444,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] :
<<
@@ -2439,11 +2650,12 @@ 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)) {
+ if (((_GET_CURRQEST_VARTINFO().mIsBitVar) && (NObj->GetOpCode() == EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY_BIT) == 0)) ||
+ (!(_GET_CURRQEST_VARTINFO().mIsBitVar) && (NObj->GetOpCode() == EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY) == 0))) {
IntDecStyle = TRUE;
}
BOOLEAN MinNegative = FALSE;
BOOLEAN MaxNegative = FALSE;
>>
@@ -2453,383 +2665,539 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
}
I:Number "," <<
if (!IntDecStyle && MinNegative) {
_PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "\"-\" can't be used when not in int decimal type. ");
}
- switch (_GET_CURRQEST_DATATYPE()) {
- case EFI_IFR_TYPE_NUM_SIZE_64 :
- MinU8 = _STOU64(I->getText(), I->getLine());
- if (IntDecStyle) {
- if (MinNegative) {
- if (MinU8 > 0x8000000000000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
- }
- } else {
- if (MinU8 > 0x7FFFFFFFFFFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
- }
- }
- }
- if (MinNegative) {
- MinU8 = ~MinU8 + 1;
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32 :
+ //
+ // Value for question stored in bit fields is always set to UINT32 type.
+ //
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
MinU4 = _STOU32(I->getText(), I->getLine());
- if (IntDecStyle) {
- if (MinNegative) {
- if (MinU4 > 0x80000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't small than -0x80000000, big than 0x7FFFFFFF");
- }
- } else {
- if (MinU4 > 0x7FFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't small than -0x80000000, big than 0x7FFFFFFF");
- }
- }
- }
- if (MinNegative) {
- MinU4 = ~MinU4 + 1;
+ if (!IntDecStyle && MinU4 > (1<< _GET_CURRQEST_VARTINFO().mVarTotalSize) -1) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "BIT type minimum can't small than 0, bigger than 2^BitWidth -1");
}
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16 :
- MinU2 = _STOU16(I->getText(), I->getLine());
- if (IntDecStyle) {
- if (MinNegative) {
- if (MinU2 > 0x8000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't small than -0x8000, big than 0x7FFF");
+ } else {
+ switch (_GET_CURRQEST_DATATYPE()) {
+ case EFI_IFR_TYPE_NUM_SIZE_64 :
+ MinU8 = _STOU64(I->getText(), I->getLine());
+ if (IntDecStyle) {
+ if (MinNegative) {
+ if (MinU8 > 0x8000000000000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ }
+ } else {
+ if (MinU8 > 0x7FFFFFFFFFFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ }
}
- } else {
- if (MinU2 > 0x7FFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't small than -0x8000, big than 0x7FFF");
+ }
+ if (MinNegative) {
+ MinU8 = ~MinU8 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32 :
+ MinU4 = _STOU32(I->getText(), I->getLine());
+ if (IntDecStyle) {
+ if (MinNegative) {
+ if (MinU4 > 0x80000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't small than -0x80000000, big than 0x7FFFFFFF");
+ }
+ } else {
+ if (MinU4 > 0x7FFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't small than -0x80000000, big than 0x7FFFFFFF");
+ }
}
}
- }
- if (MinNegative) {
- MinU2 = ~MinU2 + 1;
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8 :
- MinU1 = _STOU8(I->getText(), I->getLine());
- if (IntDecStyle) {
- if (MinNegative) {
- if (MinU1 > 0x80) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small than -0x80, big than 0x7F");
+ if (MinNegative) {
+ MinU4 = ~MinU4 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16 :
+ MinU2 = _STOU16(I->getText(), I->getLine());
+ if (IntDecStyle) {
+ if (MinNegative) {
+ if (MinU2 > 0x8000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't small than -0x8000, big than 0x7FFF");
+ }
+ } else {
+ if (MinU2 > 0x7FFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't small than -0x8000, big than 0x7FFF");
+ }
}
- } else {
- if (MinU1 > 0x7F) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small than -0x80, big than 0x7F");
+ }
+ if (MinNegative) {
+ MinU2 = ~MinU2 + 1;
+ }
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8 :
+ MinU1 = _STOU8(I->getText(), I->getLine());
+ if (IntDecStyle) {
+ if (MinNegative) {
+ if (MinU1 > 0x80) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small than -0x80, big than 0x7F");
+ }
+ } else {
+ if (MinU1 > 0x7F) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small than -0x80, big than 0x7F");
+ }
}
}
+ if (MinNegative) {
+ MinU1 = ~MinU1 + 1;
+ }
+ break;
}
- 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. ");
}
-
- switch (_GET_CURRQEST_DATATYPE()) {
- case EFI_IFR_TYPE_NUM_SIZE_64 :
- MaxU8 = _STOU64(A->getText(), A->getLine());
- if (IntDecStyle) {
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ MaxU4 = _STOU32(A->getText(), A->getLine());
+ if (!IntDecStyle && MaxU4 > (1<< _GET_CURRQEST_VARTINFO().mVarTotalSize) -1) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "BIT type maximum can't bigger 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) {
+ if (MaxU8 > 0x8000000000000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ }
+ } else {
+ if (MaxU8 > 0x7FFFFFFFFFFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ }
+ }
+ }
if (MaxNegative) {
- if (MaxU8 > 0x8000000000000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ MaxU8 = ~MaxU8 + 1;
+ }
+ if (IntDecStyle) {
+ if ((INT64) MaxU8 < (INT64) MinU8) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
} else {
- if (MaxU8 > 0x7FFFFFFFFFFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't small than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF");
+ if (MaxU8 < MinU8) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
}
- }
- if (MaxNegative) {
- MaxU8 = ~MaxU8 + 1;
- }
- if (IntDecStyle) {
- if ((INT64) MaxU8 < (INT64) MinU8) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
- }
- } else {
- if (MaxU8 < MinU8) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32 :
+ MaxU4 = _STOU32(A->getText(), A->getLine());
+ if (IntDecStyle) {
+ if (MaxNegative) {
+ if (MaxU4 > 0x80000000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't small than -0x80000000, big than 0x7FFFFFFF");
+ }
+ } else {
+ if (MaxU4 > 0x7FFFFFFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't small than -0x80000000, big than 0x7FFFFFFF");
+ }
+ }
}
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32 :
- MaxU4 = _STOU32(A->getText(), A->getLine());
- if (IntDecStyle) {
if (MaxNegative) {
- if (MaxU4 > 0x80000000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't small than -0x80000000, big than 0x7FFFFFFF");
+ MaxU4 = ~MaxU4 + 1;
+ }
+ if (IntDecStyle) {
+ if ((INT32) MaxU4 < (INT32) MinU4) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
} else {
- if (MaxU4 > 0x7FFFFFFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't small than -0x80000000, big than 0x7FFFFFFF");
+ if (MaxU4 < MinU4) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
}
- }
- if (MaxNegative) {
- MaxU4 = ~MaxU4 + 1;
- }
- if (IntDecStyle) {
- if ((INT32) MaxU4 < (INT32) MinU4) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
- }
- } else {
- if (MaxU4 < MinU4) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16 :
+ MaxU2 = _STOU16(A->getText(), A->getLine());
+ if (IntDecStyle) {
+ if (MaxNegative) {
+ if (MaxU2 > 0x8000) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't small than -0x8000, big than 0x7FFF");
+ }
+ } else {
+ if (MaxU2 > 0x7FFF) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't small than -0x8000, big than 0x7FFF");
+ }
+ }
}
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16 :
- MaxU2 = _STOU16(A->getText(), A->getLine());
- if (IntDecStyle) {
if (MaxNegative) {
- if (MaxU2 > 0x8000) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't small than -0x8000, big than 0x7FFF");
+ MaxU2 = ~MaxU2 + 1;
+ }
+ if (IntDecStyle) {
+ if ((INT16) MaxU2 < (INT16) MinU2) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
} else {
- if (MaxU2 > 0x7FFF) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't small than -0x8000, big than 0x7FFF");
+ if (MaxU2 < MinU2) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
}
- }
- if (MaxNegative) {
- MaxU2 = ~MaxU2 + 1;
- }
- if (IntDecStyle) {
- if ((INT16) MaxU2 < (INT16) MinU2) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
- }
- } else {
- if (MaxU2 < MinU2) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8 :
+ MaxU1 = _STOU8(A->getText(), A->getLine());
+ if (IntDecStyle) {
+ if (MaxNegative) {
+ if (MaxU1 > 0x80) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small than -0x80, big than 0x7F");
+ }
+ } else {
+ if (MaxU1 > 0x7F) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small than -0x80, big than 0x7F");
+ }
+ }
}
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8 :
- MaxU1 = _STOU8(A->getText(), A->getLine());
- if (IntDecStyle) {
if (MaxNegative) {
- if (MaxU1 > 0x80) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small than -0x80, big than 0x7F");
+ MaxU1 = ~MaxU1 + 1;
+ }
+ if (IntDecStyle) {
+ if ((INT8) MaxU1 < (INT8) MinU1) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
} else {
- if (MaxU1 > 0x7F) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small than -0x80, big than 0x7F");
+ if (MaxU1 < MinU1) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
}
}
+ break;
}
- if (MaxNegative) {
- MaxU1 = ~MaxU1 + 1;
- }
- if (IntDecStyle) {
- if ((INT8) MaxU1 < (INT8) MinU1) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
- }
- } else {
- if (MaxU1 < MinU1) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
- }
- }
- break;
}
>>
{
STEP "=" S:Number ","
<<
- 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) {
+ 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;
+ }
}
>>
}
<<
- 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;
+ 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] <<
+ //
+ // Create a GUID opcode to wrap the numeric opcode, if it refer to bit varstore.
+ //
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gEfiIfrBitvarstoreGuid);
+ 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()) {
+ 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 {
//
- // Base on the type to know the actual used size,shrink the buffer
- // size allocate before.
+ // Question stored in bit fields saved as UINT32 type, so the ShrinkSize same as EFI_IFR_TYPE_NUM_SIZE_32.
//
- 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;
+ ShrinkSize = 12;
}
- 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 specify 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 specify 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 specify 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 specify 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] <<
+ //
+ // Create a GUID opcode to wrap the oneof opcode, if it refer to bit varstore.
+ //
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
+ GuidObj = new CIfrGuid(0);
+ GuidObj->SetGuid (&gEfiIfrBitvarstoreGuid);
+ 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]
}
<<
- switch (_GET_CURRQEST_DATATYPE()) {
+ 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 {
//
- // Base on the type to know the actual used size,shrink the buffer
- // size allocate before.
+ // Question stored in bit fields saved as UINT32 type, so the ShrinkSize same as EFI_IFR_TYPE_NUM_SIZE_32.
//
- 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;
+ ShrinkSize = 12;
}
- OObj.ShrinkBinSize (ShrinkSize);
+ 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 |
@@ -3379,26 +3747,30 @@ vfrStatementOneOfOption :
Text "=" "STRING_TOKEN" "\(" S:Number "\)" ","
Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayType] ","
<<
if (gCurrentMinMaxData != NULL) {
//set min/max value for oneof opcode
- UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
- switch (_GET_CURRQEST_DATATYPE()) {
- case EFI_IFR_TYPE_NUM_SIZE_64:
- gCurrentMinMaxData->SetMinMaxStepData(Val->u64, Val->u64, Step);
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32:
+ UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE(), _GET_CURRQEST_VARTINFO().mIsBitVar);
+ if (_GET_CURRQEST_VARTINFO().mIsBitVar) {
gCurrentMinMaxData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step);
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16:
- gCurrentMinMaxData->SetMinMaxStepData(Val->u16, Val->u16, (UINT16) Step);
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8:
- gCurrentMinMaxData->SetMinMaxStepData(Val->u8, Val->u8, (UINT8) Step);
- break;
- default:
- break;
+ } 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:
+ gCurrentMinMaxData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ gCurrentMinMaxData->SetMinMaxStepData(Val->u16, Val->u16, (UINT16) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ gCurrentMinMaxData->SetMinMaxStepData(Val->u8, Val->u8, (UINT8) Step);
+ break;
+ default:
+ break;
+ }
}
}
if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
Size = sizeof (EFI_IFR_TYPE_VALUE);
} else if (ArrayType) {
@@ -3428,24 +3800,35 @@ vfrStatementOneOfOption :
break;
default:
break;
}
} else {
- ReturnCode = gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size);
+ //
+ // For the oneof stored in bit fields, set the option type as UINT32.
+ //
+ 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());
}
Size += OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value);
OOOObj = new CIfrOneOfOption((UINT8)Size);
OOOObj->SetLineNo(L->getLine());
OOOObj->SetOption (_STOSID(S->getText(), S->getLine()));
if (ArrayType) {
- OOOObj->SetType (EFI_IFR_TYPE_BUFFER);
+ OOOObj->SetType (EFI_IFR_TYPE_BUFFER);
} else {
- OOOObj->SetType (_GET_CURRQEST_DATATYPE());
+ 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()]
<<
@@ -5220,11 +5603,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
gCVfrDataStorage.DeclareBufferVarStore (
TypeNameList[Index],
&mFormsetGuid,
&gCVfrVarDataTypeDB,
TypeNameList[Index],
- EFI_VARSTORE_ID_INVALID
+ EFI_VARSTORE_ID_INVALID,
+ FALSE
);
gCVfrDataStorage.GetVarStoreId(TypeNameList[Index], &VarStoreId, &mFormsetGuid);
VSObj.SetVarStoreId (VarStoreId);
gCVfrVarDataTypeDB.GetDataTypeSize(TypeNameList[Index], &Size);
VSObj.SetSize ((UINT16) Size);
@@ -5245,11 +5629,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
gCVfrDataStorage.DeclareBufferVarStore (
(CHAR8 *) DateName,
&mFormsetGuid,
&gCVfrVarDataTypeDB,
(CHAR8 *) DateType,
- EFI_VARSTORE_ID_INVALID
+ EFI_VARSTORE_ID_INVALID,
+ FALSE
);
gCVfrDataStorage.GetVarStoreId((CHAR8 *) DateName, &VarStoreId, &mFormsetGuid);
VSObj.SetVarStoreId (VarStoreId);
gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) DateType, &Size);
VSObj.SetSize ((UINT16) Size);
@@ -5266,11 +5651,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
gCVfrDataStorage.DeclareBufferVarStore (
(CHAR8 *) TimeName,
&mFormsetGuid,
&gCVfrVarDataTypeDB,
(CHAR8 *) TimeType,
- EFI_VARSTORE_ID_INVALID
+ EFI_VARSTORE_ID_INVALID,
+ FALSE
);
gCVfrDataStorage.GetVarStoreId((CHAR8 *) TimeName, &VarStoreId, &mFormsetGuid);
VSObj.SetVarStoreId (VarStoreId);
gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) TimeType, &Size);
VSObj.SetSize ((UINT16) Size);
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 37b58e2..23fffa1 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -598,10 +598,65 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
}
return VFR_RETURN_SUCCESS;
}
+/**
+ Check whether the DataType contain bit field.
+
+ @param TypeName The name of the type.
+
+**/
+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;
+}
+
+/**
+ Check whether the field is bit field or not.
+
+ @param VarStr Point to the field name which may contain the structure name.
+
+**/
+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 +750,12 @@ CVfrVarDataTypeDB::GetTypeField (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetFieldOffset (
IN SVfrDataField *Field,
IN UINT32 ArrayIdx,
- OUT UINT32 &Offset
+ OUT UINT32 &Offset,
+ IN BOOLEAN IsBitField
)
{
if (Field == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
@@ -727,12 +783,15 @@ 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->mBitOffset + Field->mFieldType->mTotalSize * ((ArrayIdx == INVALID_ARRAY_INDEX) ? 0 : ArrayIdx) * 8;
+ } 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 BitField
)
{
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 (BitField) {
+ 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;
}
@@ -976,10 +1050,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
@@ -1007,10 +1082,127 @@ CVfrVarDataTypeDB::SetNewTypeName (
strcpy(mNewDataType->mTypeName, TypeName);
return VFR_RETURN_SUCCESS;
}
+/**
+ Record the bit field info in the data type.
+
+ @param FieldName Point to the field name.
+ @param TypeName Point to the type name.
+ @param Width The bit widthS.
+ @param FieldInUnion The filed is in Union type or Structure type.
+
+**/
+EFI_VFR_RETURN_CODE
+CVfrVarDataTypeDB::DataTypeAddBitField (
+ IN CHAR8 *FieldName,
+ IN CHAR8 *TypeName,
+ IN UINT32 Width,
+ IN BOOLEAN FieldInUnion
+ )
+{
+ SVfrDataField *pNewField = NULL;
+ SVfrDataType *pFieldType = NULL;
+ SVfrDataField *pTmp;
+ UINT32 Align;
+ UINT32 MaxDataTypeSize;
+ BOOLEAN UpdateTotalSize;
+
+ 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;
+ }
+
+ if (Width == 0 && strcmp (" ", FieldName) != 0) {
+ return VFR_RETURN_INVALID_PARAMETER;
+ }
+
+ for (pTmp = mNewDataType->mMembers; pTmp != NULL; pTmp = pTmp->mNext) {
+ if (strcmp (pTmp->mFieldName, FieldName) == 0 && strcmp (" ", FieldName) != 0) {
+ return VFR_RETURN_REDEFINED;
+ }
+ }
+
+ Align = MIN (mPackAlign, pFieldType->mAlign);
+ UpdateTotalSize = FALSE;
+
+ if ((pNewField = new SVfrDataField) == NULL) {
+ return VFR_RETURN_OUT_FOR_RESOURCES;
+ }
+
+ MaxDataTypeSize = mNewDataType->mTotalSize;
+ strcpy (pNewField->mFieldName, FieldName);
+ pNewField->mFieldType = pFieldType;
+ pNewField->mIsBitField = TRUE;
+ pNewField->mBitWidth = Width;
+ pNewField->mArrayNum = 0;
+ pNewField->mBitOffset = 0;
+ pNewField->mOffset = 0;
+
+ if (mNewDataType->mMembers == NULL) {
+ mNewDataType->mMembers = pNewField;
+ pNewField->mNext = NULL;
+ } else {
+ for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
+ ;
+ pTmp->mNext = pNewField;
+ pNewField->mNext = NULL;
+ }
+
+ if (FieldInUnion) {
+ pNewField->mOffset = 0;
+ if (MaxDataTypeSize < pNewField->mFieldType->mTotalSize) {
+ mNewDataType->mTotalSize = pNewField->mFieldType->mTotalSize;
+ }
+ } else {
+ //
+ // Check whether the bit fileds can be contained within one FieldType.
+ //
+ if (pTmp != NULL && pTmp->mIsBitField && strcmp (pTmp->mFieldType->mTypeName, pNewField->mFieldType->mTypeName) == 0 &&
+ (pTmp->mBitOffset - pTmp->mOffset * 8) + pTmp->mBitWidth + pNewField->mBitWidth <= pNewField->mFieldType->mTotalSize * 8) {
+ pNewField->mBitOffset = pTmp->mBitOffset + pTmp->mBitWidth;
+ pNewField->mOffset = pTmp->mOffset;
+ //
+ // If BitWidth=0,used to force alignment at the next word boundary.
+ // So make this bit field occupy the remaing bit width of current field type.
+ //
+ if (pNewField->mBitWidth == 0) {
+ pNewField->mBitWidth = pNewField->mFieldType->mTotalSize * 8 - (pNewField->mBitOffset - pTmp->mOffset * 8);
+ }
+ } else {
+ //
+ // The bit filed start a new memory
+ //
+ pNewField->mBitOffset = mNewDataType->mTotalSize * 8;
+ UpdateTotalSize = TRUE;
+ }
+ }
+
+ if (UpdateTotalSize){
+ if ((mNewDataType->mTotalSize % Align) == 0) {
+ pNewField->mOffset = mNewDataType->mTotalSize;
+ } else {
+ pNewField->mOffset = mNewDataType->mTotalSize + ALIGN_STUFF(mNewDataType->mTotalSize, Align);
+ }
+ mNewDataType->mTotalSize = pNewField->mOffset + (pNewField->mFieldType->mTotalSize);
+ }
+
+ mNewDataType->mAlign = MIN (mPackAlign, MAX (pFieldType->mAlign, mNewDataType->mAlign));
+ mNewDataType->mHasBitField = TRUE;
+ return VFR_RETURN_SUCCESS;
+}
+
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::DataTypeAddField (
IN CHAR8 *FieldName,
IN CHAR8 *TypeName,
IN UINT32 ArrayNum,
@@ -1042,10 +1234,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);
}
@@ -1181,39 +1374,48 @@ CVfrVarDataTypeDB::GetDataTypeSize (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataFieldInfo (
IN CHAR8 *VarStr,
OUT UINT16 &Offset,
OUT UINT8 &Type,
- OUT UINT32 &Size
+ OUT UINT32 &Size,
+ OUT BOOLEAN &BitField
)
{
CHAR8 TName[MAX_NAME_LEN], FName[MAX_NAME_LEN];
UINT32 ArrayIdx, Tmp;
SVfrDataType *pType = NULL;
SVfrDataField *pField = NULL;
+ 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);
+ BitField = 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);
+ CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, pField->mIsBitField), VFR_RETURN_SUCCESS);
+ if (BitField && !pField->mIsBitField) {
+ Offset = (UINT16) (Offset + Tmp * 8);
+ } else {
+ Offset = (UINT16) (Offset + Tmp);
+ }
Type = GetFieldWidth (pField);
- Size = GetFieldSize (pField, ArrayIdx);
+ Size = GetFieldSize (pField, ArrayIdx, BitField);
}
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
@@ -1358,10 +1560,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;
@@ -1374,11 +1577,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 (
@@ -1646,10 +1853,11 @@ CVfrDataStorage::DeclareBufferVarStore (
IN CHAR8 *StoreName,
IN EFI_GUID *Guid,
IN CVfrVarDataTypeDB *DataTypeDB,
IN CHAR8 *TypeName,
IN EFI_VARSTORE_ID VarStoreId,
+ IN BOOLEAN IsBitVarStore,
IN BOOLEAN Flag
)
{
SVfrVarStorageNode *pNew = NULL;
SVfrDataType *pDataType = NULL;
@@ -1672,11 +1880,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, IsBitVarStore, Flag)) == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
pNew->mNext = mBufferVarStoreList;
mBufferVarStoreList = pNew;
@@ -2386,10 +2594,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
)
@@ -2397,10 +2606,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
@@ -2410,10 +2620,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;
}
@@ -2424,11 +2635,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;
}
@@ -3727,10 +3939,11 @@ CVfrStringDB::GetUnicodeStringTextSize (
return StringSize;
}
BOOLEAN VfrCompatibleMode = FALSE;
+EFI_GUID gEfiIfrBitvarstoreGuid = {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 0c67d73..c1d124f 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -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 gEfiIfrBitvarstoreGuid;
+#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,22 @@ struct SVfrDataType;
struct SVfrDataField {
CHAR8 mFieldName[MAX_NAME_LEN];
SVfrDataType *mFieldType;
UINT32 mOffset;
UINT32 mArrayNum;
+ BOOLEAN mIsBitField;
+ UINT8 mBitWidth;
+ UINT32 mBitOffset;
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
@@ -193,30 +199,33 @@ private:
VOID InternalTypesListInit (VOID);
VOID RegisterNewType (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);
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, IN BOOLEAN);
+ EFI_VFR_RETURN_CODE DataTypeAddBitField (IN CHAR8 *, IN CHAR8 *, IN UINT32, IN BOOLEAN);
VOID DeclareDataTypeEnd (VOID);
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 GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &, OUT BOOLEAN &);
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 +245,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 +276,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 +293,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 *);
@@ -341,11 +352,11 @@ public:
EFI_VFR_RETURN_CODE NameTableAddItem (EFI_STRING_ID);
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 DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN, 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/6] MdeModulePkg: Add GUID/flags to implement BitField support
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
2017-09-12 3:44 ` [PATCH v2 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
2017-09-12 3:44 ` [PATCH v2 3/6] MdeModulePkg/UefiHiiLib: Add codes to validate question with bit fields Dandan Bi
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
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>
---
MdeModulePkg/Include/Guid/MdeModuleHii.h | 20 +++++++++++++++++++-
MdeModulePkg/MdeModulePkg.dec | 4 ++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Include/Guid/MdeModuleHii.h b/MdeModulePkg/Include/Guid/MdeModuleHii.h
index 81821da..4ef4db8 100644
--- a/MdeModulePkg/Include/Guid/MdeModuleHii.h
+++ b/MdeModulePkg/Include/Guid/MdeModuleHii.h
@@ -1,9 +1,9 @@
/** @file
EDKII extented HII IFR guid opcodes.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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 that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -209,12 +209,30 @@ typedef struct _EFI_IFR_GUID_VAREQNAME {
/// The the Unicode String will be used as a EFI Variable Name.
///
UINT16 NameId;
} EFI_IFR_GUID_VAREQNAME;
+///
+/// EDKII implementation extension GUID, used to indaicate there are bit fields in the varstore.
+///
+#define EFI_IFR_BITVARSTORE_GUID \
+ {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 0xA8, 0xFD, 0x60,0xA7, 0x1D}}
+
+///
+/// EDKII implementation extension flags, used to indaicate the disply style and bit width for bit filed storage.
+/// Two high bits for display style and the low six bits for bit width.
+///
+#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
+
#pragma pack()
extern EFI_GUID gEfiIfrTianoGuid;
extern EFI_GUID gEfiIfrFrameworkGuid;
+extern EFI_GUID gEfiIfrBitvarstoreGuid;
#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 593bff3..8c8d76e 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -182,10 +182,14 @@
## Guid for EDKII implementation GUIDed opcodes
# Include/Guid/MdeModuleHii.h
gEfiIfrTianoGuid = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }}
+ ## Guid for EDKII implementation extension, used to indaicate there are bit fields in the varstore.
+ # Include/Guid/MdeModuleHii.h
+ gEfiIfrBitvarstoreGuid = {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 0xA8, 0xFD, 0x60,0xA7, 0x1D}}
+
## Guid for Framework vfr GUIDed opcodes.
# Include/Guid/MdeModuleHii.h
gEfiIfrFrameworkGuid = { 0x31ca5d1a, 0xd511, 0x4931, { 0xb7, 0x82, 0xae, 0x6b, 0x2b, 0x17, 0x8c, 0xd7 }}
## Guid to specify the System Non Volatile FV
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/6] MdeModulePkg/UefiHiiLib: Add codes to validate question with bit fields
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
2017-09-12 3:44 ` [PATCH v2 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore Dandan Bi
2017-09-12 3:44 ` [PATCH v2 2/6] MdeModulePkg: Add GUID/flags to implement BitField support Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
2017-09-12 3:44 ` [PATCH v2 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore Dandan Bi
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
V2: Add previous missing logic to handle question with Bit VarStore
in UefiHiiLib.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
In UefiHiiLib, there are codes to validate the current setting
of questions, now update the logic to handle question with bit
storage.
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>
---
MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 270 ++++++++++++++++-------
MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h | 4 +-
MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf | 5 +-
3 files changed, 202 insertions(+), 77 deletions(-)
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index cd0cd35..9df42d1 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -49,10 +49,11 @@ EFI_FORM_BROWSER2_PROTOCOL *mUefiFormBrowser2 = NULL;
GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_PACKAGE_HEADER mEndOfPakageList = {
sizeof (EFI_HII_PACKAGE_HEADER),
EFI_HII_PACKAGE_END
};
+BOOLEAN mQuestionReferBitField = FALSE;
/**
Extract Hii package list GUID for given HII handle.
If HiiHandle could not be found in the HII database, then ASSERT.
If Guid is NULL, then ASSERT.
@@ -1167,10 +1168,16 @@ ValidateQuestionFromVfr (
EFI_IFR_STRING *IfrString;
CHAR8 *VarStoreName;
UINTN Index;
CHAR16 *QuestionName;
CHAR16 *StringPtr;
+ UINT16 BitOffset;
+ UINT16 BitWidth;
+ UINT16 TotalBits;
+ UINT32 PreBits;
+ UINT32 Mask;
+ UINT32 *Value;
//
// Initialize the local variables.
//
Index = 0;
@@ -1180,10 +1187,12 @@ ValidateQuestionFromVfr (
IfrVarStore = NULL;
IfrNameValueStore = NULL;
IfrEfiVarStore = NULL;
ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA));
ZeroMem (&VarBlockData, sizeof (VarBlockData));
+ BitOffset = 0;
+ BitWidth = 0;
//
// Check IFR value is in block data, then Validate Value
//
PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
@@ -1343,12 +1352,23 @@ ValidateQuestionFromVfr (
}
} else {
//
// Get Offset by Question header and Width by DataType Flags
//
- Offset = IfrOneOf->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ if (mQuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
+ BitWidth = IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE_BIT;
+ Offset = BitOffset / 8;
+ TotalBits = BitOffset - (Offset * 8) + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
+ } else {
+ Offset = IfrOneOf->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ }
//
// Check whether this question is in current block array.
//
if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
//
@@ -1368,11 +1388,27 @@ ValidateQuestionFromVfr (
//
// Get the current value for oneof opcode
//
VarValue = 0;
- CopyMem (&VarValue, VarBuffer + Offset, Width);
+ if (mQuestionReferBitField) {
+ //
+ // Get the value in bit fields.
+ //
+ mQuestionReferBitField = FALSE;
+ Value = (UINT32*) &VarValue;
+ PreBits = BitOffset - Offset * 8;
+ Mask = (1 << BitWidth) -1;
+ *Value = *(VarBuffer + Offset);
+ *Value |= *(VarBuffer + Offset + 1) << 8;
+ *Value |= *(VarBuffer + Offset + 2) << 16;
+ *Value |= *(VarBuffer + Offset + 3) << 24;
+ *Value >>= PreBits;
+ *Value &= Mask;
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
+ }
}
//
// Set Block Data, to be checked in the following Oneof option opcode.
//
VarBlockData.OpCode = IfrOpHdr->OpCode;
@@ -1414,12 +1450,26 @@ ValidateQuestionFromVfr (
}
} else {
//
// Get Offset by Question header and Width by DataType Flags
//
- Offset = IfrNumeric->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
+ if (mQuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
+ BitWidth = IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE_BIT;
+ Offset = BitOffset / 8;
+ //
+ // Use current bit width and the bit width before current bit (with same byte offset) to calculate the byte width.
+ //
+ TotalBits = BitOffset - (Offset * 8) + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
+ } else {
+ Offset = IfrNumeric->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
+ }
//
// Check whether this question is in current block array.
//
if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
//
@@ -1439,81 +1489,118 @@ ValidateQuestionFromVfr (
//
// Check the current value is in the numeric range.
//
VarValue = 0;
- CopyMem (&VarValue, VarBuffer + Offset, Width);
- }
- if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) {
- switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_2:
- if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_4:
- if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
+ if (mQuestionReferBitField) {
+ //
+ // Get the value in the bit fields.
+ //
+ Value = (UINT32*) &VarValue;
+ PreBits = BitOffset - Offset * 8;
+ Mask = (1<< BitWidth) -1;
+ *Value = *(VarBuffer + Offset);
+ *Value |= *(VarBuffer + Offset + 1) << 8;
+ *Value |= *(VarBuffer + Offset + 2) << 16;
+ *Value |= *(VarBuffer + Offset + 3) << 24;
+ *Value >>= PreBits;
+ *Value &= Mask;
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
}
+ }
+ if ( mQuestionReferBitField) {
+ //
+ // Value in bit fields was stored as UINt32 type.
+ //
+ mQuestionReferBitField = FALSE;
+ if ((IfrNumeric->Flags & EFI_IFR_DISPLAY_BIT) == 0) {
+ if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ if (VarValue < IfrNumeric->data.u32.MinValue || VarValue > IfrNumeric->data.u32.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ }
} else {
- switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_2:
- if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_4:
- if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
+ if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) {
+ switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
}
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
+ } else {
+ switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
}
- break;
}
}
break;
case EFI_IFR_CHECKBOX_OP:
//
@@ -1552,12 +1639,23 @@ ValidateQuestionFromVfr (
}
} else {
//
// Get Offset by Question header
//
- Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) sizeof (BOOLEAN);
+ if (mQuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
+ BitWidth = 1;
+ Offset = BitOffset / 8;
+ TotalBits = BitOffset - (Offset * 8) + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
+ } else {
+ Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16) sizeof (BOOLEAN);
+ }
//
// Check whether this question is in current block array.
//
if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
//
@@ -1576,11 +1674,27 @@ ValidateQuestionFromVfr (
}
//
// Check the current value is in the numeric range.
//
VarValue = 0;
- CopyMem (&VarValue, VarBuffer + Offset, Width);
+ if (mQuestionReferBitField) {
+ //
+ // Get the value in bit fields.
+ //
+ mQuestionReferBitField = FALSE;
+ Value = (UINT32*) &VarValue;
+ PreBits = BitOffset - Offset* 8;
+ Mask = (1<< BitWidth) -1;
+ *Value = *(VarBuffer + Offset);
+ *Value |= *(VarBuffer + Offset + 1) << 8;
+ *Value |= *(VarBuffer + Offset + 2) << 16;
+ *Value |= *(VarBuffer + Offset + 3) << 24;
+ *Value >>= PreBits;
+ *Value &= Mask;
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
+ }
}
//
// Boolean type, only 1 and 0 is valid.
//
if (VarValue > 1) {
@@ -1692,10 +1806,11 @@ ValidateQuestionFromVfr (
VarBlockData.OpCode = 0;
}
}
break;
case EFI_IFR_END_OP:
+ mQuestionReferBitField = FALSE;
//
// Decrease opcode scope for the validated opcode
//
if (VarBlockData.Scope > 0) {
VarBlockData.Scope --;
@@ -1706,10 +1821,15 @@ ValidateQuestionFromVfr (
//
if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) {
return EFI_INVALID_PARAMETER;
}
break;
+ case EFI_IFR_GUID_OP:
+ if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEfiIfrBitvarstoreGuid)) {
+ mQuestionReferBitField = TRUE;
+ }
+ break;
default:
//
// Increase Scope for the validated opcode
//
if (VarBlockData.Scope > 0) {
diff --git a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h b/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h
index 9bf7696..293c226 100644
--- a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h
+++ b/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h
@@ -1,9 +1,9 @@
/** @file
Internal include file for the HII Library instance.
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 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
@@ -18,10 +18,12 @@
#include <Uefi.h>
#include <Protocol/DevicePath.h>
#include <Protocol/FormBrowser2.h>
+#include <Guid/MdeModuleHii.h>
+
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HiiLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf b/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
index 62f435a..411c758 100644
--- a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+++ b/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
@@ -1,9 +1,9 @@
## @file
# HII Library implementation using UEFI HII protocols and services.
#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -49,5 +49,8 @@
PrintLib
[Protocols]
gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES
+
+[Guids]
+ gEfiIfrBitvarstoreGuid ## SOMETIMES_CONSUMES ## GUID
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
` (2 preceding siblings ...)
2017-09-12 3:44 ` [PATCH v2 3/6] MdeModulePkg/UefiHiiLib: Add codes to validate question with bit fields Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
2017-09-12 3:44 ` [PATCH v2 5/6] MdeModulePkg/SetupBrowser: " Dandan Bi
2017-09-12 3:44 ` [PATCH v2 6/6] MdeModulePkg/DriverSample: Add sample questions with bit/union VarStore Dandan Bi
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
V2: Merge block data value with same offset/width
or offset/width has overlap region.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
For oneof/numeric/checkbox, their storage may be bit field.
When generating <ConfigAltResp> string to get default value
for these questions, we need to parse the Ifr data to get
the bit Varstore info,and then generating the correct
<ConfigAltResp> string.
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>
---
.../Universal/HiiDatabaseDxe/ConfigRouting.c | 247 ++++++++++++++++++---
.../Universal/HiiDatabaseDxe/HiiDatabase.h | 7 +-
.../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf | 3 +-
3 files changed, 226 insertions(+), 31 deletions(-)
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index c9ff1cf..daf22bf 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -13,10 +13,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HiiDatabase.h"
extern HII_DATABASE_PRIVATE_DATA mPrivate;
+BOOLEAN mQuestionReferBitVar = FALSE;
/**
Calculate the number of Unicode characters of the incoming Configuration string,
not including NULL terminator.
@@ -1223,19 +1224,19 @@ InsertBlockData (
// Insert block data in its Offset and Width order.
//
for (Link = BlockLink->ForwardLink; Link != BlockLink; Link = Link->ForwardLink) {
BlockArray = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
if (BlockArray->Offset == BlockSingleData->Offset) {
- if (BlockArray->Width > BlockSingleData->Width) {
+ if ((BlockArray->Width > BlockSingleData->Width) || (BlockSingleData->IsBitVar && BlockArray->Width == BlockSingleData->Width)) {
//
// Insert this block data in the front of block array
//
InsertTailList (Link, &BlockSingleData->Entry);
return;
}
- if (BlockArray->Width == BlockSingleData->Width) {
+ if ((!BlockSingleData->IsBitVar) && BlockArray->Width == BlockSingleData->Width) {
//
// The same block array has been added.
//
if (BlockSingleData != BlockArray) {
FreePool (BlockSingleData);
@@ -1978,10 +1979,11 @@ Done:
@param HiiHandle The hii handle for this form package.
@param VarStorageData The varstore data structure.
@param IfrOpHdr Ifr opcode header for this opcode.
@param VarWidth The buffer width for this opcode.
@param ReturnData The data block added for this opcode.
+ @param IsBitVar Whether the the opcode refers to bit storage.
@retval EFI_SUCCESS This opcode is required.
@retval EFI_NOT_FOUND This opcode is not required.
@retval Others Contain some error.
@@ -1991,20 +1993,26 @@ IsThisOpcodeRequired (
IN IFR_BLOCK_DATA *RequestBlockArray,
IN EFI_HII_HANDLE HiiHandle,
IN OUT IFR_VARSTORAGE_DATA *VarStorageData,
IN EFI_IFR_OP_HEADER *IfrOpHdr,
IN UINT16 VarWidth,
- OUT IFR_BLOCK_DATA **ReturnData
+ OUT IFR_BLOCK_DATA **ReturnData,
+ IN BOOLEAN IsBitVar
)
{
IFR_BLOCK_DATA *BlockData;
UINT16 VarOffset;
EFI_STRING_ID NameId;
EFI_IFR_QUESTION_HEADER *IfrQuestionHdr;
+ UINT16 BitOffset;
+ UINT16 BitWidth;
+ UINT16 TotalBits;
NameId = 0;
VarOffset = 0;
+ BitOffset = 0;
+ BitWidth = 0;
IfrQuestionHdr = (EFI_IFR_QUESTION_HEADER *)((CHAR8 *) IfrOpHdr + sizeof (EFI_IFR_OP_HEADER));
if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) {
NameId = IfrQuestionHdr->VarStoreInfo.VarName;
@@ -2016,11 +2024,27 @@ IsThisOpcodeRequired (
// This question is not in the requested string. Skip it.
//
return EFI_NOT_FOUND;
}
} else {
- VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ //
+ // Get the byte offset/with and bit offset/width
+ //
+ if (IsBitVar) {
+ BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ BitWidth = VarWidth;
+ VarOffset = BitOffset / 8;
+ //
+ // Use current bit width and the bit width before current bit (with same byte offset) to calculate the byte width.
+ //
+ TotalBits = BitOffset - (VarOffset * 8) + BitWidth;
+ VarWidth = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
+ } else {
+ VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ BitWidth = VarWidth;
+ BitOffset = VarOffset * 8;
+ }
//
// Check whether this question is in requested block array.
//
if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, HiiHandle)) {
@@ -2051,10 +2075,14 @@ IsThisOpcodeRequired (
BlockData->Width = VarWidth;
BlockData->QuestionId = IfrQuestionHdr->QuestionId;
BlockData->OpCode = IfrOpHdr->OpCode;
BlockData->Scope = IfrOpHdr->Scope;
+ BlockData->IsBitVar = IsBitVar;
+ BlockData->BitOffset = BitOffset;
+ BlockData->BitWidth = BitWidth;
+ BlockData->DefaultValueUpdated = FALSE;
InitializeListHead (&BlockData->DefaultValueEntry);
//
// Add Block Data into VarStorageData BlockEntry
//
InsertBlockData (&VarStorageData->BlockEntry, &BlockData);
@@ -2124,10 +2152,11 @@ ParseIfrData (
EFI_HII_PACKAGE_HEADER *PackageHeader;
EFI_VARSTORE_ID VarStoreId;
UINT16 SmallestDefaultId;
BOOLEAN SmallestIdFromFlag;
BOOLEAN FromOtherDefaultOpcode;
+ BOOLEAN IsBitVar;
Status = EFI_SUCCESS;
BlockData = NULL;
DefaultDataPtr = NULL;
FirstOneOfOption = FALSE;
@@ -2135,10 +2164,11 @@ ParseIfrData (
FirstOrderedList = FALSE;
VarStoreName = NULL;
ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));
SmallestDefaultId = 0xFFFF;
FromOtherDefaultOpcode = FALSE;
+ IsBitVar = FALSE;
//
// Go through the form package to parse OpCode one by one.
//
PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
@@ -2309,11 +2339,11 @@ ParseIfrData (
//
if (BlockData != NULL){
BlockData = NULL;
}
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2341,20 +2371,27 @@ ParseIfrData (
//
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
if (IfrOneOf->Question.VarStoreId != VarStoreId) {
break;
}
- VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+
+ if (mQuestionReferBitVar) {
+ VarWidth = IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE_BIT ;
+ IsBitVar = TRUE;
+ } else {
+ VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ IsBitVar = FALSE;
+ }
//
// The BlockData may allocate by other opcode,need to clean.
//
if (BlockData != NULL){
BlockData = NULL;
}
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, IsBitVar);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2376,30 +2413,38 @@ ParseIfrData (
} else if (IfrOpHdr->OpCode == EFI_IFR_NUMERIC_OP) {
//
// Numeric minimum value will be used as default value when no default is specified.
//
DefaultData.Type = DefaultValueFromDefault;
- switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- DefaultData.Value.u8 = IfrOneOf->data.u8.MinValue;
- break;
+ if (mQuestionReferBitVar) {
+ //
+ // Since default value in bit field was stored as UINT32 type.
+ //
+ mQuestionReferBitVar = FALSE;
+ CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, sizeof (UINT32));
+ } else {
+ switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ DefaultData.Value.u8 = IfrOneOf->data.u8.MinValue;
+ break;
- case EFI_IFR_NUMERIC_SIZE_2:
- CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, sizeof (UINT16));
- break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, sizeof (UINT16));
+ break;
- case EFI_IFR_NUMERIC_SIZE_4:
- CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, sizeof (UINT32));
- break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, sizeof (UINT32));
+ break;
- case EFI_IFR_NUMERIC_SIZE_8:
- CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue, sizeof (UINT64));
- break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue, sizeof (UINT64));
+ break;
- default:
- Status = EFI_INVALID_PARAMETER;
- goto Done;
+ default:
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
}
//
// Set default value base on the DefaultId list get from IFR data.
//
for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {
@@ -2439,11 +2484,11 @@ ParseIfrData (
//
if (BlockData != NULL){
BlockData = NULL;
}
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2484,11 +2529,19 @@ ParseIfrData (
//
if (BlockData != NULL){
BlockData = NULL;
}
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ if (mQuestionReferBitVar) {
+ mQuestionReferBitVar = FALSE;
+ VarWidth = 1;
+ IsBitVar = TRUE;
+ } else {
+ IsBitVar = FALSE;
+ }
+
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, IsBitVar);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2612,11 +2665,11 @@ ParseIfrData (
if (BlockData != NULL){
BlockData = NULL;
}
VarWidth = (UINT16) sizeof (EFI_HII_DATE);
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2654,11 +2707,11 @@ ParseIfrData (
if (BlockData != NULL){
BlockData = NULL;
}
VarWidth = (UINT16) sizeof (EFI_HII_TIME);
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2696,11 +2749,11 @@ ParseIfrData (
if (BlockData != NULL){
BlockData = NULL;
}
VarWidth = (UINT16) (IfrString->MaxSize * sizeof (UINT16));
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2738,11 +2791,11 @@ ParseIfrData (
if (BlockData != NULL){
BlockData = NULL;
}
VarWidth = (UINT16) (IfrPassword->MaxSize * sizeof (UINT16));
- Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
+ Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData, FALSE);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND){
//
//The opcode is not required,exit and parse other opcode.
//
@@ -2985,13 +3038,20 @@ ParseIfrData (
//
SmallestDefaultId = 0xFFFF;
FromOtherDefaultOpcode = FALSE;
}
}
+ mQuestionReferBitVar = FALSE;
break;
+ case EFI_IFR_GUID_OP:
+ if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEfiIfrBitvarstoreGuid)) {
+ mQuestionReferBitVar = TRUE;
+ }
+ break;
+
default:
if (BlockData != NULL) {
if (BlockData->Scope > 0) {
BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);
}
@@ -3566,10 +3626,137 @@ GetStorageWidth (
}
return StorageWidth;
}
+
+/**
+ Update Block data.
+
+ For some question (oneof/numeric/checkbox),their storage may be bit filed, their block data
+ may have same byte OFFSET and WIDTH or their offset and width has overlap region, this function
+ merge the value in these blocks.
+
+ @param BlockLink The Link of the block data.
+
+**/
+VOID
+UpdateBlockDataArray (
+ IN LIST_ENTRY *BlockLink
+)
+{
+ LIST_ENTRY *Link;
+ LIST_ENTRY *TempLink;
+ LIST_ENTRY *ListEntry;
+ LIST_ENTRY *NextListEntry;
+ LIST_ENTRY *LinkDefault;
+ LIST_ENTRY *NextLinkDefault;
+ IFR_BLOCK_DATA *BlockData;
+ IFR_BLOCK_DATA *NextBlockData;
+ IFR_DEFAULT_DATA *DefaultValueData;
+ IFR_DEFAULT_DATA *NextDefaultValueData;
+ UINT32 Mask;
+ UINT32 PreBits;
+ UINT16 MinOffset;
+ UINT16 OffsetShift;
+ UINT32 TempValue;
+ UINT32 *BlockDefaultValue;
+ UINT32 *NextBlockDefaultValue;
+ UINT32 TempBlockDefaultValue;
+ UINT32 TempNextBlockDefaultValue;
+ UINT32 TotalValue;
+
+ Link = BlockLink->ForwardLink;
+
+ while (Link != BlockLink) {
+ BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
+ TempLink = Link->ForwardLink;
+ if (!BlockData ->IsBitVar) {
+ Link = Link->ForwardLink;
+ continue;
+ }
+ //
+ // Find the block data with Bit VarStore. Need to set default value to related bit fields in the block.
+ //
+ if (!BlockData->DefaultValueUpdated){
+ ListEntry = &BlockData->DefaultValueEntry;
+ for (LinkDefault = ListEntry->ForwardLink; LinkDefault != ListEntry; LinkDefault = LinkDefault->ForwardLink) {
+ TempValue = 0;
+ DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry);
+ Mask = (1 << BlockData->BitWidth) - 1;
+ PreBits = BlockData->BitOffset - BlockData->Offset * 8;
+ BlockDefaultValue = (UINT32*)&(DefaultValueData->Value);
+ *BlockDefaultValue <<= PreBits;
+ Mask <<= PreBits;
+ *BlockDefaultValue = (TempValue & (~Mask)) | *BlockDefaultValue;
+ }
+ }
+
+ while (TempLink != BlockLink) {
+ NextBlockData = BASE_CR (TempLink, IFR_BLOCK_DATA, Entry);
+ TempLink = TempLink->ForwardLink;
+ if (!NextBlockData->IsBitVar || NextBlockData->Offset >= BlockData->Offset + BlockData->Width || BlockData->Offset >= NextBlockData->Offset + NextBlockData->Width) {
+ continue;
+ }
+ //
+ // Find blocks with same byte offset and width, or their offset and width has overlap region.
+ // We need to merge the default value in these blocks
+ //
+ ListEntry = &BlockData->DefaultValueEntry;
+ for (LinkDefault = ListEntry->ForwardLink; LinkDefault != ListEntry; LinkDefault = LinkDefault->ForwardLink) {
+ DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry);
+ NextListEntry = &NextBlockData->DefaultValueEntry;
+ for (NextLinkDefault = NextListEntry->ForwardLink; NextLinkDefault != NextListEntry; NextLinkDefault = NextLinkDefault->ForwardLink) {
+ NextDefaultValueData = BASE_CR (NextLinkDefault, IFR_DEFAULT_DATA, Entry);
+ if (DefaultValueData->DefaultId != NextDefaultValueData->DefaultId) {
+ continue;
+ }
+ //
+ // Find the default value in BlockData and NextBlockData with same Default Id.
+ //
+ // Set the default value to the bit fileds in NextBlock.
+ //
+ MinOffset = MIN (NextBlockData->Offset, BlockData->Offset);
+ OffsetShift = (BlockData->Offset > NextBlockData->Offset)? BlockData->Offset - NextBlockData->Offset: NextBlockData->Offset - BlockData->Offset;
+ Mask = (1 << NextBlockData->BitWidth) - 1;
+ PreBits = NextBlockData->BitOffset - MinOffset * 8;
+ NextBlockDefaultValue = (UINT32*) & (NextDefaultValueData->Value);
+ *NextBlockDefaultValue <<= PreBits;
+ NextBlockData->DefaultValueUpdated = TRUE;
+
+ //
+ // Merge the default value in NextBlockData with the value in BlockData.
+ //
+ BlockDefaultValue = (UINT32*) & (DefaultValueData->Value);
+ Mask <<= PreBits;
+ TotalValue = (*BlockDefaultValue & (~Mask)) | *NextBlockDefaultValue;
+
+ //
+ // Set the total value to the BlockData and NextBlockData respectively.
+ //
+ if (BlockData->Offset == MinOffset) {
+ TempBlockDefaultValue = TotalValue;
+ } else {
+ TempBlockDefaultValue = TotalValue >> OffsetShift * 8;
+ }
+ Mask = (1 << BlockData->Width * 8) - 1;
+ *BlockDefaultValue = TempBlockDefaultValue & Mask;
+
+ if (NextBlockData->Offset == MinOffset) {
+ TempNextBlockDefaultValue = TotalValue;
+ } else {
+ TempNextBlockDefaultValue = TotalValue >> OffsetShift * 8;
+ }
+ Mask = (1 << NextBlockData->Width * 8) - 1;
+ *NextBlockDefaultValue = TempNextBlockDefaultValue & Mask;
+ }
+ }
+ }
+ Link = Link->ForwardLink;
+ }
+}
+
/**
Generate ConfigAltResp string base on the varstore info.
@param HiiHandle Hii Handle for this hii package.
@param ConfigHdr The config header for this varstore.
@@ -3610,10 +3797,12 @@ GenerateAltConfigResp (
//
// Add length for <ConfigHdr> + '\0'
//
Length = StrLen (ConfigHdr) + 1;
+ UpdateBlockDataArray (&VarStorageData->BlockEntry);
+
for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) {
DefaultId = BASE_CR (Link, IFR_DEFAULT_DATA, Entry);
//
// Add length for "&<ConfigHdr>&ALTCFG=XXXX"
// |1| StrLen (ConfigHdr) | 8 | 4 |
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index e6760c3..5ce7d73 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -1,9 +1,9 @@
/** @file
Private structures definitions in HiiDatabase.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -29,10 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/HiiConfigKeyword.h>
#include <Protocol/SimpleTextOut.h>
#include <Guid/HiiKeyBoardLayout.h>
#include <Guid/GlobalVariable.h>
+#include <Guid/MdeModuleHii.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -75,15 +76,19 @@ typedef struct {
typedef struct {
LIST_ENTRY Entry; // Link to Block array
UINT16 Offset;
UINT16 Width;
+ UINT16 BitOffset;
+ UINT16 BitWidth;
EFI_QUESTION_ID QuestionId;
UINT8 OpCode;
UINT8 Scope;
LIST_ENTRY DefaultValueEntry; // Link to its default value array
CHAR16 *Name;
+ BOOLEAN IsBitVar;
+ BOOLEAN DefaultValueUpdated;
} IFR_BLOCK_DATA;
//
// Get default value from IFR data.
//
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
index 6bb1d03..9f99c2c 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
@@ -2,11 +2,11 @@
# The DXE driver produces HII protocols defined in UEFI specification.
#
# This driver produces all required HII serivces that includes HiiDataBase, HiiString,
# HiiFont, HiiConfigRouting. To support UEFI HII, this driver is required.
#
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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
@@ -88,10 +88,11 @@
## CONSUMES ## Event
## PRODUCES ## Event
gEfiHiiKeyBoardLayoutGuid
gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
+ gEfiIfrBitvarstoreGuid ## SOMETIMES_CONSUMES ## GUID
[Depex]
TRUE
[UserExtensions.TianoCore."ExtraFiles"]
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/6] MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
` (3 preceding siblings ...)
2017-09-12 3:44 ` [PATCH v2 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
2017-09-12 3:44 ` [PATCH v2 6/6] MdeModulePkg/DriverSample: Add sample questions with bit/union VarStore Dandan Bi
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
For oneof/numeric/CheckBox(storage can be Bit VarStore)
If the question value can be updated and shown correctly
in UI page, we need do enhancements in following cases:
1. Parse the Ifr data to get the bit VarStore info correctly.
2. Set/get value to/from bit VarStore correctly.
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>
---
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 139 ++++++++++++++++-----
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 120 ++++++++++++++++--
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 +
.../Universal/SetupBrowserDxe/SetupBrowserDxe.inf | 3 +-
4 files changed, 223 insertions(+), 42 deletions(-)
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 6b3e5e0..63232ee 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -15,10 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Setup.h"
UINT16 mStatementIndex;
UINT16 mExpressionOpCodeIndex;
EFI_QUESTION_ID mUsedQuestionId;
+BOOLEAN mQuestionReferBitVar = FALSE;
+
extern LIST_ENTRY gBrowserStorageList;
/**
Initialize Statement header members.
@param OpCodeData Pointer of the raw OpCode data.
@@ -57,10 +59,11 @@ CreateStatement (
Statement->Signature = FORM_BROWSER_STATEMENT_SIGNATURE;
Statement->Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
Statement->OpCode = (EFI_IFR_OP_HEADER *) OpCodeData;
+ Statement->QuestionReferToBitField = FALSE;
StatementHdr = (EFI_IFR_STATEMENT_HEADER *) (OpCodeData + sizeof (EFI_IFR_OP_HEADER));
CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_ID));
CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID));
@@ -1312,10 +1315,11 @@ ParseOpCodes (
BOOLEAN InUnknownScope;
UINT8 UnknownDepth;
FORMSET_DEFAULTSTORE *PreDefaultStore;
LIST_ENTRY *DefaultLink;
BOOLEAN HaveInserted;
+ UINT16 TotalBits;
SuppressForQuestion = FALSE;
SuppressForOption = FALSE;
InScopeDisable = FALSE;
DepthOfDisable = 0;
@@ -1978,47 +1982,99 @@ ParseOpCodes (
ASSERT(CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_ONE_OF *) OpCodeData)->Flags;
Value = &CurrentStatement->HiiValue;
- switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue;
- CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue;
- CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step;
- CurrentStatement->StorageWidth = (UINT16) sizeof (UINT8);
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
- break;
+ if (mQuestionReferBitVar) {
+ mQuestionReferBitVar = FALSE;
+ //
+ // Get the bit var store info (bit/byte offset, bit/byte offset)
+ //
+ CurrentStatement->BitStorageWidth = CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE_BIT;
+ CurrentStatement->QuestionReferToBitField = TRUE;
+ CurrentStatement->BitVarOffset = CurrentStatement->VarStoreInfo.VarOffset;
+ CurrentStatement->VarStoreInfo.VarOffset = CurrentStatement->BitVarOffset / 8;
+ TotalBits = CurrentStatement->BitVarOffset - (CurrentStatement->VarStoreInfo.VarOffset * 8) + CurrentStatement->BitStorageWidth;
+ CurrentStatement->StorageWidth = (TotalBits % 8 == 0? TotalBits / 8: TotalBits / 8 + 1);
- case EFI_IFR_NUMERIC_SIZE_2:
- CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue, sizeof (UINT16));
- CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue, sizeof (UINT16));
- CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step, sizeof (UINT16));
- CurrentStatement->StorageWidth = (UINT16) sizeof (UINT16);
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
- break;
+ //
+ // Get the Minimum/Maximum/Step value(Note: bit field type has been stored as UINT32 type)
+ //
+ CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue;
+ CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue;
+ CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step;
- case EFI_IFR_NUMERIC_SIZE_4:
- CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue, sizeof (UINT32));
- CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue, sizeof (UINT32));
- CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step, sizeof (UINT32));
- CurrentStatement->StorageWidth = (UINT16) sizeof (UINT32);
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
- break;
+ //
+ // Update the Flag and type of Minimum/Maximum/Step according to the actual width of bit field,
+ // in order to make Browser handle these question with bit varstore correctly.
+ //
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &= EFI_IFR_DISPLAY_BIT;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags >>= 2;
+ switch (CurrentStatement->StorageWidth) {
+ case 1:
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |= EFI_IFR_TYPE_NUM_SIZE_8;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue = (UINT8)CurrentStatement->Minimum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue = (UINT8)CurrentStatement->Maximum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step = (UINT8)CurrentStatement->Step;
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ break;
+ case 2:
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |= EFI_IFR_TYPE_NUM_SIZE_16;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue = (UINT16)CurrentStatement->Minimum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue = (UINT16)CurrentStatement->Maximum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step = (UINT16)CurrentStatement->Step;
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ break;
+ case 3:
+ case 4:
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |= EFI_IFR_TYPE_NUM_SIZE_32;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue = (UINT32)CurrentStatement->Minimum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue = (UINT32)CurrentStatement->Maximum;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step = (UINT32)CurrentStatement->Step;
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue;
+ CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue;
+ CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step;
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT8);
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ break;
- case EFI_IFR_NUMERIC_SIZE_8:
- CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MinValue, sizeof (UINT64));
- CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MaxValue, sizeof (UINT64));
- CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.Step, sizeof (UINT64));
- CurrentStatement->StorageWidth = (UINT16) sizeof (UINT64);
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue, sizeof (UINT16));
+ CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue, sizeof (UINT16));
+ CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step, sizeof (UINT16));
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT16);
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ break;
- default:
- break;
- }
+ case EFI_IFR_NUMERIC_SIZE_4:
+ CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue, sizeof (UINT32));
+ CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue, sizeof (UINT32));
+ CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step, sizeof (UINT32));
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT32);
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_8:
+ CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MinValue, sizeof (UINT64));
+ CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MaxValue, sizeof (UINT64));
+ CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.Step, sizeof (UINT64));
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT64);
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ break;
+ default:
+ break;
+ }
+ }
InitializeRequestElement (FormSet, CurrentStatement, CurrentForm);
if ((Operand == EFI_IFR_ONE_OF_OP) && Scope != 0) {
SuppressForOption = TRUE;
}
@@ -2045,10 +2101,23 @@ ParseOpCodes (
CurrentStatement->Flags = ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags;
CurrentStatement->StorageWidth = (UINT16) sizeof (BOOLEAN);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
+ if (mQuestionReferBitVar) {
+ //
+ // Get the bit var store info (bit/byte offset, bit/byte offset)
+ //
+ mQuestionReferBitVar = FALSE;
+ CurrentStatement->BitStorageWidth = 1;
+ CurrentStatement->QuestionReferToBitField = TRUE;
+ CurrentStatement->BitVarOffset = CurrentStatement->VarStoreInfo.VarOffset;
+ CurrentStatement->VarStoreInfo.VarOffset = CurrentStatement->BitVarOffset / 8;
+ TotalBits = CurrentStatement->BitVarOffset - (CurrentStatement->VarStoreInfo.VarOffset * 8) + CurrentStatement->BitStorageWidth;
+ CurrentStatement->StorageWidth = (TotalBits % 8 == 0? TotalBits / 8: TotalBits / 8 + 1);
+ }
+
InitializeRequestElement (FormSet, CurrentStatement, CurrentForm);
break;
case EFI_IFR_STRING_OP:
@@ -2592,12 +2661,16 @@ ParseOpCodes (
break;
//
// Vendor specific
//
- case EFI_IFR_GUID_OP:
+ case EFI_IFR_GUID_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
+ if (CompareGuid ((EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)), &gEfiIfrBitvarstoreGuid)) {
+ Scope = 0;
+ mQuestionReferBitVar = TRUE;
+ }
break;
//
// Scope End
//
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 89e06de..2884e45 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1367,10 +1367,73 @@ ConfigRespToStorage (
return Status;
}
/**
+ Get the question value with bit field from the buffer.
+
+ @param Question The question refer to bit field.
+ @param Buffer The buffer which the question value get from.
+ @param Value Retun the value.
+
+**/
+VOID
+GetBitsQuestionValue(
+ IN FORM_BROWSER_STATEMENT *Question,
+ IN UINT8 *Buffer,
+ OUT UINT32 *Value
+ )
+{
+ UINT32 PreBits;
+ UINT32 Mask;
+
+ PreBits = Question->BitVarOffset - Question->VarStoreInfo.VarOffset * 8;
+ Mask = (1<< Question->BitStorageWidth) -1;
+ (*Value) = *(Buffer);
+ (*Value) |= *(Buffer + 1) << 8;
+ (*Value) |= *(Buffer + 2) << 16;
+ (*Value) |= *(Buffer + 3) << 24;
+ (*Value) >>= PreBits;
+ (*Value) &= Mask;
+}
+
+/**
+ Set the question value with bit field to the buffer.
+
+ @param Question The question refer to bit field.
+ @param Buffer The buffer which the question value set to.
+ @param Value The value need to set.
+
+**/
+VOID
+SetBitsQuestionValue (
+ IN FORM_BROWSER_STATEMENT *Question,
+ IN UINT8 *Buffer,
+ IN UINT32 Value
+ )
+{
+ UINT32 PreBits;
+ UINT32 Mask;
+ UINT32 TmpBuffer;
+
+ PreBits = Question->BitVarOffset - Question->VarStoreInfo.VarOffset * 8;
+ Value <<= PreBits;
+ Mask = (1<< Question->BitStorageWidth) -1;
+ Mask <<= PreBits;
+ TmpBuffer = *(Buffer);
+ TmpBuffer |= *(Buffer + 1) << 8;
+ TmpBuffer |= *(Buffer + 2) << 16;
+ TmpBuffer |= *(Buffer + 3) << 24;
+
+ TmpBuffer = (TmpBuffer & (~Mask)) | Value;
+ *(Buffer) = (UINT8) TmpBuffer & 0xFF;
+ *(Buffer + 1) = (UINT8) (TmpBuffer >> 8);
+ *(Buffer + 2) = (UINT8) (TmpBuffer >> 16);
+ *(Buffer + 3) = (UINT8) (TmpBuffer >> 24);
+}
+
+/**
Convert the buffer value to HiiValue.
@param Question The question.
@param Value Unicode buffer save the question value.
@@ -1393,10 +1456,14 @@ BufferToValue (
UINTN Index;
UINT8 DigitUint8;
BOOLEAN IsString;
UINTN Length;
EFI_STATUS Status;
+ UINT8 *Buffer;
+ UINT32 BufferValue;
+
+ Buffer = NULL;
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);
if (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER ||
Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
IsBufferStorage = TRUE;
@@ -1414,11 +1481,17 @@ BufferToValue (
Dst = Question->BufferValue;
} else {
//
// Other type of Questions
//
- Dst = (UINT8 *) &Question->HiiValue.Value;
+ if (Question->QuestionReferToBitField) {
+ Buffer = (UINT8 *)AllocateZeroPool (Question->StorageWidth);
+ ASSERT (Buffer != NULL);
+ Dst = Buffer;
+ } else {
+ Dst = (UINT8 *) &Question->HiiValue.Value;
+ }
}
//
// Temp cut at the end of this section, end with '\0' or '&'.
//
@@ -1472,10 +1545,18 @@ BufferToValue (
}
}
*StringPtr = TempChar;
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Buffer, &BufferValue);
+ CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8*)&BufferValue, Question->StorageWidth);
+ if (Buffer != NULL) {
+ FreePool (Buffer);
+ }
+ }
+
return Status;
}
/**
Get Question's current Value.
@@ -1510,10 +1591,11 @@ GetQuestionValue (
CHAR16 *Result;
CHAR16 *Value;
UINTN Length;
BOOLEAN IsBufferStorage;
UINTN MaxLen;
+ UINT32 BufferValue;
Status = EFI_SUCCESS;
Value = NULL;
Result = NULL;
@@ -1676,17 +1758,29 @@ GetQuestionValue (
if (GetValueFrom == GetSetValueWithEditBuffer || GetValueFrom == GetSetValueWithBuffer ) {
if (IsBufferStorage) {
if (GetValueFrom == GetSetValueWithEditBuffer) {
//
// Copy from storage Edit buffer
+ // If the Question refer to bit filed, get the value in the related bit filed.
//
- CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, &BufferValue);
+ CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth);
+ } else {
+ CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ }
} else {
//
// Copy from storage Edit buffer
+ // If the Question refer to bit filed, get the value in the related bit filed.
//
- CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ if (Question->QuestionReferToBitField) {
+ GetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset, &BufferValue);
+ CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth);
+ } else {
+ CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);
+ }
}
} else {
Value = NULL;
Status = GetValueByName (Storage, Question->VariableName, &Value, GetValueFrom);
if (EFI_ERROR (Status)) {
@@ -1948,17 +2042,27 @@ SetQuestionValue (
if (SetValueTo == GetSetValueWithEditBuffer || SetValueTo == GetSetValueWithBuffer) {
if (IsBufferStorage) {
if (SetValueTo == GetSetValueWithEditBuffer) {
//
// Copy to storage edit buffer
- //
- CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ // If the Question refer to bit filed, copy the value in related bit filed to storage edit buffer.
+ //
+ if (Question->QuestionReferToBitField) {
+ SetBitsQuestionValue (Question, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));
+ } else {
+ CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ }
} else if (SetValueTo == GetSetValueWithBuffer) {
//
- // Copy to storage edit buffer
- //
- CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ // Copy to storage buffer
+ // If the Question refer to bit filed, copy the value in related bit filed to storage buffer.
+ //
+ if (Question->QuestionReferToBitField) {
+ SetBitsQuestionValue (Question, Storage->Buffer + Question->VarStoreInfo.VarOffset, (UINT32)(*Src));
+ } else {
+ CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);
+ }
}
} else {
if (IsString) {
//
// Allocate enough string buffer.
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index de140e9..09e0be7 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -327,11 +327,14 @@ struct _FORM_BROWSER_STATEMENT{
EFI_QUESTION_ID QuestionId; // The value of zero is reserved
EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
BROWSER_STORAGE *Storage;
VAR_STORE_INFO VarStoreInfo;
UINT16 StorageWidth;
+ UINT16 BitStorageWidth;
+ UINT16 BitVarOffset;
UINT8 QuestionFlags;
+ BOOLEAN QuestionReferToBitField;// Whether the question is stored in a bit field.
CHAR16 *VariableName; // Name/Value or EFI Variable name
CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
UINT8 *BufferValue; // Edit copy for string, password, orderedlist
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
index 012a39b..f979a2f 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
@@ -1,11 +1,11 @@
## @file
# The DXE driver produces FORM BROWSER2 protocol defined in UEFI specification.
#
# It also produces FormBrowserEx(2) protocol to let user register the different Hot key service.
#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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
@@ -60,10 +60,11 @@
[Guids]
gEfiIfrFrameworkGuid ## SOMETIMES_CONSUMES ## GUID
gEfiHiiPlatformSetupFormsetGuid ## SOMETIMES_CONSUMES ## GUID
gEfiHiiStandardFormGuid ## SOMETIMES_CONSUMES ## GUID
gZeroGuid ## SOMETIMES_CONSUMES ## GUID
+ gEfiIfrBitvarstoreGuid ## SOMETIMES_CONSUMES ## GUID
[Protocols]
gEfiHiiConfigAccessProtocolGuid ## SOMETIMES_CONSUMES
gEfiFormBrowser2ProtocolGuid ## PRODUCES
gEdkiiFormBrowserEx2ProtocolGuid ## PRODUCES
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 6/6] MdeModulePkg/DriverSample: Add sample questions with bit/union VarStore
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
` (4 preceding siblings ...)
2017-09-12 3:44 ` [PATCH v2 5/6] MdeModulePkg/SetupBrowser: " Dandan Bi
@ 2017-09-12 3:44 ` Dandan Bi
5 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2017-09-12 3:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong, Liming Gao
V2: Refine the new added questions and their field name in Varstore.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=545
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>
---
.../Universal/DriverSampleDxe/DriverSample.c | 120 ++++++++++++++
.../Universal/DriverSampleDxe/DriverSample.h | 2 +
.../Universal/DriverSampleDxe/NVDataStruc.h | 34 +++-
MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 173 +++++++++++++++++++++
.../Universal/DriverSampleDxe/VfrStrings.uni | 61 ++++++++
5 files changed, 389 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index bbd9713..af31615 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -18,10 +18,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define DISPLAY_ONLY_MY_ITEM 0x0002
CHAR16 VariableName[] = L"MyIfrNVData";
CHAR16 MyEfiVar[] = L"MyEfiVar";
+CHAR16 MyEfiBitVar[] = L"MyEfiBitVar";
+CHAR16 MyEfiUnionVar[] = L"MyEfiUnionVar";
+
EFI_HANDLE DriverHandle[2] = {NULL, NULL};
DRIVER_SAMPLE_PRIVATE_DATA *mPrivateData = NULL;
EFI_EVENT mEvent;
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 = {
@@ -662,10 +665,17 @@ ExtractConfig (
// through hii database, not support in this path.
//
if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiVar)) {
return EFI_UNSUPPORTED;
}
+ if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiBitVar)) {
+ return EFI_UNSUPPORTED;
+ }
+ if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiUnionVar)) {
+ return EFI_UNSUPPORTED;
+ }
+
//
// Set Request to the unified request string.
//
ConfigRequest = Request;
//
@@ -883,10 +893,16 @@ RouteConfig (
// through hii database, not support in this path.
//
if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiVar)) {
return EFI_UNSUPPORTED;
}
+ if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiBitVar)) {
+ return EFI_UNSUPPORTED;
+ }
+ if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiUnionVar)) {
+ return EFI_UNSUPPORTED;
+ }
//
// Get Buffer Storage data from EFI variable
//
BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
@@ -1295,10 +1311,14 @@ DriverCallback (
for (Index = 0; Index < 3; Index ++) {
SetArrayData (Value, EFI_IFR_TYPE_NUM_SIZE_8, Index, BufferValue--);
}
break;
+ case 0x6666:
+ Value->u8 = 12;
+ break;
+
default:
Status = EFI_UNSUPPORTED;
break;
}
}
@@ -1309,10 +1329,14 @@ DriverCallback (
switch (QuestionId) {
case 0x1240:
Value->u8 = DEFAULT_CLASS_MANUFACTURING_VALUE;
break;
+ case 0x6666:
+ Value->u8 = 13;
+ break;
+
default:
Status = EFI_UNSUPPORTED;
break;
}
}
@@ -1703,10 +1727,12 @@ DriverSampleInit (
DRIVER_SAMPLE_CONFIGURATION *Configuration;
BOOLEAN ActionFlag;
EFI_STRING ConfigRequestHdr;
EFI_STRING NameRequestHdr;
MY_EFI_VARSTORE_DATA *VarStoreConfig;
+ MY_EFI_BITS_VARSTORE_DATA *BitsVarStoreConfig;
+ MY_EFI_UNION_DATA *UnionConfig;
EFI_INPUT_KEY HotKey;
EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx;
//
// Initialize the local variables.
@@ -1991,10 +2017,104 @@ DriverSampleInit (
return EFI_INVALID_PARAMETER;
}
}
FreePool (ConfigRequestHdr);
+ //
+ // Initialize Bits efi varstore configuration data
+ //
+ BitsVarStoreConfig = &mPrivateData->BitsVarStoreConfig;
+ ZeroMem (BitsVarStoreConfig, sizeof (MY_EFI_BITS_VARSTORE_DATA));
+
+ ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, MyEfiBitVar, DriverHandle[0]);
+ ASSERT (ConfigRequestHdr != NULL);
+
+ BufferSize = sizeof (MY_EFI_BITS_VARSTORE_DATA);
+ Status = gRT->GetVariable (MyEfiBitVar, &gDriverSampleFormSetGuid, NULL, &BufferSize, BitsVarStoreConfig);
+ if (EFI_ERROR (Status)) {
+ //
+ // Store zero data to EFI variable Storage.
+ //
+ Status = gRT->SetVariable(
+ MyEfiBitVar,
+ &gDriverSampleFormSetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (MY_EFI_BITS_VARSTORE_DATA),
+ BitsVarStoreConfig
+ );
+ if (EFI_ERROR (Status)) {
+ DriverSampleUnload (ImageHandle);
+ return Status;
+ }
+ //
+ // EFI variable for NV config doesn't exit, we should build this variable
+ // based on default values stored in IFR
+ //
+ ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
+ if (!ActionFlag) {
+ DriverSampleUnload (ImageHandle);
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ //
+ // EFI variable does exist and Validate Current Setting
+ //
+ ActionFlag = HiiValidateSettings (ConfigRequestHdr);
+ if (!ActionFlag) {
+ DriverSampleUnload (ImageHandle);
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ FreePool (ConfigRequestHdr);
+
+ //
+ // Initialize Union efi varstore configuration data
+ //
+ UnionConfig = &mPrivateData->UnionConfig;
+ ZeroMem (UnionConfig, sizeof (MY_EFI_UNION_DATA));
+
+ ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, MyEfiUnionVar, DriverHandle[0]);
+ ASSERT (ConfigRequestHdr != NULL);
+
+ BufferSize = sizeof (MY_EFI_UNION_DATA);
+ Status = gRT->GetVariable (MyEfiUnionVar, &gDriverSampleFormSetGuid, NULL, &BufferSize, UnionConfig);
+ if (EFI_ERROR (Status)) {
+ //
+ // Store zero data to EFI variable Storage.
+ //
+ Status = gRT->SetVariable(
+ MyEfiUnionVar,
+ &gDriverSampleFormSetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (MY_EFI_UNION_DATA),
+ UnionConfig
+ );
+ if (EFI_ERROR (Status)) {
+ DriverSampleUnload (ImageHandle);
+ return Status;
+ }
+ //
+ // EFI variable for NV config doesn't exit, we should build this variable
+ // based on default values stored in IFR
+ //
+ ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
+ if (!ActionFlag) {
+ DriverSampleUnload (ImageHandle);
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ //
+ // EFI variable does exist and Validate Current Setting
+ //
+ ActionFlag = HiiValidateSettings (ConfigRequestHdr);
+ if (!ActionFlag) {
+ DriverSampleUnload (ImageHandle);
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ FreePool (ConfigRequestHdr);
+
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
EfiEventEmptyFunction,
NULL,
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
index 507cff6..00752bf 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
@@ -83,10 +83,12 @@ typedef struct {
EFI_HANDLE DriverHandle[2];
EFI_HII_HANDLE HiiHandle[2];
DRIVER_SAMPLE_CONFIGURATION Configuration;
MY_EFI_VARSTORE_DATA VarStoreConfig;
+ MY_EFI_BITS_VARSTORE_DATA BitsVarStoreConfig;
+ MY_EFI_UNION_DATA UnionConfig;
//
// Name/Value storage Name list
//
EFI_STRING_ID NameStringId[NAME_VALUE_NAME_NUMBER];
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
index 195cc8a..40fb3d0 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
@@ -1,8 +1,8 @@
/** @file
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -29,12 +29,28 @@ Revision History:
#include <Guid/HiiFormMapMethodGuid.h>
#include <Guid/DriverSampleHii.h>
#include <Guid/ZeroGuid.h>
#define CONFIGURATION_VARSTORE_ID 0x1234
+#define BITS_VARSTORE_ID 0x2345
#pragma pack(1)
+
+typedef struct {
+ UINT16 NestByteField;
+ UINT8 : 1; // unamed field can be used for padding
+ UINT8 NestBitCheckbox : 1;
+ UINT8 NestBitOneof : 2;
+ UINT8 : 0; // Special width 0 can be used to force alignment at the next word boundary
+ UINT8 NestBitNumeric : 4;
+} MY_BITS_DATA;
+
+typedef union {
+ UINT16 BitField : 10;
+ UINT8 ByteField;
+} MY_EFI_UNION_DATA;
+
typedef struct {
UINT16 MyStringData[40];
UINT16 SomethingHiddenForHtml;
UINT8 HowOldAreYouInYearsManual;
UINT16 HowTallAreYouManual;
@@ -65,10 +81,15 @@ typedef struct {
UINT8 GetDefaultValueFromAccess;
EFI_HII_TIME Time;
UINT8 RefreshGuidCount;
UINT8 Match2;
UINT8 GetDefaultValueFromCallBackForOrderedList[3];
+ UINT8 BitCheckbox : 1;
+ UINT16 BitOneof : 6;
+ UINT16 BitNumeric : 12;
+ MY_BITS_DATA MyBitData;
+ MY_EFI_UNION_DATA MyUnionData;
} DRIVER_SAMPLE_CONFIGURATION;
//
// 2nd NV data structure definition
//
@@ -78,10 +99,21 @@ typedef struct {
UINT8 OrderedList[3];
UINT16 SubmittedCallback;
} MY_EFI_VARSTORE_DATA;
//
+// 3rd NV data structure definition
+//
+typedef struct {
+ MY_BITS_DATA BitsData;
+ UINT32 EfiBitGrayoutTest : 5;
+ UINT32 EfiBitNumeric : 4;
+ UINT32 EfiBitOneof : 10;
+ UINT32 EfiBitCheckbox : 1;
+} MY_EFI_BITS_VARSTORE_DATA;
+
+//
// Labels definition
//
#define LABEL_UPDATE1 0x1234
#define LABEL_UPDATE2 0x2234
#define LABEL_UPDATE3 0x3234
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
index d547ec8..39a6753 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
+++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
@@ -86,10 +86,23 @@ formset
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures
name = MyEfiVar,
guid = DRIVER_SAMPLE_FORMSET_GUID;
//
+ // Define a Buffer Storage (EFI_IFR_VARSTORE)
+ //
+ efivarstore MY_EFI_BITS_VARSTORE_DATA, // This is the data structure type
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures
+ name = MyEfiBitVar, // Define referenced name in vfr
+ guid = DRIVER_SAMPLE_FORMSET_GUID; // GUID of this buffer storage
+
+ efivarstore MY_EFI_UNION_DATA,
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures
+ name = MyEfiUnionVar,
+ guid = DRIVER_SAMPLE_FORMSET_GUID;
+
+ //
// Define a Name/Value Storage (EFI_IFR_VARSTORE_NAME_VALUE)
//
namevaluevarstore MyNameValueVar, // Define storage reference name in vfr
name = STRING_TOKEN(STR_NAME_VALUE_VAR_NAME0), // Define Name list of this storage, refer it by MyNameValueVar[0]
name = STRING_TOKEN(STR_NAME_VALUE_VAR_NAME1), // Define Name list of this storage, refer it by MyNameValueVar[1]
@@ -516,10 +529,13 @@ formset
data.Field8 = 0x21,
data.Field16 = 0x2121,
data.OrderedList[0] = 0x21,
endguidop;
+ goto 7,
+ prompt = STRING_TOKEN(STR_GOTO_FORM7),
+ help = STRING_TOKEN(STR_GOTO_FORM7_HELP);
endform;
suppressif ideqval MyIfrNVData.BootOrderLarge == 0;
form formid = 2, // SecondSetupPage,
@@ -778,6 +794,163 @@ formset
//
label LABEL_END;
endform;
+
+ form formid = 7, // Form to show the question refer to union and bit Varstore
+ title = STRING_TOKEN(STR_FORM7_TITLE);
+
+ subtitle text = STRING_TOKEN(STR_NEST_BIT_EFI_VARSTORE);
+
+ checkbox varid = MyEfiBitVar.BitsData.NestBitCheckbox,
+ prompt = STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_HELP),
+ flags = CHECKBOX_DEFAULT,
+ endcheckbox;
+
+ oneof varid = MyEfiBitVar.BitsData.NestBitOneof,
+ prompt = STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT),
+ help = STRING_TOKEN(STR_ONE_OF_BIT_NEST_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 1, flags = DEFAULT;
+ endoneof;
+
+ numeric varid = MyEfiBitVar.BitsData.NestBitNumeric,
+ questionid = 0x6666,
+ prompt = STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NEST_NUMERIC_DEFAULT_HELP),
+ flags = DISPLAY_UINT_HEX | INTERACTIVE,
+ minimum = 2,
+ maximum = 15,
+ step = 1,
+ endnumeric;
+
+ oneof varid = MyEfiBitVar.BitsData.NestByteField,
+ prompt = STRING_TOKEN(BYTE_QUESTION_NEST_BIT_PROMPT),
+ help = STRING_TOKEN(BYTE_QUESTION_NEST_BIT_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 1, flags = DEFAULT;
+ endoneof;
+
+ subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
+ subtitle text = STRING_TOKEN(STR_BIT_EFI_VARSTORE);
+
+ checkbox varid = MyEfiBitVar.EfiBitCheckbox,
+ prompt = STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT),
+ help = STRING_TOKEN(STR_BIT_CHECK_BOX_HELP),
+ flags = CHECKBOX_DEFAULT,
+ endcheckbox;
+
+ grayoutif ideqval MyEfiBitVar.EfiBitGrayoutTest == 0;
+ numeric varid = MyEfiBitVar.EfiBitNumeric,
+ questionid = 0x8888,
+ prompt = STRING_TOKEN(STR_BIT_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NUMERIC_HELP),
+ minimum = 0,
+ maximum = 7,
+ step = 0,
+ default = 4, defaultstore = MyStandardDefault,
+ default = 5, defaultstore = MyManufactureDefault,
+ endnumeric;
+ endif;
+
+ oneof varid = MyEfiBitVar.EfiBitOneof,
+ questionid = 0x9999,
+ prompt = STRING_TOKEN(STR_ONE_OF_BIT_PROMPT),
+ help = STRING_TOKEN(STR_ONE_OF_BIT_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0x0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 0x1, flags = DEFAULT;
+ endoneof;
+
+ subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
+ subtitle text = STRING_TOKEN(STR_NEST_BIT_VARSTORE);
+ checkbox varid = MyIfrNVData.MyBitData.NestBitCheckbox,
+ prompt = STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_HELP),
+ flags = CHECKBOX_DEFAULT,
+ endcheckbox;
+
+ oneof varid = MyIfrNVData.MyBitData.NestBitOneof,
+ prompt = STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT),
+ help = STRING_TOKEN(STR_ONE_OF_BIT_NEST_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 1, flags = DEFAULT;
+ endoneof;
+
+ numeric varid = MyIfrNVData.MyBitData.NestBitNumeric,
+ prompt = STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NEST_NUMERIC_HELP),
+ minimum = 0,
+ maximum = 7,
+ step = 0,
+ default = 6, defaultstore = MyStandardDefault,
+ default = 7, defaultstore = MyManufactureDefault,
+ endnumeric;
+
+ oneof varid = MyIfrNVData.MyBitData.NestByteField,
+ prompt = STRING_TOKEN(BYTE_QUESTION_NEST_BIT_PROMPT),
+ help = STRING_TOKEN(BYTE_QUESTION_NEST_BIT_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 1, flags = DEFAULT;
+ endoneof;
+
+ subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
+ subtitle text = STRING_TOKEN(STR_BIT_VARSTORE);
+
+ oneof varid = MyIfrNVData.BitOneof,
+ prompt = STRING_TOKEN(STR_ONE_OF_BIT_PROMPT),
+ help = STRING_TOKEN(STR_ONE_OF_BIT_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0, flags = MANUFACTURING;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 1, flags = DEFAULT;
+ endoneof;
+
+ checkbox varid = MyIfrNVData.BitCheckbox,
+ prompt = STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT),
+ help = STRING_TOKEN(STR_BIT_CHECK_BOX_HELP),
+ flags = CHECKBOX_DEFAULT,
+ endcheckbox;
+
+ numeric varid = MyIfrNVData.BitNumeric,
+ prompt = STRING_TOKEN(STR_BIT_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_BIT_NUMERIC_HELP),
+ minimum = 0,
+ maximum = 20,
+ step = 0,
+ default = 16, defaultstore = MyStandardDefault,
+ default = 17, defaultstore = MyManufactureDefault,
+ endnumeric;
+
+ subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
+ subtitle text = STRING_TOKEN(STR_UNION_EFI_VARSTORE);
+
+ numeric varid = MyEfiUnionVar.ByteField,
+ prompt = STRING_TOKEN(STR_UNION_BYTE_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_UNION_BYTE_NUMERIC_HELP),
+ minimum = 0,
+ maximum = 20,
+ step = 0,
+ default = 7, defaultstore = MyStandardDefault,
+ default = 8, defaultstore = MyManufactureDefault,
+ endnumeric;
+
+ numeric varid = MyEfiUnionVar.BitField,
+ prompt = STRING_TOKEN(STR_UNION_BIT_NUMERIC_PROMPT),
+ help = STRING_TOKEN(STR_UNION_BIT_NUMERIC_HELP),
+ minimum = 0,
+ maximum = 20,
+ step = 0,
+ default = 7, defaultstore = MyStandardDefault,
+ default = 8, defaultstore = MyManufactureDefault,
+ endnumeric;
+
+ guidop
+ guid = DRIVER_SAMPLE_FORMSET_GUID,
+ datatype = MY_EFI_BITS_VARSTORE_DATA,
+ data.EfiBitNumeric = 1,
+ data.EfiBitOneof = 1,
+ data.EfiBitCheckbox = 1,
+ endguidop;
+
+ endform;
+
endformset;
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
index 6a268d1..d9d46df 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
+++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
@@ -271,10 +271,71 @@
#language fr-FR "Select it to invoke Hii Popup Protocol"
#string STR_POPUP_TEST_HELP #language en-US "Select this question will pop up a message box, then user can decide whether exit curret form or not"
#language fr-FR "Select this question will pop up a message box, then user can decide whether exit curret form or not"
#string STR_POPUP_STRING #language en-US "Are you sure to exit current form?"
#language fr-FR "Are you sure to exit current form?"
+//
+// Form 7 to show Questions which refer to Union Bit varstore
+//
+#string STR_FORM7_TITLE #language en-US "Form to Show Questions with union and bit VarStore"
+ #language fr-FR "Form to Show Questions with union and bit VarStore"
+#string STR_GOTO_FORM7 #language en-US "Enter Page 7"
+ #language fr-FR "Enter Page 7"
+#string STR_GOTO_FORM7_HELP #language en-US "This Form is to Show Questions with union and bit VarStore"
+ #language fr-FR "This Form is to Show Questions with union and bit VarStore"
+#string STR_NEST_BIT_EFI_VARSTORE #language en-US "Nested BIT fields in efivarstore"
+ #language fr-FR "Nested BIT fields in efivarstore"
+#string STR_BIT_EFI_VARSTORE #language en-US "BIT fields in efivarstore"
+ #language fr-FR "BIT fields in efivarstore"
+#string STR_NEST_BIT_VARSTORE #language en-US "Nested BIT fields in bufferstore"
+ #language fr-FR "Nested BIT fields in bufferstore"
+#string STR_BIT_VARSTORE #language en-US "BIT fields in bufferstore"
+ #language fr-FR "BIT fields in bufferstore"
+#string STR_UNION_EFI_VARSTORE #language en-US "Union efivarstore"
+ #language fr-FR "Union efivarstore"
+#string STR_BIT_NEST_CHECK_BOX_PROMPT #language en-US "NEST_BIT check box"
+ #language fr-FR "NEST_BIT check box"
+#string STR_BIT_NEST_CHECK_BOX_HELP #language en-US "The check box refer to nested bit field"
+ #language fr-FR "The check box refer to nested bit field"
+#string STR_ONE_OF_BIT_NEST_PROMPT #language en-US "NEST_BIT one-of"
+ #language fr-FR "NEST_BIT one-of"
+#string STR_ONE_OF_BIT_NEST_HELP #language en-US "The oneof refer to nested bit field"
+ #language fr-FR "The oneof refer to nested bit field"
+#string STR_BIT_NEST_NUMERIC_PROMPT #language en-US "NEST_BIT numeric"
+ #language fr-FR "NEST_BIT numeric"
+#string STR_BIT_NEST_NUMERIC_HELP #language en-US "The numeric refer to nested bit field"
+ #language fr-FR "The numeric refer to nested bit field"
+#string BYTE_QUESTION_NEST_BIT_PROMPT #language en-US "Use byte field in NEST_BIT structure"
+ #language fr-FR "Use byte field in NEST_BIT structure"
+#string BYTE_QUESTION_NEST_BIT_HELP #language en-US "The Question refer to byte field in NEST_BIT structure"
+ #language fr-FR "The Question refer to byte field in NEST_BIT structure"
+#string STR_BIT_NEST_NUMERIC_DEFAULT_HELP #language en-US "NEST_BIT numeric, default value form callback function"
+ #language fr-FR "NEST_BIT numeric, default value form callback function"
+#string STR_BIT_CHECK_BOX_PROMPT #language en-US "BIT check box"
+ #language fr-FR "BIT check box"
+#string STR_BIT_CHECK_BOX_HELP #language en-US "The check box refer to bit field"
+ #language fr-FR "The check box refer to bit field"
+#string STR_ONE_OF_BIT_PROMPT #language en-US "BIT one-of"
+ #language fr-FR "BIT one-of"
+#string STR_ONE_OF_BIT_HELP #language en-US "The one-of refer to bit field"
+ #language fr-FR "The one-of refer to bit field"
+#string STR_BIT_NUMERIC_PROMPT #language en-US "BIT numeric"
+ #language fr-FR "BIT numeric"
+#string STR_BIT_NUMERIC_HELP #language en-US "The numeric refer to bit field"
+ #language fr-FR "The numeric refer to bit field"
+#string BYTE_QUESTION_BIT_PROMPT #language en-US "Use byte field in BIT structure"
+ #language fr-FR "Use byte field in BIT structure"
+#string BYTE_QUESTION_BIT_HELP #language en-US "The question refer to byte field in BIT structure"
+ #language fr-FR "The question refer to byte field in BIT structure"
+#string STR_UNION_BYTE_NUMERIC_PROMPT #language en-US "UNION EfiVarStore byte numeric"
+ #language fr-FR "UNION EfiVarStore byte numeric"
+#string STR_UNION_BYTE_NUMERIC_HELP #language en-US "Question refer to byte field in UNION type efivastore"
+ #language fr-FR "Question refer to byte field in UNION type efivastore"
+#string STR_UNION_BIT_NUMERIC_PROMPT #language en-US "UNION EfiVarStore bit numeric"
+ #language fr-FR "UNION EfiVarStore bit numeric"
+#string STR_UNION_BIT_NUMERIC_HELP #language en-US "Question refer to bit field in UNION type efivastore"
+ #language fr-FR "Question refer to bit field in UNION type efivastore"
// Boot Order
#string STR_BOOT_TITLE #language en-US "Boot"
#string STR_BOOT_OPTIONS #language en-US "Boot Order"
#string STR_BOOT_OPTION1 #language en-US "IDE HDD"
#string STR_BOOT_OPTION2 #language en-US "ATAPI CD"
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-12 3:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 3:44 [PATCH v2 0/6] Support bitfield in storage of vfr Dandan Bi
2017-09-12 3:44 ` [PATCH v2 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore Dandan Bi
2017-09-12 3:44 ` [PATCH v2 2/6] MdeModulePkg: Add GUID/flags to implement BitField support Dandan Bi
2017-09-12 3:44 ` [PATCH v2 3/6] MdeModulePkg/UefiHiiLib: Add codes to validate question with bit fields Dandan Bi
2017-09-12 3:44 ` [PATCH v2 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore Dandan Bi
2017-09-12 3:44 ` [PATCH v2 5/6] MdeModulePkg/SetupBrowser: " Dandan Bi
2017-09-12 3:44 ` [PATCH v2 6/6] MdeModulePkg/DriverSample: Add sample questions with bit/union VarStore Dandan Bi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox