|
|
b6dd5a |
From 58011a6f6c7c284f6532486f819b5895be9b76c7 Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
d4cdad |
From: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
Date: Mon, 21 Mar 2011 20:31:45 +0100
|
|
|
b6dd5a |
Subject: [PATCH] char: Add a QemuChrHandlers struct to initialise chardev
|
|
|
b6dd5a |
handlers
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
Instead of passing each handler in the qemu_add_handlers() function,
|
|
Justin M. Forbes |
d4cdad |
create a struct of handlers that can be passed to the function instead.
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
---
|
|
|
b6dd5a |
gdbstub.c | 9 +++++++--
|
|
|
b6dd5a |
hw/cadence_uart.c | 9 +++++++--
|
|
|
b6dd5a |
hw/ccid-card-passthru.c | 11 +++++++----
|
|
|
b6dd5a |
hw/debugcon.c | 2 +-
|
|
|
b6dd5a |
hw/escc.c | 9 +++++++--
|
|
|
b6dd5a |
hw/etraxfs_ser.c | 13 +++++++++----
|
|
|
b6dd5a |
hw/exynos4210_uart.c | 9 +++++++--
|
|
|
b6dd5a |
hw/grlib_apbuart.c | 12 +++++++-----
|
|
|
b6dd5a |
hw/imx_serial.c | 9 +++++++--
|
|
|
b6dd5a |
hw/ivshmem.c | 28 ++++++++++++++++++++++------
|
|
|
b6dd5a |
hw/lm32_juart.c | 8 +++++++-
|
|
|
b6dd5a |
hw/lm32_uart.c | 8 +++++++-
|
|
|
b6dd5a |
hw/mcf_uart.c | 9 +++++++--
|
|
|
b6dd5a |
hw/milkymist-uart.c | 8 +++++++-
|
|
|
b6dd5a |
hw/pl011.c | 9 +++++++--
|
|
|
b6dd5a |
hw/pxa2xx.c | 13 +++++++++----
|
|
|
b6dd5a |
hw/qdev-properties.c | 2 +-
|
|
|
b6dd5a |
hw/serial.c | 9 +++++++--
|
|
|
b6dd5a |
hw/sh_serial.c | 12 +++++++++---
|
|
|
b6dd5a |
hw/spapr_vty.c | 8 ++++++--
|
|
|
b6dd5a |
hw/strongarm.c | 12 +++++++-----
|
|
|
b6dd5a |
hw/usb/dev-serial.c | 9 +++++++--
|
|
|
b6dd5a |
hw/usb/redirect.c | 9 +++++++--
|
|
|
b6dd5a |
hw/virtio-console.c | 9 +++++++--
|
|
|
b6dd5a |
hw/xen_console.c | 16 +++++++++++-----
|
|
|
b6dd5a |
hw/xilinx_uartlite.c | 11 +++++++++--
|
|
|
b6dd5a |
monitor.c | 18 ++++++++++++++----
|
|
|
b6dd5a |
net/slirp.c | 8 ++++++--
|
|
|
b6dd5a |
qemu-char.c | 32 ++++++++++++++++++++++----------
|
|
|
b6dd5a |
qemu-char.h | 13 +++++++++----
|
|
|
b6dd5a |
qtest.c | 9 ++++++++-
|
|
|
b6dd5a |
31 files changed, 255 insertions(+), 88 deletions(-)
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/gdbstub.c b/gdbstub.c
|
|
|
b6dd5a |
index 5d37dd9..7f6b1cb 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/gdbstub.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/gdbstub.c
|
|
|
b6dd5a |
@@ -2929,6 +2929,12 @@ static void gdb_sigterm_handler(int signal)
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
#endif
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers gdb_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = gdb_chr_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = gdb_chr_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = gdb_chr_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
int gdbserver_start(const char *device)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
GDBState *s;
|
|
|
b6dd5a |
@@ -2958,8 +2964,7 @@ int gdbserver_start(const char *device)
|
|
Justin M. Forbes |
d4cdad |
if (!chr)
|
|
Justin M. Forbes |
d4cdad |
return -1;
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
|
|
Justin M. Forbes |
d4cdad |
- gdb_chr_event, NULL);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &gdb_handlers, NULL);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
s = gdbserver_state;
|
|
Hans de Goede |
329b58 |
diff --git a/hw/cadence_uart.c b/hw/cadence_uart.c
|
|
Hans de Goede |
329b58 |
index d98e531..8f7d64a 100644
|
|
Hans de Goede |
329b58 |
--- a/hw/cadence_uart.c
|
|
Hans de Goede |
329b58 |
+++ b/hw/cadence_uart.c
|
|
Hans de Goede |
329b58 |
@@ -435,6 +435,12 @@ static void cadence_uart_reset(UartState *s)
|
|
Hans de Goede |
329b58 |
s->rx_wpos = 0;
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
+static const QemuChrHandlers cadence_uart_handlers = {
|
|
Hans de Goede |
329b58 |
+ .fd_can_read = uart_can_receive,
|
|
Hans de Goede |
329b58 |
+ .fd_read = uart_receive,
|
|
Hans de Goede |
329b58 |
+ .fd_event = uart_event,
|
|
Hans de Goede |
329b58 |
+};
|
|
Hans de Goede |
329b58 |
+
|
|
Hans de Goede |
329b58 |
static int cadence_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
{
|
|
Hans de Goede |
329b58 |
UartState *s = FROM_SYSBUS(UartState, dev);
|
|
Hans de Goede |
329b58 |
@@ -456,8 +462,7 @@ static int cadence_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
cadence_uart_reset(s);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
if (s->chr) {
|
|
Hans de Goede |
329b58 |
- qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
|
|
Hans de Goede |
329b58 |
- uart_event, s);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(s->chr, &cadence_uart_handlers, s);
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
|
|
Hans de Goede |
329b58 |
index bd6c777..fb32107 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/ccid-card-passthru.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/ccid-card-passthru.c
|
|
Justin M. Forbes |
d4cdad |
@@ -274,6 +274,12 @@ static const uint8_t *passthru_get_atr(CCIDCardState *base, uint32_t *len)
|
|
Justin M. Forbes |
d4cdad |
return card->atr;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers passthru_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = ccid_card_vscard_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = ccid_card_vscard_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = ccid_card_vscard_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int passthru_initfn(CCIDCardState *base)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
PassthruState *card = DO_UPCAST(PassthruState, base, base);
|
|
Justin M. Forbes |
d4cdad |
@@ -282,10 +288,7 @@ static int passthru_initfn(CCIDCardState *base)
|
|
Justin M. Forbes |
d4cdad |
card->vscard_in_hdr = 0;
|
|
Justin M. Forbes |
d4cdad |
if (card->cs) {
|
|
Justin M. Forbes |
d4cdad |
DPRINTF(card, D_INFO, "initing chardev\n");
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(card->cs,
|
|
Justin M. Forbes |
d4cdad |
- ccid_card_vscard_can_read,
|
|
Justin M. Forbes |
d4cdad |
- ccid_card_vscard_read,
|
|
Justin M. Forbes |
d4cdad |
- ccid_card_vscard_event, card);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(card->cs, &passthru_handlers, card);
|
|
Justin M. Forbes |
d4cdad |
ccid_card_vscard_send_init(card);
|
|
Justin M. Forbes |
d4cdad |
} else {
|
|
Justin M. Forbes |
d4cdad |
error_report("missing chardev");
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/debugcon.c b/hw/debugcon.c
|
|
Hans de Goede |
329b58 |
index 14ab326..7887fd2 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/debugcon.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/debugcon.c
|
|
Justin M. Forbes |
d4cdad |
@@ -73,7 +73,7 @@ static void debugcon_init_core(DebugconState *s)
|
|
Justin M. Forbes |
d4cdad |
exit(1);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, NULL, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
static int debugcon_isa_initfn(ISADevice *dev)
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/escc.c b/hw/escc.c
|
|
|
b6dd5a |
index e1f5e73..ff9d8b1 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/escc.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/escc.c
|
|
Justin M. Forbes |
d4cdad |
@@ -867,6 +867,12 @@ void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
|
|
Justin M. Forbes |
d4cdad |
sysbus_mmio_map(s, 0, base);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers serial_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = serial_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = serial_receive1,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = serial_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int escc_init1(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
SerialState *s = FROM_SYSBUS(SerialState, dev);
|
|
Justin M. Forbes |
d4cdad |
@@ -879,8 +885,7 @@ static int escc_init1(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
s->chn[i].chn = 1 - i;
|
|
Justin M. Forbes |
d4cdad |
s->chn[i].clock = s->frequency / 2;
|
|
Justin M. Forbes |
d4cdad |
if (s->chn[i].chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
|
|
Justin M. Forbes |
d4cdad |
- serial_receive1, serial_event, &s->chn[i]);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chn[i].chr, &serial_handlers, &s->chn[i]);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
s->chn[0].otherchn = &s->chn[1];
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c
|
|
Hans de Goede |
329b58 |
index 5f16b17..f2571c2 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/etraxfs_ser.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/etraxfs_ser.c
|
|
Justin M. Forbes |
d4cdad |
@@ -208,6 +208,12 @@ static void etraxfs_ser_reset(DeviceState *d)
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers serial_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = serial_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = serial_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = serial_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int etraxfs_ser_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
struct etrax_serial *s = FROM_SYSBUS(typeof (*s), dev);
|
|
Justin M. Forbes |
d4cdad |
@@ -217,10 +223,9 @@ static int etraxfs_ser_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
sysbus_init_mmio(dev, &s->mmio);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
s->chr = qemu_char_get_next_serial();
|
|
Justin M. Forbes |
d4cdad |
- if (s->chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr,
|
|
Justin M. Forbes |
d4cdad |
- serial_can_receive, serial_receive,
|
|
Justin M. Forbes |
d4cdad |
- serial_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, &serial_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
|
|
Hans de Goede |
329b58 |
index ccc4780..fefe400 100644
|
|
Hans de Goede |
329b58 |
--- a/hw/exynos4210_uart.c
|
|
Hans de Goede |
329b58 |
+++ b/hw/exynos4210_uart.c
|
|
Hans de Goede |
329b58 |
@@ -625,6 +625,12 @@ DeviceState *exynos4210_uart_create(target_phys_addr_t addr,
|
|
Hans de Goede |
329b58 |
return dev;
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
+static const QemuChrHandlers exynos4210_handlers = {
|
|
Hans de Goede |
329b58 |
+ .fd_can_read = exynos4210_uart_can_receive,
|
|
Hans de Goede |
329b58 |
+ .fd_read = exynos4210_uart_receive,
|
|
Hans de Goede |
329b58 |
+ .fd_event = exynos4210_uart_event,
|
|
Hans de Goede |
329b58 |
+};
|
|
Hans de Goede |
329b58 |
+
|
|
Hans de Goede |
329b58 |
static int exynos4210_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
{
|
|
Hans de Goede |
329b58 |
Exynos4210UartState *s = FROM_SYSBUS(Exynos4210UartState, dev);
|
|
Hans de Goede |
329b58 |
@@ -636,8 +642,7 @@ static int exynos4210_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
sysbus_init_irq(dev, &s->irq);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
- qemu_chr_add_handlers(s->chr, exynos4210_uart_can_receive,
|
|
Hans de Goede |
329b58 |
- exynos4210_uart_receive, exynos4210_uart_event, s);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(s->chr, &exynos4210_handlers, s);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
return 0;
|
|
Hans de Goede |
329b58 |
}
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/grlib_apbuart.c b/hw/grlib_apbuart.c
|
|
Hans de Goede |
329b58 |
index 73fc989..fd77d52 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/grlib_apbuart.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/grlib_apbuart.c
|
|
Hans de Goede |
329b58 |
@@ -222,15 +222,17 @@ static const MemoryRegionOps grlib_apbuart_ops = {
|
|
Hans de Goede |
329b58 |
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
Justin M. Forbes |
d4cdad |
};
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers grlib_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = grlib_apbuart_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = grlib_apbuart_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = grlib_apbuart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int grlib_apbuart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Hans de Goede |
329b58 |
UART *uart = FROM_SYSBUS(typeof(*uart), dev);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(uart->chr,
|
|
Justin M. Forbes |
d4cdad |
- grlib_apbuart_can_receive,
|
|
Justin M. Forbes |
d4cdad |
- grlib_apbuart_receive,
|
|
Justin M. Forbes |
d4cdad |
- grlib_apbuart_event,
|
|
Justin M. Forbes |
d4cdad |
- uart);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(uart->chr, &grlib_handlers, uart);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
sysbus_init_irq(dev, &uart->irq);
|
|
Hans de Goede |
329b58 |
|
|
|
b6dd5a |
diff --git a/hw/imx_serial.c b/hw/imx_serial.c
|
|
|
b6dd5a |
index d4eae43..f2304d2 100644
|
|
|
b6dd5a |
--- a/hw/imx_serial.c
|
|
|
b6dd5a |
+++ b/hw/imx_serial.c
|
|
|
b6dd5a |
@@ -381,6 +381,12 @@ static const struct MemoryRegionOps imx_serial_ops = {
|
|
|
b6dd5a |
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
b6dd5a |
};
|
|
|
b6dd5a |
|
|
|
b6dd5a |
+static const QemuChrHandlers imx_handlers = {
|
|
|
b6dd5a |
+ .fd_can_read = imx_can_receive,
|
|
|
b6dd5a |
+ .fd_read = imx_receive,
|
|
|
b6dd5a |
+ .fd_event = imx_event,
|
|
|
b6dd5a |
+};
|
|
|
b6dd5a |
+
|
|
|
b6dd5a |
static int imx_serial_init(SysBusDevice *dev)
|
|
|
b6dd5a |
{
|
|
|
b6dd5a |
IMXSerialState *s = FROM_SYSBUS(IMXSerialState, dev);
|
|
|
b6dd5a |
@@ -391,8 +397,7 @@ static int imx_serial_init(SysBusDevice *dev)
|
|
|
b6dd5a |
sysbus_init_irq(dev, &s->irq);
|
|
|
b6dd5a |
|
|
|
b6dd5a |
if (s->chr) {
|
|
|
b6dd5a |
- qemu_chr_add_handlers(s->chr, imx_can_receive, imx_receive,
|
|
|
b6dd5a |
- imx_event, s);
|
|
|
b6dd5a |
+ qemu_chr_add_handlers(s->chr, &imx_handlers, s);
|
|
|
b6dd5a |
} else {
|
|
|
b6dd5a |
DPRINTF("No char dev for uart at 0x%lx\n",
|
|
|
b6dd5a |
(unsigned long)s->iomem.ram_addr);
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
|
|
|
b6dd5a |
index 0c58161..f9a7fe8 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/ivshmem.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/ivshmem.c
|
|
|
b6dd5a |
@@ -273,6 +273,18 @@ static void fake_irqfd(void *opaque, const uint8_t *buf, int size) {
|
|
Justin M. Forbes |
d4cdad |
msix_notify(pdev, entry->vector);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers ivshmem_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = ivshmem_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = ivshmem_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = ivshmem_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers ivshmem_msi_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = ivshmem_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = fake_irqfd,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = ivshmem_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
|
b6dd5a |
static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *n,
|
|
|
b6dd5a |
int vector)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
|
b6dd5a |
@@ -293,11 +305,10 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *
|
|
Justin M. Forbes |
d4cdad |
s->eventfd_table[vector].pdev = &s->dev;
|
|
Justin M. Forbes |
d4cdad |
s->eventfd_table[vector].vector = vector;
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,
|
|
Justin M. Forbes |
d4cdad |
- ivshmem_event, &s->eventfd_table[vector]);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &ivshmem_msi_handlers,
|
|
Justin M. Forbes |
d4cdad |
+ &s->eventfd_table[vector]);
|
|
Justin M. Forbes |
d4cdad |
} else {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, ivshmem_can_receive, ivshmem_receive,
|
|
Justin M. Forbes |
d4cdad |
- ivshmem_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &ivshmem_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return chr;
|
|
|
b6dd5a |
@@ -641,6 +652,12 @@ static void ivshmem_write_config(PCIDevice *pci_dev, uint32_t address,
|
|
Hans de Goede |
329b58 |
msix_write_config(pci_dev, address, val, len);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers ivshmem_server_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = ivshmem_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = ivshmem_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = ivshmem_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int pci_ivshmem_init(PCIDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
|
|
|
b6dd5a |
@@ -730,8 +747,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
s->eventfd_chr = g_malloc0(s->vectors * sizeof(CharDriverState *));
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read,
|
|
Justin M. Forbes |
d4cdad |
- ivshmem_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->server_chr, &ivshmem_server_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
} else {
|
|
Justin M. Forbes |
d4cdad |
/* just map the file immediately, we're not using a server */
|
|
Justin M. Forbes |
d4cdad |
int fd;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/lm32_juart.c b/hw/lm32_juart.c
|
|
Hans de Goede |
329b58 |
index f07ed39..d4daeb8 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/lm32_juart.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/lm32_juart.c
|
|
Justin M. Forbes |
d4cdad |
@@ -110,13 +110,19 @@ static void juart_reset(DeviceState *d)
|
|
Justin M. Forbes |
d4cdad |
s->jrx = 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers juart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = juart_can_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = juart_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = juart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int lm32_juart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
LM32JuartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
s->chr = qemu_char_get_next_serial();
|
|
Justin M. Forbes |
d4cdad |
if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, juart_can_rx, juart_rx, juart_event, s);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(s->chr, &juart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c
|
|
Hans de Goede |
329b58 |
index 57066e2..4ea130b 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/lm32_uart.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/lm32_uart.c
|
|
Hans de Goede |
329b58 |
@@ -243,6 +243,12 @@ static void uart_reset(DeviceState *d)
|
|
Justin M. Forbes |
d4cdad |
s->regs[R_LSR] = LSR_THRE | LSR_TEMT;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers uart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = uart_can_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = uart_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = uart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int lm32_uart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
LM32UartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Hans de Goede |
329b58 |
@@ -254,7 +260,7 @@ static int lm32_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
s->chr = qemu_char_get_next_serial();
|
|
Justin M. Forbes |
d4cdad |
if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(s->chr, &uart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/mcf_uart.c b/hw/mcf_uart.c
|
|
Hans de Goede |
329b58 |
index ec6a87f..f52fb96 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/mcf_uart.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/mcf_uart.c
|
|
Hans de Goede |
329b58 |
@@ -272,6 +272,12 @@ static void mcf_uart_receive(void *opaque, const uint8_t *buf, int size)
|
|
Justin M. Forbes |
d4cdad |
mcf_uart_push_byte(s, buf[0]);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers mcf_uart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = mcf_uart_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = mcf_uart_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = mcf_uart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
mcf_uart_state *s;
|
|
Hans de Goede |
329b58 |
@@ -280,8 +286,7 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
|
|
Justin M. Forbes |
d4cdad |
s->chr = chr;
|
|
Justin M. Forbes |
d4cdad |
s->irq = irq;
|
|
Justin M. Forbes |
d4cdad |
if (chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, mcf_uart_can_receive, mcf_uart_receive,
|
|
Justin M. Forbes |
d4cdad |
- mcf_uart_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &mcf_uart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
mcf_uart_reset(s);
|
|
Justin M. Forbes |
d4cdad |
return s;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c
|
|
Hans de Goede |
329b58 |
index 291fe3c..2dcb41c 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/milkymist-uart.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/milkymist-uart.c
|
|
Justin M. Forbes |
d4cdad |
@@ -189,6 +189,12 @@ static void milkymist_uart_reset(DeviceState *d)
|
|
Justin M. Forbes |
d4cdad |
s->regs[R_STAT] = STAT_THRE;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers uart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = uart_can_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = uart_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = uart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int milkymist_uart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
MilkymistUartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Justin M. Forbes |
d4cdad |
@@ -201,7 +207,7 @@ static int milkymist_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
s->chr = qemu_char_get_next_serial();
|
|
Justin M. Forbes |
d4cdad |
if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(s->chr, &uart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/pl011.c b/hw/pl011.c
|
|
|
b6dd5a |
index 3245702..0d620f8 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/pl011.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/pl011.c
|
|
|
b6dd5a |
@@ -258,6 +258,12 @@ static const VMStateDescription vmstate_pl011 = {
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
};
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers pl011_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = pl011_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = pl011_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = pl011_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int pl011_init(SysBusDevice *dev, const unsigned char *id)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Hans de Goede |
329b58 |
pl011_state *s = FROM_SYSBUS(pl011_state, dev);
|
|
|
b6dd5a |
@@ -273,8 +279,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)
|
|
Justin M. Forbes |
d4cdad |
s->cr = 0x300;
|
|
Justin M. Forbes |
d4cdad |
s->flags = 0x90;
|
|
Justin M. Forbes |
d4cdad |
if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, pl011_can_receive, pl011_receive,
|
|
Justin M. Forbes |
d4cdad |
- pl011_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, &pl011_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
vmstate_register(&dev->qdev, -1, &vmstate_pl011, s);
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
|
|
|
b6dd5a |
index d5f1420..0b308cf 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/pxa2xx.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/pxa2xx.c
|
|
|
b6dd5a |
@@ -1962,6 +1962,12 @@ static int pxa2xx_fir_load(QEMUFile *f, void *opaque, int version_id)
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers pxa2xx_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = pxa2xx_fir_is_empty,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = pxa2xx_fir_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = pxa2xx_fir_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static PXA2xxFIrState *pxa2xx_fir_init(MemoryRegion *sysmem,
|
|
Justin M. Forbes |
d4cdad |
target_phys_addr_t base,
|
|
Justin M. Forbes |
d4cdad |
qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma,
|
|
|
b6dd5a |
@@ -1980,10 +1986,9 @@ static PXA2xxFIrState *pxa2xx_fir_init(MemoryRegion *sysmem,
|
|
Justin M. Forbes |
d4cdad |
memory_region_init_io(&s->iomem, &pxa2xx_fir_ops, s, "pxa2xx-fir", 0x1000);
|
|
Justin M. Forbes |
d4cdad |
memory_region_add_subregion(sysmem, base, &s->iomem);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- if (chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
|
|
Justin M. Forbes |
d4cdad |
- pxa2xx_fir_rx, pxa2xx_fir_event, s);
|
|
Justin M. Forbes |
d4cdad |
-
|
|
Justin M. Forbes |
d4cdad |
+ if (chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &pxa2xx_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
register_savevm(NULL, "pxa2xx_fir", 0, 0, pxa2xx_fir_save,
|
|
Justin M. Forbes |
d4cdad |
pxa2xx_fir_load, s);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
|
|
|
b6dd5a |
index 8aca0d4..677c665 100644
|
|
Hans de Goede |
329b58 |
--- a/hw/qdev-properties.c
|
|
Hans de Goede |
329b58 |
+++ b/hw/qdev-properties.c
|
|
|
b6dd5a |
@@ -549,7 +549,7 @@ static void release_chr(Object *obj, const char *name, void *opaque)
|
|
Hans de Goede |
329b58 |
CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
if (*ptr) {
|
|
Hans de Goede |
329b58 |
- qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(*ptr, NULL, NULL);
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/serial.c b/hw/serial.c
|
|
Hans de Goede |
329b58 |
index a421d1e..056d823 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/serial.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/serial.c
|
|
Hans de Goede |
329b58 |
@@ -736,6 +736,12 @@ static void serial_reset(void *opaque)
|
|
Justin M. Forbes |
d4cdad |
qemu_irq_lower(s->irq);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers serial_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = serial_can_receive1,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = serial_receive1,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = serial_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static void serial_init_core(SerialState *s)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
if (!s->chr) {
|
|
Hans de Goede |
329b58 |
@@ -750,8 +756,7 @@ static void serial_init_core(SerialState *s)
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
qemu_register_reset(serial_reset, s);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1,
|
|
Justin M. Forbes |
d4cdad |
- serial_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, &serial_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
/* Change the main reference oscillator frequency. */
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/sh_serial.c b/hw/sh_serial.c
|
|
|
b6dd5a |
index 1d1883d..ce1c765 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/sh_serial.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/sh_serial.c
|
|
|
b6dd5a |
@@ -352,6 +352,12 @@ static const MemoryRegionOps sh_serial_ops = {
|
|
Hans de Goede |
329b58 |
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
Justin M. Forbes |
d4cdad |
};
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers sh_serial_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = sh_serial_can_receive1,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = sh_serial_receive1,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = sh_serial_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Hans de Goede |
329b58 |
void sh_serial_init(MemoryRegion *sysmem,
|
|
Hans de Goede |
329b58 |
target_phys_addr_t base, int feat,
|
|
Hans de Goede |
329b58 |
uint32_t freq, CharDriverState *chr,
|
|
|
b6dd5a |
@@ -396,9 +402,9 @@ void sh_serial_init(MemoryRegion *sysmem,
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
s->chr = chr;
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- if (chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, sh_serial_can_receive1, sh_serial_receive1,
|
|
Justin M. Forbes |
d4cdad |
- sh_serial_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ if (chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &sh_serial_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
s->eri = eri_source;
|
|
Justin M. Forbes |
d4cdad |
s->rxi = rxi_source;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
|
|
|
b6dd5a |
index 99e52cc..e7cb84f 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/spapr_vty.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/spapr_vty.c
|
|
Justin M. Forbes |
d4cdad |
@@ -54,6 +54,11 @@ void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len)
|
|
Justin M. Forbes |
d4cdad |
qemu_chr_fe_write(dev->chardev, buf, len);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers vty_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = vty_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = vty_receive,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int spapr_vty_init(VIOsPAPRDevice *sdev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
|
|
Justin M. Forbes |
d4cdad |
@@ -63,8 +68,7 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev)
|
|
Justin M. Forbes |
d4cdad |
exit(1);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(dev->chardev, vty_can_receive,
|
|
Justin M. Forbes |
d4cdad |
- vty_receive, NULL, dev);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(dev->chardev, &vty_handlers, dev);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/strongarm.c b/hw/strongarm.c
|
|
|
b6dd5a |
index 7150eeb..594cf31 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/strongarm.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/strongarm.c
|
|
Hans de Goede |
329b58 |
@@ -1199,6 +1199,12 @@ static const MemoryRegionOps strongarm_uart_ops = {
|
|
Justin M. Forbes |
d4cdad |
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
Justin M. Forbes |
d4cdad |
};
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers strongarm_uart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = strongarm_uart_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = strongarm_uart_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = strongarm_uart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int strongarm_uart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
StrongARMUARTState *s = FROM_SYSBUS(StrongARMUARTState, dev);
|
|
Hans de Goede |
329b58 |
@@ -1211,11 +1217,7 @@ static int strongarm_uart_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
s->tx_timer = qemu_new_timer_ns(vm_clock, strongarm_uart_tx, s);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr,
|
|
Justin M. Forbes |
d4cdad |
- strongarm_uart_can_receive,
|
|
Justin M. Forbes |
d4cdad |
- strongarm_uart_receive,
|
|
Justin M. Forbes |
d4cdad |
- strongarm_uart_event,
|
|
Justin M. Forbes |
d4cdad |
- s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, &strongarm_uart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Hans de Goede |
329b58 |
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
|
|
|
b6dd5a |
index 8aa6552..8fc9bdd 100644
|
|
Hans de Goede |
329b58 |
--- a/hw/usb/dev-serial.c
|
|
Hans de Goede |
329b58 |
+++ b/hw/usb/dev-serial.c
|
|
Hans de Goede |
329b58 |
@@ -475,6 +475,12 @@ static void usb_serial_event(void *opaque, int event)
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers usb_serial_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = usb_serial_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = usb_serial_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = usb_serial_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int usb_serial_initfn(USBDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
|
|
Hans de Goede |
329b58 |
@@ -487,8 +493,7 @@ static int usb_serial_initfn(USBDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
return -1;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
|
|
Justin M. Forbes |
d4cdad |
- usb_serial_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->cs, &usb_serial_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
usb_serial_handle_reset(dev);
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
|
|
|
b6dd5a |
index 10b4fbb..ecb2cd4 100644
|
|
Hans de Goede |
329b58 |
--- a/hw/usb/redirect.c
|
|
Hans de Goede |
329b58 |
+++ b/hw/usb/redirect.c
|
|
|
b6dd5a |
@@ -892,6 +892,12 @@ static void usbredir_chardev_event(void *opaque, int event)
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
+static const QemuChrHandlers usbredir_chr_handlers = {
|
|
Hans de Goede |
329b58 |
+ .fd_can_read = usbredir_chardev_can_read,
|
|
Hans de Goede |
329b58 |
+ .fd_read = usbredir_chardev_read,
|
|
Hans de Goede |
329b58 |
+ .fd_event = usbredir_chardev_event,
|
|
Hans de Goede |
329b58 |
+};
|
|
Hans de Goede |
329b58 |
+
|
|
Hans de Goede |
329b58 |
/*
|
|
Hans de Goede |
329b58 |
* init + destroy
|
|
Hans de Goede |
329b58 |
*/
|
|
|
b6dd5a |
@@ -930,8 +936,7 @@ static int usbredir_initfn(USBDevice *udev)
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
/* Let the backend know we are ready */
|
|
Hans de Goede |
329b58 |
qemu_chr_fe_open(dev->cs);
|
|
Hans de Goede |
329b58 |
- qemu_chr_add_handlers(dev->cs, usbredir_chardev_can_read,
|
|
Hans de Goede |
329b58 |
- usbredir_chardev_read, usbredir_chardev_event, dev);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(dev->cs, &usbredir_chr_handlers, dev);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
add_boot_device_path(dev->bootindex, &udev->qdev, NULL);
|
|
Hans de Goede |
329b58 |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
|
|
Hans de Goede |
329b58 |
index cffee3d..066590c 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/virtio-console.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/virtio-console.c
|
|
Hans de Goede |
329b58 |
@@ -106,6 +106,12 @@ static void chr_event(void *opaque, int event)
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers chr_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = chr_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = chr_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = chr_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int virtconsole_initfn(VirtIOSerialPort *port)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
|
Hans de Goede |
329b58 |
@@ -117,8 +123,7 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
if (vcon->chr) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
|
|
Justin M. Forbes |
d4cdad |
- vcon);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(vcon->chr, &chr_handlers, vcon);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/xen_console.c b/hw/xen_console.c
|
|
|
b6dd5a |
index 9426d73..e9fcadc 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/xen_console.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/xen_console.c
|
|
|
b6dd5a |
@@ -211,6 +211,11 @@ out:
|
|
Justin M. Forbes |
d4cdad |
return ret;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers xencons_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = xencons_can_receive,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = xencons_receive,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int con_initialise(struct XenDevice *xendev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
|
|
|
b6dd5a |
@@ -231,9 +236,9 @@ static int con_initialise(struct XenDevice *xendev)
|
|
Justin M. Forbes |
d4cdad |
return -1;
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
xen_be_bind_evtchn(&con->xendev);
|
|
Justin M. Forbes |
d4cdad |
- if (con->chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(con->chr, xencons_can_receive, xencons_receive,
|
|
Justin M. Forbes |
d4cdad |
- NULL, con);
|
|
Justin M. Forbes |
d4cdad |
+ if (con->chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(con->chr, &xencons_handlers, con);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
|
|
Justin M. Forbes |
d4cdad |
con->ring_ref,
|
|
|
b6dd5a |
@@ -250,8 +255,9 @@ static void con_disconnect(struct XenDevice *xendev)
|
|
Hans de Goede |
329b58 |
if (!xendev->dev) {
|
|
Hans de Goede |
329b58 |
return;
|
|
Hans de Goede |
329b58 |
}
|
|
Justin M. Forbes |
d4cdad |
- if (con->chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL);
|
|
Justin M. Forbes |
d4cdad |
+ if (con->chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(con->chr, NULL, NULL);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
xen_be_unbind_evtchn(&con->xendev);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
if (con->sring) {
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/xilinx_uartlite.c b/hw/xilinx_uartlite.c
|
|
|
b6dd5a |
index d0f32db..33f0cd5 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/hw/xilinx_uartlite.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/hw/xilinx_uartlite.c
|
|
Justin M. Forbes |
d4cdad |
@@ -195,6 +195,12 @@ static void uart_event(void *opaque, int event)
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers uart_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = uart_can_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = uart_rx,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = uart_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int xilinx_uartlite_init(SysBusDevice *dev)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
struct xlx_uartlite *s = FROM_SYSBUS(typeof (*s), dev);
|
|
|
b6dd5a |
@@ -207,8 +213,9 @@ static int xilinx_uartlite_init(SysBusDevice *dev)
|
|
Hans de Goede |
329b58 |
sysbus_init_mmio(dev, &s->mmio);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
s->chr = qemu_char_get_next_serial();
|
|
Justin M. Forbes |
d4cdad |
- if (s->chr)
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Justin M. Forbes |
d4cdad |
+ if (s->chr) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(s->chr, &uart_handlers, s);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/monitor.c b/monitor.c
|
|
|
b6dd5a |
index 99618a0..c020089 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/monitor.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/monitor.c
|
|
|
b6dd5a |
@@ -4689,6 +4689,18 @@ static void sortcmdlist(void)
|
|
Justin M. Forbes |
d4cdad |
* End:
|
|
Justin M. Forbes |
d4cdad |
*/
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers monitor_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = monitor_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = monitor_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = monitor_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers monitor_control_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = monitor_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = monitor_control_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = monitor_control_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
void monitor_init(CharDriverState *chr, int flags)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
static int is_first_init = 1;
|
|
|
b6dd5a |
@@ -4712,12 +4724,10 @@ void monitor_init(CharDriverState *chr, int flags)
|
|
Justin M. Forbes |
d4cdad |
if (monitor_ctrl_mode(mon)) {
|
|
Justin M. Forbes |
d4cdad |
mon->mc = g_malloc0(sizeof(MonitorControl));
|
|
Justin M. Forbes |
d4cdad |
/* Control mode requires special handlers */
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_control_read,
|
|
Justin M. Forbes |
d4cdad |
- monitor_control_event, mon);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &monitor_control_handlers, mon);
|
|
Justin M. Forbes |
d4cdad |
qemu_chr_fe_set_echo(chr, true);
|
|
Justin M. Forbes |
d4cdad |
} else {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_read,
|
|
Justin M. Forbes |
d4cdad |
- monitor_event, mon);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(chr, &monitor_handlers, mon);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
QLIST_INSERT_HEAD(&mon_list, mon, entry);
|
|
Justin M. Forbes |
d4cdad |
diff --git a/net/slirp.c b/net/slirp.c
|
|
|
b6dd5a |
index 08adb97..f5ba440 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/net/slirp.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/net/slirp.c
|
|
|
b6dd5a |
@@ -593,6 +593,11 @@ static void guestfwd_read(void *opaque, const uint8_t *buf, int size)
|
|
Justin M. Forbes |
d4cdad |
slirp_socket_recv(fwd->slirp, fwd->server, fwd->port, buf, size);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers guestfwd_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = guestfwd_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = guestfwd_read,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
|
Justin M. Forbes |
d4cdad |
int legacy_format)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
|
b6dd5a |
@@ -658,8 +663,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
|
|
b6dd5a |
fwd->port = port;
|
|
|
b6dd5a |
fwd->slirp = s->slirp;
|
|
Hans de Goede |
329b58 |
|
|
|
b6dd5a |
- qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read,
|
|
|
b6dd5a |
- NULL, fwd);
|
|
|
b6dd5a |
+ qemu_chr_add_handlers(fwd->hd, &guestfwd_handlers, fwd);
|
|
|
b6dd5a |
}
|
|
Justin M. Forbes |
d4cdad |
return 0;
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/qemu-char.c b/qemu-char.c
|
|
|
b6dd5a |
index 132ac08..5c5ae1e 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/qemu-char.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/qemu-char.c
|
|
Hans de Goede |
329b58 |
@@ -192,19 +192,26 @@ void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)
|
|
Justin M. Forbes |
d4cdad |
va_end(ap);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers null_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ /* All handlers are initialised to NULL */
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
void qemu_chr_add_handlers(CharDriverState *s,
|
|
Justin M. Forbes |
d4cdad |
- IOCanReadHandler *fd_can_read,
|
|
Justin M. Forbes |
d4cdad |
- IOReadHandler *fd_read,
|
|
Justin M. Forbes |
d4cdad |
- IOEventHandler *fd_event,
|
|
Justin M. Forbes |
d4cdad |
- void *opaque)
|
|
Justin M. Forbes |
d4cdad |
+ const QemuChrHandlers *handlers, void *opaque)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
- if (!opaque && !fd_can_read && !fd_read && !fd_event) {
|
|
Justin M. Forbes |
d4cdad |
+ if (!s) {
|
|
Justin M. Forbes |
d4cdad |
+ return;
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+ if (!opaque && !handlers) {
|
|
Justin M. Forbes |
d4cdad |
/* chr driver being released. */
|
|
Justin M. Forbes |
d4cdad |
++s->avail_connections;
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
- s->chr_can_read = fd_can_read;
|
|
Justin M. Forbes |
d4cdad |
- s->chr_read = fd_read;
|
|
Justin M. Forbes |
d4cdad |
- s->chr_event = fd_event;
|
|
Justin M. Forbes |
d4cdad |
+ if (!handlers) {
|
|
Justin M. Forbes |
d4cdad |
+ handlers = &null_handlers;
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+ s->chr_can_read = handlers->fd_can_read;
|
|
Justin M. Forbes |
d4cdad |
+ s->chr_read = handlers->fd_read;
|
|
Justin M. Forbes |
d4cdad |
+ s->chr_event = handlers->fd_event;
|
|
Justin M. Forbes |
d4cdad |
s->handler_opaque = opaque;
|
|
Justin M. Forbes |
d4cdad |
if (s->chr_update_read_handler)
|
|
Justin M. Forbes |
d4cdad |
s->chr_update_read_handler(s);
|
|
Hans de Goede |
329b58 |
@@ -442,6 +449,12 @@ static void mux_chr_event(void *opaque, int event)
|
|
Justin M. Forbes |
d4cdad |
mux_chr_send_event(d, i, event);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static const QemuChrHandlers mux_chr_handlers = {
|
|
Justin M. Forbes |
d4cdad |
+ .fd_can_read = mux_chr_can_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_read = mux_chr_read,
|
|
Justin M. Forbes |
d4cdad |
+ .fd_event = mux_chr_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static void mux_chr_update_read_handler(CharDriverState *chr)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
MuxDriver *d = chr->opaque;
|
|
Hans de Goede |
329b58 |
@@ -456,8 +469,7 @@ static void mux_chr_update_read_handler(CharDriverState *chr)
|
|
Justin M. Forbes |
d4cdad |
d->chr_event[d->mux_cnt] = chr->chr_event;
|
|
Justin M. Forbes |
d4cdad |
/* Fix up the real driver with mux routines */
|
|
Justin M. Forbes |
d4cdad |
if (d->mux_cnt == 0) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_add_handlers(d->drv, mux_chr_can_read, mux_chr_read,
|
|
Justin M. Forbes |
d4cdad |
- mux_chr_event, chr);
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_add_handlers(d->drv, &mux_chr_handlers, chr);
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
if (d->focus != -1) {
|
|
Justin M. Forbes |
d4cdad |
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
|
|
Justin M. Forbes |
d4cdad |
diff --git a/qemu-char.h b/qemu-char.h
|
|
Hans de Goede |
329b58 |
index 486644b..dfa8c2d 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/qemu-char.h
|
|
Justin M. Forbes |
d4cdad |
+++ b/qemu-char.h
|
|
Justin M. Forbes |
d4cdad |
@@ -222,10 +222,15 @@ void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len);
|
|
Justin M. Forbes |
d4cdad |
*/
|
|
Justin M. Forbes |
d4cdad |
void qemu_chr_be_event(CharDriverState *s, int event);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
-void qemu_chr_add_handlers(CharDriverState *s,
|
|
Justin M. Forbes |
d4cdad |
- IOCanReadHandler *fd_can_read,
|
|
Justin M. Forbes |
d4cdad |
- IOReadHandler *fd_read,
|
|
Justin M. Forbes |
d4cdad |
- IOEventHandler *fd_event,
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+typedef struct QemuChrHandlers {
|
|
Justin M. Forbes |
d4cdad |
+ IOCanReadHandler *fd_can_read;
|
|
Justin M. Forbes |
d4cdad |
+ IOReadHandler *fd_read;
|
|
Justin M. Forbes |
d4cdad |
+ IOHandler *fd_write_unblocked;
|
|
Justin M. Forbes |
d4cdad |
+ IOEventHandler *fd_event;
|
|
Justin M. Forbes |
d4cdad |
+} QemuChrHandlers;
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+void qemu_chr_add_handlers(CharDriverState *s, const QemuChrHandlers *handlers,
|
|
Justin M. Forbes |
d4cdad |
void *opaque);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
void qemu_chr_generic_open(CharDriverState *s);
|
|
Hans de Goede |
329b58 |
diff --git a/qtest.c b/qtest.c
|
|
Hans de Goede |
329b58 |
index fbfab4e..4ab5b69 100644
|
|
Hans de Goede |
329b58 |
--- a/qtest.c
|
|
Hans de Goede |
329b58 |
+++ b/qtest.c
|
|
Hans de Goede |
329b58 |
@@ -416,6 +416,13 @@ static void qtest_event(void *opaque, int event)
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Justin M. Forbes |
d4cdad |
}
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
+static const QemuChrHandlers test_handlers = {
|
|
Hans de Goede |
329b58 |
+ .fd_can_read = qtest_can_read,
|
|
Hans de Goede |
329b58 |
+ .fd_read = qtest_read,
|
|
Hans de Goede |
329b58 |
+ .fd_event = qtest_event,
|
|
Justin M. Forbes |
d4cdad |
+};
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Hans de Goede |
329b58 |
+
|
|
Hans de Goede |
329b58 |
int qtest_init(void)
|
|
Hans de Goede |
329b58 |
{
|
|
Hans de Goede |
329b58 |
CharDriverState *chr;
|
|
Hans de Goede |
329b58 |
@@ -425,7 +432,7 @@ int qtest_init(void)
|
|
Hans de Goede |
329b58 |
configure_icount("0");
|
|
Hans de Goede |
329b58 |
chr = qemu_chr_new("qtest", qtest_chrdev, NULL);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
- qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
|
|
Hans de Goede |
329b58 |
+ qemu_chr_add_handlers(chr, &test_handlers, chr);
|
|
Hans de Goede |
329b58 |
qemu_chr_fe_set_echo(chr, true);
|
|
Hans de Goede |
329b58 |
|
|
Hans de Goede |
329b58 |
inbuf = g_string_new("");
|
|
Justin M. Forbes |
d4cdad |
--
|
|
|
b6dd5a |
1.7.11.2
|
|
Justin M. Forbes |
d4cdad |
|