FreeCalypso > hg > freecalypso-sw
annotate rvinterf/tmsh/etmbasic.c @ 984:8c83777f856c
tfc139 reworked for the new "universal" break-in method
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 12 Dec 2015 03:17:12 +0000 |
parents | ebdf5afa9fb5 |
children |
rev | line source |
---|---|
183
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Basic ETM interaction |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <string.h> |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <strings.h> |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
260
c146f38d2b5f
rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
257
diff
changeset
|
10 #include "pktmux.h" |
c146f38d2b5f
rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
257
diff
changeset
|
11 #include "limits.h" |
188
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
12 #include "etm.h" |
979
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
13 #include "tm3.h" |
183
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern u_char rvi_msg[]; |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern int rvi_msg_len; |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 void |
188
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
19 print_etm_pkt_raw(err) |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
20 char *err; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
21 { |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
22 char buf[MAX_PKT_FROM_TARGET*3+80], *dp; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
23 int i; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
24 |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
25 sprintf(buf, "%s:", err); |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
26 dp = index(buf, '\0'); |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
27 for (i = 2; i < rvi_msg_len; i++) { |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
28 sprintf(dp, " %02X", rvi_msg[i]); |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
29 dp += 3; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
30 } |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
31 async_msg_output(buf); |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
32 } |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
33 |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
34 void |
183
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 etm_packet_rx() |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 { |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 int i, c; |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 if (rvi_msg_len < 4) { |
979
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
40 runt: print_etm_pkt_raw("TM runt"); |
188
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
41 return; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
42 } |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
43 c = 0; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
44 for (i = 2; i < rvi_msg_len; i++) |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
45 c ^= rvi_msg[i]; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
46 if (c) { |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
47 print_etm_pkt_raw("BAD CKSUM"); |
183
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 return; |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |
188
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
50 switch (rvi_msg[2]) { |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
51 case ETM_CORE: |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
52 if (rvi_msg_len < 6) |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
53 goto runt; |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
54 tmcore_msg_rx(); |
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
55 return; |
257
c413e791595a
fc-tmsh: added check-ffs1 command, getting ready to begin ffs2 implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
56 case ETM_FFS1: |
c413e791595a
fc-tmsh: added check-ffs1 command, getting ready to begin ffs2 implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
57 print_etm_pkt_raw("FFS1"); |
c413e791595a
fc-tmsh: added check-ffs1 command, getting ready to begin ffs2 implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
58 return; |
c413e791595a
fc-tmsh: added check-ffs1 command, getting ready to begin ffs2 implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
59 case ETM_FFS2: |
262
577291a2ad76
fc-tmsh ffs2 basic response handling implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
260
diff
changeset
|
60 if (rvi_msg_len < 5) |
577291a2ad76
fc-tmsh ffs2 basic response handling implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
260
diff
changeset
|
61 goto runt; |
577291a2ad76
fc-tmsh ffs2 basic response handling implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
260
diff
changeset
|
62 handle_ffs2_response(); |
257
c413e791595a
fc-tmsh: added check-ffs1 command, getting ready to begin ffs2 implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
63 return; |
979
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
64 /* TM3 */ |
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
65 case MEM_READ: |
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
66 if (rvi_msg_len < 5) |
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
67 goto runt; |
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
68 handle_omr_response(); |
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
69 return; |
188
9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
184
diff
changeset
|
70 default: |
979
ebdf5afa9fb5
fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
262
diff
changeset
|
71 print_etm_pkt_raw("TM unknown"); |
183
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 } |
85222710dc92
rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 } |
184
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
74 |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
75 void |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
76 cmd_etmpkt(argc, argv) |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
77 char **argv; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
78 { |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
79 u_char pkt[MAX_PKT_TO_TARGET]; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
80 int di, c, b; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
81 char **ap; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
82 |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
83 pkt[0] = RVT_TM_HEADER; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
84 di = 1; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
85 c = 0; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
86 for (ap = argv + 1; *ap; ap++) { |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
87 b = strtoul(*ap, 0, 16); |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
88 pkt[di++] = b; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
89 c ^= b; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
90 } |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
91 pkt[di++] = c; |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
92 send_pkt_to_target(pkt, di); |
4714fdfca39c
fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
183
diff
changeset
|
93 } |
189
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
94 |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
95 void |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
96 send_etm_cmd(buf, len) |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
97 u_char *buf; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
98 { |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
99 int i, c; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
100 |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
101 buf[0] = RVT_TM_HEADER; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
102 c = 0; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
103 for (i = 1; i <= len; i++) |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
104 c ^= buf[i]; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
105 buf[i] = c; |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
106 send_pkt_to_target(buf, len + 2); |
a95d253ef952
fc-tmsh: some basic tmcore commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
188
diff
changeset
|
107 } |