Skip to content

Commit d25202f

Browse files
Nikita Shubinphilmd
authored andcommitted
hw/char/stm32f2xx_usart: replace print with trace
Drop debug printing macros and replace them with according trace functions. Signed-off-by: Nikita Shubin <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent 14b1086 commit d25202f

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

hw/char/stm32f2xx_usart.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,7 @@
3030
#include "qemu/log.h"
3131
#include "qemu/module.h"
3232

33-
#ifndef STM_USART_ERR_DEBUG
34-
#define STM_USART_ERR_DEBUG 0
35-
#endif
36-
37-
#define DB_PRINT_L(lvl, fmt, args...) do { \
38-
if (STM_USART_ERR_DEBUG >= lvl) { \
39-
qemu_log("%s: " fmt, __func__, ## args); \
40-
} \
41-
} while (0)
42-
43-
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
33+
#include "trace.h"
4434

4535
static int stm32f2xx_usart_can_receive(void *opaque)
4636
{
@@ -67,10 +57,11 @@ static void stm32f2xx_update_irq(STM32F2XXUsartState *s)
6757
static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
6858
{
6959
STM32F2XXUsartState *s = opaque;
60+
DeviceState *d = DEVICE(s);
7061

7162
if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) {
7263
/* USART not enabled - drop the chars */
73-
DB_PRINT("Dropping the chars\n");
64+
trace_stm32f2xx_usart_drop(d->id);
7465
return;
7566
}
7667

@@ -79,7 +70,7 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
7970

8071
stm32f2xx_update_irq(s);
8172

82-
DB_PRINT("Receiving: %c\n", s->usart_dr);
73+
trace_stm32f2xx_usart_receive(d->id, *buf);
8374
}
8475

8576
static void stm32f2xx_usart_reset(DeviceState *dev)
@@ -101,49 +92,55 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr,
10192
unsigned int size)
10293
{
10394
STM32F2XXUsartState *s = opaque;
104-
uint64_t retvalue;
105-
106-
DB_PRINT("Read 0x%"HWADDR_PRIx"\n", addr);
95+
DeviceState *d = DEVICE(s);
96+
uint64_t retvalue = 0;
10797

10898
switch (addr) {
10999
case USART_SR:
110100
retvalue = s->usart_sr;
111101
qemu_chr_fe_accept_input(&s->chr);
112-
return retvalue;
102+
break;
113103
case USART_DR:
114-
DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr);
115104
retvalue = s->usart_dr & 0x3FF;
116105
s->usart_sr &= ~USART_SR_RXNE;
117106
qemu_chr_fe_accept_input(&s->chr);
118107
stm32f2xx_update_irq(s);
119-
return retvalue;
108+
break;
120109
case USART_BRR:
121-
return s->usart_brr;
110+
retvalue = s->usart_brr;
111+
break;
122112
case USART_CR1:
123-
return s->usart_cr1;
113+
retvalue = s->usart_cr1;
114+
break;
124115
case USART_CR2:
125-
return s->usart_cr2;
116+
retvalue = s->usart_cr2;
117+
break;
126118
case USART_CR3:
127-
return s->usart_cr3;
119+
retvalue = s->usart_cr3;
120+
break;
128121
case USART_GTPR:
129-
return s->usart_gtpr;
122+
retvalue = s->usart_gtpr;
123+
break;
130124
default:
131125
qemu_log_mask(LOG_GUEST_ERROR,
132126
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
133127
return 0;
134128
}
135129

136-
return 0;
130+
trace_stm32f2xx_usart_read(d->id, size, addr, retvalue);
131+
132+
return retvalue;
137133
}
138134

139135
static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
140136
uint64_t val64, unsigned int size)
141137
{
142138
STM32F2XXUsartState *s = opaque;
139+
DeviceState *d = DEVICE(s);
143140
uint32_t value = val64;
144141
unsigned char ch;
145142

146-
DB_PRINT("Write 0x%" PRIx32 ", 0x%"HWADDR_PRIx"\n", value, addr);
143+
trace_stm32f2xx_usart_write(d->id, size, addr, val64);
147144

148145
switch (addr) {
149146
case USART_SR:

hw/char/trace-events

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,9 @@ xen_console_unrealize(unsigned int idx) "idx %u"
125125
xen_console_realize(unsigned int idx, const char *chrdev) "idx %u chrdev %s"
126126
xen_console_device_create(unsigned int idx) "idx %u"
127127
xen_console_device_destroy(unsigned int idx) "idx %u"
128+
129+
# stm32f2xx_usart.c
130+
stm32f2xx_usart_read(char *id, unsigned size, uint64_t ofs, uint64_t val) " %s size %d ofs 0x%02" PRIx64 " -> 0x%02" PRIx64
131+
stm32f2xx_usart_write(char *id, unsigned size, uint64_t ofs, uint64_t val) "%s size %d ofs 0x%02" PRIx64 " <- 0x%02" PRIx64
132+
stm32f2xx_usart_drop(char *id) " %s dropping the chars"
133+
stm32f2xx_usart_receive(char *id, uint8_t chr) " %s receiving '%c'"

0 commit comments

Comments
 (0)