comparison gsm-fw/lldbg/cmd_dump.c @ 865:f5affe83ba2d

lldbg hack (poor girl's substitute for JTAG) implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Fri, 15 May 2015 00:02:03 +0000
parents
children
comparison
equal deleted inserted replaced
864:4fa939eada22 865:f5affe83ba2d
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 lldbg_cmd_dump(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 (lldbg_parse_args(argbulk, 2, 2, argv, 0) < 0)
20 return;
21 if (lldbg_parse_hexarg(argv[0], 8, &start) < 0) {
22 lldbg_printf("ERROR: arg1 must be a valid 32-bit hex address\n");
23 return;
24 }
25 if (lldbg_parse_hexarg(argv[1], 8, &length) < 0) {
26 lldbg_printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n");
27 return;
28 }
29 if (start & 0xF || length & 0xF) {
30 lldbg_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 lldbg_printf("%08X: ", start + offset);
36 for (i = 0; i < 16; i++) {
37 lldbg_printf("%02X ", intbuf[i]);
38 if ((i & 3) == 3)
39 lldbg_putchar(' ');
40 }
41 for (i = 0; i < 16; i++) {
42 c = intbuf[i];
43 if (c >= ' ' && c <= '~')
44 lldbg_putchar(c);
45 else
46 lldbg_putchar('.');
47 }
48 lldbg_putchar('\n');
49 }
50 }