changeset 270:095ffce023d4

etmsync: l1tmops module compiles and links into fc-tmsync
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 16 Nov 2017 19:00:05 +0000
parents 20ed7a320b12
children dc9dbb2f74e7
files rvinterf/etmsync/Makefile rvinterf/etmsync/l1tmops.c
diffstat 2 files changed, 90 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile	Thu Nov 16 18:43:52 2017 +0000
+++ b/rvinterf/etmsync/Makefile	Thu Nov 16 19:00:05 2017 +0000
@@ -14,8 +14,8 @@
 
 MEMDUMP_OBJS=	connect.o interf.o launchrvif.o memdump.o memops.o
 
-TMSYNC_OBJS=	cl_des.o connect.o dispatch.o interf.o launchrvif.o memcmd.o \
-		memops.o pirimei.o tmscmdtab.o tmsmain.o
+TMSYNC_OBJS=	cl_des.o connect.o dispatch.o interf.o l1tmops.o launchrvif.o \
+		memcmd.o memops.o pirimei.o tmscmdtab.o tmsmain.o
 
 all:	${PROGS}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/l1tmops.c	Thu Nov 16 19:00:05 2017 +0000
@@ -0,0 +1,88 @@
+/*
+ * In this module we implement the functions that access the L1TM operations
+ * which we are going to use in fc-tmsync and fc-readcal.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "pktmux.h"
+#include "tm3.h"
+#include "l1tm.h"
+#include "exitcodes.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+do_tms(arg)
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = TM_MODE_SET;
+	cmdpkt[2] = arg;
+	cmdpkt[3] = arg >> 8;
+	etm_pkt_exch(cmdpkt, 3);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "target error %u in response to tms\n",
+			rvi_msg[3]);
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg_len != 5) {
+		fprintf(stderr, "target error: tms response wrong length\n");
+		exit(ERROR_TARGET);
+	}
+	return(0);
+}
+
+do_rfpw(index, value)
+{
+	u_char cmdpkt[7];
+
+	cmdpkt[1] = RF_PARAM_WRITE;
+	cmdpkt[2] = index;
+	cmdpkt[3] = index >> 8;
+	cmdpkt[4] = value;
+	cmdpkt[5] = value >> 8;
+	etm_pkt_exch(cmdpkt, 5);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "target error %u in response to rfpw\n",
+			rvi_msg[3]);
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg_len != 6) {
+		fprintf(stderr, "target error: rfpw response wrong length\n");
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg[4] != index) {
+		fprintf(stderr, "target error: rfpw response wrong index\n");
+		exit(ERROR_TARGET);
+	}
+	return(0);
+}
+
+do_rftr(index, table, size)
+	u_char *table;
+{
+	u_char cmdpkt[4];
+
+	cmdpkt[1] = RF_TABLE_READ;
+	cmdpkt[2] = index;
+	etm_pkt_exch(cmdpkt, 2);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "target error %u in response to rftr\n",
+			rvi_msg[3]);
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg_len < size + 6) {
+		fprintf(stderr, "target error: rftr response too short\n");
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg[4] != index) {
+		fprintf(stderr, "target error: rftr response wrong index\n");
+		exit(ERROR_TARGET);
+	}
+	bcopy(rvi_msg + 5, table, size);
+	return(0);
+}