FreeCalypso > hg > freecalypso-tools
comparison rvinterf/etmsync/memcmd.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * User commands for reading memory regions and Calypso die ID via ETM | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "etm.h" | |
11 #include "tm3.h" | |
12 #include "limits.h" | |
13 #include "localtypes.h" | |
14 #include "exitcodes.h" | |
15 | |
16 static void | |
17 memdump_line(addr, buf, len) | |
18 u32 addr; | |
19 u_char *buf; | |
20 { | |
21 int i, c; | |
22 | |
23 printf("%08X: ", addr); | |
24 for (i = 0; i < 16; i++) { | |
25 if (i < len) | |
26 printf("%02X ", buf[i]); | |
27 else | |
28 fputs(" ", stdout); | |
29 if (i == 7 || i == 15) | |
30 putchar(' '); | |
31 } | |
32 for (i = 0; i < len; i++) { | |
33 c = buf[i]; | |
34 if (c < ' ' || c > '~') | |
35 c = '.'; | |
36 putchar(c); | |
37 } | |
38 putchar('\n'); | |
39 } | |
40 | |
41 cmd_memdump(argc, argv) | |
42 char **argv; | |
43 { | |
44 u_char databuf[MAX_MEMREAD_BYTES]; | |
45 u32 memaddr; | |
46 int rc, sz, off, l; | |
47 | |
48 memaddr = strtoul(argv[1], 0, 16); | |
49 sz = strtoul(argv[2], 0, 16); | |
50 rc = do_memory_read(memaddr, databuf, sz); | |
51 if (rc) | |
52 return(rc); | |
53 for (off = 0; off < sz; off += 16) { | |
54 l = sz - off; | |
55 if (l > 16) | |
56 l = 16; | |
57 memdump_line(memaddr + off, databuf + off, l); | |
58 } | |
59 return(0); | |
60 } | |
61 | |
62 cmd_omemdump(argc, argv) | |
63 char **argv; | |
64 { | |
65 u_char databuf[TM3_MEMREAD_MAX]; | |
66 u32 memaddr; | |
67 int rc, sz, off, l; | |
68 | |
69 memaddr = strtoul(argv[1], 0, 16); | |
70 sz = strtoul(argv[2], 0, 16); | |
71 rc = do_memory_read_tm3(memaddr, databuf, sz); | |
72 if (rc) | |
73 return(rc); | |
74 for (off = 0; off < sz; off += 16) { | |
75 l = sz - off; | |
76 if (l > 16) | |
77 l = 16; | |
78 memdump_line(memaddr + off, databuf + off, l); | |
79 } | |
80 return(0); | |
81 } | |
82 | |
83 cmd_dieid() | |
84 { | |
85 u_char buf[8]; | |
86 int rc; | |
87 | |
88 rc = do_dieid_read(buf); | |
89 if (rc) | |
90 return(rc); | |
91 printf("%02X %02X %02X %02X %02X %02X %02X %02X\n", buf[0], buf[1], | |
92 buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); | |
93 return(0); | |
94 } |