亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ian_xmodem.c

?? umon bootloader source code, support mips cpu.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* 
 * ian_xmodem.c
 *
 * X and Y modem file download and upload protocols.
 *
 * by Nick Patavalis (npat@inaccessnetworks.com)
 *
 *	General notice:
 *	This code is part of a boot-monitor package developed as a generic base
 *	platform for embedded system designs.  As such, it is likely to be
 *	distributed to various projects beyond the control of the original
 *	author.  Please notify the author of any enhancements made or bugs found
 *	so that all may benefit from the changes.  In addition, notification back
 *	to the author will allow the new user to pick up changes that may have
 *	been made by other users after this version of the code was distributed.
 *
 *	Note1: the majority of this code was edited with 4-space tabs.
 *	Note2: as more and more contributions are accepted, the term "author"
 *		   is becoming a mis-representation of credit.
 *
 *	Original author:	Ed Sutter
 *	Email:				esutter@lucent.com
 *	Phone:				908-582-2351
 *
 * $Id: ian_xmodem.c,v 2.0 2006/09/22 05:28:45 lxw Exp $
 */

/***************************************************************************/

#include "config.h"
#include "genlib.h"
#include "stddefs.h"
#include "flash.h"
#include "tfs.h"
#include "tfsprivate.h"
#include "cli.h"
#include "ascii.h"

/***************************************************************************/

#if INCLUDE_XMODEM

/* These "wait" functions may be better placed in chario.c.  They
 * are here for now, because this version of xmodem is the only
 * module that uses them.
 */

int
waitchar(int tmo)
{
	int timeout;
	int rval;

	timeout = tmo * LoopsPerSecond;
	while(!gotachar() && timeout)
		timeout--;
	if (timeout)
		rval = getchar();
	else
		rval = -1;

	return(rval);
}

void
waitclear (void)
{
	ulong timeout;

	while (1) {
		timeout = 1 * LoopsPerSecond;

		while(!gotachar() && timeout)
			timeout--;
		if (!timeout)
			break;
		getchar();
	}
}

int
waitbytes (char *buf, int cnt, int tmo)
{
	ulong timeout;
	int	i;

	for(i=0; i<cnt; i++) {
		timeout = tmo * LoopsPerSecond;
		while(!gotachar() && timeout)
			timeout--;
	    if (!timeout)
			break;
		buf[i] = (char)getchar();
	}
	return (i < cnt) ? -1 : i;
}

char ian_xmodem_cvsid[] = "$Id: ian_xmodem.c,v 2.0 2006/09/22 05:28:45 lxw Exp $";

/***************************************************************************/

/* RCV: Frame timeout. Time to wait for next frame, before sending a NAK */
#define FRAME_TMO  5
/* RCV: Character timeout. Characters in the same frame should normally 
   not be more than CHAR_TMO seconds appart */
#define CHAR_TMO   1
/* TRN: Transmiter timeout. Usually a large value. The standard suggests 
   something in the order of 1m */
#define TRANS_TMO  20
/* TRN: Number of times to retransmit a frame before quiting */
#define RETR_MAX   10
/* TRN: Number of invalid characters (i.e. not ACK or NAK) received 
   by the transmiter before quiting. This *not* the right way to do 
   things. The right way is to wait for a valid char up to TRANS_TMO 
   secs, and then quit. Unfortunatelly without timers, this behavior is 
   a bit tricky to implement. So this crude approxomation will have to do 
   for the moment. */
#define NOISE_MAX 100

/* Maximum number of files per Y-modem transfer */
#define YFILES_MAX 10

/***************************************************************************/

/* X/Ymodem protocol: */
#define SOH ASCII_SOH
#define STX ASCII_STX
#define EOT ASCII_EOT
#define ACK ASCII_ACK
#define NAK ASCII_NAK
#define CAN ASCII_CAN
#define ESC ASCII_ESC
#define BS  ASCII_BS

#define PKTLEN_128 128
#define PKTLEN_1K  1024

/***************************************************************************/

enum _xmodem_ops {
	XNULL = 0,
	XUP,
	XDOWN
};

enum _protocol_type {
	XMODEM = 0,
	YMODEM = 1
};

#define XERR_GEN  (-1)
#define XERR_TOUT (-2)
#define XERR_SYNC (-3)
#define XERR_CAN  (-4)
#define XERR_UCAN (-5)
#define XERR_RETR (-6)
#define XERR_HEAD (-7)
#define XERR_TFS  (-8)
#define XERR_NOFILE (-9)
#define XERR_NOSIZE (-10)

static char *xerr_msgs[] = {
	"E00:No Error",
	"E01:General Error",
	"E02:Timeout",
	"E03:Synchronization error",
	"E04:Operation canceled",
	"E05:Operation canceled by user",
	"E06:Maximum retransmitions exceeded",
	"E07:Invalid header-block",
	"E08:TFS error",
	"E09:File not found",
	"E10:Cannot determine file size"
};

/***************************************************************************/

/* struct yinfo:
 * used to pass information to and from the y-modem transfer functions.
 */
struct yinfo {	
	int usecrc;      /* use 16bit CRC instead of 8bit checksum */
	int onek;        /* use 1k blocks instead of 128bytes blocks */ 
	int verify;      /* operate in verification-mode */
	ulong baseaddr;  /* start address for the first file data transfer */
	char *flags;     /* TFS file flags (same for all files) */
	char *info;      /* TFS file info (same for all files) */

	int filecnt;                         /* number of files processed */
	char fname[YFILES_MAX][TFSNAMESIZE]; /* names of files processed */
	ulong dataddr[YFILES_MAX];           /* start address of each file */
	long size[YFILES_MAX];               /* size of each file in bytes */
	long pktcnt[YFILES_MAX];             /* number of frames exchanged */
	long errcnt[YFILES_MAX];             /* number of verification errors */
	ulong firsterrat[YFILES_MAX];        /* offset of first error */
};

/* struct xinfo:
 * used to pass information to and from the x-modem transfer functions.
 */
struct xinfo {
	int     usecrc;      /* use 16bit CRC instead of 8bit checksum */
	int     onek;        /* use 1k blocks instead of 128bytes blocks */ 
	int     verify;      /* operate in verification-mode */
	ulong	dataddr;	 /* start address for data transfer */
	long	size;	     /* size of the tansfer in bytes */
	int		pktcnt;		 /* number of packets processed */
	int		errcnt;		 /* number of errors (used in verify mode) */
	ulong	firsterrat;  /* pointer to location if first error (vrf mode) */
};

/***************************************************************************/

/* local prototypes */

static int Xup(struct xinfo *, int);
static int Xdown(struct xinfo *, int);
static int Ydown(struct yinfo *);
static int Yup(struct yinfo *);
static int getPacket(uchar *, int, int);
static void putPacket (uchar *, int, int, int);
static char *xerr_msg(int);
static void doCAN(void);

/***************************************************************************/

/* Defined globaly to conserve stack-space. Ugly but effective. */
static struct yinfo yif;
static struct xinfo xif;
static uchar pktbuff[PKTLEN_1K];

/* Used to pass-back the TFS error code, in case of a TFS error */
int tfserr;

/***************************************************************************/

char *XmodemHelp[] = {
	"X/Y modem file transfer",
#if INCLUDE_TFS
#if INCLUDE_FLASH
	"-[a:BckdF:f:i:s:t:uvy]",
#else /* of INCLUDE_FLASH */
	"-[a:ckdF:f:i:s:t:uvy]",
#endif /* of INCLUDE_FLASH */
#else /* of INCLUDE_TFS */
#if INCLUDE_FLASH
	"-[a:Bckds:t:uvy]",
#else /* of INCLUDE_FLASH */
	"-[a:ckds:t:uvy]",
#endif /* of INCLUDE_FLASH */
#endif /* of INCLUDE_TFS */
	"Options:",
	" -a{##}     address (overrides default of APPRAMBASE)",
#if INCLUDE_FLASH
	" -B         Program boot-sector (i.e. uMon-binary reload)",
#endif
	" -c         have xmodem receiver request the use of CRC (def = chksum)",
	"            have ymodem receiver request the use of chksum (def = CRC)",
	" -k         send 1K frames (default = 128bytes)",
	" -d         download",
#if INCLUDE_TFS
	" -F{name}   filename",
	" -f{flags}  file flags (see tfs)",
	" -i{info}   file info (see tfs)",
#endif
	" -s{##}     size (overrides computed size)",
	" -u         upload",
	" -v         verify only",
	" -y         use YMODEM extensions",
	"Notes:",
	" * Either -d or -u must be specified (-B implies -d).",
	" * The -c argument affects only the receiver (download operations).",
    "   The -k option affects only the transmitter (upload operations).",
#if INCLUDE_TFS
    " * YMODEM downloads: The file-name and size arguments are ignored,",
    "   since they are supplied by the sender. Multiple files can be",
    "   downloaded. Each file is downloaded at the address specified by",
    "   the '-a' argument (or at APPRAMBASE), and then saved to the TFS.",
    "   A summary of the files downloaded, their sizes and the download",
	"   locations is displayed at the end of the transfer.", 
#else /* of INCLUDE_TFS */
    " * YMODEM downloads: The file-name and size arguments are ignored,",
    "   since they are supplied by the sender. Multiple files can be",
    "   downloaded. The files are stored sequencially starting at the", 
    "   address specified with '-a' (or at APPRAMBASE). A summary of the",
    "   files downloaded, their sizes and the download locations is",
    "   displayed at the end of the transfer.",
#endif /* of INCLUDE_TFS */
#if INCLUDE_FLASH
    "   If -B is given, the boot-sector is programmed with the contents",
    "   of the last file downloaded.",
#endif
#if INCLUDE_TFS
	" * XMODEM downloads: Only one file can be downloaded. A 128-byte",
    "   modulo is forced on file size. The file is downloaded at the address",
    "   specified by '-a' (or at APPRAMBASE), and then saved to a TFS file",
    "   if a file-name argument is given. The '-s' option can be used to", 
    "   override the 128-bytes modulo when transferring a file to TFS.",
#else /* of INCLUDE_TFS */
	" * XMODEM downloads: Only one file can be downloaded. A 128-byte",
    "   modulo is forced on file size. The file is downloaded at the address",
    "   specified by '-a' (or at APPRAMBASE).",
#endif /* of INCLUDE_TFS */
#if INCLUDE_FLASH
    "   If -B is given, the boot-sector is programmed with the contents",
    "   of the downloaded file.",
#endif /* of INCLUDE_FLASH */
#if INCLUDE_TFS
    " * X/YMODEM uploads: Only one file can be uploaded. The size argument",
    "   is ignored since it is taken form the TFS. Before the file is", 
	"   uploaded it is copied at the address specified by '-a' (or at", 
    "   APPRAMBASE).",
#else /* of INCLUDE_TFS */
    " * X/YMODEM uploads: Only one file can be uploaded. The size argument",
    "   is mandatory (since there is no other way to know the number of", 
    "   bytes to transfer). The data (file) to be uploaded are taken form",
    "   the address specified by '-a' (or from APPRAMBASE).",
#endif /* of INCLUDE_TFS */
	(char *)0,
};

/***************************************************************************/

int
Xmodem(int argc,char *argv[])
{
#if INCLUDE_TFS
	TFILE	*tfp;
#endif
	char fname[TFSNAMESIZE+1], *info, *flags;
	int	opt, xop, newboot, usecrc, verify, onek, ymodem;
	ulong dataddr;
	long size;
	int i, r;

	/* Initialize to defaults */
	dataddr = getAppRamStart();
	xop = XNULL;
	newboot = 0;
	usecrc = 0;
	fname[0]='\0';
	info = (char *)0;
	flags = (char *)0;
	onek = 0;
	size = 0;
	verify = 0;
	ymodem = 0;

	/* Parse command line arguments */
	while ((opt=getopt(argc,argv,"a:Bci:f:dF:ks:uvy")) != -1) {
		switch(opt) {
		case 'a':
			dataddr = strtoul(optarg,(char **)0,0);
			break;
#if INCLUDE_FLASH
		case 'B':
			xop = XDOWN;
			newboot = 1;
			break;
#endif
		case 'c':
			usecrc = 1;
			break;
		case 'd':
			xop = XDOWN;
			break;
#if INCLUDE_TFS
		case 'F':
			strncpy(fname, optarg, TFSNAMESIZE);
			break;
		case 'f':
			flags = optarg;
			break;
		case 'i':
			info = optarg;
			break;
#endif
		case 'k':
			onek = 1;
			break;
		case 's':
			size = (ulong)strtoul(optarg,(char **)0,0);
			break;
		case 'u':
			xop = XUP;
			break;
		case 'v':
			verify = 1;
			break;
		case 'y':
			ymodem = 1;
			break;
		default:
			return(CMD_PARAM_ERROR);
		}
	}

	/* There should be no arguments after the option list. */
	if (argc != optind)
		return(CMD_PARAM_ERROR);

	if ( xop == XUP ) {

		/* UPLOAD: Host <-- Micromonitor */

		if ( ymodem ) {

			/* we 're using the Y-Modem extensions */

			yif.onek = onek;
			yif.baseaddr = dataddr;
			yif.filecnt = 1;
			if (fname && fname[0]) {
				strcpy(yif.fname[0], fname);
			} else {
				strcpy(yif.fname[0], "noname");
			}
			yif.size[0] = size;

#if ! INCLUDE_TFS
			if ( yif.size[0] <= 0 ) {
				printf("%s\n", xerr_msg(XERR_NOSIZE));
				return(CMD_FAILURE);
			}
#endif

			r = Yup(&yif);

			printf("\n");

			if ( yif.filecnt > 0 ) {
				printf("Sent %d file%s.\n",
					   yif.filecnt, (yif.filecnt > 1) ? "s" : "");
				for (i = 0; i < yif.filecnt; i++) {
					printf(" %s: %ld bytes, %ld blocks, @ 0x%08lx\n",
						   yif.fname[i] ? yif.fname[i] : "<noname>",
						   yif.size[i],
						   yif.pktcnt[i],
						   yif.dataddr[i]);
				}
			}

			if ( r < 0 ) {
				printf("%s\n", xerr_msg(r));
				return(CMD_FAILURE);
			}			

		} else {

			/* plain X-modem */

			xif.dataddr = dataddr;
			xif.size = size;
			xif.onek = onek;

			if ( fname && fname[0] ) {
#if INCLUDE_TFS
				if ( ! (tfp = tfsstat(fname)) ) {
					printf("%s\n", xerr_msg(XERR_NOFILE));
					return(CMD_FAILURE);
				}
				memcpy((char *)(xif.dataddr), TFS_BASE(tfp), tfp->filsize);
				xif.size = size = tfp->filsize;
#endif
			}

			if ( xif.size <= 0 ) {
				printf("%s\n", xerr_msg(XERR_NOSIZE));
				return(CMD_FAILURE);
			}

			r = Xup(&xif, XMODEM);

			printf("\n");

			if ( r < 0 ) {
				printf("%s\n", xerr_msg(r));
				return(CMD_FAILURE);
			}

			printf("Sent 1 file.\n");

			printf(" %s: %ld bytes, %d blocks, @ 0x%08lx\n",
				   fname[0] ? fname : "<no-name>",
				   xif.size,
				   xif.pktcnt,
				   xif.dataddr);
		}

	} else if ( xop == XDOWN ) {

		/* DOWNLOAD: Host --> Micromonitor */

		if ( ymodem ) {

			/* Use Y-Modem extensions */

			yif.baseaddr = dataddr;
			yif.usecrc = !usecrc;
			yif.verify = verify;
			yif.flags = flags;
			yif.info = info;

			r = Ydown(&yif);

			printf("\n");

			if ( yif.filecnt ) {
				printf("Rcvd %d file%s.\n",
					   yif.filecnt, (yif.filecnt > 1) ? "s" : "");
				if ( yif.verify ) {
					for (i = 0; i < yif.filecnt; i++) {
						printf(" %s: %ld bytes, %ld blocks, %ld errors, " 
							   "first err @ 0x%08lx\n",
							   yif.fname[i] ? yif.fname[i] : "<noname>",
							   yif.size[i],
							   yif.pktcnt[i],
							   yif.errcnt[i], yif.firsterrat[i]);
					}
				} else {
					for (i = 0; i < yif.filecnt; i++) {
						printf(" %s: %ld bytes, %ld blocks, @ 0x%08lx\n",
							   yif.fname[i] ? yif.fname[i] : "<noname>",
							   yif.size[i],
							   yif.pktcnt[i],
							   yif.dataddr[i]);
					}
				}
			}

			if ( r < 0 ) {
				if ( r == XERR_TFS ) {
					printf("%s: %s: %s\n",
						   xerr_msg(XERR_TFS),
						   yif.fname[yif.filecnt], 
						   (char *)tfsctrl(TFS_ERRMSG,tfserr,0));
				} else {
					printf("%s\n", xerr_msg(r));
				}
				return(CMD_FAILURE);
			}

		} else {

			/* plain X-Modem */

			xif.dataddr = dataddr;
			xif.usecrc = usecrc;
			xif.verify = verify;

			if (verify && fname && fname[0]) {
#if INCLUDE_TFS
				if (! (tfp = tfsstat(fname)) ) {
					printf("%s\n", xerr_msg(XERR_NOFILE));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区四区av| 国产精品精品国产色婷婷| 精品剧情v国产在线观看在线| 日韩欧美另类在线| 国产精品视频一二三区| 国产婷婷一区二区| 亚洲午夜在线视频| 国产激情精品久久久第一区二区| zzijzzij亚洲日本少妇熟睡| 正在播放一区二区| 久久亚洲综合色| 欧美精品第一页| 中文字幕视频一区二区三区久| 狂野欧美性猛交blacked| 欧美一级艳片视频免费观看| 国产98色在线|日韩| 国产精品美女久久久久久| 91麻豆自制传媒国产之光| 最新日韩在线视频| 日韩久久久久久| 色噜噜夜夜夜综合网| 亚洲一区二区三区免费视频| 欧美一区二区高清| 日韩国产高清影视| 2020国产精品自拍| 天堂在线一区二区| 欧美成人福利视频| 播五月开心婷婷综合| 色www精品视频在线观看| 欧美精品一区二区三区蜜桃| 精品视频123区在线观看| 成人精品免费看| 午夜成人免费视频| 亚洲视频网在线直播| 国产亚洲欧洲一区高清在线观看| 一本到不卡精品视频在线观看 | 亚洲综合一区二区三区| 日韩欧美一区二区久久婷婷| 色婷婷av一区二区| 成人18精品视频| 丁香激情综合国产| 粉嫩高潮美女一区二区三区| 日韩国产欧美在线观看| 水野朝阳av一区二区三区| 一区二区不卡在线播放| 国产精品乱码一区二区三区软件 | 国产一区二区三区精品欧美日韩一区二区三区| 亚洲婷婷综合色高清在线| 亚洲欧洲精品一区二区三区不卡 | 久久综合五月天婷婷伊人| 一区二区三区视频在线观看 | 欧美电视剧在线观看完整版| 狠狠色丁香婷婷综合| 成人开心网精品视频| 欧美最猛黑人xxxxx猛交| 日韩影院免费视频| 国产精品国产三级国产专播品爱网 | 日韩欧美一二三四区| 国产一区不卡视频| 亚洲精品国产第一综合99久久 | 欧美国产一区在线| 欧美久久久一区| 日韩欧美亚洲国产精品字幕久久久| 欧美精品一区二| 一区二区三区在线观看动漫| 久久国产日韩欧美精品| 国产日韩精品一区二区三区| av电影在线观看完整版一区二区| 亚洲一区二区三区四区在线| 2欧美一区二区三区在线观看视频| jizz一区二区| 麻豆91在线看| 亚洲国产日日夜夜| 国产欧美日韩麻豆91| 欧美高清视频一二三区| 91亚洲国产成人精品一区二区三 | 午夜精品久久久久久久99樱桃| 久久成人久久爱| 久久精品人人爽人人爽| 日韩美女久久久| 久久综合一区二区| 欧美高清视频www夜色资源网| 久久电影网电视剧免费观看| 亚洲一区二区三区在线播放| 中文字幕+乱码+中文字幕一区| 日韩一卡二卡三卡四卡| 欧美日韩一区三区| 91福利在线观看| 91看片淫黄大片一级| 精品中文字幕一区二区小辣椒| 亚洲综合男人的天堂| 亚洲美女视频在线| 亚洲日本在线观看| 亚洲图片激情小说| 国产精品福利在线播放| 国产农村妇女毛片精品久久麻豆 | 2017欧美狠狠色| 久久先锋影音av| 久久久久国产精品人| 亚洲国产岛国毛片在线| 国产精品久久久久影院老司| 中文字幕精品—区二区四季| 国产精品久久久久一区二区三区共| 国产午夜精品久久久久久久 | 懂色av一区二区夜夜嗨| 成人av综合一区| 欧美视频在线一区| 精品国产乱码久久久久久夜甘婷婷 | 欧美精品v国产精品v日韩精品| 欧美日韩精品一二三区| 久久午夜国产精品| 亚洲欧美乱综合| 理论电影国产精品| 99久久99久久精品免费看蜜桃| 国产精品一区二区在线观看不卡 | 毛片av一区二区三区| 韩国一区二区三区| 亚洲国产日日夜夜| 国产一区二区三区四| 经典三级一区二区| 国产精品亚洲综合一区在线观看| 免费在线一区观看| 美女脱光内衣内裤视频久久影院| 日韩电影在线一区| 麻豆国产精品官网| 国产馆精品极品| 成人午夜精品一区二区三区| 99久久99久久精品免费观看| 91蜜桃网址入口| 欧美日本一区二区三区| 日韩欧美中文一区二区| 欧美mv和日韩mv的网站| 国产欧美va欧美不卡在线| 自拍偷拍国产精品| 亚洲午夜在线电影| 蜜桃久久av一区| 国产传媒欧美日韩成人| thepron国产精品| 欧美日韩另类国产亚洲欧美一级| 日韩欧美激情在线| 中文字幕乱码日本亚洲一区二区 | 国产亚洲精品bt天堂精选| 中文字幕精品一区二区精品绿巨人 | 97久久精品人人澡人人爽| 欧洲一区在线电影| 欧美成va人片在线观看| 国产喷白浆一区二区三区| 亚洲精品国产一区二区三区四区在线| 一区二区三区成人| 久久国内精品视频| 91浏览器打开| 制服丝袜日韩国产| 国产精品三级视频| 日韩成人一级大片| 99国产精品久久久久久久久久久| 欧美一区二视频| 亚洲欧洲在线观看av| 男人的j进女人的j一区| 国产91富婆露脸刺激对白| 91精品国产欧美一区二区18| 久久免费美女视频| 亚洲成年人影院| 成人听书哪个软件好| 欧美美女直播网站| 中文字幕欧美一| 久久91精品国产91久久小草| 欧美羞羞免费网站| 日本一区二区动态图| 青青草原综合久久大伊人精品优势| 99久久精品99国产精品| 亚洲精品一区二区三区四区高清| 亚洲伦理在线免费看| 国产一区二区日韩精品| 91精品国产色综合久久不卡蜜臀| 亚洲欧洲国产专区| 国产成人午夜片在线观看高清观看| 欧美日韩另类一区| 一区二区三区四区激情| 成人午夜免费电影| 久久综合狠狠综合久久综合88| 丝袜美腿亚洲一区| 欧美日韩亚洲高清一区二区| 17c精品麻豆一区二区免费| 国产真实乱偷精品视频免| 8v天堂国产在线一区二区| 亚洲综合小说图片| 91看片淫黄大片一级在线观看| 国产精品伦一区二区三级视频| 国产高清精品在线| 国产欧美日韩卡一| 国产精品久99| 亚洲香肠在线观看| 国产在线不卡视频| 精品欧美乱码久久久久久 | 日韩黄色一级片| 欧美日韩高清不卡| 自拍偷拍欧美精品| 99热国产精品| 亚洲免费大片在线观看| 在线亚洲免费视频|