|
Justin M. Forbes |
5e10b1 |
From ffef9f85d32395989a3c5845dfe34d2110ccb82b Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
3f1f29 |
From: Amit Shah <amit.shah@redhat.com>
|
|
Hans de Goede |
3f1f29 |
Date: Mon, 21 Mar 2011 20:31:45 +0100
|
|
Justin M. Forbes |
5e10b1 |
Subject: [PATCH 02/13] char: Add a QemuChrHandlers struct to initialise
|
|
Hans de Goede |
3f1f29 |
chardev handlers
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
Instead of passing each handler in the qemu_add_handlers() function,
|
|
Hans de Goede |
3f1f29 |
create a struct of handlers that can be passed to the function instead.
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
Hans de Goede |
3f1f29 |
---
|
|
Hans de Goede |
3f1f29 |
gdbstub.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/ccid-card-passthru.c | 11 +++++++----
|
|
Hans de Goede |
3f1f29 |
hw/debugcon.c | 2 +-
|
|
Hans de Goede |
3f1f29 |
hw/escc.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/etraxfs_ser.c | 13 +++++++++----
|
|
Hans de Goede |
3f1f29 |
hw/grlib_apbuart.c | 12 +++++++-----
|
|
Hans de Goede |
3f1f29 |
hw/ivshmem.c | 28 ++++++++++++++++++++++------
|
|
Hans de Goede |
3f1f29 |
hw/lm32_juart.c | 8 +++++++-
|
|
Hans de Goede |
3f1f29 |
hw/lm32_uart.c | 8 +++++++-
|
|
Hans de Goede |
3f1f29 |
hw/mcf_uart.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/milkymist-uart.c | 8 +++++++-
|
|
Hans de Goede |
3f1f29 |
hw/pl011.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/pxa2xx.c | 13 +++++++++----
|
|
Hans de Goede |
3f1f29 |
hw/serial.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/sh_serial.c | 12 +++++++++---
|
|
Hans de Goede |
3f1f29 |
hw/spapr_vty.c | 8 ++++++--
|
|
Hans de Goede |
3f1f29 |
hw/strongarm.c | 12 +++++++-----
|
|
Hans de Goede |
3f1f29 |
hw/syborg_serial.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/usb-serial.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
hw/virtio-console.c | 11 ++++++++---
|
|
Hans de Goede |
3f1f29 |
hw/xen_console.c | 16 +++++++++++-----
|
|
Hans de Goede |
3f1f29 |
hw/xilinx_uartlite.c | 11 +++++++++--
|
|
Hans de Goede |
3f1f29 |
monitor.c | 18 ++++++++++++++----
|
|
Hans de Goede |
3f1f29 |
net/slirp.c | 8 ++++++--
|
|
Hans de Goede |
3f1f29 |
qemu-char.c | 32 ++++++++++++++++++++++----------
|
|
Hans de Goede |
3f1f29 |
qemu-char.h | 13 +++++++++----
|
|
Hans de Goede |
3f1f29 |
usb-redir.c | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
27 files changed, 233 insertions(+), 83 deletions(-)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/gdbstub.c b/gdbstub.c
|
|
Hans de Goede |
3f1f29 |
index c085a5a..0ff61cb 100644
|
|
Hans de Goede |
3f1f29 |
--- a/gdbstub.c
|
|
Hans de Goede |
3f1f29 |
+++ b/gdbstub.c
|
|
Hans de Goede |
3f1f29 |
@@ -2739,6 +2739,12 @@ static void gdb_sigterm_handler(int signal)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
#endif
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers gdb_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = gdb_chr_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = gdb_chr_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = gdb_chr_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
int gdbserver_start(const char *device)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
GDBState *s;
|
|
Hans de Goede |
3f1f29 |
@@ -2768,8 +2774,7 @@ int gdbserver_start(const char *device)
|
|
Hans de Goede |
3f1f29 |
if (!chr)
|
|
Hans de Goede |
3f1f29 |
return -1;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
|
|
Hans de Goede |
3f1f29 |
- gdb_chr_event, NULL);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &gdb_handlers, NULL);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s = gdbserver_state;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
|
|
Hans de Goede |
3f1f29 |
index 28eb9d1..1dee6f7 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/ccid-card-passthru.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/ccid-card-passthru.c
|
|
Hans de Goede |
3f1f29 |
@@ -273,6 +273,12 @@ static const uint8_t *passthru_get_atr(CCIDCardState *base, uint32_t *len)
|
|
Hans de Goede |
3f1f29 |
return card->atr;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers passthru_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = ccid_card_vscard_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = ccid_card_vscard_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = ccid_card_vscard_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int passthru_initfn(CCIDCardState *base)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
PassthruState *card = DO_UPCAST(PassthruState, base, base);
|
|
Hans de Goede |
3f1f29 |
@@ -281,10 +287,7 @@ static int passthru_initfn(CCIDCardState *base)
|
|
Hans de Goede |
3f1f29 |
card->vscard_in_hdr = 0;
|
|
Hans de Goede |
3f1f29 |
if (card->cs) {
|
|
Hans de Goede |
3f1f29 |
DPRINTF(card, D_INFO, "initing chardev\n");
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(card->cs,
|
|
Hans de Goede |
3f1f29 |
- ccid_card_vscard_can_read,
|
|
Hans de Goede |
3f1f29 |
- ccid_card_vscard_read,
|
|
Hans de Goede |
3f1f29 |
- ccid_card_vscard_event, card);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(card->cs, &passthru_handlers, card);
|
|
Hans de Goede |
3f1f29 |
ccid_card_vscard_send_init(card);
|
|
Hans de Goede |
3f1f29 |
} else {
|
|
Hans de Goede |
3f1f29 |
error_report("missing chardev");
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/debugcon.c b/hw/debugcon.c
|
|
Hans de Goede |
3f1f29 |
index 5ee6821..e79a595 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/debugcon.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/debugcon.c
|
|
Hans de Goede |
3f1f29 |
@@ -73,7 +73,7 @@ static void debugcon_init_core(DebugconState *s)
|
|
Hans de Goede |
3f1f29 |
exit(1);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, NULL, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static int debugcon_isa_initfn(ISADevice *dev)
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/escc.c b/hw/escc.c
|
|
Hans de Goede |
3f1f29 |
index f6fd919..dfa329a 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/escc.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/escc.c
|
|
Hans de Goede |
3f1f29 |
@@ -898,6 +898,12 @@ void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
|
|
Hans de Goede |
3f1f29 |
sysbus_mmio_map(s, 0, base);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = serial_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = serial_receive1,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int escc_init1(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
SerialState *s = FROM_SYSBUS(SerialState, dev);
|
|
Hans de Goede |
3f1f29 |
@@ -911,8 +917,7 @@ static int escc_init1(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
s->chn[i].chn = 1 - i;
|
|
Hans de Goede |
3f1f29 |
s->chn[i].clock = s->frequency / 2;
|
|
Hans de Goede |
3f1f29 |
if (s->chn[i].chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
|
|
Hans de Goede |
3f1f29 |
- serial_receive1, serial_event, &s->chn[i]);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chn[i].chr, &serial_handlers, &s->chn[i]);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
s->chn[0].otherchn = &s->chn[1];
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c
|
|
Hans de Goede |
3f1f29 |
index b917d4d..ebbad77 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/etraxfs_ser.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/etraxfs_ser.c
|
|
Hans de Goede |
3f1f29 |
@@ -202,6 +202,12 @@ static void etraxfs_ser_reset(DeviceState *d)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = serial_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = serial_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int etraxfs_ser_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
struct etrax_serial *s = FROM_SYSBUS(typeof (*s), dev);
|
|
Hans de Goede |
3f1f29 |
@@ -212,10 +218,9 @@ static int etraxfs_ser_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
DEVICE_NATIVE_ENDIAN);
|
|
Hans de Goede |
3f1f29 |
sysbus_init_mmio(dev, R_MAX * 4, ser_regs);
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
- if (s->chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr,
|
|
Hans de Goede |
3f1f29 |
- serial_can_receive, serial_receive,
|
|
Hans de Goede |
3f1f29 |
- serial_event, s);
|
|
Hans de Goede |
3f1f29 |
+ if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &serial_handlers, s);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/grlib_apbuart.c b/hw/grlib_apbuart.c
|
|
Hans de Goede |
3f1f29 |
index 169a56e..310687b 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/grlib_apbuart.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/grlib_apbuart.c
|
|
Hans de Goede |
3f1f29 |
@@ -144,16 +144,18 @@ static CPUWriteMemoryFunc * const grlib_apbuart_write[] = {
|
|
Hans de Goede |
3f1f29 |
NULL, NULL, grlib_apbuart_writel,
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers grlib_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = grlib_apbuart_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = grlib_apbuart_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = grlib_apbuart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int grlib_apbuart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
UART *uart = FROM_SYSBUS(typeof(*uart), dev);
|
|
Hans de Goede |
3f1f29 |
int uart_regs = 0;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(uart->chr,
|
|
Hans de Goede |
3f1f29 |
- grlib_apbuart_can_receive,
|
|
Hans de Goede |
3f1f29 |
- grlib_apbuart_receive,
|
|
Hans de Goede |
3f1f29 |
- grlib_apbuart_event,
|
|
Hans de Goede |
3f1f29 |
- uart);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(uart->chr, &grlib_handlers, uart);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
sysbus_init_irq(dev, &uart->irq);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
|
|
Hans de Goede |
3f1f29 |
index 3055dd2..4f59575 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/ivshmem.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/ivshmem.c
|
|
Hans de Goede |
3f1f29 |
@@ -312,6 +312,18 @@ static void fake_irqfd(void *opaque, const uint8_t *buf, int size) {
|
|
Hans de Goede |
3f1f29 |
msix_notify(pdev, entry->vector);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers ivshmem_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = ivshmem_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = ivshmem_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = ivshmem_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers ivshmem_msi_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = ivshmem_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = fake_irqfd,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = ivshmem_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static CharDriverState* create_eventfd_chr_device(void * opaque, int eventfd,
|
|
Hans de Goede |
3f1f29 |
int vector)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
@@ -331,11 +343,10 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, int eventfd,
|
|
Hans de Goede |
3f1f29 |
s->eventfd_table[vector].pdev = &s->dev;
|
|
Hans de Goede |
3f1f29 |
s->eventfd_table[vector].vector = vector;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,
|
|
Hans de Goede |
3f1f29 |
- ivshmem_event, &s->eventfd_table[vector]);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &ivshmem_msi_handlers,
|
|
Hans de Goede |
3f1f29 |
+ &s->eventfd_table[vector]);
|
|
Hans de Goede |
3f1f29 |
} else {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, ivshmem_can_receive, ivshmem_receive,
|
|
Hans de Goede |
3f1f29 |
- ivshmem_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &ivshmem_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return chr;
|
|
Hans de Goede |
3f1f29 |
@@ -666,6 +677,12 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers ivshmem_server_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = ivshmem_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = ivshmem_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = ivshmem_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int pci_ivshmem_init(PCIDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
|
|
Hans de Goede |
3f1f29 |
@@ -749,8 +766,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->eventfd_chr = qemu_mallocz(s->vectors * sizeof(CharDriverState *));
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read,
|
|
Hans de Goede |
3f1f29 |
- ivshmem_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->server_chr, &ivshmem_server_handlers, s);
|
|
Hans de Goede |
3f1f29 |
} else {
|
|
Hans de Goede |
3f1f29 |
/* just map the file immediately, we're not using a server */
|
|
Hans de Goede |
3f1f29 |
int fd;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/lm32_juart.c b/hw/lm32_juart.c
|
|
Hans de Goede |
3f1f29 |
index fddcf7e..12dd1e8 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/lm32_juart.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/lm32_juart.c
|
|
Hans de Goede |
3f1f29 |
@@ -110,13 +110,19 @@ static void juart_reset(DeviceState *d)
|
|
Hans de Goede |
3f1f29 |
s->jrx = 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers juart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = juart_can_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = juart_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = juart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int lm32_juart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
LM32JuartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, juart_can_rx, juart_rx, juart_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, juart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c
|
|
Hans de Goede |
3f1f29 |
index 09090e9..5438660 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/lm32_uart.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/lm32_uart.c
|
|
Hans de Goede |
3f1f29 |
@@ -242,6 +242,12 @@ static void uart_reset(DeviceState *d)
|
|
Hans de Goede |
3f1f29 |
s->regs[R_LSR] = LSR_THRE | LSR_TEMT;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers uart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = uart_can_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = uart_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = uart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int lm32_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
LM32UartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Hans de Goede |
3f1f29 |
@@ -255,7 +261,7 @@ static int lm32_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, uart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/mcf_uart.c b/hw/mcf_uart.c
|
|
Justin M. Forbes |
5e10b1 |
index 905e116..bb5740c 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/mcf_uart.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/mcf_uart.c
|
|
Hans de Goede |
3f1f29 |
@@ -268,6 +268,12 @@ static void mcf_uart_receive(void *opaque, const uint8_t *buf, int size)
|
|
Hans de Goede |
3f1f29 |
mcf_uart_push_byte(s, buf[0]);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers mcf_uart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = mcf_uart_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = mcf_uart_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = mcf_uart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
mcf_uart_state *s;
|
|
Hans de Goede |
3f1f29 |
@@ -276,8 +282,7 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
|
|
Hans de Goede |
3f1f29 |
s->chr = chr;
|
|
Hans de Goede |
3f1f29 |
s->irq = irq;
|
|
Hans de Goede |
3f1f29 |
if (chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, mcf_uart_can_receive, mcf_uart_receive,
|
|
Hans de Goede |
3f1f29 |
- mcf_uart_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &mcf_uart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
mcf_uart_reset(s);
|
|
Hans de Goede |
3f1f29 |
return s;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c
|
|
Hans de Goede |
3f1f29 |
index 56c90da..4412b1b 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/milkymist-uart.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/milkymist-uart.c
|
|
Hans de Goede |
3f1f29 |
@@ -133,6 +133,12 @@ static void milkymist_uart_reset(DeviceState *d)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers uart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = uart_can_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = uart_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = uart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int milkymist_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
MilkymistUartState *s = FROM_SYSBUS(typeof(*s), dev);
|
|
Hans de Goede |
3f1f29 |
@@ -147,7 +153,7 @@ static int milkymist_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, uart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/pl011.c b/hw/pl011.c
|
|
Justin M. Forbes |
5e10b1 |
index 997ce84..37ba7f6 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/pl011.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/pl011.c
|
|
Hans de Goede |
3f1f29 |
@@ -260,6 +260,12 @@ static const VMStateDescription vmstate_pl011 = {
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers pl011_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = pl011_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = pl011_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = pl011_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int pl011_init(SysBusDevice *dev, const unsigned char *id)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
int iomemtype;
|
|
Hans de Goede |
3f1f29 |
@@ -278,8 +284,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)
|
|
Hans de Goede |
3f1f29 |
s->cr = 0x300;
|
|
Hans de Goede |
3f1f29 |
s->flags = 0x90;
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, pl011_can_receive, pl011_receive,
|
|
Hans de Goede |
3f1f29 |
- pl011_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &pl011_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
vmstate_register(&dev->qdev, -1, &vmstate_pl011, s);
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
|
|
Justin M. Forbes |
5e10b1 |
index cf93110..18bbe48 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/pxa2xx.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/pxa2xx.c
|
|
Hans de Goede |
3f1f29 |
@@ -2019,6 +2019,12 @@ static int pxa2xx_fir_load(QEMUFile *f, void *opaque, int version_id)
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers pxa2xx_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = pxa2xx_fir_is_empty,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = pxa2xx_fir_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = pxa2xx_fir_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,
|
|
Hans de Goede |
3f1f29 |
qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma,
|
|
Hans de Goede |
3f1f29 |
CharDriverState *chr)
|
|
Hans de Goede |
3f1f29 |
@@ -2038,10 +2044,9 @@ static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,
|
|
Hans de Goede |
3f1f29 |
pxa2xx_fir_writefn, s, DEVICE_NATIVE_ENDIAN);
|
|
Hans de Goede |
3f1f29 |
cpu_register_physical_memory(base, 0x1000, iomemtype);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- if (chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
|
|
Hans de Goede |
3f1f29 |
- pxa2xx_fir_rx, pxa2xx_fir_event, s);
|
|
Hans de Goede |
3f1f29 |
-
|
|
Hans de Goede |
3f1f29 |
+ if (chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &pxa2xx_handlers, s);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
register_savevm(NULL, "pxa2xx_fir", 0, 0, pxa2xx_fir_save,
|
|
Hans de Goede |
3f1f29 |
pxa2xx_fir_load, s);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/serial.c b/hw/serial.c
|
|
Hans de Goede |
3f1f29 |
index 0ee61dd..d496bcf 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/serial.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/serial.c
|
|
Hans de Goede |
3f1f29 |
@@ -727,6 +727,12 @@ static void serial_reset(void *opaque)
|
|
Hans de Goede |
3f1f29 |
qemu_irq_lower(s->irq);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = serial_can_receive1,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = serial_receive1,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static void serial_init_core(SerialState *s)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
if (!s->chr) {
|
|
Hans de Goede |
3f1f29 |
@@ -741,8 +747,7 @@ static void serial_init_core(SerialState *s)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
qemu_register_reset(serial_reset, s);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1,
|
|
Hans de Goede |
3f1f29 |
- serial_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &serial_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
/* Change the main reference oscillator frequency. */
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/sh_serial.c b/hw/sh_serial.c
|
|
Hans de Goede |
3f1f29 |
index 191f4a6..8b6460d 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/sh_serial.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/sh_serial.c
|
|
Hans de Goede |
3f1f29 |
@@ -350,6 +350,12 @@ static CPUWriteMemoryFunc * const sh_serial_writefn[] = {
|
|
Hans de Goede |
3f1f29 |
&sh_serial_write,
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers sh_serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = sh_serial_can_receive1,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = sh_serial_receive1,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = sh_serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
void sh_serial_init (target_phys_addr_t base, int feat,
|
|
Hans de Goede |
3f1f29 |
uint32_t freq, CharDriverState *chr,
|
|
Hans de Goede |
3f1f29 |
qemu_irq eri_source,
|
|
Hans de Goede |
3f1f29 |
@@ -389,9 +395,9 @@ void sh_serial_init (target_phys_addr_t base, int feat,
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->chr = chr;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- if (chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, sh_serial_can_receive1, sh_serial_receive1,
|
|
Hans de Goede |
3f1f29 |
- sh_serial_event, s);
|
|
Hans de Goede |
3f1f29 |
+ if (chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &sh_serial_handlers, s);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->eri = eri_source;
|
|
Hans de Goede |
3f1f29 |
s->rxi = rxi_source;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
|
|
Hans de Goede |
3f1f29 |
index 6fc0105..5968d85 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/spapr_vty.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/spapr_vty.c
|
|
Hans de Goede |
3f1f29 |
@@ -54,12 +54,16 @@ void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len)
|
|
Hans de Goede |
3f1f29 |
qemu_chr_write(dev->chardev, buf, len);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers vty_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = vty_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = vty_receive,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int spapr_vty_init(VIOsPAPRDevice *sdev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(dev->chardev, vty_can_receive,
|
|
Hans de Goede |
3f1f29 |
- vty_receive, NULL, dev);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(dev->chardev, vty_handlers, dev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/strongarm.c b/hw/strongarm.c
|
|
Hans de Goede |
3f1f29 |
index 0e03d61..c2dce95 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/strongarm.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/strongarm.c
|
|
Hans de Goede |
3f1f29 |
@@ -1188,6 +1188,12 @@ static CPUWriteMemoryFunc * const strongarm_uart_writefn[] = {
|
|
Hans de Goede |
3f1f29 |
strongarm_uart_write,
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers strongarm_uart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = strongarm_uart_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = strongarm_uart_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = strongarm_uart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int strongarm_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
StrongARMUARTState *s = FROM_SYSBUS(StrongARMUARTState, dev);
|
|
Hans de Goede |
3f1f29 |
@@ -1202,11 +1208,7 @@ static int strongarm_uart_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
s->tx_timer = qemu_new_timer_ns(vm_clock, strongarm_uart_tx, s);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr,
|
|
Hans de Goede |
3f1f29 |
- strongarm_uart_can_receive,
|
|
Hans de Goede |
3f1f29 |
- strongarm_uart_receive,
|
|
Hans de Goede |
3f1f29 |
- strongarm_uart_event,
|
|
Hans de Goede |
3f1f29 |
- s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &strongarm_uart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/syborg_serial.c b/hw/syborg_serial.c
|
|
Hans de Goede |
3f1f29 |
index 2ef7175..ac68022 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/syborg_serial.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/syborg_serial.c
|
|
Hans de Goede |
3f1f29 |
@@ -292,6 +292,12 @@ static const VMStateDescription vmstate_syborg_serial = {
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers syborg_serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = syborg_serial_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = syborg_serial_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = syborg_serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int syborg_serial_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
SyborgSerialState *s = FROM_SYSBUS(SyborgSerialState, dev);
|
|
Hans de Goede |
3f1f29 |
@@ -304,8 +310,7 @@ static int syborg_serial_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
sysbus_init_mmio(dev, 0x1000, iomemtype);
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, syborg_serial_can_receive,
|
|
Hans de Goede |
3f1f29 |
- syborg_serial_receive, syborg_serial_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &syborg_serial_handlers, s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
if (s->fifo_size <= 0) {
|
|
Hans de Goede |
3f1f29 |
fprintf(stderr, "syborg_serial: fifo too small\n");
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
|
|
Justin M. Forbes |
5e10b1 |
index c69c437..45d48ee 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-serial.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-serial.c
|
|
Hans de Goede |
3f1f29 |
@@ -476,6 +476,12 @@ static void usb_serial_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers usb_serial_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = usb_serial_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = usb_serial_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = usb_serial_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int usb_serial_initfn(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
|
|
Hans de Goede |
3f1f29 |
@@ -487,8 +493,7 @@ static int usb_serial_initfn(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
return -1;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
|
|
Hans de Goede |
3f1f29 |
- usb_serial_event, s);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->cs, &usb_serial_handlers, s);
|
|
Hans de Goede |
3f1f29 |
usb_serial_handle_reset(dev);
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
|
|
Justin M. Forbes |
5e10b1 |
index fe5e188..cfc3087 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/virtio-console.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/virtio-console.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -95,6 +95,12 @@ static void chr_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers chr_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = chr_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = chr_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = chr_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int virtconsole_initfn(VirtIOSerialPort *port)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
|
Justin M. Forbes |
5e10b1 |
@@ -107,8 +113,7 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
if (vcon->chr) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
|
|
Hans de Goede |
3f1f29 |
- vcon);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(vcon->chr, &chr_handlers, vcon);
|
|
Hans de Goede |
3f1f29 |
info->have_data = flush_buf;
|
|
Hans de Goede |
3f1f29 |
info->guest_open = guest_open;
|
|
Hans de Goede |
3f1f29 |
info->guest_close = guest_close;
|
|
Justin M. Forbes |
5e10b1 |
@@ -126,7 +131,7 @@ static int virtconsole_exitfn(VirtIOSerialPort *port)
|
|
Hans de Goede |
3f1f29 |
* Instead of closing the chardev, free it so it can be used
|
|
Hans de Goede |
3f1f29 |
* for other purposes.
|
|
Hans de Goede |
3f1f29 |
*/
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(vcon->chr, NULL, NULL, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(vcon->chr, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/xen_console.c b/hw/xen_console.c
|
|
Justin M. Forbes |
5e10b1 |
index 8ef104c..85e8a22 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/xen_console.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/xen_console.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -212,6 +212,11 @@ out:
|
|
Justin M. Forbes |
5e10b1 |
return ret;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers xencons_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = xencons_can_receive,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = xencons_receive,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int con_connect(struct XenDevice *xendev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
|
|
Justin M. Forbes |
5e10b1 |
@@ -232,9 +237,9 @@ static int con_connect(struct XenDevice *xendev)
|
|
Hans de Goede |
3f1f29 |
return -1;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
xen_be_bind_evtchn(&con->xendev);
|
|
Hans de Goede |
3f1f29 |
- if (con->chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(con->chr, xencons_can_receive, xencons_receive,
|
|
Hans de Goede |
3f1f29 |
- NULL, con);
|
|
Hans de Goede |
3f1f29 |
+ if (con->chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(con->chr, &xencons_handlers, con);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
|
|
Hans de Goede |
3f1f29 |
con->ring_ref,
|
|
Justin M. Forbes |
5e10b1 |
@@ -248,8 +253,9 @@ static void con_disconnect(struct XenDevice *xendev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- if (con->chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
+ if (con->chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(con->chr, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
xen_be_unbind_evtchn(&con->xendev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
if (con->sring) {
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/xilinx_uartlite.c b/hw/xilinx_uartlite.c
|
|
Hans de Goede |
3f1f29 |
index 9b94e98..1845577 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/xilinx_uartlite.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/xilinx_uartlite.c
|
|
Hans de Goede |
3f1f29 |
@@ -193,6 +193,12 @@ static void uart_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers uart_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = uart_can_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = uart_rx,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = uart_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int xilinx_uartlite_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
struct xlx_uartlite *s = FROM_SYSBUS(typeof (*s), dev);
|
|
Hans de Goede |
3f1f29 |
@@ -206,8 +212,9 @@ static int xilinx_uartlite_init(SysBusDevice *dev)
|
|
Hans de Goede |
3f1f29 |
sysbus_init_mmio(dev, R_MAX * 4, uart_regs);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
s->chr = qdev_init_chardev(&dev->qdev);
|
|
Hans de Goede |
3f1f29 |
- if (s->chr)
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
|
Hans de Goede |
3f1f29 |
+ if (s->chr) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(s->chr, &uart_handlers, s);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/monitor.c b/monitor.c
|
|
Justin M. Forbes |
5e10b1 |
index 718935b..5b79dde 100644
|
|
Hans de Goede |
3f1f29 |
--- a/monitor.c
|
|
Hans de Goede |
3f1f29 |
+++ b/monitor.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -5249,6 +5249,18 @@ static void monitor_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
* End:
|
|
Hans de Goede |
3f1f29 |
*/
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers monitor_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = monitor_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = monitor_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = monitor_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers monitor_control_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = monitor_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = monitor_control_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = monitor_control_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
void monitor_init(CharDriverState *chr, int flags)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
static int is_first_init = 1;
|
|
Justin M. Forbes |
5e10b1 |
@@ -5271,12 +5283,10 @@ void monitor_init(CharDriverState *chr, int flags)
|
|
Hans de Goede |
3f1f29 |
if (monitor_ctrl_mode(mon)) {
|
|
Hans de Goede |
3f1f29 |
mon->mc = qemu_mallocz(sizeof(MonitorControl));
|
|
Hans de Goede |
3f1f29 |
/* Control mode requires special handlers */
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_control_read,
|
|
Hans de Goede |
3f1f29 |
- monitor_control_event, mon);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &monitor_control_handlers, mon);
|
|
Hans de Goede |
3f1f29 |
qemu_chr_set_echo(chr, true);
|
|
Hans de Goede |
3f1f29 |
} else {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_read,
|
|
Hans de Goede |
3f1f29 |
- monitor_event, mon);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(chr, &monitor_handlers, mon);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
QLIST_INSERT_HEAD(&mon_list, mon, entry);
|
|
Hans de Goede |
3f1f29 |
diff --git a/net/slirp.c b/net/slirp.c
|
|
Justin M. Forbes |
5e10b1 |
index 157b80a..8eeec7e 100644
|
|
Hans de Goede |
3f1f29 |
--- a/net/slirp.c
|
|
Hans de Goede |
3f1f29 |
+++ b/net/slirp.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -577,6 +577,11 @@ static void guestfwd_read(void *opaque, const uint8_t *buf, int size)
|
|
Hans de Goede |
3f1f29 |
slirp_socket_recv(fwd->slirp, fwd->server, fwd->port, buf, size);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers guestfwd_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = guestfwd_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = guestfwd_read,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
|
Hans de Goede |
3f1f29 |
int legacy_format)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Justin M. Forbes |
5e10b1 |
@@ -633,8 +638,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
|
Hans de Goede |
3f1f29 |
fwd->port = port;
|
|
Hans de Goede |
3f1f29 |
fwd->slirp = s->slirp;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read,
|
|
Hans de Goede |
3f1f29 |
- NULL, fwd);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(fwd->hd, &guestfwd_handlers, fwd);
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
fail_syntax:
|
|
Hans de Goede |
3f1f29 |
diff --git a/qemu-char.c b/qemu-char.c
|
|
Justin M. Forbes |
5e10b1 |
index 1701bdf..1c33828 100644
|
|
Hans de Goede |
3f1f29 |
--- a/qemu-char.c
|
|
Hans de Goede |
3f1f29 |
+++ b/qemu-char.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -195,19 +195,26 @@ void qemu_chr_send_event(CharDriverState *s, int event)
|
|
Hans de Goede |
3f1f29 |
s->chr_send_event(s, event);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers null_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ /* All handlers are initialised to NULL */
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
void qemu_chr_add_handlers(CharDriverState *s,
|
|
Hans de Goede |
3f1f29 |
- IOCanReadHandler *fd_can_read,
|
|
Hans de Goede |
3f1f29 |
- IOReadHandler *fd_read,
|
|
Hans de Goede |
3f1f29 |
- IOEventHandler *fd_event,
|
|
Hans de Goede |
3f1f29 |
- void *opaque)
|
|
Hans de Goede |
3f1f29 |
+ const QemuChrHandlers *handlers, void *opaque)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
- if (!opaque && !fd_can_read && !fd_read && !fd_event) {
|
|
Hans de Goede |
3f1f29 |
+ if (!s) {
|
|
Hans de Goede |
3f1f29 |
+ return;
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
+ if (!opaque && !handlers) {
|
|
Hans de Goede |
3f1f29 |
/* chr driver being released. */
|
|
Hans de Goede |
3f1f29 |
++s->avail_connections;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
- s->chr_can_read = fd_can_read;
|
|
Hans de Goede |
3f1f29 |
- s->chr_read = fd_read;
|
|
Hans de Goede |
3f1f29 |
- s->chr_event = fd_event;
|
|
Hans de Goede |
3f1f29 |
+ if (!handlers) {
|
|
Hans de Goede |
3f1f29 |
+ handlers = &null_handlers;
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
+ s->chr_can_read = handlers->fd_can_read;
|
|
Hans de Goede |
3f1f29 |
+ s->chr_read = handlers->fd_read;
|
|
Hans de Goede |
3f1f29 |
+ s->chr_event = handlers->fd_event;
|
|
Hans de Goede |
3f1f29 |
s->handler_opaque = opaque;
|
|
Hans de Goede |
3f1f29 |
if (s->chr_update_read_handler)
|
|
Hans de Goede |
3f1f29 |
s->chr_update_read_handler(s);
|
|
Justin M. Forbes |
5e10b1 |
@@ -447,6 +454,12 @@ static void mux_chr_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
mux_chr_send_event(d, i, event);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers mux_chr_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = mux_chr_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = mux_chr_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = mux_chr_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static void mux_chr_update_read_handler(CharDriverState *chr)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
MuxDriver *d = chr->opaque;
|
|
Justin M. Forbes |
5e10b1 |
@@ -461,8 +474,7 @@ static void mux_chr_update_read_handler(CharDriverState *chr)
|
|
Hans de Goede |
3f1f29 |
d->chr_event[d->mux_cnt] = chr->chr_event;
|
|
Hans de Goede |
3f1f29 |
/* Fix up the real driver with mux routines */
|
|
Hans de Goede |
3f1f29 |
if (d->mux_cnt == 0) {
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(d->drv, mux_chr_can_read, mux_chr_read,
|
|
Hans de Goede |
3f1f29 |
- mux_chr_event, chr);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(d->drv, &mux_chr_handlers, chr);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
if (d->focus != -1) {
|
|
Hans de Goede |
3f1f29 |
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
|
|
Hans de Goede |
3f1f29 |
diff --git a/qemu-char.h b/qemu-char.h
|
|
Justin M. Forbes |
5e10b1 |
index f361c6d..b8372ea 100644
|
|
Hans de Goede |
3f1f29 |
--- a/qemu-char.h
|
|
Hans de Goede |
3f1f29 |
+++ b/qemu-char.h
|
|
Hans de Goede |
3f1f29 |
@@ -1,6 +1,7 @@
|
|
Hans de Goede |
3f1f29 |
#ifndef QEMU_CHAR_H
|
|
Hans de Goede |
3f1f29 |
#define QEMU_CHAR_H
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+#include <stdbool.h>
|
|
Hans de Goede |
3f1f29 |
#include "qemu-common.h"
|
|
Hans de Goede |
3f1f29 |
#include "qemu-queue.h"
|
|
Hans de Goede |
3f1f29 |
#include "qemu-option.h"
|
|
Justin M. Forbes |
5e10b1 |
@@ -77,6 +78,13 @@ struct CharDriverState {
|
|
Hans de Goede |
3f1f29 |
QTAILQ_ENTRY(CharDriverState) next;
|
|
Hans de Goede |
3f1f29 |
};
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+typedef struct QemuChrHandlers {
|
|
Hans de Goede |
3f1f29 |
+ IOCanReadHandler *fd_can_read;
|
|
Hans de Goede |
3f1f29 |
+ IOReadHandler *fd_read;
|
|
Hans de Goede |
3f1f29 |
+ IOHandler *fd_write_unblocked;
|
|
Hans de Goede |
3f1f29 |
+ IOEventHandler *fd_event;
|
|
Hans de Goede |
3f1f29 |
+} QemuChrHandlers;
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
|
|
Hans de Goede |
3f1f29 |
CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
|
|
Hans de Goede |
3f1f29 |
void (*init)(struct CharDriverState *s));
|
|
Justin M. Forbes |
5e10b1 |
@@ -89,10 +97,7 @@ void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
|
|
Hans de Goede |
3f1f29 |
GCC_FMT_ATTR(2, 3);
|
|
Hans de Goede |
3f1f29 |
int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
|
|
Hans de Goede |
3f1f29 |
void qemu_chr_send_event(CharDriverState *s, int event);
|
|
Hans de Goede |
3f1f29 |
-void qemu_chr_add_handlers(CharDriverState *s,
|
|
Hans de Goede |
3f1f29 |
- IOCanReadHandler *fd_can_read,
|
|
Hans de Goede |
3f1f29 |
- IOReadHandler *fd_read,
|
|
Hans de Goede |
3f1f29 |
- IOEventHandler *fd_event,
|
|
Hans de Goede |
3f1f29 |
+void qemu_chr_add_handlers(CharDriverState *s, const QemuChrHandlers *handlers,
|
|
Hans de Goede |
3f1f29 |
void *opaque);
|
|
Hans de Goede |
3f1f29 |
int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
|
|
Hans de Goede |
3f1f29 |
void qemu_chr_generic_open(CharDriverState *s);
|
|
Hans de Goede |
3f1f29 |
diff --git a/usb-redir.c b/usb-redir.c
|
|
Hans de Goede |
3f1f29 |
index e212993..e2b5a2c 100644
|
|
Hans de Goede |
3f1f29 |
--- a/usb-redir.c
|
|
Hans de Goede |
3f1f29 |
+++ b/usb-redir.c
|
|
Hans de Goede |
3f1f29 |
@@ -782,6 +782,12 @@ static void usbredir_chardev_event(void *opaque, int event)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static const QemuChrHandlers usbredir_chr_handlers = {
|
|
Hans de Goede |
3f1f29 |
+ .fd_can_read = usbredir_chardev_can_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_read = usbredir_chardev_read,
|
|
Hans de Goede |
3f1f29 |
+ .fd_event = usbredir_chardev_event,
|
|
Hans de Goede |
3f1f29 |
+};
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
/*
|
|
Hans de Goede |
3f1f29 |
* init + destroy
|
|
Hans de Goede |
3f1f29 |
*/
|
|
Hans de Goede |
3f1f29 |
@@ -807,8 +813,7 @@ static int usbredir_initfn(USBDevice *udev)
|
|
Hans de Goede |
3f1f29 |
/* We'll do the attach once we receive the speed from the usb-host */
|
|
Hans de Goede |
3f1f29 |
udev->auto_attach = 0;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_add_handlers(dev->cs, usbredir_chardev_can_read,
|
|
Hans de Goede |
3f1f29 |
- usbredir_chardev_read, usbredir_chardev_event, dev);
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_add_handlers(dev->cs, &usbredir_chr_handlers, dev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
--
|
|
Hans de Goede |
3f1f29 |
1.7.5.1
|
|
Hans de Goede |
3f1f29 |
|