annotate rvinterf/etmsync/l1tmops.c @ 988:5a6019ed7e72

pln-ppb-test: implement read-id
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 00:04:18 +0000
parents 4694c7686ccd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the functions that access the L1TM operations
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * which we are going to use in fc-tmsync and fc-readcal.
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "pktmux.h"
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "tm3.h"
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "l1tm.h"
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "exitcodes.h"
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern u_char rvi_msg[];
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern int rvi_msg_len;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 do_tms(arg)
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 u_char cmdpkt[5];
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 cmdpkt[1] = TM_MODE_SET;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 cmdpkt[2] = arg;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 cmdpkt[3] = arg >> 8;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 etm_pkt_exch(cmdpkt, 3);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (rvi_msg[3]) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fprintf(stderr, "target error %u in response to tms\n",
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 rvi_msg[3]);
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
30 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (rvi_msg_len != 5) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fprintf(stderr, "target error: tms response wrong length\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
34 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return(0);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
271
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
39 do_rfpr(index, retp)
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
40 u_short *retp;
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
41 {
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
42 u_char cmdpkt[5];
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
43
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
44 cmdpkt[1] = RF_PARAM_READ;
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
45 cmdpkt[2] = index;
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
46 cmdpkt[3] = index >> 8;
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
47 etm_pkt_exch(cmdpkt, 3);
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
48 if (rvi_msg[3]) {
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
49 fprintf(stderr, "target error %u in response to rfpr\n",
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
50 rvi_msg[3]);
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
51 return(ERROR_TARGET);
271
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
52 }
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
53 if (rvi_msg_len != 8) {
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
54 fprintf(stderr, "target error: rfpr response wrong length\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
55 return(ERROR_TARGET);
271
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
56 }
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
57 if (rvi_msg[4] != index) {
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
58 fprintf(stderr, "target error: rfpr response wrong index\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
59 return(ERROR_TARGET);
271
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
60 }
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
61 *retp = rvi_msg[5] | (rvi_msg[6] << 8);
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
62 return(0);
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
63 }
dc9dbb2f74e7 etmsync l1tmops module: rfpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 270
diff changeset
64
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 do_rfpw(index, value)
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 u_char cmdpkt[7];
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 cmdpkt[1] = RF_PARAM_WRITE;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 cmdpkt[2] = index;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 cmdpkt[3] = index >> 8;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 cmdpkt[4] = value;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 cmdpkt[5] = value >> 8;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 etm_pkt_exch(cmdpkt, 5);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (rvi_msg[3]) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 fprintf(stderr, "target error %u in response to rfpw\n",
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 rvi_msg[3]);
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
78 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if (rvi_msg_len != 6) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 fprintf(stderr, "target error: rfpw response wrong length\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
82 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (rvi_msg[4] != index) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 fprintf(stderr, "target error: rfpw response wrong index\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
86 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 return(0);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 do_rftr(index, table, size)
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 u_char *table;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 u_char cmdpkt[4];
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 cmdpkt[1] = RF_TABLE_READ;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 cmdpkt[2] = index;
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 etm_pkt_exch(cmdpkt, 2);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 if (rvi_msg[3]) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 fprintf(stderr, "target error %u in response to rftr\n",
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 rvi_msg[3]);
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
102 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 if (rvi_msg_len < size + 6) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 fprintf(stderr, "target error: rftr response too short\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
106 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 if (rvi_msg[4] != index) {
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 fprintf(stderr, "target error: rftr response wrong index\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
110 return(ERROR_TARGET);
270
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 }
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 bcopy(rvi_msg + 5, table, size);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 return(0);
095ffce023d4 etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 }
272
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
115
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
116 do_ttr(index, buf)
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
117 u_char *buf;
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
118 {
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
119 u_char cmdpkt[4];
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
120
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
121 cmdpkt[1] = TX_TEMPLATE_READ;
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
122 cmdpkt[2] = index;
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
123 etm_pkt_exch(cmdpkt, 2);
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
124 if (rvi_msg[3]) {
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
125 fprintf(stderr, "target error %u in response to ttr\n",
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
126 rvi_msg[3]);
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
127 return(ERROR_TARGET);
272
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
128 }
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
129 if (rvi_msg_len != 38) {
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
130 fprintf(stderr, "target error: ttr response wrong length\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
131 return(ERROR_TARGET);
272
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
132 }
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
133 if (rvi_msg[4] != index) {
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
134 fprintf(stderr, "target error: ttr response wrong index\n");
277
4469d73bbc60 etmsync l1tmops module: need to return on errors, not exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 272
diff changeset
135 return(ERROR_TARGET);
272
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
136 }
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
137 bcopy(rvi_msg + 5, buf, 32);
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
138 return(0);
3e272b956ef4 etmsync l1tmops module: ttr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 271
diff changeset
139 }
844
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
140
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
141 do_mpr(index, retp)
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
142 u_short *retp;
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
143 {
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
144 u_char cmdpkt[5];
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
145
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
146 cmdpkt[1] = MISC_PARAM_READ;
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
147 cmdpkt[2] = index;
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
148 cmdpkt[3] = index >> 8;
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
149 etm_pkt_exch(cmdpkt, 3);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
150 if (rvi_msg[3]) {
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
151 fprintf(stderr, "target error %u in response to mpr\n",
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
152 rvi_msg[3]);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
153 return(ERROR_TARGET);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
154 }
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
155 if (rvi_msg_len < 8) {
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
156 fprintf(stderr, "target error: mpr response too short\n");
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
157 return(ERROR_TARGET);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
158 }
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
159 if (rvi_msg[4] != index) {
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
160 fprintf(stderr, "target error: mpr response wrong index\n");
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
161 return(ERROR_TARGET);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
162 }
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
163 *retp = rvi_msg[5] | (rvi_msg[6] << 8);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
164 return(0);
4694c7686ccd fc-tmsync: add mpr command
Mychaela Falconia <falcon@freecalypso.org>
parents: 277
diff changeset
165 }