From: GiWoong Kim Date: Wed, 6 Nov 2013 07:44:01 +0000 (+0900) Subject: emulator: boot completed logging X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~614^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abba64faf3c409340fc085d4b7f601d2c3bb452b;p=sdk%2Femulator%2Fqemu.git emulator: boot completed logging 1. Added logging and state setting for emulator boot completed. 2. For efficient logging, I moved gettimeofday function to osutil Change-Id: Iea9ab8862c62f66bb33f12b6ab2b7aa778dadf3a Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/debug_ch.c b/tizen/src/debug_ch.c index 833b1ec357..af99ce9825 100644 --- a/tizen/src/debug_ch.c +++ b/tizen/src/debug_ch.c @@ -42,6 +42,7 @@ #include "emulator.h" #include "debug_ch.h" +#include "osutil.h" static char debugchfile[512] = {0, }; #ifdef _WIN32 @@ -447,38 +448,16 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel, int ret = 0; int ret_write = 0; char buf_msg[2048]; - char buf_time[128]; va_list valist; int open_flags; int fd; -#ifdef _WIN32 - struct tm *ptm; -#else - struct tm tm; -#endif - qemu_timeval tv = { 0, 0 }; - time_t ti; - if (!(_dbg_get_channel_flags(channel) & (1 << cls))) { return -1; } - qemu_gettimeofday(&tv); - ti = tv.tv_sec; - -#ifdef _WIN32 - ptm = localtime(&ti); - strftime(buf_time, sizeof(buf_time), - "%H:%M:%S", ptm); -#else - localtime_r(&ti, &tm); - strftime(buf_time, sizeof(buf_time), - "%H:%M:%S", &tm); -#endif - ret += snprintf(buf_msg, sizeof(buf_msg),"%s [%s:%s", - buf_time, debug_classes[cls], channel->name); + get_timeofday(), debug_classes[cls], channel->name); if (*channel->multiname) { ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s] ", channel->multiname); diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index aaf8c3edc3..71d1be3ff5 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -164,6 +164,10 @@ int get_emulator_condition(void) void set_emulator_condition(int state) { + if (state == BOOT_COMPLETED) { + INFO("boot completed!\n"); + } + _emul_state.emulator_condition = state; } diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 515349b7f8..993f317a99 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -37,6 +37,11 @@ #include "maru_common.h" #include "maru_finger.h" +enum { + BOOTING = 0, + BOOT_COMPLETED = 1, +}; + /* keep it consistent with emulator-skin definition */ enum { HARD_KEY_HOME = 139, diff --git a/tizen/src/hw/maru_virtio_esm.c b/tizen/src/hw/maru_virtio_esm.c index fd7d8e0c78..65d353d5bc 100644 --- a/tizen/src/hw/maru_virtio_esm.c +++ b/tizen/src/hw/maru_virtio_esm.c @@ -29,10 +29,16 @@ #include "maru_device_ids.h" #include "maru_virtio_esm.h" #include "skin/maruskin_server.h" +#include "emul_state.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(qemu, virtio-esm); + +#define SYSTEM_MODE_LAYER 1 +#define USER_MODE_LAYER 0 +static uint8_t boot_complete; + struct progress_info { char mode; uint16_t percentage; @@ -71,11 +77,27 @@ static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq) TRACE("Boot up progress is [%u] percent done at %s.\n", progress.percentage, progress.mode == 's' || progress.mode == 'S' ? "system mode" : "user mode"); + /* notify to skin */ - if(progress.mode == 's' || progress.mode == 'S') - notify_booting_progress(1, progress.percentage); - else - notify_booting_progress(0, progress.percentage); + if (progress.mode == 's' || progress.mode == 'S') { + if (progress.percentage >= 100) { + boot_complete |= (1 << SYSTEM_MODE_LAYER); + } + + notify_booting_progress(SYSTEM_MODE_LAYER, progress.percentage); + } else { + if (progress.percentage >= 100) { + boot_complete |= (1 << USER_MODE_LAYER); + } + + notify_booting_progress(USER_MODE_LAYER, progress.percentage); + } + + /* booting complete check */ + if ((boot_complete & (1 << SYSTEM_MODE_LAYER)) && + (boot_complete & (1 << USER_MODE_LAYER))) { + set_emulator_condition(BOOT_COMPLETED); + } } } diff --git a/tizen/src/osutil-darwin.c b/tizen/src/osutil-darwin.c index f39ba632ee..7ad28109e6 100644 --- a/tizen/src/osutil-darwin.c +++ b/tizen/src/osutil-darwin.c @@ -52,6 +52,11 @@ MULTI_DEBUG_CHANNEL(qemu, osutil); + +static qemu_timeval tv = { 0, 0 }; +static time_t ti; +static char buf_time[64]; + int g_shmid; extern char tizen_target_img_path[]; CFDictionaryRef proxySettings; @@ -225,6 +230,19 @@ void print_system_info_os(void) } } +char *get_timeofday(void) +{ + qemu_gettimeofday(&tv); + ti = tv.tv_sec; + + struct tm tm; + localtime_r(&ti, &tm); + strftime(buf_time, sizeof(buf_time), + "%H:%M:%S", &tm); + + return buf_time; +} + static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char type[MAXLEN]; diff --git a/tizen/src/osutil-linux.c b/tizen/src/osutil-linux.c index 6d5068b253..c90af7e739 100644 --- a/tizen/src/osutil-linux.c +++ b/tizen/src/osutil-linux.c @@ -56,6 +56,11 @@ MULTI_DEBUG_CHANNEL(emulator, osutil); + +static qemu_timeval tv = { 0, 0 }; +static time_t ti; +static char buf_time[64]; + extern char tizen_target_img_path[]; int g_shmid; char *g_shared_memory; @@ -227,6 +232,19 @@ void print_system_info_os(void) } } +char *get_timeofday(void) +{ + qemu_gettimeofday(&tv); + ti = tv.tv_sec; + + struct tm tm; + localtime_r(&ti, &tm); + strftime(buf_time, sizeof(buf_time), + "%H:%M:%S", &tm); + + return buf_time; +} + static void process_string(char *buf) { char tmp_buf[MAXLEN]; diff --git a/tizen/src/osutil-win32.c b/tizen/src/osutil-win32.c index d650641e8f..9403c2678a 100644 --- a/tizen/src/osutil-win32.c +++ b/tizen/src/osutil-win32.c @@ -50,6 +50,11 @@ MULTI_DEBUG_CHANNEL (emulator, osutil); + +static qemu_timeval tv = { 0, 0 }; +static time_t ti; +static char buf_time[64]; + extern char tizen_target_img_path[]; static const char *pactempfile = ".autoproxy"; @@ -195,6 +200,18 @@ void print_system_info_os(void) memInfo.ullTotalPhys / 1024, memInfo.ullAvailPhys / 1024); } +char *get_timeofday(void) +{ + qemu_gettimeofday(&tv); + ti = tv.tv_sec; + + struct tm *ptm = localtime(&ti); + strftime(buf_time, sizeof(buf_time), + "%H:%M:%S", ptm); + + return buf_time; +} + static int get_auto_proxy(BYTE *url, char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char type[MAXLEN]; diff --git a/tizen/src/osutil.c b/tizen/src/osutil.c index 10877c61a7..ece46bad2e 100644 --- a/tizen/src/osutil.c +++ b/tizen/src/osutil.c @@ -42,7 +42,8 @@ MULTI_DEBUG_CHANNEL(emulator, osutil); -const char *pac_tempfile = ".autoproxy"; + +const char *pac_tempfile = ".autoproxy"; inline size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { @@ -53,27 +54,29 @@ inline size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) inline void download_url(char *url) { - CURL *curl; - FILE *fp; - CURLcode res; + CURL *curl; + FILE *fp; + CURLcode res; curl = curl_easy_init(); - if (curl) { - fp = fopen(pac_tempfile,"wb"); + if (curl) { + fp = fopen(pac_tempfile, "wb"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); - //just in case network does not work. + /* just in case network does not work */ curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 3000); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + res = curl_easy_perform(curl); - if(res != 0) { + if (res != 0) { ERR("Fail to download pac file: %s\n", url); } - curl_easy_cleanup(curl); + + curl_easy_cleanup(curl); fclose(fp); - } + } - return; + return; } inline void remove_string(char *src, char *dst, const char *toremove) diff --git a/tizen/src/osutil.h b/tizen/src/osutil.h index 032d483a16..80f34fa925 100644 --- a/tizen/src/osutil.h +++ b/tizen/src/osutil.h @@ -32,6 +32,7 @@ #ifndef __OSUTIL_H__ #define __OSUTIL_H__ +#include "qemu-common.h" #include "maru_common.h" #include "emul_state.h" @@ -71,6 +72,7 @@ void get_host_proxy_os(char *, char *, char *, char *); void download_url(char *); size_t write_data(void *, size_t, size_t, FILE *); void remove_string(char *, char *, const char *); +char *get_timeofday(void); int get_number_of_processors(void);