Debugging facility improvements.
authorUwe Hermann <uwe@hermann-uwe.de>
Wed, 10 Nov 2010 00:14:32 +0000 (00:14 +0000)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 10 Nov 2010 00:14:32 +0000 (00:14 +0000)
 - Hook up malloc() debug code via CONFIG_DEBUG_MALLOC. Only show it in
   menuconfig if at least DEBUG or SPEW are selected as loglevel, as this
   code does additional printk(BIOS_DEBUG, ...) calls which would otherwise
   not be visible anyway.

 - Similarly, make DEBUG_CAR and REALMODE_DEBUG only visible if thr DEBUG or
   SPEW loglevel is selected.

 - Get rid of a custom "debug" macro, use printk() as usual.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Peter Stuge <peter@stuge.se>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6054 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

src/Kconfig
src/lib/cbmem.c
src/lib/malloc.c

index a61efe1a8e7025d0b88d1fb16b05975b12f136df..b25a19e044d90b3d5602c5d0bf917a4c5c90f1a0 100644 (file)
@@ -502,10 +502,13 @@ config DEBUG_RAM_SETUP
 config HAVE_DEBUG_CAR
        def_bool n
 
+# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
+# printk(BIOS_DEBUG, ...) calls.
 config DEBUG_CAR
        bool "Output verbose Cache-as-RAM debug messages"
        default n
-       depends on HAVE_DEBUG_CAR
+       depends on HAVE_DEBUG_CAR && \
+                  (DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8)
        help
          This option enables additional CAR related debug messages.
 
@@ -553,10 +556,26 @@ config DEBUG_SMM_RELOCATION
 
          If unsure, say N.
 
+# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
+# printk(BIOS_DEBUG, ...) calls.
+config DEBUG_MALLOC
+       bool "Output verbose malloc debug messages"
+       default n
+       depends on DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
+       help
+         This option enables additional malloc related debug messages.
+
+         Note: This option will increase the size of the coreboot image.
+
+         If unsure, say N.
+
+# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
+# printk(BIOS_DEBUG, ...) calls.
 config REALMODE_DEBUG
        bool "Enable debug messages for option ROM execution"
        default n
-       depends on PCI_OPTION_ROM_RUN_REALMODE
+       depends on PCI_OPTION_ROM_RUN_REALMODE && \
+                  (DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8)
        help
          This option enables additional x86emu related debug messages.
 
index 7e3e20123a543e8372b41d794d6a4d64ce695efb..5490a1fef6dd6195a3f83047abf0d2c3487c1978 100644 (file)
 #include <cbmem.h>
 #include <console/console.h>
 
-#if 1
-#define debug(x...) printk(BIOS_DEBUG, x)
-#else
-#define debug(x...)
-#endif
-
 // The CBMEM TOC reserves 512 bytes to keep
 // the other entries somewhat aligned.
 // Increase if MAX_CBMEM_ENTRIES exceeds 21
@@ -68,10 +62,11 @@ void cbmem_init(u64 baseaddr, u64 size)
        bss_cbmem_toc = cbmem_toc;
 #endif
 
-       debug("Initializing CBMEM area to 0x%llx (%lld bytes)\n", baseaddr, size);
+       printk(BIOS_DEBUG, "Initializing CBMEM area to 0x%llx (%lld bytes)\n",
+              baseaddr, size);
 
        if (size < (64 * 1024)) {
-               debug("Increase CBMEM size!!\n");
+               printk(BIOS_DEBUG, "Increase CBMEM size!\n");
                for (;;) ;
        }
 
@@ -90,7 +85,9 @@ int cbmem_reinit(u64 baseaddr)
        struct cbmem_entry *cbmem_toc;
        cbmem_toc = (struct cbmem_entry *)(unsigned long)baseaddr;
 
-       debug("Re-Initializing CBMEM area to 0x%lx\n", (unsigned long)baseaddr);
+       printk(BIOS_DEBUG, "Re-Initializing CBMEM area to 0x%lx\n",
+              (unsigned long)baseaddr);
+
 #ifndef __PRE_RAM__
        bss_cbmem_toc = cbmem_toc;
 #endif
@@ -135,7 +132,7 @@ void *cbmem_add(u32 id, u64 size)
                return NULL;
        }
 
-       debug("Adding CBMEM entry as no. %d\n", i);
+       printk(BIOS_DEBUG, "Adding CBMEM entry as no. %d\n", i);
 
        cbmem_toc[i] = (struct cbmem_entry) {
                .magic = CBMEM_MAGIC,
index 2ed23ad79597e923409bb1fe5c13e266609490b6..ac038ecd44f00473f34ad553b2353dd9407db6c6 100644 (file)
@@ -1,11 +1,12 @@
 #include <stdlib.h>
 #include <console/console.h>
 
-#if 0
-#define MALLOCDBG(x)
-#else
+#if CONFIG_DEBUG_MALLOC
 #define MALLOCDBG(x...) printk(BIOS_SPEW, x)
+#else
+#define MALLOCDBG(x)
 #endif
+
 extern unsigned char _heap, _eheap;
 static void *free_mem_ptr = &_heap;            /* Start of heap */
 static void *free_mem_end_ptr = &_eheap;       /* End of heap */