openpic: fix debug prints

Fix various format errors when debug prints are enabled.  Also
cause error checking to happen even when debug prints are not
enabled, and consistently use 0x for hex output.

Signed-off-by: Scott Wood <scottwood@freescale.com>
[agraf: adjust for more recent code base, prettify DPRINTF macro]
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Scott Wood 2012-12-21 16:15:38 +00:00 committed by Alexander Graf
parent beb526b121
commit 4c4f0e4801

View File

@ -43,11 +43,17 @@
//#define DEBUG_OPENPIC //#define DEBUG_OPENPIC
#ifdef DEBUG_OPENPIC #ifdef DEBUG_OPENPIC
#define DPRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } while (0) static const int debug_openpic = 1;
#else #else
#define DPRINTF(fmt, ...) do { } while (0) static const int debug_openpic = 0;
#endif #endif
#define DPRINTF(fmt, ...) do { \
if (debug_openpic) { \
printf(fmt , ## __VA_ARGS__); \
} \
} while (0)
#define MAX_CPU 15 #define MAX_CPU 15
#define MAX_SRC 256 #define MAX_SRC 256
#define MAX_TMR 4 #define MAX_TMR 4
@ -422,7 +428,7 @@ static void openpic_set_irq(void *opaque, int n_IRQ, int level)
IRQSource *src; IRQSource *src;
src = &opp->src[n_IRQ]; src = &opp->src[n_IRQ];
DPRINTF("openpic: set irq %d = %d ipvp=%08x\n", DPRINTF("openpic: set irq %d = %d ipvp=0x%08x\n",
n_IRQ, level, src->ipvp); n_IRQ, level, src->ipvp);
if (src->ipvp & IPVP_SENSE_MASK) { if (src->ipvp & IPVP_SENSE_MASK) {
/* level-sensitive irq */ /* level-sensitive irq */
@ -513,7 +519,8 @@ static void openpic_gbl_write(void *opaque, hwaddr addr, uint64_t val,
IRQDest *dst; IRQDest *dst;
int idx; int idx;
DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); DPRINTF("%s: addr %#" HWADDR_PRIx " <= %08" PRIx64 "\n",
__func__, addr, val);
if (addr & 0xF) { if (addr & 0xF) {
return; return;
} }
@ -576,7 +583,7 @@ static uint64_t openpic_gbl_read(void *opaque, hwaddr addr, unsigned len)
OpenPICState *opp = opaque; OpenPICState *opp = opaque;
uint32_t retval; uint32_t retval;
DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr);
retval = 0xFFFFFFFF; retval = 0xFFFFFFFF;
if (addr & 0xF) { if (addr & 0xF) {
return retval; return retval;
@ -623,7 +630,7 @@ static uint64_t openpic_gbl_read(void *opaque, hwaddr addr, unsigned len)
default: default:
break; break;
} }
DPRINTF("%s: => %08x\n", __func__, retval); DPRINTF("%s: => 0x%08x\n", __func__, retval);
return retval; return retval;
} }
@ -634,7 +641,8 @@ static void openpic_tmr_write(void *opaque, hwaddr addr, uint64_t val,
OpenPICState *opp = opaque; OpenPICState *opp = opaque;
int idx; int idx;
DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); DPRINTF("%s: addr %#" HWADDR_PRIx " <= %08" PRIx64 "\n",
__func__, addr, val);
if (addr & 0xF) { if (addr & 0xF) {
return; return;
} }
@ -672,7 +680,7 @@ static uint64_t openpic_tmr_read(void *opaque, hwaddr addr, unsigned len)
uint32_t retval = -1; uint32_t retval = -1;
int idx; int idx;
DPRINTF("%s: addr %08x\n", __func__, addr); DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr);
if (addr & 0xF) { if (addr & 0xF) {
goto out; goto out;
} }
@ -698,7 +706,7 @@ static uint64_t openpic_tmr_read(void *opaque, hwaddr addr, unsigned len)
} }
out: out:
DPRINTF("%s: => %08x\n", __func__, retval); DPRINTF("%s: => 0x%08x\n", __func__, retval);
return retval; return retval;
} }
@ -709,7 +717,8 @@ static void openpic_src_write(void *opaque, hwaddr addr, uint64_t val,
OpenPICState *opp = opaque; OpenPICState *opp = opaque;
int idx; int idx;
DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); DPRINTF("%s: addr %#" HWADDR_PRIx " <= %08" PRIx64 "\n",
__func__, addr, val);
if (addr & 0xF) { if (addr & 0xF) {
return; return;
} }
@ -730,7 +739,7 @@ static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)
uint32_t retval; uint32_t retval;
int idx; int idx;
DPRINTF("%s: addr %08x\n", __func__, addr); DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr);
retval = 0xFFFFFFFF; retval = 0xFFFFFFFF;
if (addr & 0xF) { if (addr & 0xF) {
return retval; return retval;
@ -744,7 +753,7 @@ static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)
/* EXVP / IFEVP / IEEVP */ /* EXVP / IFEVP / IEEVP */
retval = read_IRQreg_ipvp(opp, idx); retval = read_IRQreg_ipvp(opp, idx);
} }
DPRINTF("%s: => %08x\n", __func__, retval); DPRINTF("%s: => 0x%08x\n", __func__, retval);
return retval; return retval;
} }
@ -756,7 +765,8 @@ static void openpic_msi_write(void *opaque, hwaddr addr, uint64_t val,
int idx = opp->irq_msi; int idx = opp->irq_msi;
int srs, ibs; int srs, ibs;
DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); DPRINTF("%s: addr %#" HWADDR_PRIx " <= 0x%08" PRIx64 "\n",
__func__, addr, val);
if (addr & 0xF) { if (addr & 0xF) {
return; return;
} }
@ -781,7 +791,7 @@ static uint64_t openpic_msi_read(void *opaque, hwaddr addr, unsigned size)
uint64_t r = 0; uint64_t r = 0;
int i, srs; int i, srs;
DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); DPRINTF("%s: addr %#" HWADDR_PRIx "\n", __func__, addr);
if (addr & 0xF) { if (addr & 0xF) {
return -1; return -1;
} }
@ -819,7 +829,7 @@ static void openpic_cpu_write_internal(void *opaque, hwaddr addr,
IRQDest *dst; IRQDest *dst;
int s_IRQ, n_IRQ; int s_IRQ, n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx " <= %08x\n", __func__, idx, DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx " <= 0x%08x\n", __func__, idx,
addr, val); addr, val);
if (idx < 0) { if (idx < 0) {
@ -890,7 +900,7 @@ static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
uint32_t retval; uint32_t retval;
int n_IRQ; int n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr); DPRINTF("%s: cpu %d addr %#" HWADDR_PRIx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF; retval = 0xFFFFFFFF;
if (idx < 0) { if (idx < 0) {
@ -958,7 +968,7 @@ static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
default: default:
break; break;
} }
DPRINTF("%s: => %08x\n", __func__, retval); DPRINTF("%s: => 0x%08x\n", __func__, retval);
return retval; return retval;
} }