@@ -28,15 +28,17 @@
#include "net/net.h"
#include "net/checksum.h"
+//#define CADENCE_GEM_ERR_DEBUG
+
#ifdef CADENCE_GEM_ERR_DEBUG
-#define DB_PRINT(...) do { \
- fprintf(stderr, ": %s: ", __func__); \
- fprintf(stderr, ## __VA_ARGS__); \
- } while (0);
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 1
#else
- #define DB_PRINT(...)
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 0
#endif
+#define DB_PRINT(...) \
+ QEMU_DPRINTF(CADENCE_GEM_ERR_DEBUG_ENABLED, "cadence_gem", __VA_ARGS__)
+
#define GEM_NWCTRL (0x00000000/4) /* Network Control reg */
#define GEM_NWCFG (0x00000004/4) /* Network Config reg */
#define GEM_NWSTATUS (0x00000008/4) /* Network Status reg */
@@ -1195,7 +1197,9 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
break;
}
- DB_PRINT("newval: 0x%08x\n", s->regs[offset]);
+ if(CADENCE_GEM_ERR_DEBUG_ENABLED) {
+ fprintf(stderr, "newval: 0x%08x\n", s->regs[offset]);
+ }
}
static const MemoryRegionOps gem_ops = {
@@ -1208,13 +1212,17 @@ static void gem_cleanup(NetClientState *nc)
{
GemState *s = qemu_get_nic_opaque(nc);
- DB_PRINT("\n");
+ if(CADENCE_GEM_ERR_DEBUG_ENABLED) {
+ fprintf(stderr, "\n");
+ }
s->nic = NULL;
}
static void gem_set_link(NetClientState *nc)
{
- DB_PRINT("\n");
+ if(CADENCE_GEM_ERR_DEBUG_ENABLED) {
+ fprintf(stderr, "\n");
+ }
phy_update_link(qemu_get_nic_opaque(nc));
}
Modify debug macros to have the same format through the codebase and use regular ifs instead of ifdef. As QEMU_DPRINTF adds a header to the message, when the message is not in a new line, printf has to be used. Signed-off-by: Marc MarĂ <marc.mari.barcelo@gmail.com> --- hw/net/cadence_gem.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)