FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/memcmd.c @ 1005:908566db1538
gsm-fw feature tch-reroute: init and config fleshed out
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 20 Mar 2016 18:50:54 +0000 |
parents | ce0ded19a769 |
children |
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" |
977
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
11 #include "tm3.h" |
911
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "limits.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "localtypes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "exitcodes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
16 static void |
911
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 memdump_line(addr, buf, len) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u32 addr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 u_char *buf; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 int i, c; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 printf("%08X: ", addr); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 for (i = 0; i < 16; i++) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 if (i < len) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 printf("%02X ", buf[i]); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 else |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 fputs(" ", stdout); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (i == 7 || i == 15) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 putchar(' '); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 for (i = 0; i < len; i++) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 c = buf[i]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 if (c < ' ' || c > '~') |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 c = '.'; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 putchar(c); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 putchar('\n'); |
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 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 cmd_memdump(argc, argv) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 char **argv; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 u_char databuf[MAX_MEMREAD_BYTES]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 u32 memaddr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 int rc, sz, off, l; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 memaddr = strtoul(argv[1], 0, 16); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 sz = strtoul(argv[2], 0, 16); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 rc = do_memory_read(memaddr, databuf, sz); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 if (rc) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 return(rc); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 for (off = 0; off < sz; off += 16) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 l = sz - off; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (l > 16) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 l = 16; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 memdump_line(memaddr + off, databuf + off, l); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 return(0); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
61 |
977
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
62 cmd_omemdump(argc, argv) |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
63 char **argv; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
64 { |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
65 u_char databuf[TM3_MEMREAD_MAX]; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
66 u32 memaddr; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
67 int rc, sz, off, l; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
68 |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
69 memaddr = strtoul(argv[1], 0, 16); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
70 sz = strtoul(argv[2], 0, 16); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
71 rc = do_memory_read_tm3(memaddr, databuf, sz); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
72 if (rc) |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
73 return(rc); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
74 for (off = 0; off < sz; off += 16) { |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
75 l = sz - off; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
76 if (l > 16) |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
77 l = 16; |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
78 memdump_line(memaddr + off, databuf + off, l); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
79 } |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
80 return(0); |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
81 } |
ce0ded19a769
rvinterf: first attempt at TM3 memory read: omemdump command in fc-fsio
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
82 |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
83 cmd_dieid() |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
84 { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
85 u_char buf[8]; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
86 int rc; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
87 |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
88 rc = do_dieid_read(buf); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
89 if (rc) |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
90 return(rc); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
91 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
|
92 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
|
93 return(0); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
94 } |