]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add new API DebugPrintLevelEnabled() in DebugLib
authorLiming Gao <liming.gao@intel.com>
Fri, 6 Feb 2015 06:33:29 +0000 (06:33 +0000)
committerlgao4 <lgao4@Edk2>
Fri, 6 Feb 2015 06:33:29 +0000 (06:33 +0000)
This API is applied in _DEBUG_PRINT() macro for build time size optimization.
DebugLib library instance should implement this API to return the constant value.
DEBUG_PRINT() will base on __VA_ARGS__ for build time size optimization.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16787 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/DebugLib.h

index f969ce23178753533cb7914d7697023f03fff11d..402bebe7d3797f94c7ba07c14b23388685163f33 100644 (file)
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is\r
   defined, then debug and assert related macros wrapped by it are the NULL implementations.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -220,6 +220,20 @@ DebugClearMemoryEnabled (
   VOID\r
   );\r
 \r
+/**\r
+  Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
+\r
+  This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
+\r
+  @retval  TRUE    Current ErrorLevel is supported.\r
+  @retval  FALSE   Current ErrorLevel is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugPrintLevelEnabled (\r
+  IN  CONST UINTN        ErrorLevel\r
+  );\r
 \r
 /**  \r
   Internal worker macro that calls DebugAssert().\r
@@ -243,8 +257,18 @@ DebugClearMemoryEnabled (
                       and a variable argument list based on the format string.\r
 \r
 **/\r
-#define _DEBUG(Expression)   DebugPrint Expression\r
 \r
+#if !defined(MDE_CPU_EBC)\r
+  #define _DEBUG_PRINT(PrintLevel, ...)              \\r
+    do {                                             \\r
+      if (DebugPrintLevelEnabled (PrintLevel)) {     \\r
+        DebugPrint (PrintLevel, ##__VA_ARGS__);      \\r
+      }                                              \\r
+    } while (FALSE)\r
+  #define _DEBUG(Expression)   _DEBUG_PRINT Expression\r
+#else\r
+#define _DEBUG(Expression)   DebugPrint Expression\r
+#endif\r
 \r
 /**  \r
   Macro that calls DebugAssert() if an expression evaluates to FALSE.\r