* [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2
@ 2021-09-20 6:40 Philippe Mathieu-Daudé
2021-09-20 6:40 ` [PATCH 1/3] hw/input/lasips2: Fix typos in function names Philippe Mathieu-Daudé
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-20 6:40 UTC (permalink / raw)
To: qemu-devel
Cc: Sven Schnelle, Helge Deller, Richard Henderson,
Philippe Mathieu-Daudé
Slowly nuking non-QOM devices: Lasi PS/2's turn.
Philippe Mathieu-Daudé (3):
hw/input/lasips2: Fix typos in function names
hw/input/lasips2: Move LASIPS2State declaration to
'hw/input/lasips2.h'
hw/input/lasips2: QOM'ify the Lasi PS/2
include/hw/input/lasips2.h | 31 ++++++++++++++++--
hw/hppa/lasi.c | 10 +++++-
hw/input/lasips2.c | 64 +++++++++++++++++++-------------------
3 files changed, 70 insertions(+), 35 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] hw/input/lasips2: Fix typos in function names
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
@ 2021-09-20 6:40 ` Philippe Mathieu-Daudé
2021-09-29 14:24 ` Damien Hedde
2021-09-20 6:40 ` [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h' Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-20 6:40 UTC (permalink / raw)
To: qemu-devel
Cc: Sven Schnelle, Helge Deller, Richard Henderson,
Philippe Mathieu-Daudé
Artist is another device, this one is the Lasi PS/2.
Rename the functions accordingly.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/input/lasips2.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index e7faf24058b..68d741d3421 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -96,7 +96,7 @@ typedef enum {
LASIPS2_STATUS_CLKSHD = 0x80,
} lasips2_status_reg_t;
-static const char *artist_read_reg_name(uint64_t addr)
+static const char *lasips2_read_reg_name(uint64_t addr)
{
switch (addr & 0xc) {
case REG_PS2_ID:
@@ -116,7 +116,7 @@ static const char *artist_read_reg_name(uint64_t addr)
}
}
-static const char *artist_write_reg_name(uint64_t addr)
+static const char *lasips2_write_reg_name(uint64_t addr)
{
switch (addr & 0x0c) {
case REG_PS2_RESET:
@@ -145,7 +145,7 @@ static void lasips2_reg_write(void *opaque, hwaddr addr, uint64_t val,
LASIPS2Port *port = opaque;
trace_lasips2_reg_write(size, port->id, addr,
- artist_write_reg_name(addr), val);
+ lasips2_write_reg_name(addr), val);
switch (addr & 0xc) {
case REG_PS2_CONTROL:
@@ -239,7 +239,7 @@ static uint64_t lasips2_reg_read(void *opaque, hwaddr addr, unsigned size)
break;
}
trace_lasips2_reg_read(size, port->id, addr,
- artist_read_reg_name(addr), ret);
+ lasips2_read_reg_name(addr), ret);
return ret;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h'
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
2021-09-20 6:40 ` [PATCH 1/3] hw/input/lasips2: Fix typos in function names Philippe Mathieu-Daudé
@ 2021-09-20 6:40 ` Philippe Mathieu-Daudé
2021-09-29 14:27 ` Damien Hedde
2021-09-20 6:40 ` [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-20 6:40 UTC (permalink / raw)
To: qemu-devel
Cc: Sven Schnelle, Helge Deller, Richard Henderson,
Philippe Mathieu-Daudé
We want to use the OBJECT_DECLARE_SIMPLE_TYPE() macro to QOM'ify
this device in the next commit. To make its review simpler, as a
first step move the LASIPS2State and LASIPS2Port declarations to
'hw/input/lasips2.h'
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/input/lasips2.h | 18 ++++++++++++++++++
hw/input/lasips2.c | 18 ------------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
index 0cd7b59064a..c88f1700162 100644
--- a/include/hw/input/lasips2.h
+++ b/include/hw/input/lasips2.h
@@ -11,6 +11,24 @@
#define TYPE_LASIPS2 "lasips2"
+struct LASIPS2State;
+typedef struct LASIPS2Port {
+ struct LASIPS2State *parent;
+ MemoryRegion reg;
+ void *dev;
+ uint8_t id;
+ uint8_t control;
+ uint8_t buf;
+ bool loopback_rbne;
+ bool irq;
+} LASIPS2Port;
+
+typedef struct LASIPS2State {
+ LASIPS2Port kbd;
+ LASIPS2Port mouse;
+ qemu_irq irq;
+} LASIPS2State;
+
void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq);
#endif /* HW_INPUT_LASIPS2_H */
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index 68d741d3421..0f8362f17bc 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -33,24 +33,6 @@
#include "hw/irq.h"
-struct LASIPS2State;
-typedef struct LASIPS2Port {
- struct LASIPS2State *parent;
- MemoryRegion reg;
- void *dev;
- uint8_t id;
- uint8_t control;
- uint8_t buf;
- bool loopback_rbne;
- bool irq;
-} LASIPS2Port;
-
-typedef struct LASIPS2State {
- LASIPS2Port kbd;
- LASIPS2Port mouse;
- qemu_irq irq;
-} LASIPS2State;
-
static const VMStateDescription vmstate_lasips2 = {
.name = "lasips2",
.version_id = 0,
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
2021-09-20 6:40 ` [PATCH 1/3] hw/input/lasips2: Fix typos in function names Philippe Mathieu-Daudé
2021-09-20 6:40 ` [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h' Philippe Mathieu-Daudé
@ 2021-09-20 6:40 ` Philippe Mathieu-Daudé
2021-09-29 14:33 ` Damien Hedde
2021-09-29 14:06 ` [PATCH 0/3] " Philippe Mathieu-Daudé
2021-10-27 5:11 ` Philippe Mathieu-Daudé
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-20 6:40 UTC (permalink / raw)
To: qemu-devel
Cc: Sven Schnelle, Helge Deller, Richard Henderson,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/input/lasips2.h | 17 +++++++++++++----
hw/hppa/lasi.c | 10 +++++++++-
hw/input/lasips2.c | 38 ++++++++++++++++++++++++++++----------
3 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
index c88f1700162..834b6d867d9 100644
--- a/include/hw/input/lasips2.h
+++ b/include/hw/input/lasips2.h
@@ -7,11 +7,11 @@
#ifndef HW_INPUT_LASIPS2_H
#define HW_INPUT_LASIPS2_H
-#include "exec/hwaddr.h"
+#include "hw/sysbus.h"
#define TYPE_LASIPS2 "lasips2"
+OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2)
-struct LASIPS2State;
typedef struct LASIPS2Port {
struct LASIPS2State *parent;
MemoryRegion reg;
@@ -23,12 +23,21 @@ typedef struct LASIPS2Port {
bool irq;
} LASIPS2Port;
+/*
+ * QEMU interface:
+ * + sysbus MMIO region 0 is the keyboard port interface
+ * + sysbus MMIO region 1 is the mouse port interface
+ * + sysbus IRQ 0 is the interrupt line shared between
+ * keyboard and mouse ports
+ */
typedef struct LASIPS2State {
+ /*< private >*/
+ SysBusDevice parent_obj;
+
+ /*< public >*/
LASIPS2Port kbd;
LASIPS2Port mouse;
qemu_irq irq;
} LASIPS2State;
-void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq);
-
#endif /* HW_INPUT_LASIPS2_H */
diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 88c3791eb68..91414748b70 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -297,6 +297,7 @@ static int lasi_get_irq(unsigned long hpa)
DeviceState *lasi_init(MemoryRegion *address_space)
{
DeviceState *dev;
+ SysBusDevice *sbd;
LasiState *s;
dev = qdev_new(TYPE_LASI_CHIP);
@@ -340,7 +341,14 @@ DeviceState *lasi_init(MemoryRegion *address_space)
/* PS/2 Keyboard/Mouse */
qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s,
lasi_get_irq(LASI_PS2KBD_HPA));
- lasips2_init(address_space, LASI_PS2KBD_HPA, ps2kbd_irq);
+
+ sbd = SYS_BUS_DEVICE(qdev_new(TYPE_LASIPS2));
+ sysbus_realize_and_unref(sbd, &error_fatal);
+ memory_region_add_subregion(address_space, LASI_PS2KBD_HPA,
+ sysbus_mmio_get_region(sbd, 0));
+ memory_region_add_subregion(address_space, LASI_PS2MOU_HPA,
+ sysbus_mmio_get_region(sbd, 1));
+ sysbus_connect_irq(sbd, 0, ps2kbd_irq);
return dev;
}
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index 0f8362f17bc..46cd32316da 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -243,28 +243,46 @@ static void ps2dev_update_irq(void *opaque, int level)
lasips2_update_irq(port->parent);
}
-void lasips2_init(MemoryRegion *address_space,
- hwaddr base, qemu_irq irq)
+static void lasips2_init(Object *obj)
{
- LASIPS2State *s;
+ LASIPS2State *s = LASIPS2(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- s = g_malloc0(sizeof(LASIPS2State));
-
- s->irq = irq;
+ sysbus_init_irq(sbd, &s->irq);
s->mouse.id = 1;
s->kbd.parent = s;
s->mouse.parent = s;
- vmstate_register(NULL, base, &vmstate_lasips2, s);
-
s->kbd.dev = ps2_kbd_init(ps2dev_update_irq, &s->kbd);
s->mouse.dev = ps2_mouse_init(ps2dev_update_irq, &s->mouse);
memory_region_init_io(&s->kbd.reg, NULL, &lasips2_reg_ops, &s->kbd,
"lasips2-kbd", 0x100);
- memory_region_add_subregion(address_space, base, &s->kbd.reg);
+ sysbus_init_mmio(sbd, &s->kbd.reg);
memory_region_init_io(&s->mouse.reg, NULL, &lasips2_reg_ops, &s->mouse,
"lasips2-mouse", 0x100);
- memory_region_add_subregion(address_space, base + 0x100, &s->mouse.reg);
+ sysbus_init_mmio(sbd, &s->mouse.reg);
}
+
+static void lasips2_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->vmsd = &vmstate_lasips2;
+}
+
+static const TypeInfo lasips2_info = {
+ .name = TYPE_LASIPS2,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(LASIPS2State),
+ .instance_init = lasips2_init,
+ .class_init = lasips2_class_init,
+};
+
+static void lasips2_register_types(void)
+{
+ type_register_static(&lasips2_info);
+}
+
+type_init(lasips2_register_types)
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2021-09-20 6:40 ` [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
@ 2021-09-29 14:06 ` Philippe Mathieu-Daudé
2021-10-27 5:11 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-29 14:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Helge Deller, Sven Schnelle
ping?
On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
> Slowly nuking non-QOM devices: Lasi PS/2's turn.
>
> Philippe Mathieu-Daudé (3):
> hw/input/lasips2: Fix typos in function names
> hw/input/lasips2: Move LASIPS2State declaration to
> 'hw/input/lasips2.h'
> hw/input/lasips2: QOM'ify the Lasi PS/2
>
> include/hw/input/lasips2.h | 31 ++++++++++++++++--
> hw/hppa/lasi.c | 10 +++++-
> hw/input/lasips2.c | 64 +++++++++++++++++++-------------------
> 3 files changed, 70 insertions(+), 35 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] hw/input/lasips2: Fix typos in function names
2021-09-20 6:40 ` [PATCH 1/3] hw/input/lasips2: Fix typos in function names Philippe Mathieu-Daudé
@ 2021-09-29 14:24 ` Damien Hedde
0 siblings, 0 replies; 10+ messages in thread
From: Damien Hedde @ 2021-09-29 14:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Helge Deller, Sven Schnelle
On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
> Artist is another device, this one is the Lasi PS/2.
> Rename the functions accordingly.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
> ---
> hw/input/lasips2.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
> index e7faf24058b..68d741d3421 100644
> --- a/hw/input/lasips2.c
> +++ b/hw/input/lasips2.c
> @@ -96,7 +96,7 @@ typedef enum {
> LASIPS2_STATUS_CLKSHD = 0x80,
> } lasips2_status_reg_t;
>
> -static const char *artist_read_reg_name(uint64_t addr)
> +static const char *lasips2_read_reg_name(uint64_t addr)
> {
> switch (addr & 0xc) {
> case REG_PS2_ID:
> @@ -116,7 +116,7 @@ static const char *artist_read_reg_name(uint64_t addr)
> }
> }
>
> -static const char *artist_write_reg_name(uint64_t addr)
> +static const char *lasips2_write_reg_name(uint64_t addr)
> {
> switch (addr & 0x0c) {
> case REG_PS2_RESET:
> @@ -145,7 +145,7 @@ static void lasips2_reg_write(void *opaque, hwaddr addr, uint64_t val,
> LASIPS2Port *port = opaque;
>
> trace_lasips2_reg_write(size, port->id, addr,
> - artist_write_reg_name(addr), val);
> + lasips2_write_reg_name(addr), val);
>
> switch (addr & 0xc) {
> case REG_PS2_CONTROL:
> @@ -239,7 +239,7 @@ static uint64_t lasips2_reg_read(void *opaque, hwaddr addr, unsigned size)
> break;
> }
> trace_lasips2_reg_read(size, port->id, addr,
> - artist_read_reg_name(addr), ret);
> + lasips2_read_reg_name(addr), ret);
>
> return ret;
> }
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h'
2021-09-20 6:40 ` [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h' Philippe Mathieu-Daudé
@ 2021-09-29 14:27 ` Damien Hedde
0 siblings, 0 replies; 10+ messages in thread
From: Damien Hedde @ 2021-09-29 14:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Helge Deller, Sven Schnelle
On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
> We want to use the OBJECT_DECLARE_SIMPLE_TYPE() macro to QOM'ify
> this device in the next commit. To make its review simpler, as a
> first step move the LASIPS2State and LASIPS2Port declarations to
> 'hw/input/lasips2.h'
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
> ---
> include/hw/input/lasips2.h | 18 ++++++++++++++++++
> hw/input/lasips2.c | 18 ------------------
> 2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
> index 0cd7b59064a..c88f1700162 100644
> --- a/include/hw/input/lasips2.h
> +++ b/include/hw/input/lasips2.h
> @@ -11,6 +11,24 @@
>
> #define TYPE_LASIPS2 "lasips2"
>
> +struct LASIPS2State;
> +typedef struct LASIPS2Port {
> + struct LASIPS2State *parent;
> + MemoryRegion reg;
> + void *dev;
> + uint8_t id;
> + uint8_t control;
> + uint8_t buf;
> + bool loopback_rbne;
> + bool irq;
> +} LASIPS2Port;
> +
> +typedef struct LASIPS2State {
> + LASIPS2Port kbd;
> + LASIPS2Port mouse;
> + qemu_irq irq;
> +} LASIPS2State;
> +
> void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq);
>
> #endif /* HW_INPUT_LASIPS2_H */
> diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
> index 68d741d3421..0f8362f17bc 100644
> --- a/hw/input/lasips2.c
> +++ b/hw/input/lasips2.c
> @@ -33,24 +33,6 @@
> #include "hw/irq.h"
>
>
> -struct LASIPS2State;
> -typedef struct LASIPS2Port {
> - struct LASIPS2State *parent;
> - MemoryRegion reg;
> - void *dev;
> - uint8_t id;
> - uint8_t control;
> - uint8_t buf;
> - bool loopback_rbne;
> - bool irq;
> -} LASIPS2Port;
> -
> -typedef struct LASIPS2State {
> - LASIPS2Port kbd;
> - LASIPS2Port mouse;
> - qemu_irq irq;
> -} LASIPS2State;
> -
> static const VMStateDescription vmstate_lasips2 = {
> .name = "lasips2",
> .version_id = 0,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2
2021-09-20 6:40 ` [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
@ 2021-09-29 14:33 ` Damien Hedde
0 siblings, 0 replies; 10+ messages in thread
From: Damien Hedde @ 2021-09-29 14:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Helge Deller, Sven Schnelle
On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
> ---
> include/hw/input/lasips2.h | 17 +++++++++++++----
> hw/hppa/lasi.c | 10 +++++++++-
> hw/input/lasips2.c | 38 ++++++++++++++++++++++++++++----------
> 3 files changed, 50 insertions(+), 15 deletions(-)
>
> diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
> index c88f1700162..834b6d867d9 100644
> --- a/include/hw/input/lasips2.h
> +++ b/include/hw/input/lasips2.h
> @@ -7,11 +7,11 @@
> #ifndef HW_INPUT_LASIPS2_H
> #define HW_INPUT_LASIPS2_H
>
> -#include "exec/hwaddr.h"
> +#include "hw/sysbus.h"
>
> #define TYPE_LASIPS2 "lasips2"
> +OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2)
>
> -struct LASIPS2State;
> typedef struct LASIPS2Port {
> struct LASIPS2State *parent;
> MemoryRegion reg;
> @@ -23,12 +23,21 @@ typedef struct LASIPS2Port {
> bool irq;
> } LASIPS2Port;
>
> +/*
> + * QEMU interface:
> + * + sysbus MMIO region 0 is the keyboard port interface
> + * + sysbus MMIO region 1 is the mouse port interface
> + * + sysbus IRQ 0 is the interrupt line shared between
> + * keyboard and mouse ports
> + */
> typedef struct LASIPS2State {
> + /*< private >*/
> + SysBusDevice parent_obj;
> +
> + /*< public >*/
> LASIPS2Port kbd;
> LASIPS2Port mouse;
> qemu_irq irq;
> } LASIPS2State;
>
> -void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq);
> -
> #endif /* HW_INPUT_LASIPS2_H */
> diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
> index 88c3791eb68..91414748b70 100644
> --- a/hw/hppa/lasi.c
> +++ b/hw/hppa/lasi.c
> @@ -297,6 +297,7 @@ static int lasi_get_irq(unsigned long hpa)
> DeviceState *lasi_init(MemoryRegion *address_space)
> {
> DeviceState *dev;
> + SysBusDevice *sbd;
> LasiState *s;
>
> dev = qdev_new(TYPE_LASI_CHIP);
> @@ -340,7 +341,14 @@ DeviceState *lasi_init(MemoryRegion *address_space)
> /* PS/2 Keyboard/Mouse */
> qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s,
> lasi_get_irq(LASI_PS2KBD_HPA));
> - lasips2_init(address_space, LASI_PS2KBD_HPA, ps2kbd_irq);
> +
> + sbd = SYS_BUS_DEVICE(qdev_new(TYPE_LASIPS2));
> + sysbus_realize_and_unref(sbd, &error_fatal);
> + memory_region_add_subregion(address_space, LASI_PS2KBD_HPA,
> + sysbus_mmio_get_region(sbd, 0));
> + memory_region_add_subregion(address_space, LASI_PS2MOU_HPA,
> + sysbus_mmio_get_region(sbd, 1));
> + sysbus_connect_irq(sbd, 0, ps2kbd_irq);
>
> return dev;
> }
> diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
> index 0f8362f17bc..46cd32316da 100644
> --- a/hw/input/lasips2.c
> +++ b/hw/input/lasips2.c
> @@ -243,28 +243,46 @@ static void ps2dev_update_irq(void *opaque, int level)
> lasips2_update_irq(port->parent);
> }
>
> -void lasips2_init(MemoryRegion *address_space,
> - hwaddr base, qemu_irq irq)
> +static void lasips2_init(Object *obj)
> {
> - LASIPS2State *s;
> + LASIPS2State *s = LASIPS2(obj);
> + SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>
> - s = g_malloc0(sizeof(LASIPS2State));
> -
> - s->irq = irq;
> + sysbus_init_irq(sbd, &s->irq);
> s->mouse.id = 1;
> s->kbd.parent = s;
> s->mouse.parent = s;
>
> - vmstate_register(NULL, base, &vmstate_lasips2, s);
> -
> s->kbd.dev = ps2_kbd_init(ps2dev_update_irq, &s->kbd);
> s->mouse.dev = ps2_mouse_init(ps2dev_update_irq, &s->mouse);
>
> memory_region_init_io(&s->kbd.reg, NULL, &lasips2_reg_ops, &s->kbd,
> "lasips2-kbd", 0x100);
> - memory_region_add_subregion(address_space, base, &s->kbd.reg);
> + sysbus_init_mmio(sbd, &s->kbd.reg);
>
> memory_region_init_io(&s->mouse.reg, NULL, &lasips2_reg_ops, &s->mouse,
> "lasips2-mouse", 0x100);
> - memory_region_add_subregion(address_space, base + 0x100, &s->mouse.reg);
> + sysbus_init_mmio(sbd, &s->mouse.reg);
> }
> +
> +static void lasips2_class_init(ObjectClass *oc, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(oc);
> +
> + dc->vmsd = &vmstate_lasips2;
> +}
> +
> +static const TypeInfo lasips2_info = {
> + .name = TYPE_LASIPS2,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .instance_size = sizeof(LASIPS2State),
> + .instance_init = lasips2_init,
> + .class_init = lasips2_class_init,
> +};
> +
> +static void lasips2_register_types(void)
> +{
> + type_register_static(&lasips2_info);
> +}
> +
> +type_init(lasips2_register_types)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2021-09-29 14:06 ` [PATCH 0/3] " Philippe Mathieu-Daudé
@ 2021-10-27 5:11 ` Philippe Mathieu-Daudé
2021-10-27 8:46 ` Laurent Vivier
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-27 5:11 UTC (permalink / raw)
To: qemu-devel, QEMU Trivial; +Cc: Richard Henderson, Helge Deller, Sven Schnelle
Cc'ing qemu-trivial@ (fully reviewed).
On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
> Slowly nuking non-QOM devices: Lasi PS/2's turn.
>
> Philippe Mathieu-Daudé (3):
> hw/input/lasips2: Fix typos in function names
> hw/input/lasips2: Move LASIPS2State declaration to
> 'hw/input/lasips2.h'
> hw/input/lasips2: QOM'ify the Lasi PS/2
>
> include/hw/input/lasips2.h | 31 ++++++++++++++++--
> hw/hppa/lasi.c | 10 +++++-
> hw/input/lasips2.c | 64 +++++++++++++++++++-------------------
> 3 files changed, 70 insertions(+), 35 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2
2021-10-27 5:11 ` Philippe Mathieu-Daudé
@ 2021-10-27 8:46 ` Laurent Vivier
0 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2021-10-27 8:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel, QEMU Trivial
Cc: Sven Schnelle, Helge Deller, Richard Henderson
Le 27/10/2021 à 07:11, Philippe Mathieu-Daudé a écrit :
> Cc'ing qemu-trivial@ (fully reviewed).
>
> On 9/20/21 08:40, Philippe Mathieu-Daudé wrote:
>> Slowly nuking non-QOM devices: Lasi PS/2's turn.
>>
>> Philippe Mathieu-Daudé (3):
>> hw/input/lasips2: Fix typos in function names
>> hw/input/lasips2: Move LASIPS2State declaration to
>> 'hw/input/lasips2.h'
>> hw/input/lasips2: QOM'ify the Lasi PS/2
>>
>> include/hw/input/lasips2.h | 31 ++++++++++++++++--
>> hw/hppa/lasi.c | 10 +++++-
>> hw/input/lasips2.c | 64 +++++++++++++++++++-------------------
>> 3 files changed, 70 insertions(+), 35 deletions(-)
>>
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-10-27 8:49 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 6:40 [PATCH 0/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
2021-09-20 6:40 ` [PATCH 1/3] hw/input/lasips2: Fix typos in function names Philippe Mathieu-Daudé
2021-09-29 14:24 ` Damien Hedde
2021-09-20 6:40 ` [PATCH 2/3] hw/input/lasips2: Move LASIPS2State declaration to 'hw/input/lasips2.h' Philippe Mathieu-Daudé
2021-09-29 14:27 ` Damien Hedde
2021-09-20 6:40 ` [PATCH 3/3] hw/input/lasips2: QOM'ify the Lasi PS/2 Philippe Mathieu-Daudé
2021-09-29 14:33 ` Damien Hedde
2021-09-29 14:06 ` [PATCH 0/3] " Philippe Mathieu-Daudé
2021-10-27 5:11 ` Philippe Mathieu-Daudé
2021-10-27 8:46 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.