Implement pl011_xmit_cb() using the FEWatchFunc prototype to register it as GSource. While the return value is not yet used, we return G_SOURCE_REMOVE, meaning the GSource is removed from the main loop (because we only send one char).
Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- hw/char/pl011.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 113b29cd9e6..18ea03a52f4 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -226,8 +226,9 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) pl011_fifo_rx_put(s, value); } -static void pl011_xmit(PL011State *s) +static gboolean pl011_xmit_cb(void *do_not_use, GIOCondition cond, void *opaque) { + PL011State *s = opaque; int bytes_consumed; uint8_t buf[PL011_FIFO_DEPTH]; uint32_t count; @@ -254,6 +255,13 @@ static void pl011_xmit(PL011State *s) } pl011_update(s); + + return G_SOURCE_REMOVE; +} + +static void pl011_xmit(PL011State *s) +{ + (void)pl011_xmit_cb(NULL, G_IO_OUT, s); } static void pl011_write_txdata(PL011State *s, uint8_t data) @@ -630,6 +638,11 @@ static int pl011_post_load(void *opaque, int version_id) s->read_pos = 0; } + if (!fifo8_is_empty(&s->xmit_fifo)) { + /* Reschedule another transmission */ + qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, pl011_xmit_cb, s); + } + s->ibrd &= IBRD_MASK; s->fbrd &= FBRD_MASK; -- 2.47.1