FreeCalypso > hg > freecalypso-tools
changeset 69:2159f260ed13
fc-tmsh: all commands internally return values
in preparation for adding one-shot mode of operation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 26 Oct 2016 23:17:03 +0000 |
parents | 585f63e5bca6 |
children | 2c6dca514a20 |
files | rvinterf/tmsh/abb.c rvinterf/tmsh/audiocmd.c rvinterf/tmsh/etmbasic.c rvinterf/tmsh/ffs2.c rvinterf/tmsh/misc.c rvinterf/tmsh/omr.c rvinterf/tmsh/tmcore.c rvinterf/tmsh/usercmd.c |
diffstat | 8 files changed, 91 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/tmsh/abb.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/abb.c Wed Oct 26 23:17:03 2016 +0000 @@ -11,11 +11,11 @@ #include "limits.h" #include "localtypes.h" #include "etm.h" +#include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; -void cmd_abbr(argc, argv) char **argv; { @@ -26,12 +26,13 @@ reg = strtoul(argv[2], 0, 0); if (page > 1 || reg > 31) { printf("error: argument(s) out of range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_CODEC_RD; cmdpkt[3] = page << 5 | reg; send_etm_cmd(cmdpkt, 3); + return(0); } void @@ -55,7 +56,6 @@ async_msg_output(buf); } -void cmd_abbw(argc, argv) char **argv; { @@ -67,7 +67,7 @@ val = strtoul(argv[3], 0, 16); if (page > 1 || reg > 31 || val > 0x3FF) { printf("error: argument(s) out of range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_CODEC_WR; @@ -75,6 +75,7 @@ cmdpkt[4] = val; cmdpkt[5] = val >> 8; send_etm_cmd(cmdpkt, 5); + return(0); } void
--- a/rvinterf/tmsh/audiocmd.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/audiocmd.c Wed Oct 26 23:17:03 2016 +0000 @@ -10,8 +10,8 @@ #include "limits.h" #include "localtypes.h" #include "etm.h" +#include "exitcodes.h" -void cmd_audio_load(argc, argv) char **argv; { @@ -21,7 +21,7 @@ slen = strlen(argv[1]); if (slen > 9) { printf("error: audio config name is limited to 9 chars\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_AUDIO; @@ -29,9 +29,9 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_audio_save(argc, argv) char **argv; { @@ -41,7 +41,7 @@ slen = strlen(argv[1]); if (slen > 9) { printf("error: audio config name is limited to 9 chars\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_AUDIO; @@ -49,20 +49,20 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } static struct cmdtab { char *cmd; int minargs; int maxargs; - void (*func)(); + int (*func)(); } audio_cmds[] = { {"load", 1, 1, cmd_audio_load}, {"save", 1, 1, cmd_audio_save}, {0, 0, 0, 0} }; -void cmd_audio(argc, argv) char **argv; { @@ -74,16 +74,16 @@ break; if (!tp->func) { printf("error: no such audio command\n"); - return; + return(ERROR_USAGE); } extargs = argc - 2; if (extargs > tp->maxargs) { printf("error: too many arguments\n"); - return; + return(ERROR_USAGE); } if (extargs < tp->minargs) { printf("error: too few arguments\n"); - return; + return(ERROR_USAGE); } - tp->func(argc - 1, argv + 1); + return tp->func(argc - 1, argv + 1); }
--- a/rvinterf/tmsh/etmbasic.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/etmbasic.c Wed Oct 26 23:17:03 2016 +0000 @@ -11,6 +11,7 @@ #include "limits.h" #include "etm.h" #include "tm3.h" +#include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; @@ -72,7 +73,6 @@ } } -void cmd_tmpkt(argc, argv) char **argv; { @@ -90,6 +90,7 @@ } pkt[di++] = c; send_pkt_to_target(pkt, di); + return(0); } void
--- a/rvinterf/tmsh/ffs2.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/ffs2.c Wed Oct 26 23:17:03 2016 +0000 @@ -12,8 +12,8 @@ #include "etm.h" #include "ffs.h" #include "tmffs2.h" +#include "exitcodes.h" -void cmd_ffs2_close(argc, argv) char **argv; { @@ -23,9 +23,9 @@ cmdpkt[2] = TMFFS_CLOSE; cmdpkt[3] = strtoul(argv[1], 0, 0); send_etm_cmd(cmdpkt, 3); + return(0); } -void cmd_ffs2_delete(argc, argv) char **argv; { @@ -35,7 +35,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -44,9 +44,9 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_format(argc, argv) char **argv; { @@ -56,7 +56,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: argument exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -68,9 +68,9 @@ *dp++ = 0xAD; *dp++ = 0x2B; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_mkdir(argc, argv) char **argv; { @@ -80,7 +80,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -89,9 +89,9 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_open(argc, argv) char **argv; { @@ -101,7 +101,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -111,9 +111,9 @@ dp += slen + 1; *dp++ = strtoul(argv[2], 0, 16); send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_opendir(argc, argv) char **argv; { @@ -123,7 +123,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -132,9 +132,9 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_preformat() { u_char cmdpkt[6]; @@ -145,9 +145,9 @@ cmdpkt[3] = 0xAD; cmdpkt[4] = 0xDE; send_etm_cmd(cmdpkt, 4); + return(0); } -void cmd_ffs2_query(argc, argv) char **argv; { @@ -157,9 +157,9 @@ cmdpkt[2] = TMFFS_QUERY; cmdpkt[3] = strtoul(argv[1], 0, 0); send_etm_cmd(cmdpkt, 3); + return(0); } -void cmd_ffs2_readfd(argc, argv) char **argv; { @@ -170,9 +170,9 @@ cmdpkt[3] = strtoul(argv[1], 0, 0); cmdpkt[4] = strtoul(argv[2], 0, 0); send_etm_cmd(cmdpkt, 4); + return(0); } -void cmd_ffs2_readfile(argc, argv) char **argv; { @@ -182,7 +182,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -192,9 +192,9 @@ dp += slen + 1; *dp++ = strtoul(argv[2], 0, 0); send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_stat(argc, argv) char **argv; { @@ -204,7 +204,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -213,9 +213,9 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_version() { u_char cmdpkt[4]; @@ -223,9 +223,9 @@ cmdpkt[1] = ETM_FFS2; cmdpkt[2] = TMFFS_VERSION; send_etm_cmd(cmdpkt, 2); + return(0); } -void cmd_ffs2_wrfile(argc, argv) char **argv; { @@ -235,12 +235,12 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } slen2 = strlen(argv[2]); if (slen2 > 64) { printf("error: write test data argument is too long\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -253,9 +253,9 @@ dp += slen2; *dp++ = FFS_O_CREATE | FFS_O_TRUNC; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_writefd(argc, argv) char **argv; { @@ -265,7 +265,7 @@ slen2 = strlen(argv[2]); if (slen2 > 64) { printf("error: write test data argument is too long\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -275,9 +275,9 @@ strcpy(dp, argv[2]); dp += slen2; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } -void cmd_ffs2_xlstat(argc, argv) char **argv; { @@ -287,7 +287,7 @@ slen = strlen(argv[1]); if (slen >= TMFFS_STRING_SIZE) { printf("error: pathname arg exceeds string length limit\n"); - return; + return(ERROR_USAGE); } dp = cmdpkt + 1; *dp++ = ETM_FFS2; @@ -296,13 +296,14 @@ strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); + return(0); } static struct cmdtab { char *cmd; int minargs; int maxargs; - void (*func)(); + int (*func)(); } ffs2_cmds[] = { {"close", 1, 1, cmd_ffs2_close}, {"delete", 1, 1, cmd_ffs2_delete}, @@ -322,7 +323,6 @@ {0, 0, 0, 0} }; -void cmd_ffs2(argc, argv) char **argv; { @@ -334,16 +334,16 @@ break; if (!tp->func) { printf("error: no such ffs2 command\n"); - return; + return(ERROR_USAGE); } extargs = argc - 2; if (extargs > tp->maxargs) { printf("error: too many arguments\n"); - return; + return(ERROR_USAGE); } if (extargs < tp->minargs) { printf("error: too few arguments\n"); - return; + return(ERROR_USAGE); } - tp->func(argc - 1, argv + 1); + return tp->func(argc - 1, argv + 1); }
--- a/rvinterf/tmsh/misc.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/misc.c Wed Oct 26 23:17:03 2016 +0000 @@ -11,7 +11,6 @@ #include "etm.h" #include "tmffs1.h" -void cmd_check_ffs1(argc, argv) char **argv; { @@ -21,4 +20,5 @@ cmdpkt[2] = FPI_TMFFS_VERSION; cmdpkt[3] = FPI_END; send_etm_cmd(cmdpkt, 3); + return(0); }
--- a/rvinterf/tmsh/omr.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/omr.c Wed Oct 26 23:17:03 2016 +0000 @@ -11,6 +11,7 @@ #include "limits.h" #include "localtypes.h" #include "tm3.h" +#include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; @@ -68,7 +69,6 @@ } } -void cmd_omr(argc, argv) char **argv; { @@ -79,7 +79,7 @@ size = strtoul(argv[2], 0, 16); if (size < 1 || size > TM3_MEMREAD_MAX) { printf("error: count argument outside valid range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = MEM_READ; cmdpkt[2] = addr; @@ -91,4 +91,5 @@ cmdpkt[8] = 0; cmdpkt[9] = 0; send_etm_cmd(cmdpkt, 9); + return(0); }
--- a/rvinterf/tmsh/tmcore.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/tmcore.c Wed Oct 26 23:17:03 2016 +0000 @@ -12,6 +12,7 @@ #include "limits.h" #include "localtypes.h" #include "etm.h" +#include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; @@ -194,7 +195,6 @@ } } -void cmd_r8(argc, argv) char **argv; { @@ -209,7 +209,7 @@ count = 1; if (count < 1 || count > 253) { printf("error: count argument outside valid range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; @@ -220,9 +220,9 @@ cmdpkt[7] = addr >> 16; cmdpkt[8] = addr >> 24; send_etm_cmd(cmdpkt, 8); + return(0); } -void cmd_r16(argc, argv) char **argv; { @@ -237,11 +237,11 @@ count = 1; if (addr & 1) { printf("error: address not aligned\n"); - return; + return(ERROR_USAGE); } if (count < 1 || count > 126) { printf("error: count argument outside valid range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; @@ -252,9 +252,9 @@ cmdpkt[7] = addr >> 16; cmdpkt[8] = addr >> 24; send_etm_cmd(cmdpkt, 8); + return(0); } -void cmd_r32(argc, argv) char **argv; { @@ -269,11 +269,11 @@ count = 1; if (addr & 3) { printf("error: address not aligned\n"); - return; + return(ERROR_USAGE); } if (count < 1 || count > 63) { printf("error: count argument outside valid range\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; @@ -284,9 +284,9 @@ cmdpkt[7] = addr >> 16; cmdpkt[8] = addr >> 24; send_etm_cmd(cmdpkt, 8); + return(0); } -void cmd_w8(argc, argv) char **argv; { @@ -310,9 +310,9 @@ cmdpkt[di++] = v; } send_etm_cmd(cmdpkt, di - 1); + return(0); } -void cmd_w16(argc, argv) char **argv; { @@ -324,7 +324,7 @@ addr = strtoul(argv[1], 0, 16); if (addr & 1) { printf("error: address not aligned\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; @@ -341,9 +341,9 @@ cmdpkt[di++] = v >> 8; } send_etm_cmd(cmdpkt, di - 1); + return(0); } -void cmd_w32(argc, argv) char **argv; { @@ -355,7 +355,7 @@ addr = strtoul(argv[1], 0, 16); if (addr & 3) { printf("error: address not aligned\n"); - return; + return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; @@ -374,9 +374,9 @@ cmdpkt[di++] = v >> 24; } send_etm_cmd(cmdpkt, di - 1); + return(0); } -void cmd_dieid(argc, argv) char **argv; { @@ -385,9 +385,9 @@ cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_DIEID; send_etm_cmd(cmdpkt, 2); + return(0); } -void cmd_ping(argc, argv) char **argv; { @@ -398,7 +398,7 @@ delay = strtoul(argv[1], 0, 0); if (delay > 65535) { printf("error: ping delay argument too big\n"); - return; + return(ERROR_USAGE); } } else delay = 0; @@ -406,7 +406,7 @@ size = strtoul(argv[2], 0, 0); if (size > 240) { printf("error: ping size argument too big\n"); - return; + return(ERROR_USAGE); } } else size = 1; @@ -417,9 +417,9 @@ cmdpkt[5] = size; cmdpkt[6] = size >> 8; send_etm_cmd(cmdpkt, 6); + return(0); } -void cmd_tgtreset(argc, argv) char **argv; { @@ -428,9 +428,9 @@ cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_RESET; send_etm_cmd(cmdpkt, 2); + return(0); } -void cmd_version(argc, argv) char **argv; { @@ -445,4 +445,5 @@ cmdpkt[5] = arg >> 16; cmdpkt[6] = arg >> 24; send_etm_cmd(cmdpkt, 6); + return(0); }
--- a/rvinterf/tmsh/usercmd.c Wed Oct 26 22:56:29 2016 +0000 +++ b/rvinterf/tmsh/usercmd.c Wed Oct 26 23:17:03 2016 +0000 @@ -11,25 +11,24 @@ extern char usercmd[]; -extern void cmd_abbr(); -extern void cmd_abbw(); -extern void cmd_audio(); -extern void cmd_check_ffs1(); -extern void cmd_dieid(); -extern void cmd_ffs2(); -extern void cmd_omr(); -extern void cmd_ping(); -extern void cmd_r8(); -extern void cmd_r16(); -extern void cmd_r32(); -extern void cmd_tgtreset(); -extern void cmd_tmpkt(); -extern void cmd_version(); -extern void cmd_w8(); -extern void cmd_w16(); -extern void cmd_w32(); +extern int cmd_abbr(); +extern int cmd_abbw(); +extern int cmd_audio(); +extern int cmd_check_ffs1(); +extern int cmd_dieid(); +extern int cmd_ffs2(); +extern int cmd_omr(); +extern int cmd_ping(); +extern int cmd_r8(); +extern int cmd_r16(); +extern int cmd_r32(); +extern int cmd_tgtreset(); +extern int cmd_tmpkt(); +extern int cmd_version(); +extern int cmd_w8(); +extern int cmd_w16(); +extern int cmd_w32(); -void cmd_exit() { tty_cleanup(); @@ -40,7 +39,7 @@ char *cmd; int minargs; int maxargs; - void (*func)(); + int (*func)(); } cmdtab[] = { {"abbr", 2, 2, cmd_abbr}, {"abbw", 3, 3, cmd_abbw},