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>
This commit is contained in:
parent
501f062e91
commit
cb663a81c1
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user