44 lines
1.6 KiB
Diff
44 lines
1.6 KiB
Diff
|
|
From 8733b8a26407177b867d3293283c257efeb784a0 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Fri, 1 Dec 2023 12:51:56 +0800
|
||
|
|
Subject: [PATCH] Fix STM32F2XX USART data register readout
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
cherry picked from commit ab08c3467605365b44fab1b66bb6254db86814f6
|
||
|
|
|
||
|
|
Fix issue where the data register may be overwritten by next character
|
||
|
|
reception before being read and returned.
|
||
|
|
|
||
|
|
Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr>
|
||
|
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||
|
|
Message-id: 20211128120723.4053-1-olivier.heriveaux@ledger.fr
|
||
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/char/stm32f2xx_usart.c | 3 ++-
|
||
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
|
||
|
|
index 8df0832424..fde67f4f03 100644
|
||
|
|
--- a/hw/char/stm32f2xx_usart.c
|
||
|
|
+++ b/hw/char/stm32f2xx_usart.c
|
||
|
|
@@ -103,10 +103,11 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr,
|
||
|
|
return retvalue;
|
||
|
|
case USART_DR:
|
||
|
|
DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr);
|
||
|
|
+ retvalue = s->usart_dr & 0x3FF;
|
||
|
|
s->usart_sr &= ~USART_SR_RXNE;
|
||
|
|
qemu_chr_fe_accept_input(&s->chr);
|
||
|
|
qemu_set_irq(s->irq, 0);
|
||
|
|
- return s->usart_dr & 0x3FF;
|
||
|
|
+ return retvalue;
|
||
|
|
case USART_BRR:
|
||
|
|
return s->usart_brr;
|
||
|
|
case USART_CR1:
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|