[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 36/40] pckbd: don't use legacy ps2_kbd_init() function
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 36/40] pckbd: don't use legacy ps2_kbd_init() function |
Date: |
Wed, 29 Jun 2022 13:40:22 +0100 |
Instantiate the PS2 keyboard 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>
---
hw/input/pckbd.c | 29 +++++++++++++++++++++--------
include/hw/input/i8042.h | 3 ++-
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 195a64f520..cb452f2612 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 : s->kbd, b);
+ ps2_queue(aux ? s->mouse : PS2_DEVICE(&s->ps2kbd), b);
}
}
@@ -408,7 +408,7 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr,
timer_mod(s->throttle_timer,
qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 1000);
}
- s->obdata = ps2_read_data(s->kbd);
+ s->obdata = ps2_read_data(PS2_DEVICE(&s->ps2kbd));
} else if (s->obsrc & KBD_OBSRC_MOUSE) {
s->obdata = ps2_read_data(s->mouse);
} else if (s->obsrc & KBD_OBSRC_CTRL) {
@@ -429,14 +429,15 @@ static void kbd_write_data(void *opaque, hwaddr addr,
switch (s->write_cmd) {
case 0:
- ps2_write_keyboard(s->kbd, val);
+ ps2_write_keyboard(&s->ps2kbd, val);
/* sending data to the keyboard reenables PS/2 communication */
s->mode &= ~KBD_MODE_DISABLE_KBD;
kbd_safe_update_irq(s);
break;
case KBD_CCMD_WRITE_MODE:
s->mode = val;
- ps2_keyboard_set_translation(s->kbd, (s->mode & KBD_MODE_KCC) != 0);
+ ps2_keyboard_set_translation(&s->ps2kbd,
+ (s->mode & KBD_MODE_KCC) != 0);
/*
* a write to the mode byte interrupt enable flags directly updates
* the irq lines
@@ -699,10 +700,14 @@ static void i8042_mmio_realize(DeviceState *dev, Error
**errp)
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->region);
- ks->kbd = ps2_kbd_init();
- qdev_connect_gpio_out(DEVICE(ks->kbd), PS2_DEVICE_IRQ,
+ if (!sysbus_realize(SYS_BUS_DEVICE(&ks->ps2kbd), 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_get_gpio_in_named(dev, "ps2-mouse-input-irq",
@@ -716,6 +721,8 @@ static void i8042_mmio_init(Object *obj)
ks->extended_state = true;
+ object_initialize_child(obj, "ps2kbd", &ks->ps2kbd, TYPE_PS2_KBD_DEVICE);
+
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);
@@ -851,6 +858,8 @@ static void i8042_initfn(Object *obj)
memory_region_init_io(isa_s->io + 1, obj, &i8042_cmd_ops, s,
"i8042-cmd", 1);
+ object_initialize_child(obj, "ps2kbd", &s->ps2kbd, TYPE_PS2_KBD_DEVICE);
+
qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, I8042_A20_LINE, 1);
qdev_init_gpio_out(DEVICE(obj), s->irqs, 2);
@@ -884,10 +893,14 @@ static void i8042_realizefn(DeviceState *dev, Error
**errp)
isa_register_ioport(isadev, isa_s->io + 0, 0x60);
isa_register_ioport(isadev, isa_s->io + 1, 0x64);
- s->kbd = ps2_kbd_init();
- qdev_connect_gpio_out(DEVICE(s->kbd), PS2_DEVICE_IRQ,
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ps2kbd), errp)) {
+ return;
+ }
+
+ qdev_connect_gpio_out(DEVICE(&s->ps2kbd), PS2_DEVICE_IRQ,
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,
qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq",
diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h
index ca933d8e1b..8beb0ac01f 100644
--- a/include/hw/input/i8042.h
+++ b/include/hw/input/i8042.h
@@ -10,6 +10,7 @@
#include "hw/isa/isa.h"
#include "hw/sysbus.h"
+#include "hw/input/ps2.h"
#include "qom/object.h"
#define I8042_KBD_IRQ 0
@@ -30,7 +31,7 @@ typedef struct KBDState {
uint8_t obdata;
uint8_t cbdata;
uint8_t pending_tmp;
- void *kbd;
+ PS2KbdState ps2kbd;
void *mouse;
QEMUTimer *throttle_timer;
--
2.30.2
- [PATCH 26/40] lasips2: add named input gpio to port for downstream PS2 device IRQ, (continued)
- [PATCH 26/40] lasips2: add named input gpio to port for downstream PS2 device IRQ, Mark Cave-Ayland, 2022/06/29
- [PATCH 28/40] lasips2: switch to using port-based IRQs, Mark Cave-Ayland, 2022/06/29
- [PATCH 27/40] lasips2: add named input gpio to handle incoming port IRQs, Mark Cave-Ayland, 2022/06/29
- [PATCH 30/40] lasips2: standardise on lp name for LASIPS2Port variables, Mark Cave-Ayland, 2022/06/29
- [PATCH 29/40] lasips2: rename LASIPS2Port parent pointer to lasips2, Mark Cave-Ayland, 2022/06/29
- [PATCH 32/40] lasips2: don't use legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 31/40] lasips2: switch register memory region to DEVICE_BIG_ENDIAN, Mark Cave-Ayland, 2022/06/29
- [PATCH 35/40] pckbd: introduce new vmstate_kbd_mmio VMStateDescription for the I8042_MMIO device, Mark Cave-Ayland, 2022/06/29
- [PATCH 33/40] lasips2: don't use legacy ps2_mouse_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 34/40] lasips2: update VMStateDescription for LASIPS2 device, Mark Cave-Ayland, 2022/06/29
- [PATCH 36/40] pckbd: don't use legacy ps2_kbd_init() function,
Mark Cave-Ayland <=
- [PATCH 37/40] ps2: remove unused legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 38/40] pckbd: don't use legacy ps2_mouse_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 39/40] ps2: remove unused legacy ps2_mouse_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 40/40] pckbd: remove legacy i8042_mm_init() function, Mark Cave-Ayland, 2022/06/29