summaryrefslogtreecommitdiff
path: root/hw/char/serial.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-06-20 15:08:20 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-29 14:03:47 +0200
commitb0585e7e07982daa578c3bfef7f6843c89f110a8 (patch)
tree2904bbe8bb7696550ea117d897b2462b27bb01be /hw/char/serial.c
parentbce933b85a34514fe34fa559be1d8ccd1f39f954 (diff)
downloadqemu-b0585e7e07982daa578c3bfef7f6843c89f110a8.tar.gz
serial: separate serial_xmit and serial_watch_cb
serial_xmit starts transmission of whatever is in the transmitter register, THR or FIFO; serial_watch_cb is a wrapper around it and is only used as a qemu_chr_fe_add_watch callback. Tested-by: Bret Ketchum <bcketchum@gmail.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/char/serial.c')
-rw-r--r--hw/char/serial.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 904b218c21..0b09094c0c 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -106,6 +106,7 @@ do {} while (0)
#endif
static void serial_receive1(void *opaque, const uint8_t *buf, int size);
+static void serial_xmit(SerialState *s);
static inline void recv_fifo_put(SerialState *s, uint8_t chr)
{
@@ -223,10 +224,16 @@ static void serial_update_msl(SerialState *s)
}
}
-static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
+static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
+ void *opaque)
{
SerialState *s = opaque;
+ serial_xmit(s);
+ return FALSE;
+}
+static void serial_xmit(SerialState *s)
+{
do {
assert(!(s->lsr & UART_LSR_TEMT));
if (s->tsr_retry == 0) {
@@ -254,9 +261,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if (s->tsr_retry < MAX_XMIT_RETRY &&
qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
- serial_xmit, s) > 0) {
+ serial_watch_cb, s) > 0) {
s->tsr_retry++;
- return FALSE;
+ return;
}
}
s->tsr_retry = 0;
@@ -267,11 +274,8 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
s->last_xmit_ts = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
s->lsr |= UART_LSR_TEMT;
-
- return FALSE;
}
-
/* Setter for FCR.
is_load flag means, that value is set while loading VM state
and interrupt should not be invoked */
@@ -329,7 +333,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
s->lsr &= ~UART_LSR_TEMT;
serial_update_irq(s);
if (s->tsr_retry == 0) {
- serial_xmit(NULL, G_IO_OUT, s);
+ serial_xmit(s);
}
}
break;