2005-11-26 13:36:25 +03:00
|
|
|
/*
|
|
|
|
* QEMU PS/2 keyboard/mouse emulation
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2005-11-26 13:36:25 +03:00
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2005-11-26 13:36:25 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2016-01-26 21:17:30 +03:00
|
|
|
#include "qemu/osdep.h"
|
2016-09-15 23:06:27 +03:00
|
|
|
#include "qemu/log.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/hw.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/input/ps2.h"
|
2012-11-28 15:06:30 +04:00
|
|
|
#include "ui/console.h"
|
2014-03-13 15:39:38 +04:00
|
|
|
#include "ui/input.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2005-11-26 13:36:25 +03:00
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
#include "trace.h"
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
/* debug PC keyboard */
|
|
|
|
//#define DEBUG_KBD
|
|
|
|
|
|
|
|
/* debug PC keyboard : only mouse */
|
|
|
|
//#define DEBUG_MOUSE
|
|
|
|
|
|
|
|
/* Keyboard Commands */
|
|
|
|
#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */
|
|
|
|
#define KBD_CMD_ECHO 0xEE
|
2008-03-18 09:54:34 +03:00
|
|
|
#define KBD_CMD_SCANCODE 0xF0 /* Get/set scancode set */
|
2005-11-26 13:36:25 +03:00
|
|
|
#define KBD_CMD_GET_ID 0xF2 /* get keyboard ID */
|
|
|
|
#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */
|
|
|
|
#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
|
|
|
|
#define KBD_CMD_RESET_DISABLE 0xF5 /* reset and disable scanning */
|
|
|
|
#define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */
|
|
|
|
#define KBD_CMD_RESET 0xFF /* Reset */
|
|
|
|
|
|
|
|
/* Keyboard Replies */
|
|
|
|
#define KBD_REPLY_POR 0xAA /* Power on reset */
|
2008-04-13 20:08:44 +04:00
|
|
|
#define KBD_REPLY_ID 0xAB /* Keyboard ID */
|
2005-11-26 13:36:25 +03:00
|
|
|
#define KBD_REPLY_ACK 0xFA /* Command ACK */
|
|
|
|
#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
|
|
|
|
|
|
|
|
/* Mouse Commands */
|
|
|
|
#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */
|
|
|
|
#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */
|
|
|
|
#define AUX_SET_RES 0xE8 /* Set resolution */
|
|
|
|
#define AUX_GET_SCALE 0xE9 /* Get scaling factor */
|
|
|
|
#define AUX_SET_STREAM 0xEA /* Set stream mode */
|
|
|
|
#define AUX_POLL 0xEB /* Poll */
|
|
|
|
#define AUX_RESET_WRAP 0xEC /* Reset wrap mode */
|
|
|
|
#define AUX_SET_WRAP 0xEE /* Set wrap mode */
|
|
|
|
#define AUX_SET_REMOTE 0xF0 /* Set remote mode */
|
|
|
|
#define AUX_GET_TYPE 0xF2 /* Get type */
|
|
|
|
#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */
|
|
|
|
#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */
|
|
|
|
#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */
|
|
|
|
#define AUX_SET_DEFAULT 0xF6
|
|
|
|
#define AUX_RESET 0xFF /* Reset aux device */
|
|
|
|
#define AUX_ACK 0xFA /* Command byte ACK. */
|
|
|
|
|
|
|
|
#define MOUSE_STATUS_REMOTE 0x40
|
|
|
|
#define MOUSE_STATUS_ENABLED 0x20
|
|
|
|
#define MOUSE_STATUS_SCALE21 0x10
|
|
|
|
|
2014-04-24 16:06:19 +04:00
|
|
|
#define PS2_QUEUE_SIZE 16 /* Buffer size required by PS/2 protocol */
|
2005-11-26 13:36:25 +03:00
|
|
|
|
|
|
|
typedef struct {
|
2014-04-24 16:06:19 +04:00
|
|
|
/* Keep the data array 256 bytes long, which compatibility
|
|
|
|
with older qemu versions. */
|
|
|
|
uint8_t data[256];
|
2005-11-26 13:36:25 +03:00
|
|
|
int rptr, wptr, count;
|
|
|
|
} PS2Queue;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PS2Queue queue;
|
|
|
|
int32_t write_cmd;
|
|
|
|
void (*update_irq)(void *, int);
|
|
|
|
void *update_arg;
|
|
|
|
} PS2State;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PS2State common;
|
|
|
|
int scan_enabled;
|
2006-02-08 07:42:17 +03:00
|
|
|
int translate;
|
2008-03-18 09:54:34 +03:00
|
|
|
int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */
|
2011-10-17 15:37:34 +04:00
|
|
|
int ledstate;
|
2016-09-15 23:06:25 +03:00
|
|
|
bool need_high_bit;
|
2005-11-26 13:36:25 +03:00
|
|
|
} PS2KbdState;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PS2State common;
|
|
|
|
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;
|
|
|
|
uint8_t mouse_buttons;
|
|
|
|
} PS2MouseState;
|
|
|
|
|
2016-09-15 23:06:26 +03:00
|
|
|
/* Table to convert from QEMU codes to scancodes. */
|
|
|
|
static const uint16_t qcode_to_keycode_set1[Q_KEY_CODE__MAX] = {
|
|
|
|
[0 ... Q_KEY_CODE__MAX - 1] = 0,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_A] = 0x1e,
|
|
|
|
[Q_KEY_CODE_B] = 0x30,
|
|
|
|
[Q_KEY_CODE_C] = 0x2e,
|
|
|
|
[Q_KEY_CODE_D] = 0x20,
|
|
|
|
[Q_KEY_CODE_E] = 0x12,
|
|
|
|
[Q_KEY_CODE_F] = 0x21,
|
|
|
|
[Q_KEY_CODE_G] = 0x22,
|
|
|
|
[Q_KEY_CODE_H] = 0x23,
|
|
|
|
[Q_KEY_CODE_I] = 0x17,
|
|
|
|
[Q_KEY_CODE_J] = 0x24,
|
|
|
|
[Q_KEY_CODE_K] = 0x25,
|
|
|
|
[Q_KEY_CODE_L] = 0x26,
|
|
|
|
[Q_KEY_CODE_M] = 0x32,
|
|
|
|
[Q_KEY_CODE_N]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= 0xe05b,
|
|
|
|
[Q_KEY_CODE_ALT] = 0x38,
|
|
|
|
[Q_KEY_CODE_SHIFT_R] = 0x36,
|
|
|
|
[Q_KEY_CODE_CTRL_R] = 0xe01d,
|
|
|
|
[Q_KEY_CODE_META_R] = 0xe05c,
|
|
|
|
[Q_KEY_CODE_ALT_R] = 0xe038,
|
|
|
|
[Q_KEY_CODE_MENU] = 0xe05d,
|
|
|
|
[Q_KEY_CODE_RET] = 0x1c,
|
|
|
|
[Q_KEY_CODE_ESC] = 0x01,
|
|
|
|
[Q_KEY_CODE_F1] = 0x3b,
|
|
|
|
[Q_KEY_CODE_F2] = 0x3c,
|
|
|
|
[Q_KEY_CODE_F3] = 0x3d,
|
|
|
|
[Q_KEY_CODE_F4] = 0x3e,
|
|
|
|
[Q_KEY_CODE_F5] = 0x3f,
|
|
|
|
[Q_KEY_CODE_F6] = 0x40,
|
|
|
|
[Q_KEY_CODE_F7] = 0x41,
|
|
|
|
[Q_KEY_CODE_F8] = 0x42,
|
|
|
|
[Q_KEY_CODE_F9] = 0x43,
|
|
|
|
[Q_KEY_CODE_F10] = 0x44,
|
|
|
|
[Q_KEY_CODE_F11] = 0x57,
|
|
|
|
[Q_KEY_CODE_F12] = 0x58,
|
|
|
|
/* special handling for Q_KEY_CODE_PRINT */
|
|
|
|
[Q_KEY_CODE_SCROLL_LOCK] = 0x46,
|
|
|
|
/* special handling for Q_KEY_CODE_PAUSE */
|
|
|
|
[Q_KEY_CODE_BRACKET_LEFT] = 0x1a,
|
|
|
|
[Q_KEY_CODE_INSERT] = 0xe052,
|
|
|
|
[Q_KEY_CODE_HOME] = 0xe047,
|
|
|
|
[Q_KEY_CODE_PGUP] = 0xe049,
|
|
|
|
[Q_KEY_CODE_DELETE] = 0xe053,
|
|
|
|
[Q_KEY_CODE_END] = 0xe04f,
|
|
|
|
[Q_KEY_CODE_PGDN] = 0xe051,
|
|
|
|
[Q_KEY_CODE_UP] = 0xe048,
|
|
|
|
[Q_KEY_CODE_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_AUDIONEXT] = 0xe019,
|
|
|
|
[Q_KEY_CODE_AUDIOPREV] = 0xe010,
|
|
|
|
[Q_KEY_CODE_AUDIOSTOP] = 0xe024,
|
|
|
|
[Q_KEY_CODE_AUDIOPLAY] = 0xe022,
|
|
|
|
[Q_KEY_CODE_AUDIOMUTE] = 0xe020,
|
|
|
|
[Q_KEY_CODE_VOLUMEUP] = 0xe030,
|
|
|
|
[Q_KEY_CODE_VOLUMEDOWN] = 0xe02e,
|
|
|
|
[Q_KEY_CODE_MEDIASELECT] = 0xe06d,
|
|
|
|
[Q_KEY_CODE_MAIL] = 0xe06c,
|
|
|
|
[Q_KEY_CODE_CALCULATOR] = 0xe021,
|
|
|
|
[Q_KEY_CODE_COMPUTER] = 0xe06b,
|
|
|
|
[Q_KEY_CODE_AC_SEARCH] = 0xe065,
|
|
|
|
[Q_KEY_CODE_AC_HOME] = 0xe032,
|
|
|
|
[Q_KEY_CODE_AC_BACK] = 0xe06a,
|
|
|
|
[Q_KEY_CODE_AC_FORWARD] = 0xe069,
|
|
|
|
[Q_KEY_CODE_AC_STOP] = 0xe068,
|
|
|
|
[Q_KEY_CODE_AC_REFRESH] = 0xe067,
|
|
|
|
[Q_KEY_CODE_AC_BOOKMARKS] = 0xe066,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
[Q_KEY_CODE_ASTERISK] = 0x37,
|
|
|
|
[Q_KEY_CODE_LESS] = 0x56,
|
|
|
|
[Q_KEY_CODE_RO] = 0x73,
|
2016-12-27 22:55:51 +03:00
|
|
|
[Q_KEY_CODE_HIRAGANA] = 0x70,
|
|
|
|
[Q_KEY_CODE_HENKAN] = 0x79,
|
|
|
|
[Q_KEY_CODE_YEN] = 0x7d,
|
2016-09-15 23:06:26 +03:00
|
|
|
[Q_KEY_CODE_KP_COMMA] = 0x7e,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const uint16_t qcode_to_keycode_set2[Q_KEY_CODE__MAX] = {
|
|
|
|
[0 ... Q_KEY_CODE__MA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x78,
|
|
|
|
[Q_KEY_CODE_F12] = 0x07,
|
|
|
|
/* special handling for Q_KEY_CODE_PRINT */
|
|
|
|
[Q_KEY_CODE_SCROLL_LOCK] = 0x7e,
|
|
|
|
/* special handling for Q_KEY_CODE_PAUSE */
|
|
|
|
[Q_KEY_CODE_BRACKET_LEFT] = 0x54,
|
|
|
|
[Q_KEY_CODE_INSERT] = 0xe070,
|
|
|
|
[Q_KEY_CODE_HOME] = 0xe06c,
|
|
|
|
[Q_KEY_CODE_PGUP] = 0xe07d,
|
|
|
|
[Q_KEY_CODE_DELETE] = 0xe071,
|
|
|
|
[Q_KEY_CODE_END] = 0xe069,
|
|
|
|
[Q_KEY_CODE_PGDN] = 0xe07a,
|
|
|
|
[Q_KEY_CODE_UP] = 0xe075,
|
|
|
|
[Q_KEY_CODE_LEFT] = 0xe06b,
|
|
|
|
[Q_KEY_CODE_DOWN] = 0xe072,
|
|
|
|
[Q_KEY_CODE_RIGHT] = 0xe074,
|
|
|
|
[Q_KEY_CODE_NUM_LOCK] = 0x77,
|
|
|
|
[Q_KEY_CODE_KP_DIVIDE] = 0xe04a,
|
|
|
|
[Q_KEY_CODE_KP_MULTIPLY] = 0x7c,
|
|
|
|
[Q_KEY_CODE_KP_SUBTRACT] = 0x7b,
|
|
|
|
[Q_KEY_CODE_KP_ADD] = 0x79,
|
|
|
|
[Q_KEY_CODE_KP_ENTER] = 0xe05a,
|
|
|
|
[Q_KEY_CODE_KP_DECIMAL] = 0x71,
|
|
|
|
[Q_KEY_CODE_KP_0] = 0x70,
|
|
|
|
[Q_KEY_CODE_KP_1] = 0x69,
|
|
|
|
[Q_KEY_CODE_KP_2] = 0x72,
|
|
|
|
[Q_KEY_CODE_KP_3] = 0x7a,
|
|
|
|
[Q_KEY_CODE_KP_4] = 0x6b,
|
|
|
|
[Q_KEY_CODE_KP_5] = 0x73,
|
|
|
|
[Q_KEY_CODE_KP_6] = 0x74,
|
|
|
|
[Q_KEY_CODE_KP_7] = 0x6c,
|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0xe020,
|
|
|
|
[Q_KEY_CODE_AC_BOOKMARKS] = 0xe018,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
[Q_KEY_CODE_ALTGR] = 0x08,
|
|
|
|
[Q_KEY_CODE_ALTGR_R] = 0xe008,
|
|
|
|
[Q_KEY_CODE_ASTERISK] = 0x7c,
|
|
|
|
[Q_KEY_CODE_LESS] = 0x61,
|
|
|
|
[Q_KEY_CODE_SYSRQ] = 0x7f,
|
|
|
|
[Q_KEY_CODE_RO] = 0x51,
|
2016-12-27 22:55:51 +03:00
|
|
|
[Q_KEY_CODE_HIRAGANA] = 0x13,
|
|
|
|
[Q_KEY_CODE_HENKAN] = 0x64,
|
|
|
|
[Q_KEY_CODE_YEN] = 0x6a,
|
2016-09-15 23:06:26 +03:00
|
|
|
[Q_KEY_CODE_KP_COMMA] = 0x6d,
|
2011-02-21 03:06:32 +03:00
|
|
|
};
|
2016-09-15 23:06:26 +03:00
|
|
|
|
|
|
|
static const uint16_t qcode_to_keycode_set3[Q_KEY_CODE__MAX] = {
|
|
|
|
[0 ... Q_KEY_CODE__MAX - 1] = 0,
|
|
|
|
|
|
|
|
[Q_KEY_CODE_A] = 0x1c,
|
|
|
|
[Q_KEY_CODE_B] = 0x32,
|
|
|
|
[Q_KEY_CODE_C] = 0x21,
|
|
|
|
[Q_KEY_CODE_D] = 0x23,
|
|
|
|
[Q_KEY_CODE_E] = 0x24,
|
|
|
|
[Q_KEY_CODE_F] = 0x2b,
|
|
|
|
[Q_KEY_CODE_G] = 0x34,
|
|
|
|
[Q_KEY_CODE_H] = 0x33,
|
|
|
|
[Q_KEY_CODE_I] = 0x43,
|
|
|
|
[Q_KEY_CODE_J] = 0x3b,
|
|
|
|
[Q_KEY_CODE_K] = 0x42,
|
|
|
|
[Q_KEY_CODE_L] = 0x4b,
|
|
|
|
[Q_KEY_CODE_M] = 0x3a,
|
|
|
|
[Q_KEY_CODE_N] = 0x31,
|
|
|
|
[Q_KEY_CODE_O] = 0x44,
|
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|
|
|
|
[Q_KEY_CODE_RIGHT] = 0x6a,
|
|
|
|
[Q_KEY_CODE_NUM_LOCK] = 0x76,
|
|
|
|
[Q_KEY_CODE_KP_DIVIDE] = 0x4a,
|
|
|
|
[Q_KEY_CODE_KP_MULTIPLY] = 0x7e,
|
|
|
|
[Q_KEY_CODE_KP_SUBTRACT] = 0x4e,
|
|
|
|
[Q_KEY_CODE_KP_ADD] = 0x7c,
|
|
|
|
[Q_KEY_CODE_KP_ENTER] = 0x79,
|
|
|
|
[Q_KEY_CODE_KP_DECIMAL] = 0x71,
|
|
|
|
[Q_KEY_CODE_KP_0] = 0x70,
|
|
|
|
[Q_KEY_CODE_KP_1] = 0x69,
|
|
|
|
[Q_KEY_CODE_KP_2] = 0x72,
|
|
|
|
[Q_KEY_CODE_KP_3] = 0x7a,
|
|
|
|
[Q_KEY_CODE_KP_4] = 0x6b,
|
|
|
|
[Q_KEY_CODE_KP_5] = 0x73,
|
|
|
|
[Q_KEY_CODE_KP_6] = 0x74,
|
|
|
|
[Q_KEY_CODE_KP_7] = 0x6c,
|
|
|
|
[Q_KEY_CODE_KP_8] = 0x75,
|
|
|
|
[Q_KEY_CODE_KP_9] = 0x7d,
|
|
|
|
[Q_KEY_CODE_BRACKET_RIGHT] = 0x5b,
|
|
|
|
[Q_KEY_CODE_SEMICOLON] = 0x4c,
|
|
|
|
[Q_KEY_CODE_APOSTROPHE] = 0x52,
|
|
|
|
[Q_KEY_CODE_COMMA] = 0x41,
|
|
|
|
[Q_KEY_CODE_DOT] = 0x49,
|
|
|
|
[Q_KEY_CODE_SLASH] = 0x4a,
|
2016-12-27 22:55:51 +03:00
|
|
|
|
|
|
|
[Q_KEY_CODE_HIRAGANA] = 0x87,
|
|
|
|
[Q_KEY_CODE_HENKAN] = 0x86,
|
|
|
|
[Q_KEY_CODE_YEN] = 0x5d,
|
2006-02-08 07:42:17 +03:00
|
|
|
};
|
|
|
|
|
2016-09-15 23:06:25 +03:00
|
|
|
static uint8_t translate_table[256] = {
|
|
|
|
0xff, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x3c, 0x58,
|
|
|
|
0x64, 0x44, 0x42, 0x40, 0x3e, 0x0f, 0x29, 0x59,
|
|
|
|
0x65, 0x38, 0x2a, 0x70, 0x1d, 0x10, 0x02, 0x5a,
|
|
|
|
0x66, 0x71, 0x2c, 0x1f, 0x1e, 0x11, 0x03, 0x5b,
|
|
|
|
0x67, 0x2e, 0x2d, 0x20, 0x12, 0x05, 0x04, 0x5c,
|
|
|
|
0x68, 0x39, 0x2f, 0x21, 0x14, 0x13, 0x06, 0x5d,
|
|
|
|
0x69, 0x31, 0x30, 0x23, 0x22, 0x15, 0x07, 0x5e,
|
|
|
|
0x6a, 0x72, 0x32, 0x24, 0x16, 0x08, 0x09, 0x5f,
|
|
|
|
0x6b, 0x33, 0x25, 0x17, 0x18, 0x0b, 0x0a, 0x60,
|
|
|
|
0x6c, 0x34, 0x35, 0x26, 0x27, 0x19, 0x0c, 0x61,
|
|
|
|
0x6d, 0x73, 0x28, 0x74, 0x1a, 0x0d, 0x62, 0x6e,
|
|
|
|
0x3a, 0x36, 0x1c, 0x1b, 0x75, 0x2b, 0x63, 0x76,
|
|
|
|
0x55, 0x56, 0x77, 0x78, 0x79, 0x7a, 0x0e, 0x7b,
|
|
|
|
0x7c, 0x4f, 0x7d, 0x4b, 0x47, 0x7e, 0x7f, 0x6f,
|
|
|
|
0x52, 0x53, 0x50, 0x4c, 0x4d, 0x48, 0x01, 0x45,
|
|
|
|
0x57, 0x4e, 0x51, 0x4a, 0x37, 0x49, 0x46, 0x54,
|
|
|
|
0x80, 0x81, 0x82, 0x41, 0x54, 0x85, 0x86, 0x87,
|
|
|
|
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
|
|
|
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
|
|
|
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
|
|
|
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
|
|
|
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
|
|
|
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
|
|
|
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
|
|
|
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
|
|
|
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
|
|
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
|
|
|
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
|
|
|
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
|
|
|
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
|
|
|
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
|
|
|
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
|
|
|
};
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
void ps2_queue(void *opaque, int b)
|
|
|
|
{
|
|
|
|
PS2State *s = (PS2State *)opaque;
|
|
|
|
PS2Queue *q = &s->queue;
|
|
|
|
|
2014-04-24 16:06:19 +04:00
|
|
|
if (q->count >= PS2_QUEUE_SIZE - 1)
|
2005-11-26 13:36:25 +03:00
|
|
|
return;
|
|
|
|
q->data[q->wptr] = b;
|
|
|
|
if (++q->wptr == PS2_QUEUE_SIZE)
|
|
|
|
q->wptr = 0;
|
|
|
|
q->count++;
|
|
|
|
s->update_irq(s->update_arg, 1);
|
|
|
|
}
|
|
|
|
|
2016-09-15 23:06:25 +03:00
|
|
|
/* keycode is the untranslated scancode in the current scancode set. */
|
2005-11-26 13:36:25 +03:00
|
|
|
static void ps2_put_keycode(void *opaque, int keycode)
|
|
|
|
{
|
2006-02-08 07:42:17 +03:00
|
|
|
PS2KbdState *s = opaque;
|
2008-03-18 09:54:34 +03:00
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_put_keycode(opaque, keycode);
|
2012-02-23 16:45:22 +04:00
|
|
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
2016-09-15 23:06:25 +03:00
|
|
|
|
|
|
|
if (s->translate) {
|
|
|
|
if (keycode == 0xf0) {
|
|
|
|
s->need_high_bit = true;
|
|
|
|
} else if (s->need_high_bit) {
|
|
|
|
ps2_queue(&s->common, translate_table[keycode] | 0x80);
|
|
|
|
s->need_high_bit = false;
|
|
|
|
} else {
|
|
|
|
ps2_queue(&s->common, translate_table[keycode]);
|
2011-02-21 03:06:32 +03:00
|
|
|
}
|
2016-09-15 23:06:25 +03:00
|
|
|
} else {
|
|
|
|
ps2_queue(&s->common, keycode);
|
|
|
|
}
|
2005-11-26 13:36:25 +03:00
|
|
|
}
|
|
|
|
|
2014-03-13 15:39:38 +04:00
|
|
|
static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
|
|
|
|
InputEvent *evt)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState *)dev;
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
InputKeyEvent *key = evt->u.key.data;
|
2016-09-15 23:06:26 +03:00
|
|
|
int qcode;
|
|
|
|
uint16_t keycode;
|
2014-03-13 15:39:38 +04:00
|
|
|
|
|
|
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
2016-09-15 23:06:26 +03:00
|
|
|
assert(evt->type == INPUT_EVENT_KIND_KEY);
|
|
|
|
qcode = qemu_input_key_value_to_qcode(key->key);
|
2016-09-15 23:06:25 +03:00
|
|
|
|
2016-09-15 23:06:26 +03:00
|
|
|
if (s->scancode_set == 1) {
|
|
|
|
if (qcode == Q_KEY_CODE_PAUSE) {
|
|
|
|
if (key->down) {
|
|
|
|
ps2_put_keycode(s, 0xe1);
|
|
|
|
ps2_put_keycode(s, 0x1d);
|
|
|
|
ps2_put_keycode(s, 0x45);
|
|
|
|
ps2_put_keycode(s, 0x91);
|
|
|
|
ps2_put_keycode(s, 0x9d);
|
|
|
|
ps2_put_keycode(s, 0xc5);
|
|
|
|
}
|
|
|
|
} else if (qcode == Q_KEY_CODE_PRINT) {
|
|
|
|
if (key->down) {
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0x2a);
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0x37);
|
|
|
|
} else {
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0xb7);
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0xaa);
|
|
|
|
}
|
2016-09-15 23:06:25 +03:00
|
|
|
} else {
|
2016-09-15 23:06:26 +03:00
|
|
|
keycode = qcode_to_keycode_set1[qcode];
|
|
|
|
if (keycode) {
|
|
|
|
if (keycode & 0xff00) {
|
|
|
|
ps2_put_keycode(s, keycode >> 8);
|
|
|
|
}
|
|
|
|
if (!key->down) {
|
|
|
|
keycode |= 0x80;
|
|
|
|
}
|
|
|
|
ps2_put_keycode(s, keycode & 0xff);
|
|
|
|
} else {
|
2016-09-15 23:06:27 +03:00
|
|
|
qemu_log_mask(LOG_UNIMP,
|
|
|
|
"ps2: ignoring key with qcode %d\n", qcode);
|
2016-09-15 23:06:26 +03:00
|
|
|
}
|
2016-09-15 23:06:25 +03:00
|
|
|
}
|
2016-09-15 23:06:26 +03:00
|
|
|
} else if (s->scancode_set == 2) {
|
|
|
|
if (qcode == Q_KEY_CODE_PAUSE) {
|
|
|
|
if (key->down) {
|
|
|
|
ps2_put_keycode(s, 0xe1);
|
|
|
|
ps2_put_keycode(s, 0x14);
|
|
|
|
ps2_put_keycode(s, 0x77);
|
|
|
|
ps2_put_keycode(s, 0xe1);
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
ps2_put_keycode(s, 0x14);
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
ps2_put_keycode(s, 0x77);
|
2016-09-15 23:06:25 +03:00
|
|
|
}
|
2016-09-15 23:06:26 +03:00
|
|
|
} else if (qcode == Q_KEY_CODE_PRINT) {
|
|
|
|
if (key->down) {
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0x12);
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0x7c);
|
|
|
|
} else {
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
ps2_put_keycode(s, 0x7c);
|
|
|
|
ps2_put_keycode(s, 0xe0);
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
ps2_put_keycode(s, 0x12);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
keycode = qcode_to_keycode_set2[qcode];
|
|
|
|
if (keycode) {
|
|
|
|
if (keycode & 0xff00) {
|
|
|
|
ps2_put_keycode(s, keycode >> 8);
|
|
|
|
}
|
|
|
|
if (!key->down) {
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
}
|
|
|
|
ps2_put_keycode(s, keycode & 0xff);
|
|
|
|
} else {
|
2016-09-15 23:06:27 +03:00
|
|
|
qemu_log_mask(LOG_UNIMP,
|
|
|
|
"ps2: ignoring key with qcode %d\n", qcode);
|
2016-09-15 23:06:25 +03:00
|
|
|
}
|
|
|
|
}
|
2016-09-15 23:06:26 +03:00
|
|
|
} else if (s->scancode_set == 3) {
|
|
|
|
keycode = qcode_to_keycode_set3[qcode];
|
|
|
|
if (keycode) {
|
|
|
|
/* FIXME: break code should be configured on a key by key basis */
|
|
|
|
if (!key->down) {
|
|
|
|
ps2_put_keycode(s, 0xf0);
|
|
|
|
}
|
|
|
|
ps2_put_keycode(s, keycode);
|
|
|
|
} else {
|
2016-09-15 23:06:27 +03:00
|
|
|
qemu_log_mask(LOG_UNIMP,
|
|
|
|
"ps2: ignoring key with qcode %d\n", qcode);
|
2016-09-15 23:06:26 +03:00
|
|
|
}
|
2014-03-13 15:39:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
uint32_t ps2_read_data(void *opaque)
|
|
|
|
{
|
|
|
|
PS2State *s = (PS2State *)opaque;
|
|
|
|
PS2Queue *q;
|
|
|
|
int val, index;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_read_data(opaque);
|
2005-11-26 13:36:25 +03:00
|
|
|
q = &s->queue;
|
|
|
|
if (q->count == 0) {
|
|
|
|
/* NOTE: if no data left, we return the last keyboard one
|
|
|
|
(needed for EMM386) */
|
|
|
|
/* XXX: need a timer to do things correctly */
|
|
|
|
index = q->rptr - 1;
|
|
|
|
if (index < 0)
|
|
|
|
index = PS2_QUEUE_SIZE - 1;
|
|
|
|
val = q->data[index];
|
|
|
|
} else {
|
|
|
|
val = q->data[q->rptr];
|
|
|
|
if (++q->rptr == PS2_QUEUE_SIZE)
|
|
|
|
q->rptr = 0;
|
|
|
|
q->count--;
|
|
|
|
/* reading deasserts IRQ */
|
|
|
|
s->update_irq(s->update_arg, 0);
|
|
|
|
/* reassert IRQs if data left */
|
|
|
|
s->update_irq(s->update_arg, q->count != 0);
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-10-17 15:37:34 +04:00
|
|
|
static void ps2_set_ledstate(PS2KbdState *s, int ledstate)
|
|
|
|
{
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_set_ledstate(s, ledstate);
|
2011-10-17 15:37:34 +04:00
|
|
|
s->ledstate = ledstate;
|
|
|
|
kbd_put_ledstate(ledstate);
|
|
|
|
}
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
static void ps2_reset_keyboard(PS2KbdState *s)
|
|
|
|
{
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_reset_keyboard(s);
|
2005-11-26 13:36:25 +03:00
|
|
|
s->scan_enabled = 1;
|
2008-03-18 09:54:34 +03:00
|
|
|
s->scancode_set = 2;
|
2011-10-17 15:37:34 +04:00
|
|
|
ps2_set_ledstate(s, 0);
|
2005-11-26 13:36:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ps2_write_keyboard(void *opaque, int val)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState *)opaque;
|
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_write_keyboard(opaque, val);
|
2005-11-26 13:36:25 +03:00
|
|
|
switch(s->common.write_cmd) {
|
|
|
|
default:
|
|
|
|
case -1:
|
|
|
|
switch(val) {
|
|
|
|
case 0x00:
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
break;
|
|
|
|
case 0x05:
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_RESEND);
|
|
|
|
break;
|
|
|
|
case KBD_CMD_GET_ID:
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
2008-03-18 09:54:34 +03:00
|
|
|
/* We emulate a MF2 AT keyboard here */
|
2008-04-13 20:08:44 +04:00
|
|
|
ps2_queue(&s->common, KBD_REPLY_ID);
|
|
|
|
if (s->translate)
|
|
|
|
ps2_queue(&s->common, 0x41);
|
|
|
|
else
|
|
|
|
ps2_queue(&s->common, 0x83);
|
2005-11-26 13:36:25 +03:00
|
|
|
break;
|
|
|
|
case KBD_CMD_ECHO:
|
|
|
|
ps2_queue(&s->common, KBD_CMD_ECHO);
|
|
|
|
break;
|
|
|
|
case KBD_CMD_ENABLE:
|
|
|
|
s->scan_enabled = 1;
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
break;
|
2008-03-18 09:54:34 +03:00
|
|
|
case KBD_CMD_SCANCODE:
|
2005-11-26 13:36:25 +03:00
|
|
|
case KBD_CMD_SET_LEDS:
|
|
|
|
case KBD_CMD_SET_RATE:
|
|
|
|
s->common.write_cmd = val;
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
break;
|
|
|
|
case KBD_CMD_RESET_DISABLE:
|
|
|
|
ps2_reset_keyboard(s);
|
|
|
|
s->scan_enabled = 0;
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
break;
|
|
|
|
case KBD_CMD_RESET_ENABLE:
|
|
|
|
ps2_reset_keyboard(s);
|
|
|
|
s->scan_enabled = 1;
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
break;
|
|
|
|
case KBD_CMD_RESET:
|
|
|
|
ps2_reset_keyboard(s);
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_POR);
|
|
|
|
break;
|
|
|
|
default:
|
2016-09-15 23:06:23 +03:00
|
|
|
ps2_queue(&s->common, KBD_REPLY_RESEND);
|
2005-11-26 13:36:25 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-03-18 09:54:34 +03:00
|
|
|
case KBD_CMD_SCANCODE:
|
|
|
|
if (val == 0) {
|
2016-09-15 23:06:24 +03:00
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
2016-09-15 23:06:25 +03:00
|
|
|
ps2_put_keycode(s, s->scancode_set);
|
2016-09-15 23:06:24 +03:00
|
|
|
} else if (val >= 1 && val <= 3) {
|
|
|
|
s->scancode_set = val;
|
2008-03-18 09:54:34 +03:00
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
2016-09-15 23:06:24 +03:00
|
|
|
} else {
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_RESEND);
|
2008-03-18 09:54:34 +03:00
|
|
|
}
|
|
|
|
s->common.write_cmd = -1;
|
|
|
|
break;
|
2005-11-26 13:36:25 +03:00
|
|
|
case KBD_CMD_SET_LEDS:
|
2011-10-17 15:37:34 +04:00
|
|
|
ps2_set_ledstate(s, val);
|
2005-11-26 13:36:25 +03:00
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
s->common.write_cmd = -1;
|
|
|
|
break;
|
|
|
|
case KBD_CMD_SET_RATE:
|
|
|
|
ps2_queue(&s->common, KBD_REPLY_ACK);
|
|
|
|
s->common.write_cmd = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-08 07:42:17 +03:00
|
|
|
/* Set the scancode translation mode.
|
|
|
|
0 = raw scancodes.
|
|
|
|
1 = translated scancodes (used by qemu internally). */
|
|
|
|
|
|
|
|
void ps2_keyboard_set_translation(void *opaque, int mode)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState *)opaque;
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_keyboard_set_translation(opaque, mode);
|
2006-02-08 07:42:17 +03:00
|
|
|
s->translate = mode;
|
|
|
|
}
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
static void ps2_mouse_send_packet(PS2MouseState *s)
|
|
|
|
{
|
|
|
|
unsigned int b;
|
|
|
|
int dx1, dy1, dz1;
|
|
|
|
|
|
|
|
dx1 = s->mouse_dx;
|
|
|
|
dy1 = s->mouse_dy;
|
|
|
|
dz1 = s->mouse_dz;
|
|
|
|
/* XXX: increase range to 8 bits ? */
|
|
|
|
if (dx1 > 127)
|
|
|
|
dx1 = 127;
|
|
|
|
else if (dx1 < -127)
|
|
|
|
dx1 = -127;
|
|
|
|
if (dy1 > 127)
|
|
|
|
dy1 = 127;
|
|
|
|
else if (dy1 < -127)
|
|
|
|
dy1 = -127;
|
|
|
|
b = 0x08 | ((dx1 < 0) << 4) | ((dy1 < 0) << 5) | (s->mouse_buttons & 0x07);
|
|
|
|
ps2_queue(&s->common, b);
|
|
|
|
ps2_queue(&s->common, dx1 & 0xff);
|
|
|
|
ps2_queue(&s->common, dy1 & 0xff);
|
|
|
|
/* extra byte for IMPS/2 or IMEX */
|
|
|
|
switch(s->mouse_type) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (dz1 > 127)
|
|
|
|
dz1 = 127;
|
|
|
|
else if (dz1 < -127)
|
|
|
|
dz1 = -127;
|
|
|
|
ps2_queue(&s->common, dz1 & 0xff);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (dz1 > 7)
|
|
|
|
dz1 = 7;
|
|
|
|
else if (dz1 < -7)
|
|
|
|
dz1 = -7;
|
|
|
|
b = (dz1 & 0x0f) | ((s->mouse_buttons & 0x18) << 1);
|
|
|
|
ps2_queue(&s->common, b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_mouse_send_packet(s, dx1, dy1, dz1, b);
|
2005-11-26 13:36:25 +03:00
|
|
|
/* update deltas */
|
|
|
|
s->mouse_dx -= dx1;
|
|
|
|
s->mouse_dy -= dy1;
|
|
|
|
s->mouse_dz -= dz1;
|
|
|
|
}
|
|
|
|
|
2014-03-13 15:58:29 +04:00
|
|
|
static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
|
|
|
|
InputEvent *evt)
|
2005-11-26 13:36:25 +03:00
|
|
|
{
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 11:52:57 +03:00
|
|
|
static const int bmap[INPUT_BUTTON__MAX] = {
|
2016-12-06 22:00:06 +03:00
|
|
|
[INPUT_BUTTON_LEFT] = PS2_MOUSE_BUTTON_LEFT,
|
|
|
|
[INPUT_BUTTON_MIDDLE] = PS2_MOUSE_BUTTON_MIDDLE,
|
|
|
|
[INPUT_BUTTON_RIGHT] = PS2_MOUSE_BUTTON_RIGHT,
|
|
|
|
[INPUT_BUTTON_SIDE] = PS2_MOUSE_BUTTON_SIDE,
|
|
|
|
[INPUT_BUTTON_EXTRA] = PS2_MOUSE_BUTTON_EXTRA,
|
2014-03-13 15:58:29 +04:00
|
|
|
};
|
|
|
|
PS2MouseState *s = (PS2MouseState *)dev;
|
2016-03-03 19:16:49 +03:00
|
|
|
InputMoveEvent *move;
|
|
|
|
InputBtnEvent *btn;
|
2005-11-26 13:36:25 +03:00
|
|
|
|
|
|
|
/* check if deltas are recorded when disabled */
|
|
|
|
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
|
|
|
|
return;
|
|
|
|
|
2015-10-27 01:34:58 +03:00
|
|
|
switch (evt->type) {
|
2014-03-13 15:58:29 +04:00
|
|
|
case INPUT_EVENT_KIND_REL:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
move = evt->u.rel.data;
|
2016-03-03 19:16:49 +03:00
|
|
|
if (move->axis == INPUT_AXIS_X) {
|
|
|
|
s->mouse_dx += move->value;
|
|
|
|
} else if (move->axis == INPUT_AXIS_Y) {
|
|
|
|
s->mouse_dy -= move->value;
|
2014-03-13 15:58:29 +04:00
|
|
|
}
|
|
|
|
break;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2014-03-13 15:58:29 +04:00
|
|
|
case INPUT_EVENT_KIND_BTN:
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
btn = evt->u.btn.data;
|
2016-03-03 19:16:49 +03:00
|
|
|
if (btn->down) {
|
|
|
|
s->mouse_buttons |= bmap[btn->button];
|
|
|
|
if (btn->button == INPUT_BUTTON_WHEEL_UP) {
|
2014-03-13 15:58:29 +04:00
|
|
|
s->mouse_dz--;
|
2016-03-03 19:16:49 +03:00
|
|
|
} else if (btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
2014-03-13 15:58:29 +04:00
|
|
|
s->mouse_dz++;
|
|
|
|
}
|
|
|
|
} else {
|
2016-03-03 19:16:49 +03:00
|
|
|
s->mouse_buttons &= ~bmap[btn->button];
|
2014-03-13 15:58:29 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* keep gcc happy */
|
|
|
|
break;
|
2012-02-23 16:45:22 +04:00
|
|
|
}
|
2014-03-13 15:58:29 +04:00
|
|
|
}
|
2012-02-23 16:45:22 +04:00
|
|
|
|
2014-03-13 15:58:29 +04:00
|
|
|
static void ps2_mouse_sync(DeviceState *dev)
|
|
|
|
{
|
|
|
|
PS2MouseState *s = (PS2MouseState *)dev;
|
|
|
|
|
|
|
|
if (s->mouse_buttons) {
|
|
|
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
|
|
|
}
|
2014-04-24 16:06:19 +04:00
|
|
|
if (!(s->mouse_status & MOUSE_STATUS_REMOTE)) {
|
|
|
|
while (s->common.queue.count < PS2_QUEUE_SIZE - 4) {
|
2005-11-26 13:36:25 +03:00
|
|
|
/* if not remote, send event. Multiple events are sent if
|
|
|
|
too big deltas */
|
|
|
|
ps2_mouse_send_packet(s);
|
|
|
|
if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 19:45:27 +03:00
|
|
|
void ps2_mouse_fake_event(void *opaque)
|
|
|
|
{
|
2014-03-13 15:58:29 +04:00
|
|
|
PS2MouseState *s = opaque;
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_mouse_fake_event(opaque);
|
2014-03-13 15:58:29 +04:00
|
|
|
s->mouse_dx++;
|
|
|
|
ps2_mouse_sync(opaque);
|
2007-03-20 19:45:27 +03:00
|
|
|
}
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
void ps2_write_mouse(void *opaque, int val)
|
|
|
|
{
|
|
|
|
PS2MouseState *s = (PS2MouseState *)opaque;
|
2015-01-16 22:21:37 +03:00
|
|
|
|
|
|
|
trace_ps2_write_mouse(opaque, val);
|
2005-11-26 13:36:25 +03:00
|
|
|
#ifdef DEBUG_MOUSE
|
|
|
|
printf("kbd: write mouse 0x%02x\n", val);
|
|
|
|
#endif
|
|
|
|
switch(s->common.write_cmd) {
|
|
|
|
default:
|
|
|
|
case -1:
|
|
|
|
/* mouse command */
|
|
|
|
if (s->mouse_wrap) {
|
|
|
|
if (val == AUX_RESET_WRAP) {
|
|
|
|
s->mouse_wrap = 0;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
return;
|
|
|
|
} else if (val != AUX_RESET) {
|
|
|
|
ps2_queue(&s->common, val);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch(val) {
|
|
|
|
case AUX_SET_SCALE11:
|
|
|
|
s->mouse_status &= ~MOUSE_STATUS_SCALE21;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_SET_SCALE21:
|
|
|
|
s->mouse_status |= MOUSE_STATUS_SCALE21;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_SET_STREAM:
|
|
|
|
s->mouse_status &= ~MOUSE_STATUS_REMOTE;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_SET_WRAP:
|
|
|
|
s->mouse_wrap = 1;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_SET_REMOTE:
|
|
|
|
s->mouse_status |= MOUSE_STATUS_REMOTE;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_GET_TYPE:
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
ps2_queue(&s->common, s->mouse_type);
|
|
|
|
break;
|
|
|
|
case AUX_SET_RES:
|
|
|
|
case AUX_SET_SAMPLE:
|
|
|
|
s->common.write_cmd = val;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_GET_SCALE:
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
ps2_queue(&s->common, s->mouse_status);
|
|
|
|
ps2_queue(&s->common, s->mouse_resolution);
|
|
|
|
ps2_queue(&s->common, s->mouse_sample_rate);
|
|
|
|
break;
|
|
|
|
case AUX_POLL:
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
ps2_mouse_send_packet(s);
|
|
|
|
break;
|
|
|
|
case AUX_ENABLE_DEV:
|
|
|
|
s->mouse_status |= MOUSE_STATUS_ENABLED;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_DISABLE_DEV:
|
|
|
|
s->mouse_status &= ~MOUSE_STATUS_ENABLED;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_SET_DEFAULT:
|
|
|
|
s->mouse_sample_rate = 100;
|
|
|
|
s->mouse_resolution = 2;
|
|
|
|
s->mouse_status = 0;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
break;
|
|
|
|
case AUX_RESET:
|
|
|
|
s->mouse_sample_rate = 100;
|
|
|
|
s->mouse_resolution = 2;
|
|
|
|
s->mouse_status = 0;
|
|
|
|
s->mouse_type = 0;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
ps2_queue(&s->common, 0xaa);
|
|
|
|
ps2_queue(&s->common, s->mouse_type);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AUX_SET_SAMPLE:
|
|
|
|
s->mouse_sample_rate = val;
|
|
|
|
/* detect IMPS/2 or IMEX */
|
|
|
|
switch(s->mouse_detect_state) {
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
if (val == 200)
|
|
|
|
s->mouse_detect_state = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (val == 100)
|
|
|
|
s->mouse_detect_state = 2;
|
|
|
|
else if (val == 200)
|
|
|
|
s->mouse_detect_state = 3;
|
|
|
|
else
|
|
|
|
s->mouse_detect_state = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
2007-09-17 01:08:06 +04:00
|
|
|
if (val == 80)
|
2005-11-26 13:36:25 +03:00
|
|
|
s->mouse_type = 3; /* IMPS/2 */
|
|
|
|
s->mouse_detect_state = 0;
|
|
|
|
break;
|
|
|
|
case 3:
|
2007-09-17 01:08:06 +04:00
|
|
|
if (val == 80)
|
2005-11-26 13:36:25 +03:00
|
|
|
s->mouse_type = 4; /* IMEX */
|
|
|
|
s->mouse_detect_state = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
s->common.write_cmd = -1;
|
|
|
|
break;
|
|
|
|
case AUX_SET_RES:
|
|
|
|
s->mouse_resolution = val;
|
|
|
|
ps2_queue(&s->common, AUX_ACK);
|
|
|
|
s->common.write_cmd = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-15 05:30:53 +04:00
|
|
|
static void ps2_common_reset(PS2State *s)
|
2005-11-26 13:36:25 +03:00
|
|
|
{
|
|
|
|
PS2Queue *q;
|
|
|
|
s->write_cmd = -1;
|
|
|
|
q = &s->queue;
|
|
|
|
q->rptr = 0;
|
|
|
|
q->wptr = 0;
|
|
|
|
q->count = 0;
|
2009-01-26 18:57:52 +03:00
|
|
|
s->update_irq(s->update_arg, 0);
|
2005-11-26 13:36:25 +03:00
|
|
|
}
|
|
|
|
|
2014-04-24 16:06:19 +04:00
|
|
|
static void ps2_common_post_load(PS2State *s)
|
|
|
|
{
|
|
|
|
PS2Queue *q = &s->queue;
|
|
|
|
int size;
|
|
|
|
int i;
|
|
|
|
int tmp_data[PS2_QUEUE_SIZE];
|
|
|
|
|
|
|
|
/* set the useful data buffer queue size, < PS2_QUEUE_SIZE */
|
|
|
|
size = q->count > PS2_QUEUE_SIZE ? 0 : q->count;
|
|
|
|
|
|
|
|
/* move the queue elements to the start of data array */
|
|
|
|
if (size > 0) {
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
/* move the queue elements to the temporary buffer */
|
|
|
|
tmp_data[i] = q->data[q->rptr];
|
|
|
|
if (++q->rptr == 256) {
|
|
|
|
q->rptr = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(q->data, tmp_data, size);
|
|
|
|
}
|
|
|
|
/* reset rptr/wptr/count */
|
|
|
|
q->rptr = 0;
|
|
|
|
q->wptr = size;
|
|
|
|
q->count = size;
|
|
|
|
s->update_irq(s->update_arg, q->count != 0);
|
|
|
|
}
|
|
|
|
|
2009-07-15 05:30:53 +04:00
|
|
|
static void ps2_kbd_reset(void *opaque)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState *) opaque;
|
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_kbd_reset(opaque);
|
2009-07-15 05:30:53 +04:00
|
|
|
ps2_common_reset(&s->common);
|
|
|
|
s->scan_enabled = 0;
|
|
|
|
s->translate = 0;
|
2016-03-23 09:21:40 +03:00
|
|
|
s->scancode_set = 2;
|
2009-07-15 05:30:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ps2_mouse_reset(void *opaque)
|
|
|
|
{
|
|
|
|
PS2MouseState *s = (PS2MouseState *) opaque;
|
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_mouse_reset(opaque);
|
2009-07-15 05:30:53 +04:00
|
|
|
ps2_common_reset(&s->common);
|
|
|
|
s->mouse_status = 0;
|
|
|
|
s->mouse_resolution = 0;
|
|
|
|
s->mouse_sample_rate = 0;
|
|
|
|
s->mouse_wrap = 0;
|
|
|
|
s->mouse_type = 0;
|
|
|
|
s->mouse_detect_state = 0;
|
|
|
|
s->mouse_dx = 0;
|
|
|
|
s->mouse_dy = 0;
|
|
|
|
s->mouse_dz = 0;
|
|
|
|
s->mouse_buttons = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 21:42:36 +04:00
|
|
|
static const VMStateDescription vmstate_ps2_common = {
|
|
|
|
.name = "PS2 Common State",
|
|
|
|
.version_id = 3,
|
|
|
|
.minimum_version_id = 2,
|
2014-04-16 17:32:32 +04:00
|
|
|
.fields = (VMStateField[]) {
|
2009-08-20 21:42:36 +04:00
|
|
|
VMSTATE_INT32(write_cmd, PS2State),
|
|
|
|
VMSTATE_INT32(queue.rptr, PS2State),
|
|
|
|
VMSTATE_INT32(queue.wptr, PS2State),
|
|
|
|
VMSTATE_INT32(queue.count, PS2State),
|
|
|
|
VMSTATE_BUFFER(queue.data, PS2State),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
2005-11-26 13:36:25 +03:00
|
|
|
|
2011-10-17 15:37:34 +04:00
|
|
|
static bool ps2_keyboard_ledstate_needed(void *opaque)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = opaque;
|
|
|
|
|
|
|
|
return s->ledstate != 0; /* 0 is default state */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ps2_kbd_ledstate_post_load(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = opaque;
|
|
|
|
|
|
|
|
kbd_put_ledstate(s->ledstate);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_ps2_keyboard_ledstate = {
|
|
|
|
.name = "ps2kbd/ledstate",
|
|
|
|
.version_id = 3,
|
|
|
|
.minimum_version_id = 2,
|
|
|
|
.post_load = ps2_kbd_ledstate_post_load,
|
2014-09-23 16:09:54 +04:00
|
|
|
.needed = ps2_keyboard_ledstate_needed,
|
2014-04-16 17:32:32 +04:00
|
|
|
.fields = (VMStateField[]) {
|
2011-10-17 15:37:34 +04:00
|
|
|
VMSTATE_INT32(ledstate, PS2KbdState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-15 23:06:25 +03:00
|
|
|
static bool ps2_keyboard_need_high_bit_needed(void *opaque)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = opaque;
|
|
|
|
return s->need_high_bit != 0; /* 0 is the usual state */
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_ps2_keyboard_need_high_bit = {
|
|
|
|
.name = "ps2kbd/need_high_bit",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = ps2_keyboard_need_high_bit_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_BOOL(need_high_bit, PS2KbdState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-09-30 00:48:23 +04:00
|
|
|
static int ps2_kbd_post_load(void* opaque, int version_id)
|
2005-11-26 13:36:25 +03:00
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState*)opaque;
|
2014-04-24 16:06:19 +04:00
|
|
|
PS2State *ps2 = &s->common;
|
2006-04-08 18:12:31 +04:00
|
|
|
|
2009-09-30 00:48:23 +04:00
|
|
|
if (version_id == 2)
|
2008-03-18 09:54:34 +03:00
|
|
|
s->scancode_set=2;
|
2014-04-24 16:06:19 +04:00
|
|
|
|
|
|
|
ps2_common_post_load(ps2);
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-24 16:06:19 +04:00
|
|
|
static void ps2_kbd_pre_save(void *opaque)
|
|
|
|
{
|
|
|
|
PS2KbdState *s = (PS2KbdState *)opaque;
|
|
|
|
PS2State *ps2 = &s->common;
|
|
|
|
|
|
|
|
ps2_common_post_load(ps2);
|
|
|
|
}
|
|
|
|
|
2009-08-20 21:42:36 +04:00
|
|
|
static const VMStateDescription vmstate_ps2_keyboard = {
|
|
|
|
.name = "ps2kbd",
|
|
|
|
.version_id = 3,
|
2009-09-30 00:48:23 +04:00
|
|
|
.minimum_version_id = 2,
|
|
|
|
.post_load = ps2_kbd_post_load,
|
2014-04-24 16:06:19 +04:00
|
|
|
.pre_save = ps2_kbd_pre_save,
|
2014-04-16 17:32:32 +04:00
|
|
|
.fields = (VMStateField[]) {
|
2009-08-20 21:42:36 +04:00
|
|
|
VMSTATE_STRUCT(common, PS2KbdState, 0, vmstate_ps2_common, PS2State),
|
|
|
|
VMSTATE_INT32(scan_enabled, PS2KbdState),
|
|
|
|
VMSTATE_INT32(translate, PS2KbdState),
|
|
|
|
VMSTATE_INT32_V(scancode_set, PS2KbdState,3),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2011-10-17 15:37:34 +04:00
|
|
|
},
|
2014-09-23 16:09:54 +04:00
|
|
|
.subsections = (const VMStateDescription*[]) {
|
|
|
|
&vmstate_ps2_keyboard_ledstate,
|
2016-09-15 23:06:25 +03:00
|
|
|
&vmstate_ps2_keyboard_need_high_bit,
|
2014-09-23 16:09:54 +04:00
|
|
|
NULL
|
2009-08-20 21:42:36 +04:00
|
|
|
}
|
|
|
|
};
|
2006-04-08 18:12:31 +04:00
|
|
|
|
2014-04-24 16:06:19 +04:00
|
|
|
static int ps2_mouse_post_load(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
PS2MouseState *s = (PS2MouseState *)opaque;
|
|
|
|
PS2State *ps2 = &s->common;
|
|
|
|
|
|
|
|
ps2_common_post_load(ps2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ps2_mouse_pre_save(void *opaque)
|
|
|
|
{
|
|
|
|
PS2MouseState *s = (PS2MouseState *)opaque;
|
|
|
|
PS2State *ps2 = &s->common;
|
|
|
|
|
|
|
|
ps2_common_post_load(ps2);
|
|
|
|
}
|
|
|
|
|
2009-08-20 21:42:36 +04:00
|
|
|
static const VMStateDescription vmstate_ps2_mouse = {
|
|
|
|
.name = "ps2mouse",
|
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2014-04-24 16:06:19 +04:00
|
|
|
.post_load = ps2_mouse_post_load,
|
|
|
|
.pre_save = ps2_mouse_pre_save,
|
2014-04-16 17:32:32 +04:00
|
|
|
.fields = (VMStateField[]) {
|
2009-08-20 21:42:36 +04:00
|
|
|
VMSTATE_STRUCT(common, PS2MouseState, 0, vmstate_ps2_common, PS2State),
|
|
|
|
VMSTATE_UINT8(mouse_status, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_resolution, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_sample_rate, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_wrap, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_type, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_detect_state, PS2MouseState),
|
|
|
|
VMSTATE_INT32(mouse_dx, PS2MouseState),
|
|
|
|
VMSTATE_INT32(mouse_dy, PS2MouseState),
|
|
|
|
VMSTATE_INT32(mouse_dz, PS2MouseState),
|
|
|
|
VMSTATE_UINT8(mouse_buttons, PS2MouseState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
2005-11-26 13:36:25 +03:00
|
|
|
|
2014-03-13 15:39:38 +04:00
|
|
|
static QemuInputHandler ps2_keyboard_handler = {
|
|
|
|
.name = "QEMU PS/2 Keyboard",
|
|
|
|
.mask = INPUT_EVENT_MASK_KEY,
|
|
|
|
.event = ps2_keyboard_event,
|
|
|
|
};
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
|
|
|
|
{
|
2011-08-21 07:09:37 +04:00
|
|
|
PS2KbdState *s = (PS2KbdState *)g_malloc0(sizeof(PS2KbdState));
|
2005-11-26 13:36:25 +03:00
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_kbd_init(s);
|
2005-11-26 13:36:25 +03:00
|
|
|
s->common.update_irq = update_irq;
|
|
|
|
s->common.update_arg = update_arg;
|
2008-03-18 09:54:34 +03:00
|
|
|
s->scancode_set = 2;
|
2010-06-25 21:09:07 +04:00
|
|
|
vmstate_register(NULL, 0, &vmstate_ps2_keyboard, s);
|
2014-03-13 15:39:38 +04:00
|
|
|
qemu_input_handler_register((DeviceState *)s,
|
|
|
|
&ps2_keyboard_handler);
|
2009-07-15 05:30:53 +04:00
|
|
|
qemu_register_reset(ps2_kbd_reset, s);
|
2005-11-26 13:36:25 +03:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2014-03-13 15:58:29 +04:00
|
|
|
static QemuInputHandler ps2_mouse_handler = {
|
|
|
|
.name = "QEMU PS/2 Mouse",
|
|
|
|
.mask = INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL,
|
|
|
|
.event = ps2_mouse_event,
|
|
|
|
.sync = ps2_mouse_sync,
|
|
|
|
};
|
|
|
|
|
2005-11-26 13:36:25 +03:00
|
|
|
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
|
|
|
|
{
|
2011-08-21 07:09:37 +04:00
|
|
|
PS2MouseState *s = (PS2MouseState *)g_malloc0(sizeof(PS2MouseState));
|
2005-11-26 13:36:25 +03:00
|
|
|
|
2015-01-16 22:21:37 +03:00
|
|
|
trace_ps2_mouse_init(s);
|
2005-11-26 13:36:25 +03:00
|
|
|
s->common.update_irq = update_irq;
|
|
|
|
s->common.update_arg = update_arg;
|
2010-06-25 21:09:07 +04:00
|
|
|
vmstate_register(NULL, 0, &vmstate_ps2_mouse, s);
|
2014-03-13 15:58:29 +04:00
|
|
|
qemu_input_handler_register((DeviceState *)s,
|
|
|
|
&ps2_mouse_handler);
|
2009-07-15 05:30:53 +04:00
|
|
|
qemu_register_reset(ps2_mouse_reset, s);
|
2005-11-26 13:36:25 +03:00
|
|
|
return s;
|
|
|
|
}
|