annotate rvinterf/tmsh/abb.c @ 704:3b6cc1a90ef8

dl_dcch3.c compiles
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 03 Oct 2014 03:38:51 +0000
parents c146f38d2b5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
198
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * In this module we are going to implement commands dealing with the ABB.
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
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: 256
diff changeset
10 #include "pktmux.h"
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
11 #include "limits.h"
198
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "localtypes.h"
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "etm.h"
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern u_char rvi_msg[];
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern int rvi_msg_len;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 void
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 cmd_abbr(argc, argv)
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 char **argv;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 u32 page, reg;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 u_char cmdpkt[5];
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 page = strtoul(argv[1], 0, 0);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 reg = strtoul(argv[2], 0, 0);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 if (page > 1 || reg > 31) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 printf("error: argument(s) out of range\n");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 cmdpkt[1] = ETM_CORE;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 cmdpkt[2] = TMCORE_OPC_CODEC_RD;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 cmdpkt[3] = page << 5 | reg;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 send_etm_cmd(cmdpkt, 3);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 void
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 abbr_response()
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 unsigned pg, reg, val;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 char buf[80];
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 if (rvi_msg[3]) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 print_etm_pkt_raw("abbr error");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 if (rvi_msg_len != 9) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 print_etm_pkt_raw("abbr malformed resp");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 pg = rvi_msg[5] >> 5;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 reg = rvi_msg[5] & 0x1F;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 val = rvi_msg[6] | rvi_msg[7] << 8;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 sprintf(buf, "abbr %u %u: %03X", pg, reg, val);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 async_msg_output(buf);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 void
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 cmd_abbw(argc, argv)
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 char **argv;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 u32 page, reg, val;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 u_char cmdpkt[7];
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 page = strtoul(argv[1], 0, 0);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 reg = strtoul(argv[2], 0, 0);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 val = strtoul(argv[3], 0, 16);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 if (page > 1 || reg > 31 || val > 0x3FF) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 printf("error: argument(s) out of range\n");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 cmdpkt[1] = ETM_CORE;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 cmdpkt[2] = TMCORE_OPC_CODEC_WR;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 cmdpkt[3] = page << 5 | reg;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 cmdpkt[4] = val;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 cmdpkt[5] = val >> 8;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 send_etm_cmd(cmdpkt, 5);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 void
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 abbw_response()
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 unsigned pg, reg;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 char buf[80];
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 if (rvi_msg[3]) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 print_etm_pkt_raw("abbw error");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 if (rvi_msg_len != 7) {
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 print_etm_pkt_raw("abbw malformed resp");
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 return;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 }
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 pg = rvi_msg[5] >> 5;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 reg = rvi_msg[5] & 0x1F;
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 sprintf(buf, "abbw %u %u OK", pg, reg);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 async_msg_output(buf);
c9ea2f7441a5 fc-tmsh: abb[rw] commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 }