FreeCalypso > hg > freecalypso-reveng
view pircharge/pktsort.c @ 333:f8a4a330d0e6
frbl/reconst/serial.c: 0x200 static function reconstructed
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 07 Mar 2020 02:10:27 +0000 |
parents | 84a4f6ef2d28 |
children |
line wrap: on
line source
/* * Here we sort out incoming packets from the target relayed via rvinterf. */ #include <sys/types.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include <rvinterf/pktmux.h> #include <rvinterf/limits.h> #include <rvinterf/localsock.h> #include <rvinterf/localtypes.h> #include <rvinterf/etm.h> #include <rvinterf/exitcodes.h> extern u_char rvi_msg[]; extern int rvi_msg_len; void print_rv_trace() { char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */ int i, c; char *dp; dp = fmtbuf; strcpy(dp, "RV "); dp += 3; /* the SWE static ID is sent MSB first */ for (i = 1; i <= 4; i++) { sprintf(dp, "%02X", rvi_msg[i+1]); dp += 2; } /* severity level */ sprintf(dp, " %d ", rvi_msg[6]); dp = index(dp, '\0'); for (i = 7; i < rvi_msg_len; i++) { c = rvi_msg[i]; if (c & 0x80) { *dp++ = 'M'; *dp++ = '-'; c &= 0x7F; } if (c < 0x20) { *dp++ = '^'; *dp++ = c + '@'; } else if (c == 0x7F) { *dp++ = '^'; *dp++ = '?'; } else *dp++ = c; } *dp = '\0'; printf("%s\n", fmtbuf); } void rvt_packet_rx() { u32 useid; if (rvi_msg_len < 7) { fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n"); exit(ERROR_RVINTERF); } print_rv_trace(); useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8 | rvi_msg[5]; if (useid != 0x000A0010) return; if (rvi_msg_len != 22) return; if (strncmp(rvi_msg + 7, "IQ EXT: ADC End", 15)) return; adc_end_process(); } void process_pkt_from_target() { switch (rvi_msg[1]) { case RVT_RV_HEADER: rvt_packet_rx(); return; case RVT_TM_HEADER: etm_packet_rx(); return; default: fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n", rvi_msg[1]); exit(ERROR_RVINTERF); } }