Merge tag 'v2.6.0' into develop
[sdk/emulator/qemu.git] / hw / input / ps2.c
index a8aa36f..984a263 100644 (file)
 #include "ui/console.h"
 #include "ui/input.h"
 #include "sysemu/sysemu.h"
-
 #include "trace.h"
 
+#ifdef CONFIG_MARU
+/* to guarantee safe serialization of input event by Munkyu Im */
+#include "qemu/thread.h"
+static QemuMutex mutex;
+#endif
+
 /* debug PC keyboard */
 //#define DEBUG_KBD
 
@@ -438,7 +443,14 @@ static void ps2_mouse_sync(DeviceState *dev)
         while (s->common.queue.count < PS2_QUEUE_SIZE - 4) {
             /* if not remote, send event. Multiple events are sent if
                too big deltas */
+#ifdef CONFIG_MARU
+/* to guarantee safe serialization of input event by Munkyu Im */
+            qemu_mutex_lock(&mutex);
             ps2_mouse_send_packet(s);
+            qemu_mutex_unlock(&mutex);
+#else
+            ps2_mouse_send_packet(s);
+#endif
             if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0)
                 break;
         }
@@ -809,5 +821,9 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
     qemu_input_handler_register((DeviceState *)s,
                                 &ps2_mouse_handler);
     qemu_register_reset(ps2_mouse_reset, s);
+#ifdef CONFIG_MARU
+    /* to guarantee safe serialization of input event by Munkyu Im */
+    qemu_mutex_init(&mutex);
+#endif
     return s;
 }