FreeCalypso > hg > freecalypso-tools
changeset 204:064d4eedb3a6
loadtools: second program invokation support added to fc-iram like in fc-xram
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 01 May 2017 21:54:58 +0000 |
parents | f2dde45ba378 |
children | de8f75783b3b |
files | loadtools/Makefile loadtools/clmain.c loadtools/secondprog.c loadtools/sertool.c |
diffstat | 4 files changed, 51 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/Makefile Mon May 01 21:21:13 2017 +0000 +++ b/loadtools/Makefile Mon May 01 21:54:58 2017 +0000 @@ -10,8 +10,8 @@ COMPALRAM_OBJS= compalload.o compalram.o defpath.o sercomm.o ttypassthru.o IRAM_OBJS= defexitstub.o defpath.o flashstubs.o hexdecode.o hwparam.o \ - romload.o sercomm.o sertool.o srecreader.o ttypassthru.o \ - ${EXTRA_OBJ} + romload.o secondprog.o sercomm.o sertool.o srecreader.o \ + ttypassthru.o ${EXTRA_OBJ} LOADTOOL_OBJS= crc32tab.o defpath.o flashops.o flcmplboot.o flmain.o flmisc.o \ flprogbin.o flprogsrec.o flutil.o hexdecode.o hwparam.o \ @@ -20,8 +20,9 @@ srecreader.o tpinterf.o tpinterf2.o tpinterf3.o ${EXTRA_OBJ} XRAM_OBJS= chainload.o clmain.o defexitstub.o defpath.o flashstubs.o \ - hexdecode.o hwparam.o initscript.o labaud.o romload.o sercomm.o\ - srecreader.o tpinterf.o ttypassthru.o ${EXTRA_OBJ} + hexdecode.o hwparam.o initscript.o labaud.o romload.o \ + secondprog.o sercomm.o srecreader.o tpinterf.o ttypassthru.o \ + ${EXTRA_OBJ} BUZPLAY_OBJS= bpdispatch.o bpmain.o buzplay.o defpath.o flashstubs.o \ hexdecode.o hwparam.o labaud.o ltexit.o ltpassthru.o romload.o \
--- a/loadtools/clmain.c Mon May 01 21:21:13 2017 +0000 +++ b/loadtools/clmain.c Mon May 01 21:54:58 2017 +0000 @@ -116,28 +116,3 @@ tty_passthru(); exit(0); } - -exec_2nd_prog() -{ - char **execp_argv; - char **sp, **dp; - extern int target_fd; - char desc_arg[16]; - - sprintf(desc_arg, "-d%d", target_fd); - execp_argv = (char **) malloc(sizeof(char *) * (passon_argc + 2)); - if (!execp_argv) { - perror("malloc argv for execvp"); - exit(1); - } - sp = passon_argv; - dp = execp_argv; - *dp++ = *sp++; - *dp++ = desc_arg; - while (*sp) - *dp++ = *sp++; - *dp = NULL; - execvp(execp_argv[0], execp_argv); - fprintf(stderr, "Unable to execvp %s\n", passon_argv[0]); - exit(1); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/secondprog.c Mon May 01 21:54:58 2017 +0000 @@ -0,0 +1,36 @@ +/* + * This module contains the code for passing the serial channel to a + * second program, used by fc-iram and fc-xram. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +extern char **passon_argv; +extern int passon_argc; + +exec_2nd_prog() +{ + char **execp_argv; + char **sp, **dp; + extern int target_fd; + char desc_arg[16]; + + sprintf(desc_arg, "-d%d", target_fd); + execp_argv = (char **) malloc(sizeof(char *) * (passon_argc + 2)); + if (!execp_argv) { + perror("malloc argv for execvp"); + exit(1); + } + sp = passon_argv; + dp = execp_argv; + *dp++ = *sp++; + *dp++ = desc_arg; + while (*sp) + *dp++ = *sp++; + *dp = NULL; + execvp(execp_argv[0], execp_argv); + fprintf(stderr, "Unable to execvp %s\n", passon_argv[0]); + exit(1); +}
--- a/loadtools/sertool.c Mon May 01 21:21:13 2017 +0000 +++ b/loadtools/sertool.c Mon May 01 21:54:58 2017 +0000 @@ -16,6 +16,9 @@ extern struct srecreader iramimage; extern int gta_modem_poweron; +char **passon_argv; +int passon_argc; + main(argc, argv) char **argv; { @@ -52,14 +55,20 @@ "usage: fc-iram [options] ttyport iramimage.srec\n"); exit(1); } - if (argc - optind != 2) + if (argc - optind < 2) goto usage; target_ttydev = argv[optind]; iramimage.filename = argv[optind+1]; + if (argc - optind >= 3) { + passon_argv = argv + optind + 2; + passon_argc = argc - optind - 2; + } open_target_serial(); perform_compal_stage(1); perform_romload(); + if (passon_argv) + exec_2nd_prog(); tty_passthru(); exit(0); }