diff options
Diffstat (limited to 'cfe/cfe/ui/ui_tftpd.c')
-rwxr-xr-x | cfe/cfe/ui/ui_tftpd.c | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/cfe/cfe/ui/ui_tftpd.c b/cfe/cfe/ui/ui_tftpd.c new file mode 100755 index 0000000..6cd2e4e --- /dev/null +++ b/cfe/cfe/ui/ui_tftpd.c @@ -0,0 +1,119 @@ +/*************************************************************************** +*** +*** Copyright 2005 Hon Hai Precision Ind. Co. Ltd. +*** All Rights Reserved. +*** No portions of this material shall be reproduced in any form without the +*** written permission of Hon Hai Precision Ind. Co. Ltd. +*** +*** All information contained in this document is Hon Hai Precision Ind. +*** Co. Ltd. company private, proprietary, and trade secret property and +*** are protected by international intellectual property laws and treaties. +*** +****************************************************************************/ + +#include "lib_types.h" +#include "lib_string.h" +#include "lib_queue.h" +#include "lib_malloc.h" +#include "lib_printf.h" + +#include "cfe_iocb.h" +#include "cfe_devfuncs.h" +#include "cfe_ioctl.h" +#include "cfe_timer.h" +#include "cfe_error.h" + +#include "ui_command.h" +#include "cfe.h" + +#include "cfe_fileops.h" +#include "cfe_boot.h" +#include "bsp_config.h" + +#include "cfe_loader.h" + +#include "net_ebuf.h" +#include "net_ether.h" +#include "net_api.h" + +#include "cfe_flashimage.h" + +#include "addrspace.h" +#include "initdata.h" +#include "url.h" + +#include "tftpd.h" + +int ui_init_tftpdcmds(void); + +static int tftpd_state = TFTPD_STATE_OFF; + +extern int tftp_recv_timeout; + +int get_tftpd_state(void) +{ + return tftpd_state; +} + +int set_tftpd_state(int state) +{ + tftpd_state = state; + return 0; +} + +static int ui_cmd_tftpd(ui_cmdline_t *cmd,int argc,char *argv[]) +{ + int ret; + + xprintf("enter ui_cmd_tftpd \n"); + + if( (argc==1) && strcmp(argv[0], "nmrp") == 0 ) + { + xprintf("Start TFTP server for nmrp \n"); + ret = ui_docommand("flashimage nmrp"); + if (ret == CFE_ERR_TIMEOUT || ret == CFE_ERR_BADIMAGE || ret == CFE_ERR_IOERR || (ret == -24)) + { + //printf("Upgrade image failed!\n"); + return -1; + } + else + { + //printf("Upgrade image success!\n"); + return 0; + } + + + } + else + { + xprintf("Start TFTP server\n"); + /* Extend the TFTP server timeout */ + tftp_recv_timeout = 99999; + + while (1) + { + /* Foxconn modified start pling 12/04/2008 */ + //ret = ui_docommand("flash -writechksum : flash1.trx"); + ret = ui_docommand("flashimage :"); + /* Foxconn modified end pling 12/04/2008 */ + if (ret == CFE_ERR_TIMEOUT || ret == CFE_ERR_BADIMAGE || ret == CFE_ERR_IOERR) + continue; + else + break; + } + ui_docommand("reset"); + return 0; + } + +} +int ui_init_tftpdcmds(void) +{ + cmd_addcmd("tftpd", + ui_cmd_tftpd, + NULL, + "Start TFTP server", + "tftpd", + ""); + + return 0; +} |