FreeCalypso > hg > freecalypso-sw
changeset 300:19b846c8abed
fc-fsio: format and preformat commands added
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 02 Mar 2014 01:32:55 +0000 |
parents | 91570f916dd3 |
children | 8dd522a8d60e |
files | rvinterf/etmsync/Makefile rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/fsmisc.c |
diffstat | 3 files changed, 84 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile Sun Mar 02 01:09:30 2014 +0000 +++ b/rvinterf/etmsync/Makefile Sun Mar 02 01:32:55 2014 +0000 @@ -4,8 +4,8 @@ INSTBIN=/usr/local/bin FSIO_OBJS= connect.o dispatch.o fdcmd.o fileio.o fsbasics.o fscmdtab.o \ - fserr.o fsiomain.o fspath.o fsread.o fsupload.o fswrite.o \ - interf.o launchrvif.o + fserr.o fsiomain.o fsmisc.o fspath.o fsread.o fsupload.o \ + fswrite.o interf.o launchrvif.o all: ${PROGS}
--- a/rvinterf/etmsync/fscmdtab.c Sun Mar 02 01:09:30 2014 +0000 +++ b/rvinterf/etmsync/fscmdtab.c Sun Mar 02 01:32:55 2014 +0000 @@ -11,11 +11,13 @@ extern int cmd_exit(); extern int cmd_fd(); extern int cmd_ffs2ver(); +extern int cmd_format(); extern int cmd_fwrite(); extern int cmd_hd(); extern int cmd_ll(); extern int cmd_ls(); extern int cmd_mkdir(); +extern int cmd_preformat(); extern int cmd_stat(); extern int cmd_uploadfs(); extern int cmd_upload_file(); @@ -29,11 +31,13 @@ {"exit", 0, 0, cmd_exit}, {"fd", 2, 3, cmd_fd}, {"ffs2ver", 0, 0, cmd_ffs2ver}, + {"format", 1, 1, cmd_format}, {"fwrite", 3, 3, cmd_fwrite}, {"hd", 1, 1, cmd_hd}, {"ll", 1, 1, cmd_ll}, {"ls", 1, 1, cmd_ls}, {"mkdir", 1, 1, cmd_mkdir}, + {"preformat", 0, 0, cmd_preformat}, {"stat", 1, 1, cmd_stat}, {"upload-file", 2, 2, cmd_upload_file}, {"upload-fs", 1, 1, cmd_uploadfs},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/fsmisc.c Sun Mar 02 01:32:55 2014 +0000 @@ -0,0 +1,78 @@ +/* + * Miscellaneous (dangerous!) FFS2 operations + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "etm.h" +#include "ffs.h" +#include "tmffs2.h" +#include "limits.h" +#include "ffslimits.h" +#include "localtypes.h" +#include "localstruct.h" +#include "exitcodes.h" + +extern u_char rvi_msg[]; +extern int rvi_msg_len; + +cmd_format(argc, argv) + char **argv; +{ + u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; + int rc, 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; + rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); + if (rc) + return(rc); + if (rvi_msg_len != 5) { + printf("error: TMFFS_FORMAT response has wrong length\n"); + return(ERROR_TARGET); + } + if (rvi_msg[3]) { + report_ffs_err("format", rvi_msg[3]); + return(ERROR_TARGET); + } + return(0); +} + +cmd_preformat() +{ + u_char cmdpkt[6]; + int rc; + + cmdpkt[1] = ETM_FFS2; + cmdpkt[2] = TMFFS_PREFORMAT; + /* magic is 0xDEAD, 16-bit little-endian */ + cmdpkt[3] = 0xAD; + cmdpkt[4] = 0xDE; + rc = etm_pkt_exch(cmdpkt, 4); + if (rc) + return(rc); + if (rvi_msg_len != 5) { + printf("error: TMFFS_PREFORMAT response has wrong length\n"); + return(ERROR_TARGET); + } + if (rvi_msg[3]) { + report_ffs_err("preformat", rvi_msg[3]); + return(ERROR_TARGET); + } + return(0); +}