#include "qemu/osdep.h"
#include "hw/ipack/ipack.h"
+#include "hw/irq.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
#include "qemu/bitops.h"
-#include "sysemu/char.h"
+#include "qemu/module.h"
+#include "chardev/char-fe.h"
/* #define DEBUG_IPOCTAL */
struct SCC2698Channel {
IPOctalState *ipoctal;
- CharDriverState *dev;
+ CharBackend dev;
bool rx_enabled;
uint8_t mr[2];
uint8_t mr_idx;
if (ch->rx_pending == 0) {
ch->sr &= ~SR_RXRDY;
blk->isr &= ~ISR_RXRDY(channel);
- if (ch->dev) {
- qemu_chr_accept_input(ch->dev);
- }
+ qemu_chr_fe_accept_input(&ch->dev);
} else {
ch->rhr_idx = (ch->rhr_idx + 1) % RX_FIFO_SIZE;
}
case REG_THRa:
case REG_THRb:
if (ch->sr & SR_TXRDY) {
+ uint8_t thr = reg;
DPRINTF("Write THR%c (0x%x)\n", channel + 'a', reg);
- if (ch->dev) {
- uint8_t thr = reg;
- /* XXX this blocks entire thread. Rewrite to use
- * qemu_chr_fe_write and background I/O callbacks */
- qemu_chr_fe_write_all(ch->dev, &thr, 1);
- }
+ /* XXX this blocks entire thread. Rewrite to use
+ * qemu_chr_fe_write and background I/O callbacks */
+ qemu_chr_fe_write_all(&ch->dev, &thr, 1);
} else {
DPRINTF("Write THR%c (0x%x), Tx disabled\n", channel + 'a', reg);
}
}
}
-static void hostdev_event(void *opaque, int event)
+static void hostdev_event(void *opaque, QEMUChrEvent event)
{
SCC2698Channel *ch = opaque;
switch (event) {
ch->ipoctal = s;
/* Redirect IP-Octal channels to host character devices */
- if (ch->dev) {
- qemu_chr_add_handlers(ch->dev, hostdev_can_receive,
- hostdev_receive, hostdev_event, ch);
+ if (qemu_chr_fe_backend_connected(&ch->dev)) {
+ qemu_chr_fe_set_handlers(&ch->dev, hostdev_can_receive,
+ hostdev_receive, hostdev_event,
+ NULL, ch, NULL, true);
DPRINTF("Redirecting channel %u to %s\n", i, ch->dev->label);
} else {
DPRINTF("Could not redirect channel %u, no chardev set\n", i);
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
dc->desc = "GE IP-Octal 232 8-channel RS-232 IndustryPack";
- dc->props = ipoctal_properties;
+ device_class_set_props(dc, ipoctal_properties);
dc->vmsd = &vmstate_ipoctal;
}