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>
#include "emulator.h"
#include "debug_ch.h"
+#include "osutil.h"
static char debugchfile[512] = {0, };
#ifdef _WIN32
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);
void set_emulator_condition(int state)
{
+ if (state == BOOT_COMPLETED) {
+ INFO("boot completed!\n");
+ }
+
_emul_state.emulator_condition = state;
}
#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,
#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;
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);
+ }
}
}
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;
}
}
+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];
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;
}
}
+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];
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";
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];
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)
{
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)
#ifndef __OSUTIL_H__
#define __OSUTIL_H__
+#include "qemu-common.h"
#include "maru_common.h"
#include "emul_state.h"
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);