changeset 198:c9ea2f7441a5

fc-tmsh: abb[rw] commands implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Dec 2013 08:48:52 +0000
parents fa7174faa9aa
children 96f56e875862
files rvinterf/etm/Makefile rvinterf/etm/abb.c rvinterf/etm/tmcore.c rvinterf/etm/usercmd.c
diffstat 4 files changed, 107 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etm/Makefile	Sun Dec 15 07:31:52 2013 +0000
+++ b/rvinterf/etm/Makefile	Sun Dec 15 08:48:52 2013 +0000
@@ -3,7 +3,7 @@
 PROGS=	fc-tmsh
 INSTBIN=/usr/local/bin
 
-TMSH_OBJS=	etmbasic.o init.o interf.o launchrvif.o main.o pktsort.o \
+TMSH_OBJS=	abb.o etmbasic.o init.o interf.o launchrvif.o main.o pktsort.o \
 		tmcore.o ttymagic.o usercmd.o
 
 all:	${PROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etm/abb.c	Sun Dec 15 08:48:52 2013 +0000
@@ -0,0 +1,98 @@
+/*
+ * In this module we are going to implement commands dealing with the ABB.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "../pktmux.h"
+#include "../limits.h"
+#include "localtypes.h"
+#include "etm.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+void
+cmd_abbr(argc, argv)
+	char **argv;
+{
+	u32 page, reg;
+	u_char cmdpkt[5];
+
+	page = strtoul(argv[1], 0, 0);
+	reg = strtoul(argv[2], 0, 0);
+	if (page > 1 || reg > 31) {
+		printf("error: argument(s) out of range\n");
+		return;
+	}
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_CODEC_RD;
+	cmdpkt[3] = page << 5 | reg;
+	send_etm_cmd(cmdpkt, 3);
+}
+
+void
+abbr_response()
+{
+	unsigned pg, reg, val;
+	char buf[80];
+
+	if (rvi_msg[3]) {
+		print_etm_pkt_raw("abbr error");
+		return;
+	}
+	if (rvi_msg_len != 9) {
+		print_etm_pkt_raw("abbr malformed resp");
+		return;
+	}
+	pg = rvi_msg[5] >> 5;
+	reg = rvi_msg[5] & 0x1F;
+	val = rvi_msg[6] | rvi_msg[7] << 8;
+	sprintf(buf, "abbr %u %u: %03X", pg, reg, val);
+	async_msg_output(buf);
+}
+
+void
+cmd_abbw(argc, argv)
+	char **argv;
+{
+	u32 page, reg, val;
+	u_char cmdpkt[7];
+
+	page = strtoul(argv[1], 0, 0);
+	reg = strtoul(argv[2], 0, 0);
+	val = strtoul(argv[3], 0, 16);
+	if (page > 1 || reg > 31 || val > 0x3FF) {
+		printf("error: argument(s) out of range\n");
+		return;
+	}
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_CODEC_WR;
+	cmdpkt[3] = page << 5 | reg;
+	cmdpkt[4] = val;
+	cmdpkt[5] = val >> 8;
+	send_etm_cmd(cmdpkt, 5);
+}
+
+void
+abbw_response()
+{
+	unsigned pg, reg;
+	char buf[80];
+
+	if (rvi_msg[3]) {
+		print_etm_pkt_raw("abbw error");
+		return;
+	}
+	if (rvi_msg_len != 7) {
+		print_etm_pkt_raw("abbw malformed resp");
+		return;
+	}
+	pg = rvi_msg[5] >> 5;
+	reg = rvi_msg[5] & 0x1F;
+	sprintf(buf, "abbw %u %u OK", pg, reg);
+	async_msg_output(buf);
+}
--- a/rvinterf/etm/tmcore.c	Sun Dec 15 07:31:52 2013 +0000
+++ b/rvinterf/etm/tmcore.c	Sun Dec 15 08:48:52 2013 +0000
@@ -180,9 +180,11 @@
 		version_response();
 		return;
 	case TMCORE_OPC_CODEC_RD:
+		abbr_response();
+		return;
 	case TMCORE_OPC_CODEC_WR:
-		/* not yet implemented */
-		goto unknown;
+		abbw_response();
+		return;
 	case TMCORE_OPC_DIEID:
 		dieid_response();
 		return;
--- a/rvinterf/etm/usercmd.c	Sun Dec 15 07:31:52 2013 +0000
+++ b/rvinterf/etm/usercmd.c	Sun Dec 15 08:48:52 2013 +0000
@@ -11,6 +11,8 @@
 
 extern char usercmd[];
 
+extern void cmd_abbr();
+extern void cmd_abbw();
 extern void cmd_dieid();
 extern void cmd_etmpkt();
 extern void cmd_ping();
@@ -36,6 +38,8 @@
 	int maxargs;
 	void (*func)();
 } cmdtab[] = {
+	{"abbr", 2, 2, cmd_abbr},
+	{"abbw", 3, 3, cmd_abbw},
 	{"dieid", 0, 0, cmd_dieid},
 	{"etmpkt", 1, 253, cmd_etmpkt},
 	{"exit", 0, 0, cmd_exit},