mirror of https://github.com/xemu-project/xemu.git
ps2: QOMify PS2State
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> Message-Id: <20220624134109.881989-3-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
parent
545e5cf817
commit
64bbdd138a
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
#include "hw/sysbus.h"
|
||||||
#include "hw/input/ps2.h"
|
#include "hw/input/ps2.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
|
@ -96,12 +97,17 @@ typedef struct {
|
||||||
} PS2Queue;
|
} PS2Queue;
|
||||||
|
|
||||||
struct PS2State {
|
struct PS2State {
|
||||||
|
SysBusDevice parent_obj;
|
||||||
|
|
||||||
PS2Queue queue;
|
PS2Queue queue;
|
||||||
int32_t write_cmd;
|
int32_t write_cmd;
|
||||||
void (*update_irq)(void *, int);
|
void (*update_irq)(void *, int);
|
||||||
void *update_arg;
|
void *update_arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TYPE_PS2_DEVICE "ps2-device"
|
||||||
|
OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PS2State common;
|
PS2State common;
|
||||||
int scan_enabled;
|
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);
|
qemu_register_reset(ps2_mouse_reset, s);
|
||||||
return 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)
|
||||||
|
|
Loading…
Reference in New Issue