return _emul_info.skin_enable;
}
-/* current emulator condition */
-int get_emulator_condition(void)
-{
- return _emul_state.emulator_condition;
-}
-
-void set_emulator_condition(int state)
-{
- _emul_state.emulator_condition = state;
-}
-
/* lcd screen size */
void set_emul_lcd_size(int width, int height)
{
return _emul_info.max_touch_point;
}
+/* base port for emualtor vm */
+void set_emul_vm_base_port(int port)
+{
+ _emul_info.vm_base_port = port;
+}
+
+int get_emul_vm_base_port(void)
+{
+ return _emul_info.vm_base_port;
+}
+
+/* current emulator condition */
+int get_emulator_condition(void)
+{
+ return _emul_state.emulator_condition;
+}
+
+void set_emulator_condition(int state)
+{
+ _emul_state.emulator_condition = state;
+}
+
/* emulator window scale */
void set_emul_win_scale(double scale_factor)
{
return -1;
}
-/* manage CapsLock key state for usb keyboard input */
+/* manage CapsLock key state for host keyboard input */
void set_emul_caps_lock_state(int state)
{
_emul_state.qemu_caps_lock = state;
int get_emul_caps_lock_state(void)
{
- return _emul_state.qemu_caps_lock;
+ return _emul_state.qemu_caps_lock;
}
-/* manage NumLock key state for usb keyboard input */
+/* manage NumLock key state for host keyboard input */
void set_emul_num_lock_state(int state)
{
_emul_state.qemu_num_lock = state;
int get_emul_num_lock_state(void)
{
- return _emul_state.qemu_num_lock;
+ return _emul_state.qemu_num_lock;
}
+
int lcd_size_h;
int sdl_bpp;
int max_touch_point;
- //TODO:
+ int vm_base_port;
+ /* add here */
} EmulatorConfigInfo;
typedef struct EmulatorConfigState {
MultiTouchState qemu_mts;
int qemu_caps_lock;
int qemu_num_lock;
- //TODO:
+ /* add here */
} EmulatorConfigState;
void set_emul_win_scale(double scale);
void set_emul_sdl_bpp(int bpp);
void set_emul_max_touch_point(int cnt);
+void set_emul_vm_base_port(int port);
+
void set_emulator_condition(int state);
void set_emul_rotation(short rotation_type);
void set_emul_caps_lock_state(int state);
double get_emul_win_scale(void);
int get_emul_sdl_bpp(void);
int get_emul_max_touch_point(void);
+int get_emul_vm_base_port(void);
+
int get_emulator_condition(void);
short get_emul_rotation(void);
MultiTouchState *get_emul_multi_touch_state(void);
tizen_base_port = get_sdb_base_port();
get_host_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
- // using "DNS" provided by default QEMU
+ /* using "DNS" provided by default QEMU */
g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1);
check_vm_lock();
socket_init();
make_vm_lock();
- sdb_setup();
+ sdb_setup(); /* determine the base port for emulator */
+ set_emul_vm_base_port(tizen_base_port);
gchar * const tmp_str = g_strdup_printf(" sdb_port=%d,"
- " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
- " dns1=%s", tizen_base_port,
- http_proxy, https_proxy, ftp_proxy, socks_proxy,
- dns);
+ " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
+ " dns1=%s", get_emul_vm_base_port(),
+ http_proxy, https_proxy, ftp_proxy, socks_proxy, dns);
g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
* Maru vga device
* Based on qemu/hw/vga.c
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "maru_err_table.h"
+#include "emul_state.h"
#endif
#ifdef CONFIG_USE_SHM
void *shared_memory = (void*) 0;
int skin_shmid;
-int port_shmid;
#endif
vga_dirty_log_start(s);
#ifdef CONFIG_USE_SHM
- int mykey;
- void *temp;
+ /* base + 1 = sdb port */
+ /* base + 2 = shared memory key */
+ int mykey = get_emul_vm_base_port() + 2;
- port_shmid = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT);
- if (port_shmid == -1) {
- ERR("shmget failed\n");
- perror("maru_vga: ");
- exit(1);
- }
-
- temp = shmat(port_shmid, (char*)0x0, 0);
- if (temp == (void *)-1) {
- ERR("shmat failed\n");
- perror("maru_vga: ");
- exit(1);
- }
-
- mykey = atoi(temp);
- shmdt(temp);
-
INFO("shared memory key: %d, vga ram_size : %d\n", mykey, s->vram_size);
skin_shmid = shmget((key_t)mykey, (size_t)s->vram_size, 0666 | IPC_CREAT);
if (skin_shmid == -1) {
ERR("shmget failed\n");
perror("maru_vga: ");
- maru_register_exit_msg(MARU_EXIT_UNKNOWN, (char*)"Cannot launch this VM.\n"
- "Shared memory is not enough.");
+ maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+ (char*) "Cannot launch this VM.\n"
+ "Shared memory is not enough.");
exit(0);
}
ERR("shmctl failed\n");
perror("maru_vga: ");
}
-
- if (shmctl(port_shmid, IPC_RMID, 0) == -1) {
- ERR("temp shmctl failed\n");
- perror("maru_vga: ");
- }
}
#endif
/**
+ * Transmit the framebuffer from shared memory by JNI
*
- *
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
#include "org_tizen_emulator_skin_EmulatorShmSkin.h"
#define MAXLEN 512
-#define SHMKEY 26099
void *shared_memory = (void *)0;
int shmid;
JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmget
- (JNIEnv *env, jobject obj, jint vga_ram_size)
+ (JNIEnv *env, jobject obj, jint shmkey, jint vga_ram_size)
{
- void *temp;
- int keyval;
- shmid = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT);
- if (shmid == -1) {
- fprintf(stderr, "share.c: shmget failed\n");
- exit(1);
- }
-
- temp = shmat(shmid, (char*)0x0, 0);
- if (temp == (void *)-1) {
- fprintf(stderr, "share.c: shmat failed\n");
- exit(1);
- }
- keyval = atoi(temp);
- fprintf(stdout, "share.c: shared memory key = %d\n", keyval);
- shmdt(temp);
+ fprintf(stdout, "share.c: shared memory key = %d\n", shmkey);
+ fflush(stdout);
- shmid = shmget((key_t)keyval, (size_t)vga_ram_size, 0666 | IPC_CREAT);
+ shmid = shmget((key_t)shmkey, (size_t)vga_ram_size, 0666 | IPC_CREAT);
if (shmid == -1) {
fprintf(stderr, "share.c: shmget failed\n");
+ fflush(stderr);
return 1;
}
- /* We now make the shared memory accessible to the program. */
+ /* We now make the shared memory accessible to the program */
shared_memory = shmat(shmid, (void *)0, 0);
if (shared_memory == (void *)-1) {
fprintf(stderr, "share.c: shmat failed\n");
+ fflush(stderr);
return 2;
}
}
JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmdt
- (JNIEnv *env, jobject obj)
+ (JNIEnv *env, jobject obj)
{
/* Lastly, the shared memory is detached */
if (shmdt(shared_memory) == -1) {
fprintf(stderr, "share.c: shmdt failed\n");
+ fflush(stderr);
perror("share.c: ");
return 1;
}
-/*
+
+ /*
if (shmctl(shmid, IPC_RMID, 0) == -1) {
fprintf(stderr, "share.c: shmctl failed\n");
+ fflush(stderr);
perror("share.c: ");
}
-*/
+ */
+
return 0;
}
JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_getPixels
- (JNIEnv *env, jobject obj, jintArray array)
+ (JNIEnv *env, jobject obj, jintArray array)
{
int i = 0;
int len = (*env)->GetArrayLength(env, array);
if (len <= 0) {
fprintf(stderr, "share.c: get length failed\n");
+ fflush(stderr);
return -1;
}
int *framebuffer = (int *)shared_memory;
jint value = 0xFFFFFFFF;
- for(i = 0; i < len; i++) {
+ for (i = 0; i < len; i++) {
value = framebuffer[i];
(*env)->SetIntArrayRegion(env, array, i, 1, &value);
}
/**
* Emulator Skin Process
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.info.SkinInformation;
public static final int COLOR_DEPTH = 32;
/* define JNI functions */
- public native int shmget(int size);
+ public native int shmget(int shmkey, int size);
public native int shmdt();
public native int getPixels(int[] array);
public long initLayout() {
super.initLayout();
+ /* base + 1 = sdb port */
+ /* base + 2 = shared memory key */
+ int shmkey = config.getArgInt(ArgsConstants.NET_BASE_PORT) + 2;
+ logger.info("shmkey = " + shmkey);
+
/* initialize shared memory */
- int result = shmget(
+ int result = shmget(shmkey,
currentState.getCurrentResolutionWidth() *
currentState.getCurrentResolutionHeight());
logger.info("shmget native function returned " + result);
}
boolean skinPhoneShape = true;
- String skinInfoResolutionW = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH);
- String skinInfoResolutionH = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT);
+ String skinInfoResolutionW =
+ skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH);
+ String skinInfoResolutionH =
+ skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT);
+
if (skinInfoResolutionW.equalsIgnoreCase("all") ||
skinInfoResolutionH.equalsIgnoreCase("all")) {
skinPhoneShape = false;
private Properties configProperties;
private String skinPropertiesFilePath;
- public EmulatorConfig( Map<String, String> args, EmulatorUI dbiContents, Properties skinProperties,
- String skinPropertiesFilePath, Properties configProperties ) {
+ public EmulatorConfig(Map<String, String> args,
+ EmulatorUI dbiContents, Properties skinProperties,
+ String skinPropertiesFilePath, Properties configProperties) {
this.args = args;
this.dbiContents = dbiContents;
this.skinProperties = skinProperties;
this.skinPropertiesFilePath = skinPropertiesFilePath;
this.configProperties = configProperties;
- if ( null == configProperties ) {
+
+ if (null == configProperties) {
this.configProperties = new Properties();
}
}
#define OPT_MAX_TOUCHPOINT "max.touchpoint"
extern char tizen_target_path[];
-extern int tizen_base_port;
static int skin_argc;
static char** skin_argv;
char buf_tizen_base_port[16];
sprintf(buf_skin_server_port, "%d", skin_server_port);
sprintf(buf_uid, "%d", uid);
- sprintf(buf_tizen_base_port, "%d", tizen_base_port);
+ sprintf(buf_tizen_base_port, "%d", get_emul_vm_base_port());
#ifdef CONFIG_WIN32
// find java path in 64bit windows
char* bin_dir = get_bin_path();
#endif
INFO("bin directory : %s\n", bin_dir);
+
int maxtouchpoint = get_emul_max_touch_point();
int len_maxtouchpoint;
- if(maxtouchpoint > 9) {
+ if (maxtouchpoint > 9) {
len_maxtouchpoint = 2;
- }else {
+ } else {
len_maxtouchpoint = 1;
}
OPT_SVR_PORT, skin_server_port,
OPT_UID, uid,
OPT_VM_PATH, vm_path,
- OPT_NET_BASE_PORT, tizen_base_port,
+ OPT_NET_BASE_PORT, get_emul_vm_base_port(),
OPT_MAX_TOUCHPOINT, maxtouchpoint,
- argv );
+ argv);
INFO("command for swt : %s\n", cmd);
} else {
count++;
INFO("sleep for ready. count:%d\n", count);
+
#ifdef CONFIG_WIN32
- Sleep(SKIN_SERVER_SLEEP_TIME);
+ Sleep(SKIN_SERVER_SLEEP_TIME);
#else
- usleep(1000 * SKIN_SERVER_SLEEP_TIME);
+ usleep(1000 * SKIN_SERVER_SLEEP_TIME);
#endif
}
#if defined(CONFIG_USE_SHM) && defined(TARGET_I386)
#include <sys/shm.h>
int g_shmid;
-extern int port_shmid;
#endif
MULTI_DEBUG_CHANNEL(qemu, skin_operation);
extern pthread_cond_t cond_screenshot;
extern int tizen_base_port;
+
static void* run_timed_shutdown_thread(void* args);
-static void send_to_emuld(const char* request_type, int request_size, const char* send_buf, int buf_size);
+static void send_to_emuld(const char* request_type,
+ int request_size, const char* send_buf, int buf_size);
+
void start_display(uint64 handle_id,
- int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type)
+ int lcd_size_width, int lcd_size_height,
+ double scale_factor, short rotation_type)
{
INFO("start_display handle_id:%ld, lcd size:%dx%d, scale_factor:%f, rotation_type:%d\n",
(long)handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation_type);
info->pixel_data = (unsigned char*) g_malloc0( length );
if ( !info->pixel_data ) {
g_free( info );
- ERR( "Fail to malloc for pixel data.\n");
+ ERR("Fail to malloc for pixel data.\n");
return NULL;
}
pthread_mutex_lock(&mutex_screenshot);
MaruScreenshot* maru_screenshot = get_maru_screenshot();
- if ( !maru_screenshot || maru_screenshot->isReady != 1) {
- ERR( "maru screenshot is NULL or not ready.\n" );
+ if (!maru_screenshot || maru_screenshot->isReady != 1) {
+ ERR("maru screenshot is NULL or not ready.\n");
memset(info->pixel_data, 0x00, length);
} else {
maru_screenshot->pixel_data = info->pixel_data;
void do_open_shell(void)
{
INFO("open shell\n");
+
/* do nothing */
}
}
-void shutdown_qemu_gracefully( void ) {
-
+void shutdown_qemu_gracefully(void)
+{
requested_shutdown_qemu_gracefully = 1;
pthread_t thread_id;
- if( 0 > pthread_create( &thread_id, NULL, run_timed_shutdown_thread, NULL ) ) {
- ERR( "!!! Fail to create run_timed_shutdown_thread. shutdown qemu right now !!!\n" );
+ if (0 > pthread_create(
+ &thread_id, NULL, run_timed_shutdown_thread, NULL)) {
+
+ ERR("!!! Fail to create run_timed_shutdown_thread. shutdown qemu right now !!!\n");
qemu_system_shutdown_request();
}
}
-int is_requested_shutdown_qemu_gracefully( void ) {
+int is_requested_shutdown_qemu_gracefully(void)
+{
return requested_shutdown_qemu_gracefully;
}
-static void* run_timed_shutdown_thread( void* args ) {
-
- send_to_emuld( "system\n\n\n\n", 10, "shutdown", 8 );
+static void* run_timed_shutdown_thread(void* args)
+{
+ send_to_emuld("system\n\n\n\n", 10, "shutdown", 8);
- int sleep_interval_time = 1000; // milli-seconds
+ int sleep_interval_time = 1000; /* milli-seconds */
int i;
- for ( i = 0; i < TIMEOUT_FOR_SHUTDOWN; i++ ) {
+ for (i = 0; i < TIMEOUT_FOR_SHUTDOWN; i++) {
#ifdef CONFIG_WIN32
- Sleep( sleep_interval_time );
+ Sleep(sleep_interval_time);
#else
- usleep( sleep_interval_time * 1000 );
+ usleep(sleep_interval_time * 1000);
#endif
- // do not use logger to help user see log in console
- fprintf( stdout, "Wait for shutdown qemu...%d\n", ( i + 1 ) );
+ /* do not use logger to help user see log in console */
+ fprintf(stdout, "Wait for shutdown qemu...%d\n", (i + 1));
}
- INFO( "Shutdown qemu !!!\n" );
+ INFO("Shutdown qemu !!!\n");
+
#if defined(CONFIG_USE_SHM) && defined(TARGET_I386)
if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
ERR("shmctl failed\n");
perror("maruskin_operation.c:g_shmid: ");
}
-
- if (shmctl(port_shmid, IPC_RMID, 0) == -1) {
- ERR("shmctl failed\n");
- perror("maruskin_operation.c:port_shmid: ");
- }
#endif
qemu_system_shutdown_request();
}
-static void send_to_emuld( const char* request_type, int request_size, const char* send_buf, int buf_size ) {
-
+static void send_to_emuld(const char* request_type,
+ int request_size, const char* send_buf, int buf_size)
+{
int s = tcp_socket_outgoing( "127.0.0.1", (uint16_t) ( tizen_base_port + SDB_TCP_EMULD_INDEX ) );
if ( s < 0 ) {