From 43bed2ced6211d7449dee7ee61bdbf49635dba2f Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Fri, 7 Dec 2012 15:15:09 +0900 Subject: [PATCH] menu: ramdump function call is delegated to mloop The heavy job like ramdump should not run on the communication thread. Signed-off-by: GiWoong Kim --- tizen/src/mloop_event.c | 109 ++++++++++++++++++++++++++++-------- tizen/src/mloop_event.h | 3 + tizen/src/skin/maruskin_operation.c | 78 ++++++++------------------ tizen/src/skin/maruskin_operation.h | 25 +++------ tizen/src/skin/maruskin_server.c | 31 +++++----- 5 files changed, 138 insertions(+), 108 deletions(-) mode change 100755 => 100644 tizen/src/skin/maruskin_server.c diff --git a/tizen/src/mloop_event.c b/tizen/src/mloop_event.c index db35d56..5069fba 100644 --- a/tizen/src/mloop_event.c +++ b/tizen/src/mloop_event.c @@ -5,6 +5,8 @@ * * Contact: * DoHyung Hong + * Kitae Kim + * GiWoong Kim * * 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); +} + diff --git a/tizen/src/mloop_event.h b/tizen/src/mloop_event.h index d7f6954..22db1a2 100644 --- a/tizen/src/mloop_event.h +++ b/tizen/src/mloop_event.h @@ -5,6 +5,8 @@ * * Contact: * DoHyung Hong + * Kitae Kim + * GiWoong Kim * * 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 } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index a3f1b92..c3e8dcd 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -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); } diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index ba9690f..d11b38d 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -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_ */ diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c old mode 100755 new mode 100644 index f038a2d..f47cc6f --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -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; -- 2.7.4