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

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

?? flash.c

?? 可移到ucos上的文件系統
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* flashcom.c:
 *	This file contains the portions of the flash code that are device
 *	independent.  Refer to the appropriate device sub-directory for the
 *	code that is specific to the flash device on the target.
 *
 *	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.
 *
 *	Author:	Ed Sutter
 *	email:	esutter@lucent.com		(home: lesutter@worldnet.att.net)
 *	phone:	908-582-2351			(home: 908-889-5161)
 */
#include "config.h"

#if INCLUDE_FLASH
#include "cpu.h"
#include "flashdev.h"
#include "flash.h"
#include "genlib.h"
#include "ctype.h"

#define printf mprintf	//m

typedef unsigned char uchar;
typedef unsigned long ulong;

extern struct flashdesc FlashNamId[];

int		FlashCurrentBank;
int		sectortoaddr(int,int *,uchar **);

extern	int FlashInit(void);

#define	SRANGE_ERROR	-1
#define	SRANGE_SINGLE	1
#define	SRANGE_RANGE	2
#define	SRANGE_ALL		3
	
/* FlashProtectWindow:
 *	Must be set to allow any flash operation to be done on space assumed
 *	to be software protected.
 */
int FlashProtectWindow;

/* FlashBank[]:
 *	This table contains all of the information that is needed to keep the
 *	flash code somewhat generic across multiple flash devices.
 */
extern struct	flashinfo FlashBank[FLASHBANKS];

#ifdef DISABLE_INTERRUPTS_DURING_FLASHOPS
#define FLASH_INTSOFF()				intsoff()
#define FLASH_INTSRESTORE(ival)		intsrestore(ival)
#else
#define FLASH_INTSOFF()				0
#define FLASH_INTSRESTORE(ival)
#endif

/* showflashtype():
 *	Find a match between the incoming id and an entry in the FlashNamId[]
 *	table.  The FlashNamId[] table is part of the device-specific code.
 */
int
showflashtype(ulong id)
{
	struct flashdesc *fdp;

	fdp = FlashNamId;
	while(fdp->desc) {
		if (id == fdp->id) {
			printf("Device = %s\n",fdp->desc);
			return(0);
		}
		fdp++;
	}
	printf("Flash id 0x%lx not recognized\n",id);
	return(-1);
}

int
showflashinfo(struct flashinfo *fdev)
{
	int	i;

	if (showflashtype(fdev->id) < 0)
		return(-1);

	printf("  Base addr   : 0x%08lx\n",(ulong)(fdev->base));
	printf("  Sectors     : %d\n",fdev->sectorcnt);
	printf("  Bank width  : %d\n",fdev->width);
	printf("  Sector     Begin       End        Size     SW-Protected?\n");
	for(i=0;i<fdev->sectorcnt;i++) {
		printf("    %2d    0x%08lx  0x%08lx  0x%06lx      %s\n",
		    fdev->sectors[i].snum,
			(ulong)(fdev->sectors[i].begin),
			(ulong)(fdev->sectors[i].end),
		    fdev->sectors[i].size,
		    fdev->sectors[i].protected ? "yes" : " no");
	}
	return(0);
}

/* flashopload():
 *	Copy flash operation to ram space.  
 *	Note that this function assumes that cache is disabled at this point.
 *	This is important because we are copying text into bss space and if
 *	cache was on, there could be a coherency problem.
 */
int
flashopload(ulong *begin,ulong *end,ulong *copy,int size)
{
	volatile ulong	*bp;
	int	ret;

	/* Verify space availability: */
	if (((int)end - (int)begin) >= size) {
		printf("flashopload overflow ((0x%lx-0x%lx) > 0x%x)\n",
			(ulong)end,(ulong)begin,size);
		return(-1);
	}

	ret = 0;
	/* Copy function() to RAM, then verify: */
	bp = begin;
	while(bp <= end) {
		*copy = *bp;
		if (*copy++ != *bp++) {
			printf("flashopload failed\n");
			ret = -1;
			break;
		}
	}

	return(ret);
}

/* flashtype():
 *	Use the device-specific function pointer to call the routine
 *	relocated to RAM space.
 */
int
flashtype(fdev)
struct flashinfo *fdev;
{
	return(fdev->fltype(fdev));
}

/* flasherase():
 *	Use the device-specific function pointer to call the routine
 *	relocated to RAM space.
 *	Note that flasherase() is called with a sector number.  The sector
 *	number is relative to the entire system, not just the particular device.
 *	This means that if there is more than one flash device in the system that
 *	the actual sector number (relative to the device) may not be the same
 *	value.  This adjustment is made here so that the underlying code that is
 *	pumped into ram for execution does not have to be aware of this.
 */
int
flasherase(fdev,snum)
struct	flashinfo *fdev;
int	snum;
{
	int	size;
	unsigned char *base, *end;

	if (fdev->id == FLASHRAM) {
		if (snum == ALL_SECTORS) {
			size = fdev->end - fdev->base;
			base = fdev->base;
		}
		else {
			sectortoaddr(snum,&size,&base);
		}
		end = base+size;
		while(base < end) {
			*base = 0xff;
			if (*base++ != 0xff)
				return(-1);
		}
		return(0);
	}

	if ((snum != ALL_SECTORS) && (fdev->sectors[0].snum != 0)) {
/*		printf("Adjusting snum from %d to",snum); */
		snum -= fdev->sectors[0].snum;
/*		printf(" %d.\n",snum); */
	}
	return(fdev->flerase(fdev,snum));
}

/* flashwrite():
 *	Use the device-specific function pointer to call the routine
 *	relocated to RAM space.
 *	First make a few checks on the request, then write to flash if all
 *	checks succeed.
 */
int
flashwrite(struct flashinfo *fdev,uchar *dest,uchar *src,long bytecnt)
{
	int	j, lowsector, highsector;
	register uchar	*dp, *sp, *edp;

	if (fdev->id == FLASHRAM) {
		uchar *sp, *dp, *end;
		sp = src;
		dp = dest;
		end = dp+bytecnt;
		while(dp < end) {
			*dp = *sp;
			if (*dp != *sp)
				return(-1);
			dp++; sp++;
		}
		return(0);
	}

	dp = dest;
	sp = src;
	edp = (dest + bytecnt) - 1;

	/* If outside the devices space, return failed.. */
	if ((edp < fdev->sectors[0].begin) ||
	    (dp > fdev->sectors[fdev->sectorcnt-1].end)) {
		printf("flashwrite() failed: dest out of flash range\n");
		return(-1);
	}

	/* Make sure the destination is not within a protected sector */
	if (FlashProtectWindow == FLASH_PROTECT_WINDOW_CLOSED) {

		/* First determine the sectors that overlap with the
		 * flash space to be written...
		 */

		lowsector = highsector = -1;
		for(j=0;j<fdev->sectorcnt;j++) {
			if ((dp >= fdev->sectors[j].begin) &&
			    (dp <= fdev->sectors[j].end))
				lowsector = j;
		}
		for(j=0;j<fdev->sectorcnt;j++) {
			if ((edp >= fdev->sectors[j].begin) &&
			    (edp <= fdev->sectors[j].end))
				highsector = j;
		}
		if ((lowsector == -1) || (highsector == -1)) {
			printf("flashwrite() failed: can't find sector\n");
			return(-1);
		}

		/* Now that the range of affected sectors is known,
		 * verify that those sectors are not protected...
		 */
		for(j=lowsector;j<=highsector;j++) {
			if (fdev->sectors[j].protected) {
				printf("flashwrite() failed: sector protected\n");
				return(-1);
			}
		}
	}

	/* Now make sure that there is no attempt to transition a bit
	 * in the affected range from 0 to 1...  A flash write can only
	 * bring bits low (erase brings them  high).
	 */
	while(dp < edp) {
		if ((*dp & *sp) != *sp) {
			printf("flashwrite() failed: bit 0->1 rqst denied.\n");
			return(-1);
		}
		dp++; 
		sp++;
	}
	return(fdev->flwrite(fdev,dest,src,bytecnt));
}

/* flashewrite():
 *	Use the device-specific function pointer to call the routine
 *	relocated to RAM space.
 */
int
flashewrite(struct flashinfo *fdev,uchar *dest,uchar *src,long bytecnt)
{
	int	i;

	/* Source and destination addresses must be long-aligned. */
	if (((int)src & 3) || ((int)dest & 3))
		return(-1);

	/* If the protection window is closed, then verify that no protected
	 * sectors will be written over...
	 */
	if (FlashProtectWindow == FLASH_PROTECT_WINDOW_CLOSED) {
		for (i=0;i<fdev->sectorcnt;i++) {
			if((((uchar *)dest) > (fdev->sectors[i].end)) ||
			    (((uchar *)dest+bytecnt) < (fdev->sectors[i].begin)))
				continue;
			else
				if (fdev->sectors[i].protected)
					return(-1);
		}
	}
	return(fdev->flewrite(fdev,dest,src,bytecnt));
}

/* addrtosector():
 *	Incoming address is translated to sector number, size of sector
 *	and base of sector.
 *	Return 0 if successful; else -1.
 */
int
addrtosector(uchar *addr,int *sector,int *size,uchar **base)
{
	struct flashinfo *fbnk;
	struct	sectorinfo *sinfo;
	int		dev, sec, i;

	sec = 0;
	for(dev=0;dev<FLASHBANKS;dev++) {
		fbnk = &FlashBank[dev];
		for(i=0;i<fbnk->sectorcnt;i++,sec++) {
			sinfo = &fbnk->sectors[i];
			if ((addr >= sinfo->begin) && (addr <= sinfo->end)) {
				if (sector) {
					*sector = sec;
				}
				if (base) {
					*base = sinfo->begin;
				}
				if (size) {
					*size = sinfo->size;
				}
				return(0);
			}
		}
	}
	printf("addrtosector(0x%lx) failed\n",(ulong)addr);
	return(-1);
}

/* addrtobank():
 *	From the incoming address, return a pointer to the flash bank that
 *	this address is within.
 */
struct flashinfo *
addrtobank(uchar *addr)
{
	struct flashinfo *fbnk;
	int		dev;

	for(dev=0;dev<FLASHBANKS;dev++) {
		fbnk = &FlashBank[dev];
		if ((addr >= fbnk->base) && (addr <= fbnk->end))
			return(fbnk);
	}
	printf("addrtobank(0x%lx) failed\n",(ulong)addr);
	return(0);
}

int
sectortoaddr(int sector,int *size,uchar **base)
{
	struct flashinfo *fbnk;
	struct	sectorinfo *sinfo;
	int		dev, sec, i;

	sec = 0;
	for(dev=0;dev<FLASHBANKS;dev++) {
		fbnk = &FlashBank[dev];
		for(i=0;i<fbnk->sectorcnt;i++,sec++) {
			if (sec == sector) {
				sinfo = &fbnk->sectors[i];
				if (base) *base = sinfo->begin;
				if (size) *size = sinfo->size;
				return(0);
			}
		}
	}
	printf("sectortoaddr(%d) failed\n",sector);
	return(-1);
}

/* flashbankinfo():
 *	Based on the incoming bank number, return the beginning, end and
 *	number of sectors within that bank.
 */
int
flashbankinfo(int bank,uchar **begin,uchar **end,int *sectorcnt)
{
	struct flashinfo *fbnk;

	if (bank >= FLASHBANKS)
		return(-1);

	fbnk = &FlashBank[bank];
	if (begin)
		*begin = fbnk->base;
	if (end)
		*end = fbnk->end;
	if (sectorcnt)
		*sectorcnt = fbnk->sectorcnt;
	return(0);
}

/* lastlargesector():
 *	Incoming bank number is used to populate the sector information
 *	(sector number, sector size and address) of the last large sector
 *	in the specified bank.
 *	Return 0 if successful; else -1.
 */
int
lastlargesector(int bank,int *sector,int *size,uchar **base)
{
	struct flashinfo	*fbnk;
	struct sectorinfo	*sinfo;
	uchar				*largest_sbase;
	int					i, largest_ssize, largest_snum;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区久久| 日韩一区二区三区视频| 国产经典欧美精品| 久久精品国产999大香线蕉| 日韩av在线免费观看不卡| 亚洲电影欧美电影有声小说| 亚洲一区二区三区影院| 亚洲国产cao| 日欧美一区二区| 蜜臀av一级做a爰片久久| 麻豆精品视频在线| 国产成人精品www牛牛影视| 成人的网站免费观看| 成人国产精品视频| 在线免费观看日本一区| 在线看日韩精品电影| 欧美日韩国产免费一区二区| 在线成人免费观看| 久久午夜免费电影| 欧美国产一区视频在线观看| 亚洲欧美自拍偷拍| 视频一区二区三区在线| 精品一区二区三区在线播放视频 | 欧美日韩精品三区| 欧美乱妇一区二区三区不卡视频| 91精品国产91久久久久久一区二区| 欧美一级欧美三级在线观看 | 成人午夜大片免费观看| 日本黄色一区二区| 日韩欧美国产一区二区在线播放| 久久久www成人免费毛片麻豆| 中文字幕精品三区| 亚洲国产成人av网| 国产成人在线色| 在线看日韩精品电影| 精品欧美一区二区三区精品久久| 国产精品进线69影院| 日日夜夜免费精品| 成人av在线资源网站| 欧美精品在线观看播放| 中文字幕中文字幕一区| 久久国产福利国产秒拍| 91捆绑美女网站| 精品久久久久久无| 亚洲综合男人的天堂| 国产乱码精品一区二区三区av| 色94色欧美sute亚洲线路一久| 精品国产一区久久| 婷婷开心激情综合| 91麻豆免费视频| 欧美精品一区二区三区很污很色的| 伊人色综合久久天天人手人婷| 九九在线精品视频| 欧美日本一道本| 亚洲品质自拍视频| 北岛玲一区二区三区四区| 精品奇米国产一区二区三区| 天天做天天摸天天爽国产一区| 91蜜桃在线观看| 亚洲国产精品成人久久综合一区| 麻豆精品一区二区av白丝在线| 欧美私人免费视频| 亚洲欧美aⅴ...| 成人午夜精品在线| 国产日本亚洲高清| 国产一区二区不卡老阿姨| 欧美一二三四在线| 日韩不卡一区二区三区| 欧美三级午夜理伦三级中视频| 亚洲人成电影网站色mp4| a4yy欧美一区二区三区| 中文字幕第一页久久| 国产一区999| 久久久一区二区三区| 国产一区二区三区最好精华液| 日韩视频一区二区三区 | 欧美国产日韩亚洲一区| 国产在线日韩欧美| 久久综合色鬼综合色| 激情久久五月天| 久久久国际精品| 国产福利91精品一区| 国产亚洲福利社区一区| 国产白丝网站精品污在线入口| 国产欧美一区二区三区网站| 国产99久久久久久免费看农村| 久久久精品蜜桃| 成人av网址在线| 综合色天天鬼久久鬼色| 91福利社在线观看| 日韩中文字幕1| 欧美岛国在线观看| 成人免费视频一区| 一区二区三区欧美| 制服丝袜激情欧洲亚洲| 国产一区二区三区在线观看免费视频| 精品av久久707| 成人av片在线观看| 亚洲va国产va欧美va观看| 911精品产国品一二三产区| 久久不见久久见中文字幕免费| 久久久91精品国产一区二区精品| 成人一级黄色片| 亚洲国产日韩在线一区模特| 欧美成人精品高清在线播放| 国产suv精品一区二区6| 亚洲日本乱码在线观看| 欧美日韩高清在线播放| 国产精品一二三四| 亚洲国产一区在线观看| 精品国产乱码久久久久久蜜臀| 成人h动漫精品一区二区| 日韩和欧美一区二区| 国产精品少妇自拍| 91麻豆精品91久久久久同性| 成人av免费在线| 蜜臀va亚洲va欧美va天堂| 亚洲视频一区二区在线观看| 欧美一级午夜免费电影| 91亚洲精品一区二区乱码| 精东粉嫩av免费一区二区三区| 综合分类小说区另类春色亚洲小说欧美| 欧美日韩不卡一区| 91亚洲资源网| 国产69精品久久777的优势| 日本一道高清亚洲日美韩| 国产精品国产馆在线真实露脸 | 国产亚洲美州欧州综合国| 欧美日韩视频专区在线播放| aaa欧美色吧激情视频| 国产一区二区三区四区五区美女| 亚洲综合色在线| 亚洲欧美日韩电影| 国产人伦精品一区二区| 精品三级av在线| 日韩欧美一区二区免费| 在线精品视频一区二区三四| 国产剧情一区二区| 韩国视频一区二区| 日韩不卡在线观看日韩不卡视频| 亚洲国产成人精品视频| 亚洲色图第一区| 亚洲欧洲另类国产综合| 国产欧美日韩久久| 精品国产免费一区二区三区四区 | 精品久久一区二区| 日韩无一区二区| 日韩女优电影在线观看| 91精品国产麻豆| 欧美一级电影网站| 欧美一区二区三区视频免费 | 国产精品久久久久久久久免费樱桃| 精品福利一二区| 久久一日本道色综合| 精品少妇一区二区三区视频免付费 | 成人一区二区在线观看| 国产v日产∨综合v精品视频| 国产乱人伦精品一区二区在线观看 | 亚洲一区二区五区| 亚洲一级二级在线| 亚洲chinese男男1069| 亚洲成人av一区二区| 五月天一区二区三区| 日本不卡1234视频| 看国产成人h片视频| 国产一区二区三区四区五区入口| 国产精品自拍三区| av不卡在线观看| 欧美日韩国产高清一区| 日韩精品一区国产麻豆| 久久综合狠狠综合久久激情| 国产欧美精品一区二区色综合| 国产精品午夜电影| 一区二区在线免费观看| 亚洲成人中文在线| 国产精品亚洲一区二区三区妖精| 成人免费毛片嘿嘿连载视频| 91网站最新地址| 555夜色666亚洲国产免| 久久久亚洲精品石原莉奈| 国产精品久久久久久久岛一牛影视 | 亚洲免费观看高清完整版在线观看 | 亚洲同性同志一二三专区| 亚洲一区二区在线播放相泽| 麻豆一区二区99久久久久| thepron国产精品| 91麻豆精品国产91久久久久久| 国产欧美日韩不卡免费| 亚洲国产中文字幕在线视频综合| 精品一区二区三区久久久| 91在线一区二区| 日韩视频一区二区| 玉足女爽爽91| 国产成人亚洲综合a∨婷婷| 欧美日韩精品欧美日韩精品一| 2024国产精品| 亚洲成人7777| 在线免费观看日本欧美| 国产情人综合久久777777| 日韩高清在线不卡|