FreeCalypso > hg > freecalypso-sw
comparison target-utils/libcommon/cmd_memdump_human.c @ 956:1557e15a012f
target-utils refactoring: memory dump commands moved from libload to libcommon
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 04 Nov 2015 20:48:40 +0000 |
parents | target-utils/libload/cmd_memdump_human.c@9ee91bc6057c |
children |
comparison
equal
deleted
inserted
replaced
955:d7830aee0d35 | 956:1557e15a012f |
---|---|
1 /* | |
2 * This is a human-oriented memory dump command. The dump is given in | |
3 * both hex and ASCII, with readable spacing. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include "types.h" | |
8 | |
9 void | |
10 cmd_memdump_human(argbulk) | |
11 char *argbulk; | |
12 { | |
13 char *argv[3]; | |
14 u_long start, length; | |
15 u_long offset; | |
16 u_char intbuf[16]; | |
17 int i, c; | |
18 | |
19 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
20 return; | |
21 if (parse_hexarg(argv[0], 8, &start) < 0) { | |
22 printf("ERROR: arg1 must be a valid 32-bit hex address\n"); | |
23 return; | |
24 } | |
25 if (parse_hexarg(argv[1], 8, &length) < 0) { | |
26 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n"); | |
27 return; | |
28 } | |
29 if (start & 0xF || length & 0xF) { | |
30 printf("ERROR: implementation limit: 16-byte alignment required\n"); | |
31 return; | |
32 } | |
33 for (offset = 0; offset < length; offset += 0x10) { | |
34 bcopy(start + offset, intbuf, 0x10); | |
35 printf("%08X: ", start + offset); | |
36 for (i = 0; i < 16; i++) { | |
37 printf("%02X ", intbuf[i]); | |
38 if ((i & 3) == 3) | |
39 putchar(' '); | |
40 } | |
41 for (i = 0; i < 16; i++) { | |
42 c = intbuf[i]; | |
43 if (c >= ' ' && c <= '~') | |
44 putchar(c); | |
45 else | |
46 putchar('.'); | |
47 } | |
48 putchar('\n'); | |
49 } | |
50 } |