FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/memcmd.c @ 953:9e1be763b626
c139explore: hbars and vbars tests implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 04 Nov 2015 04:09:44 +0000 |
parents | f50c71442d50 |
children | ce0ded19a769 |
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 |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
15 static void |
911
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 } |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
60 |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
61 cmd_dieid() |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
62 { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
63 u_char buf[8]; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
64 int rc; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
65 |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
66 rc = do_dieid_read(buf); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
67 if (rc) |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
68 return(rc); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
69 printf("%02X %02X %02X %02X %02X %02X %02X %02X\n", buf[0], buf[1], |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
70 buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
71 return(0); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
72 } |