summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-11 21:36:14 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-11 21:36:14 +0000
commita8bdf7a63901c6ce2d02b2b67a8cc8f84222bd26 (patch)
tree73fceeb3d475a517f89caf65640bca6f54de73ad /monitor.c
parent0938cda5d0015d36e9b1a65a5b523fdcaaf1b6a8 (diff)
downloadqemu-a8bdf7a63901c6ce2d02b2b67a8cc8f84222bd26.tar.gz
physical memory dump to file
(Marvin Flumm) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4195 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 025025b7b0..7bad3263d6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -744,6 +744,32 @@ static void do_memory_save(unsigned int valh, unsigned int vall,
fclose(f);
}
+static void do_physical_memory_save(unsigned int valh, unsigned int vall,
+ uint32_t size, const char *filename)
+{
+ FILE *f;
+ uint32_t l;
+ uint8_t buf[1024];
+ target_long addr = GET_TLONG(valh, vall);
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ term_printf("could not open '%s'\n", filename);
+ return;
+ }
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size)
+ l = size;
+ cpu_physical_memory_rw(addr, buf, l, 0);
+ fwrite(buf, 1, l, f);
+ fflush(f);
+ addr += l;
+ size -= l;
+ }
+ fclose(f);
+}
+
static void do_sum(uint32_t start, uint32_t size)
{
uint32_t addr;
@@ -1328,6 +1354,8 @@ static term_cmd_t term_cmds[] = {
"capture index", "stop capture" },
{ "memsave", "lis", do_memory_save,
"addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", },
+ { "pmemsave", "lis", do_physical_memory_save,
+ "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", },
{ NULL, NULL, },
};