annotate pircharge/pktsort.c @ 374:f59d2577df2d

pirelli/volume-ctrl: captured VBDCTRL for all levels in all modes
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 31 Jul 2021 07:00:26 +0000
parents 84a4f6ef2d28
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
228
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we sort out incoming packets from the target relayed via rvinterf.
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/pktmux.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/limits.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <rvinterf/localsock.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <rvinterf/localtypes.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <rvinterf/etm.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <rvinterf/exitcodes.h>
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern u_char rvi_msg[];
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 extern int rvi_msg_len;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 void
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 print_rv_trace()
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int i, c;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 char *dp;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 dp = fmtbuf;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 strcpy(dp, "RV ");
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 dp += 3;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /* the SWE static ID is sent MSB first */
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (i = 1; i <= 4; i++) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 sprintf(dp, "%02X", rvi_msg[i+1]);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 dp += 2;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* severity level */
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 sprintf(dp, " %d ", rvi_msg[6]);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 dp = index(dp, '\0');
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (i = 7; i < rvi_msg_len; i++) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 c = rvi_msg[i];
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (c & 0x80) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *dp++ = 'M';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 *dp++ = '-';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 c &= 0x7F;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (c < 0x20) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *dp++ = '^';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *dp++ = c + '@';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 } else if (c == 0x7F) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *dp++ = '^';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *dp++ = '?';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 } else
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *dp++ = c;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 *dp = '\0';
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 printf("%s\n", fmtbuf);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 void
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 rvt_packet_rx()
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 u32 useid;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (rvi_msg_len < 7) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n");
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 exit(ERROR_RVINTERF);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 print_rv_trace();
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 | rvi_msg[5];
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (useid != 0x000A0010)
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 return;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 if (rvi_msg_len != 22)
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 return;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (strncmp(rvi_msg + 7, "IQ EXT: ADC End", 15))
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return;
229
84a4f6ef2d28 pirchgdbg: complete enough for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 228
diff changeset
76 adc_end_process();
228
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 void
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 process_pkt_from_target()
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 switch (rvi_msg[1]) {
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 case RVT_RV_HEADER:
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 rvt_packet_rx();
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 return;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 case RVT_TM_HEADER:
229
84a4f6ef2d28 pirchgdbg: complete enough for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 228
diff changeset
87 etm_packet_rx();
228
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 return;
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 default:
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 rvi_msg[1]);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 exit(ERROR_RVINTERF);
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
fec90990f613 pirchgdbg started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }