Commit a8bdf7a63901c6ce2d02b2b67a8cc8f84222bd26
1 parent
0938cda5
physical memory dump to file
(Marvin Flumm) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4195 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
28 additions
and
0 deletions
monitor.c
... | ... | @@ -744,6 +744,32 @@ static void do_memory_save(unsigned int valh, unsigned int vall, |
744 | 744 | fclose(f); |
745 | 745 | } |
746 | 746 | |
747 | +static void do_physical_memory_save(unsigned int valh, unsigned int vall, | |
748 | + uint32_t size, const char *filename) | |
749 | +{ | |
750 | + FILE *f; | |
751 | + uint32_t l; | |
752 | + uint8_t buf[1024]; | |
753 | + target_long addr = GET_TLONG(valh, vall); | |
754 | + | |
755 | + f = fopen(filename, "wb"); | |
756 | + if (!f) { | |
757 | + term_printf("could not open '%s'\n", filename); | |
758 | + return; | |
759 | + } | |
760 | + while (size != 0) { | |
761 | + l = sizeof(buf); | |
762 | + if (l > size) | |
763 | + l = size; | |
764 | + cpu_physical_memory_rw(addr, buf, l, 0); | |
765 | + fwrite(buf, 1, l, f); | |
766 | + fflush(f); | |
767 | + addr += l; | |
768 | + size -= l; | |
769 | + } | |
770 | + fclose(f); | |
771 | +} | |
772 | + | |
747 | 773 | static void do_sum(uint32_t start, uint32_t size) |
748 | 774 | { |
749 | 775 | uint32_t addr; |
... | ... | @@ -1328,6 +1354,8 @@ static term_cmd_t term_cmds[] = { |
1328 | 1354 | "capture index", "stop capture" }, |
1329 | 1355 | { "memsave", "lis", do_memory_save, |
1330 | 1356 | "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, |
1357 | + { "pmemsave", "lis", do_physical_memory_save, | |
1358 | + "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", }, | |
1331 | 1359 | { NULL, NULL, }, |
1332 | 1360 | }; |
1333 | 1361 | ... | ... |