562 |
term_printf("\n"); |
term_printf("\n"); |
563 |
} |
} |
564 |
|
|
565 |
|
static void do_sum(uint32_t start, uint32_t size) |
566 |
|
{ |
567 |
|
uint32_t addr; |
568 |
|
uint8_t buf[1]; |
569 |
|
uint16_t sum; |
570 |
|
|
571 |
|
sum = 0; |
572 |
|
for(addr = start; addr < (start + size); addr++) { |
573 |
|
cpu_physical_memory_rw(addr, buf, 1, 0); |
574 |
|
/* BSD sum algorithm ('sum' Unix command) */ |
575 |
|
sum = (sum >> 1) | (sum << 15); |
576 |
|
sum += buf[0]; |
577 |
|
} |
578 |
|
term_printf("%05d\n", sum); |
579 |
|
} |
580 |
|
|
581 |
typedef struct { |
typedef struct { |
582 |
int keycode; |
int keycode; |
583 |
const char *name; |
const char *name; |
922 |
"keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, |
"keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, |
923 |
{ "system_reset", "", do_system_reset, |
{ "system_reset", "", do_system_reset, |
924 |
"", "reset the system" }, |
"", "reset the system" }, |
925 |
|
{ "sum", "ii", do_sum, |
926 |
|
"addr size", "compute the checksum of a memory region" }, |
927 |
{ NULL, NULL, }, |
{ NULL, NULL, }, |
928 |
}; |
}; |
929 |
|
|