From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id AFA2D9413DE for ; Thu, 21 Mar 2024 07:30:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/S3LZwYFI0OD8LSru1ynIY19+XvtIxnv9Gm3MOBwJEU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1711006217; v=1; b=jAMDmvItexfG5Mrz/cASNf/FvvuBOiv7aEbUWvdAFXqu/HAWWLyr4Xn0iP7PV9K3oxWeN51u 0twlZOOfQ5vUqnGH0elNy/YwYd0LAhclbFnrt6fpxdkZ49G4l0reeUb20aKTemHYo/3RHTEz3wQ wavacGYys97WSidTfnQPuMSS4epAjJR6LFlngKwpgCtbP8EDiTs+FtsMTpibxhtkFij1BzuhUL4 mj6thCwwnEQXwKfYptMj2cwnXCBOpMmOLVff7639GST4erGa9y7cHzVkI4wPPjepLlBlSjpa4t4 GXTSBAnJWvEPynm0KDdiIpR0ZYRzhYS30HcNYPf4VZ8+g== X-Received: by 127.0.0.2 with SMTP id So34YY7687511xTRr5cuDMP0; Thu, 21 Mar 2024 00:30:17 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mx.groups.io with SMTP id smtpd.web10.1814.1711006216613111809 for ; Thu, 21 Mar 2024 00:30:16 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="6586219" X-IronPort-AV: E=Sophos;i="6.07,142,1708416000"; d="scan'208";a="6586219" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 00:30:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,142,1708416000"; d="scan'208";a="51847457" X-Received: from sh0701bl-hv01.ccr.corp.intel.com ([10.239.220.156]) by orviesa001.jf.intel.com with ESMTP; 21 Mar 2024 00:30:14 -0700 From: "Yuting Yang" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng , Christine Chen , Zifeng Zhang Subject: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Date: Thu, 21 Mar 2024 00:30:03 -0700 Message-Id: <20240321073003.1198-1-yuting2.yang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 21 Mar 2024 00:30:16 -0700 Reply-To: devel@edk2.groups.io,yuting2.yang@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: YZq4drjvNLdL2qcDYafscGNpx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=jAMDmvIt; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Add --catch_default option Raise a DefaultValueError when encountering VFR default definitions to help remove default variables. Signed-off-by: Yuting Yang Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Cc: Christine Chen Cc: Zifeng Zhang --- BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 8 ++++---- BaseTools/Source/C/VfrCompile/VfrCompiler.h | 1 + BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 ++- BaseTools/Source/C/VfrCompile/VfrError.h | 3 ++- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 1 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 58 +++++++++++++++++++++++= +++++++++++++++++++++++++++-------- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Sour= ce/C/VfrCompile/VfrCompiler.cpp index 5f4d262d85..4031af6e39 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -78,6 +78,7 @@ CVfrCompiler::OptionInitialization ( mOptions.WarningAsError =3D FALSE;=0D mOptions.AutoDefault =3D FALSE;=0D mOptions.CheckDefault =3D FALSE;=0D + mOptions.IsCatchDefaultEnable =3D FALSE;=0D memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID));=0D =0D if (Argc =3D=3D 1) {=0D @@ -95,6 +96,8 @@ CVfrCompiler::OptionInitialization ( Version ();=0D SET_RUN_STATUS (STATUS_DEAD);=0D return;=0D + } else if (stricmp(Argv[Index], "--catch_default") =3D=3D 0){=0D + mOptions.IsCatchDefaultEnable =3D TRUE;=0D } else if (stricmp(Argv[Index], "-l") =3D=3D 0) {=0D mOptions.CreateRecordListFile =3D TRUE;=0D gCIfrRecordInfoDB.TurnOn ();=0D @@ -179,7 +182,6 @@ CVfrCompiler::OptionInitialization ( goto Fail;=0D }=0D strcpy (mOptions.VfrFileName, Argv[Index]);=0D -=0D if (mOptions.OutputDirectory =3D=3D NULL) {=0D mOptions.OutputDirectory =3D (CHAR8 *) malloc (1);=0D if (mOptions.OutputDirectory =3D=3D NULL) {=0D @@ -679,7 +681,7 @@ CVfrCompiler::Compile ( DebugError (NULL, 0, 0001, "Error opening the input file", "%s", InFil= eName);=0D goto Fail;=0D }=0D -=0D + InputInfo.IsCatchDefaultEnable =3D mOptions.IsCatchDefaultEnable;=0D if (mOptions.HasOverrideClassGuid) {=0D InputInfo.OverrideClassGuid =3D &mOptions.OverrideClassGuid;=0D } else {=0D @@ -937,5 +939,3 @@ main ( =0D return GetUtilityStatus ();=0D }=0D -=0D -=0D diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source= /C/VfrCompile/VfrCompiler.h index b6e207d2ce..974f37c4eb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h @@ -52,6 +52,7 @@ typedef struct { BOOLEAN WarningAsError;=0D BOOLEAN AutoDefault;=0D BOOLEAN CheckDefault;=0D + BOOLEAN IsCatchDefaultEnable;=0D } OPTIONS;=0D =0D typedef enum {=0D diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/= C/VfrCompile/VfrError.cpp index 65bb8e34fd..8a706f929b 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -49,7 +49,8 @@ static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = =3D { { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with = different value"},=0D { VFR_WARNING_ACTION_WITH_TEXT_TWO, ": Action opcode should not have Tex= tTwo part"},=0D { VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE, ": Not recommend to use obsole= ted framework opcode"},=0D - { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" }=0D + { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" },=0D + { VFR_WARNING_UNSUPPORTED, ": pls remove the default values if necessary= " }=0D };=0D =0D CVfrErrorHandle::CVfrErrorHandle (=0D diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/= VfrCompile/VfrError.h index 7d16bd5f74..1b4bc173d2 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.h +++ b/BaseTools/Source/C/VfrCompile/VfrError.h @@ -47,7 +47,8 @@ typedef enum { VFR_WARNING_DEFAULT_VALUE_REDEFINED =3D 0,=0D VFR_WARNING_ACTION_WITH_TEXT_TWO,=0D VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,=0D - VFR_WARNING_CODEUNDEFINED=0D + VFR_WARNING_CODEUNDEFINED,=0D + VFR_WARNING_UNSUPPORTED=0D } EFI_VFR_WARNING_CODE;=0D =0D typedef struct _SVFR_ERROR_HANDLE {=0D diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/= C/VfrCompile/VfrFormPkg.h index 9ef6f07787..d8fada3bcb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -96,6 +96,7 @@ struct SBufferNode { =0D typedef struct {=0D EFI_GUID *OverrideClassGuid;=0D + BOOLEAN IsCatchDefaultEnable;=0D } INPUT_INFO_TO_SYNTAX;=0D =0D class CFormPkg {=0D diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C= /VfrCompile/VfrSyntax.g index 55fd067f8a..d7376122d8 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -50,6 +50,7 @@ VfrParserStart ( {=0D ParserBlackBox VfrParser(File);= =0D VfrParser.parser()->SetOverrideClassGuid (InputInfo->OverrideClassGuid);= =0D + VfrParser.parser()->SetIsCatchDefaultEnable(InputInfo->IsCatchDefaultEna= ble);=0D return VfrParser.parser()->vfrProgram();=0D }=0D >>=0D @@ -975,7 +976,15 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *= TypeName, UINT32 TypeSize, =0D vfrStatementDefaultStore :=0D << UINT16 DefaultId =3D EFI_HII_DEFAULT_CLASS_STANDARD; >>=0D - D:DefaultStore N:StringIdentifier ","=0D + D:DefaultStore N:StringIdentifier "," <<=0D + if (mIsCatchDefaultE= nable) {=0D + gCVfrErrorHandle.Han= dleWarning (=0D + VFR_WARNING_UNSU= PPORTED,=0D + D->getLine(),=0D + D->getText()=0D + );=0D + }=0D + >>=0D Prompt "=3D" "STRING_TOKEN" "\(" S:Number "\)"=0D {=0D "," Attribute "=3D" A:Number << DefaultId =3D _ST= OU16(A->getText(), A->getLine()); >>=0D @@ -1775,7 +1784,11 @@ vfrStatementDefault : CIfrNumeric *NumericQst =3D NULL;=0D =0D >>=0D - D:Default =0D + D:Default <<=0D + if (mIsCatchDefaul= tEnable) {=0D + DefaultValueErro= r(VFR_RETURN_UNSUPPORTED, D->getLine());=0D + }=0D + >>=0D (=0D (=0D "=3D" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayTyp= e] "," =0D @@ -1970,11 +1983,15 @@ vfrStatementInvalid : ;=0D =0D flagsField :=0D - Number =0D - | InteractiveFlag =0D - | ManufacturingFlag =0D - | DefaultFlag =0D - | ResetRequiredFlag =0D + Number=0D + | InteractiveFlag=0D + | ManufacturingFlag=0D + | D:DefaultFlag <<=0D + if (mIsCatchDefa= ultEnable) {=0D + DefaultValueEr= ror(VFR_RETURN_UNSUPPORTED, D->getLine());=0D + }=0D + >>=0D + | ResetRequiredFlag=0D | ReconnectRequiredFlag=0D | N:NVAccessFlag <<=0D gCVfrErrorHandle= .HandleWarning (=0D @@ -3790,7 +3807,12 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlag= s] : | RestStyleFlag << $HFlags |=3D 0x2= 0; >>=0D | ReconnectRequiredFlag << $HFlags |=3D 0x4= 0; >>=0D | ManufacturingFlag << $LFlags |=3D 0x2= 0; >>=0D - | DefaultFlag << $LFlags |=3D 0x1= 0; >>=0D + | D:DefaultFlag <<=0D + $LFlags |=3D 0x1= 0;=0D + if (mIsCatchDefa= ultEnable) {=0D + DefaultValueEr= ror(VFR_RETURN_UNSUPPORTED, D->getLine());=0D + }=0D + >>=0D | A:NVAccessFlag <<=0D gCVfrErrorHandle= .HandleWarning (=0D VFR_WARNING_OB= SOLETED_FRAMEWORK_OPCODE,=0D @@ -4837,6 +4859,7 @@ spanFlags [UINT8 & Flags] : class EfiVfrParser {=0D <<=0D private:=0D + BOOLEAN mIsCatchDefaultEnable;=0D UINT8 mParserStatus;=0D BOOLEAN mConstantOnlyInExpression;=0D =0D @@ -4880,6 +4903,7 @@ public: VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);= =0D VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);=0D VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST= CHAR8 *);=0D + VOID DefaultValueError (IN EFI_VFR_RETURN_CODE, IN UINT32= );=0D =0D VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWord= Type *, ANTLRTokenType, INT32);=0D =0D @@ -4909,6 +4933,7 @@ public: VOID IdEqIdDoSpecial (IN UINT32 &, IN UINT32, IN EF= I_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UI= NT32, IN EFI_COMPARE_TYPE);=0D VOID IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EF= I_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *);=0D VOID SetOverrideClassGuid (IN EFI_GUID *);=0D + VOID SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnabl= e);=0D >>=0D }=0D =0D @@ -5086,6 +5111,17 @@ EfiVfrParser::_PCATCH ( mParserStatus =3D mParserStatus + gCVfrErrorHandle.HandleError (ReturnCo= de, LineNum, (CHAR8 *) ErrorMsg);=0D }=0D =0D +VOID=0D +EfiVfrParser::DefaultValueError (=0D + IN EFI_VFR_RETURN_CODE ReturnCode,=0D + IN UINT32 LineNum=0D + )=0D +{=0D + CHAR8 ErrorMsg[100];=0D + sprintf(ErrorMsg, "please remove the default value / defaultstore in lin= e %d", LineNum);=0D + mParserStatus =3D mParserStatus + gCVfrErrorHandle.HandleError (ReturnCo= de, LineNum, ErrorMsg);=0D +}=0D +=0D VOID=0D EfiVfrParser::syn (=0D ANTLRAbstractToken *Tok,=0D @@ -5688,6 +5724,12 @@ EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *Ove= rrideClassGuid) mOverrideClassGuid =3D OverrideClassGuid;=0D }=0D =0D +VOID=0D +EfiVfrParser::SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable)=0D +{=0D + mIsCatchDefaultEnable =3D IsCatchDefaultEnable;=0D +}=0D +=0D VOID=0D EfiVfrParser::CheckDuplicateDefaultValue (=0D IN EFI_DEFAULT_ID DefaultId,=0D --=20 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116948): https://edk2.groups.io/g/devel/message/116948 Mute This Topic: https://groups.io/mt/105061128/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-