aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:52 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:20 +0200
commit32a6ebecd2ffe82ffade5edf9e054e20cb48f281 (patch)
treeb1e82e3f6eb4a28c65098015dd8114e190a064bf /hw
parentbecdfa00cfa2995e859ccefa4b7d72a72eb96581 (diff)
char: remaining switch to CharBackend in frontend
Similar to previous change, for the remaining CharDriverState front ends users. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-13-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/omap2.c11
-rw-r--r--hw/char/mcf_uart.c12
-rw-r--r--hw/char/sh_serial.c10
-rw-r--r--hw/char/xen_console.c39
-rw-r--r--hw/mips/mips_malta.c32
5 files changed, 59 insertions, 45 deletions
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 0b2a355f04..43d9c4b1f0 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -621,7 +621,7 @@ struct omap_sti_s {
qemu_irq irq;
MemoryRegion iomem;
MemoryRegion iomem_fifo;
- CharDriverState *chr;
+ CharBackend chr;
uint32_t sysconfig;
uint32_t systest;
@@ -771,14 +771,14 @@ static void omap_sti_fifo_write(void *opaque, hwaddr addr,
/* Flush channel <i>value</i>. */
/* XXX this blocks entire thread. Rewrite to use
* qemu_chr_fe_write and background I/O callbacks */
- qemu_chr_fe_write_all(s->chr, (const uint8_t *) "\r", 1);
+ qemu_chr_fe_write_all(s->chr.chr, (const uint8_t *) "\r", 1);
} else if (ch == STI_TRACE_CONSOLE_CHANNEL || 1) {
if (value == 0xc0 || value == 0xc3) {
/* Open channel <i>ch</i>. */
} else if (value == 0x00)
- qemu_chr_fe_write_all(s->chr, (const uint8_t *) "\n", 1);
+ qemu_chr_fe_write_all(s->chr.chr, (const uint8_t *) "\n", 1);
else
- qemu_chr_fe_write_all(s->chr, &byte, 1);
+ qemu_chr_fe_write_all(s->chr.chr, &byte, 1);
}
}
@@ -798,7 +798,8 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
s->irq = irq;
omap_sti_reset(s);
- s->chr = chr ?: qemu_chr_new("null", "null");
+ qemu_chr_fe_init(&s->chr, chr ?: qemu_chr_new("null", "null"),
+ &error_abort);
memory_region_init_io(&s->iomem, NULL, &omap_sti_ops, s, "omap.sti",
omap_l4_region_size(ta, 0));
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);
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index ed0850c70c..d5601b18cb 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -85,7 +85,7 @@ typedef struct {
uint32_t i2coe;
uint32_t i2cout;
uint32_t i2csel;
- CharDriverState *display;
+ CharBackend display;
char display_text[9];
SerialState *uart;
bool display_inited;
@@ -125,8 +125,10 @@ static void malta_fpga_update_display(void *opaque)
}
leds_text[8] = '\0';
- qemu_chr_fe_printf(s->display, "\e[H\n\n|\e[32m%-8.8s\e[00m|\r\n", leds_text);
- qemu_chr_fe_printf(s->display, "\n\n\n\n|\e[31m%-8.8s\e[00m|", s->display_text);
+ qemu_chr_fe_printf(s->display.chr, "\e[H\n\n|\e[32m%-8.8s\e[00m|\r\n",
+ leds_text);
+ qemu_chr_fe_printf(s->display.chr, "\n\n\n\n|\e[31m%-8.8s\e[00m|",
+ s->display_text);
}
/*
@@ -536,15 +538,15 @@ static void malta_fgpa_display_event(void *opaque, int event)
MaltaFPGAState *s = opaque;
if (event == CHR_EVENT_OPENED && !s->display_inited) {
- qemu_chr_fe_printf(s->display, "\e[HMalta LEDBAR\r\n");
- qemu_chr_fe_printf(s->display, "+--------+\r\n");
- qemu_chr_fe_printf(s->display, "+ +\r\n");
- qemu_chr_fe_printf(s->display, "+--------+\r\n");
- qemu_chr_fe_printf(s->display, "\n");
- qemu_chr_fe_printf(s->display, "Malta ASCII\r\n");
- qemu_chr_fe_printf(s->display, "+--------+\r\n");
- qemu_chr_fe_printf(s->display, "+ +\r\n");
- qemu_chr_fe_printf(s->display, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display.chr, "\e[HMalta LEDBAR\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+ +\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display.chr, "\n");
+ qemu_chr_fe_printf(s->display.chr, "Malta ASCII\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+ +\r\n");
+ qemu_chr_fe_printf(s->display.chr, "+--------+\r\n");
s->display_inited = true;
}
}
@@ -553,6 +555,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
hwaddr base, qemu_irq uart_irq, CharDriverState *uart_chr)
{
MaltaFPGAState *s;
+ CharDriverState *chr;
s = (MaltaFPGAState *)g_malloc0(sizeof(MaltaFPGAState));
@@ -566,8 +569,9 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
memory_region_add_subregion(address_space, base, &s->iomem_lo);
memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi);
- s->display = qemu_chr_new("fpga", "vc:320x200");
- qemu_chr_add_handlers(s->display, NULL, NULL,
+ chr = qemu_chr_new("fpga", "vc:320x200");
+ qemu_chr_fe_init(&s->display, chr, &error_abort);
+ qemu_chr_add_handlers(s->display.chr, NULL, NULL,
malta_fgpa_display_event, s);
s->uart = serial_mm_init(address_space, base + 0x900, 3, uart_irq,