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

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

?? am29lv160d_8x2.c

?? umon bootloader source code, support mips cpu.
?? C
字號:
/* am29lv160d_8x2.c:
 * Device interface for the AM29LV160D flash device configured for
 * x16 mode with 1 device in parallel.  
 */
#include "config.h"

#if INCLUDE_FLASH

#include "stddefs.h"
#include "cpu.h"
#include "flash.h"			/* Part of monitor common code */
#include "am29lv160d_8x2.h"

#define ftype 					volatile unsigned short
#define Is_ff(add)			   	(*(ftype *)add == 0xffff)
#define Is_not_ff(add)	    	(*(ftype *)add != 0xffff)
#define Is_Equal(p1,p2) 	    (*(ftype *)p1 == *(ftype *)p2)
#define Is_Not_Equal(p1,p2)		(*(ftype *)p1 != *(ftype *)p2)
#define Fwrite(to,frm)  	    (*(ftype *)to = *(ftype *)frm)
#define D5_Timeout(add)	   		((*(ftype *)add & 0x00df) == 0x0020)


#define SECTOR_ERASE(add)		{ \
		*(ftype *)(fdev->base+0xaaa) = 0xaaaa; \
		*(ftype *)(fdev->base+0x555) = 0x5555; \
		*(ftype *)(fdev->base+0xaaa) = 0x8080; \
		*(ftype *)(fdev->base+0xaaa) = 0xaaaa; \
		*(ftype *)(fdev->base+0x555) = 0x5555; \
		*(ftype *)add = 0x3030; }

#define FLASH_WRITE(dest,src)	{ 	\
		*(ftype *)(fdev->base+0xaaa) = 0xaaaa; \
		*(ftype *)(fdev->base+0x555) = 0x5555; \
		*(ftype *)(fdev->base+0xaaa) = 0xa0a0; \
		Fwrite(dest,src); }

#define AUTO_SELECT()			{	\
		*(ftype *)(fdev->base+0xaaa) = 0xaaaa; \
		*(ftype *)(fdev->base+0x555) = 0x5555; \
		*(ftype *)(fdev->base+0xaaa) = 0x9090; }

#define READ_RESET() 			{	\
		*(ftype *)(fdev->base) = 0xf0f0; \
		val = *(ftype *)(fdev->base); }


/* Am29lv160d_8x2_erase():
 * Based on the 'snum' value, erase the appropriate sector(s).
 * Return 0 if success, else -1.
 */
int
Am29lv160d_8x2_erase(struct flashinfo *fdev,int snum)
{
	ftype	val;
	ulong	add;
	int	ret, sector;

	ret = 0;
	add = (ulong)(fdev->base);

	/* Erase the request sector(s): */
	for (sector=0;sector<fdev->sectorcnt;sector++) {
		if ((!FlashProtectWindow) &&
		    (fdev->sectors[sector].protected)) {
			add += fdev->sectors[sector].size;
			continue;
		}
		if ((snum == ALL_SECTORS) || (snum == sector)) {
			register ulong *lp, *lp1;
			int	noterased;

			/* See if the sector is already erased: */
			noterased = 0;
			lp = (ulong *)fdev->sectors[sector].begin; 
			lp1 = (ulong *)((char *)lp + fdev->sectors[sector].size-1); 
			while(lp <= lp1) {
				if (*lp++ != 0xffffffff) {
					noterased = 1;
					break;
				}
			}
			if (noterased) {
				SECTOR_ERASE(add);

				/* Wait for sector erase to complete or timeout.. */
				/* DQ7 polling: wait for D7 to be 1. */
				/* DQ6 toggling: wait for D6 to not toggle. */
				/* DQ5 timeout: if DQ7 is 0, and DQ5 = 1, timeout. */
				while(1) {
					if (Is_ff(add)) {
						if (Is_ff(add))
							break;
					}
					if (D5_Timeout(add)) {
						if (Is_not_ff(add))
							ret = -1;
						break;
					}
				}
			}
		}
		add += fdev->sectors[sector].size;
	}

	/* If the erase failed for some reason, then issue the read/reset
	 * command sequence prior to returning...
	 */
	if (ret == -1)  {
		READ_RESET();
	}

	return(ret);
}

/* EndAm29lv160d_8x2_erase():
 * Function place holder to determine the end of the above function.
 */
void
EndAm29lv160d_8x2_erase(void)
{
}

/* Am29lv160d_8x2_write():
 * Copy specified number of bytes from source to destination.  The destination
 * address is assumed to be flash space.
 */
int
Am29lv160d_8x2_write(struct flashinfo *fdev,
	uchar *dest,uchar *src,long bytecnt)
{
	ftype	val;
	long	cnt;
	int		i, ret;
	uchar 	*src1;

	ret = 0;
	cnt = bytecnt & ~1;
	src1 = (uchar *)&val;

	/* Since we are working on a 2-byte wide device, every write to the
	 * device must be aligned on a 2-byte boundary.  If our incoming
	 * destination address is odd, then decrement the destination by one
	 * and build a fake source using *dest-1 and src[0]...
	 */
	if (NotAligned16(dest)) {
		dest--;
		
		src1[0] = *dest;
		src1[1] = *src;

		FLASH_WRITE(dest,src1);

		/* Wait for write to complete or timeout. */
		while(1) {
			if (Is_Equal(dest,src1)) {
				if (Is_Equal(dest,src1))
					break;
			}
			/* Check D5 for timeout... */
			if (D5_Timeout(dest)) {
				if (Is_Not_Equal(dest,src1)) {
					ret = -1;
					goto done;
				}
				break;
			}
		}

		dest += 2;
		src++;
		bytecnt--;
	}

	/* Each pass through this loop writes 'fdev->width' bytes...
	 */

	for (i=0;i<cnt;i+=fdev->width) {

		/* Just in case src is not aligned... */
		src1[0] = src[0];
		src1[1] = src[1];

		FLASH_WRITE(dest,src1);
		
		/* Wait for write to complete or timeout. */
		while(1) {
			if (Is_Equal(dest,src1)) {
				if (Is_Equal(dest,src1))
					break;
			}
			/* Check D5 for timeout... */
			if (D5_Timeout(dest)) {
				if (Is_Not_Equal(dest,src1)) {
					ret = -1;
					goto done;
				}
				break;
			}
		}
		dest += fdev->width; 
		src += fdev->width;
	}

	/* Similar to the front end of this function, if the byte count is not
	 * even, then we have one byte left to write, so we need to write a 
	 * 16-bit value by writing the last byte, plus whatever is already in
	 * the next flash location.
	 */
	if (cnt != bytecnt) {
		src1[0] = *src;
		src1[1] = dest[1];

		FLASH_WRITE(dest,src1);

		/* Wait for write to complete or timeout. */
		while(1) {
			if (Is_Equal(dest,src1)) {
				if (Is_Equal(dest,src1))
					break;
			}
			/* Check D5 for timeout... */
			if (D5_Timeout(dest)) {
				if (Is_Not_Equal(dest,src1)) {
					ret = -1;
					goto done;
				}
				break;
			}
		}
	}

done:
	READ_RESET();
	return(ret);
}

/* EndAm29lv160d_8x2_write():
 * Function place holder to determine the end of the above function.
 */
void
EndAm29lv160d_8x2_write(void)
{}

/* Am29lv160d_8x2_ewrite():
 * Erase all sectors that are part of the address space to be written,
 * then write the data to that address space.  This is basically a
 * concatenation of the above erase & write done in one step.  This is
 * necessary primarily for re-writing the bootcode; because after the boot
 * code is erased, there is nowhere to return so the re-write must be done
 * while executing out of ram also.  It is only needed in systems that are
 * executing the monitor out of the same device that is being updated.
 */
int
Am29lv160d_8x2_ewrite(struct flashinfo *fdev,
	ftype *dest,ftype *src,int bytecnt)
{
	int	i;
	ulong	add;
	void	(*reset)();
	ftype	val, *src1, *dest1;

	add = (ulong)(fdev->base);
	src1 = src;
	dest1 = dest;

	/* For each sector, if it overlaps any of the destination space
	 * then erase that sector.
	 */
	for (i=0;i<fdev->sectorcnt;i++) {
		if ((((uchar *)dest) > (fdev->sectors[i].end)) ||
		    (((uchar *)dest+bytecnt-1) < (fdev->sectors[i].begin))) {
			add += fdev->sectors[i].size;
			continue;
		}

		SECTOR_ERASE(add);

		/* Wait for sector erase to complete or timeout..
		 * DQ7 polling: wait for D7 to be 1.
		 * DQ6 toggling: wait for D6 to not toggle.
		 * DQ5 timeout: if DQ7 is 0, and DQ5 = 1, timeout.
		 */
		while(1) {
			if (Is_ff(add)) {
				if (Is_ff(add))
					break;
			}
		}
		add += fdev->sectors[i].size;
	}

	READ_RESET();

	for(i=0;i<bytecnt;i+=fdev->width) {
		FLASH_WRITE(dest,src);

		while(1) {
			if (Is_Equal(dest,src)) {
				if (Is_Equal(dest,src))
					break;
			}
		}

		dest++; 
		src++;
	}

	/* Issue the read/reset command sequence: */
	*(ftype *)(fdev->base + 0x555) = 0x00f0;
	val = *(ftype *)(fdev->base + 0x555);

	/* Wait till flash is readable, or timeout: */
	for(i=0;i<FLASH_TIMEOUT;i++) {
		if (Is_Equal(dest1,src1))
			break;
	}

	/* Now that the re-programming of flash is complete, reset: */
	reset = RESETFUNC();
	reset();

	return(0);	/* won't get here */
}

/* EndAm29lv160d_8x2_ewrite():
 * Function place holder to determine the end of the above function.
 */
void
EndAm29lv160d_8x2_ewrite(void)
{}


/* Am29lv160d_8x2_type():
 * Run the AUTOSELECT algorithm to retrieve the manufacturer and
 * device id of the flash.
 */
int
Am29lv160d_8x2_type(struct flashinfo *fdev)
{
	ftype	val;
	ushort	man, dev;
	ulong	id;

	AUTO_SELECT();

	man = *(ftype *)(fdev->base);		/* manufacturer ID */
	dev = *(ftype *)(fdev->base + 2);	/* device ID */
	id = man;
	id <<= 16;
	id |= dev;

	fdev->id = id;

	READ_RESET();

	return((int)(fdev->id));
}

/* EndAm29lv160d_8x2_type():
 * Function place holder to determine the end of the above function.
 */
void
EndAm29lv160d_8x2_type(void)
{}

/**************************************************************************
 **************************************************************************
 *
 * The remainder of the code in this file should only included if the
 * target configuration is such that this AM29F040 device is the only
 * real flash device in the system that is to be visible to the monitor.
 *
 **************************************************************************
 **************************************************************************
 */
#ifdef SINGLE_FLASH_DEVICE

/* FlashXXXFbuf[]:
 * If FLASH_COPY_TO_RAM is defined then these arrays will contain the
 * flash operation functions above.  To operate on most flash devices,
 * you cannot be executing out of it (there are exceptions, but
 * in general, we do not assume the flash supports this).  The flash
 * functions are copied here, then executed through the function
 * pointers established in the flashinfo structure below.
 * One obvious requirement...  The size of each array must be at least
 * as large as the function that it will contain.
 */
#ifdef FLASH_COPY_TO_RAM
ulong    FlashTypeFbuf[400];
ulong    FlashEraseFbuf[400];
ulong    FlashWriteFbuf[400];
ulong    FlashEwriteFbuf[400];
#endif

/* FlashNamId[]:
 * Used to correlate between the ID and a string representing the name
 * of the flash device.
 */
struct flashdesc FlashNamId[] = {
		{ AMD29DL160DT,	"AMD-29DL160DT" },
		{ AMD29DL160DB,	"AMD-29DL160DB" },
		{ 0, (char *)0 },
};

int	SectorSizes160DT[] = {	/* Top boot */
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x10000,
	0x04000, 0x04000, 0x08000,
};

int	SectorSizes160DB[] = {	/* Bottom boot */
	0x08000, 0x04000, 0x04000, 0x10000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000,
	0x20000, 0x20000, 0x20000,
};


struct sectorinfo sinfo160[sizeof(SectorSizes160DT)/sizeof(int)];

/* FlashInit():
 * Initialize data structures for each bank of flash...
 */
int
FlashInit()
{
	int	i,	snum, *sst;
	uchar	*begin;
	struct	flashinfo *fbnk;

	snum = 0;
	FlashCurrentBank = 0;

	/* Copy functions to ram space...
	 * Note that this MUST be done when cache is disabled to assure that
	 * the RAM is occupied by the designated block of code.
	 */

#ifdef FLASH_COPY_TO_RAM
	if (flashopload((ulong *)Am29lv160d_8x2_type,
		(ulong *)EndAm29lv160d_8x2_type,
		FlashTypeFbuf,sizeof(FlashTypeFbuf)) < 0)
		return(-1);

	if (flashopload((ulong *)Am29lv160d_8x2_erase,
		(ulong *)EndAm29lv160d_8x2_erase,
		FlashEraseFbuf,sizeof(FlashEraseFbuf)) < 0)
		return(-1);

	if (flashopload((ulong *)Am29lv160d_8x2_ewrite,
		(ulong *)EndAm29lv160d_8x2_ewrite,
		FlashEwriteFbuf,sizeof(FlashEwriteFbuf)) < 0)
		return(-1);

	if (flashopload((ulong *)Am29lv160d_8x2_write,
		(ulong *)EndAm29lv160d_8x2_write,
		FlashWriteFbuf,sizeof(FlashWriteFbuf)) < 0)
		return(-1);
#endif

	fbnk = &FlashBank[0];
	fbnk->base = (unsigned char *)FLASH_BANK0_BASE_ADDR;
	fbnk->end = fbnk->base + FLASH_BANK0_SIZE - 1;
	fbnk->sectorcnt = (sizeof(SectorSizes160DT)/sizeof(int));
	fbnk->width = FLASH_BANK0_WIDTH;

#ifdef FLASH_COPY_TO_RAM
	fbnk->fltype = (int(*)())FlashTypeFbuf;			/* flashtype(). */
	fbnk->flerase = (int(*)())FlashEraseFbuf;		/* flasherase(). */
	fbnk->flwrite = (int(*)())FlashWriteFbuf;		/* flashwrite(). */
	fbnk->flewrite = (int(*)())FlashEwriteFbuf;		/* flashewrite(). */
#else
	fbnk->fltype = Am29lv160d_8x2_type;
	fbnk->flerase = Am29lv160d_8x2_erase;
	fbnk->flwrite = Am29lv160d_8x2_write;
	fbnk->flewrite = Am29lv160d_8x2_ewrite;
#endif
	fbnk->fllock = FlashLockNotSupported;

	fbnk->sectors = sinfo160;
	fbnk->id = flashtype(fbnk);
	if (fbnk->id == AMD29DL160DT)
		sst = SectorSizes160DT;
	else if (fbnk->id == AMD29DL160DB)
		sst = SectorSizes160DB;
	else {
		printf("Bad flash id: 0x%lx\n",fbnk->id);
		return(-1);
	}

	begin = fbnk->base;
	for(i=0;i<fbnk->sectorcnt;i++,snum++) {
		int	ssize;

		ssize = sst[i];
		fbnk->sectors[i].snum = snum;
		fbnk->sectors[i].size = ssize;
		fbnk->sectors[i].begin = begin;
		fbnk->sectors[i].end = fbnk->sectors[i].begin + ssize - 1;
		fbnk->sectors[i].protected = 0;
		begin += ssize;
	}

	sectorProtect(FLASH_PROTECT_RANGE,1);

#if FLASHRAM_BASE
	FlashRamInit(snum, FLASHRAM_SECTORCOUNT, &FlashBank[FLASHRAM_BANKNUM],
		sinfoRAM, ramSectors);
#endif

	return(0);
}

#endif	/* SINGLE_FLASH_DEVICE */

#endif	/* INCLUDE_FLASH */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
奇米888四色在线精品| 亚洲精品国产无套在线观| 国产精品视频一二三区| 亚洲国产日韩精品| aaa欧美大片| 国产丝袜在线精品| 狠狠色狠狠色综合日日91app| 欧美手机在线视频| 亚洲制服丝袜在线| 99精品国产热久久91蜜凸| 中文文精品字幕一区二区| 成人性色生活片| 国产精品美女久久久久久| 成人app在线| 亚洲福利一区二区三区| 91精品久久久久久蜜臀| 国产精品66部| 亚洲综合av网| 国产欧美一区二区精品忘忧草| 国产精品一品二品| 亚洲女性喷水在线观看一区| 欧美在线视频不卡| 奇米一区二区三区| 国产农村妇女毛片精品久久麻豆| 91一区二区三区在线观看| 精品亚洲aⅴ乱码一区二区三区| 国产欧美日本一区视频| 在线成人av网站| 91在线精品一区二区三区| 久久99精品久久久久婷婷| 欧美国产日韩在线观看| 国产成都精品91一区二区三| 亚洲aaa精品| 国产精品国产三级国产aⅴ中文 | 精品福利一二区| 99re66热这里只有精品3直播| 亚洲成人激情综合网| 国产亚洲精品7777| 欧美v亚洲v综合ⅴ国产v| 色综合久久中文字幕综合网| 99精品久久只有精品| 懂色av一区二区三区免费观看| 国产一区二区三区蝌蚪| 国产乱码精品一区二区三区五月婷| 欧美bbbbb| 久久99热这里只有精品| 水野朝阳av一区二区三区| 亚洲国产综合色| 午夜伊人狠狠久久| 亚洲一区二区三区影院| 久久久青草青青国产亚洲免观| 日韩欧美亚洲另类制服综合在线| 欧美男男青年gay1069videost| 97aⅴ精品视频一二三区| 不卡av在线免费观看| 亚洲人成网站在线| 国产午夜亚洲精品午夜鲁丝片 | www.一区二区| 99麻豆久久久国产精品免费| 国产成人精品亚洲午夜麻豆| 不卡一区二区三区四区| 国产成人免费视频| 色综合久久久久网| 欧美刺激午夜性久久久久久久| 欧美一区二区三区思思人| 欧美mv日韩mv国产网站app| 中文字幕一区二区不卡| 中文字幕综合网| 久久精品国产99国产| 成人免费视频国产在线观看| 99国产欧美久久久精品| 国产亚洲午夜高清国产拍精品| 蜜桃在线一区二区三区| 欧美成人在线直播| 国产精品自在在线| 欧美国产激情一区二区三区蜜月| 国产精品资源站在线| 国产精品传媒在线| 91国产精品成人| 免费看日韩a级影片| 精品久久久久久久一区二区蜜臀| 美女网站色91| 国产精品久久久久久久第一福利 | 免费高清在线一区| 国产丝袜欧美中文另类| 色婷婷国产精品| 免费成人在线视频观看| 国产欧美中文在线| 欧美日韩小视频| 东方欧美亚洲色图在线| 综合色中文字幕| 91精品国产综合久久婷婷香蕉| 日日夜夜一区二区| 久久九九国产精品| 91传媒视频在线播放| 久久99精品国产| 亚洲国产精品久久艾草纯爱| 久久蜜桃av一区二区天堂| 成人h版在线观看| 琪琪一区二区三区| 亚洲精品视频在线观看免费 | 欧美亚洲国产一区在线观看网站| 亚洲一区二区三区四区五区中文| 精品国产乱码久久久久久浪潮| 不卡一区中文字幕| 粉嫩绯色av一区二区在线观看| 亚洲精品中文在线影院| 中文字幕 久热精品 视频在线 | 欧美日韩精品欧美日韩精品一| 国产一区日韩二区欧美三区| 日韩精品欧美成人高清一区二区| 亚洲欧美综合色| 中文字幕一区二区三区在线播放| 亚洲日本电影在线| 免费在线看成人av| 国产**成人网毛片九色| 91麻豆精品国产91久久久久久| 色婷婷综合久久久久中文一区二区 | 九九国产精品视频| 97aⅴ精品视频一二三区| 欧美色倩网站大全免费| 2020国产精品| 日本不卡一区二区三区 | 国产东北露脸精品视频| 国产91综合网| 色网站国产精品| 欧美男人的天堂一二区| 国产亚洲精品免费| 亚洲成人动漫在线观看| 国产精品一二三区在线| 欧美视频一区二区三区四区 | 国产精品香蕉一区二区三区| 在线观看网站黄不卡| 亚洲国产激情av| 日韩精品三区四区| 欧美伊人精品成人久久综合97| 欧美大片在线观看| 亚洲一区二区av在线| 国产精品一区二区久久精品爱涩| aa级大片欧美| 国产日产欧美一区二区视频| 日日摸夜夜添夜夜添精品视频| 成人少妇影院yyyy| 中文字幕一区二区三区蜜月| 精品在线你懂的| 欧美绝品在线观看成人午夜影视| 亚洲一区日韩精品中文字幕| 一本大道久久a久久精二百| 国产精品成人在线观看| 国产高清视频一区| 国产无人区一区二区三区| 成人听书哪个软件好| 国产欧美精品一区aⅴ影院 | 激情综合网激情| 中文字幕永久在线不卡| 一区二区三区精品视频在线| 国产一区中文字幕| 亚洲日本韩国一区| 日韩你懂的在线观看| 国产精品小仙女| 亚洲欧美日韩成人高清在线一区| 在线成人av网站| 色呦呦网站一区| 国产一区二区三区四| 午夜伦欧美伦电影理论片| 日韩美一区二区三区| 色又黄又爽网站www久久| 一区二区三区在线视频播放| 日本久久一区二区三区| 亚洲精品国产a| 精品国产污污免费网站入口 | 欧美三级电影网站| 国产精品99久久久久久宅男| 亚洲与欧洲av电影| 久久久99久久精品欧美| 色网综合在线观看| 国产盗摄女厕一区二区三区| 亚洲人123区| 成人欧美一区二区三区黑人麻豆| 日韩一区二区三区三四区视频在线观看 | 在线一区二区观看| 日韩在线观看一区二区| 国产精品久久久久久久久晋中 | 久久免费电影网| 日韩欧美亚洲一区二区| 欧美视频三区在线播放| 99久久伊人久久99| 成人白浆超碰人人人人| 精品一区二区三区免费| 日韩高清中文字幕一区| 日本美女一区二区| 另类成人小视频在线| 免费看黄色91| 国产乱码精品一区二区三| 国产老妇另类xxxxx| 成人a区在线观看| 欧美无人高清视频在线观看| 国产乱码精品一区二区三区av | 粉嫩av一区二区三区| 国产成人自拍网|