From: Vitaliy Cherepanov Date: Wed, 3 Jul 2013 14:15:12 +0000 (+0400) Subject: Merge branch 'swap_protocol' of 106.109.8.71:/srv/git/sdk/dynamic-analysis-manager... X-Git-Tag: Tizen_SDK_2.3~280^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b7a1baab5a285b44294a2fed3c7f8c67a824923;p=platform%2Fcore%2Fsystem%2Fswap-manager.git Merge branch 'swap_protocol' of 106.109.8.71:/srv/git/sdk/dynamic-analysis-manager into swap_protocol Conflicts: daemon/da_protocol.c daemon/transfer_thread.c --- 1b7a1baab5a285b44294a2fed3c7f8c67a824923 diff --cc daemon/da_protocol.c index 000267c,93e7577..29becc8 --- a/daemon/da_protocol.c +++ b/daemon/da_protocol.c @@@ -12,13 -12,9 +12,14 @@@ #include "da_protocol.h" #include "daemon.h" #include "sys_stat.h" + #include "transfer_thread.h" #include "elf.h" +#include "ioctl_commands.h" +#include "debug.h" +#include +#include +#include #define SYSTEM_INFO_DEBUG #define parse_deb_on @@@ -716,40 -635,10 +640,41 @@@ static char *parse_msg_binary_info(cha return p; } + +//This function concat 2 user space lists +// this function clean "from" pointer +static void concat_add_user_space_inst(struct user_space_inst_t *from, + struct user_space_inst_t *to) +{ + struct app_inst_t *new_app_inst_list = NULL; + uint32_t size; + char *p; + + if (from->app_num == 0) + return; + + new_app_inst_list = malloc((from->app_num + to->app_num) * sizeof(*new_app_inst_list)); + p = new_app_inst_list; + + size = from->app_num * sizeof(*new_app_inst_list); + memcpy(p, from->app_inst_list, size); + p +=size; + + size = to->app_num * sizeof(*new_app_inst_list); + memcpy(p, to->app_inst_list, size); + p +=size; + + free(to->app_inst_list); + to->app_inst_list = new_app_inst_list; + + to->app_num += from->app_num; + return; +} + void reset_msg(struct msg_t *msg) { - free(msg->payload); + if (msg->len) + free(msg->payload); } static void reset_app_info(struct app_info_t *app_info) @@@ -932,11 -884,10 +920,11 @@@ static int sendACKToHost(enum HostMessa int host_message_handler(struct msg_t *msg) { - char *answer = 0; - uint32_t answer_len = 0; struct app_info_t app_info; + struct target_info_t target_info; struct msg_t *msg_reply; + struct user_space_inst_t user_space_inst; + struct conf_t conf; LOGI("MY HANDLE %s (%X)\n", msg_ID_str(msg->id), msg->id); @@@ -945,26 -896,17 +933,19 @@@ sendACKToHost(msg->id, ERR_NO, 0, 0); break; case NMSG_START: - if (!parse_prof_session(msg->payload, &prof_session)) { + if (parse_prof_session(msg->payload, &prof_session) != 0) { LOGE("prof session parsing error\n"); sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0); - return 1; + return -1; } + // TODO: launch translator thread if (start_transfer() != 0) { LOGE("Cannot start transfer\n"); return -1; } + - // TODO: kill app - /* #ifdef RUN_APP_LOADER */ - /* kill_app(manager.appPath); */ - /* #else */ - /* kill_app(execPath); */ - /* #endif */ - // TODO: apply_prof_session() if (0) { sendACKCodeToHost(MSG_NOTOK, ERR_CANNOT_START_PROFILING); @@@ -976,34 -918,28 +957,37 @@@ return -1; } - // TODO: exec app - // TODO: start app launch timer + //write to device + //ioctl_send_msg(msg); + // success sendACKToHost(msg->id, ERR_NO, 0, 0); break; case NMSG_STOP: terminate_all(); + stop_profiling(); reset_prof_session(&prof_session); stop_transfer(); + //write to device + ioctl_send_msg(msg); + //send ack to host sendACKToHost(msg->id, ERR_NO, 0, 0); break; case NMSG_CONFIG: - if (!parse_msg_config(msg->payload, &prof_session.conf)) { + if (!parse_msg_config(msg->payload, &conf)) { LOGE("config parsing error\n"); sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0); - return 1; + return -1; + } + if (!reconfigure(conf)) { + LOGE("Cannot change configuration\n"); + return -1; } + //write to device + ioctl_send_msg(msg); + //send ack to host sendACKToHost(msg->id,ERR_NO,0,0); break; case NMSG_BINARY_INFO: @@@ -1028,20 -964,13 +1012,20 @@@ break; case NMSG_SWAP_INST_ADD: if (!parse_user_space_inst(msg->payload, - &prof_session.user_space_inst)) { + &user_space_inst)) { LOGE("user space inst parsing error\n"); sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0); - return 1; + return -1; } // TODO: apply_prof_session() + // warning concat_add_user_space_inst free user_space_inst + // so, data will not be availible + concat_add_user_space_inst(&user_space_inst, &prof_session.user_space_inst); + //write to device + ioctl_send_msg(msg); + //send ack to host sendACKToHost(msg->id, ERR_NO, 0, 0); + // TODO release user_space_inst break; case NMSG_SWAP_INST_REMOVE: if (!parse_user_space_inst(msg->payload, @@@ -1074,14 -1003,10 +1058,8 @@@ return 0; } - // use sequence: - /* receive_msg_header */ - /* receive_msg_payload */ - /* handle_msg */ - /* dispose_payload */ - // testing -#include -#include -#include + static void print_app_info( struct app_info_t *app_info) { LOGI("application info=\n"); diff --cc daemon/threads.c index 67d2d26,a01634d..557c02d --- a/daemon/threads.c +++ b/daemon/threads.c @@@ -42,11 -42,8 +42,9 @@@ #include "da_protocol.h" #include "da_data.h" +#include "debug.h" //#define DEBUG_GSI - #define TIMER_INTERVAL_SEC 1 - #define TIMER_INTERVAL_USEC 0 static void* recvThread(void* data) { diff --cc daemon/transfer_thread.c index 573d40b,b5b600e..bae1b67 --- a/daemon/transfer_thread.c +++ b/daemon/transfer_thread.c @@@ -3,10 -3,9 +3,11 @@@ #include #include #include + #include "daemon.h" #include "buffer.h" +#include "debug.h" + #include "transfer_thread.h" #define BUF_SIZE 4096