[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/8] i.MX: Standardize i.MX serial debug.
From: |
Jean-Christophe Dubois |
Subject: |
[Qemu-devel] [PATCH 1/8] i.MX: Standardize i.MX serial debug. |
Date: |
Tue, 20 Oct 2015 23:19:38 +0200 |
The goal is to have debug code always compiled during build.
Signed-off-by: Jean-Christophe Dubois <address@hidden>
---
hw/char/imx_serial.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index f0c4c72..08274e0 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -22,25 +22,17 @@
#include "sysemu/sysemu.h"
#include "sysemu/char.h"
-//#define DEBUG_SERIAL 1
-#ifdef DEBUG_SERIAL
-#define DPRINTF(fmt, args...) \
-do { printf("%s: " fmt , TYPE_IMX_SERIAL, ##args); } while (0)
-#else
-#define DPRINTF(fmt, args...) do {} while (0)
+#ifndef DEBUG_IMX_UART
+#define DEBUG_IMX_UART 0
#endif
-/*
- * Define to 1 for messages about attempts to
- * access unimplemented registers or similar.
- */
-//#define DEBUG_IMPLEMENTATION 1
-#ifdef DEBUG_IMPLEMENTATION
-# define IPRINTF(fmt, args...) \
- do { fprintf(stderr, "%s: " fmt, TYPE_IMX_SERIAL, ##args); } while (0)
-#else
-# define IPRINTF(fmt, args...) do {} while (0)
-#endif
+#define DPRINTF(fmt, args...) \
+ do { \
+ if (DEBUG_IMX_UART) { \
+ fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_SERIAL, \
+ __func__, ##args); \
+ } \
+ } while (0)
static const VMStateDescription vmstate_imx_serial = {
.name = TYPE_IMX_SERIAL,
@@ -115,7 +107,7 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
IMXSerialState *s = (IMXSerialState *)opaque;
uint32_t c;
- DPRINTF("read(offset=%x)\n", offset >> 2);
+ DPRINTF("read(offset=%x)\n", (int)(offset >> 2));
switch (offset >> 2) {
case 0x0: /* URXD */
c = s->readbuff;
@@ -167,7 +159,8 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
return 0x0; /* TODO */
default:
- IPRINTF("%s: bad offset: 0x%x\n", __func__, (int)offset);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
+ TYPE_IMX_SERIAL, __func__, (int)offset);
return 0;
}
}
@@ -179,7 +172,7 @@ static void imx_serial_write(void *opaque, hwaddr offset,
unsigned char ch;
DPRINTF("write(offset=%x, value = %x) to %s\n",
- offset >> 2,
+ (int)(offset >> 2),
(unsigned int)value, s->chr ? s->chr->label : "NODEV");
switch (offset >> 2) {
@@ -266,12 +259,14 @@ static void imx_serial_write(void *opaque, hwaddr offset,
case 0x2d: /* UTS1 */
case 0x23: /* UCR4 */
- IPRINTF("Unimplemented Register %x written to\n", offset >> 2);
+ qemu_log_mask(LOG_UNIMP, "%s[%s]: Unimplemented reg %d\n",
+ TYPE_IMX_SERIAL, __func__, (int)(offset >> 2));
/* TODO */
break;
default:
- IPRINTF("%s: Bad offset 0x%x\n", __func__, (int)offset);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
+ TYPE_IMX_SERIAL, __func__, (int)offset);
}
}
--
2.1.4
- [Qemu-devel] [PATCH 0/8] i.MX: Standardize debug code, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 1/8] i.MX: Standardize i.MX serial debug.,
Jean-Christophe Dubois <=
- [Qemu-devel] [PATCH 2/8] i.MX: Standardize i.MX GPIO debug, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 3/8] i.MX: Standardize i.MX I2C debug, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 4/8] i.MX: Standardize i.MX AVIC debug, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 5/8] i.MX: Standardize i.MX CCM debug, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 7/8] i.MX: Standardize i.MX EPIT debug, Jean-Christophe Dubois, 2015/10/20
- [Qemu-devel] [PATCH 8/8] i.MX: Standardize i.MX GPT debug, Jean-Christophe Dubois, 2015/10/20