| 184 | } |
| 185 | |
| 186 | void ps2_write_keyboard(void *opaque, int val) |
| 187 | { |
| 188 | PS2KbdState *s = (PS2KbdState *)opaque; |
| 189 | |
| 190 | switch(s->common.write_cmd) { |
| 191 | default: |
| 192 | case -1: |
| 193 | switch(val) { |
| 194 | case 0x00: |
| 195 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 196 | break; |
| 197 | case 0x05: |
| 198 | ps2_queue(&s->common, KBD_REPLY_RESEND); |
| 199 | break; |
| 200 | case KBD_CMD_GET_ID: |
| 201 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 202 | ps2_queue(&s->common, 0xab); |
| 203 | ps2_queue(&s->common, 0x83); |
| 204 | break; |
| 205 | case KBD_CMD_ECHO: |
| 206 | ps2_queue(&s->common, KBD_CMD_ECHO); |
| 207 | break; |
| 208 | case KBD_CMD_ENABLE: |
| 209 | s->scan_enabled = 1; |
| 210 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 211 | break; |
| 212 | case KBD_CMD_SET_LEDS: |
| 213 | case KBD_CMD_SET_RATE: |
| 214 | s->common.write_cmd = val; |
| 215 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 216 | break; |
| 217 | case KBD_CMD_RESET_DISABLE: |
| 218 | ps2_reset_keyboard(s); |
| 219 | s->scan_enabled = 0; |
| 220 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 221 | break; |
| 222 | case KBD_CMD_RESET_ENABLE: |
| 223 | ps2_reset_keyboard(s); |
| 224 | s->scan_enabled = 1; |
| 225 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 226 | break; |
| 227 | case KBD_CMD_RESET: |
| 228 | ps2_reset_keyboard(s); |
| 229 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 230 | ps2_queue(&s->common, KBD_REPLY_POR); |
| 231 | break; |
| 232 | default: |
| 233 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 234 | break; |
| 235 | } |
| 236 | break; |
| 237 | case KBD_CMD_SET_LEDS: |
| 238 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 239 | s->common.write_cmd = -1; |
| 240 | break; |
| 241 | case KBD_CMD_SET_RATE: |
| 242 | ps2_queue(&s->common, KBD_REPLY_ACK); |
| 243 | s->common.write_cmd = -1; |
no test coverage detected