[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 38/40] pckbd: don't use legacy ps2_mouse_init() function
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 38/40] pckbd: don't use legacy ps2_mouse_init() function |
Date: |
Tue, 12 Jul 2022 22:52:49 +0100 |
Instantiate the PS2 mouse device within KBDState using
object_initialize_child() in i8042_initfn() and i8042_mmio_init() and realize
it in i8042_realizefn() and i8042_mmio_realize() accordingly.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Helge Deller <deller@gmx.de>
Acked-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/input/pckbd.c | 27 +++++++++++++++++++--------
include/hw/input/i8042.h | 2 +-
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index cb452f2612..0fc1af403e 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -286,7 +286,7 @@ static void kbd_queue(KBDState *s, int b, int aux)
s->pending |= aux ? KBD_PENDING_CTRL_AUX : KBD_PENDING_CTRL_KBD;
kbd_safe_update_irq(s);
} else {
- ps2_queue(aux ? s->mouse : PS2_DEVICE(&s->ps2kbd), b);
+ ps2_queue(aux ? PS2_DEVICE(&s->ps2mouse) : PS2_DEVICE(&s->ps2kbd), b);
}
}
@@ -410,7 +410,7 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr,
}
s->obdata = ps2_read_data(PS2_DEVICE(&s->ps2kbd));
} else if (s->obsrc & KBD_OBSRC_MOUSE) {
- s->obdata = ps2_read_data(s->mouse);
+ s->obdata = ps2_read_data(PS2_DEVICE(&s->ps2mouse));
} else if (s->obsrc & KBD_OBSRC_CTRL) {
s->obdata = kbd_dequeue(s);
}
@@ -459,7 +459,7 @@ static void kbd_write_data(void *opaque, hwaddr addr,
outport_write(s, val);
break;
case KBD_CCMD_WRITE_MOUSE:
- ps2_write_mouse(s->mouse, val);
+ ps2_write_mouse(&s->ps2mouse, val);
/* sending data to the mouse reenables PS/2 communication */
s->mode &= ~KBD_MODE_DISABLE_MOUSE;
kbd_safe_update_irq(s);
@@ -704,12 +704,15 @@ static void i8042_mmio_realize(DeviceState *dev, Error
**errp)
return;
}
+ if (!sysbus_realize(SYS_BUS_DEVICE(&ks->ps2mouse), errp)) {
+ return;
+ }
+
qdev_connect_gpio_out(DEVICE(&ks->ps2kbd), PS2_DEVICE_IRQ,
qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq",
0));
- ks->mouse = ps2_mouse_init();
- qdev_connect_gpio_out(DEVICE(ks->mouse), PS2_DEVICE_IRQ,
+ qdev_connect_gpio_out(DEVICE(&ks->ps2mouse), PS2_DEVICE_IRQ,
qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq",
0));
}
@@ -722,6 +725,8 @@ static void i8042_mmio_init(Object *obj)
ks->extended_state = true;
object_initialize_child(obj, "ps2kbd", &ks->ps2kbd, TYPE_PS2_KBD_DEVICE);
+ object_initialize_child(obj, "ps2mouse", &ks->ps2mouse,
+ TYPE_PS2_MOUSE_DEVICE);
qdev_init_gpio_out(DEVICE(obj), ks->irqs, 2);
qdev_init_gpio_in_named(DEVICE(obj), i8042_mmio_set_kbd_irq,
@@ -785,7 +790,7 @@ void i8042_isa_mouse_fake_event(ISAKBDState *isa)
{
KBDState *s = &isa->kbd;
- ps2_mouse_fake_event(s->mouse);
+ ps2_mouse_fake_event(&s->ps2mouse);
}
void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out)
@@ -859,6 +864,8 @@ static void i8042_initfn(Object *obj)
"i8042-cmd", 1);
object_initialize_child(obj, "ps2kbd", &s->ps2kbd, TYPE_PS2_KBD_DEVICE);
+ object_initialize_child(obj, "ps2mouse", &s->ps2mouse,
+ TYPE_PS2_MOUSE_DEVICE);
qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, I8042_A20_LINE, 1);
@@ -901,10 +908,14 @@ static void i8042_realizefn(DeviceState *dev, Error
**errp)
qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq",
0));
- s->mouse = ps2_mouse_init();
- qdev_connect_gpio_out(DEVICE(s->mouse), PS2_DEVICE_IRQ,
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ps2mouse), errp)) {
+ return;
+ }
+
+ qdev_connect_gpio_out(DEVICE(&s->ps2mouse), 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");
diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h
index 8beb0ac01f..e199f1ece8 100644
--- a/include/hw/input/i8042.h
+++ b/include/hw/input/i8042.h
@@ -32,7 +32,7 @@ typedef struct KBDState {
uint8_t cbdata;
uint8_t pending_tmp;
PS2KbdState ps2kbd;
- void *mouse;
+ PS2MouseState ps2mouse;
QEMUTimer *throttle_timer;
qemu_irq irqs[2];
--
2.30.2
- [PATCH v2 29/40] lasips2: rename LASIPS2Port parent pointer to lasips2, (continued)
- [PATCH v2 29/40] lasips2: rename LASIPS2Port parent pointer to lasips2, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 30/40] lasips2: standardise on lp name for LASIPS2Port variables, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 32/40] lasips2: don't use legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 31/40] lasips2: switch register memory region to DEVICE_BIG_ENDIAN, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 33/40] lasips2: don't use legacy ps2_mouse_init() function, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 34/40] lasips2: update VMStateDescription for LASIPS2 device, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 35/40] pckbd: introduce new vmstate_kbd_mmio VMStateDescription for the I8042_MMIO device, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 36/40] pckbd: don't use legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 39/40] ps2: remove unused legacy ps2_mouse_init() function, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 37/40] ps2: remove unused legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/07/12
- [PATCH v2 38/40] pckbd: don't use legacy ps2_mouse_init() function,
Mark Cave-Ayland <=
- [PATCH v2 40/40] pckbd: remove legacy i8042_mm_init() function, Mark Cave-Ayland, 2022/07/12
- Re: [PATCH v2 00/40] PS2 device QOMification - part 2, Philippe Mathieu-Daudé, 2022/07/12
- Re: [PATCH v2 00/40] PS2 device QOMification - part 2, Mark Cave-Ayland, 2022/07/18