[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/54] ps2: QOMify PS2State
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 02/54] ps2: QOMify PS2State |
Date: |
Fri, 24 Jun 2022 14:40:17 +0100 |
Make PS2State a new abstract PS2_DEVICE QOM type to represent the common
functionality shared between PS2 keyboard and mouse devices.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Helge Deller <deller@gmx.de>
---
hw/input/ps2.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 67dd2eca84..514e55cbb6 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "hw/sysbus.h"
#include "hw/input/ps2.h"
#include "migration/vmstate.h"
#include "ui/console.h"
@@ -96,12 +97,17 @@ typedef struct {
} PS2Queue;
struct PS2State {
+ SysBusDevice parent_obj;
+
PS2Queue queue;
int32_t write_cmd;
void (*update_irq)(void *, int);
void *update_arg;
};
+#define TYPE_PS2_DEVICE "ps2-device"
+OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE)
+
typedef struct {
PS2State common;
int scan_enabled;
@@ -1277,3 +1283,25 @@ void *ps2_mouse_init(void (*update_irq)(void *, int),
void *update_arg)
qemu_register_reset(ps2_mouse_reset, s);
return s;
}
+
+static void ps2_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+}
+
+static const TypeInfo ps2_info = {
+ .name = TYPE_PS2_DEVICE,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(PS2State),
+ .class_init = ps2_class_init,
+ .abstract = true
+};
+
+static void ps2_register_types(void)
+{
+ type_register_static(&ps2_info);
+}
+
+type_init(ps2_register_types)
--
2.30.2
- [PATCH v2 00/54] PS2 device QOMification - part 1, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 01/54] ps2: checkpatch fixes, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 02/54] ps2: QOMify PS2State,
Mark Cave-Ayland <=
- [PATCH v2 03/54] ps2: QOMify PS2KbdState, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 04/54] ps2: QOMify PS2MouseState, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 05/54] ps2: move QOM type definitions from ps2.c to ps2.h, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 06/54] ps2: improve function prototypes in ps2.c and ps2.h, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 07/54] ps2: introduce PS2DeviceClass, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 08/54] ps2: implement ps2_reset() for the PS2_DEVICE QOM type based upon ps2_common_reset(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 09/54] ps2: remove duplicate setting of scancode_set in ps2_kbd_init(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 11/54] ps2: implement ps2_mouse_realize() and use it to register ps2_mouse_handler, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 10/54] ps2: implement ps2_kbd_realize() and use it to register ps2_keyboard_handler, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 12/54] ps2: don't use vmstate_register() in ps2_kbd_init(), Mark Cave-Ayland, 2022/06/24