emulator: boot completed logging 48/11848/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 6 Nov 2013 07:44:01 +0000 (16:44 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 7 Nov 2013 03:49:45 +0000 (12:49 +0900)
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 <giwoong.kim@samsung.com>
tizen/src/debug_ch.c
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/hw/maru_virtio_esm.c
tizen/src/osutil-darwin.c
tizen/src/osutil-linux.c
tizen/src/osutil-win32.c
tizen/src/osutil.c
tizen/src/osutil.h

index 833b1ec..af99ce9 100644 (file)
@@ -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);
index aaf8c3e..71d1be3 100644 (file)
@@ -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;
 }
 
index 515349b..993f317 100644 (file)
 #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,
index fd7d8e0..65d353d 100644 (file)
 #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);
+            }
         }
     }
 
index f39ba63..7ad2810 100644 (file)
 
 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];
index 6d5068b..c90af7e 100644 (file)
 
 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];
index d650641..9403c26 100644 (file)
 
 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];
index 10877c6..ece46ba 100644 (file)
@@ -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)
index 032d483..80f34fa 100644 (file)
@@ -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);