ps2.c (46919512fcfec1e677733a16bc178898c524854f) ps2.c (af0f07dfc7ce56a944c38d872b7d4502178e6948)
1/*
2 * QEMU PS/2 keyboard/mouse emulation
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 1079 unchanged lines hidden (view full) ---

1088 s->mouse_dw = 0;
1089 s->mouse_buttons = 0;
1090}
1091
1092static const VMStateDescription vmstate_ps2_common = {
1093 .name = "PS2 Common State",
1094 .version_id = 3,
1095 .minimum_version_id = 2,
1/*
2 * QEMU PS/2 keyboard/mouse emulation
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 1079 unchanged lines hidden (view full) ---

1088 s->mouse_dw = 0;
1089 s->mouse_buttons = 0;
1090}
1091
1092static const VMStateDescription vmstate_ps2_common = {
1093 .name = "PS2 Common State",
1094 .version_id = 3,
1095 .minimum_version_id = 2,
1096 .fields = (VMStateField[]) {
1096 .fields = (const VMStateField[]) {
1097 VMSTATE_INT32(write_cmd, PS2State),
1098 VMSTATE_INT32(queue.rptr, PS2State),
1099 VMSTATE_INT32(queue.wptr, PS2State),
1100 VMSTATE_INT32(queue.count, PS2State),
1101 VMSTATE_BUFFER(queue.data, PS2State),
1102 VMSTATE_END_OF_LIST()
1103 }
1104};

--- 14 unchanged lines hidden (view full) ---

1119}
1120
1121static const VMStateDescription vmstate_ps2_keyboard_ledstate = {
1122 .name = "ps2kbd/ledstate",
1123 .version_id = 3,
1124 .minimum_version_id = 2,
1125 .post_load = ps2_kbd_ledstate_post_load,
1126 .needed = ps2_keyboard_ledstate_needed,
1097 VMSTATE_INT32(write_cmd, PS2State),
1098 VMSTATE_INT32(queue.rptr, PS2State),
1099 VMSTATE_INT32(queue.wptr, PS2State),
1100 VMSTATE_INT32(queue.count, PS2State),
1101 VMSTATE_BUFFER(queue.data, PS2State),
1102 VMSTATE_END_OF_LIST()
1103 }
1104};

--- 14 unchanged lines hidden (view full) ---

1119}
1120
1121static const VMStateDescription vmstate_ps2_keyboard_ledstate = {
1122 .name = "ps2kbd/ledstate",
1123 .version_id = 3,
1124 .minimum_version_id = 2,
1125 .post_load = ps2_kbd_ledstate_post_load,
1126 .needed = ps2_keyboard_ledstate_needed,
1127 .fields = (VMStateField[]) {
1127 .fields = (const VMStateField[]) {
1128 VMSTATE_INT32(ledstate, PS2KbdState),
1129 VMSTATE_END_OF_LIST()
1130 }
1131};
1132
1133static bool ps2_keyboard_need_high_bit_needed(void *opaque)
1134{
1135 PS2KbdState *s = opaque;
1136 return s->need_high_bit != 0; /* 0 is the usual state */
1137}
1138
1139static const VMStateDescription vmstate_ps2_keyboard_need_high_bit = {
1140 .name = "ps2kbd/need_high_bit",
1141 .version_id = 1,
1142 .minimum_version_id = 1,
1143 .needed = ps2_keyboard_need_high_bit_needed,
1128 VMSTATE_INT32(ledstate, PS2KbdState),
1129 VMSTATE_END_OF_LIST()
1130 }
1131};
1132
1133static bool ps2_keyboard_need_high_bit_needed(void *opaque)
1134{
1135 PS2KbdState *s = opaque;
1136 return s->need_high_bit != 0; /* 0 is the usual state */
1137}
1138
1139static const VMStateDescription vmstate_ps2_keyboard_need_high_bit = {
1140 .name = "ps2kbd/need_high_bit",
1141 .version_id = 1,
1142 .minimum_version_id = 1,
1143 .needed = ps2_keyboard_need_high_bit_needed,
1144 .fields = (VMStateField[]) {
1144 .fields = (const VMStateField[]) {
1145 VMSTATE_BOOL(need_high_bit, PS2KbdState),
1146 VMSTATE_END_OF_LIST()
1147 }
1148};
1149
1150static bool ps2_keyboard_cqueue_needed(void *opaque)
1151{
1152 PS2KbdState *s = opaque;
1153 PS2State *ps2 = PS2_DEVICE(s);
1154
1155 return ps2->queue.cwptr != -1; /* the queue is mostly empty */
1156}
1157
1158static const VMStateDescription vmstate_ps2_keyboard_cqueue = {
1159 .name = "ps2kbd/command_reply_queue",
1160 .needed = ps2_keyboard_cqueue_needed,
1145 VMSTATE_BOOL(need_high_bit, PS2KbdState),
1146 VMSTATE_END_OF_LIST()
1147 }
1148};
1149
1150static bool ps2_keyboard_cqueue_needed(void *opaque)
1151{
1152 PS2KbdState *s = opaque;
1153 PS2State *ps2 = PS2_DEVICE(s);
1154
1155 return ps2->queue.cwptr != -1; /* the queue is mostly empty */
1156}
1157
1158static const VMStateDescription vmstate_ps2_keyboard_cqueue = {
1159 .name = "ps2kbd/command_reply_queue",
1160 .needed = ps2_keyboard_cqueue_needed,
1161 .fields = (VMStateField[]) {
1161 .fields = (const VMStateField[]) {
1162 VMSTATE_INT32(parent_obj.queue.cwptr, PS2KbdState),
1163 VMSTATE_END_OF_LIST()
1164 }
1165};
1166
1167static int ps2_kbd_post_load(void *opaque, int version_id)
1168{
1169 PS2KbdState *s = (PS2KbdState *)opaque;

--- 8 unchanged lines hidden (view full) ---

1178 return 0;
1179}
1180
1181static const VMStateDescription vmstate_ps2_keyboard = {
1182 .name = "ps2kbd",
1183 .version_id = 3,
1184 .minimum_version_id = 2,
1185 .post_load = ps2_kbd_post_load,
1162 VMSTATE_INT32(parent_obj.queue.cwptr, PS2KbdState),
1163 VMSTATE_END_OF_LIST()
1164 }
1165};
1166
1167static int ps2_kbd_post_load(void *opaque, int version_id)
1168{
1169 PS2KbdState *s = (PS2KbdState *)opaque;

--- 8 unchanged lines hidden (view full) ---

1178 return 0;
1179}
1180
1181static const VMStateDescription vmstate_ps2_keyboard = {
1182 .name = "ps2kbd",
1183 .version_id = 3,
1184 .minimum_version_id = 2,
1185 .post_load = ps2_kbd_post_load,
1186 .fields = (VMStateField[]) {
1186 .fields = (const VMStateField[]) {
1187 VMSTATE_STRUCT(parent_obj, PS2KbdState, 0, vmstate_ps2_common,
1188 PS2State),
1189 VMSTATE_INT32(scan_enabled, PS2KbdState),
1190 VMSTATE_INT32(translate, PS2KbdState),
1191 VMSTATE_INT32_V(scancode_set, PS2KbdState, 3),
1192 VMSTATE_END_OF_LIST()
1193 },
1187 VMSTATE_STRUCT(parent_obj, PS2KbdState, 0, vmstate_ps2_common,
1188 PS2State),
1189 VMSTATE_INT32(scan_enabled, PS2KbdState),
1190 VMSTATE_INT32(translate, PS2KbdState),
1191 VMSTATE_INT32_V(scancode_set, PS2KbdState, 3),
1192 VMSTATE_END_OF_LIST()
1193 },
1194 .subsections = (const VMStateDescription * []) {
1194 .subsections = (const VMStateDescription * const []) {
1195 &vmstate_ps2_keyboard_ledstate,
1196 &vmstate_ps2_keyboard_need_high_bit,
1197 &vmstate_ps2_keyboard_cqueue,
1198 NULL
1199 }
1200};
1201
1202static int ps2_mouse_post_load(void *opaque, int version_id)

--- 6 unchanged lines hidden (view full) ---

1209 return 0;
1210}
1211
1212static const VMStateDescription vmstate_ps2_mouse = {
1213 .name = "ps2mouse",
1214 .version_id = 2,
1215 .minimum_version_id = 2,
1216 .post_load = ps2_mouse_post_load,
1195 &vmstate_ps2_keyboard_ledstate,
1196 &vmstate_ps2_keyboard_need_high_bit,
1197 &vmstate_ps2_keyboard_cqueue,
1198 NULL
1199 }
1200};
1201
1202static int ps2_mouse_post_load(void *opaque, int version_id)

--- 6 unchanged lines hidden (view full) ---

1209 return 0;
1210}
1211
1212static const VMStateDescription vmstate_ps2_mouse = {
1213 .name = "ps2mouse",
1214 .version_id = 2,
1215 .minimum_version_id = 2,
1216 .post_load = ps2_mouse_post_load,
1217 .fields = (VMStateField[]) {
1217 .fields = (const VMStateField[]) {
1218 VMSTATE_STRUCT(parent_obj, PS2MouseState, 0, vmstate_ps2_common,
1219 PS2State),
1220 VMSTATE_UINT8(mouse_status, PS2MouseState),
1221 VMSTATE_UINT8(mouse_resolution, PS2MouseState),
1222 VMSTATE_UINT8(mouse_sample_rate, PS2MouseState),
1223 VMSTATE_UINT8(mouse_wrap, PS2MouseState),
1224 VMSTATE_UINT8(mouse_type, PS2MouseState),
1225 VMSTATE_UINT8(mouse_detect_state, PS2MouseState),

--- 104 unchanged lines hidden ---
1218 VMSTATE_STRUCT(parent_obj, PS2MouseState, 0, vmstate_ps2_common,
1219 PS2State),
1220 VMSTATE_UINT8(mouse_status, PS2MouseState),
1221 VMSTATE_UINT8(mouse_resolution, PS2MouseState),
1222 VMSTATE_UINT8(mouse_sample_rate, PS2MouseState),
1223 VMSTATE_UINT8(mouse_wrap, PS2MouseState),
1224 VMSTATE_UINT8(mouse_type, PS2MouseState),
1225 VMSTATE_UINT8(mouse_detect_state, PS2MouseState),

--- 104 unchanged lines hidden ---