changeset 945:4c601097d23f

rvinterf: retire libg23 to old subdir
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 24 May 2023 07:22:32 +0000
parents 441004febe35
children 8f7c50e1fa3b
files rvinterf/libg23/Makefile rvinterf/libg23/README rvinterf/libg23/fmtdispatch.c rvinterf/libg23/fmtfunc.c rvinterf/old/libg23/Makefile rvinterf/old/libg23/README rvinterf/old/libg23/fmtdispatch.c rvinterf/old/libg23/fmtfunc.c
diffstat 8 files changed, 335 insertions(+), 335 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/libg23/Makefile	Wed May 24 07:12:50 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2
-OBJS=	fmtdispatch.o fmtfunc.o
-LIB=	libg23.a
-
-all:	${LIB}
-
-${LIB}:	${OBJS}
-	ar rcu $@ ${OBJS}
-	ranlib $@
-
-clean:
-	rm -f *.[oa] errs
--- a/rvinterf/libg23/README	Wed May 24 07:12:50 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-The library built in this directory is a host side library, not for the target.
-This library implements some functions for handling packet exchanges with GPF,
-and it will be linked by some of the programs in the rvinterf suite.
-
-It needs to be noted that the RVTMUX channel belonging to GPF was named
-RVT_L23_HEADER by TI, and as a result, I thought that these packets related
-specifically to the higher layers of the protocol stack.  But now we know that
-hierarchically speaking, GPF sits *below* L1, not above, and GPF packets should
-not be automatically associated with G23.  This realization was made fairly
-late, thus "g23" appears in a bunch of function names, and in the name of this
-library.
--- a/rvinterf/libg23/fmtdispatch.c	Wed May 24 07:12:50 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * This libg23 module exports the format_g23_packet() function, which
- * validates the packet, then dispatches it to format_g23_trace(),
- * format_g23_sysprim() or format_g23_psprim() as appropriate, or
- * prints it in raw hex if malformed.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-
-static int
-basic_checks(rxpkt, rxpkt_len)
-	u_char *rxpkt;
-{
-	int i, c;
-
-	if (rxpkt_len < 17)
-		return(0);
-	/* check version bits in the header byte */
-	if ((rxpkt[1] & 0xC0) != 0x80)
-		return(0);
-	/* check the length */
-	c = rxpkt[2] | rxpkt[3] << 8;
-	if (c + 4 != rxpkt_len)
-		return(0);
-	/* ensure that the "from" and "to" are printable ASCII */
-	for (i = 8; i < 16; i++) {
-		c = rxpkt[i];
-		if (c < ' ' || c > '~')
-			return(0);
-	}
-	/* basic checks pass */
-	return(1);
-}
-
-static int
-psprim_extra_checks(rxpkt, rxpkt_len)
-	u_char *rxpkt;
-{
-	int i, c;
-
-	if (rxpkt_len < 24)
-		return(0);
-	/* "original rcvr" field needs to be printable ASCII */
-	for (i = 16; i < 20; i++) {
-		c = rxpkt[i];
-		if (c < ' ' || c > '~')
-			return(0);
-	}
-	/* checks pass */
-	return(1);
-}
-
-static void
-print_unknown_bin(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	int i;
-	char *dp;
-
-	dp = outbuf;
-	strcpy(dp, "GPF UNK:");
-	dp += 8;
-	for (i = 1; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-}
-
-static void
-print_old_ascii(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	char *dp;
-	int txtlen = rxpkt_len - 1;
-
-	dp = outbuf;
-	strcpy(dp, "GPF ASC: ");
-	dp += 9;
-	bcopy(rxpkt + 1, dp, txtlen);
-	dp += txtlen;
-	*dp = '\0';
-}
-
-static int
-is_old_ascii(rxpkt, rxpkt_len)
-	u_char *rxpkt;
-{
-	int i, c;
-
-	for (i = 1; i < rxpkt_len; i++) {
-		c = rxpkt[i];
-		if (c < ' ' || c > '~')
-			return(0);
-	}
-	return(1);
-}
-
-static void
-print_malformed(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	if (is_old_ascii(rxpkt, rxpkt_len))
-		print_old_ascii(rxpkt, rxpkt_len, outbuf);
-	else
-		print_unknown_bin(rxpkt, rxpkt_len, outbuf);
-}
-
-void
-format_g23_packet(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	if (!basic_checks(rxpkt, rxpkt_len)) {
-		print_malformed(rxpkt, rxpkt_len, outbuf);
-		return;
-	}
-	/* dispatch by type */
-	switch (rxpkt[1] & 0x30) {
-	case 0x10:
-		/* PS primitive */
-		if (psprim_extra_checks(rxpkt, rxpkt_len))
-			format_g23_psprim(rxpkt, rxpkt_len, outbuf);
-		else
-			print_malformed(rxpkt, rxpkt_len, outbuf);
-		return;
-	case 0x20:
-		/* trace */
-		format_g23_trace(rxpkt, rxpkt_len, outbuf);
-		return;
-	case 0x30:
-		/* system primitive */
-		format_g23_sysprim(rxpkt, rxpkt_len, outbuf);
-		return;
-	default:
-		print_malformed(rxpkt, rxpkt_len, outbuf);
-	}
-}
--- a/rvinterf/libg23/fmtfunc.c	Wed May 24 07:12:50 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * This libg23 module exports functions for formatting 3 different kinds
- * of GPF packets into human-readable form: traces, system primitives
- * and protocol stack primitives.
- *
- * GPF packets passed to these functions for decoding MUST have already
- * been verified to be well-formed for their respective type.
- */
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-
-static int
-entity_name_well_formed(p)
-	char *p;
-{
-	int i, len;
-
-	if (!isupper(p[0]))
-		return(0);
-	for (i = 0; i < 4; i++)
-		if (!isalnum(p[i]))
-			break;
-	len = i;
-	for (; i < 4; i++)
-		if (p[i] != ' ')
-			return(0);
-	return(len);
-}
-
-static void
-print_entity_name(raw, outp)
-	char *raw, **outp;
-{
-	int len;
-
-	len = entity_name_well_formed(raw);
-	if (len) {
-		sprintf(*outp, "%.*s", len, raw);
-		*outp += len;
-	} else {
-		sprintf(*outp, "\"%.4s\"", raw);
-		*outp += 6;
-	}
-}
-
-static void
-print_common_hdr(rxpkt, outp, typestr)
-	u_char *rxpkt;
-	char **outp, *typestr;
-{
-	sprintf(*outp, "GPF %s id=%02X ts=%02X%02X%02X%02X ", typestr,
-		rxpkt[1], rxpkt[7], rxpkt[6], rxpkt[5], rxpkt[4]);
-	*outp = index(*outp, '\0');
-	print_entity_name(rxpkt + 8, outp);
-	*(*outp)++ = '-';
-	*(*outp)++ = '>';
-	print_entity_name(rxpkt + 12, outp);
-	*(*outp)++ = ' ';
-}
-
-static void
-format_text(rxpkt, rxpkt_len, start_off, outp)
-	u_char *rxpkt;
-	char *outp;
-{
-	int i, c;
-
-	*outp++ = '\"';
-	for (i = start_off; i < rxpkt_len; i++) {
-		c = rxpkt[i];
-		if (c & 0x80) {
-			*outp++ = 'M';
-			*outp++ = '-';
-			c &= 0x7F;
-		}
-		if (c < 0x20) {
-			*outp++ = '^';
-			*outp++ = c + '@';
-		} else if (c == 0x7F) {
-			*outp++ = '^';
-			*outp++ = '?';
-		} else
-			*outp++ = c;
-	}
-	*outp++ = '\"';
-	*outp = '\0';
-}
-
-static void
-format_compressed_trace(rxpkt, rxpkt_len, start_off, outp)
-	u_char *rxpkt;
-	char *outp;
-{
-	int i;
-
-	i = start_off + 1;
-	sprintf(outp, "%d", rxpkt[i+1] << 8 | rxpkt[i]);
-	outp = index(outp, '\0');
-	i += 4;
-	for (; i < rxpkt_len; i++) {
-		sprintf(outp, " %02X", rxpkt[i]);
-		outp += 3;
-	}
-	*outp = '\0';
-}
-
-void
-format_g23_trace(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	char *outp = outbuf;
-	int i;
-
-	print_common_hdr(rxpkt, &outp, "trace");
-	i = 16;
-	if (rxpkt[i] < 0x20) {
-		sprintf(outp, "tc=%02X ", rxpkt[i]);
-		outp += 6;
-		i++;
-	}
-	if (rxpkt_len - i >= 5 && rxpkt[i] == '%' &&
-	    !rxpkt[i+3] && !rxpkt[i+4])
-		format_compressed_trace(rxpkt, rxpkt_len, i, outp);
-	else
-		format_text(rxpkt, rxpkt_len, i, outp);
-}
-
-void
-format_g23_sysprim(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	char *outp = outbuf;
-	int i;
-
-	print_common_hdr(rxpkt, &outp, "sysprim");
-	format_text(rxpkt, rxpkt_len, 16, outp);
-}
-
-void
-format_g23_psprim(rxpkt, rxpkt_len, outbuf)
-	u_char *rxpkt;
-	char *outbuf;
-{
-	char *outp = outbuf;
-	int i;
-
-	print_common_hdr(rxpkt, &outp, "PSprim");
-	/* original destination */
-	*outp++ = '(';
-	print_entity_name(rxpkt + 16, &outp);
-	*outp++ = ')';
-	/* opcode */
-	sprintf(outp, " %02X%02X%02X%02X",
-		rxpkt[23], rxpkt[22], rxpkt[21], rxpkt[20]);
-	outp += 9;
-	for (i = 24; i < rxpkt_len; i++) {
-		sprintf(outp, " %02X", rxpkt[i]);
-		outp += 3;
-	}
-	*outp = '\0';
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/libg23/Makefile	Wed May 24 07:22:32 2023 +0000
@@ -0,0 +1,13 @@
+CC=	gcc
+CFLAGS=	-O2
+OBJS=	fmtdispatch.o fmtfunc.o
+LIB=	libg23.a
+
+all:	${LIB}
+
+${LIB}:	${OBJS}
+	ar rcu $@ ${OBJS}
+	ranlib $@
+
+clean:
+	rm -f *.[oa] errs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/libg23/README	Wed May 24 07:22:32 2023 +0000
@@ -0,0 +1,11 @@
+The library built in this directory is a host side library, not for the target.
+This library implements some functions for handling packet exchanges with GPF,
+and it will be linked by some of the programs in the rvinterf suite.
+
+It needs to be noted that the RVTMUX channel belonging to GPF was named
+RVT_L23_HEADER by TI, and as a result, I thought that these packets related
+specifically to the higher layers of the protocol stack.  But now we know that
+hierarchically speaking, GPF sits *below* L1, not above, and GPF packets should
+not be automatically associated with G23.  This realization was made fairly
+late, thus "g23" appears in a bunch of function names, and in the name of this
+library.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/libg23/fmtdispatch.c	Wed May 24 07:22:32 2023 +0000
@@ -0,0 +1,144 @@
+/*
+ * This libg23 module exports the format_g23_packet() function, which
+ * validates the packet, then dispatches it to format_g23_trace(),
+ * format_g23_sysprim() or format_g23_psprim() as appropriate, or
+ * prints it in raw hex if malformed.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+static int
+basic_checks(rxpkt, rxpkt_len)
+	u_char *rxpkt;
+{
+	int i, c;
+
+	if (rxpkt_len < 17)
+		return(0);
+	/* check version bits in the header byte */
+	if ((rxpkt[1] & 0xC0) != 0x80)
+		return(0);
+	/* check the length */
+	c = rxpkt[2] | rxpkt[3] << 8;
+	if (c + 4 != rxpkt_len)
+		return(0);
+	/* ensure that the "from" and "to" are printable ASCII */
+	for (i = 8; i < 16; i++) {
+		c = rxpkt[i];
+		if (c < ' ' || c > '~')
+			return(0);
+	}
+	/* basic checks pass */
+	return(1);
+}
+
+static int
+psprim_extra_checks(rxpkt, rxpkt_len)
+	u_char *rxpkt;
+{
+	int i, c;
+
+	if (rxpkt_len < 24)
+		return(0);
+	/* "original rcvr" field needs to be printable ASCII */
+	for (i = 16; i < 20; i++) {
+		c = rxpkt[i];
+		if (c < ' ' || c > '~')
+			return(0);
+	}
+	/* checks pass */
+	return(1);
+}
+
+static void
+print_unknown_bin(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	int i;
+	char *dp;
+
+	dp = outbuf;
+	strcpy(dp, "GPF UNK:");
+	dp += 8;
+	for (i = 1; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+}
+
+static void
+print_old_ascii(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	char *dp;
+	int txtlen = rxpkt_len - 1;
+
+	dp = outbuf;
+	strcpy(dp, "GPF ASC: ");
+	dp += 9;
+	bcopy(rxpkt + 1, dp, txtlen);
+	dp += txtlen;
+	*dp = '\0';
+}
+
+static int
+is_old_ascii(rxpkt, rxpkt_len)
+	u_char *rxpkt;
+{
+	int i, c;
+
+	for (i = 1; i < rxpkt_len; i++) {
+		c = rxpkt[i];
+		if (c < ' ' || c > '~')
+			return(0);
+	}
+	return(1);
+}
+
+static void
+print_malformed(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	if (is_old_ascii(rxpkt, rxpkt_len))
+		print_old_ascii(rxpkt, rxpkt_len, outbuf);
+	else
+		print_unknown_bin(rxpkt, rxpkt_len, outbuf);
+}
+
+void
+format_g23_packet(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	if (!basic_checks(rxpkt, rxpkt_len)) {
+		print_malformed(rxpkt, rxpkt_len, outbuf);
+		return;
+	}
+	/* dispatch by type */
+	switch (rxpkt[1] & 0x30) {
+	case 0x10:
+		/* PS primitive */
+		if (psprim_extra_checks(rxpkt, rxpkt_len))
+			format_g23_psprim(rxpkt, rxpkt_len, outbuf);
+		else
+			print_malformed(rxpkt, rxpkt_len, outbuf);
+		return;
+	case 0x20:
+		/* trace */
+		format_g23_trace(rxpkt, rxpkt_len, outbuf);
+		return;
+	case 0x30:
+		/* system primitive */
+		format_g23_sysprim(rxpkt, rxpkt_len, outbuf);
+		return;
+	default:
+		print_malformed(rxpkt, rxpkt_len, outbuf);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/libg23/fmtfunc.c	Wed May 24 07:22:32 2023 +0000
@@ -0,0 +1,167 @@
+/*
+ * This libg23 module exports functions for formatting 3 different kinds
+ * of GPF packets into human-readable form: traces, system primitives
+ * and protocol stack primitives.
+ *
+ * GPF packets passed to these functions for decoding MUST have already
+ * been verified to be well-formed for their respective type.
+ */
+
+#include <sys/types.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+static int
+entity_name_well_formed(p)
+	char *p;
+{
+	int i, len;
+
+	if (!isupper(p[0]))
+		return(0);
+	for (i = 0; i < 4; i++)
+		if (!isalnum(p[i]))
+			break;
+	len = i;
+	for (; i < 4; i++)
+		if (p[i] != ' ')
+			return(0);
+	return(len);
+}
+
+static void
+print_entity_name(raw, outp)
+	char *raw, **outp;
+{
+	int len;
+
+	len = entity_name_well_formed(raw);
+	if (len) {
+		sprintf(*outp, "%.*s", len, raw);
+		*outp += len;
+	} else {
+		sprintf(*outp, "\"%.4s\"", raw);
+		*outp += 6;
+	}
+}
+
+static void
+print_common_hdr(rxpkt, outp, typestr)
+	u_char *rxpkt;
+	char **outp, *typestr;
+{
+	sprintf(*outp, "GPF %s id=%02X ts=%02X%02X%02X%02X ", typestr,
+		rxpkt[1], rxpkt[7], rxpkt[6], rxpkt[5], rxpkt[4]);
+	*outp = index(*outp, '\0');
+	print_entity_name(rxpkt + 8, outp);
+	*(*outp)++ = '-';
+	*(*outp)++ = '>';
+	print_entity_name(rxpkt + 12, outp);
+	*(*outp)++ = ' ';
+}
+
+static void
+format_text(rxpkt, rxpkt_len, start_off, outp)
+	u_char *rxpkt;
+	char *outp;
+{
+	int i, c;
+
+	*outp++ = '\"';
+	for (i = start_off; i < rxpkt_len; i++) {
+		c = rxpkt[i];
+		if (c & 0x80) {
+			*outp++ = 'M';
+			*outp++ = '-';
+			c &= 0x7F;
+		}
+		if (c < 0x20) {
+			*outp++ = '^';
+			*outp++ = c + '@';
+		} else if (c == 0x7F) {
+			*outp++ = '^';
+			*outp++ = '?';
+		} else
+			*outp++ = c;
+	}
+	*outp++ = '\"';
+	*outp = '\0';
+}
+
+static void
+format_compressed_trace(rxpkt, rxpkt_len, start_off, outp)
+	u_char *rxpkt;
+	char *outp;
+{
+	int i;
+
+	i = start_off + 1;
+	sprintf(outp, "%d", rxpkt[i+1] << 8 | rxpkt[i]);
+	outp = index(outp, '\0');
+	i += 4;
+	for (; i < rxpkt_len; i++) {
+		sprintf(outp, " %02X", rxpkt[i]);
+		outp += 3;
+	}
+	*outp = '\0';
+}
+
+void
+format_g23_trace(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	char *outp = outbuf;
+	int i;
+
+	print_common_hdr(rxpkt, &outp, "trace");
+	i = 16;
+	if (rxpkt[i] < 0x20) {
+		sprintf(outp, "tc=%02X ", rxpkt[i]);
+		outp += 6;
+		i++;
+	}
+	if (rxpkt_len - i >= 5 && rxpkt[i] == '%' &&
+	    !rxpkt[i+3] && !rxpkt[i+4])
+		format_compressed_trace(rxpkt, rxpkt_len, i, outp);
+	else
+		format_text(rxpkt, rxpkt_len, i, outp);
+}
+
+void
+format_g23_sysprim(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	char *outp = outbuf;
+	int i;
+
+	print_common_hdr(rxpkt, &outp, "sysprim");
+	format_text(rxpkt, rxpkt_len, 16, outp);
+}
+
+void
+format_g23_psprim(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	char *outp = outbuf;
+	int i;
+
+	print_common_hdr(rxpkt, &outp, "PSprim");
+	/* original destination */
+	*outp++ = '(';
+	print_entity_name(rxpkt + 16, &outp);
+	*outp++ = ')';
+	/* opcode */
+	sprintf(outp, " %02X%02X%02X%02X",
+		rxpkt[23], rxpkt[22], rxpkt[21], rxpkt[20]);
+	outp += 9;
+	for (i = 24; i < rxpkt_len; i++) {
+		sprintf(outp, " %02X", rxpkt[i]);
+		outp += 3;
+	}
+	*outp = '\0';
+}