comparison rvinterf/tmsh/abb.c @ 260:c146f38d2b5f

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