changeset 889:1b1683cda154

fc-shell: implemented poweroff and tgtreset commands
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 28 Jun 2015 16:52:06 +0000
parents 0590cfd5803f
children 452a4aea3fc5
files rvinterf/asyncshell/Makefile rvinterf/asyncshell/poweroff.c rvinterf/asyncshell/usercmd.c
diffstat 3 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/asyncshell/Makefile	Sun Jun 28 15:40:47 2015 +0000
+++ b/rvinterf/asyncshell/Makefile	Sun Jun 28 16:52:06 2015 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2 -I../include
 PROG=	fc-shell
-OBJS=	at.o init.o main.o pktsort.o rxctl.o sendsp.o usercmd.o
+OBJS=	at.o init.o main.o pktsort.o poweroff.o rxctl.o sendsp.o usercmd.o
 LIBS=	../libasync/libasync.a ../libg23/libg23.a
 INSTBIN=/usr/local/bin
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/asyncshell/poweroff.c	Sun Jun 28 16:52:06 2015 +0000
@@ -0,0 +1,46 @@
+/*
+ * fc-shell poweroff and tgtreset commands
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "etm.h"
+
+void
+send_etm_cmd(buf, len)
+	u_char *buf;
+{
+	int i, c;
+
+	buf[0] = RVT_TM_HEADER;
+	c = 0;
+	for (i = 1; i <= len; i++)
+		c ^= buf[i];
+	buf[i] = c;
+	send_pkt_to_target(buf, len + 2);
+}
+
+void
+cmd_poweroff()
+{
+	u_char cmdpkt[7];
+
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_CODEC_WR;
+	cmdpkt[3] = 30;		/* VRPCDEV */
+	cmdpkt[4] = 0x01;	/* low 8 bits */
+	cmdpkt[5] = 0;		/* high 2 bits */
+	send_etm_cmd(cmdpkt, 5);
+}
+
+void
+cmd_tgtreset()
+{
+	u_char cmdpkt[4];
+
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_RESET;
+	send_etm_cmd(cmdpkt, 2);
+}
--- a/rvinterf/asyncshell/usercmd.c	Sun Jun 28 15:40:47 2015 +0000
+++ b/rvinterf/asyncshell/usercmd.c	Sun Jun 28 16:52:06 2015 +0000
@@ -13,8 +13,10 @@
 
 extern void cmd_disable();
 extern void cmd_enable();
+extern void cmd_poweroff();
 extern void cmd_sendat();
 extern void cmd_sendsp();
+extern void cmd_tgtreset();
 
 void
 cmd_exit()
@@ -30,9 +32,11 @@
 	{"disable", cmd_disable},
 	{"enable", cmd_enable},
 	{"exit", cmd_exit},
+	{"poweroff", cmd_poweroff},
 	{"quit", cmd_exit},
 	{"sp", cmd_sendsp},
 	{"str", cmd_sendat},
+	{"tgtreset", cmd_tgtreset},
 	{0, 0}
 };