[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 20/40] lasips2: move mouse port initialisation to new lasips2_mou
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 20/40] lasips2: move mouse port initialisation to new lasips2_mouse_port_init() function |
Date: |
Wed, 29 Jun 2022 13:40:06 +0100 |
Move the initialisation of the mouse port from lasips2_init() to
a new lasips2_mouse_port_init() function which will be invoked using
object_initialize_child() during the LASIPS2 device init.
Update LASIPS2State so that it now holds the new LASIPS2MousePort child object
and
ensure that it is realised in lasips2_realize().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/input/lasips2.c | 52 +++++++++++++++++++++++++-------------
include/hw/input/lasips2.h | 2 +-
2 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index 74427c9990..9535cab268 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -43,9 +43,9 @@ static const VMStateDescription vmstate_lasips2 = {
VMSTATE_UINT8(kbd_port.parent_obj.control, LASIPS2State),
VMSTATE_UINT8(kbd_port.parent_obj.id, LASIPS2State),
VMSTATE_BOOL(kbd_port.parent_obj.irq, LASIPS2State),
- VMSTATE_UINT8(mouse.control, LASIPS2State),
- VMSTATE_UINT8(mouse.id, LASIPS2State),
- VMSTATE_BOOL(mouse.irq, LASIPS2State),
+ VMSTATE_UINT8(mouse_port.parent_obj.control, LASIPS2State),
+ VMSTATE_UINT8(mouse_port.parent_obj.id, LASIPS2State),
+ VMSTATE_BOOL(mouse_port.parent_obj.irq, LASIPS2State),
VMSTATE_END_OF_LIST()
}
};
@@ -119,8 +119,10 @@ static const char *lasips2_write_reg_name(uint64_t addr)
static void lasips2_update_irq(LASIPS2State *s)
{
- trace_lasips2_intr(s->kbd_port.parent_obj.irq | s->mouse.irq);
- qemu_set_irq(s->irq, s->kbd_port.parent_obj.irq | s->mouse.irq);
+ trace_lasips2_intr(s->kbd_port.parent_obj.irq |
+ s->mouse_port.parent_obj.irq);
+ qemu_set_irq(s->irq, s->kbd_port.parent_obj.irq |
+ s->mouse_port.parent_obj.irq);
}
static void lasips2_reg_write(void *opaque, hwaddr addr, uint64_t val,
@@ -211,8 +213,9 @@ static uint64_t lasips2_reg_read(void *opaque, hwaddr addr,
unsigned size)
}
}
- if (port->parent->kbd_port.parent_obj.irq || port->parent->mouse.irq) {
- ret |= LASIPS2_STATUS_CMPINTR;
+ if (port->parent->kbd_port.parent_obj.irq ||
+ port->parent->mouse_port.parent_obj.irq) {
+ ret |= LASIPS2_STATUS_CMPINTR;
}
break;
@@ -249,7 +252,7 @@ static void lasips2_set_kbd_irq(void *opaque, int n, int
level)
static void lasips2_set_mouse_irq(void *opaque, int n, int level)
{
LASIPS2State *s = LASIPS2(opaque);
- LASIPS2Port *port = &s->mouse;
+ LASIPS2Port *port = LASIPS2_PORT(&s->mouse_port);
port->irq = level;
lasips2_update_irq(port->parent);
@@ -269,8 +272,14 @@ static void lasips2_realize(DeviceState *dev, Error **errp)
qdev_connect_gpio_out(DEVICE(lp->ps2dev), PS2_DEVICE_IRQ,
qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq",
0));
- s->mouse.ps2dev = ps2_mouse_init();
- qdev_connect_gpio_out(DEVICE(s->mouse.ps2dev), PS2_DEVICE_IRQ,
+
+ lp = LASIPS2_PORT(&s->mouse_port);
+ if (!(qdev_realize(DEVICE(lp), NULL, errp))) {
+ return;
+ }
+
+ lp->ps2dev = ps2_mouse_init();
+ qdev_connect_gpio_out(DEVICE(lp->ps2dev), PS2_DEVICE_IRQ,
qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq",
0));
}
@@ -282,16 +291,13 @@ static void lasips2_init(Object *obj)
object_initialize_child(obj, "lasips2-kbd-port", &s->kbd_port,
TYPE_LASIPS2_KBD_PORT);
-
- s->mouse.id = 1;
- s->mouse.parent = s;
-
- memory_region_init_io(&s->mouse.reg, obj, &lasips2_reg_ops, &s->mouse,
- "lasips2-mouse", 0x100);
+ object_initialize_child(obj, "lasips2-mouse-port", &s->mouse_port,
+ TYPE_LASIPS2_MOUSE_PORT);
lp = LASIPS2_PORT(&s->kbd_port);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &lp->reg);
- sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mouse.reg);
+ lp = LASIPS2_PORT(&s->mouse_port);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &lp->reg);
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
@@ -343,10 +349,22 @@ static const TypeInfo lasips2_kbd_port_info = {
.instance_init = lasips2_kbd_port_init,
};
+static void lasips2_mouse_port_init(Object *obj)
+{
+ LASIPS2MousePort *s = LASIPS2_MOUSE_PORT(obj);
+ LASIPS2Port *lp = LASIPS2_PORT(obj);
+
+ memory_region_init_io(&lp->reg, obj, &lasips2_reg_ops, lp, "lasips2-mouse",
+ 0x100);
+ lp->id = 1;
+ lp->parent = container_of(s, LASIPS2State, mouse_port);
+}
+
static const TypeInfo lasips2_mouse_port_info = {
.name = TYPE_LASIPS2_MOUSE_PORT,
.parent = TYPE_LASIPS2_PORT,
.instance_size = sizeof(LASIPS2MousePort),
+ .instance_init = lasips2_mouse_port_init,
};
static void lasips2_register_types(void)
diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
index f728f54c78..84807bec36 100644
--- a/include/hw/input/lasips2.h
+++ b/include/hw/input/lasips2.h
@@ -61,7 +61,7 @@ struct LASIPS2State {
SysBusDevice parent_obj;
LASIPS2KbdPort kbd_port;
- LASIPS2Port mouse;
+ LASIPS2MousePort mouse_port;
qemu_irq irq;
};
--
2.30.2
- [PATCH 09/40] pl050: introduce pl050_mouse_class_init() and pl050_mouse_realize(), (continued)
- [PATCH 09/40] pl050: introduce pl050_mouse_class_init() and pl050_mouse_realize(), Mark Cave-Ayland, 2022/06/29
- [PATCH 12/40] lasips2: don't use vmstate_register() in lasips2_realize(), Mark Cave-Ayland, 2022/06/29
- [PATCH 13/40] lasips2: remove the qdev base property and the lasips2_properties array, Mark Cave-Ayland, 2022/06/29
- [PATCH 14/40] lasips2: remove legacy lasips2_initfn() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 15/40] lasips2: change LASIPS2State dev pointer from void to PS2State, Mark Cave-Ayland, 2022/06/29
- [PATCH 10/40] pl050: don't use legacy ps2_kbd_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 16/40] lasips2: QOMify LASIPS2Port, Mark Cave-Ayland, 2022/06/29
- [PATCH 17/40] lasips2: introduce new LASIPS2_KBD_PORT QOM type, Mark Cave-Ayland, 2022/06/29
- [PATCH 19/40] lasips2: move keyboard port initialisation to new lasips2_kbd_port_init() function, Mark Cave-Ayland, 2022/06/29
- [PATCH 18/40] lasips2: introduce new LASIPS2_MOUSE_PORT QOM type, Mark Cave-Ayland, 2022/06/29
- [PATCH 20/40] lasips2: move mouse port initialisation to new lasips2_mouse_port_init() function,
Mark Cave-Ayland <=
- [PATCH 21/40] lasips2: introduce lasips2_kbd_port_class_init() and lasips2_kbd_port_realize(), Mark Cave-Ayland, 2022/06/29
- [PATCH 23/40] lasips2: rename LASIPS2Port irq field to birq, Mark Cave-Ayland, 2022/06/29
- [PATCH 22/40] lasips2: introduce lasips2_mouse_port_class_init() and lasips2_mouse_port_realize(), Mark Cave-Ayland, 2022/06/29
- [PATCH 25/40] lasips2: introduce LASIPS2PortDeviceClass for the LASIPS2_PORT device, Mark Cave-Ayland, 2022/06/29
- [PATCH 24/40] lasips2: introduce port IRQ and new lasips2_port_init() function, Mark Cave-Ayland, 2022/06/29
- [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