changeset 173:f42854da4563

rvinterf: beginning of refactoring
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 22 Nov 2013 05:56:07 +0000
parents 019120585a1c
children 3256dc6e84ae
files rvinterf/Makefile rvinterf/README rvinterf/etmsend.c rvinterf/log.c rvinterf/lowlevel/openport.c rvinterf/lowlevel/packetrx.c rvinterf/lowlevel/packettx.c rvinterf/old/Makefile rvinterf/old/etmsend.c rvinterf/old/log.c rvinterf/old/openport.c rvinterf/old/packetrx.c rvinterf/old/packettx.c rvinterf/old/pktmux.h rvinterf/old/rvtdump.c rvinterf/old/rvtdump_tx.c rvinterf/old/trdump.c rvinterf/old/txpkt.h rvinterf/openport.c rvinterf/packetrx.c rvinterf/packettx.c rvinterf/rvtdump.c rvinterf/rvtdump_tx.c rvinterf/trdump.c rvinterf/txpkt.h
diffstat 25 files changed, 1038 insertions(+), 731 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/Makefile	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2
-PROGS=	rvtdump
-XPROGS=	etmsend
-INSTBIN=/usr/local/bin
-
-RVTDUMP_OBJS=	log.o openport.o packetrx.o packettx.o rvtdump.o rvtdump_tx.o \
-		trdump.o
-
-all:	${PROGS} ${XPROGS}
-
-rvtdump:	${RVTDUMP_OBJS}
-	${CC} ${CFLAGS} -o $@ ${RVTDUMP_OBJS}
-
-etmsend:	etmsend.c
-	${CC} ${CFLAGS} -o $@ $@.c
-
-install:	${PROGS}
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
-
-clean:
-	rm -f *.o *.out *errs ${PROGS} ${XPROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/README	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,89 @@
+I (Spacefalcon the Outlaw, FreeCalypso developer) am still learning what kinds
+of traffic may be passed across TI's RVTMUX binary-packet serial interface.  We
+already know that much of this traffic is debug trace output, i.e.,
+unidirectional and essentially unconditional output from the GSM device.  All
+of the "standard" firmwares we have (mokoN, our leo2moko which functions almost
+identically, and Pirelli's fw) produce massive volumes of such trace output in
+normal operation.  We already know that this "unsolicited" trace output comes
+in at least 3 different flavors:
+
+* RiViera traces emitted by rvf_send_trace()
+* L1 traces
+* G23 traces
+
+The RVTMUX interface can be used for more than just trace output, though: any
+component in TI's fw suite can send and/or register to receive binary packets.
+As I slowly work my way through various components which comprise TI's Leonardo
+fw whose semi-source we use as our reference version, learning what they do and
+reintegrating them in our own gsm-fw, I will undoubtedly uncover additional uses
+to which the RVTMUX interface is put.
+
+Aside from the trivial provision in the RVT module itself whereby an external
+host can send a command to the target to set a filter masking some of the RV
+trace output, so far the only entity I've come across which accepts packets from
+an external host is ETM (Enhanced Test Mode).  ETM implements a registration
+system of its own, whereby other modules can register with ETM to receive
+certain external command messages passing first through RVT, then through ETM.
+
+Because I do not yet have a clear mental picture of *every* function for which
+the RVTMUX interface will ever be used, it is correspondingly impractical to
+decide on a once-and-for-all design of what the host-side software for talking
+to this interface should be like.  Therefore, it is currently premature to
+expect any stability in the present rvinterf subdirectory of freecalypso-sw; I
+may implement something one day, then toss it away the next day (without
+providing much in the way of backward compatibility) when I come up with some
+other idea.
+
+The current roadmap for what the rvinterf suite of host tools is envisioned to
+look like eventually is as follows:
+
+rvtdump		Opens the serial port, decodes TI's binary packet protocol, and
+		simply dumps every received/decoded packet on stdout in a human-
+		readable form.  No provision for sending anything to the target.
+		Intended use: observing the debug trace output which all TI
+		firmwares emit as standard "background noise".  This utility has
+		already been written, and it allows one to observe/log/study the
+		"noise" that appears on Pirelli's USB-serial port (running
+		Pirelli's original fw), as well as that emitted on the IrDA
+		(headset jack) port on the GTA02 by mokoN/leo2moko firmwares.
+
+rvinterf	My plan is to make a copy of rvtdump, called rvinterf, and have
+		it act very much like rvtdump: receive TI's packets from the
+		serial port, decode them and print the decoded form on stdout.
+		However, rvinterf will also create a listening UNIX domain
+		socket to which other programs in the present suite will
+		connect.  These other programs connecting through rvinterf will
+		be able to send packets to the target, as well as register to
+		receive certain kinds of target->host message packets.
+
+fc-tmsh		FreeCalypso Test Mode Shell is my vision for the utility which
+		will provide a practically usable interface to ETM.  ETM's
+		general mode of operation seems to be (weasel phrase inserted
+		because many other fw components may connect through ETM, and I
+		have yet to study all of them) command-response: an external
+		host sends a command to ETM, that command gets dispatched to the
+		proper registered handler, the command function is executed, a
+		response packet is composed, and finally that response is sent
+		back to the host.  But because all code on the target side is
+		under active development and debugging, we should not expect
+		perfect lock-step behaviour on the interface; instead, our
+		fc-tmsh should be fundamentally asynchronous: when the user
+		enters a command, the appropriate command packet is sent to the
+		target, but we are prepared for target->host messages at any
+		time, without enforcing strict correspondence to issued
+		commands: let the developer-operator sort that out instead.
+
+The usage scenario I envision is that one will need to run rvinterf first
+(either directly or through fc-xram) in one terminal window, leave it running,
+then run fc-tmsh in another terminal window, and have it connect to rvinterf
+via the local UNIX domain socket interface.  Why such complexity, why not have
+one program do everything?  I suspect that in many debug/experimentation
+sessions it will be necessary to use fc-tmsh on "noisy" targets, i.e., in
+scenarios where the target is continuously spewing its "normal" voluminous debug
+trace output, such that the "interesting" output as in responses to commands
+gets drowned in the noise.  In such a scenario it would be helpful to have one
+terminal window in which one sees the transcript of the fc-tmsh session,
+consisting of issued commands and received ETM responses without the general
+noise, and another window in which one sees all RVTMUX interface activity in
+real time - the latter would allow one to observe commands having side effects
+outside of ETM, such as crashing the whole fw. :-)
--- a/rvinterf/etmsend.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * This program is a hack that sends a hand-crafted ETM packet
- * to the UNIX-local dgram socket established by rvtdump with -s option.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-#include "txpkt.h"
-
-char sockpath[] = "/tmp/rvt_send_socket";
-
-u_char packet[MAX_PKT_TO_TARGET];
-int payload_len;
-
-main(argc, argv)
-	char **argv;
-{
-	int i, c, s;
-	struct sockaddr_un local;
-	unsigned int namelen;
-
-	if (argc < 2) {
-		fprintf(stderr, "usage: %s hexbytes...\n", argv[0]);
-		exit(1);
-	}
-	payload_len = argc - 1;
-	if (payload_len > MAX_PKT_TO_TARGET-2) {
-		fprintf(stderr,
-			"%s: too many bytes (packet length limit exceeded)\n",
-			argv[0]);
-		exit(1);
-	}
-
-	packet[0] = RVT_TM_HEADER;
-	for (i = 1; i <= payload_len; i++)
-		packet[i] = strtoul(argv[i], 0, 16);
-	c = 0;
-	for (i = 1; i <= payload_len; i++)
-		c ^= packet[i];
-	packet[payload_len+1] = c;
-
-	s = socket(AF_UNIX, SOCK_DGRAM, 0);
-	if (s < 0) {
-		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
-		exit(1);
-	}
-
-	local.sun_family = AF_UNIX;
-	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
-	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
-
-	/* we use the same magic that X11 uses in Xtranssock.c for
-	 * calculating the proper length of the sockaddr */
-#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
-	local.sun_len = strlen(local.sun_path);
-#endif
-#if defined(BSD44SOCKETS) || defined(SUN_LEN)
-	namelen = SUN_LEN(&local);
-#else
-	namelen = strlen(local.sun_path) +
-		  offsetof(struct sockaddr_un, sun_path);
-#endif
-
-	i = sendto(s, packet, payload_len+2, 0,
-			(struct sockaddr *) &local, namelen);
-	if (i < 0) {
-		perror("sendto");
-		exit(1);
-	}
-
-	exit(0);
-}
--- a/rvinterf/log.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * This module implements the logging function
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-
-extern char pr_item[];
-
-extern FILE *logF;
-extern time_t logtime;
-
-static struct tm last_tm;
-
-log_item()
-{
-	struct tm *curtm;
-
-	curtm = gmtime(&logtime);
-	if (curtm->tm_year != last_tm.tm_year ||
-	    curtm->tm_mon != last_tm.tm_mon ||
-	    curtm->tm_mday != last_tm.tm_mday)
-		fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
-			curtm->tm_mon+1, curtm->tm_mday);
-	fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
-		curtm->tm_sec, pr_item);
-	bcopy(curtm, &last_tm, sizeof(struct tm));
-}
-
-log_sent_packet(pkt, pktlen)
-	u_char *pkt;
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "Sent");
-	dp += 4;
-	for (i = 0; i < pktlen; i++) {
-		sprintf(dp, " %02X", pkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/lowlevel/openport.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,82 @@
+/*
+ * This module takes care of opening the serial port and setting the
+ * proper "raw" termios modes, including the baud rate.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+int target_fd;
+char *baudrate_name = "115200";
+
+static struct baudrate {
+	char	*name;
+	speed_t	termios_code;
+} baud_rate_table[] = {
+	{"19200",	B19200},
+	{"38400",	B38400},
+	{"57600",	B57600},
+	{"115200",	B115200},
+	/* non-standard high baud rates "remapped" by CP2102 usb2serial IC */
+	{"203125",	B230400},
+	{"406250",	B460800},
+	{"812500",	B921600},
+	/* table search terminator */
+	{NULL,		B0}
+};
+
+static speed_t
+get_baud_rate()
+{
+	struct baudrate *br;
+
+	for (br = baud_rate_table; br->name; br++)
+		if (!strcmp(br->name, baudrate_name))
+			break;
+	if (!br->name) {
+		fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n",
+			baudrate_name);
+		exit(1);
+	}
+	return br->termios_code;
+}
+
+open_target_serial(ttydev)
+	char *ttydev;
+{
+	struct termios target_termios;
+	speed_t br_code;
+
+	br_code = get_baud_rate();
+	target_fd = open(ttydev, O_RDWR|O_NONBLOCK);
+	if (target_fd < 0) {
+		perror(ttydev);
+		exit(1);
+	}
+	target_termios.c_iflag = IGNBRK;
+	target_termios.c_oflag = 0;
+	target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
+	target_termios.c_lflag = 0;
+	target_termios.c_cc[VMIN] = 1;
+	target_termios.c_cc[VTIME] = 0;
+	cfsetispeed(&target_termios, br_code);
+	cfsetospeed(&target_termios, br_code);
+	if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
+		perror("initial tcsetattr on target");
+		exit(1);
+	}
+	return 0;
+}
+
+set_serial_nonblock(state)
+	int state;
+{
+	ioctl(target_fd, FIONBIO, &state);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/lowlevel/packetrx.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,88 @@
+/*
+ * This module handles the lowest level of serial packet Rx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+
+extern int target_fd;
+
+#define	MAXPKT	512
+u_char rxpkt[MAXPKT];
+size_t rxpkt_len;
+
+extern char pr_item[];
+
+static int in_pkt, dle_state, toobig;
+
+static void
+process_inbyte(inb)
+{
+	if (!in_pkt) {
+		if (inb != STX || dle_state) {
+			rxpkt_len++;
+			dle_state = (inb == DLE);
+			return;
+		}
+		if (rxpkt_len) {
+			sprintf(pr_item,
+				"Warning: Rx %u byte%s outside of a packet",
+				(unsigned)rxpkt_len, rxpkt_len != 1 ? "s" : "");
+			print_item();
+			rxpkt_len = 0;
+		}
+		in_pkt = 1;
+		toobig = 0;
+		return;
+	}
+	if (dle_state) {
+		dle_state = 0;
+		if (inb != STX && inb != DLE) {
+			sprintf(pr_item,
+				"Rx framing error: %02X after DLE\n", inb);
+			print_item();
+			in_pkt = 0;
+			rxpkt_len = 0;
+			return;
+		}
+		goto data;
+	}
+	if (inb == DLE) {
+		dle_state = 1;
+		return;
+	} else if (inb == STX) {
+		if (!rxpkt_len)
+			return;
+		in_pkt = 0;
+		handle_rx_packet();
+		rxpkt_len = 0;
+		return;
+	}
+data:	if (rxpkt_len >= MAXPKT) {
+		if (!toobig) {
+			sprintf(pr_item, "Error: Rx packet too big!\n");
+			print_item();
+			toobig = 1;
+		}
+		return;
+	}
+	rxpkt[rxpkt_len++] = inb;
+}
+
+void
+process_serial_rx()
+{
+	u_char rdbuf[512];
+	int cc, i;
+
+	cc = read(target_fd, rdbuf, sizeof rdbuf);
+	if (cc <= 0) {
+		perror("Error/EOF reading from target");
+		exit(1);
+	}
+	for (i = 0; i < cc; i++)
+		process_inbyte(rdbuf[i]);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/lowlevel/packettx.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,32 @@
+/*
+ * This module handles the lowest level of serial packet Tx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+#include "txpkt.h"
+
+extern int target_fd;
+
+send_pkt_to_target(pkt, pktlen)
+	u_char *pkt;
+{
+	u_char buf[MAX_PKT_TO_TARGET*2+2];
+	u_char *cp, *dp, *endp;
+	int c;
+
+	endp = pkt + pktlen;
+	dp = buf;
+	*dp++ = STX;
+	for (cp = pkt; cp < endp; cp++) {
+		c = *cp;
+		if (c == STX || c == DLE)
+			*dp++ = DLE;
+		*dp++ = c;
+	}
+	*dp++ = STX;
+	write(target_fd, buf, dp - buf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/Makefile	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,23 @@
+CC=	gcc
+CFLAGS=	-O2
+PROGS=	rvtdump
+XPROGS=	etmsend
+INSTBIN=/usr/local/bin
+
+RVTDUMP_OBJS=	log.o openport.o packetrx.o packettx.o rvtdump.o rvtdump_tx.o \
+		trdump.o
+
+all:	${PROGS} ${XPROGS}
+
+rvtdump:	${RVTDUMP_OBJS}
+	${CC} ${CFLAGS} -o $@ ${RVTDUMP_OBJS}
+
+etmsend:	etmsend.c
+	${CC} ${CFLAGS} -o $@ $@.c
+
+install:	${PROGS}
+	mkdir -p ${INSTBIN}
+	install -c ${PROGS} ${INSTBIN}
+
+clean:
+	rm -f *.o *.out *errs ${PROGS} ${XPROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/etmsend.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,79 @@
+/*
+ * This program is a hack that sends a hand-crafted ETM packet
+ * to the UNIX-local dgram socket established by rvtdump with -s option.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+#include "txpkt.h"
+
+char sockpath[] = "/tmp/rvt_send_socket";
+
+u_char packet[MAX_PKT_TO_TARGET];
+int payload_len;
+
+main(argc, argv)
+	char **argv;
+{
+	int i, c, s;
+	struct sockaddr_un local;
+	unsigned int namelen;
+
+	if (argc < 2) {
+		fprintf(stderr, "usage: %s hexbytes...\n", argv[0]);
+		exit(1);
+	}
+	payload_len = argc - 1;
+	if (payload_len > MAX_PKT_TO_TARGET-2) {
+		fprintf(stderr,
+			"%s: too many bytes (packet length limit exceeded)\n",
+			argv[0]);
+		exit(1);
+	}
+
+	packet[0] = RVT_TM_HEADER;
+	for (i = 1; i <= payload_len; i++)
+		packet[i] = strtoul(argv[i], 0, 16);
+	c = 0;
+	for (i = 1; i <= payload_len; i++)
+		c ^= packet[i];
+	packet[payload_len+1] = c;
+
+	s = socket(AF_UNIX, SOCK_DGRAM, 0);
+	if (s < 0) {
+		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
+		exit(1);
+	}
+
+	local.sun_family = AF_UNIX;
+	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
+	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+
+	/* we use the same magic that X11 uses in Xtranssock.c for
+	 * calculating the proper length of the sockaddr */
+#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
+	local.sun_len = strlen(local.sun_path);
+#endif
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+	namelen = SUN_LEN(&local);
+#else
+	namelen = strlen(local.sun_path) +
+		  offsetof(struct sockaddr_un, sun_path);
+#endif
+
+	i = sendto(s, packet, payload_len+2, 0,
+			(struct sockaddr *) &local, namelen);
+	if (i < 0) {
+		perror("sendto");
+		exit(1);
+	}
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/log.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,50 @@
+/*
+ * This module implements the logging function
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+extern char pr_item[];
+
+extern FILE *logF;
+extern time_t logtime;
+
+static struct tm last_tm;
+
+log_item()
+{
+	struct tm *curtm;
+
+	curtm = gmtime(&logtime);
+	if (curtm->tm_year != last_tm.tm_year ||
+	    curtm->tm_mon != last_tm.tm_mon ||
+	    curtm->tm_mday != last_tm.tm_mday)
+		fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
+			curtm->tm_mon+1, curtm->tm_mday);
+	fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
+		curtm->tm_sec, pr_item);
+	bcopy(curtm, &last_tm, sizeof(struct tm));
+}
+
+log_sent_packet(pkt, pktlen)
+	u_char *pkt;
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "Sent");
+	dp += 4;
+	for (i = 0; i < pktlen; i++) {
+		sprintf(dp, " %02X", pkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/openport.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,82 @@
+/*
+ * This module takes care of opening the serial port and setting the
+ * proper "raw" termios modes, including the baud rate.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+int target_fd;
+char *baudrate_name = "115200";
+
+static struct baudrate {
+	char	*name;
+	speed_t	termios_code;
+} baud_rate_table[] = {
+	{"19200",	B19200},
+	{"38400",	B38400},
+	{"57600",	B57600},
+	{"115200",	B115200},
+	/* non-standard high baud rates "remapped" by CP2102 usb2serial IC */
+	{"203125",	B230400},
+	{"406250",	B460800},
+	{"812500",	B921600},
+	/* table search terminator */
+	{NULL,		B0}
+};
+
+static speed_t
+get_baud_rate()
+{
+	struct baudrate *br;
+
+	for (br = baud_rate_table; br->name; br++)
+		if (!strcmp(br->name, baudrate_name))
+			break;
+	if (!br->name) {
+		fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n",
+			baudrate_name);
+		exit(1);
+	}
+	return br->termios_code;
+}
+
+open_target_serial(ttydev)
+	char *ttydev;
+{
+	struct termios target_termios;
+	speed_t br_code;
+
+	br_code = get_baud_rate();
+	target_fd = open(ttydev, O_RDWR|O_NONBLOCK);
+	if (target_fd < 0) {
+		perror(ttydev);
+		exit(1);
+	}
+	target_termios.c_iflag = IGNBRK;
+	target_termios.c_oflag = 0;
+	target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
+	target_termios.c_lflag = 0;
+	target_termios.c_cc[VMIN] = 1;
+	target_termios.c_cc[VTIME] = 0;
+	cfsetispeed(&target_termios, br_code);
+	cfsetospeed(&target_termios, br_code);
+	if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
+		perror("initial tcsetattr on target");
+		exit(1);
+	}
+	return 0;
+}
+
+set_serial_nonblock(state)
+	int state;
+{
+	ioctl(target_fd, FIONBIO, &state);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/packetrx.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,88 @@
+/*
+ * This module handles the lowest level of serial packet Rx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+
+extern int target_fd;
+
+#define	MAXPKT	512
+u_char rxpkt[MAXPKT];
+size_t rxpkt_len;
+
+extern char pr_item[];
+
+static int in_pkt, dle_state, toobig;
+
+static void
+process_inbyte(inb)
+{
+	if (!in_pkt) {
+		if (inb != STX || dle_state) {
+			rxpkt_len++;
+			dle_state = (inb == DLE);
+			return;
+		}
+		if (rxpkt_len) {
+			sprintf(pr_item,
+				"Warning: Rx %u byte%s outside of a packet",
+				(unsigned)rxpkt_len, rxpkt_len != 1 ? "s" : "");
+			print_item();
+			rxpkt_len = 0;
+		}
+		in_pkt = 1;
+		toobig = 0;
+		return;
+	}
+	if (dle_state) {
+		dle_state = 0;
+		if (inb != STX && inb != DLE) {
+			sprintf(pr_item,
+				"Rx framing error: %02X after DLE\n", inb);
+			print_item();
+			in_pkt = 0;
+			rxpkt_len = 0;
+			return;
+		}
+		goto data;
+	}
+	if (inb == DLE) {
+		dle_state = 1;
+		return;
+	} else if (inb == STX) {
+		if (!rxpkt_len)
+			return;
+		in_pkt = 0;
+		handle_rx_packet();
+		rxpkt_len = 0;
+		return;
+	}
+data:	if (rxpkt_len >= MAXPKT) {
+		if (!toobig) {
+			sprintf(pr_item, "Error: Rx packet too big!\n");
+			print_item();
+			toobig = 1;
+		}
+		return;
+	}
+	rxpkt[rxpkt_len++] = inb;
+}
+
+void
+process_serial_rx()
+{
+	u_char rdbuf[512];
+	int cc, i;
+
+	cc = read(target_fd, rdbuf, sizeof rdbuf);
+	if (cc <= 0) {
+		perror("Error/EOF reading from target");
+		exit(1);
+	}
+	for (i = 0; i < cc; i++)
+		process_inbyte(rdbuf[i]);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/packettx.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,32 @@
+/*
+ * This module handles the lowest level of serial packet Tx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+#include "txpkt.h"
+
+extern int target_fd;
+
+send_pkt_to_target(pkt, pktlen)
+	u_char *pkt;
+{
+	u_char buf[MAX_PKT_TO_TARGET*2+2];
+	u_char *cp, *dp, *endp;
+	int c;
+
+	endp = pkt + pktlen;
+	dp = buf;
+	*dp++ = STX;
+	for (cp = pkt; cp < endp; cp++) {
+		c = *cp;
+		if (c == STX || c == DLE)
+			*dp++ = DLE;
+		*dp++ = c;
+	}
+	*dp++ = STX;
+	write(target_fd, buf, dp - buf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/pktmux.h	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,16 @@
+/*
+ * Definitions for the RVT MUX over-the-wire protocol
+ */
+
+#define	STX	0x02
+#define	DLE	0x10
+
+#define RVT_RV_HEADER        0x11
+#define RVT_L1_HEADER        0x12
+#define RVT_L23_HEADER       0x13
+#define RVT_TM_HEADER        0x14
+#define RVT_RNET_HEADER      0x15
+#define RVT_PROF_HEADER      0x16
+#define RVT_GTTBACK_HEADER   0x17
+#define RVT_OTHER_HEADER     0x18
+#define RVT_INVALID_HEADER   0xFF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/rvtdump.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,123 @@
+/*
+ * This program reads bytes from a serial port, parses them assuming
+ * TI's RVT MUX format, and prints every decoded packet.
+ */
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+extern int target_fd;
+extern char *baudrate_name;
+
+extern char pr_item[];
+extern int sendsock_fd;
+
+char *logfname;
+FILE *logF;
+time_t logtime;
+int background, sendsock_enable;
+
+main(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	extern int optind;
+	int c, maxfd;
+	fd_set fds;
+
+	while ((c = getopt(argc, argv, "bB:d:l:s")) != EOF)
+		switch (c) {
+		case 'b':
+			background++;
+			continue;
+		case 'B':
+			baudrate_name = optarg;
+			continue;
+		case 'd':
+			target_fd = atoi(optarg);
+			continue;
+		case 'l':
+			logfname = optarg;
+			continue;
+		case 's':
+			sendsock_enable++;
+			continue;
+		case '?':
+		default:
+usage:			fprintf(stderr,
+			"usage: %s [options] ttyport\n", argv[0]);
+			exit(1);
+		}
+	if (background && !logfname) {
+		fprintf(stderr, "%s: -b is meaningless without -l\n", argv[0]);
+		exit(1);
+	}
+	if (target_fd <= 0) {
+		if (argc - optind != 1)
+			goto usage;
+		open_target_serial(argv[optind]);
+	}
+
+	set_serial_nonblock(0);
+	setlinebuf(stdout);
+	if (logfname) {
+		logF = fopen(logfname, "w");
+		if (!logF) {
+			perror(logfname);
+			exit(1);
+		}
+		fprintf(logF, "*** Log of decoded RVT output ***\n");
+		setlinebuf(logF);
+	}
+	if (sendsock_enable)
+		create_send_socket();
+	if (background) {
+		c = fork();
+		if (c < 0) {
+			perror("fork");
+			exit(1);
+		}
+		if (c) {
+			printf("rvtdump forked into background (pid %d)\n", c);
+			exit(0);
+		}
+	}
+	maxfd = target_fd;
+	if (sendsock_fd > maxfd)
+		maxfd = sendsock_fd;
+	for (;;) {
+		FD_ZERO(&fds);
+		FD_SET(target_fd, &fds);
+		if (sendsock_enable)
+			FD_SET(sendsock_fd, &fds);
+		c = select(maxfd+1, &fds, 0, 0, 0);
+		time(&logtime);
+		if (c < 0) {
+			if (errno == EINTR)
+				continue;
+			perror("select");
+			exit(1);
+		}
+		if (FD_ISSET(target_fd, &fds))
+			process_serial_rx();
+		if (FD_ISSET(sendsock_fd, &fds))
+			handle_sendsock();
+	}
+}
+
+handle_rx_packet()
+{
+	print_rx_packet();
+}
+
+print_item()
+{
+	if (!background)
+		printf("%s\n", pr_item);
+	if (logF)
+		log_item();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/rvtdump_tx.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,70 @@
+/*
+ * This module contains the implementation of the Tx extension to rvtdump
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "txpkt.h"
+
+static char sockpath[] = "/tmp/rvt_send_socket";
+
+int sendsock_fd;
+u_char sendsock_pkt[MAX_PKT_TO_TARGET];
+int sendsock_pktlen;
+
+create_send_socket()
+{
+	/* local socket binding voodoo copied from osmocon */
+	struct sockaddr_un local;
+	unsigned int namelen;
+	int rc;
+
+	sendsock_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+	if (sendsock_fd < 0) {
+		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
+		exit(1);
+	}
+
+	local.sun_family = AF_UNIX;
+	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
+	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+	unlink(local.sun_path);
+
+	/* we use the same magic that X11 uses in Xtranssock.c for
+	 * calculating the proper length of the sockaddr */
+#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
+	local.sun_len = strlen(local.sun_path);
+#endif
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+	namelen = SUN_LEN(&local);
+#else
+	namelen = strlen(local.sun_path) +
+		  offsetof(struct sockaddr_un, sun_path);
+#endif
+
+	rc = bind(sendsock_fd, (struct sockaddr *) &local, namelen);
+	if (rc != 0) {
+		perror("bind on local dgram socket");
+		exit(1);
+	}
+
+	return(0);
+}
+
+handle_sendsock()
+{
+	sendsock_pktlen = recv(sendsock_fd, sendsock_pkt, MAX_PKT_TO_TARGET, 0);
+	if (sendsock_pktlen <= 0) {
+		fprintf(stderr, "return value from recv on socket: %d\n",
+			sendsock_pktlen);
+		exit(1);
+	}
+	send_pkt_to_target(sendsock_pkt, sendsock_pktlen);
+	log_sent_packet(sendsock_pkt, sendsock_pktlen);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/trdump.c	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,169 @@
+/*
+ * This module implements the basic dump of any incoming packets
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include "pktmux.h"
+
+extern u_char rxpkt[];
+extern size_t rxpkt_len;
+
+char pr_item[4096];
+
+void
+print_rv_trace()
+{
+	int i, c;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "RV ");
+	dp += 3;
+	/* the SWE static ID is sent MSB first */
+	for (i = 1; i <= 4; i++) {
+		sprintf(dp, "%02X", rxpkt[i]);
+		dp += 2;
+	}
+	/* severity level */
+	sprintf(dp, " %d ", rxpkt[5]);
+	dp = index(dp, '\0');
+	for (i = 6; i < rxpkt_len; i++) {
+		c = rxpkt[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';
+	print_item();
+}
+
+void
+print_l1_trace()
+{
+	int i, c;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "L1: ");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		if ((i+1 < rxpkt_len) &&
+		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
+		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
+			*dp = '\0';
+			print_item();
+			if (i+2 == rxpkt_len)
+				return;
+			dp = pr_item;
+			*dp++ = '+';
+			*dp++ = ' ';
+			i++;
+			continue;
+		}
+		c = rxpkt[i];
+		if (c & 0x80) {
+			*dp++ = 'M';
+			*dp++ = '-';
+			c &= 0x7F;
+		}
+		if (c < 0x20) {
+			*dp++ = '^';
+			*dp++ = c + '@';
+		} else if (c == 0x7F) {
+			*dp++ = '^';
+			*dp++ = '?';
+		} else
+			*dp++ = c;
+	}
+	/* will get here only if no newline sequence at the end */
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_g23_trace()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "G23:");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_etm_output_raw()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "ETM:");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_unknown_packet()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "UNK:");
+	dp += 4;
+	for (i = 0; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_rx_packet()
+{
+	switch (rxpkt[0]) {
+	case RVT_RV_HEADER:
+		if (rxpkt_len < 6)
+			goto unknown;
+		print_rv_trace();
+		return;
+	case RVT_L1_HEADER:
+		print_l1_trace();
+		return;
+	case RVT_L23_HEADER:
+		print_g23_trace();
+		return;
+	case RVT_TM_HEADER:
+		print_etm_output_raw();
+		return;
+	default:
+	unknown:
+		print_unknown_packet();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/txpkt.h	Fri Nov 22 05:56:07 2013 +0000
@@ -0,0 +1,15 @@
+/*
+ * For sizing our buffers etc in rvinterf, we need a limit on the size of
+ * message packets we can send to the target.  As it happens, the packet
+ * Rx code in RVT on the target side also has a limit (quite naturally,
+ * as it needs to use a static buffer to reassemble incoming packets as
+ * they arrive at the UART in unpredictable interrupt-sized chunks), so
+ * we set our limit to match that in RVT.
+ */
+
+#define	MAX_PKT_TO_TARGET	255
+
+/*
+ * The above limit definition counts all bytes between the opening and
+ * closing STX flags, but not DLEs inserted for binary transparency.
+ */
--- a/rvinterf/openport.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * This module takes care of opening the serial port and setting the
- * proper "raw" termios modes, including the baud rate.
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <termios.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-
-int target_fd;
-char *baudrate_name = "115200";
-
-static struct baudrate {
-	char	*name;
-	speed_t	termios_code;
-} baud_rate_table[] = {
-	{"19200",	B19200},
-	{"38400",	B38400},
-	{"57600",	B57600},
-	{"115200",	B115200},
-	/* non-standard high baud rates "remapped" by CP2102 usb2serial IC */
-	{"203125",	B230400},
-	{"406250",	B460800},
-	{"812500",	B921600},
-	/* table search terminator */
-	{NULL,		B0}
-};
-
-static speed_t
-get_baud_rate()
-{
-	struct baudrate *br;
-
-	for (br = baud_rate_table; br->name; br++)
-		if (!strcmp(br->name, baudrate_name))
-			break;
-	if (!br->name) {
-		fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n",
-			baudrate_name);
-		exit(1);
-	}
-	return br->termios_code;
-}
-
-open_target_serial(ttydev)
-	char *ttydev;
-{
-	struct termios target_termios;
-	speed_t br_code;
-
-	br_code = get_baud_rate();
-	target_fd = open(ttydev, O_RDWR|O_NONBLOCK);
-	if (target_fd < 0) {
-		perror(ttydev);
-		exit(1);
-	}
-	target_termios.c_iflag = IGNBRK;
-	target_termios.c_oflag = 0;
-	target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
-	target_termios.c_lflag = 0;
-	target_termios.c_cc[VMIN] = 1;
-	target_termios.c_cc[VTIME] = 0;
-	cfsetispeed(&target_termios, br_code);
-	cfsetospeed(&target_termios, br_code);
-	if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
-		perror("initial tcsetattr on target");
-		exit(1);
-	}
-	return 0;
-}
-
-set_serial_nonblock(state)
-	int state;
-{
-	ioctl(target_fd, FIONBIO, &state);
-}
--- a/rvinterf/packetrx.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * This module handles the lowest level of serial packet Rx
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-
-extern int target_fd;
-
-#define	MAXPKT	512
-u_char rxpkt[MAXPKT];
-size_t rxpkt_len;
-
-extern char pr_item[];
-
-static int in_pkt, dle_state, toobig;
-
-static void
-process_inbyte(inb)
-{
-	if (!in_pkt) {
-		if (inb != STX || dle_state) {
-			rxpkt_len++;
-			dle_state = (inb == DLE);
-			return;
-		}
-		if (rxpkt_len) {
-			sprintf(pr_item,
-				"Warning: Rx %u byte%s outside of a packet",
-				(unsigned)rxpkt_len, rxpkt_len != 1 ? "s" : "");
-			print_item();
-			rxpkt_len = 0;
-		}
-		in_pkt = 1;
-		toobig = 0;
-		return;
-	}
-	if (dle_state) {
-		dle_state = 0;
-		if (inb != STX && inb != DLE) {
-			sprintf(pr_item,
-				"Rx framing error: %02X after DLE\n", inb);
-			print_item();
-			in_pkt = 0;
-			rxpkt_len = 0;
-			return;
-		}
-		goto data;
-	}
-	if (inb == DLE) {
-		dle_state = 1;
-		return;
-	} else if (inb == STX) {
-		if (!rxpkt_len)
-			return;
-		in_pkt = 0;
-		handle_rx_packet();
-		rxpkt_len = 0;
-		return;
-	}
-data:	if (rxpkt_len >= MAXPKT) {
-		if (!toobig) {
-			sprintf(pr_item, "Error: Rx packet too big!\n");
-			print_item();
-			toobig = 1;
-		}
-		return;
-	}
-	rxpkt[rxpkt_len++] = inb;
-}
-
-void
-process_serial_rx()
-{
-	u_char rdbuf[512];
-	int cc, i;
-
-	cc = read(target_fd, rdbuf, sizeof rdbuf);
-	if (cc <= 0) {
-		perror("Error/EOF reading from target");
-		exit(1);
-	}
-	for (i = 0; i < cc; i++)
-		process_inbyte(rdbuf[i]);
-}
--- a/rvinterf/packettx.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * This module handles the lowest level of serial packet Tx
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-#include "txpkt.h"
-
-extern int target_fd;
-
-send_pkt_to_target(pkt, pktlen)
-	u_char *pkt;
-{
-	u_char buf[MAX_PKT_TO_TARGET*2+2];
-	u_char *cp, *dp, *endp;
-	int c;
-
-	endp = pkt + pktlen;
-	dp = buf;
-	*dp++ = STX;
-	for (cp = pkt; cp < endp; cp++) {
-		c = *cp;
-		if (c == STX || c == DLE)
-			*dp++ = DLE;
-		*dp++ = c;
-	}
-	*dp++ = STX;
-	write(target_fd, buf, dp - buf);
-}
--- a/rvinterf/rvtdump.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * This program reads bytes from a serial port, parses them assuming
- * TI's RVT MUX format, and prints every decoded packet.
- */
-
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-
-extern int target_fd;
-extern char *baudrate_name;
-
-extern char pr_item[];
-extern int sendsock_fd;
-
-char *logfname;
-FILE *logF;
-time_t logtime;
-int background, sendsock_enable;
-
-main(argc, argv)
-	char **argv;
-{
-	extern char *optarg;
-	extern int optind;
-	int c, maxfd;
-	fd_set fds;
-
-	while ((c = getopt(argc, argv, "bB:d:l:s")) != EOF)
-		switch (c) {
-		case 'b':
-			background++;
-			continue;
-		case 'B':
-			baudrate_name = optarg;
-			continue;
-		case 'd':
-			target_fd = atoi(optarg);
-			continue;
-		case 'l':
-			logfname = optarg;
-			continue;
-		case 's':
-			sendsock_enable++;
-			continue;
-		case '?':
-		default:
-usage:			fprintf(stderr,
-			"usage: %s [options] ttyport\n", argv[0]);
-			exit(1);
-		}
-	if (background && !logfname) {
-		fprintf(stderr, "%s: -b is meaningless without -l\n", argv[0]);
-		exit(1);
-	}
-	if (target_fd <= 0) {
-		if (argc - optind != 1)
-			goto usage;
-		open_target_serial(argv[optind]);
-	}
-
-	set_serial_nonblock(0);
-	setlinebuf(stdout);
-	if (logfname) {
-		logF = fopen(logfname, "w");
-		if (!logF) {
-			perror(logfname);
-			exit(1);
-		}
-		fprintf(logF, "*** Log of decoded RVT output ***\n");
-		setlinebuf(logF);
-	}
-	if (sendsock_enable)
-		create_send_socket();
-	if (background) {
-		c = fork();
-		if (c < 0) {
-			perror("fork");
-			exit(1);
-		}
-		if (c) {
-			printf("rvtdump forked into background (pid %d)\n", c);
-			exit(0);
-		}
-	}
-	maxfd = target_fd;
-	if (sendsock_fd > maxfd)
-		maxfd = sendsock_fd;
-	for (;;) {
-		FD_ZERO(&fds);
-		FD_SET(target_fd, &fds);
-		if (sendsock_enable)
-			FD_SET(sendsock_fd, &fds);
-		c = select(maxfd+1, &fds, 0, 0, 0);
-		time(&logtime);
-		if (c < 0) {
-			if (errno == EINTR)
-				continue;
-			perror("select");
-			exit(1);
-		}
-		if (FD_ISSET(target_fd, &fds))
-			process_serial_rx();
-		if (FD_ISSET(sendsock_fd, &fds))
-			handle_sendsock();
-	}
-}
-
-handle_rx_packet()
-{
-	print_rx_packet();
-}
-
-print_item()
-{
-	if (!background)
-		printf("%s\n", pr_item);
-	if (logF)
-		log_item();
-}
--- a/rvinterf/rvtdump_tx.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * This module contains the implementation of the Tx extension to rvtdump
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "txpkt.h"
-
-static char sockpath[] = "/tmp/rvt_send_socket";
-
-int sendsock_fd;
-u_char sendsock_pkt[MAX_PKT_TO_TARGET];
-int sendsock_pktlen;
-
-create_send_socket()
-{
-	/* local socket binding voodoo copied from osmocon */
-	struct sockaddr_un local;
-	unsigned int namelen;
-	int rc;
-
-	sendsock_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
-	if (sendsock_fd < 0) {
-		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
-		exit(1);
-	}
-
-	local.sun_family = AF_UNIX;
-	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
-	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
-	unlink(local.sun_path);
-
-	/* we use the same magic that X11 uses in Xtranssock.c for
-	 * calculating the proper length of the sockaddr */
-#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
-	local.sun_len = strlen(local.sun_path);
-#endif
-#if defined(BSD44SOCKETS) || defined(SUN_LEN)
-	namelen = SUN_LEN(&local);
-#else
-	namelen = strlen(local.sun_path) +
-		  offsetof(struct sockaddr_un, sun_path);
-#endif
-
-	rc = bind(sendsock_fd, (struct sockaddr *) &local, namelen);
-	if (rc != 0) {
-		perror("bind on local dgram socket");
-		exit(1);
-	}
-
-	return(0);
-}
-
-handle_sendsock()
-{
-	sendsock_pktlen = recv(sendsock_fd, sendsock_pkt, MAX_PKT_TO_TARGET, 0);
-	if (sendsock_pktlen <= 0) {
-		fprintf(stderr, "return value from recv on socket: %d\n",
-			sendsock_pktlen);
-		exit(1);
-	}
-	send_pkt_to_target(sendsock_pkt, sendsock_pktlen);
-	log_sent_packet(sendsock_pkt, sendsock_pktlen);
-}
--- a/rvinterf/trdump.c	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * This module implements the basic dump of any incoming packets
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include "pktmux.h"
-
-extern u_char rxpkt[];
-extern size_t rxpkt_len;
-
-char pr_item[4096];
-
-void
-print_rv_trace()
-{
-	int i, c;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "RV ");
-	dp += 3;
-	/* the SWE static ID is sent MSB first */
-	for (i = 1; i <= 4; i++) {
-		sprintf(dp, "%02X", rxpkt[i]);
-		dp += 2;
-	}
-	/* severity level */
-	sprintf(dp, " %d ", rxpkt[5]);
-	dp = index(dp, '\0');
-	for (i = 6; i < rxpkt_len; i++) {
-		c = rxpkt[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';
-	print_item();
-}
-
-void
-print_l1_trace()
-{
-	int i, c;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "L1: ");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		if ((i+1 < rxpkt_len) &&
-		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
-		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
-			*dp = '\0';
-			print_item();
-			if (i+2 == rxpkt_len)
-				return;
-			dp = pr_item;
-			*dp++ = '+';
-			*dp++ = ' ';
-			i++;
-			continue;
-		}
-		c = rxpkt[i];
-		if (c & 0x80) {
-			*dp++ = 'M';
-			*dp++ = '-';
-			c &= 0x7F;
-		}
-		if (c < 0x20) {
-			*dp++ = '^';
-			*dp++ = c + '@';
-		} else if (c == 0x7F) {
-			*dp++ = '^';
-			*dp++ = '?';
-		} else
-			*dp++ = c;
-	}
-	/* will get here only if no newline sequence at the end */
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_g23_trace()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "G23:");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_etm_output_raw()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "ETM:");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_unknown_packet()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "UNK:");
-	dp += 4;
-	for (i = 0; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_rx_packet()
-{
-	switch (rxpkt[0]) {
-	case RVT_RV_HEADER:
-		if (rxpkt_len < 6)
-			goto unknown;
-		print_rv_trace();
-		return;
-	case RVT_L1_HEADER:
-		print_l1_trace();
-		return;
-	case RVT_L23_HEADER:
-		print_g23_trace();
-		return;
-	case RVT_TM_HEADER:
-		print_etm_output_raw();
-		return;
-	default:
-	unknown:
-		print_unknown_packet();
-	}
-}
--- a/rvinterf/txpkt.h	Wed Nov 20 06:25:05 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * For sizing our buffers etc in rvinterf, we need a limit on the size of
- * message packets we can send to the target.  As it happens, the packet
- * Rx code in RVT on the target side also has a limit (quite naturally,
- * as it needs to use a static buffer to reassemble incoming packets as
- * they arrive at the UART in unpredictable interrupt-sized chunks), so
- * we set our limit to match that in RVT.
- */
-
-#define	MAX_PKT_TO_TARGET	255
-
-/*
- * The above limit definition counts all bytes between the opening and
- * closing STX flags, but not DLEs inserted for binary transparency.
- */