diff options
Diffstat (limited to 'hw/char')
-rw-r--r-- | hw/char/mcf_uart.c | 12 | ||||
-rw-r--r-- | hw/char/sh_serial.c | 10 | ||||
-rw-r--r-- | hw/char/xen_console.c | 39 |
3 files changed, 35 insertions, 26 deletions
diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index c184859c83..436e1b0228 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -10,6 +10,7 @@ #include "hw/m68k/mcf.h" #include "sysemu/char.h" #include "exec/address-spaces.h" +#include "qapi/error.h" typedef struct { MemoryRegion iomem; @@ -26,7 +27,7 @@ typedef struct { int tx_enabled; int rx_enabled; qemu_irq irq; - CharDriverState *chr; + CharBackend chr; } mcf_uart_state; /* UART Status Register bits. */ @@ -92,7 +93,7 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr, if (s->fifo_len == 0) s->sr &= ~MCF_UART_RxRDY; mcf_uart_update(s); - qemu_chr_accept_input(s->chr); + qemu_chr_accept_input(s->chr.chr); return val; } case 0x10: @@ -113,10 +114,11 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr, static void mcf_uart_do_tx(mcf_uart_state *s) { if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) == 0) { - if (s->chr) + if (s->chr.chr) { /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(s->chr, (unsigned char *)&s->tb, 1); + qemu_chr_fe_write_all(s->chr.chr, (unsigned char *)&s->tb, 1); + } s->sr |= MCF_UART_TxEMP; } if (s->tx_enabled) { @@ -280,9 +282,9 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr) mcf_uart_state *s; s = g_malloc0(sizeof(mcf_uart_state)); - s->chr = chr; s->irq = irq; if (chr) { + qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_claim_no_fail(chr); qemu_chr_add_handlers(chr, mcf_uart_can_receive, mcf_uart_receive, mcf_uart_event, s); diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 97ce5629a4..c8b91bbaa2 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -29,6 +29,7 @@ #include "hw/sh4/sh.h" #include "sysemu/char.h" #include "exec/address-spaces.h" +#include "qapi/error.h" //#define DEBUG_SERIAL @@ -62,7 +63,7 @@ typedef struct { int flags; int rtrg; - CharDriverState *chr; + CharBackend chr; qemu_irq eri; qemu_irq rxi; @@ -109,11 +110,11 @@ static void sh_serial_write(void *opaque, hwaddr offs, } return; case 0x0c: /* FTDR / TDR */ - if (s->chr) { + if (s->chr.chr) { ch = val; /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(s->chr, &ch, 1); + qemu_chr_fe_write_all(s->chr.chr, &ch, 1); } s->dr = val; s->flags &= ~SH_SERIAL_FLAG_TDE; @@ -395,10 +396,9 @@ void sh_serial_init(MemoryRegion *sysmem, 0, 0x28); memory_region_add_subregion(sysmem, A7ADDR(base), &s->iomem_a7); - s->chr = chr; - if (chr) { qemu_chr_fe_claim_no_fail(chr); + qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_add_handlers(chr, sh_serial_can_receive1, sh_serial_receive1, sh_serial_event, s); } diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 11bf6a44cf..c1d36dc2d0 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -26,6 +26,7 @@ #include "hw/hw.h" #include "sysemu/char.h" #include "hw/xen/xen_backend.h" +#include "qapi/error.h" #include <xen/io/console.h> @@ -43,7 +44,7 @@ struct XenConsole { char console[XEN_BUFSIZE]; int ring_ref; void *sring; - CharDriverState *chr; + CharBackend chr; int backlog; }; @@ -148,11 +149,13 @@ static void xencons_send(struct XenConsole *con) ssize_t len, size; size = con->buffer.size - con->buffer.consumed; - if (con->chr) - len = qemu_chr_fe_write(con->chr, con->buffer.data + con->buffer.consumed, - size); - else + if (con->chr.chr) { + len = qemu_chr_fe_write(con->chr.chr, + con->buffer.data + con->buffer.consumed, + size); + } else { len = size; + } if (len < 1) { if (!con->backlog) { con->backlog = 1; @@ -196,13 +199,17 @@ static int con_init(struct XenDevice *xendev) /* no Xen override, use qemu output device */ if (output == NULL) { - con->chr = serial_hds[con->xendev.dev]; + if (con->xendev.dev) { + qemu_chr_fe_init(&con->chr, serial_hds[con->xendev.dev], + &error_abort); + } } else { snprintf(label, sizeof(label), "xencons%d", con->xendev.dev); - con->chr = qemu_chr_new(label, output); + qemu_chr_fe_init(&con->chr, + qemu_chr_new(label, output), &error_abort); } - xenstore_store_pv_console_info(con->xendev.dev, con->chr); + xenstore_store_pv_console_info(con->xendev.dev, con->chr.chr); out: g_free(type); @@ -235,15 +242,15 @@ static int con_initialise(struct XenDevice *xendev) return -1; xen_be_bind_evtchn(&con->xendev); - if (con->chr) { - if (qemu_chr_fe_claim(con->chr) == 0) { - qemu_chr_add_handlers(con->chr, xencons_can_receive, + if (con->chr.chr) { + if (qemu_chr_fe_claim(con->chr.chr) == 0) { + qemu_chr_add_handlers(con->chr.chr, xencons_can_receive, xencons_receive, NULL, con); } else { xen_be_printf(xendev, 0, "xen_console_init error chardev %s already used\n", - con->chr->label); - con->chr = NULL; + con->chr.chr->label); + con->chr.chr = NULL; } } @@ -259,9 +266,9 @@ static void con_disconnect(struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); - if (con->chr) { - qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL); - qemu_chr_fe_release(con->chr); + if (con->chr.chr) { + qemu_chr_add_handlers(con->chr.chr, NULL, NULL, NULL, NULL); + qemu_chr_fe_release(con->chr.chr); } xen_be_unbind_evtchn(&con->xendev); |