]> Git Repo - qemu.git/blobdiff - hw/adb.c
qxl/update_area_io: guest_bug on invalid parameters
[qemu.git] / hw / adb.c
index d6b0298b1ccbc0505113f2e8ffbec168b59158c8..aa15f55dc9a5d58d69d259bf880cf38788be3ef6 100644 (file)
--- a/hw/adb.c
+++ b/hw/adb.c
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "adb.h"
 #include "console.h"
 
 /* debug ADB */
 //#define DEBUG_ADB
 
 #ifdef DEBUG_ADB
-#define ADB_DPRINTF(fmt, args...) \
-do { printf("ADB: " fmt , ##args); } while (0)
+#define ADB_DPRINTF(fmt, ...) \
+do { printf("ADB: " fmt , ## __VA_ARGS__); } while (0)
 #else
-#define ADB_DPRINTF(fmt, args...)
+#define ADB_DPRINTF(fmt, ...)
 #endif
 
 /* ADB commands */
@@ -122,6 +122,7 @@ ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
     d->devreq = devreq;
     d->devreset = devreset;
     d->opaque = opaque;
+    qemu_register_reset((QEMUResetHandler *)devreset, d);
     return d;
 }
 
@@ -260,6 +261,20 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
     return olen;
 }
 
+static const VMStateDescription vmstate_adb_kbd = {
+    .name = "adb_kbd",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_BUFFER(data, KBDState),
+        VMSTATE_INT32(rptr, KBDState),
+        VMSTATE_INT32(wptr, KBDState),
+        VMSTATE_INT32(count, KBDState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static int adb_kbd_reset(ADBDevice *d)
 {
     KBDState *s = d->opaque;
@@ -275,11 +290,11 @@ void adb_kbd_init(ADBBusState *bus)
 {
     ADBDevice *d;
     KBDState *s;
-    s = qemu_mallocz(sizeof(KBDState));
+    s = g_malloc0(sizeof(KBDState));
     d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request,
                             adb_kbd_reset, s);
-    adb_kbd_reset(d);
     qemu_add_kbd_event_handler(adb_kbd_put_keycode, d);
+    vmstate_register(NULL, -1, &vmstate_adb_kbd, s);
 }
 
 /***************************************************************/
@@ -412,14 +427,29 @@ static int adb_mouse_reset(ADBDevice *d)
     return 0;
 }
 
+static const VMStateDescription vmstate_adb_mouse = {
+    .name = "adb_mouse",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_INT32(buttons_state, MouseState),
+        VMSTATE_INT32(last_buttons_state, MouseState),
+        VMSTATE_INT32(dx, MouseState),
+        VMSTATE_INT32(dy, MouseState),
+        VMSTATE_INT32(dz, MouseState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 void adb_mouse_init(ADBBusState *bus)
 {
     ADBDevice *d;
     MouseState *s;
 
-    s = qemu_mallocz(sizeof(MouseState));
+    s = g_malloc0(sizeof(MouseState));
     d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request,
                             adb_mouse_reset, s);
-    adb_mouse_reset(d);
     qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse");
+    vmstate_register(NULL, -1, &vmstate_adb_mouse, s);
 }
This page took 0.028501 seconds and 4 git commands to generate.