[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/12] hw/char/pl011: Check if receiver is enabled
|
From: |
Philippe Mathieu-Daudé |
|
Subject: |
[PATCH 10/12] hw/char/pl011: Check if receiver is enabled |
|
Date: |
Mon, 22 May 2023 17:31:42 +0200 |
Do not receive characters when UART or receiver are disabled.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/pl011.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 30bedeac15..1ec102d8de 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -77,6 +77,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev
*chr)
#define LCR_BRK (1 << 0)
/* Control Register, UARTCR */
+#define CR_RXE (1 << 9)
#define CR_TXE (1 << 8)
#define CR_UARTEN (1 << 0)
@@ -348,9 +349,11 @@ static void pl011_write(void *opaque, hwaddr offset,
static int pl011_can_receive(void *opaque)
{
PL011State *s = (PL011State *)opaque;
- int r;
+ int r = 0;
- r = s->read_count < pl011_get_fifo_depth(s);
+ if (s->cr & (CR_UARTEN | CR_RXE)) {
+ r = s->read_count < pl011_get_fifo_depth(s);
+ }
trace_pl011_can_receive(s->lcr, s->read_count, r);
return r;
}
--
2.38.1
- Re: [PATCH 07/12] hw/char/pl011: Split RX/TX path of pl011_reset_fifo(), (continued)
- [PATCH 09/12] hw/char/pl011: Check if transmitter is enabled, Philippe Mathieu-Daudé, 2023/05/22
- [PATCH 01/12] util/fifo8: Fix typo in fifo8_push_all() description, Philippe Mathieu-Daudé, 2023/05/22
- [PATCH 04/12] hw/char/pl011: Display register name in trace events, Philippe Mathieu-Daudé, 2023/05/22
- [PATCH 08/12] hw/char/pl011: Extract pl011_write_tx() from pl011_write(), Philippe Mathieu-Daudé, 2023/05/22
- [PATCH 10/12] hw/char/pl011: Check if receiver is enabled,
Philippe Mathieu-Daudé <=
- [PATCH 11/12] hw/char/pl011: Rename RX FIFO methods, Philippe Mathieu-Daudé, 2023/05/22
- [PATCH 12/12] hw/char/pl011: Implement TX FIFO, Philippe Mathieu-Daudé, 2023/05/22