annotate rvinterf/etm/etmbasic.c @ 184:4714fdfca39c

fc-tmsh compiles!
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 24 Nov 2013 08:40:44 +0000
parents 85222710dc92
children 9f4f331ac24d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
184
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
10 #include "../pktmux.h"
183
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../limits.h"
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern u_char rvi_msg[];
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 extern int rvi_msg_len;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 void
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 etm_packet_rx()
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 char buf[MAX_PKT_FROM_TARGET*3+80], *dp;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 int i, c;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 if (rvi_msg_len < 4) {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 async_msg_output("!!! Short ETM Rx packet !!!");
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 return;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 strcpy(buf, "Pkt from ETM:");
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 dp = index(buf, '\0');
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 c = 0;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 for (i = 2; i < rvi_msg_len; i++) {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 sprintf(dp, " %02X", rvi_msg[i]);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 dp += 3;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 c ^= rvi_msg[i];
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 sprintf(dp, " chksum %s", c ? "BAD" : "OK");
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 async_msg_output(buf);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
184
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
37
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
38 void
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
39 cmd_etmpkt(argc, argv)
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
40 char **argv;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
41 {
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
42 u_char pkt[MAX_PKT_TO_TARGET];
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
43 int di, c, b;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
44 char **ap;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
45
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
46 pkt[0] = RVT_TM_HEADER;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
47 di = 1;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
48 c = 0;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
49 for (ap = argv + 1; *ap; ap++) {
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
50 b = strtoul(*ap, 0, 16);
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
51 pkt[di++] = b;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
52 c ^= b;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
53 }
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
54 pkt[di++] = c;
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
55 send_pkt_to_target(pkt, di);
4714fdfca39c fc-tmsh compiles!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 183
diff changeset
56 }