diff options
author | David 'Digit' Turner <digit@google.com> | 2016-09-15 12:24:36 +0200 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2016-10-18 16:27:43 +0200 |
commit | 3a5fce5d8a614a7e76f6ae8a895fdd241d51ac74 (patch) | |
tree | 1f420f5bdfb70b9e27927ebec3e92b2de4857aad | |
parent | be95fbfe0830e40d97f7143b7149c20bd608635f (diff) | |
download | qemu-android-3a5fce5d8a614a7e76f6ae8a895fdd241d51ac74.tar.gz |
android: glue: setup goldfish sync host service.
Change-Id: I312f87f3416fa9fcf236df4e9434d60bfe4713df
-rw-r--r-- | android-qemu2-glue/build/Makefile.qemu2-glue.mk | 1 | ||||
-rw-r--r-- | android-qemu2-glue/emulation/goldfish_sync.cpp | 56 | ||||
-rw-r--r-- | android-qemu2-glue/emulation/goldfish_sync.h | 17 | ||||
-rw-r--r-- | android-qemu2-glue/qemu-setup.cpp | 6 |
4 files changed, 80 insertions, 0 deletions
diff --git a/android-qemu2-glue/build/Makefile.qemu2-glue.mk b/android-qemu2-glue/build/Makefile.qemu2-glue.mk index 1e2939de98..406b6c4d0d 100644 --- a/android-qemu2-glue/build/Makefile.qemu2-glue.mk +++ b/android-qemu2-glue/build/Makefile.qemu2-glue.mk @@ -19,6 +19,7 @@ LOCAL_SRC_FILES := \ emulation/android_pipe_device.cpp \ emulation/charpipe.c \ emulation/CharSerialLine.cpp \ + emulation/goldfish_sync.cpp \ emulation/serial_line.cpp \ emulation/VmLock.cpp \ looper-qemu.cpp \ diff --git a/android-qemu2-glue/emulation/goldfish_sync.cpp b/android-qemu2-glue/emulation/goldfish_sync.cpp new file mode 100644 index 0000000000..01cc29f7ba --- /dev/null +++ b/android-qemu2-glue/emulation/goldfish_sync.cpp @@ -0,0 +1,56 @@ +/* Copyright 2016 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ +#include "android-qemu2-glue/emulation/goldfish_sync.h" + +// Glue code between the virtual goldfish sync device, and the +// host-side sync service implementation. + +#include "android/base/Log.h" +#include "android/emulation/GoldfishSyncCommandQueue.h" +#include "android/emulation/goldfish_sync.h" + +extern "C" { +#include "hw/misc/goldfish_sync.h" +} // extern "C" + +static trigger_wait_fn_t sTriggerWaitFn = nullptr; + +// These callbacks are called from the host sync service to operate +// on the virtual device (.doHostCommand) or register a trigger-waiting +// callback that will be invoked later from the device +// (.registerTriggerWait). +static GoldfishSyncDeviceInterface kSyncDeviceInterface = { + .doHostCommand = goldfish_sync_send_command, + .registerTriggerWait = [](trigger_wait_fn_t fn) { + sTriggerWaitFn = fn; + }, +}; + +// These callbacks are called from the virtual device to send +// data to the host sync service. +static const GoldfishSyncServiceOps kSyncServiceOps = { + .receive_hostcmd_result = goldfish_sync_receive_hostcmd_result, + .trigger_host_wait = [](uint64_t glsync_ptr, + uint64_t thread_ptr, + uint64_t timeline) { + if (sTriggerWaitFn) { + sTriggerWaitFn(glsync_ptr, thread_ptr, timeline); + } + } +}; + +bool qemu_android_sync_init(android::VmLock* vmLock) { + goldfish_sync_set_service_ops(&kSyncServiceOps); + goldfish_sync_set_hw_funcs(&kSyncDeviceInterface); + android::GoldfishSyncCommandQueue::initThreading(vmLock); + return true; +} diff --git a/android-qemu2-glue/emulation/goldfish_sync.h b/android-qemu2-glue/emulation/goldfish_sync.h new file mode 100644 index 0000000000..cd20b9d958 --- /dev/null +++ b/android-qemu2-glue/emulation/goldfish_sync.h @@ -0,0 +1,17 @@ +/* Copyright 2016 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ +#pragma once + +#include "android/emulation/VmLock.h" + +/* Initialize Goldfish Sync device and service. */ +bool qemu_android_sync_init(android::VmLock* vmLock); diff --git a/android-qemu2-glue/qemu-setup.cpp b/android-qemu2-glue/qemu-setup.cpp index 56cc148c15..bdb0af8765 100644 --- a/android-qemu2-glue/qemu-setup.cpp +++ b/android-qemu2-glue/qemu-setup.cpp @@ -19,6 +19,7 @@ #include "android/console.h" #include "android-qemu2-glue/emulation/android_pipe_device.h" #include "android-qemu2-glue/emulation/charpipe.h" +#include "android-qemu2-glue/emulation/goldfish_sync.h" #include "android-qemu2-glue/emulation/VmLock.h" #include "android-qemu2-glue/looper-qemu.h" #include "android-qemu2-glue/android_qemud.h" @@ -56,6 +57,11 @@ bool qemu_android_emulation_early_setup() { return false; } + // Initialize host sync service. + if (!qemu_android_sync_init(vmLock)) { + return false; + } + return true; } |