[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/54] ps2: move QOM type definitions from ps2.c to ps2.h
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 05/54] ps2: move QOM type definitions from ps2.c to ps2.h |
Date: |
Fri, 24 Jun 2022 14:40:20 +0100 |
Move the QOM type definitions into the ps2.h header file to allow the new QOM
types to be used by other 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 | 55 ---------------------------------------
include/hw/input/ps2.h | 58 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 56 deletions(-)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index ee7c36d4f2..f4bad9876a 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -76,11 +76,6 @@
#define MOUSE_STATUS_ENABLED 0x20
#define MOUSE_STATUS_SCALE21 0x10
-/*
- * PS/2 buffer size. Keep 256 bytes for compatibility with
- * older QEMU versions.
- */
-#define PS2_BUFFER_SIZE 256
#define PS2_QUEUE_SIZE 16 /* Queue size required by PS/2 protocol */
#define PS2_QUEUE_HEADROOM 8 /* Queue size for keyboard command replies */
@@ -92,56 +87,6 @@
#define MOD_SHIFT_R (1 << 4)
#define MOD_ALT_R (1 << 5)
-typedef struct {
- uint8_t data[PS2_BUFFER_SIZE];
- int rptr, wptr, cwptr, count;
-} 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)
-
-struct PS2KbdState {
- PS2State parent_obj;
-
- int scan_enabled;
- int translate;
- int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */
- int ledstate;
- bool need_high_bit;
- unsigned int modifiers; /* bitmask of MOD_* constants above */
-};
-
-#define TYPE_PS2_KBD_DEVICE "ps2-kbd"
-OBJECT_DECLARE_SIMPLE_TYPE(PS2KbdState, PS2_KBD_DEVICE)
-
-struct PS2MouseState {
- PS2State parent_obj;
-
- uint8_t mouse_status;
- uint8_t mouse_resolution;
- uint8_t mouse_sample_rate;
- uint8_t mouse_wrap;
- uint8_t mouse_type; /* 0 = PS2, 3 = IMPS/2, 4 = IMEX */
- uint8_t mouse_detect_state;
- int mouse_dx; /* current values, needed for 'poll' mode */
- int mouse_dy;
- int mouse_dz;
- int mouse_dw;
- uint8_t mouse_buttons;
-};
-
-#define TYPE_PS2_MOUSE_DEVICE "ps2-mouse"
-OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE)
-
static uint8_t translate_table[256] = {
0xff, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x3c, 0x58,
0x64, 0x44, 0x42, 0x40, 0x3e, 0x0f, 0x29, 0x59,
diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h
index 35d983897a..7f2c3f6090 100644
--- a/include/hw/input/ps2.h
+++ b/include/hw/input/ps2.h
@@ -25,13 +25,69 @@
#ifndef HW_PS2_H
#define HW_PS2_H
+#include "hw/sysbus.h"
+
#define PS2_MOUSE_BUTTON_LEFT 0x01
#define PS2_MOUSE_BUTTON_RIGHT 0x02
#define PS2_MOUSE_BUTTON_MIDDLE 0x04
#define PS2_MOUSE_BUTTON_SIDE 0x08
#define PS2_MOUSE_BUTTON_EXTRA 0x10
-typedef struct PS2State PS2State;
+/*
+ * PS/2 buffer size. Keep 256 bytes for compatibility with
+ * older QEMU versions.
+ */
+#define PS2_BUFFER_SIZE 256
+
+typedef struct {
+ uint8_t data[PS2_BUFFER_SIZE];
+ int rptr, wptr, cwptr, count;
+} 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)
+
+struct PS2KbdState {
+ PS2State parent_obj;
+
+ int scan_enabled;
+ int translate;
+ int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */
+ int ledstate;
+ bool need_high_bit;
+ unsigned int modifiers; /* bitmask of MOD_* constants above */
+};
+
+#define TYPE_PS2_KBD_DEVICE "ps2-kbd"
+OBJECT_DECLARE_SIMPLE_TYPE(PS2KbdState, PS2_KBD_DEVICE)
+
+struct PS2MouseState {
+ PS2State parent_obj;
+
+ uint8_t mouse_status;
+ uint8_t mouse_resolution;
+ uint8_t mouse_sample_rate;
+ uint8_t mouse_wrap;
+ uint8_t mouse_type; /* 0 = PS2, 3 = IMPS/2, 4 = IMEX */
+ uint8_t mouse_detect_state;
+ int mouse_dx; /* current values, needed for 'poll' mode */
+ int mouse_dy;
+ int mouse_dz;
+ int mouse_dw;
+ uint8_t mouse_buttons;
+};
+
+#define TYPE_PS2_MOUSE_DEVICE "ps2-mouse"
+OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE)
/* ps2.c */
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
--
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, 2022/06/24
- [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 <=
- [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
- [PATCH v2 13/54] ps2: don't use vmstate_register() in ps2_mouse_init(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 14/54] pl050: checkpatch fixes, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 15/54] pl050: split pl050_update_irq() into separate pl050_set_irq() and pl050_update_irq() functions, Mark Cave-Ayland, 2022/06/24