From 14414da4688e9af239e06d1f823c37d8f92090f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 31 Jul 2010 11:05:28 +0200 Subject: [PATCH] jazz led: Fix debug prints MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a macro to easily enable/disable debug prints Also fix wrong printf formatters Signed-off-by: Hervé Poussineau Signed-off-by: Aurelien Jarno --- hw/jazz_led.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/jazz_led.c b/hw/jazz_led.c index 18780e9..4cb680c 100644 --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -29,6 +29,15 @@ //#define DEBUG_LED +#ifdef DEBUG_LED +#define DPRINTF(fmt, ...) \ +do { printf("jazz led: " fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) do {} while (0) +#endif +#define BADF(fmt, ...) \ +do { fprintf(stderr, "jazz led ERROR: " fmt , ## __VA_ARGS__);} while (0) + typedef enum { REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2, } screen_state_t; @@ -49,12 +58,12 @@ static uint32_t led_readb(void *opaque, target_phys_addr_t addr) val = s->segments; break; default: -#ifdef DEBUG_LED - printf("jazz led: invalid read [0x%x]\n", relative_addr); -#endif + BADF("invalid read at [" TARGET_FMT_plx "]\n", addr); val = 0; } + DPRINTF("read addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val); + return val; } @@ -92,15 +101,15 @@ static void led_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) { LedState *s = opaque; + DPRINTF("write addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val); + switch (addr) { case 0: s->segments = val; s->state |= REDRAW_SEGMENTS; break; default: -#ifdef DEBUG_LED - printf("jazz led: invalid write of 0x%02x at [0x%x]\n", val, relative_addr); -#endif + BADF("invalid write of 0x%08x at [" TARGET_FMT_plx "]\n", val, addr); break; } } -- 2.7.4