menu: ramdump function call is delegated to mloop
authorgiwoong.kim <giwoong.kim@samsung.com>
Fri, 7 Dec 2012 06:15:09 +0000 (15:15 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 7 Dec 2012 06:30:26 +0000 (15:30 +0900)
The heavy job like ramdump should not run on
the communication thread.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/mloop_event.c
tizen/src/mloop_event.h
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c [changed mode: 0755->0644]

index db35d56f2a0eeacbbf6c8409bd5f7eab67813bf7..5069fba2c59924fa4261cf6400a9abfa1aa843c1 100644 (file)
@@ -5,6 +5,8 @@
  *
  * Contact:
  * DoHyung Hong <don.hong@samsung.com>
+ * Kitae Kim <kt920.kim@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -76,6 +78,8 @@ struct mloop_evpack {
 #define MLOOP_EVTYPE_KEYBOARD   7
 #define MLOOP_EVTYPE_KBD_ADD    8
 #define MLOOP_EVTYPE_KBD_DEL    9
+#define MLOOP_EVTYPE_RAMDUMP    10
+
 
 static struct mloop_evsock mloop = {-1, 0, 0};
 
@@ -264,12 +268,13 @@ static void mloop_evhandle_hwkey(struct mloop_evpack* pack)
         if (kbd_mouse_is_absolute()) {
             ps2kbd_put_keycode(keycode & 0x7f);
         }
-    } else if ( KEY_RELEASED == event_type ) {
+    } else if (KEY_RELEASED == event_type) {
         if (kbd_mouse_is_absolute()) {
             ps2kbd_put_keycode(keycode | 0x80);
         }
     } else {
-        fprintf(stderr, "Unknown hardkey event type.[event_type:%d, keycode:%d]", event_type, keycode);
+        ERR("Unknown hardkey event type.[event_type:%d, keycode:%d]\n",
+            event_type, keycode);
     }
 }
 
@@ -359,6 +364,48 @@ static void mloop_evhandle_kbd_del(char *name)
 }
 #endif
 
+
+static void mloop_evhandle_ramdump(struct mloop_evpack* pack)
+{
+#define MAX_PATH 256
+    INFO("dumping...\n");
+
+#if defined(CONFIG_LINUX) && !defined(TARGET_ARM) /* FIXME: Handle ARM ram as list */
+    MemoryRegion* rm = get_ram_memory();
+    unsigned int size = rm->size.lo;
+    char dump_fullpath[MAX_PATH];
+    char dump_filename[MAX_PATH];
+
+    char* dump_path = g_path_get_dirname(get_logpath());
+
+    sprintf(dump_filename, "0x%08x%s0x%08x%s", rm->ram_addr, "-",
+        rm->ram_addr + size, "_RAM.dump");
+    sprintf(dump_fullpath, "%s/%s", dump_path, dump_filename);
+    free(dump_path);
+
+    FILE *dump_file = fopen(dump_fullpath, "w+");
+    if(!dump_file) {
+        fprintf(stderr, "Dump file create failed [%s]\n", dump_fullpath);
+
+        return;
+    }
+
+    size_t written;
+    written = fwrite(qemu_get_ram_ptr(rm->ram_addr), sizeof(char), size, dump_file);
+    fprintf(stdout, "Dump file written [%08x][%d bytes]\n", rm->ram_addr, written);
+    if(written != size) {
+        fprintf(stderr, "Dump file size error [%d, %d, %d]\n", written, size, errno);
+    }
+
+    fprintf(stdout, "Dump file create success [%s, %d bytes]\n", dump_fullpath, size);
+
+    fclose(dump_file);
+#endif
+
+    /* notify to skin process */
+    notify_ramdump_completed();
+}
+
 static void mloop_evcb_recv(struct mloop_evsock *ev)
 {
     struct mloop_evpack pack;
@@ -372,11 +419,11 @@ static void mloop_evcb_recv(struct mloop_evsock *ev)
     } while (ret == -1 && errno == EINTR);
 #endif // _WIN32
 
-    if (ret == -1 ) {
+    if (ret == -1) {
         return;
     }
 
-    if (ret == 0 ) {
+    if (ret == 0) {
         return;
     }
 
@@ -413,6 +460,9 @@ static void mloop_evcb_recv(struct mloop_evsock *ev)
         mloop_evhandle_kbd_del(pack.data);
         break;
 #endif
+    case MLOOP_EVTYPE_RAMDUMP:
+        mloop_evhandle_ramdump(&pack);
+        break;
     default:
         break;
     }
@@ -432,6 +482,26 @@ void mloop_ev_stop(void)
     mloop_evsock_remove(&mloop);
 }
 
+void mloop_evcmd_raise_intr(void *irq)
+{
+    struct mloop_evpack pack;
+    memset((void*)&pack, 0, sizeof(struct mloop_evpack));
+    pack.type = htons(MLOOP_EVTYPE_INTR_UP);
+    pack.size = htons(8);
+    *(long*)&pack.data[0] = htonl((long)irq);
+    mloop_evsock_send(&mloop, &pack);
+}
+
+void mloop_evcmd_lower_intr(void *irq)
+{
+    struct mloop_evpack pack;
+    memset((void*)&pack, 0, sizeof(struct mloop_evpack));
+    pack.type = htons(MLOOP_EVTYPE_INTR_DOWN);
+    pack.size = htons(8);
+    *(long*)&pack.data[0] = htonl((long)irq);
+    mloop_evsock_send(&mloop, &pack);
+}
+
 void mloop_evcmd_usbkbd(int on)
 {
     struct mloop_evpack pack = { htons(MLOOP_EVTYPE_USB_ADD), htons(13), "keyboard" };
@@ -490,26 +560,6 @@ void mloop_evcmd_set_hostkbd(void *dev)
     hostkbd = (PCIDevice *)dev;
 }
 
-void mloop_evcmd_raise_intr(void *irq)
-{
-    struct mloop_evpack pack;
-    memset((void*)&pack, 0, sizeof(struct mloop_evpack));
-    pack.type = htons(MLOOP_EVTYPE_INTR_UP);
-    pack.size = htons(8);
-    *(long*)&pack.data[0] = htonl((long)irq);
-    mloop_evsock_send(&mloop, &pack);
-}
-
-void mloop_evcmd_lower_intr(void *irq)
-{
-    struct mloop_evpack pack;
-    memset((void*)&pack, 0, sizeof(struct mloop_evpack));
-    pack.type = htons(MLOOP_EVTYPE_INTR_DOWN);
-    pack.size = htons(8);
-    *(long*)&pack.data[0] = htonl((long)irq);
-    mloop_evsock_send(&mloop, &pack);
-}
-
 void mloop_evcmd_hwkey(int event_type, int keycode)
 {
     struct mloop_evpack pack;
@@ -544,3 +594,14 @@ void mloop_evcmd_keyboard(void *data)
     *(long*)&pack.data[0] = htonl((long)data);
     mloop_evsock_send(&mloop, &pack);
 }
+
+void mloop_evcmd_ramdump(void)
+{
+    struct mloop_evpack pack;
+    memset(&pack, 0, sizeof(struct mloop_evpack));
+
+    pack.type = htons(MLOOP_EVTYPE_RAMDUMP);
+    pack.size = htons(5);
+    mloop_evsock_send(&mloop, &pack);
+}
+
index d7f69549c747c4331540bc81d055fbbf157c7db2..22db1a2b4f26938f0fabf2d6aad08fe880105d4f 100644 (file)
@@ -5,6 +5,8 @@
  *
  * Contact:
  * DoHyung Hong <don.hong@samsung.com>
+ * Kitae Kim <kt920.kim@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -51,6 +53,7 @@ void mloop_evcmd_lower_intr(void *irq);
 void mloop_evcmd_hwkey(int event_type, int keycode);
 void mloop_evcmd_touch(void);
 void mloop_evcmd_keyboard(void *data);
+void mloop_evcmd_ramdump(void);
 
 #ifdef __cplusplus
 }
index a3f1b92b3c02addb3bcbd069553cb3dd5e0d8298..c3e8dcd76aa60809998af5931da38884c560bba4 100644 (file)
@@ -405,22 +405,27 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
     return detail_info;
 }
 
-void free_detail_info( DetailInfo* detail_info ) {
-    if ( detail_info ) {
-        if ( detail_info->data ) {
-            g_free( detail_info->data );
+void free_detail_info(DetailInfo* detail_info)
+{
+    if (detail_info) {
+        if (detail_info->data) {
+            g_free(detail_info->data);
         }
-        g_free( detail_info );
+
+        g_free(detail_info);
     }
 }
 
-void open_shell( void ) {
+void do_open_shell(void)
+{
     INFO("open shell\n");
+    /* do nothing */
 }
 
 void onoff_host_kbd(int on)
 {
     INFO("host kbd on/off: %d.\n", on);
+
 #if defined(TARGET_ARM)
     mloop_evcmd_usbkbd(on);
 #elif defined(TARGET_I386)
@@ -428,69 +433,34 @@ void onoff_host_kbd(int on)
 #endif
 }
 
-#define MAX_PATH 256
-static void dump_ram( void )
+void do_ram_dump(void)
 {
-#if defined(CONFIG_LINUX) && !defined(TARGET_ARM) /* FIXME: Handle ARM ram as list */
-    MemoryRegion* rm = get_ram_memory();
-    unsigned int size = rm->size.lo;
-    char dump_fullpath[MAX_PATH];
-    char dump_filename[MAX_PATH];
-
-    char* dump_path = g_path_get_dirname(get_logpath());
-
-    sprintf(dump_filename, "0x%08x%s0x%08x%s", rm->ram_addr, "-",
-        rm->ram_addr + size, "_RAM.dump");
-    sprintf(dump_fullpath, "%s/%s", dump_path, dump_filename);
-    free(dump_path);
-
-    FILE *dump_file = fopen(dump_fullpath, "w+");
-    if(!dump_file) {
-        fprintf(stderr, "Dump file create failed [%s]\n", dump_fullpath);
-
-        return;
-    }
-
-    size_t written;
-    written = fwrite(qemu_get_ram_ptr(rm->ram_addr), sizeof(char), size, dump_file);
-    fprintf(stdout, "Dump file written [%08x][%d bytes]\n", rm->ram_addr, written);
-    if(written != size) {
-        fprintf(stderr, "Dump file size error [%d, %d, %d]\n", written, size, errno);
-    }
-
-    fprintf(stdout, "Dump file create success [%s, %d bytes]\n", dump_fullpath, size);
-
-    fclose(dump_file);
-#endif
-}
-
-void ram_dump(void) {
-    INFO("ram dump!\n");
+    INFO("dump ram!\n");
 
-    dump_ram();
-
-    notify_ramdump_complete();
+    mloop_evcmd_ramdump();
 }
 
-void guestmemory_dump(void) {
-    INFO("guest memory dump!\n");
+void do_guestmemory_dump(void)
+{
+    INFO("dump guest memory!\n");
 
     //TODO:
 }
 
-void request_close( void )
+void request_close(void)
 {
-    INFO( "request_close\n" );
+    INFO("request_close\n");
 
-    do_hardkey_event( KEY_PRESSED, HARD_KEY_POWER );
+    /* FIXME: convert to device emulatoion */
+    do_hardkey_event(KEY_PRESSED, HARD_KEY_POWER);
 
 #ifdef CONFIG_WIN32
-        Sleep( CLOSE_POWER_KEY_INTERVAL );
+        Sleep(CLOSE_POWER_KEY_INTERVAL);
 #else
-        usleep( CLOSE_POWER_KEY_INTERVAL * 1000 );
+        usleep(CLOSE_POWER_KEY_INTERVAL * 1000);
 #endif
 
-    do_hardkey_event( KEY_RELEASED, HARD_KEY_POWER );
+    do_hardkey_event(KEY_RELEASED, HARD_KEY_POWER);
 
 }
 
index ba9690f94d3a612d64feae8ab88bd984d8dba0a8..d11b38d16c84056f5e46d03a4452f368c3f55d05 100644 (file)
@@ -47,36 +47,29 @@ struct DetailInfo {
 };
 typedef struct DetailInfo DetailInfo;
 
-void start_display(uint64 handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type);
-
-void do_mouse_event(int button_type, int event_type, int origin_x, int origin_y, int x, int y, int z);
-
-void do_key_event(int event_type, int keycode, int state_mask, int key_location);
+void start_display(uint64 handle_id, int lcd_size_width, int lcd_size_height,
+    double scale_factor, short rotation_type);
 
+void do_mouse_event(int button_type, int event_type,
+    int origin_x, int origin_y, int x, int y, int z);
+void do_key_event(int event_type,
+    int keycode, int state_mask, int key_location);
 void do_hardkey_event(int event_type, int keycode);
-
 void do_scale_event(double scale_factor);
-
 void do_rotation_event(int rotation_type);
 
 QemuSurfaceInfo *get_screenshot_info(void);
-
 DetailInfo *get_detail_info(int qemu_argc, char **qemu_argv);
-
 void free_detail_info(DetailInfo *detail_info);
-
 void free_screenshot_info(QemuSurfaceInfo *);
 
-void open_shell(void);
-
+void do_open_shell(void);
 void onoff_host_kbd(int on);
-
-void ram_dump(void);
+void do_ram_dump(void);
+void do_guestmemory_dump(void);
 
 void request_close(void);
-
 void shutdown_qemu_gracefully(void);
-
 int is_requested_shutdown_qemu_gracefully(void);
 
 #endif /* MARUSKIN_OPERATION_H_ */
old mode 100755 (executable)
new mode 100644 (file)
index f038a2d..f47cc6f
@@ -259,8 +259,9 @@ void notify_sensor_daemon_start( void ) {
     }
 }
 
-void notify_ramdump_complete(void) {
-    INFO("notify_ramdump_complete\n");
+void notify_ramdump_completed(void)
+{
+    INFO("ramdump completed!\n");
 
     if (client_sock) {
         if (0 > send_skin_header_only( client_sock, SEND_RAMDUMP_COMPLETE, 1)) {
@@ -270,16 +271,18 @@ void notify_ramdump_complete(void) {
 }
 
 
-int is_ready_skin_server( void ) {
+int is_ready_skin_server(void)
+{
     return ready_server;
 }
 
-int get_skin_server_port( void ) {
+int get_skin_server_port(void)
+{
     return svr_port;
 }
 
-static void parse_skinconfig_prop( void ) {
-
+static void parse_skinconfig_prop(void)
+{
     int target_path_len = strlen( tizen_target_path );
     char skin_config_path[target_path_len + 32];
 
@@ -782,14 +785,14 @@ static void* run_skin_server( void* args ) {
                     log_cnt += sprintf(log_buf + log_cnt, "RECV_RAM_DUMP ==\n");
                     TRACE(log_buf);
 
-                    ram_dump();
+                    do_ram_dump();
                     break;
                 }
                 case RECV_GUESTMEMORY_DUMP: {
                     log_cnt += sprintf(log_buf + log_cnt, "RECV_GUESTMEMORY_DUMP ==\n");
                     TRACE(log_buf);
 
-                    guestmemory_dump();
+                    do_guestmemory_dump();
                     break;
                 }
                 case RECV_RESPONSE_HEART_BEAT: {
@@ -804,10 +807,10 @@ static void* run_skin_server( void* args ) {
                     break;
                 }
                 case RECV_OPEN_SHELL: {
-                    log_cnt += sprintf( log_buf + log_cnt, "RECV_OPEN_SHELL ==\n" );
-                    TRACE( log_buf );
+                    log_cnt += sprintf(log_buf + log_cnt, "RECV_OPEN_SHELL ==\n");
+                    TRACE(log_buf);
 
-                    open_shell();
+                    do_open_shell();
                     break;
                 }
                 case RECV_HOST_KBD: {
@@ -822,13 +825,13 @@ static void* run_skin_server( void* args ) {
                     }
 
                     memcpy(&on, recvbuf, sizeof(on));
-                                       onoff_host_kbd(on);
+                    onoff_host_kbd(on);
                     break;
                 }
 
                 case RECV_CLOSE: {
-                    log_cnt += sprintf( log_buf + log_cnt, "RECV_CLOSE ==\n" );
-                    TRACE( log_buf );
+                    log_cnt += sprintf(log_buf + log_cnt, "RECV_CLOSE ==\n");
+                    TRACE(log_buf);
 
                     request_close();
                     break;