From 9a77b8c974e7f4ab57a8ad62758808e5b4e29e75 Mon Sep 17 00:00:00 2001 From: "syeon.hwang" Date: Thu, 30 Aug 2012 15:44:05 +0900 Subject: [PATCH] [Title] Experimental ramdump support [Type] [Module] [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- tizen/src/emulator.c | 6 +++++ tizen/src/emulator.h | 1 + tizen/src/guest_debug.h | 46 +++++++++++++++++++++++++++++++++++++ tizen/src/hw/maru_board.c | 12 ++++++++++ tizen/src/skin/maruskin_operation.c | 40 ++++++++++++++++++++++++++++++-- 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 tizen/src/guest_debug.h diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 2ad5cce..f51fb85 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -37,6 +37,7 @@ #include #endif #include "emulator.h" +#include "guest_debug.h" #include "sdb.h" #include "string.h" #include "skin/maruskin_server.h" @@ -84,6 +85,11 @@ static char **qemu_argv; void maru_display_fini(void); +char *get_logpath(void) +{ + return logpath; +} + void exit_emulator(void) { mloop_ev_stop(); diff --git a/tizen/src/emulator.h b/tizen/src/emulator.h index a30f731..c5f0c0e 100644 --- a/tizen/src/emulator.h +++ b/tizen/src/emulator.h @@ -49,4 +49,5 @@ void extract_info(int qemu_argc, char** qemu_argv); void prepare_maru(void); void check_shdmem(void); void make_shdmem(void); + #endif /* __EMULATOR_H__ */ diff --git a/tizen/src/guest_debug.h b/tizen/src/guest_debug.h new file mode 100644 index 0000000..2179cae --- /dev/null +++ b/tizen/src/guest_debug.h @@ -0,0 +1,46 @@ +/* + * Emulator + * + * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * HyunJun Son + * MunKyu Im + * GiWoong Kim + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +/** + * @file guest_debug.h + * @brief - header of file these are config structures and defines in emulator + */ + +#ifndef __GUEST_DEBUG_H__ +#define __GUEST_DEBUG_H__ + +#include "memory.h" + +char *get_logpath(void); +MemoryRegion *get_ram_memory(void); + +#endif /* __GUEST_DEBUG_H__ */ diff --git a/tizen/src/hw/maru_board.c b/tizen/src/hw/maru_board.c index d835958..9a5d62e 100644 --- a/tizen/src/hw/maru_board.c +++ b/tizen/src/hw/maru_board.c @@ -63,6 +63,8 @@ # include #endif +#include "guest_debug.h" + #define MAX_IDE_BUS 2 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; @@ -85,6 +87,13 @@ static void ioapic_init(GSIState *gsi_state) } } +MemoryRegion *global_ram_memory; + +MemoryRegion *get_ram_memory(void) +{ + return global_ram_memory; +} + static void maru_x86_machine_init(MemoryRegion *system_memory, MemoryRegion *system_io, ram_addr_t ram_size, @@ -146,6 +155,9 @@ static void maru_x86_machine_init(MemoryRegion *system_memory, pci_enabled ? rom_memory : system_memory, &ram_memory); } + // for ramdump... + global_ram_memory = ram_memory; + gsi_state = g_malloc0(sizeof(*gsi_state)); gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 0789878..cc2699e 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -51,6 +51,9 @@ #include "hw/maru_pm.h" #include "sysemu.h" +// for ramdump +#include "guest_debug.h" + #ifdef CONFIG_WIN32 #include "target-i386/hax-i386.h" #endif @@ -152,7 +155,7 @@ void do_key_event( int event_type, int keycode, int key_location ) #endif if (!mloop_evcmd_get_usbkbd_status()) { - return; + return; } int scancode = javakeycode_to_scancode(keycode, event_type, key_location); @@ -383,10 +386,43 @@ void onoff_usb_kbd( int on ) mloop_evcmd_usbkbd(on); } +#define MAX_PATH 256 +static void dump_ram( void ) +{ + MemoryRegion* rm = get_ram_memory(); + char dump_fullpath[MAX_PATH]; + char dump_filename[MAX_PATH]; + + char* dump_path = g_path_get_dirname(get_logpath()); + + sprintf(dump_filename, "0x%08x%s", rm->ram_addr, "_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; + unsigned int size = rm->size.lo; + 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); +} + void ram_dump(void) { INFO("ram dump!\n"); - //TODO: + dump_ram(); } void request_close( void ) -- 2.7.4