mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-14 15:36:25 +00:00
added sum command
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1434 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
72cc6cfeef
commit
e4cf1adc80
18
monitor.c
18
monitor.c
@ -562,6 +562,22 @@ static void do_print(int count, int format, int size, unsigned int valh, unsigne
|
|||||||
term_printf("\n");
|
term_printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_sum(uint32_t start, uint32_t size)
|
||||||
|
{
|
||||||
|
uint32_t addr;
|
||||||
|
uint8_t buf[1];
|
||||||
|
uint16_t sum;
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for(addr = start; addr < (start + size); addr++) {
|
||||||
|
cpu_physical_memory_rw(addr, buf, 1, 0);
|
||||||
|
/* BSD sum algorithm ('sum' Unix command) */
|
||||||
|
sum = (sum >> 1) | (sum << 15);
|
||||||
|
sum += buf[0];
|
||||||
|
}
|
||||||
|
term_printf("%05d\n", sum);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int keycode;
|
int keycode;
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -906,6 +922,8 @@ static term_cmd_t term_cmds[] = {
|
|||||||
"keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" },
|
"keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" },
|
||||||
{ "system_reset", "", do_system_reset,
|
{ "system_reset", "", do_system_reset,
|
||||||
"", "reset the system" },
|
"", "reset the system" },
|
||||||
|
{ "sum", "ii", do_sum,
|
||||||
|
"addr size", "compute the checksum of a memory region" },
|
||||||
{ NULL, NULL, },
|
{ NULL, NULL, },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user