[Title] Experimental ramdump support
authorsyeon.hwang <syeon.hwang@samsung.com>
Thu, 30 Aug 2012 06:44:05 +0000 (15:44 +0900)
committersyeon.hwang <syeon.hwang@samsung.com>
Thu, 30 Aug 2012 07:30:06 +0000 (16:30 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/emulator.c
tizen/src/emulator.h
tizen/src/guest_debug.h [new file with mode: 0644]
tizen/src/hw/maru_board.c
tizen/src/skin/maruskin_operation.c

index 2ad5cce..f51fb85 100644 (file)
@@ -37,6 +37,7 @@
 #include <SDL.h>
 #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();
index a30f731..c5f0c0e 100644 (file)
@@ -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 (file)
index 0000000..2179cae
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * HyunJun Son <hj79.son@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * 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__ */
index d835958..9a5d62e 100644 (file)
@@ -63,6 +63,8 @@
 #  include <xen/hvm/hvm_info_table.h>
 #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);
 
index 0789878..cc2699e 100644 (file)
@@ -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 )