Message ID | 20250219210841.94797-2-philmd@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | hw/char: Improve RX FIFO depth uses | expand |
Hi Phil, On 22:08 Wed 19 Feb , Philippe Mathieu-Daudé wrote: > We shouldn't receive characters when the full UART or its > receiver is disabled. However we don't want to break the > possibly incomplete "my first bare metal assembly program"s, > so we choose to simply display a warning when this occurs. > > Reviewed-by: Richard Henderson <richard.henderson@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/char/pl011.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/hw/char/pl011.c b/hw/char/pl011.c > index 06ce851044d..60cea1d9a16 100644 > --- a/hw/char/pl011.c > +++ b/hw/char/pl011.c > @@ -85,6 +85,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) > #define CR_OUT1 (1 << 12) > #define CR_RTS (1 << 11) > #define CR_DTR (1 << 10) > +#define CR_RXE (1 << 9) > #define CR_TXE (1 << 8) > #define CR_LBE (1 << 7) > #define CR_UARTEN (1 << 0) > @@ -487,6 +488,12 @@ static int pl011_can_receive(void *opaque) > PL011State *s = (PL011State *)opaque; > int r; > > + if (!(s->cr & CR_UARTEN)) { > + qemu_log_mask(LOG_GUEST_ERROR, "PL011 reading data on disabled UART\n"); I find "reading" a bit misleading here. The guest is not reading the data at this time. The chardev backend is trying to push data it received to the device model. I'd use "receiving" instead. > + } > + if (!(s->cr & CR_RXE)) { > + qemu_log_mask(LOG_GUEST_ERROR, "PL011 reading data on disabled TX UART\n"); s/TX/RX Thanks, Luc > + } > r = s->read_count < pl011_get_fifo_depth(s); > trace_pl011_can_receive(s->lcr, s->read_count, r); > return r; > -- > 2.47.1 > --
diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 06ce851044d..60cea1d9a16 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -85,6 +85,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_OUT1 (1 << 12) #define CR_RTS (1 << 11) #define CR_DTR (1 << 10) +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_LBE (1 << 7) #define CR_UARTEN (1 << 0) @@ -487,6 +488,12 @@ static int pl011_can_receive(void *opaque) PL011State *s = (PL011State *)opaque; int r; + if (!(s->cr & CR_UARTEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 reading data on disabled UART\n"); + } + if (!(s->cr & CR_RXE)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 reading data on disabled TX UART\n"); + } r = s->read_count < pl011_get_fifo_depth(s); trace_pl011_can_receive(s->lcr, s->read_count, r); return r;