hw/char/pl011: refactor FIFO depth handling code
authorEvgeny Iakovlev <eiakovlev@linux.microsoft.com>
Mon, 23 Jan 2023 16:23:00 +0000 (17:23 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 3 Feb 2023 12:59:21 +0000 (12:59 +0000)
commit9d88935cb19f8f8e7291026efe23862316ff2510
tree1d671537bcf7b132f8f0d0ea71881b16b0c51871
parent9d2617ac7d3139d870ba14204aedd74395990192
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>
hw/char/pl011.c
include/hw/char/pl011.h