hw/timer/nrf51_timer: Display timer ID in trace events

The NRF51 series SoC have 3 timer peripherals, each having
4 counters. To help differentiate which peripheral is accessed,
display the timer ID in the trace events.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20200504072822.18799-4-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2020-05-04 09:28:21 +02:00 committed by Peter Maydell
parent 54595a5731
commit 27d6dea3d7
4 changed files with 17 additions and 4 deletions

View File

@ -150,6 +150,11 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
/* TIMER */ /* TIMER */
for (i = 0; i < NRF51_NUM_TIMERS; i++) { for (i = 0; i < NRF51_NUM_TIMERS; i++) {
object_property_set_uint(OBJECT(&s->timer[i]), i, "id", &err);
if (err) {
error_propagate(errp, err);
return;
}
object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err); object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
if (err) { if (err) {
error_propagate(errp, err); error_propagate(errp, err);

View File

@ -17,6 +17,7 @@
#include "hw/arm/nrf51.h" #include "hw/arm/nrf51.h"
#include "hw/irq.h" #include "hw/irq.h"
#include "hw/timer/nrf51_timer.h" #include "hw/timer/nrf51_timer.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h" #include "migration/vmstate.h"
#include "trace.h" #include "trace.h"
@ -185,7 +186,7 @@ static uint64_t nrf51_timer_read(void *opaque, hwaddr offset, unsigned int size)
__func__, offset); __func__, offset);
} }
trace_nrf51_timer_read(offset, r, size); trace_nrf51_timer_read(s->id, offset, r, size);
return r; return r;
} }
@ -197,7 +198,7 @@ static void nrf51_timer_write(void *opaque, hwaddr offset,
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
size_t idx; size_t idx;
trace_nrf51_timer_write(offset, value, size); trace_nrf51_timer_write(s->id, offset, value, size);
switch (offset) { switch (offset) {
case NRF51_TIMER_TASK_START: case NRF51_TIMER_TASK_START:
@ -372,12 +373,18 @@ static const VMStateDescription vmstate_nrf51_timer = {
} }
}; };
static Property nrf51_timer_properties[] = {
DEFINE_PROP_UINT8("id", NRF51TimerState, id, 0),
DEFINE_PROP_END_OF_LIST(),
};
static void nrf51_timer_class_init(ObjectClass *klass, void *data) static void nrf51_timer_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
dc->reset = nrf51_timer_reset; dc->reset = nrf51_timer_reset;
dc->vmsd = &vmstate_nrf51_timer; dc->vmsd = &vmstate_nrf51_timer;
device_class_set_props(dc, nrf51_timer_properties);
} }
static const TypeInfo nrf51_timer_info = { static const TypeInfo nrf51_timer_info = {

View File

@ -67,8 +67,8 @@ cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK
cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
# nrf51_timer.c # nrf51_timer.c
nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" nrf51_timer_read(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
# bcm2835_systmr.c # bcm2835_systmr.c
bcm2835_systmr_irq(bool enable) "timer irq state %u" bcm2835_systmr_irq(bool enable) "timer irq state %u"

View File

@ -59,6 +59,7 @@ typedef struct NRF51TimerState {
MemoryRegion iomem; MemoryRegion iomem;
qemu_irq irq; qemu_irq irq;
uint8_t id;
QEMUTimer timer; QEMUTimer timer;
int64_t timer_start_ns; int64_t timer_start_ns;
int64_t update_counter_ns; int64_t update_counter_ns;