Add '-accel <mode>' and 'no-accel' options.

This patch adds two new options to better control CPU emulation
acceleration (i.e. KVM and HAX). More specifically:

  '-no-accel' can be used to disable acceleration if available.
  '-accel off' does the same.
  '-accel on' forces to run with acceleration, or refuses to start
  the emulator.
  '-accel auto' probes the system for a working accelerator and uses
  it when possible (i.e. when emulating x86 or x86_64 images only).

Also print some information with -verbose or -debug-init.

Note: This adds QEMU-independent probing code for KVM and HAX
      under android/emulation/ (C++), as well as some glue to
      use it from C under android/cpu_accelerator.[hc].

Note: HAX is no longer enabled by default when reaching the QEMU
      main function.

Change-Id: Ic91db7a3b213d69296c50fec35cd29a32a8e5779
diff --git a/android/cpu_accelerator.cpp b/android/cpu_accelerator.cpp
new file mode 100644
index 0000000..872e60d
--- /dev/null
+++ b/android/cpu_accelerator.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2014 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/cpu_accelerator.h"
+
+// This source acts as a small C++ -> C bridge between android/emulation/
+// and android/main.c
+
+#include "android/base/String.h"
+#include "android/emulation/CpuAccelerator.h"
+
+#include "android/utils/system.h"
+
+extern "C" bool android_hasCpuAcceleration(char** status_p) {
+    android::CpuAccelerator accel = android::GetCurrentCpuAccelerator();
+
+    if (status_p) {
+        android::base::String status =
+                android::GetCurrentCpuAcceleratorStatus();
+        *status_p = ASTRDUP(status.c_str());
+    }
+
+    return accel != android::CPU_ACCELERATOR_NONE;
+}