aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEvgeny Iakovlev <eiakovlev@linux.microsoft.com>2023-01-23 17:23:00 +0100
committerPeter Maydell <peter.maydell@linaro.org>2023-02-03 12:59:21 +0000
commit9d88935cb19f8f8e7291026efe23862316ff2510 (patch)
tree1d671537bcf7b132f8f0d0ea71881b16b0c51871 /include
parent9d2617ac7d3139d870ba14204aedd74395990192 (diff)
downloadqemu-9d88935cb19f8f8e7291026efe23862316ff2510.zip
qemu-9d88935cb19f8f8e7291026efe23862316ff2510.tar.gz
qemu-9d88935cb19f8f8e7291026efe23862316ff2510.tar.bz2
hw/char/pl011: refactor FIFO depth handling code
PL011 can be in either of 2 modes depending guest config: FIFO and single register. The last mode could be viewed as a 1-element-deep FIFO. Current code open-codes a bunch of depth-dependent logic. Refactor FIFO depth handling code to isolate calculating current FIFO depth. One functional (albeit guest-invisible) side-effect of this change is that previously we would always increment s->read_pos in UARTDR read handler even if FIFO was disabled, now we are limiting read_pos to not exceed FIFO depth (read_pos itself is reset to 0 if user disables FIFO). Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20230123162304.26254-2-eiakovlev@linux.microsoft.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/hw/char/pl011.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h
index dc2c90e..926322e 100644
--- a/include/hw/char/pl011.h
+++ b/include/hw/char/pl011.h
@@ -27,6 +27,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(PL011State, PL011)
/* This shares the same struct (and cast macro) as the base pl011 device */
#define TYPE_PL011_LUMINARY "pl011_luminary"
+/* Depth of UART FIFO in bytes, when FIFO mode is enabled (else depth == 1) */
+#define PL011_FIFO_DEPTH 16
+
struct PL011State {
SysBusDevice parent_obj;
@@ -39,7 +42,7 @@ struct PL011State {
uint32_t dmacr;
uint32_t int_enabled;
uint32_t int_level;
- uint32_t read_fifo[16];
+ uint32_t read_fifo[PL011_FIFO_DEPTH];
uint32_t ilpr;
uint32_t ibrd;
uint32_t fbrd;