FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/memcmd.c @ 911:42719fa3e6af
etmsync: memory read implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 08 Sep 2015 07:52:29 +0000 |
parents | |
children | f50c71442d50 |
rev | line source |
---|---|
911
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * User commands for reading memory regions and Calypso die ID via ETM |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "etm.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "limits.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "localtypes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "exitcodes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 void |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 memdump_line(addr, buf, len) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 u32 addr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u_char *buf; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 int i, c; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 printf("%08X: ", addr); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 for (i = 0; i < 16; i++) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 if (i < len) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 printf("%02X ", buf[i]); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 else |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 fputs(" ", stdout); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (i == 7 || i == 15) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 putchar(' '); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 for (i = 0; i < len; i++) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 c = buf[i]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 if (c < ' ' || c > '~') |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 c = '.'; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 putchar(c); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 putchar('\n'); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 cmd_memdump(argc, argv) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 char **argv; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 u_char databuf[MAX_MEMREAD_BYTES]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 u32 memaddr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 int rc, sz, off, l; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 memaddr = strtoul(argv[1], 0, 16); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 sz = strtoul(argv[2], 0, 16); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 rc = do_memory_read(memaddr, databuf, sz); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (rc) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 return(rc); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 for (off = 0; off < sz; off += 16) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 l = sz - off; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 if (l > 16) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 l = 16; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 memdump_line(memaddr + off, databuf + off, l); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 return(0); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 } |