* [PATCH v2 0/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check @ 2017-11-05 10:05 Dandan Bi 2017-11-05 10:06 ` [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO Dandan Bi 2017-11-05 10:06 ` [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi 0 siblings, 2 replies; 5+ messages in thread From: Dandan Bi @ 2017-11-05 10:05 UTC (permalink / raw) To: edk2-devel; +Cc: Star Zeng, Eric Dong, Liming Gao V2: Patch 1: Replace EFI_D_INFO with DEBUG_INFO in VarCheckHiiLib. Patch 2: (1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final VarCheckBinSize and update the implementation accordingly. (2)UPdate the VAR_CHECK_HII_REVISION (3)Refine the Debug message and function comments,like update oneof", "checkbox", "numeric" to "OneOf", "CheckBox", "Numeric". Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Dandan Bi (2): MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check .../VarCheckHiiLib/InternalVarCheckStructure.h | 9 +- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 364 ++++++++++++++------- .../Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c | 14 +- .../Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c | 2 +- .../Library/VarCheckHiiLib/VarCheckHiiLib.inf | 5 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 242 +++++++++----- 7 files changed, 426 insertions(+), 214 deletions(-) -- 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO 2017-11-05 10:05 [PATCH v2 0/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi @ 2017-11-05 10:06 ` Dandan Bi 2017-11-06 5:46 ` Zeng, Star 2017-11-05 10:06 ` [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi 1 sibling, 1 reply; 5+ messages in thread From: Dandan Bi @ 2017-11-05 10:06 UTC (permalink / raw) To: edk2-devel; +Cc: Star Zeng, Eric Dong, Liming Gao In patch 2, we will introduce DEBUG_INFO in VarCheckHiiLib,in order to keep consistence, replace all EFI_D_INFO with DEBUG_INFO firstly in this pacth. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 148 ++++++++++----------- .../Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c | 14 +- .../Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c | 2 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 88 ++++++------ 4 files changed, 126 insertions(+), 126 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index f018c87..a334a6f 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -121,123 +121,123 @@ DumpHiiPackage ( EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; - DEBUG ((EFI_D_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); - DEBUG ((EFI_D_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length)); + DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); + DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length)); switch (HiiPackageHeader->Type) { case EFI_HII_PACKAGE_FORMS: IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1); while ((UINTN) IfrOpCodeHeader < ((UINTN) HiiPackageHeader + HiiPackageHeader->Length)) { switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_VARSTORE_OP: IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &IfrVarStore->Guid)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", IfrVarStore->VarStoreId)); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", IfrVarStore->Size)); - DEBUG ((EFI_D_INFO, " Name - %a\n", IfrVarStore->Name)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &IfrVarStore->Guid)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", IfrVarStore->VarStoreId)); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", IfrVarStore->Size)); + DEBUG ((DEBUG_INFO, " Name - %a\n", IfrVarStore->Name)); break; case EFI_IFR_VARSTORE_EFI_OP: IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader; if (IfrEfiVarStore->Header.Length >= sizeof (EFI_IFR_VARSTORE_EFI)) { - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &IfrEfiVarStore->Guid)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", IfrEfiVarStore->VarStoreId)); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", IfrEfiVarStore->Size)); - DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); - DEBUG ((EFI_D_INFO, " Name - %a\n", IfrEfiVarStore->Name)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &IfrEfiVarStore->Guid)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", IfrEfiVarStore->VarStoreId)); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", IfrEfiVarStore->Size)); + DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); + DEBUG ((DEBUG_INFO, " Name - %a\n", IfrEfiVarStore->Name)); } break; case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); - DEBUG ((EFI_D_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); - DEBUG ((EFI_D_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); - DEBUG ((EFI_D_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); + DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); + DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); + DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); { EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ORDERED_LIST *IfrOrderedList; switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); break; case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); break; case EFI_IFR_NUMERIC_SIZE_4: - DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); break; case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); break; } break; case EFI_IFR_CHECKBOX_OP: IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); break; case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); break; case EFI_IFR_NUMERIC_SIZE_4: - DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); break; case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); break; } break; case EFI_IFR_ORDERED_LIST_OP: IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrOrderedList->Flags)); + DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOrderedList->Flags)); break; default: break; } @@ -249,30 +249,30 @@ DumpHiiPackage ( Scope = 1; while (Scope != 0) { switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OPTION_OP: IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *)IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, "!!!! IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", (UINTN)IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, "!!!! IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, "!!!! Option - 0x%04x\n", IfrOneOfOption->Option)); - DEBUG ((EFI_D_INFO, "!!!! Flags - 0x%02x\n", IfrOneOfOption->Flags)); - DEBUG ((EFI_D_INFO, "!!!! Type - 0x%02x\n", IfrOneOfOption->Type)); + DEBUG ((DEBUG_INFO, "!!!! IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", (UINTN)IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, "!!!! IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, "!!!! Option - 0x%04x\n", IfrOneOfOption->Option)); + DEBUG ((DEBUG_INFO, "!!!! Flags - 0x%02x\n", IfrOneOfOption->Flags)); + DEBUG ((DEBUG_INFO, "!!!! Type - 0x%02x\n", IfrOneOfOption->Type)); switch (IfrOneOfOption->Type) { case EFI_IFR_TYPE_NUM_SIZE_8: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.u8)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.u8)); break; case EFI_IFR_TYPE_NUM_SIZE_16: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%04x\n", IfrOneOfOption->Value.u16)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%04x\n", IfrOneOfOption->Value.u16)); break; case EFI_IFR_TYPE_NUM_SIZE_32: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%08x\n", IfrOneOfOption->Value.u32)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%08x\n", IfrOneOfOption->Value.u32)); break; case EFI_IFR_TYPE_NUM_SIZE_64: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%016lx\n", IfrOneOfOption->Value.u64)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%016lx\n", IfrOneOfOption->Value.u64)); break; case EFI_IFR_TYPE_BOOLEAN: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.b)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.b)); break; default: break; } break; @@ -316,16 +316,16 @@ DumpHiiDatabase ( ) { EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader; EFI_HII_PACKAGE_HEADER *HiiPackageHeader; - DEBUG ((EFI_D_INFO, "HiiDatabaseSize - 0x%x\n", HiiDatabaseSize)); + DEBUG ((DEBUG_INFO, "HiiDatabaseSize - 0x%x\n", HiiDatabaseSize)); HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) HiiDatabase; while ((UINTN) HiiPackageListHeader < ((UINTN) HiiDatabase + HiiDatabaseSize)) { - DEBUG ((EFI_D_INFO, "HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid)); - DEBUG ((EFI_D_INFO, "HiiPackageListHeader->PackageLength - 0x%x\n", (UINTN)HiiPackageListHeader->PackageLength)); + DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid)); + DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageLength - 0x%x\n", (UINTN)HiiPackageListHeader->PackageLength)); HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)(HiiPackageListHeader + 1); while ((UINTN) HiiPackageHeader < (UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength) { DumpHiiPackage (HiiPackageHeader); @@ -503,11 +503,11 @@ MergeHiiQuestion ( ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth)); switch (HiiQuestion1->OpCode) { case EFI_IFR_ONE_OF_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -584,15 +584,15 @@ MergeHiiQuestion ( InternalVarCheckFreePool (HiiQuestion1); } break; case EFI_IFR_CHECKBOX_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); break; case EFI_IFR_NUMERIC_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get minimum and maximum of Hii Question 1. // Minimum1 = 0; Maximum1 = 0; @@ -628,11 +628,11 @@ MergeHiiQuestion ( CopyMem (Ptr, &Maximum1, HiiQuestion1->StorageWidth); } break; case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_ORDERED_LIST_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ORDERED_LIST_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -1401,11 +1401,11 @@ BuildVarCheckHiiBin ( HiiVariableNode->HiiVariable->Length = HiiVariableLength; BinSize += HiiVariableLength; } - DEBUG ((EFI_D_INFO, "VarCheckHiiBin - size = 0x%x\n", BinSize)); + DEBUG ((DEBUG_INFO, "VarCheckHiiBin - size = 0x%x\n", BinSize)); if (BinSize == 0) { *Size = BinSize; return NULL; } @@ -1414,11 +1414,11 @@ BuildVarCheckHiiBin ( // Only here AllocateRuntimeZeroPool () from MemoryAllocateLib is used for runtime access // in SetVariable check handler. // Data = AllocateRuntimeZeroPool (BinSize); ASSERT (Data != NULL); - DEBUG ((EFI_D_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); + DEBUG ((DEBUG_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); // // Gen Data // Ptr = Data; @@ -1463,11 +1463,11 @@ VarCheckHiiGen ( VarCheckHiiGenFromHiiDatabase (); VarCheckHiiGenFromFv (); mVarCheckHiiBin = BuildVarCheckHiiBin (&mVarCheckHiiBinSize); if (mVarCheckHiiBin == NULL) { - DEBUG ((EFI_D_INFO, "[VarCheckHii] This driver could be removed from *.dsc and *.fdf\n")); + DEBUG ((DEBUG_INFO, "[VarCheckHii] This driver could be removed from *.dsc and *.fdf\n")); return; } DestroyHiiVariableNode (); if (mVarName != NULL) { diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c index 71ece27..7866350 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c @@ -217,12 +217,12 @@ ParseFfs ( &SectionBuffer, &SectionSize, &AuthenticationStatus ); if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FfsNameGuid - %g\n", DriverGuid)); - DEBUG ((EFI_D_INFO, "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin)); + DEBUG ((DEBUG_INFO , "FfsNameGuid - %g\n", DriverGuid)); + DEBUG ((DEBUG_INFO , "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin)); for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) { #ifdef DUMP_HII_DATA DEBUG_CODE ( DumpHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32)); @@ -282,11 +282,11 @@ ParseFv ( // // Search all FVs // for (Index = 0; Index < HandleCount; Index++) { - DEBUG ((EFI_D_INFO, "FvIndex - %x\n", Index)); + DEBUG ((DEBUG_INFO , "FvIndex - %x\n", Index)); Status = gBS->HandleProtocol ( HandleBuffer[Index], &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &Fv2 ); @@ -303,13 +303,13 @@ ParseFv ( (VOID **) &Fvb2 ); ASSERT_EFI_ERROR (Status); Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress); if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FvAddress - 0x%08x\n", FvAddress)); + DEBUG ((DEBUG_INFO , "FvAddress - 0x%08x\n", FvAddress)); FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvAddress)->FvLength; - DEBUG ((EFI_D_INFO, "FvSize - 0x%08x\n", FvSize)); + DEBUG ((DEBUG_INFO , "FvSize - 0x%08x\n", FvSize)); } ); if (ScanAll) { // @@ -371,11 +371,11 @@ CreateVfrDriverList ( { UINTN Index; VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo; for (Index = 0; !IsZeroGuid (&DriverGuidArray[Index]); Index++) { - DEBUG ((EFI_D_INFO, "CreateVfrDriverList: %g\n", &DriverGuidArray[Index])); + DEBUG ((DEBUG_INFO , "CreateVfrDriverList: %g\n", &DriverGuidArray[Index])); VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo)); ASSERT (VfrDriverInfo != NULL); VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE; VfrDriverInfo->DriverGuid = &DriverGuidArray[Index]; InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link); @@ -412,11 +412,11 @@ VarCheckHiiGenFromFv ( ) { EFI_GUID *DriverGuidArray; BOOLEAN ScanAll; - DEBUG ((EFI_D_INFO, "VarCheckHiiGenDxeFromFv\n")); + DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromFv\n")); // // Get vfr driver guid array from PCD. // DriverGuidArray = (EFI_GUID *) PcdGetPtr (PcdVarCheckVfrDriverGuidArray); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c index 41cde34..de2de48 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c @@ -56,11 +56,11 @@ VarCheckHiiGenFromHiiDatabase ( // Export HII Database into the buffer. // Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer); ASSERT_EFI_ERROR (Status); - DEBUG ((EFI_D_INFO, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize)); #ifdef DUMP_HII_DATA DEBUG_CODE ( DumpHiiDatabase (Buffer, BufferSize); ); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 93ff934..46a93bd 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -58,11 +58,11 @@ VarCheckHiiInternalDumpHex ( Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte); } Val[Index * 3] = 0; Str[Index] = 0; - DEBUG ((EFI_D_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str)); + DEBUG ((DEBUG_INFO , "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str)); Data += Size; Offset += Size; DataSize -= Size; } @@ -93,11 +93,11 @@ VarCheckHiiQuestion ( UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); return FALSE; } OneData = 0; CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth); @@ -118,19 +118,19 @@ VarCheckHiiQuestion ( } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; case EFI_IFR_CHECKBOX_OP: if ((OneData != 0) && (OneData != 1)) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; @@ -145,20 +145,20 @@ VarCheckHiiQuestion ( // // No need to check Step, because it is ONLY for UI. // if ((OneData < Minimum) || (OneData > Maximum)) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; case EFI_IFR_ORDERED_LIST_OP: MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers; if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize)); return FALSE; } for (Index = 0; Index < MaxContainers; Index++) { OneData = 0; CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth); @@ -183,11 +183,11 @@ VarCheckHiiQuestion ( } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: OrderedList mismatch\n")); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OrderedList mismatch\n")); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *) Data + HiiQuestion->VarOffset);); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } } @@ -249,23 +249,23 @@ SetVariableCheckHandlerHii ( if ((StrCmp ((CHAR16 *) (HiiVariable + 1), VariableName) == 0) && (CompareGuid (&HiiVariable->Guid, VendorGuid))) { // // Found the Hii Variable that could be used to do check. // - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize)); if (HiiVariable->Attributes != Attributes) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes)); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes)); return EFI_SECURITY_VIOLATION; } if (DataSize == 0) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - CHECK PASS with DataSize == 0 !\n")); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - CHECK PASS with DataSize == 0 !\n")); return EFI_SUCCESS; } if (HiiVariable->Size != DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable fail for Size - 0x%x\n", HiiVariable->Size)); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Size - 0x%x\n", HiiVariable->Size)); return EFI_SECURITY_VIOLATION; } // // Do the check. @@ -280,11 +280,11 @@ SetVariableCheckHandlerHii ( // For Hii Question header align. // HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length)); } - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n")); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n")); return EFI_SUCCESS; } // // For Hii Variable header align. // @@ -341,34 +341,34 @@ DumpHiiQuestion ( UINT64 Minimum; UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; - DEBUG ((EFI_D_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); - DEBUG ((EFI_D_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); - DEBUG ((EFI_D_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); - DEBUG ((EFI_D_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); - DEBUG ((EFI_D_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); + DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); break; default: ASSERT (FALSE); break; } @@ -388,49 +388,49 @@ DumpHiiQuestion ( CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); Ptr += HiiQuestion->StorageWidth; switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " Minimum - 0x%02x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%02x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " Minimum - 0x%04x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%04x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " Minimum - 0x%08x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%08x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " Minimum - 0x%016lx\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%016lx\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); break; default: ASSERT (FALSE); break; } break; case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); + DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); break; default: ASSERT (FALSE); break; } @@ -455,19 +455,19 @@ DumpHiiVariable ( IN VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable ) { VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion; - DEBUG ((EFI_D_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n")); - DEBUG ((EFI_D_INFO, " Revision - 0x%04x\n", HiiVariable->Revision)); - DEBUG ((EFI_D_INFO, " HeaderLength - 0x%04x\n", HiiVariable->HeaderLength)); - DEBUG ((EFI_D_INFO, " Length - 0x%08x\n", HiiVariable->Length)); - DEBUG ((EFI_D_INFO, " OpCode - 0x%02x (%a)\n", HiiVariable->OpCode, HiiOpCodeToStr (HiiVariable->OpCode))); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", HiiVariable->Size)); - DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", HiiVariable->Attributes)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &HiiVariable->Guid)); - DEBUG ((EFI_D_INFO, " Name - %s\n", HiiVariable + 1)); + DEBUG ((DEBUG_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n")); + DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", HiiVariable->Revision)); + DEBUG ((DEBUG_INFO, " HeaderLength - 0x%04x\n", HiiVariable->HeaderLength)); + DEBUG ((DEBUG_INFO, " Length - 0x%08x\n", HiiVariable->Length)); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiVariable->OpCode, HiiOpCodeToStr (HiiVariable->OpCode))); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", HiiVariable->Size)); + DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", HiiVariable->Attributes)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &HiiVariable->Guid)); + DEBUG ((DEBUG_INFO, " Name - %s\n", HiiVariable + 1)); // // For Hii Question header align. // HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength)); @@ -496,11 +496,11 @@ DumpVarCheckHii ( IN UINTN VarCheckHiiBinSize ) { VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable; - DEBUG ((EFI_D_INFO, "DumpVarCheckHii\n")); + DEBUG ((DEBUG_INFO, "DumpVarCheckHii\n")); // // For Hii Variable header align. // HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckHiiBin); -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO 2017-11-05 10:06 ` [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO Dandan Bi @ 2017-11-06 5:46 ` Zeng, Star 0 siblings, 0 replies; 5+ messages in thread From: Zeng, Star @ 2017-11-06 5:46 UTC (permalink / raw) To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Dong, Eric, Zeng, Star Reviewed-by: Star Zeng <star.zeng@intel.com> -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi Sent: Sunday, November 5, 2017 6:06 PM To: edk2-devel@lists.01.org Cc: Gao, Liming <liming.gao@intel.com>; Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com> Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO In patch 2, we will introduce DEBUG_INFO in VarCheckHiiLib,in order to keep consistence, replace all EFI_D_INFO with DEBUG_INFO firstly in this pacth. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 148 ++++++++++----------- .../Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c | 14 +- .../Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c | 2 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 88 ++++++------ 4 files changed, 126 insertions(+), 126 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index f018c87..a334a6f 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -121,123 +121,123 @@ DumpHiiPackage ( EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; - DEBUG ((EFI_D_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); - DEBUG ((EFI_D_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length)); + DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); + DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", + HiiPackageHeader->Length)); switch (HiiPackageHeader->Type) { case EFI_HII_PACKAGE_FORMS: IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1); while ((UINTN) IfrOpCodeHeader < ((UINTN) HiiPackageHeader + HiiPackageHeader->Length)) { switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_VARSTORE_OP: IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &IfrVarStore->Guid)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", IfrVarStore->VarStoreId)); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", IfrVarStore->Size)); - DEBUG ((EFI_D_INFO, " Name - %a\n", IfrVarStore->Name)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &IfrVarStore->Guid)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", IfrVarStore->VarStoreId)); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", IfrVarStore->Size)); + DEBUG ((DEBUG_INFO, " Name - %a\n", IfrVarStore->Name)); break; case EFI_IFR_VARSTORE_EFI_OP: IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader; if (IfrEfiVarStore->Header.Length >= sizeof (EFI_IFR_VARSTORE_EFI)) { - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &IfrEfiVarStore->Guid)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", IfrEfiVarStore->VarStoreId)); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", IfrEfiVarStore->Size)); - DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); - DEBUG ((EFI_D_INFO, " Name - %a\n", IfrEfiVarStore->Name)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &IfrEfiVarStore->Guid)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", IfrEfiVarStore->VarStoreId)); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", IfrEfiVarStore->Size)); + DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); + DEBUG ((DEBUG_INFO, " Name - %a\n", IfrEfiVarStore->Name)); } break; case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); - DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); - DEBUG ((EFI_D_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); - DEBUG ((EFI_D_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); - DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); - DEBUG ((EFI_D_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); + DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); + DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); + DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); + DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); + DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); { EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ORDERED_LIST *IfrOrderedList; switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); break; case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); break; case EFI_IFR_NUMERIC_SIZE_4: - DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); break; case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); break; } break; case EFI_IFR_CHECKBOX_OP: IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); break; case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); break; case EFI_IFR_NUMERIC_SIZE_4: - DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); break; case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); break; } break; case EFI_IFR_ORDERED_LIST_OP: IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); - DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", IfrOrderedList->Flags)); + DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); + DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOrderedList->Flags)); break; default: break; } @@ -249,30 +249,30 @@ DumpHiiPackage ( Scope = 1; while (Scope != 0) { switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OPTION_OP: IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *)IfrOpCodeHeader; - DEBUG ((EFI_D_INFO, "!!!! IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", (UINTN)IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); - DEBUG ((EFI_D_INFO, "!!!! IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); - DEBUG ((EFI_D_INFO, "!!!! Option - 0x%04x\n", IfrOneOfOption->Option)); - DEBUG ((EFI_D_INFO, "!!!! Flags - 0x%02x\n", IfrOneOfOption->Flags)); - DEBUG ((EFI_D_INFO, "!!!! Type - 0x%02x\n", IfrOneOfOption->Type)); + DEBUG ((DEBUG_INFO, "!!!! IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", (UINTN)IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); + DEBUG ((DEBUG_INFO, "!!!! IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope)); + DEBUG ((DEBUG_INFO, "!!!! Option - 0x%04x\n", IfrOneOfOption->Option)); + DEBUG ((DEBUG_INFO, "!!!! Flags - 0x%02x\n", IfrOneOfOption->Flags)); + DEBUG ((DEBUG_INFO, "!!!! Type - 0x%02x\n", IfrOneOfOption->Type)); switch (IfrOneOfOption->Type) { case EFI_IFR_TYPE_NUM_SIZE_8: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.u8)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.u8)); break; case EFI_IFR_TYPE_NUM_SIZE_16: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%04x\n", IfrOneOfOption->Value.u16)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%04x\n", IfrOneOfOption->Value.u16)); break; case EFI_IFR_TYPE_NUM_SIZE_32: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%08x\n", IfrOneOfOption->Value.u32)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%08x\n", IfrOneOfOption->Value.u32)); break; case EFI_IFR_TYPE_NUM_SIZE_64: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%016lx\n", IfrOneOfOption->Value.u64)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%016lx\n", IfrOneOfOption->Value.u64)); break; case EFI_IFR_TYPE_BOOLEAN: - DEBUG ((EFI_D_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.b)); + DEBUG ((DEBUG_INFO, "!!!! Value - 0x%02x\n", IfrOneOfOption->Value.b)); break; default: break; } break; @@ -316,16 +316,16 @@ DumpHiiDatabase ( ) { EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader; EFI_HII_PACKAGE_HEADER *HiiPackageHeader; - DEBUG ((EFI_D_INFO, "HiiDatabaseSize - 0x%x\n", HiiDatabaseSize)); + DEBUG ((DEBUG_INFO, "HiiDatabaseSize - 0x%x\n", HiiDatabaseSize)); HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) HiiDatabase; while ((UINTN) HiiPackageListHeader < ((UINTN) HiiDatabase + HiiDatabaseSize)) { - DEBUG ((EFI_D_INFO, "HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid)); - DEBUG ((EFI_D_INFO, "HiiPackageListHeader->PackageLength - 0x%x\n", (UINTN)HiiPackageListHeader->PackageLength)); + DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid)); + DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageLength - 0x%x\n", (UINTN)HiiPackageListHeader->PackageLength)); HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)(HiiPackageListHeader + 1); while ((UINTN) HiiPackageHeader < (UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength) { DumpHiiPackage (HiiPackageHeader); @@ -503,11 +503,11 @@ MergeHiiQuestion ( ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth)); switch (HiiQuestion1->OpCode) { case EFI_IFR_ONE_OF_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP + VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -584,15 +584,15 @@ MergeHiiQuestion ( InternalVarCheckFreePool (HiiQuestion1); } break; case EFI_IFR_CHECKBOX_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP + VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); break; case EFI_IFR_NUMERIC_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP + VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get minimum and maximum of Hii Question 1. // Minimum1 = 0; Maximum1 = 0; @@ -628,11 +628,11 @@ MergeHiiQuestion ( CopyMem (Ptr, &Maximum1, HiiQuestion1->StorageWidth); } break; case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, "MergeHiiQuestion - EFI_IFR_ORDERED_LIST_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ORDERED_LIST_OP + VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -1401,11 +1401,11 @@ BuildVarCheckHiiBin ( HiiVariableNode->HiiVariable->Length = HiiVariableLength; BinSize += HiiVariableLength; } - DEBUG ((EFI_D_INFO, "VarCheckHiiBin - size = 0x%x\n", BinSize)); + DEBUG ((DEBUG_INFO, "VarCheckHiiBin - size = 0x%x\n", BinSize)); if (BinSize == 0) { *Size = BinSize; return NULL; } @@ -1414,11 +1414,11 @@ BuildVarCheckHiiBin ( // Only here AllocateRuntimeZeroPool () from MemoryAllocateLib is used for runtime access // in SetVariable check handler. // Data = AllocateRuntimeZeroPool (BinSize); ASSERT (Data != NULL); - DEBUG ((EFI_D_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); + DEBUG ((DEBUG_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); // // Gen Data // Ptr = Data; @@ -1463,11 +1463,11 @@ VarCheckHiiGen ( VarCheckHiiGenFromHiiDatabase (); VarCheckHiiGenFromFv (); mVarCheckHiiBin = BuildVarCheckHiiBin (&mVarCheckHiiBinSize); if (mVarCheckHiiBin == NULL) { - DEBUG ((EFI_D_INFO, "[VarCheckHii] This driver could be removed from *.dsc and *.fdf\n")); + DEBUG ((DEBUG_INFO, "[VarCheckHii] This driver could be removed + from *.dsc and *.fdf\n")); return; } DestroyHiiVariableNode (); if (mVarName != NULL) { diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c index 71ece27..7866350 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c @@ -217,12 +217,12 @@ ParseFfs ( &SectionBuffer, &SectionSize, &AuthenticationStatus ); if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FfsNameGuid - %g\n", DriverGuid)); - DEBUG ((EFI_D_INFO, "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin)); + DEBUG ((DEBUG_INFO , "FfsNameGuid - %g\n", DriverGuid)); + DEBUG ((DEBUG_INFO , "NumberofMatchingVfrBin - 0x%02x\n", + NumberofMatchingVfrBin)); for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) { #ifdef DUMP_HII_DATA DEBUG_CODE ( DumpHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32)); @@ -282,11 +282,11 @@ ParseFv ( // // Search all FVs // for (Index = 0; Index < HandleCount; Index++) { - DEBUG ((EFI_D_INFO, "FvIndex - %x\n", Index)); + DEBUG ((DEBUG_INFO , "FvIndex - %x\n", Index)); Status = gBS->HandleProtocol ( HandleBuffer[Index], &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &Fv2 ); @@ -303,13 +303,13 @@ ParseFv ( (VOID **) &Fvb2 ); ASSERT_EFI_ERROR (Status); Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress); if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FvAddress - 0x%08x\n", FvAddress)); + DEBUG ((DEBUG_INFO , "FvAddress - 0x%08x\n", FvAddress)); FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvAddress)->FvLength; - DEBUG ((EFI_D_INFO, "FvSize - 0x%08x\n", FvSize)); + DEBUG ((DEBUG_INFO , "FvSize - 0x%08x\n", FvSize)); } ); if (ScanAll) { // @@ -371,11 +371,11 @@ CreateVfrDriverList ( { UINTN Index; VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo; for (Index = 0; !IsZeroGuid (&DriverGuidArray[Index]); Index++) { - DEBUG ((EFI_D_INFO, "CreateVfrDriverList: %g\n", &DriverGuidArray[Index])); + DEBUG ((DEBUG_INFO , "CreateVfrDriverList: %g\n", + &DriverGuidArray[Index])); VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo)); ASSERT (VfrDriverInfo != NULL); VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE; VfrDriverInfo->DriverGuid = &DriverGuidArray[Index]; InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link); @@ -412,11 +412,11 @@ VarCheckHiiGenFromFv ( ) { EFI_GUID *DriverGuidArray; BOOLEAN ScanAll; - DEBUG ((EFI_D_INFO, "VarCheckHiiGenDxeFromFv\n")); + DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromFv\n")); // // Get vfr driver guid array from PCD. // DriverGuidArray = (EFI_GUID *) PcdGetPtr (PcdVarCheckVfrDriverGuidArray); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c index 41cde34..de2de48 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c @@ -56,11 +56,11 @@ VarCheckHiiGenFromHiiDatabase ( // Export HII Database into the buffer. // Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer); ASSERT_EFI_ERROR (Status); - DEBUG ((EFI_D_INFO, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromHii - HII Database + exported at 0x%x, size = 0x%x\n", Buffer, BufferSize)); #ifdef DUMP_HII_DATA DEBUG_CODE ( DumpHiiDatabase (Buffer, BufferSize); ); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 93ff934..46a93bd 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -58,11 +58,11 @@ VarCheckHiiInternalDumpHex ( Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte); } Val[Index * 3] = 0; Str[Index] = 0; - DEBUG ((EFI_D_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str)); + DEBUG ((DEBUG_INFO , "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, + Val, Str)); Data += Size; Offset += Size; DataSize -= Size; } @@ -93,11 +93,11 @@ VarCheckHiiQuestion ( UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, + HiiQuestion->StorageWidth, DataSize)); return FALSE; } OneData = 0; CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth); @@ -118,19 +118,19 @@ VarCheckHiiQuestion ( } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OneOf mismatch + (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; case EFI_IFR_CHECKBOX_OP: if ((OneData != 0) && (OneData != 1)) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: CheckBox + mismatch (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; @@ -145,20 +145,20 @@ VarCheckHiiQuestion ( // // No need to check Step, because it is ONLY for UI. // if ((OneData < Minimum) || (OneData > Maximum)) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: Numeric + mismatch (0x%lx)\n", OneData)); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } break; case EFI_IFR_ORDERED_LIST_OP: MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers; if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: + (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > + Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, + MaxContainers, DataSize)); return FALSE; } for (Index = 0; Index < MaxContainers; Index++) { OneData = 0; CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth); @@ -183,11 +183,11 @@ VarCheckHiiQuestion ( } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // - DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: OrderedList mismatch\n")); + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OrderedList + mismatch\n")); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *) Data + HiiQuestion->VarOffset);); DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion);); return FALSE; } } @@ -249,23 +249,23 @@ SetVariableCheckHandlerHii ( if ((StrCmp ((CHAR16 *) (HiiVariable + 1), VariableName) == 0) && (CompareGuid (&HiiVariable->Guid, VendorGuid))) { // // Found the Hii Variable that could be used to do check. // - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize)); + DEBUG ((DEBUG_INFO , "VarCheckHiiVariable - %s:%g with Attributes + = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, + DataSize)); if (HiiVariable->Attributes != Attributes) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes)); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Attributes - + 0x%08x\n", HiiVariable->Attributes)); return EFI_SECURITY_VIOLATION; } if (DataSize == 0) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - CHECK PASS with DataSize == 0 !\n")); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - CHECK PASS with + DataSize == 0 !\n")); return EFI_SUCCESS; } if (HiiVariable->Size != DataSize) { - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable fail for Size - 0x%x\n", HiiVariable->Size)); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Size - + 0x%x\n", HiiVariable->Size)); return EFI_SECURITY_VIOLATION; } // // Do the check. @@ -280,11 +280,11 @@ SetVariableCheckHandlerHii ( // For Hii Question header align. // HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length)); } - DEBUG ((EFI_D_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n")); + DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n")); return EFI_SUCCESS; } // // For Hii Variable header align. // @@ -341,34 +341,34 @@ DumpHiiQuestion ( UINT64 Minimum; UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; - DEBUG ((EFI_D_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); - DEBUG ((EFI_D_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); - DEBUG ((EFI_D_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); - DEBUG ((EFI_D_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); - DEBUG ((EFI_D_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); + DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); break; default: ASSERT (FALSE); break; } @@ -388,49 +388,49 @@ DumpHiiQuestion ( CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); Ptr += HiiQuestion->StorageWidth; switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " Minimum - 0x%02x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%02x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " Minimum - 0x%04x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%04x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " Minimum - 0x%08x\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%08x\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " Minimum - 0x%016lx\n", Minimum)); - DEBUG ((EFI_D_INFO, " Maximum - 0x%016lx\n", Maximum)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); break; default: ASSERT (FALSE); break; } break; case EFI_IFR_ORDERED_LIST_OP: - DEBUG ((EFI_D_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); + DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); break; case sizeof (UINT16): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); break; case sizeof (UINT32): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); break; case sizeof (UINT64): - DEBUG ((EFI_D_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); break; default: ASSERT (FALSE); break; } @@ -455,19 +455,19 @@ DumpHiiVariable ( IN VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable ) { VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion; - DEBUG ((EFI_D_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n")); - DEBUG ((EFI_D_INFO, " Revision - 0x%04x\n", HiiVariable->Revision)); - DEBUG ((EFI_D_INFO, " HeaderLength - 0x%04x\n", HiiVariable->HeaderLength)); - DEBUG ((EFI_D_INFO, " Length - 0x%08x\n", HiiVariable->Length)); - DEBUG ((EFI_D_INFO, " OpCode - 0x%02x (%a)\n", HiiVariable->OpCode, HiiOpCodeToStr (HiiVariable->OpCode))); - DEBUG ((EFI_D_INFO, " Size - 0x%04x\n", HiiVariable->Size)); - DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", HiiVariable->Attributes)); - DEBUG ((EFI_D_INFO, " Guid - %g\n", &HiiVariable->Guid)); - DEBUG ((EFI_D_INFO, " Name - %s\n", HiiVariable + 1)); + DEBUG ((DEBUG_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n")); + DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", HiiVariable->Revision)); + DEBUG ((DEBUG_INFO, " HeaderLength - 0x%04x\n", HiiVariable->HeaderLength)); + DEBUG ((DEBUG_INFO, " Length - 0x%08x\n", HiiVariable->Length)); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiVariable->OpCode, HiiOpCodeToStr (HiiVariable->OpCode))); + DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", HiiVariable->Size)); + DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", HiiVariable->Attributes)); + DEBUG ((DEBUG_INFO, " Guid - %g\n", &HiiVariable->Guid)); + DEBUG ((DEBUG_INFO, " Name - %s\n", HiiVariable + 1)); // // For Hii Question header align. // HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength)); @@ -496,11 +496,11 @@ DumpVarCheckHii ( IN UINTN VarCheckHiiBinSize ) { VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable; - DEBUG ((EFI_D_INFO, "DumpVarCheckHii\n")); + DEBUG ((DEBUG_INFO, "DumpVarCheckHii\n")); // // For Hii Variable header align. // HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckHiiBin); -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check 2017-11-05 10:05 [PATCH v2 0/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi 2017-11-05 10:06 ` [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO Dandan Bi @ 2017-11-05 10:06 ` Dandan Bi 2017-11-06 5:45 ` Zeng, Star 1 sibling, 1 reply; 5+ messages in thread From: Dandan Bi @ 2017-11-05 10:06 UTC (permalink / raw) To: edk2-devel; +Cc: Star Zeng, Eric Dong, Liming Gao V2: (1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final VarCheckBinSize and update the implementation accordingly. (2)Update the VAR_CHECK_HII_REVISION (3)Refine the Debug message and function comments,like update oneof", "checkbox", "numeric" to "OneOf", "CheckBox", "Numeric". VarCheckHiiLib check the value set to storage based on the possible value listed in the vfr file. Since we have enhanced vfr to support Question value stored in bit field, so now enhance VarCheckHiiLib to support bit field check. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../VarCheckHiiLib/InternalVarCheckStructure.h | 9 +- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 260 +++++++++++++++------ .../Library/VarCheckHiiLib/VarCheckHiiLib.inf | 5 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 184 ++++++++++----- 5 files changed, 337 insertions(+), 125 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h index a9faed4..8878e4a 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h @@ -1,9 +1,9 @@ /** @file Internal structure for Var Check Hii. -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 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 @@ -21,11 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define HEADER_ALIGNMENT 4 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1))) #pragma pack (1) -#define VAR_CHECK_HII_REVISION 0x0001 +#define VAR_CHECK_HII_REVISION 0x0002 typedef struct { UINT16 Revision; UINT16 HeaderLength; UINT32 Length; // Length include this header @@ -40,41 +40,46 @@ typedef struct { typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. } VAR_CHECK_HII_QUESTION_HEADER; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. //UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ONEOF; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. } VAR_CHECK_HII_QUESTION_CHECKBOX; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. //UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64; //UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_NUMERIC; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. UINT8 MaxContainers; //UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ORDEREDLIST; #pragma pack () diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h index a54b867..7363edf 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h @@ -1,9 +1,9 @@ /** @file Include file for Var Check Hii handler and bin. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/MemoryAllocationLib.h> +#include <Guid/MdeModuleHii.h> + #include <Protocol/HiiDatabase.h> #include <Protocol/FirmwareVolume2.h> #include <Protocol/FirmwareVolumeBlock.h> #include "InternalVarCheckStructure.h" diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index a334a6f..7d1da0b 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -1,9 +1,9 @@ /** @file Var Check Hii bin generation. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 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 @@ -118,12 +118,14 @@ DumpHiiPackage ( { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + BOOLEAN QuestionStoredInBitField; HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; + QuestionStoredInBitField = FALSE; DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length)); switch (HiiPackageHeader->Type) { @@ -155,83 +157,116 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); DEBUG ((DEBUG_INFO, " Name - %a\n", IfrEfiVarStore->Name)); } break; + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField = TRUE; + } + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: + if (QuestionStoredInBitField) { + DEBUG ((DEBUG_INFO, "----DumpHiiPackage-The Question is stored in bit field----\n")); + } else { + DEBUG ((DEBUG_INFO, "----DumpHiiPackage-The Question is stored in byte field----\n")); + } DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); - DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + if (QuestionStoredInBitField) { + DEBUG ((DEBUG_INFO, " VarStoreInfo (bit level) - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + } else { + DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + } { EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ORDERED_LIST *IfrOrderedList; switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); - switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_4: + if (QuestionStoredInBitField) { + // + // For OneOf stored in bit field, the option value are saved as UINT32 type. + // DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); - break; + } else { + switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); + break; + } } break; case EFI_IFR_CHECKBOX_OP: IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_4: + if (QuestionStoredInBitField) { + // + // For Numeric stored in bit field, the MinValue,MaxValue and Step are saved as UINT32 type. + // DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); - break; + } else { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); + break; + } } break; case EFI_IFR_ORDERED_LIST_OP: IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); @@ -486,28 +521,39 @@ MergeHiiQuestion ( UINT64 Maximum2; UINT64 OneValue2; UINT8 *Ptr; UINT8 *Ptr1; UINT8 *Ptr2; + UINT16 ArrayIndex; // // Hii Question from Hii Database has high priority. // Do not to merge Hii Question from Fv to Hii Question from Hii Database. // if (FromFv) { InternalVarCheckFreePool (HiiQuestion); return; } - HiiQuestion1 = HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset]; + if (HiiQuestion->BitFieldStore) { + ArrayIndex = HiiQuestion->VarOffset; + } else { + ArrayIndex = HiiQuestion->VarOffset * 8; + } + + HiiQuestion1 = HiiVariableNode->HiiQuestionArray[ArrayIndex]; HiiQuestion2 = HiiQuestion; ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth)); switch (HiiQuestion1->OpCode) { case EFI_IFR_ONE_OF_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -578,21 +624,29 @@ MergeHiiQuestion ( Ptr += HiiQuestion1->StorageWidth; } Ptr2 += HiiQuestion2->StorageWidth; } - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; case EFI_IFR_CHECKBOX_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } break; case EFI_IFR_NUMERIC_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } // // Get minimum and maximum of Hii Question 1. // Minimum1 = 0; Maximum1 = 0; @@ -703,11 +757,11 @@ MergeHiiQuestion ( Ptr += HiiQuestion1->StorageWidth; } Ptr2 += HiiQuestion2->StorageWidth; } - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; default: @@ -829,29 +883,42 @@ GetOneOfOption ( /** Parse Hii Question Oneof. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the OneOf is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionOneOf ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_ONE_OF *IfrOneOf; VAR_CHECK_HII_QUESTION_ONEOF *OneOf; UINTN Length; UINT8 Width; UINTN OptionCount; UINT8 OptionWidth; + UINT8 BitWidth; IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; + BitWidth = 0; - Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); + if (StoredInBitField) { + // + // When OneOf stored in bit field, the bit width is saved in the lower six bits of the flag. + // And the options in the OneOf is saved as UINT32 type. + // + BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width = sizeof (UINT32); + } else { + Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); + } GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL); ASSERT (Width == OptionWidth); Length = sizeof (*OneOf) + OptionCount * Width; @@ -859,28 +926,35 @@ ParseHiiQuestionOneOf ( OneOf = InternalVarCheckAllocateZeroPool (Length); ASSERT (OneOf != NULL); OneOf->OpCode = EFI_IFR_ONE_OF_OP; OneOf->Length = (UINT8) Length; OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset; - OneOf->StorageWidth = Width; + if (StoredInBitField) { + OneOf->StorageWidth = BitWidth; + } else { + OneOf->StorageWidth = Width; + } + OneOf->BitFieldStore = StoredInBitField; GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1); return (VAR_CHECK_HII_QUESTION_HEADER *) OneOf; } /** Parse Hii Question CheckBox. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the CheckBox is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionCheckBox ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_CHECKBOX *IfrCheckBox; VAR_CHECK_HII_QUESTION_CHECKBOX *CheckBox; @@ -889,43 +963,66 @@ ParseHiiQuestionCheckBox ( CheckBox = InternalVarCheckAllocateZeroPool (sizeof (*CheckBox)); ASSERT (CheckBox != NULL); CheckBox->OpCode = EFI_IFR_CHECKBOX_OP; CheckBox->Length = (UINT8) sizeof (*CheckBox);; CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset; - CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN); + if (StoredInBitField) { + CheckBox->StorageWidth = 1; + } else { + CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN); + } + CheckBox->BitFieldStore = StoredInBitField; return (VAR_CHECK_HII_QUESTION_HEADER *) CheckBox; } /** Parse Hii Question Numeric. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the Numeric is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionNumeric ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_NUMERIC *IfrNumeric; VAR_CHECK_HII_QUESTION_NUMERIC *Numeric; UINT8 Width; + UINT8 BitWidth; IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; + BitWidth = 0; Numeric = InternalVarCheckAllocateZeroPool (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * sizeof (UINT64)); ASSERT (Numeric != NULL); - Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); + if (StoredInBitField) { + // + // When Numeric stored in bit field, the bit field width is saved in the lower six bits of the flag. + // And the Minimum Maximum of Numeric is saved as UINT32 type. + // + BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width = sizeof (UINT32); + } else { + Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); + } Numeric->OpCode = EFI_IFR_NUMERIC_OP; Numeric->Length = (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width); - Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset; - Numeric->StorageWidth = Width; + Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset; + if (StoredInBitField) { + Numeric->StorageWidth = BitWidth; + } else { + Numeric->StorageWidth = Width; + } + Numeric->BitFieldStore = StoredInBitField; CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2); return (VAR_CHECK_HII_QUESTION_HEADER *) Numeric; } @@ -955,15 +1052,16 @@ ParseHiiQuestionOrderedList ( Length = sizeof (*OrderedList) + OptionCount * OptionWidth; OrderedList = InternalVarCheckAllocateZeroPool (Length); ASSERT (OrderedList != NULL); - OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP; - OrderedList->Length = (UINT8) Length; - OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset; - OrderedList->StorageWidth = OptionWidth; - OrderedList->MaxContainers = IfrOrderedList->MaxContainers; + OrderedList->BitFieldStore = FALSE; + OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList->Length = (UINT8) Length; + OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset; + OrderedList->StorageWidth = OptionWidth; + OrderedList->MaxContainers = IfrOrderedList->MaxContainers; GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList + 1); return (VAR_CHECK_HII_QUESTION_HEADER *) OrderedList; } @@ -972,32 +1070,38 @@ ParseHiiQuestionOrderedList ( Parse and create Hii Question node. @param[in] HiiVariableNode Pointer to Hii Variable node. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. @param[in] FromFv Hii Question from FV. + @param[in] StoredInBitField Whether the Question is stored in bit field Storage. **/ VOID ParseHiiQuestion ( IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode, IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, - IN BOOLEAN FromFv + IN BOOLEAN FromFv, + IN BOOLEAN StoredInBitField ) { VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion; + UINT16 ArrayIndex; + // + // Currently only OneOf, CheckBox and Numeric can be stored in bit field. + // switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: - HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader, StoredInBitField); break; case EFI_IFR_CHECKBOX_OP: - HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader, StoredInBitField); break; case EFI_IFR_NUMERIC_OP: - HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader, StoredInBitField); break; case EFI_IFR_ORDERED_LIST_OP: HiiQuestion = ParseHiiQuestionOrderedList (IfrOpCodeHeader); break; @@ -1006,14 +1110,19 @@ ParseHiiQuestion ( ASSERT (FALSE); return; break; } - if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] != NULL) { + if (StoredInBitField) { + ArrayIndex = HiiQuestion->VarOffset; + } else { + ArrayIndex = HiiQuestion->VarOffset * 8; + } + if (HiiVariableNode->HiiQuestionArray[ArrayIndex] != NULL) { MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv); } else { - HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] = HiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = HiiQuestion; } } /** Find Hii variable node by name and GUID. @@ -1164,11 +1273,11 @@ CreateHiiVariableNode ( HiiVariableNode->HiiVariable = HiiVariable; // // The variable store identifier, which is unique within the current form set. // HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId; - HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * sizeof (VAR_CHECK_HII_QUESTION_HEADER *)); + HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * 8 * sizeof (VAR_CHECK_HII_QUESTION_HEADER *)); InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link); } else { HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId; } @@ -1237,24 +1346,37 @@ VarCheckParseHiiPackage ( ) { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode; + BOOLEAN QuestionStoredInBitField; // // Parse and create Hii Variable node list for this Hii Package. // ParseHiiVariable (HiiPackage); HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; + QuestionStoredInBitField = FALSE; + switch (HiiPackageHeader->Type) { case EFI_HII_PACKAGE_FORMS: IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1); while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPackageHeader->Length) { switch (IfrOpCodeHeader->OpCode) { + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField = TRUE; + } + break; + + case EFI_IFR_END_OP: + QuestionStoredInBitField = FALSE; + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: HiiVariableNode = FindHiiVariableNodeByVarStoreId (((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId); @@ -1268,11 +1390,11 @@ VarCheckParseHiiPackage ( // } else { // // Normal IFR // - ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv); + ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv, QuestionStoredInBitField); } default: break; } IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length); @@ -1339,11 +1461,11 @@ DestroyHiiVariableNode ( RemoveEntryList (&HiiVariableNode->Link); // // Free the allocated buffer. // - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]); } } InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray); @@ -1387,11 +1509,11 @@ BuildVarCheckHiiBin ( BinSize = (UINT32) HEADER_ALIGN (BinSize); HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink); HiiVariableLength = HiiVariableNode->HiiVariable->HeaderLength; - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { // // For Hii Question header align. // HiiVariableLength = (UINT32) HEADER_ALIGN (HiiVariableLength); @@ -1432,11 +1554,11 @@ BuildVarCheckHiiBin ( HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink); CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariable->HeaderLength); Ptr += HiiVariableNode->HiiVariable->HeaderLength; - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { // // For Hii Question header align. // Ptr = (UINT8 *) HEADER_ALIGN (Ptr); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf index 98e6983..aeca3ef 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf @@ -1,9 +1,9 @@ ## @file # NULL class library to register var check HII handler. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2015 - 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 @@ -44,10 +44,13 @@ UefiBootServicesTableLib MemoryAllocationLib PcdLib VarCheckLib +[Guids] + gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID + [Protocols] gEfiFirmwareVolume2ProtocolGuid ## SOMETIMES_CONSUMES gEfiFirmwareVolumeBlock2ProtocolGuid ## SOMETIMES_CONSUMES gEfiHiiDatabaseProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 46a93bd..f0274d2 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -91,32 +91,65 @@ VarCheckHiiQuestion ( UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; + UINT8 StartBit; + UINT8 EndBit; + UINT8 TotalBits; + UINT16 VarOffsetByteLevel; + UINT8 StorageWidthByteLevel; + + if (HiiQuestion->BitFieldStore) { + VarOffsetByteLevel = HiiQuestion->VarOffset / 8; + TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth; + StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1); + } else { + VarOffsetByteLevel = HiiQuestion->VarOffset; + StorageWidthByteLevel = HiiQuestion->StorageWidth; + } - if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { - DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); + if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) { + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize)); return FALSE; } OneData = 0; - CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth); + CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel); + if (HiiQuestion->BitFieldStore) { + // + // Get the value form the bit field. + // + StartBit = HiiQuestion->VarOffset % 8; + EndBit = StartBit + HiiQuestion->StorageWidth - 1; + OneData = BitFieldRead64 (OneData, StartBit, EndBit); + } switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + } if (OneData == OneValue) { // // Match // break; } - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // @@ -136,14 +169,24 @@ VarCheckHiiQuestion ( case EFI_IFR_NUMERIC_OP: Minimum = 0; Maximum = 0; Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + } // // No need to check Step, because it is ONLY for UI. // if ((OneData < Minimum) || (OneData > Maximum)) { @@ -341,75 +384,112 @@ DumpHiiQuestion ( UINT64 Minimum; UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; + if (HiiQuestion->BitFieldStore) { + DEBUG ((DEBUG_INFO, "----DumpHiiQuestion-The Question is stored in bit field----\n")); + } else { + DEBUG ((DEBUG_INFO, "----DumpHiiQuestion-The Question is stored in byte field----\n")); + } + DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); - DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); - DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + + if (HiiQuestion->BitFieldStore) { + DEBUG ((DEBUG_INFO, " VarOffset(bit level) - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth(bit level) - 0x%02x\n", HiiQuestion->StorageWidth)); + } else { + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + } switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + switch (HiiQuestion->StorageWidth) { + case sizeof (UINT8): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + break; + case sizeof (UINT16): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + break; + case sizeof (UINT32): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + break; + case sizeof (UINT64): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + break; + default: + ASSERT (FALSE); + break; + } + } + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } + } + break; + + case EFI_IFR_CHECKBOX_OP: + break; + + case EFI_IFR_NUMERIC_OP: + Minimum = 0; + Maximum = 0; + Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); + if(HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); break; case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); break; case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); break; case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); break; default: ASSERT (FALSE); break; } - Ptr += HiiQuestion->StorageWidth; - } - break; - - case EFI_IFR_CHECKBOX_OP: - break; - - case EFI_IFR_NUMERIC_OP: - Minimum = 0; - Maximum = 0; - Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - - switch (HiiQuestion->StorageWidth) { - case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); - break; - case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); - break; - case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); - break; - case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); - break; - default: - ASSERT (FALSE); - break; } break; case EFI_IFR_ORDERED_LIST_OP: DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check 2017-11-05 10:06 ` [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi @ 2017-11-06 5:45 ` Zeng, Star 0 siblings, 0 replies; 5+ messages in thread From: Zeng, Star @ 2017-11-06 5:45 UTC (permalink / raw) To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Dong, Eric, Gao, Liming, Zeng, Star The code logic is good. :) Below are my some minor comments. 1. Fix the typo 'form' to 'from' in "// Get the value form the bit field.". 2. Remove one extra whitespace in "if (StoredInBitField) {" to "if (StoredInBitField) {". 3. Make the assignment in ParseHiiQuestionNumeric()and etc to be line aligned. 4. Should QuestionStoredInBitField be reset to FALSE at EFI_IFR_END_OP? 5. Could you double confirm and refine the line alignment of debug print? Thanks, Star -----Original Message----- From: Bi, Dandan Sent: Sunday, November 5, 2017 6:06 PM To: edk2-devel@lists.01.org Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com> Subject: [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check V2: (1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final VarCheckBinSize and update the implementation accordingly. (2)Update the VAR_CHECK_HII_REVISION (3)Refine the Debug message and function comments,like update oneof", "checkbox", "numeric" to "OneOf", "CheckBox", "Numeric". VarCheckHiiLib check the value set to storage based on the possible value listed in the vfr file. Since we have enhanced vfr to support Question value stored in bit field, so now enhance VarCheckHiiLib to support bit field check. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../VarCheckHiiLib/InternalVarCheckStructure.h | 9 +- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 260 +++++++++++++++------ .../Library/VarCheckHiiLib/VarCheckHiiLib.inf | 5 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 184 ++++++++++----- 5 files changed, 337 insertions(+), 125 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h index a9faed4..8878e4a 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h @@ -1,9 +1,9 @@ /** @file Internal structure for Var Check Hii. -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 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 @@ -21,11 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define HEADER_ALIGNMENT 4 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1))) #pragma pack (1) -#define VAR_CHECK_HII_REVISION 0x0001 +#define VAR_CHECK_HII_REVISION 0x0002 typedef struct { UINT16 Revision; UINT16 HeaderLength; UINT32 Length; // Length include this header @@ -40,41 +40,46 @@ typedef struct { typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. } VAR_CHECK_HII_QUESTION_HEADER; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. //UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ONEOF; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. } VAR_CHECK_HII_QUESTION_CHECKBOX; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. //UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64; //UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_NUMERIC; typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level. UINT8 MaxContainers; //UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ORDEREDLIST; #pragma pack () diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h index a54b867..7363edf 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h @@ -1,9 +1,9 @@ /** @file Include file for Var Check Hii handler and bin. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/MemoryAllocationLib.h> +#include <Guid/MdeModuleHii.h> + #include <Protocol/HiiDatabase.h> #include <Protocol/FirmwareVolume2.h> #include <Protocol/FirmwareVolumeBlock.h> #include "InternalVarCheckStructure.h" diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index a334a6f..7d1da0b 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -1,9 +1,9 @@ /** @file Var Check Hii bin generation. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 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 @@ -118,12 +118,14 @@ DumpHiiPackage ( { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + BOOLEAN QuestionStoredInBitField; HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; + QuestionStoredInBitField = FALSE; DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length)); switch (HiiPackageHeader->Type) { @@ -155,83 +157,116 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes)); DEBUG ((DEBUG_INFO, " Name - %a\n", IfrEfiVarStore->Name)); } break; + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField = TRUE; + } + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: + if (QuestionStoredInBitField) { + DEBUG ((DEBUG_INFO, "----DumpHiiPackage-The Question is stored in bit field----\n")); + } else { + DEBUG ((DEBUG_INFO, "----DumpHiiPackage-The Question is stored in byte field----\n")); + } DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", IfrOpCodeHeader->Length)); DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", IfrOpCodeHeader->Scope)); DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); - DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + if (QuestionStoredInBitField) { + DEBUG ((DEBUG_INFO, " VarStoreInfo (bit level) - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + } else { + DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + } { EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ORDERED_LIST *IfrOrderedList; switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags)); - switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_4: + if (QuestionStoredInBitField) { + // + // For OneOf stored in bit field, the option value are saved as UINT32 type. + // DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); - break; + } else { + switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step)); + break; + } } break; case EFI_IFR_CHECKBOX_OP: IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags)); - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_4: + if (QuestionStoredInBitField) { + // + // For Numeric stored in bit field, the MinValue,MaxValue and Step are saved as UINT32 type. + // DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); - DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); - DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); - break; + } else { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue)); + DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue)); + DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step)); + break; + } } break; case EFI_IFR_ORDERED_LIST_OP: IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers)); @@ -486,28 +521,39 @@ MergeHiiQuestion ( UINT64 Maximum2; UINT64 OneValue2; UINT8 *Ptr; UINT8 *Ptr1; UINT8 *Ptr2; + UINT16 ArrayIndex; // // Hii Question from Hii Database has high priority. // Do not to merge Hii Question from Fv to Hii Question from Hii Database. // if (FromFv) { InternalVarCheckFreePool (HiiQuestion); return; } - HiiQuestion1 = HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset]; + if (HiiQuestion->BitFieldStore) { + ArrayIndex = HiiQuestion->VarOffset; } else { + ArrayIndex = HiiQuestion->VarOffset * 8; } + + HiiQuestion1 = HiiVariableNode->HiiQuestionArray[ArrayIndex]; HiiQuestion2 = HiiQuestion; ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth)); switch (HiiQuestion1->OpCode) { case EFI_IFR_ONE_OF_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } // // Get the length of Hii Question 1. // NewLength = HiiQuestion1->Length; @@ -578,21 +624,29 @@ MergeHiiQuestion ( Ptr += HiiQuestion1->StorageWidth; } Ptr2 += HiiQuestion2->StorageWidth; } - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; case EFI_IFR_CHECKBOX_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } break; case EFI_IFR_NUMERIC_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + if (HiiQuestion1->BitFieldStore) { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset (bit level) = 0x%04x\n", HiiQuestion1->VarOffset)); + } else { + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset)); + } // // Get minimum and maximum of Hii Question 1. // Minimum1 = 0; Maximum1 = 0; @@ -703,11 +757,11 @@ MergeHiiQuestion ( Ptr += HiiQuestion1->StorageWidth; } Ptr2 += HiiQuestion2->StorageWidth; } - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; default: @@ -829,29 +883,42 @@ GetOneOfOption ( /** Parse Hii Question Oneof. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the OneOf is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionOneOf ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_ONE_OF *IfrOneOf; VAR_CHECK_HII_QUESTION_ONEOF *OneOf; UINTN Length; UINT8 Width; UINTN OptionCount; UINT8 OptionWidth; + UINT8 BitWidth; IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader; + BitWidth = 0; - Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); + if (StoredInBitField) { + // + // When OneOf stored in bit field, the bit width is saved in the lower six bits of the flag. + // And the options in the OneOf is saved as UINT32 type. + // + BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width = sizeof (UINT32); + } else { + Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); } GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL); ASSERT (Width == OptionWidth); Length = sizeof (*OneOf) + OptionCount * Width; @@ -859,28 +926,35 @@ ParseHiiQuestionOneOf ( OneOf = InternalVarCheckAllocateZeroPool (Length); ASSERT (OneOf != NULL); OneOf->OpCode = EFI_IFR_ONE_OF_OP; OneOf->Length = (UINT8) Length; OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset; - OneOf->StorageWidth = Width; + if (StoredInBitField) { + OneOf->StorageWidth = BitWidth; + } else { + OneOf->StorageWidth = Width; + } + OneOf->BitFieldStore = StoredInBitField; GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1); return (VAR_CHECK_HII_QUESTION_HEADER *) OneOf; } /** Parse Hii Question CheckBox. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the CheckBox is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionCheckBox ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_CHECKBOX *IfrCheckBox; VAR_CHECK_HII_QUESTION_CHECKBOX *CheckBox; @@ -889,43 +963,66 @@ ParseHiiQuestionCheckBox ( CheckBox = InternalVarCheckAllocateZeroPool (sizeof (*CheckBox)); ASSERT (CheckBox != NULL); CheckBox->OpCode = EFI_IFR_CHECKBOX_OP; CheckBox->Length = (UINT8) sizeof (*CheckBox);; CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset; - CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN); + if (StoredInBitField) { + CheckBox->StorageWidth = 1; + } else { + CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN); } + CheckBox->BitFieldStore = StoredInBitField; return (VAR_CHECK_HII_QUESTION_HEADER *) CheckBox; } /** Parse Hii Question Numeric. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the Numeric is stored in bit field Storage. return Pointer to Hii Question. **/ VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionNumeric ( - IN EFI_IFR_OP_HEADER *IfrOpCodeHeader + IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, + IN BOOLEAN StoredInBitField ) { EFI_IFR_NUMERIC *IfrNumeric; VAR_CHECK_HII_QUESTION_NUMERIC *Numeric; UINT8 Width; + UINT8 BitWidth; IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader; + BitWidth = 0; Numeric = InternalVarCheckAllocateZeroPool (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * sizeof (UINT64)); ASSERT (Numeric != NULL); - Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); + if (StoredInBitField) { + // + // When Numeric stored in bit field, the bit field width is saved in the lower six bits of the flag. + // And the Minimum Maximum of Numeric is saved as UINT32 type. + // + BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width = sizeof (UINT32); + } else { + Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); + } Numeric->OpCode = EFI_IFR_NUMERIC_OP; Numeric->Length = (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width); - Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset; - Numeric->StorageWidth = Width; + Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset; + if (StoredInBitField) { + Numeric->StorageWidth = BitWidth; + } else { + Numeric->StorageWidth = Width; + } + Numeric->BitFieldStore = StoredInBitField; CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2); return (VAR_CHECK_HII_QUESTION_HEADER *) Numeric; } @@ -955,15 +1052,16 @@ ParseHiiQuestionOrderedList ( Length = sizeof (*OrderedList) + OptionCount * OptionWidth; OrderedList = InternalVarCheckAllocateZeroPool (Length); ASSERT (OrderedList != NULL); - OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP; - OrderedList->Length = (UINT8) Length; - OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset; - OrderedList->StorageWidth = OptionWidth; - OrderedList->MaxContainers = IfrOrderedList->MaxContainers; + OrderedList->BitFieldStore = FALSE; + OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList->Length = (UINT8) Length; + OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset; + OrderedList->StorageWidth = OptionWidth; + OrderedList->MaxContainers = IfrOrderedList->MaxContainers; GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList + 1); return (VAR_CHECK_HII_QUESTION_HEADER *) OrderedList; } @@ -972,32 +1070,38 @@ ParseHiiQuestionOrderedList ( Parse and create Hii Question node. @param[in] HiiVariableNode Pointer to Hii Variable node. @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. @param[in] FromFv Hii Question from FV. + @param[in] StoredInBitField Whether the Question is stored in bit field Storage. **/ VOID ParseHiiQuestion ( IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode, IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, - IN BOOLEAN FromFv + IN BOOLEAN FromFv, + IN BOOLEAN StoredInBitField ) { VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion; + UINT16 ArrayIndex; + // + // Currently only OneOf, CheckBox and Numeric can be stored in bit field. + // switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: - HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader, + StoredInBitField); break; case EFI_IFR_CHECKBOX_OP: - HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader, + StoredInBitField); break; case EFI_IFR_NUMERIC_OP: - HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader); + HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader, + StoredInBitField); break; case EFI_IFR_ORDERED_LIST_OP: HiiQuestion = ParseHiiQuestionOrderedList (IfrOpCodeHeader); break; @@ -1006,14 +1110,19 @@ ParseHiiQuestion ( ASSERT (FALSE); return; break; } - if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] != NULL) { + if (StoredInBitField) { + ArrayIndex = HiiQuestion->VarOffset; } else { + ArrayIndex = HiiQuestion->VarOffset * 8; } if + (HiiVariableNode->HiiQuestionArray[ArrayIndex] != NULL) { MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv); } else { - HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] = HiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] = HiiQuestion; } } /** Find Hii variable node by name and GUID. @@ -1164,11 +1273,11 @@ CreateHiiVariableNode ( HiiVariableNode->HiiVariable = HiiVariable; // // The variable store identifier, which is unique within the current form set. // HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId; - HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * sizeof (VAR_CHECK_HII_QUESTION_HEADER *)); + HiiVariableNode->HiiQuestionArray = + InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * 8 * sizeof + (VAR_CHECK_HII_QUESTION_HEADER *)); InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link); } else { HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId; } @@ -1237,24 +1346,37 @@ VarCheckParseHiiPackage ( ) { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode; + BOOLEAN QuestionStoredInBitField; // // Parse and create Hii Variable node list for this Hii Package. // ParseHiiVariable (HiiPackage); HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; + QuestionStoredInBitField = FALSE; + switch (HiiPackageHeader->Type) { case EFI_HII_PACKAGE_FORMS: IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1); while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPackageHeader->Length) { switch (IfrOpCodeHeader->OpCode) { + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField = TRUE; + } + break; + + case EFI_IFR_END_OP: + QuestionStoredInBitField = FALSE; + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: HiiVariableNode = FindHiiVariableNodeByVarStoreId (((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId); @@ -1268,11 +1390,11 @@ VarCheckParseHiiPackage ( // } else { // // Normal IFR // - ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv); + ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, + FromFv, QuestionStoredInBitField); } default: break; } IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length); @@ -1339,11 +1461,11 @@ DestroyHiiVariableNode ( RemoveEntryList (&HiiVariableNode->Link); // // Free the allocated buffer. // - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]); } } InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray); @@ -1387,11 +1509,11 @@ BuildVarCheckHiiBin ( BinSize = (UINT32) HEADER_ALIGN (BinSize); HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink); HiiVariableLength = HiiVariableNode->HiiVariable->HeaderLength; - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { // // For Hii Question header align. // HiiVariableLength = (UINT32) HEADER_ALIGN (HiiVariableLength); @@ -1432,11 +1554,11 @@ BuildVarCheckHiiBin ( HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink); CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariable->HeaderLength); Ptr += HiiVariableNode->HiiVariable->HeaderLength; - for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) { + for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] != NULL) { // // For Hii Question header align. // Ptr = (UINT8 *) HEADER_ALIGN (Ptr); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf index 98e6983..aeca3ef 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf @@ -1,9 +1,9 @@ ## @file # NULL class library to register var check HII handler. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2015 - 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 @@ -44,10 +44,13 @@ UefiBootServicesTableLib MemoryAllocationLib PcdLib VarCheckLib +[Guids] + gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID + [Protocols] gEfiFirmwareVolume2ProtocolGuid ## SOMETIMES_CONSUMES gEfiFirmwareVolumeBlock2ProtocolGuid ## SOMETIMES_CONSUMES gEfiHiiDatabaseProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 46a93bd..f0274d2 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -91,32 +91,65 @@ VarCheckHiiQuestion ( UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; + UINT8 StartBit; + UINT8 EndBit; + UINT8 TotalBits; + UINT16 VarOffsetByteLevel; + UINT8 StorageWidthByteLevel; + + if (HiiQuestion->BitFieldStore) { + VarOffsetByteLevel = HiiQuestion->VarOffset / 8; + TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth; + StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: + TotalBits / 8 + 1); } else { + VarOffsetByteLevel = HiiQuestion->VarOffset; + StorageWidthByteLevel = HiiQuestion->StorageWidth; } - if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { - DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); + if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) { + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, + StorageWidthByteLevel, DataSize)); return FALSE; } OneData = 0; - CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth); + CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, + StorageWidthByteLevel); if (HiiQuestion->BitFieldStore) { + // + // Get the value form the bit field. + // + StartBit = HiiQuestion->VarOffset % 8; + EndBit = StartBit + HiiQuestion->StorageWidth - 1; + OneData = BitFieldRead64 (OneData, StartBit, EndBit); } switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + } if (OneData == OneValue) { // // Match // break; } - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // @@ -136,14 +169,24 @@ VarCheckHiiQuestion ( case EFI_IFR_NUMERIC_OP: Minimum = 0; Maximum = 0; Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + } // // No need to check Step, because it is ONLY for UI. // if ((OneData < Minimum) || (OneData > Maximum)) { @@ -341,75 +384,112 @@ DumpHiiQuestion ( UINT64 Minimum; UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; + if (HiiQuestion->BitFieldStore) { + DEBUG ((DEBUG_INFO, "----DumpHiiQuestion-The Question is stored in + bit field----\n")); } else { + DEBUG ((DEBUG_INFO, "----DumpHiiQuestion-The Question is stored in + byte field----\n")); } + DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); - DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); - DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + + if (HiiQuestion->BitFieldStore) { + DEBUG ((DEBUG_INFO, " VarOffset(bit level) - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth(bit level) - 0x%02x\n", + HiiQuestion->StorageWidth)); } else { + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + } switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + switch (HiiQuestion->StorageWidth) { + case sizeof (UINT8): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + break; + case sizeof (UINT16): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + break; + case sizeof (UINT32): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + break; + case sizeof (UINT64): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + break; + default: + ASSERT (FALSE); + break; + } + } + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } + } + break; + + case EFI_IFR_CHECKBOX_OP: + break; + + case EFI_IFR_NUMERIC_OP: + Minimum = 0; + Maximum = 0; + Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); + if(HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); break; case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); break; case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); break; case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); break; default: ASSERT (FALSE); break; } - Ptr += HiiQuestion->StorageWidth; - } - break; - - case EFI_IFR_CHECKBOX_OP: - break; - - case EFI_IFR_NUMERIC_OP: - Minimum = 0; - Maximum = 0; - Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - - switch (HiiQuestion->StorageWidth) { - case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); - break; - case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); - break; - case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); - break; - case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); - break; - default: - ASSERT (FALSE); - break; } break; case EFI_IFR_ORDERED_LIST_OP: DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-06 5:42 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-11-05 10:05 [PATCH v2 0/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi 2017-11-05 10:06 ` [PATCH v2 1/2] MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFO Dandan Bi 2017-11-06 5:46 ` Zeng, Star 2017-11-05 10:06 ` [PATCH v2 2/2] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Dandan Bi 2017-11-06 5:45 ` Zeng, Star
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox