1 /* 2 * QEMU PC keyboard 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 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #include "qemu/osdep.h" 26 #include "qemu/log.h" 27 #include "hw/hw.h" 28 #include "hw/isa/isa.h" 29 #include "migration/vmstate.h" 30 #include "hw/i386/pc.h" 31 #include "hw/input/ps2.h" 32 #include "hw/irq.h" 33 #include "hw/input/i8042.h" 34 #include "sysemu/reset.h" 35 #include "sysemu/sysemu.h" 36 37 #include "trace.h" 38 39 /* Keyboard Controller Commands */ 40 #define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */ 41 #define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */ 42 #define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */ 43 #define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */ 44 #define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */ 45 #define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */ 46 #define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */ 47 #define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */ 48 #define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */ 49 #define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */ 50 #define KBD_CCMD_READ_INPORT 0xC0 /* read input port */ 51 #define KBD_CCMD_READ_OUTPORT 0xD0 /* read output port */ 52 #define KBD_CCMD_WRITE_OUTPORT 0xD1 /* write output port */ 53 #define KBD_CCMD_WRITE_OBUF 0xD2 54 #define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if 55 initiated by the auxiliary device */ 56 #define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */ 57 #define KBD_CCMD_DISABLE_A20 0xDD /* HP vectra only ? */ 58 #define KBD_CCMD_ENABLE_A20 0xDF /* HP vectra only ? */ 59 #define KBD_CCMD_PULSE_BITS_3_0 0xF0 /* Pulse bits 3-0 of the output port P2. */ 60 #define KBD_CCMD_RESET 0xFE /* Pulse bit 0 of the output port P2 = CPU reset. */ 61 #define KBD_CCMD_NO_OP 0xFF /* Pulse no bits of the output port P2. */ 62 63 /* Keyboard Commands */ 64 #define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ 65 #define KBD_CMD_ECHO 0xEE 66 #define KBD_CMD_GET_ID 0xF2 /* get keyboard ID */ 67 #define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */ 68 #define KBD_CMD_ENABLE 0xF4 /* Enable scanning */ 69 #define KBD_CMD_RESET_DISABLE 0xF5 /* reset and disable scanning */ 70 #define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */ 71 #define KBD_CMD_RESET 0xFF /* Reset */ 72 73 /* Keyboard Replies */ 74 #define KBD_REPLY_POR 0xAA /* Power on reset */ 75 #define KBD_REPLY_ACK 0xFA /* Command ACK */ 76 #define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */ 77 78 /* Status Register Bits */ 79 #define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */ 80 #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ 81 #define KBD_STAT_SELFTEST 0x04 /* Self test successful */ 82 #define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */ 83 #define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */ 84 #define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */ 85 #define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */ 86 #define KBD_STAT_PERR 0x80 /* Parity error */ 87 88 /* Controller Mode Register Bits */ 89 #define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */ 90 #define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */ 91 #define KBD_MODE_SYS 0x04 /* The system flag (?) */ 92 #define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */ 93 #define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */ 94 #define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */ 95 #define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */ 96 #define KBD_MODE_RFU 0x80 97 98 /* Output Port Bits */ 99 #define KBD_OUT_RESET 0x01 /* 1=normal mode, 0=reset */ 100 #define KBD_OUT_A20 0x02 /* x86 only */ 101 #define KBD_OUT_OBF 0x10 /* Keyboard output buffer full */ 102 #define KBD_OUT_MOUSE_OBF 0x20 /* Mouse output buffer full */ 103 104 /* OSes typically write 0xdd/0xdf to turn the A20 line off and on. 105 * We make the default value of the outport include these four bits, 106 * so that the subsection is rarely necessary. 107 */ 108 #define KBD_OUT_ONES 0xcc 109 110 /* Mouse Commands */ 111 #define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ 112 #define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ 113 #define AUX_SET_RES 0xE8 /* Set resolution */ 114 #define AUX_GET_SCALE 0xE9 /* Get scaling factor */ 115 #define AUX_SET_STREAM 0xEA /* Set stream mode */ 116 #define AUX_POLL 0xEB /* Poll */ 117 #define AUX_RESET_WRAP 0xEC /* Reset wrap mode */ 118 #define AUX_SET_WRAP 0xEE /* Set wrap mode */ 119 #define AUX_SET_REMOTE 0xF0 /* Set remote mode */ 120 #define AUX_GET_TYPE 0xF2 /* Get type */ 121 #define AUX_SET_SAMPLE 0xF3 /* Set sample rate */ 122 #define AUX_ENABLE_DEV 0xF4 /* Enable aux device */ 123 #define AUX_DISABLE_DEV 0xF5 /* Disable aux device */ 124 #define AUX_SET_DEFAULT 0xF6 125 #define AUX_RESET 0xFF /* Reset aux device */ 126 #define AUX_ACK 0xFA /* Command byte ACK. */ 127 128 #define MOUSE_STATUS_REMOTE 0x40 129 #define MOUSE_STATUS_ENABLED 0x20 130 #define MOUSE_STATUS_SCALE21 0x10 131 132 #define KBD_PENDING_KBD 1 133 #define KBD_PENDING_AUX 2 134 135 typedef struct KBDState { 136 uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ 137 uint8_t status; 138 uint8_t mode; 139 uint8_t outport; 140 bool outport_present; 141 /* Bitmask of devices with data available. */ 142 uint8_t pending; 143 void *kbd; 144 void *mouse; 145 146 qemu_irq irq_kbd; 147 qemu_irq irq_mouse; 148 qemu_irq a20_out; 149 hwaddr mask; 150 } KBDState; 151 152 /* update irq and KBD_STAT_[MOUSE_]OBF */ 153 /* XXX: not generating the irqs if KBD_MODE_DISABLE_KBD is set may be 154 incorrect, but it avoids having to simulate exact delays */ 155 static void kbd_update_irq(KBDState *s) 156 { 157 int irq_kbd_level, irq_mouse_level; 158 159 irq_kbd_level = 0; 160 irq_mouse_level = 0; 161 s->status &= ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); 162 s->outport &= ~(KBD_OUT_OBF | KBD_OUT_MOUSE_OBF); 163 if (s->pending) { 164 s->status |= KBD_STAT_OBF; 165 s->outport |= KBD_OUT_OBF; 166 /* kbd data takes priority over aux data. */ 167 if (s->pending == KBD_PENDING_AUX) { 168 s->status |= KBD_STAT_MOUSE_OBF; 169 s->outport |= KBD_OUT_MOUSE_OBF; 170 if (s->mode & KBD_MODE_MOUSE_INT) 171 irq_mouse_level = 1; 172 } else { 173 if ((s->mode & KBD_MODE_KBD_INT) && 174 !(s->mode & KBD_MODE_DISABLE_KBD)) 175 irq_kbd_level = 1; 176 } 177 } 178 qemu_set_irq(s->irq_kbd, irq_kbd_level); 179 qemu_set_irq(s->irq_mouse, irq_mouse_level); 180 } 181 182 static void kbd_update_kbd_irq(void *opaque, int level) 183 { 184 KBDState *s = (KBDState *)opaque; 185 186 if (level) 187 s->pending |= KBD_PENDING_KBD; 188 else 189 s->pending &= ~KBD_PENDING_KBD; 190 kbd_update_irq(s); 191 } 192 193 static void kbd_update_aux_irq(void *opaque, int level) 194 { 195 KBDState *s = (KBDState *)opaque; 196 197 if (level) 198 s->pending |= KBD_PENDING_AUX; 199 else 200 s->pending &= ~KBD_PENDING_AUX; 201 kbd_update_irq(s); 202 } 203 204 static uint64_t kbd_read_status(void *opaque, hwaddr addr, 205 unsigned size) 206 { 207 KBDState *s = opaque; 208 int val; 209 val = s->status; 210 trace_pckbd_kbd_read_status(val); 211 return val; 212 } 213 214 static void kbd_queue(KBDState *s, int b, int aux) 215 { 216 if (aux) 217 ps2_queue(s->mouse, b); 218 else 219 ps2_queue(s->kbd, b); 220 } 221 222 static void outport_write(KBDState *s, uint32_t val) 223 { 224 trace_pckbd_outport_write(val); 225 s->outport = val; 226 qemu_set_irq(s->a20_out, (val >> 1) & 1); 227 if (!(val & 1)) { 228 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); 229 } 230 } 231 232 static void kbd_write_command(void *opaque, hwaddr addr, 233 uint64_t val, unsigned size) 234 { 235 KBDState *s = opaque; 236 237 trace_pckbd_kbd_write_command(val); 238 239 /* Bits 3-0 of the output port P2 of the keyboard controller may be pulsed 240 * low for approximately 6 micro seconds. Bits 3-0 of the KBD_CCMD_PULSE 241 * command specify the output port bits to be pulsed. 242 * 0: Bit should be pulsed. 1: Bit should not be modified. 243 * The only useful version of this command is pulsing bit 0, 244 * which does a CPU reset. 245 */ 246 if((val & KBD_CCMD_PULSE_BITS_3_0) == KBD_CCMD_PULSE_BITS_3_0) { 247 if(!(val & 1)) 248 val = KBD_CCMD_RESET; 249 else 250 val = KBD_CCMD_NO_OP; 251 } 252 253 switch(val) { 254 case KBD_CCMD_READ_MODE: 255 kbd_queue(s, s->mode, 0); 256 break; 257 case KBD_CCMD_WRITE_MODE: 258 case KBD_CCMD_WRITE_OBUF: 259 case KBD_CCMD_WRITE_AUX_OBUF: 260 case KBD_CCMD_WRITE_MOUSE: 261 case KBD_CCMD_WRITE_OUTPORT: 262 s->write_cmd = val; 263 break; 264 case KBD_CCMD_MOUSE_DISABLE: 265 s->mode |= KBD_MODE_DISABLE_MOUSE; 266 break; 267 case KBD_CCMD_MOUSE_ENABLE: 268 s->mode &= ~KBD_MODE_DISABLE_MOUSE; 269 break; 270 case KBD_CCMD_TEST_MOUSE: 271 kbd_queue(s, 0x00, 0); 272 break; 273 case KBD_CCMD_SELF_TEST: 274 s->status |= KBD_STAT_SELFTEST; 275 kbd_queue(s, 0x55, 0); 276 break; 277 case KBD_CCMD_KBD_TEST: 278 kbd_queue(s, 0x00, 0); 279 break; 280 case KBD_CCMD_KBD_DISABLE: 281 s->mode |= KBD_MODE_DISABLE_KBD; 282 kbd_update_irq(s); 283 break; 284 case KBD_CCMD_KBD_ENABLE: 285 s->mode &= ~KBD_MODE_DISABLE_KBD; 286 kbd_update_irq(s); 287 break; 288 case KBD_CCMD_READ_INPORT: 289 kbd_queue(s, 0x80, 0); 290 break; 291 case KBD_CCMD_READ_OUTPORT: 292 kbd_queue(s, s->outport, 0); 293 break; 294 case KBD_CCMD_ENABLE_A20: 295 qemu_irq_raise(s->a20_out); 296 s->outport |= KBD_OUT_A20; 297 break; 298 case KBD_CCMD_DISABLE_A20: 299 qemu_irq_lower(s->a20_out); 300 s->outport &= ~KBD_OUT_A20; 301 break; 302 case KBD_CCMD_RESET: 303 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); 304 break; 305 case KBD_CCMD_NO_OP: 306 /* ignore that */ 307 break; 308 default: 309 qemu_log_mask(LOG_GUEST_ERROR, 310 "unsupported keyboard cmd=0x%02" PRIx64 "\n", val); 311 break; 312 } 313 } 314 315 static uint64_t kbd_read_data(void *opaque, hwaddr addr, 316 unsigned size) 317 { 318 KBDState *s = opaque; 319 uint32_t val; 320 321 if (s->pending == KBD_PENDING_AUX) 322 val = ps2_read_data(s->mouse); 323 else 324 val = ps2_read_data(s->kbd); 325 326 trace_pckbd_kbd_read_data(val); 327 return val; 328 } 329 330 static void kbd_write_data(void *opaque, hwaddr addr, 331 uint64_t val, unsigned size) 332 { 333 KBDState *s = opaque; 334 335 trace_pckbd_kbd_write_data(val); 336 337 switch(s->write_cmd) { 338 case 0: 339 ps2_write_keyboard(s->kbd, val); 340 break; 341 case KBD_CCMD_WRITE_MODE: 342 s->mode = val; 343 ps2_keyboard_set_translation(s->kbd, (s->mode & KBD_MODE_KCC) != 0); 344 /* ??? */ 345 kbd_update_irq(s); 346 break; 347 case KBD_CCMD_WRITE_OBUF: 348 kbd_queue(s, val, 0); 349 break; 350 case KBD_CCMD_WRITE_AUX_OBUF: 351 kbd_queue(s, val, 1); 352 break; 353 case KBD_CCMD_WRITE_OUTPORT: 354 outport_write(s, val); 355 break; 356 case KBD_CCMD_WRITE_MOUSE: 357 ps2_write_mouse(s->mouse, val); 358 break; 359 default: 360 break; 361 } 362 s->write_cmd = 0; 363 } 364 365 static void kbd_reset(void *opaque) 366 { 367 KBDState *s = opaque; 368 369 s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; 370 s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED; 371 s->outport = KBD_OUT_RESET | KBD_OUT_A20 | KBD_OUT_ONES; 372 s->outport_present = false; 373 } 374 375 static uint8_t kbd_outport_default(KBDState *s) 376 { 377 return KBD_OUT_RESET | KBD_OUT_A20 | KBD_OUT_ONES 378 | (s->status & KBD_STAT_OBF ? KBD_OUT_OBF : 0) 379 | (s->status & KBD_STAT_MOUSE_OBF ? KBD_OUT_MOUSE_OBF : 0); 380 } 381 382 static int kbd_outport_post_load(void *opaque, int version_id) 383 { 384 KBDState *s = opaque; 385 s->outport_present = true; 386 return 0; 387 } 388 389 static bool kbd_outport_needed(void *opaque) 390 { 391 KBDState *s = opaque; 392 return s->outport != kbd_outport_default(s); 393 } 394 395 static const VMStateDescription vmstate_kbd_outport = { 396 .name = "pckbd_outport", 397 .version_id = 1, 398 .minimum_version_id = 1, 399 .post_load = kbd_outport_post_load, 400 .needed = kbd_outport_needed, 401 .fields = (VMStateField[]) { 402 VMSTATE_UINT8(outport, KBDState), 403 VMSTATE_END_OF_LIST() 404 } 405 }; 406 407 static int kbd_post_load(void *opaque, int version_id) 408 { 409 KBDState *s = opaque; 410 if (!s->outport_present) { 411 s->outport = kbd_outport_default(s); 412 } 413 s->outport_present = false; 414 return 0; 415 } 416 417 static const VMStateDescription vmstate_kbd = { 418 .name = "pckbd", 419 .version_id = 3, 420 .minimum_version_id = 3, 421 .post_load = kbd_post_load, 422 .fields = (VMStateField[]) { 423 VMSTATE_UINT8(write_cmd, KBDState), 424 VMSTATE_UINT8(status, KBDState), 425 VMSTATE_UINT8(mode, KBDState), 426 VMSTATE_UINT8(pending, KBDState), 427 VMSTATE_END_OF_LIST() 428 }, 429 .subsections = (const VMStateDescription*[]) { 430 &vmstate_kbd_outport, 431 NULL 432 } 433 }; 434 435 /* Memory mapped interface */ 436 static uint64_t kbd_mm_readfn(void *opaque, hwaddr addr, unsigned size) 437 { 438 KBDState *s = opaque; 439 440 if (addr & s->mask) 441 return kbd_read_status(s, 0, 1) & 0xff; 442 else 443 return kbd_read_data(s, 0, 1) & 0xff; 444 } 445 446 static void kbd_mm_writefn(void *opaque, hwaddr addr, 447 uint64_t value, unsigned size) 448 { 449 KBDState *s = opaque; 450 451 if (addr & s->mask) 452 kbd_write_command(s, 0, value & 0xff, 1); 453 else 454 kbd_write_data(s, 0, value & 0xff, 1); 455 } 456 457 458 static const MemoryRegionOps i8042_mmio_ops = { 459 .read = kbd_mm_readfn, 460 .write = kbd_mm_writefn, 461 .valid.min_access_size = 1, 462 .valid.max_access_size = 4, 463 .endianness = DEVICE_NATIVE_ENDIAN, 464 }; 465 466 void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, 467 MemoryRegion *region, ram_addr_t size, 468 hwaddr mask) 469 { 470 KBDState *s = g_malloc0(sizeof(KBDState)); 471 472 s->irq_kbd = kbd_irq; 473 s->irq_mouse = mouse_irq; 474 s->mask = mask; 475 476 vmstate_register(NULL, 0, &vmstate_kbd, s); 477 478 memory_region_init_io(region, NULL, &i8042_mmio_ops, s, "i8042", size); 479 480 s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s); 481 s->mouse = ps2_mouse_init(kbd_update_aux_irq, s); 482 qemu_register_reset(kbd_reset, s); 483 } 484 485 #define I8042(obj) OBJECT_CHECK(ISAKBDState, (obj), TYPE_I8042) 486 487 typedef struct ISAKBDState { 488 ISADevice parent_obj; 489 490 KBDState kbd; 491 MemoryRegion io[2]; 492 } ISAKBDState; 493 494 void i8042_isa_mouse_fake_event(void *opaque) 495 { 496 ISADevice *dev = opaque; 497 ISAKBDState *isa = I8042(dev); 498 KBDState *s = &isa->kbd; 499 500 ps2_mouse_fake_event(s->mouse); 501 } 502 503 void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out) 504 { 505 qdev_connect_gpio_out_named(DEVICE(dev), I8042_A20_LINE, 0, a20_out); 506 } 507 508 static const VMStateDescription vmstate_kbd_isa = { 509 .name = "pckbd", 510 .version_id = 3, 511 .minimum_version_id = 3, 512 .fields = (VMStateField[]) { 513 VMSTATE_STRUCT(kbd, ISAKBDState, 0, vmstate_kbd, KBDState), 514 VMSTATE_END_OF_LIST() 515 } 516 }; 517 518 static const MemoryRegionOps i8042_data_ops = { 519 .read = kbd_read_data, 520 .write = kbd_write_data, 521 .impl = { 522 .min_access_size = 1, 523 .max_access_size = 1, 524 }, 525 .endianness = DEVICE_LITTLE_ENDIAN, 526 }; 527 528 static const MemoryRegionOps i8042_cmd_ops = { 529 .read = kbd_read_status, 530 .write = kbd_write_command, 531 .impl = { 532 .min_access_size = 1, 533 .max_access_size = 1, 534 }, 535 .endianness = DEVICE_LITTLE_ENDIAN, 536 }; 537 538 static void i8042_initfn(Object *obj) 539 { 540 ISAKBDState *isa_s = I8042(obj); 541 KBDState *s = &isa_s->kbd; 542 543 memory_region_init_io(isa_s->io + 0, obj, &i8042_data_ops, s, 544 "i8042-data", 1); 545 memory_region_init_io(isa_s->io + 1, obj, &i8042_cmd_ops, s, 546 "i8042-cmd", 1); 547 548 qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, I8042_A20_LINE, 1); 549 } 550 551 static void i8042_realizefn(DeviceState *dev, Error **errp) 552 { 553 ISADevice *isadev = ISA_DEVICE(dev); 554 ISAKBDState *isa_s = I8042(dev); 555 KBDState *s = &isa_s->kbd; 556 557 isa_init_irq(isadev, &s->irq_kbd, 1); 558 isa_init_irq(isadev, &s->irq_mouse, 12); 559 560 isa_register_ioport(isadev, isa_s->io + 0, 0x60); 561 isa_register_ioport(isadev, isa_s->io + 1, 0x64); 562 563 s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s); 564 s->mouse = ps2_mouse_init(kbd_update_aux_irq, s); 565 qemu_register_reset(kbd_reset, s); 566 } 567 568 static void i8042_class_initfn(ObjectClass *klass, void *data) 569 { 570 DeviceClass *dc = DEVICE_CLASS(klass); 571 572 dc->realize = i8042_realizefn; 573 dc->vmsd = &vmstate_kbd_isa; 574 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 575 } 576 577 static const TypeInfo i8042_info = { 578 .name = TYPE_I8042, 579 .parent = TYPE_ISA_DEVICE, 580 .instance_size = sizeof(ISAKBDState), 581 .instance_init = i8042_initfn, 582 .class_init = i8042_class_initfn, 583 }; 584 585 static void i8042_register_types(void) 586 { 587 type_register_static(&i8042_info); 588 } 589 590 type_init(i8042_register_types) 591