From: Jinhyung Choi Date: Tue, 30 Jul 2013 07:07:06 +0000 (+0900) Subject: qemu: moved ecs_start and port decision, and removed some warnings X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~860 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c45b14eccae16dfe793d16b7abd94916d38c6894;p=sdk%2Femulator%2Fqemu.git qemu: moved ecs_start and port decision, and removed some warnings Signed-off-by: Jinhyung Choi --- diff --git a/tizen/src/base64.c b/tizen/src/base64.c index 63d255abe7..3b723051a1 100644 --- a/tizen/src/base64.c +++ b/tizen/src/base64.c @@ -32,7 +32,7 @@ static int DecodeMimeBase64[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */ }; -int base64_decode(char *text, unsigned char *dst, int numBytes ) +int base64_decode(const char *text, unsigned char *dst, int numBytes ) { const char* cp; int space_idx = 0, phase; @@ -76,7 +76,7 @@ int base64_decode(char *text, unsigned char *dst, int numBytes ) } -int base64_encode(char *text, int numBytes, char **encodedText) +int base64_encode(const char *text, int numBytes, char **encodedText) { unsigned char input[3] = {0,0,0}; unsigned char output[4] = {0,0,0,0}; diff --git a/tizen/src/base64.h b/tizen/src/base64.h index 242adadec7..fa5ded1d79 100644 --- a/tizen/src/base64.h +++ b/tizen/src/base64.h @@ -1,4 +1,4 @@ #include "maru_common.h" -int base64_decode(char *text, unsigned char *dst, int numBytes); -int base64_encode(char *text, int numBytes, char **encodedText); +int base64_decode(const char *text, unsigned char *dst, int numBytes); +int base64_encode(const char *text, int numBytes, char **encodedText); diff --git a/tizen/src/ecs.c b/tizen/src/ecs.c index da291e9bbc..5c7292d3af 100644 --- a/tizen/src/ecs.c +++ b/tizen/src/ecs.c @@ -64,7 +64,6 @@ static QTAILQ_HEAD(ECS_ClientHead, ECS_Client) clients = QTAILQ_HEAD_INITIALIZER(clients); static ECS_State *current_ecs; -static int port; static pthread_mutex_t mutex_clilist = PTHREAD_MUTEX_INITIALIZER; @@ -315,11 +314,12 @@ static inline bool handler_is_async(const mon_cmd_t *cmd) { return cmd->flags & MONITOR_CMD_ASYNC; } +/* static void monitor_user_noop(Monitor *mon, const QObject *data) { } static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data) { - vga_hw_screen_dump(qdict_get_str(qdict, "filename")); + //vga_hw_screen_dump(qdict_get_str(qdict, "filename")); return 0; } @@ -337,6 +337,7 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data) { return 0; } +*/ static const mon_cmd_t qmp_cmds[] = { //#include "qmp-commands-old.h" @@ -1103,7 +1104,6 @@ static ECS_Client *ecs_find_client(int fd) { } static int ecs_add_client(ECS_State *cs, int fd) { - const char* welcome; ECS_Client *clii = g_malloc0(sizeof(ECS_Client)); if (NULL == clii) { @@ -1131,10 +1131,6 @@ static int ecs_add_client(ECS_State *cs, int fd) { LOG("Add an ecs client. fd: %d", fd); - welcome = WELCOME_MESSAGE; - - //send_to_client(fd, welcome); - pthread_mutex_unlock(&mutex_clilist); return 0; @@ -1192,6 +1188,7 @@ static void epoll_init(ECS_State *cs) { #endif static void alive_checker(void *opaque) { + /* ECS_State *cs = opaque; ECS_Client *clii; QObject *obj; @@ -1202,7 +1199,6 @@ static void alive_checker(void *opaque) { return; } - /* QTAILQ_FOREACH(clii, &clients, next) { if (1 == clii->keep_alive) { @@ -1304,7 +1300,7 @@ static int ecs_loop(ECS_State *cs) } #endif -static int check_port(void) { +int get_ecs_port(void) { int port = HOST_LISTEN_PORT; int try = EMULATOR_SERVER_NUM; @@ -1318,10 +1314,6 @@ static int check_port(void) { return -1; } -int get_ecs_port(void) { - return port; -} - static void* ecs_initialize(void* args) { int ret = 1; ECS_State *cs = NULL; @@ -1329,6 +1321,7 @@ static void* ecs_initialize(void* args) { Error *local_err = NULL; Monitor* mon = NULL; char host_port[16]; + int port = -1; start_logging(); LOG("ecs starts initializing."); @@ -1340,7 +1333,7 @@ static void* ecs_initialize(void* args) { return NULL; } - port = check_port(); + port = (int) args; if (port < 0) { LOG("None of port is available."); return NULL; @@ -1403,10 +1396,10 @@ int stop_ecs(void) { return 0; } -int start_ecs(void) { +int start_ecs(int port) { pthread_t thread_id; - if (0 != pthread_create(&thread_id, NULL, ecs_initialize, NULL)) { + if (0 != pthread_create(&thread_id, NULL, ecs_initialize, (void*) port)) { LOG("pthread creation failed."); return -1; } diff --git a/tizen/src/ecs.h b/tizen/src/ecs.h index 72ad384b13..84ff260032 100644 --- a/tizen/src/ecs.h +++ b/tizen/src/ecs.h @@ -33,7 +33,6 @@ #define HOST_LISTEN_ADDR "127.0.0.1" #define HOST_LISTEN_PORT 27000 #define EMULATOR_SERVER_NUM 3 -#define WELCOME_MESSAGE "### Welcome to ECS service. ###\n" #define COMMANDS_TYPE "type" #define COMMANDS_DATA "data" @@ -128,14 +127,13 @@ typedef struct ECS_Client { } ECS_Client; -int start_ecs(void); +int start_ecs(int port); int stop_ecs(void); +int get_ecs_port(void); void ecs_vprintf(const char *type, const char *fmt, va_list ap); void ecs_printf(const char *type, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -int get_ecs_port(void); - bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len); bool ntf_to_injector(const char* data, const int len); diff --git a/tizen/src/ecs_msg.c b/tizen/src/ecs_msg.c index 1bcfed3cef..7cf47f080c 100644 --- a/tizen/src/ecs_msg.c +++ b/tizen/src/ecs_msg.c @@ -26,13 +26,16 @@ #include "qmp-commands.h" #include "ecs.h" +#include "base64.h" +#include "mloop_event.h" #include "hw/maru_virtio_evdi.h" #include "hw/maru_virtio_sensor.h" +#include "hw/maru_virtio_nfc.h" #include "skin/maruskin_operation.h" // utility functions -void* build_master(ECS__Master* master, int* payloadsize) +static void* build_master(ECS__Master* master, int* payloadsize) { int len_pack = ecs__master__get_packed_size(master); *payloadsize = len_pack + 4; @@ -77,7 +80,6 @@ bool msgproc_start_req(ECS_Client* ccli, ECS__StartReq* msg) { LOG("ecs_startinfo_req"); - int hostkbd_status = mloop_evcmd_get_hostkbd_status(); LOG("hostkbd_status = %d", hostkbd_status); @@ -133,7 +135,6 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) } } - send_to_evdi(route_ij, sndbuf, sndlen); g_free(sndbuf); @@ -163,7 +164,7 @@ bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg) bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) { char cmd[10]; - char* data; + char* data = NULL; memset(cmd, 0, 10); strcpy(cmd, msg->category); type_length length = (type_length) msg->length; diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 5ca93e6158..1db3f9e20b 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -90,6 +90,7 @@ gchar bin_path[PATH_MAX] = { 0, }; gchar log_path[PATH_MAX] = { 0, }; int tizen_base_port; +int tizen_ecs_port; char tizen_target_path[PATH_MAX]; char tizen_target_img_path[PATH_MAX]; @@ -360,6 +361,12 @@ static void prepare_basic_features(void) tizen_base_port = get_sdb_base_port(); + tizen_ecs_port = get_ecs_port(); + + qemu_add_opts(&qemu_ecs_opts); + + start_ecs(tizen_ecs_port); + get_host_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); /* using "DNS" provided by default QEMU */ g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1); @@ -503,10 +510,6 @@ void prepare_maru(void) int guest_server_port = tizen_base_port + SDB_UDP_SENSOR_INDEX; start_guest_server(guest_server_port); - qemu_add_opts(&qemu_ecs_opts); - - start_ecs(); - mloop_ev_init(); }