[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH qemu v3 09/20] Fixing the basic functionality of STM32 timers
From: |
~lbryndza |
Subject: |
[PATCH qemu v3 09/20] Fixing the basic functionality of STM32 timers |
Date: |
Sat, 02 Dec 2023 13:18:17 +0100 |
From: Lucjan Bryndza <lbryndza.oss@icloud.com>
The current implementation of timers does not work properly
even in basic functionality. A counter configured to report
an interrupt every 10ms reports the first interrupts after a
few seconds. There are also no properly implemented count up an
count down modes. This commit fixes bugs with interrupt
reporting and implements the basic modes of the counter's
time-base block.
Timer read function modified
Signed-off-by: Lucjan Bryndza <lbryndza.oss@icloud.com>
---
hw/timer/stm32f2xx_timer.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c
index 20ca762601..07d82b841a 100644
--- a/hw/timer/stm32f2xx_timer.c
+++ b/hw/timer/stm32f2xx_timer.c
@@ -159,15 +159,18 @@ static uint64_t stm32f2xx_timer_read(void *opaque, hwaddr
offset,
case TIM_CR1:
return s->tim_cr1;
case TIM_CR2:
- return s->tim_cr2;
+ qemu_log_mask(LOG_GUEST_ERROR, "stm32_timer: CR2 not supported");
+ return 0;
case TIM_SMCR:
- return s->tim_smcr;
+ qemu_log_mask(LOG_GUEST_ERROR, "stm32_timer: SMCR not supported");
+ return 0;
case TIM_DIER:
return s->tim_dier;
case TIM_SR:
return s->tim_sr;
case TIM_EGR:
- return s->tim_egr;
+ qemu_log_mask(LOG_GUEST_ERROR, "stm32_timer: EGR write only");
+ return 0;
case TIM_CCMR1:
return s->tim_ccmr1;
case TIM_CCMR2:
@@ -175,8 +178,7 @@ static uint64_t stm32f2xx_timer_read(void *opaque, hwaddr
offset,
case TIM_CCER:
return s->tim_ccer;
case TIM_CNT:
- return stm32f2xx_ns_to_ticks(s, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL))
-
- s->tick_offset;
+ return stm32f2xx_timer_get_count(s);
case TIM_PSC:
return s->tim_psc;
case TIM_ARR:
@@ -190,16 +192,17 @@ static uint64_t stm32f2xx_timer_read(void *opaque, hwaddr
offset,
case TIM_CCR4:
return s->tim_ccr4;
case TIM_DCR:
- return s->tim_dcr;
+ qemu_log_mask(LOG_GUEST_ERROR, "stm32_timer: DCR not supported");
+ return 0;
case TIM_DMAR:
- return s->tim_dmar;
+ qemu_log_mask(LOG_GUEST_ERROR, "stm32_timer: CR2 not supported");
+ return 0;
case TIM_OR:
return s->tim_or;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, offset);
}
-
return 0;
}
--
2.38.5
- [PATCH qemu v3 03/20] Fixing the basic functionality of STM32 timers, (continued)
- [PATCH qemu v3 03/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 01/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 06/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 07/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 10/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 08/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 11/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 17/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 14/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 13/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 09/20] Fixing the basic functionality of STM32 timers,
~lbryndza <=
- [PATCH qemu v3 16/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 19/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 18/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 20/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 15/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- Re: [PATCH qemu v3 00/20] Fix malfunctioning of T2-T5 timers on the STM32 platform, Alistair Francis, 2023/12/05