[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 49/50] pckbd: switch I8042 device from update_irq() function to P
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 49/50] pckbd: switch I8042 device from update_irq() function to PS2 device gpio |
Date: |
Sun, 22 May 2022 19:18:35 +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 | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index b2fdd1c999..f1eeab9952 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -801,6 +801,18 @@ static const MemoryRegionOps i8042_cmd_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
+static void i8042_set_irq(void *opaque, int n, int level)
+{
+ ISAKBDState *s = I8042(opaque);
+ KBDState *ks = &s->kbd;
+
+ if (n) {
+ kbd_update_aux_irq(ks, level);
+ } else {
+ kbd_update_kbd_irq(ks, level);
+ }
+}
+
static void i8042_reset(DeviceState *dev)
{
ISAKBDState *s = I8042(dev);
@@ -820,6 +832,9 @@ 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(DEVICE(obj), i8042_set_irq, 2);
}
static void i8042_realizefn(DeviceState *dev, Error **errp)
@@ -840,14 +855,18 @@ 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(dev, I8042_KBD_INPUT_IRQ));
+ s->mouse = ps2_mouse_init(NULL, NULL);
+ qdev_connect_gpio_out(DEVICE(s->mouse), PS2_DEVICE_IRQ,
+ qdev_get_gpio_in(dev, I8042_MOUSE_INPUT_IRQ));
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");
--
2.20.1
- [PATCH 37/50] lasips2: QOMify LASIPS2State, (continued)
- [PATCH 37/50] lasips2: QOMify LASIPS2State, Mark Cave-Ayland, 2022/05/22
- [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 <=
- [PATCH 47/50] pckbd: switch I8042_MMIO device from update_irq() function to PS2 device gpio, Mark Cave-Ayland, 2022/05/22
- [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