aboutsummaryrefslogtreecommitdiff
path: root/hw/input
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2022-06-24 14:41:04 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2022-06-26 18:40:12 +0100
commitcb663a81c1a81adacd3c6201d6b236346c7ea911 (patch)
treed99b0abab727d6f091c43ab3a740c2d2755fb4f4 /hw/input
parent501f062e91ca97dfbeaa5148be59d6a27448c9d8 (diff)
pckbd: switch I8042_MMIO device from update_irq() function to PS2 device gpio
Define a new qdev input gpio for handling incoming PS2 IRQs, and then wire up the PS2 keyboard and mouse devices to use it. At the same time set update_irq() and update_arg to NULL in ps2_kbd_init() and ps2_mouse_init() to ensure that any accidental attempt to use the legacy update_irq() function will cause a NULL pointer dereference. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Helge Deller <deller@gmx.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220624134109.881989-50-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/input')
-rw-r--r--hw/input/pckbd.c38
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);
}