mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
pckbd: switch I8042 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-53-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
parent
55870d6f27
commit
6eb252d50c
|
@ -808,6 +808,23 @@ static const MemoryRegionOps i8042_cmd_ops = {
|
|||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
static void i8042_set_kbd_irq(void *opaque, int n, int level)
|
||||
{
|
||||
ISAKBDState *s = I8042(opaque);
|
||||
KBDState *ks = &s->kbd;
|
||||
|
||||
kbd_update_kbd_irq(ks, level);
|
||||
}
|
||||
|
||||
static void i8042_set_mouse_irq(void *opaque, int n, int level)
|
||||
{
|
||||
ISAKBDState *s = I8042(opaque);
|
||||
KBDState *ks = &s->kbd;
|
||||
|
||||
kbd_update_aux_irq(ks, level);
|
||||
}
|
||||
|
||||
|
||||
static void i8042_reset(DeviceState *dev)
|
||||
{
|
||||
ISAKBDState *s = I8042(dev);
|
||||
|
@ -827,6 +844,12 @@ static void i8042_initfn(Object *obj)
|
|||
"i8042-cmd", 1);
|
||||
|
||||
qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, I8042_A20_LINE, 1);
|
||||
|
||||
qdev_init_gpio_out(DEVICE(obj), s->irqs, 2);
|
||||
qdev_init_gpio_in_named(DEVICE(obj), i8042_set_kbd_irq,
|
||||
"ps2-kbd-input-irq", 1);
|
||||
qdev_init_gpio_in_named(DEVICE(obj), i8042_set_mouse_irq,
|
||||
"ps2-mouse-input-irq", 1);
|
||||
}
|
||||
|
||||
static void i8042_realizefn(DeviceState *dev, Error **errp)
|
||||
|
@ -847,14 +870,20 @@ static void i8042_realizefn(DeviceState *dev, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
s->irqs[I8042_KBD_IRQ] = isa_get_irq(isadev, isa_s->kbd_irq);
|
||||
s->irqs[I8042_MOUSE_IRQ] = isa_get_irq(isadev, isa_s->mouse_irq);
|
||||
isa_connect_gpio_out(isadev, I8042_KBD_IRQ, isa_s->kbd_irq);
|
||||
isa_connect_gpio_out(isadev, I8042_MOUSE_IRQ, isa_s->mouse_irq);
|
||||
|
||||
isa_register_ioport(isadev, isa_s->io + 0, 0x60);
|
||||
isa_register_ioport(isadev, isa_s->io + 1, 0x64);
|
||||
|
||||
s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
|
||||
s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
|
||||
s->kbd = ps2_kbd_init(NULL, NULL);
|
||||
qdev_connect_gpio_out(DEVICE(s->kbd), PS2_DEVICE_IRQ,
|
||||
qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq",
|
||||
0));
|
||||
s->mouse = ps2_mouse_init(NULL, NULL);
|
||||
qdev_connect_gpio_out(DEVICE(s->mouse), PS2_DEVICE_IRQ,
|
||||
qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq",
|
||||
0));
|
||||
if (isa_s->kbd_throttle && !isa_s->kbd.extended_state) {
|
||||
warn_report(TYPE_I8042 ": can't enable kbd-throttle without"
|
||||
" extended-state, disabling kbd-throttle");
|
||||
|
|
Loading…
Reference in a new issue