Revision 6d3962bf monitor.c
b/monitor.c | ||
---|---|---|
1370 | 1370 |
monitor_printf(mon, "\n"); |
1371 | 1371 |
} |
1372 | 1372 |
|
1373 |
static int do_physical_memory_save(Monitor *mon, const QDict *qdict, |
|
1374 |
QObject **ret_data) |
|
1375 |
{ |
|
1376 |
FILE *f; |
|
1377 |
uint32_t l; |
|
1378 |
uint8_t buf[1024]; |
|
1379 |
uint32_t size = qdict_get_int(qdict, "size"); |
|
1380 |
const char *filename = qdict_get_str(qdict, "filename"); |
|
1381 |
target_phys_addr_t addr = qdict_get_int(qdict, "val"); |
|
1382 |
int ret = -1; |
|
1383 |
|
|
1384 |
f = fopen(filename, "wb"); |
|
1385 |
if (!f) { |
|
1386 |
qerror_report(QERR_OPEN_FILE_FAILED, filename); |
|
1387 |
return -1; |
|
1388 |
} |
|
1389 |
while (size != 0) { |
|
1390 |
l = sizeof(buf); |
|
1391 |
if (l > size) |
|
1392 |
l = size; |
|
1393 |
cpu_physical_memory_read(addr, buf, l); |
|
1394 |
if (fwrite(buf, 1, l, f) != l) { |
|
1395 |
monitor_printf(mon, "fwrite() error in do_physical_memory_save\n"); |
|
1396 |
goto exit; |
|
1397 |
} |
|
1398 |
fflush(f); |
|
1399 |
addr += l; |
|
1400 |
size -= l; |
|
1401 |
} |
|
1402 |
|
|
1403 |
ret = 0; |
|
1404 |
|
|
1405 |
exit: |
|
1406 |
fclose(f); |
|
1407 |
return ret; |
|
1408 |
} |
|
1409 |
|
|
1410 | 1373 |
static void do_sum(Monitor *mon, const QDict *qdict) |
1411 | 1374 |
{ |
1412 | 1375 |
uint32_t addr; |
Also available in: Unified diff