[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 47/50] pckbd: switch I8042_MMIO device from update_irq() function
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 47/50] pckbd: switch I8042_MMIO device from update_irq() function to PS2 device gpio |
Date: |
Sun, 22 May 2022 19:18:33 +0100 |
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>
---
hw/input/pckbd.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 90acf0dd6a..d89efddda9 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -665,6 +665,21 @@ static const MemoryRegionOps i8042_mmio_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
+#define I8042_KBD_INPUT_IRQ 0
+#define I8042_MOUSE_INPUT_IRQ 1
+
+static void i8042_mmio_set_irq(void *opaque, int n, int level)
+{
+ MMIOKBDState *s = I8042_MMIO(opaque);
+ KBDState *ks = &s->kbd;
+
+ if (n) {
+ kbd_update_aux_irq(ks, level);
+ } else {
+ kbd_update_kbd_irq(ks, level);
+ }
+}
+
static void i8042_mmio_reset(DeviceState *dev)
{
MMIOKBDState *s = I8042_MMIO(dev);
@@ -685,15 +700,23 @@ 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(dev, I8042_KBD_INPUT_IRQ));
+ ks->mouse = ps2_mouse_init(NULL, NULL);
+ qdev_connect_gpio_out(DEVICE(ks->mouse), PS2_DEVICE_IRQ,
+ qdev_get_gpio_in(dev, I8042_MOUSE_INPUT_IRQ));
}
static void i8042_mmio_init(Object *obj)
{
MMIOKBDState *s = I8042_MMIO(obj);
+ KBDState *ks = &s->kbd;
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region);
+
+ qdev_init_gpio_out(DEVICE(obj), ks->irqs, 2);
+ qdev_init_gpio_in(DEVICE(obj), i8042_mmio_set_irq, 2);
}
static Property i8042_mmio_properties[] = {
@@ -716,16 +739,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);
}
--
2.20.1
- [PATCH 32/50] ps2: use ps2_raise_irq() instead of calling update_irq() directly, (continued)
- [PATCH 32/50] ps2: use ps2_raise_irq() instead of calling update_irq() directly, Mark Cave-Ayland, 2022/05/22
- [PATCH 38/50] lasips2: move lasips2 QOM types from lasips2.c to lasips2.h, Mark Cave-Ayland, 2022/05/22
- [PATCH 41/50] lasips2: move mapping of LASIPS2 registers to HPPA machine, Mark Cave-Ayland, 2022/05/22
- [PATCH 40/50] lasips2: implement lasips2_init() function, Mark Cave-Ayland, 2022/05/22
- [PATCH 42/50] lasips2: move initialisation of PS2 ports from lasi_initfn() to lasi_init(), Mark Cave-Ayland, 2022/05/22
- [PATCH 43/50] lasips2: add base property, Mark Cave-Ayland, 2022/05/22
- [PATCH 48/50] pckbd: add i8042_reset() function to I8042 device, Mark Cave-Ayland, 2022/05/22
- [PATCH 44/50] lasips2: implement lasips2_realize(), Mark Cave-Ayland, 2022/05/22
- [PATCH 45/50] lasips2: use qdev gpio for output IRQ, Mark Cave-Ayland, 2022/05/22
- [PATCH 49/50] pckbd: switch I8042 device from update_irq() function to PS2 device gpio, Mark Cave-Ayland, 2022/05/22
- [PATCH 47/50] pckbd: switch I8042_MMIO device from update_irq() function to PS2 device gpio,
Mark Cave-Ayland <=
- [PATCH 46/50] lasips2: switch over from update_irq() function to PS2 device gpio, Mark Cave-Ayland, 2022/05/22
- [PATCH 50/50] ps2: remove update_irq() function and update_arg parameter, Mark Cave-Ayland, 2022/05/22
- Re: [PATCH 00/50] PS2 device QOMification - part 1, Philippe Mathieu-Daudé, 2022/05/22
- Re: [PATCH 00/50] PS2 device QOMification - part 1, Helge Deller, 2022/05/24