DECLARE_DEBUG_CHANNEL(emul_state);
+#define MAXLEN 512
+#define HTTP_PROXY_PREFIX "http_proxy="
+#define HOST_IP_PREFIX "host_ip="
+
static EmulatorConfigInfo _emul_info = {0,};
static EmulatorConfigState _emul_state;
#include <glib/gstdio.h>
#include <glib/gprintf.h>
#include <limits.h>
+#include <errno.h>
#include "config-host.h"
#ifdef CONFIG_DARWIN
#include "sys/syslimits.h"
#endif
+#ifdef CONFIG_WIN32
+#if defined(__MINGW64_VERSION_MAJOR)
+#define __MINGW_W64__
+#endif
+#endif
+
#if !defined(PATH_MAX)
#if defined(MAX_PATH)
#define PATH_MAX MAX_PATH
#endif
#define JAVA_MAX_COMMAND_LENGTH 1024
-#define MAXLEN 512
-#define HTTP_PROXY_PREFIX "http_proxy="
-#define HOST_IP_PREFIX "host_ip="
-
+#ifdef CONFIG_JAVA_UI
#define JAR_SKINFILE "emulator-skin.jar"
#define JAVA_LIBRARY_PATH "-Djava.library.path"
-
+#define JAVA_SIMPLEMODE_OPTION "simple.msg"
+#define JAVA_EXEFILE_PATH "java"
#ifndef CONFIG_DARWIN
#define JAVA_EXEOPTION "-jar"
#else
#define JAVA_EXEOPTION "-XstartOnFirstThread -jar" // Must start the Java window on the first thread on Mac
#endif
-#define JAVA_SIMPLEMODE_OPTION "simple.msg"
-
-#ifdef CONFIG_WIN32
-#define MY_KEY_WOW64_64KEY 0x0100
-#ifdef __cplusplus
-extern "C" {
-#endif
-int is_wow64(void);
-bool get_java_path(char **java_path);
-#ifdef __cplusplus
-}
-#endif
-#else
-#define JAVA_EXEFILE_PATH "java"
#endif
#endif /* __EMULATOR_COMMON_H__ */
#define IGrabCallback_Grab(T,a,b) (T)->lpVtbl->Grab(T,a,b)
#endif /* COBJMACROS */
-#if defined(__MINGW64_VERSION_MAJOR)
+#include "emulator_common.h"
+
+#ifdef __MINGW_W64__
#include <strmif.h>
#include <control.h>
#include <amvideo.h>
// FIXME: To avoid very complex header inclusion chains
void qemu_system_graceful_shutdown_request(unsigned int sec);
+#include "util/osutil.h"
#include "util/device_hotplug.h"
#include "util/ui_operations.h"
}
return ERR_UNLCK;
}
}
+
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+int is_wow64(void)
+{
+ int result = 0;
+ LPFN_ISWOW64PROCESS fnIsWow64Process;
+
+ /* IsWow64Process is not available on all supported versions of Windows.
+ Use GetModuleHandle to get a handle to the DLL that contains the function
+ and GetProcAddress to get a pointer to the function if available. */
+
+ fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
+ GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
+
+ if (NULL != fnIsWow64Process) {
+ if (!fnIsWow64Process(GetCurrentProcess(), &result)) {
+ /* No need to handle error,
+ just check whether is this WoW64 process */
+ }
+ }
+ return result;
+}
+
+#define MY_KEY_WOW64_64KEY 0x0100
+static char wow64_java_path[PATH_MAX];
+bool get_java_path(char **java_path)
+{
+ int index;
+ LONG res;
+ HKEY hKey, hSubKey;
+ char strChoosenName[PATH_MAX] = {0};
+ char strSubKeyName[PATH_MAX] = {0};
+ char strJavaHome[PATH_MAX] = {0};
+ DWORD dwSubKeyNameMax = PATH_MAX;
+ DWORD dwBufLen = PATH_MAX;
+ char strKeyList[4][64] = {
+ /* 64bit runtime */
+ "SOFTWARE\\JavaSoft\\Java Runtime Environment",
+ "SOFTWARE\\JavaSoft\\Java Development Kit",
+ /* 32bit runtime */
+ "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment",
+ "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit"
+ };
+
+ if (wow64_java_path[0] != '\0') {
+ strcpy(*java_path, wow64_java_path);
+ return true;
+ }
+
+ for (index = 0; index < ARRAY_SIZE(strKeyList); index++) {
+ res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ strKeyList[index],
+ 0,
+ KEY_QUERY_VALUE |
+ KEY_ENUMERATE_SUB_KEYS |
+ MY_KEY_WOW64_64KEY,
+ &hKey);
+ if (res == ERROR_SUCCESS) {
+ break;
+ }
+ }
+
+ if (res == ERROR_SUCCESS) {
+ index = 0;
+ do {
+ dwSubKeyNameMax = PATH_MAX;
+ res = RegEnumKeyEx(hKey,
+ index++,
+ (LPSTR)strSubKeyName,
+ &dwSubKeyNameMax,
+ NULL, NULL, NULL, NULL);
+ if (strcmp(strChoosenName, strSubKeyName) < 0) {
+ strcpy(strChoosenName, strSubKeyName);
+ }
+ } while (res == ERROR_SUCCESS);
+
+ RegOpenKeyEx(hKey, strChoosenName, 0,
+ KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hSubKey);
+ RegQueryValueEx(hSubKey, "JavaHome", NULL,
+ NULL, (LPBYTE)strJavaHome, &dwBufLen);
+ RegCloseKey(hSubKey);
+ RegCloseKey(hKey);
+ } else {
+ /* TODO:
+ get from %winDir%\System32
+ but, is this really needed?
+ */
+ DWORD dwRet = 0;
+ char strJavaHomeVar[PATH_MAX] = {0,};
+ dwRet = GetEnvironmentVariable("JAVA_HOME",
+ strJavaHomeVar,
+ PATH_MAX);
+ if (dwRet != 0 && dwRet < PATH_MAX) {
+ strcpy(strJavaHome, strJavaHomeVar);
+ }
+ }
+ if (strJavaHome[0] != '\0') {
+ sprintf(*java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome);
+ strcpy(wow64_java_path, *java_path);
+ } else {
+ return false;
+ }
+
+ return true;
+}
#ifndef __OSUTIL_H__
#define __OSUTIL_H__
-#include "qemu-common.h"
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "emulator_common.h"
+#ifdef CONFIG_WIN32
+#include "sysemu/os-win32.h"
+#else
+#include "sysemu/os-posix.h"
+#endif
#define DEFAULTBUFLEN 512
#define ERR_SUCCESS 0
#ifndef CONFIG_WIN32
bool make_sdcard_lock_posix(char *sdcard);
int remove_sdcard_lock_posix(char *sdcard);
+#else
+int is_wow64(void);
+bool get_java_path(char **java_path);
#endif
void print_system_info_os(void);
/* this must come after including "trace.h" */
#include <shlobj.h>
-#ifdef CONFIG_MARU
-#include "tizen/src/emulator_common.h"
-
-typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
-
-int is_wow64(void)
-{
- int result = 0;
- LPFN_ISWOW64PROCESS fnIsWow64Process;
-
- /* IsWow64Process is not available on all supported versions of Windows.
- Use GetModuleHandle to get a handle to the DLL that contains the function
- and GetProcAddress to get a pointer to the function if available. */
-
- fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
- GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
-
- if (NULL != fnIsWow64Process) {
- if (!fnIsWow64Process(GetCurrentProcess(), &result)) {
- /* No need to handle error,
- just check whether is this WoW64 process */
- }
- }
- return result;
-}
-
-static char wow64_java_path[JAVA_MAX_COMMAND_LENGTH];
-bool get_java_path(char **java_path)
-{
- int index;
- LONG res;
- HKEY hKey, hSubKey;
- char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0};
- char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0};
- char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0};
- DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH;
- DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH;
- char strKeyList[4][64] = {
- /* 64bit runtime */
- "SOFTWARE\\JavaSoft\\Java Runtime Environment",
- "SOFTWARE\\JavaSoft\\Java Development Kit",
- /* 32bit runtime */
- "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment",
- "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit"
- };
-
- if (wow64_java_path[0] != '\0') {
- strcpy(*java_path, wow64_java_path);
- return true;
- }
-
- for (index = 0; index < ARRAY_SIZE(strKeyList); index++) {
- res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- strKeyList[index],
- 0,
- KEY_QUERY_VALUE |
- KEY_ENUMERATE_SUB_KEYS |
- MY_KEY_WOW64_64KEY,
- &hKey);
- if (res == ERROR_SUCCESS) {
- break;
- }
- }
-
- if (res == ERROR_SUCCESS) {
- index = 0;
- do {
- dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH;
- res = RegEnumKeyEx(hKey,
- index++,
- (LPSTR)strSubKeyName,
- &dwSubKeyNameMax,
- NULL, NULL, NULL, NULL);
- if (strcmp(strChoosenName, strSubKeyName) < 0) {
- strcpy(strChoosenName, strSubKeyName);
- }
- } while (res == ERROR_SUCCESS);
-
- RegOpenKeyEx(hKey, strChoosenName, 0,
- KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hSubKey);
- RegQueryValueEx(hSubKey, "JavaHome", NULL,
- NULL, (LPBYTE)strJavaHome, &dwBufLen);
- RegCloseKey(hSubKey);
- RegCloseKey(hKey);
- } else {
- /* TODO:
- get from %winDir%\System32
- but, is this really needed?
- */
- DWORD dwRet = 0;
- char strJavaHomeVar[JAVA_MAX_COMMAND_LENGTH] = {0,};
- dwRet = GetEnvironmentVariable("JAVA_HOME",
- strJavaHomeVar,
- JAVA_MAX_COMMAND_LENGTH);
- if (dwRet != 0 && dwRet < JAVA_MAX_COMMAND_LENGTH) {
- strcpy(strJavaHome, strJavaHomeVar);
- }
- }
- if (strJavaHome[0] != '\0') {
- sprintf(*java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome);
- strcpy(wow64_java_path, *java_path);
- } else {
- return false;
- }
-
- return true;
-}
-#endif
-
void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {