FreeCalypso > hg > freecalypso-sw
changeset 258:ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 04 Feb 2014 07:43:12 +0000 |
parents | c413e791595a |
children | 35113b1964d3 |
files | rvinterf/etm/Makefile rvinterf/etm/ffs2.c rvinterf/etm/usercmd.c |
diffstat | 3 files changed, 64 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etm/Makefile Tue Feb 04 07:22:19 2014 +0000 +++ b/rvinterf/etm/Makefile Tue Feb 04 07:43:12 2014 +0000 @@ -3,8 +3,8 @@ PROGS= fc-tmsh INSTBIN=/usr/local/bin -TMSH_OBJS= abb.o etmbasic.o init.o interf.o launchrvif.o main.o misc.o \ - pktsort.o tmcore.o ttymagic.o usercmd.o +TMSH_OBJS= abb.o etmbasic.o ffs2.o init.o interf.o launchrvif.o main.o \ + misc.o pktsort.o tmcore.o ttymagic.o usercmd.o all: ${PROGS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etm/ffs2.c Tue Feb 04 07:43:12 2014 +0000 @@ -0,0 +1,60 @@ +/* + * In this module we are going to implement TMFFS2 functionality. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "../include/pktmux.h" +#include "../include/limits.h" +#include "localtypes.h" +#include "etm.h" +#include "tmffs2.h" + +void +cmd_ffs2_version() +{ + u_char cmdpkt[4]; + + cmdpkt[1] = ETM_FFS2; + cmdpkt[2] = TMFFS_VERSION; + send_etm_cmd(cmdpkt, 2); +} + +static struct cmdtab { + char *cmd; + int minargs; + int maxargs; + void (*func)(); +} ffs2_cmds[] = { + {"version", 0, 0, cmd_ffs2_version}, + {0, 0, 0, 0} +}; + +void +cmd_ffs2(argc, argv) + char **argv; +{ + struct cmdtab *tp; + int extargs; + + for (tp = ffs2_cmds; tp->cmd; tp++) + if (!strcmp(tp->cmd, argv[1])) + break; + if (!tp->func) { + printf("error: no such ffs2 command\n"); + return; + } + extargs = argc - 2; + if (extargs > tp->maxargs) { + printf("error: too many arguments\n"); + return; + } + if (extargs < tp->minargs) { + printf("error: too few arguments\n"); + return; + } + tp->func(argc - 1, argv + 1); +}
--- a/rvinterf/etm/usercmd.c Tue Feb 04 07:22:19 2014 +0000 +++ b/rvinterf/etm/usercmd.c Tue Feb 04 07:43:12 2014 +0000 @@ -16,6 +16,7 @@ extern void cmd_check_ffs1(); extern void cmd_dieid(); extern void cmd_etmpkt(); +extern void cmd_ffs2(); extern void cmd_ping(); extern void cmd_r8(); extern void cmd_r16(); @@ -45,6 +46,7 @@ {"dieid", 0, 0, cmd_dieid}, {"etmpkt", 1, 253, cmd_etmpkt}, {"exit", 0, 0, cmd_exit}, + {"ffs2", 1, 1, cmd_ffs2}, {"ping", 0, 2, cmd_ping}, {"quit", 0, 0, cmd_exit}, {"r8", 1, 2, cmd_r8},