annotate rvinterf/tmsh/etmbasic.c @ 132:5380872923a6

fc-tmsh: beginning of l1tm response handling
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Feb 2017 20:53:41 +0000
parents 2159f260ed13
children 4aa1c18c7a2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Basic ETM interaction
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "limits.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "etm.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "tm3.h"
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
14 #include "exitcodes.h"
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern u_char rvi_msg[];
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern int rvi_msg_len;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 print_etm_pkt_raw(err)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 char *err;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 char buf[MAX_PKT_FROM_TARGET*3+80], *dp;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int i;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 sprintf(buf, "%s:", err);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 dp = index(buf, '\0');
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 for (i = 2; i < rvi_msg_len; i++) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 sprintf(dp, " %02X", rvi_msg[i]);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 dp += 3;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 async_msg_output(buf);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 etm_packet_rx()
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 int i, c;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (rvi_msg_len < 4) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 runt: print_etm_pkt_raw("TM runt");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 c = 0;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 for (i = 2; i < rvi_msg_len; i++)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 c ^= rvi_msg[i];
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (c) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 print_etm_pkt_raw("BAD CKSUM");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 switch (rvi_msg[2]) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 case ETM_CORE:
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (rvi_msg_len < 6)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 goto runt;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 tmcore_msg_rx();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 case ETM_FFS1:
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 print_etm_pkt_raw("FFS1");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 case ETM_FFS2:
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (rvi_msg_len < 5)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 goto runt;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 handle_ffs2_response();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 /* TM3 */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 case MEM_READ:
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if (rvi_msg_len < 5)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 goto runt;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 handle_omr_response();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return;
132
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
71 /* L1TM */
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
72 case TM_INIT:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
73 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
74 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
75 l1tm_response_nodata("tminit");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
76 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
77 case TM_MODE_SET:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
78 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
79 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
80 l1tm_response_nodata("tms");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
81 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
82 case VERSION_GET:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
83 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
84 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
85 l1tm_response_index_val("tm3ver");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
86 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
87 case RF_ENABLE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
88 print_etm_pkt_raw("RF_ENABLE response");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
89 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
90 case STATS_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
91 print_etm_pkt_raw("STATS_READ response");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
92 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
93 case STATS_CONFIG_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
94 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
95 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
96 l1tm_response_index("scw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
97 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
98 case STATS_CONFIG_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
99 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
100 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
101 l1tm_response_index_val("scr");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
102 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
103 case RF_PARAM_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
104 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
105 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
106 l1tm_response_index("rfpw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
107 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
108 case RF_PARAM_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
109 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
110 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
111 l1tm_response_index_val("rfpr");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
112 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
113 case RF_TABLE_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
114 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
115 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
116 l1tm_response_index("rftw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
117 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
118 case RF_TABLE_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
119 print_etm_pkt_raw("RF_TABLE_READ response");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
120 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
121 case RX_PARAM_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
122 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
123 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
124 l1tm_response_index("rxpw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
125 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
126 case RX_PARAM_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
127 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
128 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
129 l1tm_response_index_val("rxpr");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
130 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
131 case TX_PARAM_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
132 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
133 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
134 l1tm_response_index("txpw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
135 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
136 case TX_PARAM_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
137 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
138 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
139 l1tm_response_index_val("txpr");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
140 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
141 case TX_TEMPLATE_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
142 print_etm_pkt_raw("TX_TEMPLATE_WRITE response");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
143 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
144 case TX_TEMPLATE_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
145 print_etm_pkt_raw("TX_TEMPLATE_READ response");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
146 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
147 case MISC_PARAM_WRITE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
148 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
149 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
150 l1tm_response_index("mpw");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
151 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
152 case MISC_PARAM_READ:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
153 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
154 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
155 l1tm_response_index_val("mpr");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
156 return;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
157 case MISC_ENABLE:
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
158 if (rvi_msg_len < 5)
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
159 goto runt;
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
160 l1tm_response_index("me");
5380872923a6 fc-tmsh: beginning of l1tm response handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
161 return;
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 default:
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 print_etm_pkt_raw("TM unknown");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166
68
585f63e5bca6 fc-tmsh: etmpkt command renamed to tmpkt, etmpkt retained as alias
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
167 cmd_tmpkt(argc, argv)
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 char **argv;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 u_char pkt[MAX_PKT_TO_TARGET];
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 int di, c, b;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 char **ap;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 pkt[0] = RVT_TM_HEADER;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 di = 1;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 c = 0;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 for (ap = argv + 1; *ap; ap++) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 b = strtoul(*ap, 0, 16);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 pkt[di++] = b;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 c ^= b;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 pkt[di++] = c;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 send_pkt_to_target(pkt, di);
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
184 return(0);
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 send_etm_cmd(buf, len)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 u_char *buf;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 int i, c;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 buf[0] = RVT_TM_HEADER;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 c = 0;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 for (i = 1; i <= len; i++)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 c ^= buf[i];
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 buf[i] = c;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 send_pkt_to_target(buf, len + 2);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 }