changeset 259:35113b1964d3

fc-tmsh ffs2: a few request-sending commands implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 05 Feb 2014 00:11:34 +0000
parents ab66a2eea6a8
children c146f38d2b5f
files rvinterf/etm/ffs2.c rvinterf/etm/tmffs2.h rvinterf/etm/usercmd.c
diffstat 3 files changed, 100 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etm/ffs2.c	Tue Feb 04 07:43:12 2014 +0000
+++ b/rvinterf/etm/ffs2.c	Wed Feb 05 00:11:34 2014 +0000
@@ -14,6 +14,98 @@
 #include "tmffs2.h"
 
 void
+cmd_ffs2_close(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_FFS2;
+	cmdpkt[2] = TMFFS_CLOSE;
+	cmdpkt[3] = strtoul(argv[1], 0, 0);
+	send_etm_cmd(cmdpkt, 3);
+}
+
+void
+cmd_ffs2_delete(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: argument exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_REMOVE;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_format(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: argument exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_FORMAT;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	/* magic is 0x2BAD, 16-bit little-endian */
+	*dp++ = 0xAD;
+	*dp++ = 0x2B;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_open(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: argument exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_OPEN;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	*dp++ = strtoul(argv[2], 0, 16);
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_preformat()
+{
+	u_char cmdpkt[6];
+
+	cmdpkt[1] = ETM_FFS2;
+	cmdpkt[2] = TMFFS_PREFORMAT;
+	/* magic is 0xDEAD, 16-bit little-endian */
+	cmdpkt[3] = 0xAD;
+	cmdpkt[4] = 0xDE;
+	send_etm_cmd(cmdpkt, 4);
+}
+
+void
 cmd_ffs2_version()
 {
 	u_char cmdpkt[4];
@@ -29,6 +121,11 @@
 	int maxargs;
 	void (*func)();
 } ffs2_cmds[] = {
+	{"close", 1, 1, cmd_ffs2_close},
+	{"delete", 1, 1, cmd_ffs2_delete},
+	{"format", 1, 1, cmd_ffs2_format},
+	{"open", 2, 2, cmd_ffs2_open},
+	{"preformat", 0, 0, cmd_ffs2_preformat},
 	{"version", 0, 0, cmd_ffs2_version},
 	{0, 0, 0, 0}
 };
--- a/rvinterf/etm/tmffs2.h	Tue Feb 04 07:43:12 2014 +0000
+++ b/rvinterf/etm/tmffs2.h	Wed Feb 05 00:11:34 2014 +0000
@@ -44,3 +44,5 @@
 	TMFFS_VERSION    = 'v',
 	TMFFS_TFFS       = 'z'
 }; 
+
+#define TMFFS_STRING_SIZE 127	/* includes the terminating NUL */
--- a/rvinterf/etm/usercmd.c	Tue Feb 04 07:43:12 2014 +0000
+++ b/rvinterf/etm/usercmd.c	Wed Feb 05 00:11:34 2014 +0000
@@ -46,7 +46,7 @@
 	{"dieid", 0, 0, cmd_dieid},
 	{"etmpkt", 1, 253, cmd_etmpkt},
 	{"exit", 0, 0, cmd_exit},
-	{"ffs2", 1, 1, cmd_ffs2},
+	{"ffs2", 1, 3, cmd_ffs2},
 	{"ping", 0, 2, cmd_ping},
 	{"quit", 0, 0, cmd_exit},
 	{"r8", 1, 2, cmd_r8},