diff options
-rw-r--r-- | hw/input/pckbd.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 5d7c969fc6..ee306428a3 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -665,6 +665,22 @@ static const MemoryRegionOps i8042_mmio_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static void i8042_mmio_set_kbd_irq(void *opaque, int n, int level) +{ + MMIOKBDState *s = I8042_MMIO(opaque); + KBDState *ks = &s->kbd; + + kbd_update_kbd_irq(ks, level); +} + +static void i8042_mmio_set_mouse_irq(void *opaque, int n, int level) +{ + MMIOKBDState *s = I8042_MMIO(opaque); + KBDState *ks = &s->kbd; + + kbd_update_aux_irq(ks, level); +} + static void i8042_mmio_reset(DeviceState *dev) { MMIOKBDState *s = I8042_MMIO(dev); @@ -686,8 +702,14 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp) /* Note we can't use dc->vmsd without breaking migration compatibility */ vmstate_register(NULL, 0, &vmstate_kbd, ks); - ks->kbd = ps2_kbd_init(kbd_update_kbd_irq, ks); - ks->mouse = ps2_mouse_init(kbd_update_aux_irq, ks); + ks->kbd = ps2_kbd_init(NULL, NULL); + qdev_connect_gpio_out(DEVICE(ks->kbd), PS2_DEVICE_IRQ, + qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq", + 0)); + ks->mouse = ps2_mouse_init(NULL, NULL); + qdev_connect_gpio_out(DEVICE(ks->mouse), PS2_DEVICE_IRQ, + qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq", + 0)); } static void i8042_mmio_init(Object *obj) @@ -696,6 +718,12 @@ static void i8042_mmio_init(Object *obj) KBDState *ks = &s->kbd; ks->extended_state = true; + + qdev_init_gpio_out(DEVICE(obj), ks->irqs, 2); + qdev_init_gpio_in_named(DEVICE(obj), i8042_mmio_set_kbd_irq, + "ps2-kbd-input-irq", 1); + qdev_init_gpio_in_named(DEVICE(obj), i8042_mmio_set_mouse_irq, + "ps2-mouse-input-irq", 1); } static Property i8042_mmio_properties[] = { @@ -718,16 +746,14 @@ MMIOKBDState *i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, ram_addr_t size, hwaddr mask) { DeviceState *dev; - KBDState *s; dev = qdev_new(TYPE_I8042_MMIO); qdev_prop_set_uint64(dev, "mask", mask); qdev_prop_set_uint32(dev, "size", size); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - s = &I8042_MMIO(dev)->kbd; - s->irqs[I8042_KBD_IRQ] = kbd_irq; - s->irqs[I8042_MOUSE_IRQ] = mouse_irq; + qdev_connect_gpio_out(dev, I8042_KBD_IRQ, kbd_irq); + qdev_connect_gpio_out(dev, I8042_MOUSE_IRQ, mouse_irq); return I8042_MMIO(dev); } |