comparison rvinterf/etmsync/l1tmops.c @ 277:4469d73bbc60

etmsync l1tmops module: need to return on errors, not exit
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Nov 2017 00:37:52 +0000
parents 3e272b956ef4
children 4694c7686ccd
comparison
equal deleted inserted replaced
276:d332fbf5c145 277:4469d73bbc60
25 cmdpkt[3] = arg >> 8; 25 cmdpkt[3] = arg >> 8;
26 etm_pkt_exch(cmdpkt, 3); 26 etm_pkt_exch(cmdpkt, 3);
27 if (rvi_msg[3]) { 27 if (rvi_msg[3]) {
28 fprintf(stderr, "target error %u in response to tms\n", 28 fprintf(stderr, "target error %u in response to tms\n",
29 rvi_msg[3]); 29 rvi_msg[3]);
30 exit(ERROR_TARGET); 30 return(ERROR_TARGET);
31 } 31 }
32 if (rvi_msg_len != 5) { 32 if (rvi_msg_len != 5) {
33 fprintf(stderr, "target error: tms response wrong length\n"); 33 fprintf(stderr, "target error: tms response wrong length\n");
34 exit(ERROR_TARGET); 34 return(ERROR_TARGET);
35 } 35 }
36 return(0); 36 return(0);
37 } 37 }
38 38
39 do_rfpr(index, retp) 39 do_rfpr(index, retp)
46 cmdpkt[3] = index >> 8; 46 cmdpkt[3] = index >> 8;
47 etm_pkt_exch(cmdpkt, 3); 47 etm_pkt_exch(cmdpkt, 3);
48 if (rvi_msg[3]) { 48 if (rvi_msg[3]) {
49 fprintf(stderr, "target error %u in response to rfpr\n", 49 fprintf(stderr, "target error %u in response to rfpr\n",
50 rvi_msg[3]); 50 rvi_msg[3]);
51 exit(ERROR_TARGET); 51 return(ERROR_TARGET);
52 } 52 }
53 if (rvi_msg_len != 8) { 53 if (rvi_msg_len != 8) {
54 fprintf(stderr, "target error: rfpr response wrong length\n"); 54 fprintf(stderr, "target error: rfpr response wrong length\n");
55 exit(ERROR_TARGET); 55 return(ERROR_TARGET);
56 } 56 }
57 if (rvi_msg[4] != index) { 57 if (rvi_msg[4] != index) {
58 fprintf(stderr, "target error: rfpr response wrong index\n"); 58 fprintf(stderr, "target error: rfpr response wrong index\n");
59 exit(ERROR_TARGET); 59 return(ERROR_TARGET);
60 } 60 }
61 *retp = rvi_msg[5] | (rvi_msg[6] << 8); 61 *retp = rvi_msg[5] | (rvi_msg[6] << 8);
62 return(0); 62 return(0);
63 } 63 }
64 64
73 cmdpkt[5] = value >> 8; 73 cmdpkt[5] = value >> 8;
74 etm_pkt_exch(cmdpkt, 5); 74 etm_pkt_exch(cmdpkt, 5);
75 if (rvi_msg[3]) { 75 if (rvi_msg[3]) {
76 fprintf(stderr, "target error %u in response to rfpw\n", 76 fprintf(stderr, "target error %u in response to rfpw\n",
77 rvi_msg[3]); 77 rvi_msg[3]);
78 exit(ERROR_TARGET); 78 return(ERROR_TARGET);
79 } 79 }
80 if (rvi_msg_len != 6) { 80 if (rvi_msg_len != 6) {
81 fprintf(stderr, "target error: rfpw response wrong length\n"); 81 fprintf(stderr, "target error: rfpw response wrong length\n");
82 exit(ERROR_TARGET); 82 return(ERROR_TARGET);
83 } 83 }
84 if (rvi_msg[4] != index) { 84 if (rvi_msg[4] != index) {
85 fprintf(stderr, "target error: rfpw response wrong index\n"); 85 fprintf(stderr, "target error: rfpw response wrong index\n");
86 exit(ERROR_TARGET); 86 return(ERROR_TARGET);
87 } 87 }
88 return(0); 88 return(0);
89 } 89 }
90 90
91 do_rftr(index, table, size) 91 do_rftr(index, table, size)
97 cmdpkt[2] = index; 97 cmdpkt[2] = index;
98 etm_pkt_exch(cmdpkt, 2); 98 etm_pkt_exch(cmdpkt, 2);
99 if (rvi_msg[3]) { 99 if (rvi_msg[3]) {
100 fprintf(stderr, "target error %u in response to rftr\n", 100 fprintf(stderr, "target error %u in response to rftr\n",
101 rvi_msg[3]); 101 rvi_msg[3]);
102 exit(ERROR_TARGET); 102 return(ERROR_TARGET);
103 } 103 }
104 if (rvi_msg_len < size + 6) { 104 if (rvi_msg_len < size + 6) {
105 fprintf(stderr, "target error: rftr response too short\n"); 105 fprintf(stderr, "target error: rftr response too short\n");
106 exit(ERROR_TARGET); 106 return(ERROR_TARGET);
107 } 107 }
108 if (rvi_msg[4] != index) { 108 if (rvi_msg[4] != index) {
109 fprintf(stderr, "target error: rftr response wrong index\n"); 109 fprintf(stderr, "target error: rftr response wrong index\n");
110 exit(ERROR_TARGET); 110 return(ERROR_TARGET);
111 } 111 }
112 bcopy(rvi_msg + 5, table, size); 112 bcopy(rvi_msg + 5, table, size);
113 return(0); 113 return(0);
114 } 114 }
115 115
122 cmdpkt[2] = index; 122 cmdpkt[2] = index;
123 etm_pkt_exch(cmdpkt, 2); 123 etm_pkt_exch(cmdpkt, 2);
124 if (rvi_msg[3]) { 124 if (rvi_msg[3]) {
125 fprintf(stderr, "target error %u in response to ttr\n", 125 fprintf(stderr, "target error %u in response to ttr\n",
126 rvi_msg[3]); 126 rvi_msg[3]);
127 exit(ERROR_TARGET); 127 return(ERROR_TARGET);
128 } 128 }
129 if (rvi_msg_len != 38) { 129 if (rvi_msg_len != 38) {
130 fprintf(stderr, "target error: ttr response wrong length\n"); 130 fprintf(stderr, "target error: ttr response wrong length\n");
131 exit(ERROR_TARGET); 131 return(ERROR_TARGET);
132 } 132 }
133 if (rvi_msg[4] != index) { 133 if (rvi_msg[4] != index) {
134 fprintf(stderr, "target error: ttr response wrong index\n"); 134 fprintf(stderr, "target error: ttr response wrong index\n");
135 exit(ERROR_TARGET); 135 return(ERROR_TARGET);
136 } 136 }
137 bcopy(rvi_msg + 5, buf, 32); 137 bcopy(rvi_msg + 5, buf, 32);
138 return(0); 138 return(0);
139 } 139 }