Commit ef74679a810fe6858f625b9d52b68cc3fc61eb3d

Authored by Dinesh Subhraveti
Committed by Anthony Liguori
1 parent 0bb05eaf

Initialize PS2 keyboard / mouse state on reset

Currently only common PS2 state is initialized, leaving keyboard and
mouse specific state to contain stale values.

Signed-off-by: Dinesh Subhraveti <dineshs@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 32 additions and 6 deletions
hw/ps2.c
... ... @@ -488,9 +488,8 @@ void ps2_write_mouse(void *opaque, int val)
488 488 }
489 489 }
490 490  
491   -static void ps2_reset(void *opaque)
  491 +static void ps2_common_reset(PS2State *s)
492 492 {
493   - PS2State *s = (PS2State *)opaque;
494 493 PS2Queue *q;
495 494 s->write_cmd = -1;
496 495 q = &s->queue;
... ... @@ -500,6 +499,33 @@ static void ps2_reset(void *opaque)
500 499 s->update_irq(s->update_arg, 0);
501 500 }
502 501  
  502 +static void ps2_kbd_reset(void *opaque)
  503 +{
  504 + PS2KbdState *s = (PS2KbdState *) opaque;
  505 +
  506 + ps2_common_reset(&s->common);
  507 + s->scan_enabled = 0;
  508 + s->translate = 0;
  509 + s->scancode_set = 0;
  510 +}
  511 +
  512 +static void ps2_mouse_reset(void *opaque)
  513 +{
  514 + PS2MouseState *s = (PS2MouseState *) opaque;
  515 +
  516 + ps2_common_reset(&s->common);
  517 + s->mouse_status = 0;
  518 + s->mouse_resolution = 0;
  519 + s->mouse_sample_rate = 0;
  520 + s->mouse_wrap = 0;
  521 + s->mouse_type = 0;
  522 + s->mouse_detect_state = 0;
  523 + s->mouse_dx = 0;
  524 + s->mouse_dy = 0;
  525 + s->mouse_dz = 0;
  526 + s->mouse_buttons = 0;
  527 +}
  528 +
503 529 static void ps2_common_save (QEMUFile *f, PS2State *s)
504 530 {
505 531 qemu_put_be32 (f, s->write_cmd);
... ... @@ -590,10 +616,10 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
590 616 s->common.update_irq = update_irq;
591 617 s->common.update_arg = update_arg;
592 618 s->scancode_set = 2;
593   - ps2_reset(&s->common);
  619 + ps2_kbd_reset(s);
594 620 register_savevm("ps2kbd", 0, 3, ps2_kbd_save, ps2_kbd_load, s);
595 621 qemu_add_kbd_event_handler(ps2_put_keycode, s);
596   - qemu_register_reset(ps2_reset, &s->common);
  622 + qemu_register_reset(ps2_kbd_reset, s);
597 623 return s;
598 624 }
599 625  
... ... @@ -603,9 +629,9 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
603 629  
604 630 s->common.update_irq = update_irq;
605 631 s->common.update_arg = update_arg;
606   - ps2_reset(&s->common);
  632 + ps2_mouse_reset(s);
607 633 register_savevm("ps2mouse", 0, 2, ps2_mouse_save, ps2_mouse_load, s);
608 634 qemu_add_mouse_event_handler(ps2_mouse_event, s, 0, "QEMU PS/2 Mouse");
609   - qemu_register_reset(ps2_reset, &s->common);
  635 + qemu_register_reset(ps2_mouse_reset, s);
610 636 return s;
611 637 }
... ...