diff options
Diffstat (limited to 'hw/adb.c')
-rw-r--r-- | hw/adb.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -262,6 +262,31 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, return olen; } +static void adb_kbd_save(QEMUFile *f, void *opaque) +{ + KBDState *s = (KBDState *)opaque; + + qemu_put_buffer(f, s->data, sizeof(s->data)); + qemu_put_sbe32s(f, &s->rptr); + qemu_put_sbe32s(f, &s->wptr); + qemu_put_sbe32s(f, &s->count); +} + +static int adb_kbd_load(QEMUFile *f, void *opaque, int version_id) +{ + KBDState *s = (KBDState *)opaque; + + if (version_id != 1) + return -EINVAL; + + qemu_get_buffer(f, s->data, sizeof(s->data)); + qemu_get_sbe32s(f, &s->rptr); + qemu_get_sbe32s(f, &s->wptr); + qemu_get_sbe32s(f, &s->count); + + return 0; +} + static int adb_kbd_reset(ADBDevice *d) { KBDState *s = d->opaque; @@ -281,6 +306,8 @@ void adb_kbd_init(ADBBusState *bus) d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request, adb_kbd_reset, s); qemu_add_kbd_event_handler(adb_kbd_put_keycode, d); + register_savevm("adb_kbd", -1, 1, adb_kbd_save, + adb_kbd_load, s); } /***************************************************************/ @@ -413,6 +440,33 @@ static int adb_mouse_reset(ADBDevice *d) return 0; } +static void adb_mouse_save(QEMUFile *f, void *opaque) +{ + MouseState *s = (MouseState *)opaque; + + qemu_put_sbe32s(f, &s->buttons_state); + qemu_put_sbe32s(f, &s->last_buttons_state); + qemu_put_sbe32s(f, &s->dx); + qemu_put_sbe32s(f, &s->dy); + qemu_put_sbe32s(f, &s->dz); +} + +static int adb_mouse_load(QEMUFile *f, void *opaque, int version_id) +{ + MouseState *s = (MouseState *)opaque; + + if (version_id != 1) + return -EINVAL; + + qemu_get_sbe32s(f, &s->buttons_state); + qemu_get_sbe32s(f, &s->last_buttons_state); + qemu_get_sbe32s(f, &s->dx); + qemu_get_sbe32s(f, &s->dy); + qemu_get_sbe32s(f, &s->dz); + + return 0; +} + void adb_mouse_init(ADBBusState *bus) { ADBDevice *d; @@ -422,4 +476,6 @@ void adb_mouse_init(ADBBusState *bus) d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request, adb_mouse_reset, s); qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse"); + register_savevm("adb_mouse", -1, 1, adb_mouse_save, + adb_mouse_load, s); } |