From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ispras.ru (mail.ispras.ru []) by mx.groups.io with SMTP id smtpd.web10.14606.1589211685418444973 for ; Mon, 11 May 2020 08:41:28 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: ispras.ru, ip: , mailfrom: cheptsov@ispras.ru) Received: from localhost.localdomain (unknown [77.232.9.83]) by mail.ispras.ru (Postfix) with ESMTPSA id 1BA99CD466 for ; Mon, 11 May 2020 18:41:27 +0300 (MSK) From: "Vitaly Cheptsov" To: devel@edk2.groups.io Subject: [PATCH V4 26/27] MdePkg: Introduce assertion on constraint debug mask bit Date: Mon, 11 May 2020 18:41:20 +0300 Message-Id: <20200511154121.3878-27-cheptsov@ispras.ru> X-Mailer: git-send-email 2.24.2 (Apple Git-127) In-Reply-To: <20200511154121.3878-1-cheptsov@ispras.ru> References: <20200511154121.3878-1-cheptsov@ispras.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2054 This bit allows to control assertion on constrain violation. Signed-off-by: Vitaly Cheptsov --- MdePkg/Include/Library/DebugCommonLib.h | 18 ++++++++++++++++++ MdePkg/Include/Library/DebugLib.h | 18 ++++++++++++++++++ MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c | 20 ++++++++++++++++++= ++ MdePkg/MdePkg.dec | 3 ++- 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/DebugCommonLib.h b/MdePkg/Include/Libra= ry/DebugCommonLib.h index 31249f91fa..3dc906d02a 100644 --- a/MdePkg/Include/Library/DebugCommonLib.h +++ b/MdePkg/Include/Library/DebugCommonLib.h @@ -21,6 +21,7 @@ #define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08=0D #define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10=0D #define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20=0D +#define DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED 0x40=0D =0D //=0D // Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter o= f DebugPrint()=0D @@ -135,6 +136,23 @@ DebugClearMemoryEnabled ( );=0D =0D =0D +/**=0D + Returns TRUE if ASSERT_CONSTRAINT() macro is enabled.=0D +=0D + This function returns TRUE if the DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABL= ED bit of=0D + PcdDebugProperyMask is set. Otherwise, FALSE is returned.=0D +=0D + @retval TRUE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of Pcd= DebugProperyMask is set.=0D + @retval FALSE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of Pcd= DebugProperyMask is clear.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +DebugAssertConstraintEnabled (=0D + VOID=0D + );=0D +=0D +=0D /**=0D Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixe= dDebugPrintErrorLevel.=0D =0D diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.h index a38e0e2904..ea38522ae3 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -212,6 +212,24 @@ DebugClearMemory ( #define ASSERT(Expression)=0D #endif=0D =0D +=0D +/**=0D + Macro that calls ASSERT when constrain assertions are enabled.=0D +=0D + If DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask i= s set,=0D + then this macro evaluates to an ASSERT macro passing in the original Exp= ression.=0D +=0D + @param Expression Boolean expression.=0D +=0D +**/=0D +#define ASSERT_CONSTRAINT(Expression) \=0D + do { \=0D + if (DebugAssertConstraintEnabled ()) { \=0D + ASSERT (Expression); \=0D + } \=0D + } while (FALSE)=0D +=0D +=0D /**=0D Macro that calls DebugPrint().=0D =0D diff --git a/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c b/MdePkg/Li= brary/BaseDebugCommonLib/DebugCommonLib.c index 2291fb5382..870f9ceec5 100644 --- a/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c +++ b/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c @@ -93,6 +93,26 @@ DebugClearMemoryEnabled ( }=0D =0D =0D +/**=0D + Returns TRUE if ASSERT_CONSTRAINT() macro is enabled.=0D +=0D + This function returns TRUE if the DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABL= ED bit of=0D + PcdDebugProperyMask is set. Otherwise, FALSE is returned.=0D +=0D + @retval TRUE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of Pcd= DebugProperyMask is set.=0D + @retval FALSE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of Pcd= DebugProperyMask is clear.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +DebugAssertConstraintEnabled (=0D + VOID=0D + )=0D +{=0D + return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSER= T_CONSTRAINT_ENABLED) !=3D 0);=0D +}=0D +=0D +=0D /**=0D Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixe= dDebugPrintErrorLevel.=0D =0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index a121b9ecab..63003357d6 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -2136,9 +2136,10 @@ [PcdsFixedAtBuild,PcdsPatchableInModule] # BIT3 - Enable Clear Memory.
=0D # BIT4 - Enable BreakPoint as ASSERT.
=0D # BIT5 - Enable DeadLoop as ASSERT.
=0D + # BIT6 - Treat constrait violations as ASSERT.
=0D # @Prompt Debug Property.=0D # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMa= sk & 0xC0) =3D=3D 0=0D - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005=0D + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000045=0D =0D ## This flag is used to control the print out Debug message.

=0D # BIT0 - Initialization message.
=0D --=20 2.24.2 (Apple Git-127)