FreeCalypso > hg > freecalypso-sw
changeset 27:ae6294b8a015
loadtool: exit jump0 implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 May 2013 06:22:09 +0000 |
parents | 1a3bbab2ea26 |
children | 768a3d012931 |
files | loadtools/Makefile loadtools/ltdispatch.c loadtools/ltexit.c loadtools/ltmain.c |
diffstat | 4 files changed, 62 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/Makefile Sat May 04 05:38:58 2013 +0000 +++ b/loadtools/Makefile Sat May 04 06:22:09 2013 +0000 @@ -5,7 +5,7 @@ SERTOOL_OBJS= defpath.o hexdecode.o hwparam.o romload.o sercomm.o sertool.o \ srecreader.o ttypassthru.o -LOADTOOL_OBJS= defpath.o hexdecode.o hwparam.o ltdispatch.o ltmain.o \ +LOADTOOL_OBJS= defpath.o hexdecode.o hwparam.o ltdispatch.o ltexit.o ltmain.o \ ltpassthru.o romload.o sercomm.o srecreader.o tpinterf.o all: ${PROGS}
--- a/loadtools/ltdispatch.c Sat May 04 05:38:58 2013 +0000 +++ b/loadtools/ltdispatch.c Sat May 04 06:22:09 2013 +0000 @@ -10,14 +10,9 @@ extern char loadtool_command[]; +extern int cmd_exit(); extern int loadtool_cmd_passthru(); -static int -exitcmd() -{ - exit(0); -} - static struct cmdtab { char *cmd; int minargs; @@ -25,8 +20,8 @@ int (*func)(); } cmdtab[] = { {"dump", 2, 2, loadtool_cmd_passthru}, - {"exit", 0, 0, &exitcmd}, - {"quit", 0, 0, &exitcmd}, + {"exit", 0, 1, cmd_exit}, + {"quit", 0, 1, cmd_exit}, {"r8", 1, 1, loadtool_cmd_passthru}, {"r16", 1, 1, loadtool_cmd_passthru}, {"r32", 1, 1, loadtool_cmd_passthru},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/ltexit.c Sat May 04 06:22:09 2013 +0000 @@ -0,0 +1,55 @@ +/* + * This module implements the loadtool exit command, along with its + * options for jump-reboot or eventual Iota power-off. + */ + +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> + +static void +exit_bare() +{ + exit(0); +} + +static void +exit_jump0() +{ + static char *jump0_argv[3] = {"jump", "0", 0}; + + tpinterf_make_cmd(jump0_argv); + tpinterf_send_cmd(); + exit(0); +} + +void (*default_exit)() = exit_bare; + +static struct kwtab { + char *kw; + void (*func)(); +} exit_modes[] = { + {"bare", exit_bare}, + {"jump0", exit_jump0}, + {0, 0} +}; + +cmd_exit(argc, argv) + char **argv; +{ + struct kwtab *tp; + + if (argc < 2) + default_exit(); + for (tp = exit_modes; tp->kw; tp++) + if (!strcmp(tp->kw, argv[1])) + break; + if (!tp->func) { + fprintf(stderr, + "error: \"%s\" is not an understood exit mode\n", + argv[1]); + return(-1); + } + tp->func(); +}
--- a/loadtools/ltmain.c Sat May 04 05:38:58 2013 +0000 +++ b/loadtools/ltmain.c Sat May 04 06:22:09 2013 +0000 @@ -13,6 +13,8 @@ extern struct srecreader iramimage; extern char default_loadagent_image[]; +extern void (*default_exit)(); + char loadtool_command[512]; main(argc, argv) @@ -59,7 +61,7 @@ fflush(stdout); } if (!fgets(loadtool_command, sizeof loadtool_command, stdin)) - exit(0); + default_exit(); loadtool_dispatch_cmd(); } }