1// Copyright (C) 2014 The Android Open Source Project
2//
3// This software is licensed under the terms of the GNU General Public
4// License version 2, as published by the Free Software Foundation, and
5// may be copied, distributed, and modified under those terms.
6//
7// This program is distributed in the hope that it will be useful,
8// but WITHOUT ANY WARRANTY; without even the implied warranty of
9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10// GNU General Public License for more details.
11
12#ifndef ANDROID_EMULATION_CPU_EMULATOR_H
13#define ANDROID_EMULATION_CPU_EMULATOR_H
14
15#include "android/base/String.h"
16
17namespace android {
18
19using ::android::base::String;
20
21// The list of CPU emulation acceleration technologies supported by the
22// Android emulator.
23//  CPU_ACCELERATOR_NONE means no acceleration is supported on this machine.
24//
25//  CPU_ACCELERATOR_KVM means Linux KVM, which requires a specific driver
26//  to be installed and that /dev/kvm is properly accessible by the current
27//  user.
28//
29//  CPU_ACCELERATOR_HAX means Intel's Hardware Accelerated eXecution,
30//  which can be installed on Windows and OS X machines running on an
31//  Intel processor.
32//
33enum CpuAccelerator {
34    CPU_ACCELERATOR_NONE = 0,
35    CPU_ACCELERATOR_KVM,
36    CPU_ACCELERATOR_HAX,
37};
38
39// Return the CPU accelerator technology usable on the current machine.
40// This only returns CPU_ACCELERATOR_KVM or CPU_ACCELERATOR_HAX if the
41// corresponding accelerator can be used properly. Otherwise it will
42// return CPU_ACCELERATOR_NONE.
43CpuAccelerator  GetCurrentCpuAccelerator();
44
45// Return an ASCII string describing the state of the current CPU
46// acceleration on this machine. If GetCurrentCpuAccelerator() returns
47// CPU_ACCELERATOR_NONE this will contain a small explanation why
48// the accelerator cannot be used.
49String GetCurrentCpuAcceleratorStatus();
50
51// For unit testing/debugging purpose only, must be called before
52// GetCurrentCpuAccelerator().
53void SetCurrentCpuAcceleratorForTesting(CpuAccelerator accel,
54                                        const char* status);
55
56}  // namespace android
57
58#endif  // ANDROID_EMULATION_CPU_EMULATOR_H
59