i8259: improve debugging
authorBlue Swirl <blauwirbel@gmail.com>
Sat, 29 May 2010 20:23:19 +0000 (20:23 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 29 May 2010 20:23:19 +0000 (20:23 +0000)
Add a DPRINTF macro.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
hw/i8259.c

index ea48e0e..a995280 100644 (file)
 /* debug PIC */
 //#define DEBUG_PIC
 
+#ifdef DEBUG_PIC
+#define DPRINTF(fmt, ...)                                       \
+    do { printf("pic: " fmt , ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
 //#define DEBUG_IRQ_LATENCY
 //#define DEBUG_IRQ_COUNT
 
@@ -185,9 +192,7 @@ static void i8259_set_irq(void *opaque, int irq, int level)
 
 #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT)
     if (level != irq_level[irq]) {
-#if defined(DEBUG_PIC)
-        printf("i8259_set_irq: irq=%d level=%d\n", irq, level);
-#endif
+        DPRINTF("i8259_set_irq: irq=%d level=%d\n", irq, level);
         irq_level[irq] = level;
 #ifdef DEBUG_IRQ_COUNT
        if (level == 1)
@@ -253,9 +258,7 @@ int pic_read_irq(PicState2 *s)
            (double)(qemu_get_clock(vm_clock) -
                     irq_time[irq]) * 1000000.0 / get_ticks_per_sec());
 #endif
-#if defined(DEBUG_PIC)
-    printf("pic_interrupt: irq=%d\n", irq);
-#endif
+    DPRINTF("pic_interrupt: irq=%d\n", irq);
     return intno;
 }
 
@@ -286,9 +289,7 @@ static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     PicState *s = opaque;
     int priority, cmd, irq;
 
-#ifdef DEBUG_PIC
-    printf("pic_write: addr=0x%02x val=0x%02x\n", addr, val);
-#endif
+    DPRINTF("write: addr=0x%02x val=0x%02x\n", addr, val);
     addr &= 1;
     if (addr == 0) {
         if (val & 0x10) {
@@ -416,9 +417,7 @@ static uint32_t pic_ioport_read(void *opaque, uint32_t addr1)
             ret = s->imr;
         }
     }
-#ifdef DEBUG_PIC
-    printf("pic_read: addr=0x%02x val=0x%02x\n", addr1, ret);
-#endif
+    DPRINTF("read: addr=0x%02x val=0x%02x\n", addr1, ret);
     return ret;
 }