summaryrefslogtreecommitdiffstats
path: root/src/include/compiler.h
diff options
context:
space:
mode:
authorMichael Brown2008-10-01 19:58:21 +0200
committerMichael Brown2008-10-01 20:24:56 +0200
commitafe1323c76c84c5c5bf50ef8fb7aa593fe2ca2e0 (patch)
treee9c5b5ed4a8b736f9ff343dcd3f6a235985c4179 /src/include/compiler.h
parent[compiler] Add __always_inline macro (diff)
downloadipxe-afe1323c76c84c5c5bf50ef8fb7aa593fe2ca2e0.tar.gz
ipxe-afe1323c76c84c5c5bf50ef8fb7aa593fe2ca2e0.tar.xz
ipxe-afe1323c76c84c5c5bf50ef8fb7aa593fe2ca2e0.zip
[compiler] Allow for selective disabling of debug levels at runtime
The usefulness of DBGLVL_IO is limited by the fact that many cards require large numbers of uninteresting I/O reads/writes at device probe time, typically when driving a bit-bashing I2C/SPI bus to read the MAC address. This patch adds the DBG_DISABLE() and DBG_ENABLE() macros, which can be used to temporarily disable and re-enable selected debug levels. Note that debug levels must still be enabled in the build in order to function at all: you can't use DBG_ENABLE(DBGLVL_IO) in an object built with DEBUG=object:1 and expect it to do anything.
Diffstat (limited to 'src/include/compiler.h')
-rw-r--r--src/include/compiler.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h
index a6532dad..b6a6f8e2 100644
--- a/src/include/compiler.h
+++ b/src/include/compiler.h
@@ -131,11 +131,26 @@ extern void dbg_decolourise ( void );
extern void dbg_hex_dump_da ( unsigned long dispaddr,
const void *data, unsigned long len );
-/* Compatibility with existing Makefile */
#if DEBUG_SYMBOL
-#define DBGLVL DEBUG_SYMBOL
+#define DBGLVL_MAX DEBUG_SYMBOL
+#else
+#define DBGLVL_MAX 0
+#endif
+
+/* Allow for selective disabling of enabled debug levels */
+#if DBGLVL_MAX
+int __debug_disable;
+#define DBGLVL ( DBGLVL_MAX & ~__debug_disable )
+#define DBG_DISABLE( level ) do { \
+ __debug_disable |= ( (level) & DBGLVL_MAX ); \
+ } while ( 0 )
+#define DBG_ENABLE( level ) do { \
+ __debug_disable &= ~( (level) & DBGLVL_MAX ); \
+ } while ( 0 )
#else
#define DBGLVL 0
+#define DBG_DISABLE( level ) do { } while ( 0 )
+#define DBG_ENABLE( level ) do { } while ( 0 )
#endif
#define DBGLVL_LOG 1