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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? smc_core_2440.c

?? Supervivi的源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * vivi/drivers/mtd/nand/smc_core.c:  * * Based on linux/drivers/mtd/nand/smc.c * * $Id: smc_core_2440.c,v 1.1.1.1 2004/02/04 06:22:25 laputa Exp $ * * */#include "config.h"#include "mtd/mtd.h"#include "mtd/nand.h"#include "mtd/nand_ids.h"#include "mtd/nand_ecc.h"#include "time.h"#include "printk.h"#include <types.h>#include <errno.h>/* * Macros for low-level register control */#define NF_CLEAR_RB()	{NFSTAT |= NFSTAT_RnB;}#define NF_DETECT_RB()	{while(!(NFSTAT & NFSTAT_RnB));}#if 0#define nand_select()	\		do \		{\			this->hwcontrol(NAND_CTL_SETNCE); \			nand_command(mtd, NAND_CMD_RESET, -1, -1); \			NF_DETECT_RB();\			NF_CLEAR_RB();\		}\		while (0)#endif#define nand_select()	\		do \		{\			this->hwcontrol(NAND_CTL_SETNCE); \			nand_command(mtd, NAND_CMD_RESET, -1, -1); \		}\		while (0)#define nand_deselect()	this->hwcontrol(NAND_CTL_CLRNCE);static inline void sm_swap(u_char *x, u_char *y) {	u_char tmp;	tmp = *x;	*x = *y;	*y = tmp;}/* define if you'll be using < 2M SMC device */#undef USE_256BYTE_NAND_FLASH/* * Send command to NAND device */static voidnand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr){	register struct nand_chip *this = mtd->priv;	/* Begin command latch cycle */	this->hwcontrol(NAND_CTL_SETCLE);	this->hwcontrol(NAND_CTL_DAT_OUT);	/*	 * Write out the command to the device.	 */	if (command != NAND_CMD_SEQIN)		this->write_cmd(command);	else {		if (mtd->oobblock == 256 && column >= 256) {			column -= 256;			this->write_cmd(NAND_CMD_RESET);			this->write_cmd(NAND_CMD_READOOB);			this->write_cmd(NAND_CMD_SEQIN);		} else if (mtd->oobblock == 512 && column >= 256) {			if (column < 512) {				column -= 256;				this->write_cmd(NAND_CMD_READ1);				this->write_cmd(NAND_CMD_SEQIN);			} else {				column -= 512;				this->write_cmd(NAND_CMD_READOOB);				this->write_cmd(NAND_CMD_SEQIN);			}		} else {			this->write_cmd(NAND_CMD_READ0);			this->write_cmd(NAND_CMD_SEQIN);		}	}	/* Set ALE and clear CLE to start address cycle */	this->hwcontrol(NAND_CTL_CLRCLE);	this->hwcontrol(NAND_CTL_SETALE);	/* Serially input address */	if (column != -1)		this->write_addr(column);	if (page_addr != -1) {		this->write_addr((u_char)(page_addr & 0xff));		this->write_addr((u_char)((page_addr >> 8) & 0xff));		/* One more address cycle for higher density devices */		if (mtd->size & 0x0c000000) {			this->write_addr((u_char)((page_addr >> 16) & 0xff));		}	}	/* Latch in address */	this->hwcontrol(NAND_CTL_CLRALE);		this->hwcontrol(NAND_CTL_DAT_IN);	/* Pause for 15us */	udelay(15); }/* * NAND read */static intnand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf){	int j, col, page, state;	struct nand_chip *this = mtd->priv;	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__"(): from = 0x%08lx, len = %i\n",		(unsigned int)from, (int)len);	/* Do not allow reads past end of device */	if ((from + len) > mtd->size) {		DEBUG(MTD_DEBUG_LEVEL0,			__FUNCTION__"(): Attempt read beyond end of device\n");		*retlen = 0;		return -EINVAL;	}	/* First we calculate the starting page */	page = from >> this->page_shift;	/* Get raw starting column */	col = from & (mtd->oobblock - 1);	/* State machine for devices having pages larger than 256 bytes */	state = (col < mtd->eccsize) ? 0 : 1;	/* Calculate column address within ECC block context */	col = (col >= mtd->eccsize) ? (col - mtd->eccsize) : col;	/* Initialize return value */	*retlen = 0;	/* Select the NAND device */	nand_select();	/* Loop until all data read */	while (*retlen < len) {		/* Send the read command */		if (!state)			nand_command(mtd, NAND_CMD_READ0, col, page);		else			nand_command(mtd, NAND_CMD_READ1, col, page);		this->wait_for_ready();		/* Read the data directly into the return buffer */		if ((*retlen + (mtd->eccsize - col)) >= len) {			while (*retlen < len)				buf[(*retlen)++] = this->read_data();			/* We're done */			continue;		} else {			for (j = col; j < mtd->eccsize; j++)				buf[(*retlen)++] = this->read_data();		}		/*		 * If the amount of data to be read is greater than		 * (256 - col), then all subsequent reads will take		 * place on page or half-page (in the case of 512 byte		 * page devices) aligned boundaries and the column		 * address will be zero. Setting the column address to		 * zero after the first read allows us to simplify		 * the reading of data and the if/else statements above.		 */		if (col)			col = 0x00;		/* Increment page address */		if ((mtd->oobblock == 256) || state)			page++;		/* Toggle state machine */		if (mtd->oobblock == 512)			state = state ? 0 : 1;	}	/* De-select the NAND device */	nand_deselect();	/* Return happy */	return 0;	}/* * if mtd->oobblock == 512 */inline intsmc_read_ecc_512(struct mtd_info *mtd, u_char *ecc_code){	struct nand_chip *this = mtd->priv;	u_char ecc_calc[3];	int j, ret;	/* Read in a block big enough for ECC */	for (j = 0; j < (mtd->oobblock + mtd->oobsize); j++)		this->data_buf[j] = this->read_data();	for (j = 0; j < mtd->oobsize; j++)		ecc_code[j] = this->data_buf[(mtd->oobblock + j)];	nand_calculate_ecc(&this->data_buf[0], &ecc_calc[0]);	sm_swap(&ecc_calc[0], &ecc_calc[1]);	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__"(): ECC [%02x%02x%02x : %02x%02x%02x]\n",		ecc_code[SMC_OOB_ECC1], ecc_code[SMC_OOB_ECC1+1],		ecc_code[SMC_OOB_ECC1+2], ecc_calc[0], ecc_calc[1], ecc_calc[2]);	ret = nand_correct_data(&this->data_buf[0],				&(ecc_code[SMC_OOB_ECC1]), &ecc_calc[0]);	if (ret == -1)		return ret;	nand_calculate_ecc(&this->data_buf[mtd->eccsize], &ecc_calc[0]);	sm_swap(&ecc_calc[0], &ecc_calc[1]);	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__"(): ECC [%02x%02x%02x : %02x%02x%02x]\n",		ecc_code[SMC_OOB_ECC2], ecc_code[SMC_OOB_ECC2+1],		ecc_code[SMC_OOB_ECC2+2], ecc_calc[0], ecc_calc[1], ecc_calc[2]);	ret = nand_correct_data(&this->data_buf[mtd->eccsize],				&(ecc_code[SMC_OOB_ECC2]), &ecc_calc[0]);	if (ret == -1)		return ret;	return 0;}/* * NAND read with ECC */static intnand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,              u_char *buf, u_char *ecc_code){	int j, offset, page;	struct nand_chip *this = mtd->priv;	int ret;	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__ "(): from = 0x%08x, len = %i\n", (unsigned int)from,		(int)len);	/* Do not allow reads past end of device */	if ((from + len) > mtd->size) {		DEBUG(MTD_DEBUG_LEVEL0,			__FUNCTION__ "(): Attempt read beyond end of device\n");		*retlen = 0;		return -EINVAL;	}	/* Select the NAND device */	nand_select();	/* Initialize return value */	*retlen = 0;#ifdef USE_256BYTE_NAND_FLASH	/* First we calculate the starting page */	page = from >> this->page_shift;	/* Get raw starting column */	offset = from & (mtd->oobblock - 1);	/* if the length of Page is 256bytes,	 * 2 Pages must be taken for 1 Sector and as a result,	 * higher level 8 bytes of information	 * among the above 16 byte information must coincide with	 * Spare(or OOB) of Even-Page while lowel level 8 bytes	 * coincide with Spar(or OOB) of Odd-page.	 *   i.e, [0 block][oob][1 block][oob]	 *        [2 block][oob][3 block][oob]...	 */	if (mtd->oobblock == 256) {		u_char ecc_calc[3];		int oob_offset;		/* Loop until all data read */		while (*retlen < len) {			nand_command(mtd, NAND_CMD_READ0, 0x00, page);			this->wait_for_ready();			/* Read in a block big enough for ECC */			for (j = 0; j < mtd->eccsize; j++)				this->data_buf[j] = this->read_data();			if (!(page & 0x1)) {	/* page is odd! */				nand_command(mtd, NAND_CMD_READOOB,					     SMC_OOB256_ECC1, page + 1);				oob_offset = SMC_OOB_ECC1;			} else {				nand_command(mtd, NAND_CMD_READOOB,					     SMC_OOB256_ECC2, page);				oob_offset = SMC_OOB_ECC2;			}			this->wait_for_ready();			for (j = 0; j < 3; j++)				ecc_code[oob_offset + j] = this->read_data();			nand_calculate_ecc(&this->data_buf[0], &ecc_calc[0]);			sm_swap(&ecc_calc[0], &ecc_calc[1]);			ret = nand_correct_data(&this->data_buf[0], 						&(ecc_code[oob_offset]), 						&ecc_calc[0]);			if (ret == -1)				goto nand_read_ecc_err;			/* Read the data from ECC data buffer into return buffer */			if ((*retlen + (mtd->eccsize - offset)) > = len) {				while (*retlen < len)					buf[(*retlen)++] = this->data_buf[offset++];				/* We're done */				continue;			} else {				for (j = offset; j < mtd->eccsize; j++)					buf[(*retlen)++] = this->data_buf[j];			}			/*			 * If the amount of data to be read is greater than			 * (256 - offset), then all subsequent reads will take			 * place on page or half-page (in the case of 512 byte			 * page devices) aligned boundaries and the column			 * address will be zero. Setting the column address to			 * to zero after the first read allows us to simplify			 * the reading of data and the if/else statements above.			 */			if (offset)				offset = 0x00;			/* Increment page address */			page++;		}	} 	else #endif	/* USE_256BYTE_NAND_FLASH */	{ /* mtd->oobblock == 512 */		size_t last, next, len2;		last = from + len;		for (next = from; from < last; ) {			page = from >> this->page_shift;			offset = from & (mtd->oobblock - 1);			len2 = mtd->oobblock - offset;			next += len2;			nand_command(mtd, NAND_CMD_READ0, 0x00, page);			this->wait_for_ready();			ret = smc_read_ecc_512(mtd, ecc_code);			if (ret == -1)				goto nand_read_ecc_err;			if (next >= last)				if ((last & (mtd->oobblock - 1)) != 0)					len2 = (last & (mtd->oobblock - 1)) - offset;			for (j = 0; j < len2; j++)				buf[(*retlen) + j] = this->data_buf[offset + j];			*retlen += len2;			from = next;		}	}	ret = 0;	/* De-select the NAND device */	nand_deselect();	return ret;nand_read_ecc_err:	DEBUG(MTD_DEBUG_LEVEL0,		__FUNCTION__"(): Failed ECC read, page 0x%08lx\n", page);	return -EIO;}/* * NAND read out-of-band */static intnand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,               size_t *retlen, u_char *buf){	int i, offset, page;	struct nand_chip *this = mtd->priv;	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__ "(): from = 0x%08x, len = %i\n", (unsigned int)from,		(int)len);	/* Shift to get page */	page = ((int)from) >> this->page_shift;	/* Mask to get column */	offset = from & 0x0f;	/* Initialize return length value */	*retlen = 0;	/* Do not allow read past end of page */	if ((offset + len) > mtd->oobsize) {		DEBUG(MTD_DEBUG_LEVEL0,			__FUNCTION__"(): Attempt read past end of page " \			"0x%08lx, column %i, length %i\n", page, offset, len);		return -EINVAL;	}	/* Select the NAND device */	nand_select();	/* Send the read command */	nand_command(mtd, NAND_CMD_READOOB, offset, page);	this->wait_for_ready();	/* Read the data */	for (i = 0; i < len; i++)		buf[i] = this->read_data();	/* De-select the NAND device */	nand_deselect();	/* Return happy */	*retlen = len;	return 0;}/* * NAND write */static intnand_write(struct mtd_info *mtd, loff_t to, size_t len,            size_t *retlen, const u_char *buf){	int i, page, col, cnt, status;	struct nand_chip *this = mtd->priv;	DEBUG(MTD_DEBUG_LEVEL3,		__FUNCTION__"(): to = 0x%08x, len = %i\n", (unsigned int)to,		(int) len);	/* Do not allow write past end of page */	if ((to + len) > mtd->size) {		DEBUG(MTD_DEBUG_LEVEL0,			__FUNCTION__"(): Attempted write past end of device\n");		return -EINVAL;	}	/* Shift to get page */	page = ((int)to) >> this->page_shift;	/* Get the starting column */	col = to & (mtd->oobblock - 1);	/* Initialize return length value */	*retlen = 0;	/* Select the NAND device */	nand_select();	/* Check the WP bit */	nand_command(mtd, NAND_CMD_STATUS, -1, -1);//	this->wait_for_ready();	if (!(this->read_data() & SMC_STAT_NOT_WP)) {		DEBUG(MTD_DEBUG_LEVEL0,			__FUNCTION__"(): Device is write protected!!!\n");		i = -EPERM;		goto nand_write_exit;	}	/* Loop until all data is written */	while (*retlen < len) {		/* Write data into buffer */		if ((col + len) >= mtd->oobblock)			for (i = col, cnt = 0; i < mtd->oobblock; i++, cnt++)				this->data_buf[i] = buf[(*retlen + cnt)];		else			for (i = col, cnt = 0; cnt < (len - *retlen); i++, cnt++)				this->data_buf[i] = buf[(*retlen + cnt)];		/* Write ones for partial page programming */		for (i = mtd->oobblock; i < (mtd->oobblock + mtd->oobsize); i++)			this->data_buf[i] = 0xff;				/* Write pre-padding bytes into buffer */		for (i = 0; i < col; i++)			this->data_buf[i] = 0xff;		/* Write post-padding bytes into buffer */		if ((col + (len - *retlen)) < mtd->oobblock) {			for (i = (col + cnt); i < mtd->oobblock; i++)				this->data_buf[i] = 0xff;		}		/* Send command to begin auto page programming */		nand_command(mtd, NAND_CMD_SEQIN, 0x00, page);		/* Write out complete page of data */		this->hwcontrol(NAND_CTL_DAT_OUT);		for (i = 0; i < (mtd->oobblock + mtd->oobsize); i++)			this->write_data(this->data_buf[i]);		this->hwcontrol(NAND_CTL_DAT_IN);				this->hwcontrol(NAND_CTL_CLRRnB);		/* Send command to actually program the data */		nand_command(mtd, NAND_CMD_PAGEPROG, -1, -1);		this->wait_for_ready();		/*		 * Wait for program operation to complete. This could		 * take up to 3000us (3ms) on some devices. so we try		 * and exit as quickly as possible.		 */		status = 0;		for (i = 0; i < 24; i++) {			/* Delay for 125us */			udelay(125);			/* Check for status */			nand_command(mtd, NAND_CMD_STATUS, -1, -1);			status = (int)this->read_data();			if (status & SMC_STAT_READY)				break;		}		/* See if device thinks it succeeded */		if (status & SMC_STAT_WRITE_ERR) {

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人精品影院| 精品处破学生在线二十三| 国产精品久久久久四虎| 风流少妇一区二区| 亚洲欧美在线另类| 在线看不卡av| 欧美aaa在线| 日本一二三不卡| 91亚洲精品久久久蜜桃网站| 亚洲国产综合色| 日韩一区二区三区视频| 久久不见久久见免费视频1| 久久久精品2019中文字幕之3| 不卡电影一区二区三区| 一区二区三区资源| 欧美日韩一区 二区 三区 久久精品| 日韩专区一卡二卡| 欧美精品一区男女天堂| 91麻豆国产福利在线观看| 香蕉成人啪国产精品视频综合网| 日韩一级免费观看| 国产福利精品导航| 一区二区在线观看免费视频播放| 欧美精品一级二级三级| 国产一区二区免费在线| 一区二区三区精品视频在线| 日韩一区二区三区视频在线观看 | 欧美三级电影在线看| 日韩精品高清不卡| 欧美国产一区二区| 666欧美在线视频| eeuss鲁片一区二区三区| 午夜影院久久久| 国产精品毛片大码女人| 欧美一级欧美一级在线播放| 成人晚上爱看视频| 青青草原综合久久大伊人精品优势| 亚洲国产电影在线观看| 精品视频一区三区九区| 国产成都精品91一区二区三| 亚洲一区在线视频| 中文子幕无线码一区tr| 日韩欧美一区电影| 在线观看中文字幕不卡| 成人小视频在线| 久久99国内精品| 亚洲第一av色| 中文字幕五月欧美| 久久久久久一级片| 日韩欧美中文一区| 91丨porny丨国产入口| 国产精品白丝jk白祙喷水网站| 亚洲高清中文字幕| 亚洲激情图片小说视频| 欧美性色黄大片| 视频在线观看一区| 日本一区二区视频在线观看| 这里只有精品免费| 欧美日韩国产综合视频在线观看| 丁香婷婷综合五月| 国产一区二区精品在线观看| 久久福利资源站| 五月婷婷久久丁香| 亚洲在线免费播放| 一区二区久久久| 日韩毛片高清在线播放| 欧美韩日一区二区三区| 国产调教视频一区| 久久精品欧美一区二区三区麻豆| 欧美一级理论片| 日韩一区二区三区在线观看 | 99国产精品久| eeuss鲁片一区二区三区在线看| 粉嫩av亚洲一区二区图片| 国产尤物一区二区在线| 国产精品一区二区三区乱码 | 91免费观看国产| 成人av在线一区二区三区| www.欧美日韩国产在线| 91丝袜美腿高跟国产极品老师| 91老师国产黑色丝袜在线| 国产一区二区三区在线观看精品| 国内国产精品久久| 国产成人亚洲综合a∨婷婷| 成人高清av在线| youjizz国产精品| 91丨九色丨蝌蚪富婆spa| 91香蕉国产在线观看软件| 色综合色狠狠综合色| 欧美色窝79yyyycom| 日韩一区二区三区高清免费看看| 欧美一级淫片007| 久久综合九色欧美综合狠狠| 国产日韩成人精品| 伊人色综合久久天天| 亚洲成av人片在www色猫咪| 美女诱惑一区二区| 国产福利电影一区二区三区| 99久久精品费精品国产一区二区| 欧美色综合久久| 精品福利在线导航| 国产精品国产三级国产aⅴ中文| 亚洲精品综合在线| 免费精品视频最新在线| 国产成人精品一区二| 在线视频欧美精品| 日韩欧美黄色影院| 国产精品看片你懂得| 亚洲不卡av一区二区三区| 老司机一区二区| www.欧美.com| 日韩欧美黄色影院| 亚洲欧美在线aaa| 日本亚洲电影天堂| 大白屁股一区二区视频| 欧美视频日韩视频| 国产网站一区二区| 亚洲h在线观看| 国产成人福利片| 欧美日韩久久久| 国产精品美女久久久久久久网站| 亚洲成av人影院在线观看网| 韩国女主播成人在线| 91福利精品第一导航| 26uuu久久综合| 午夜私人影院久久久久| 成人sese在线| 精品黑人一区二区三区久久| 亚洲区小说区图片区qvod| 久久国产精品第一页| 欧美视频一区二区在线观看| 国产精品天天看| 免费观看在线综合| 日本韩国一区二区三区视频| 久久久www成人免费无遮挡大片 | 亚洲免费毛片网站| 国产精品夜夜爽| 欧美一级欧美三级在线观看| 亚洲在线免费播放| 成人av在线观| 国产午夜亚洲精品羞羞网站| 日本欧美一区二区在线观看| 日本道色综合久久| 中国av一区二区三区| 麻豆91在线看| 56国语精品自产拍在线观看| 亚洲综合视频网| 91蜜桃传媒精品久久久一区二区| 国产三级欧美三级日产三级99| 免费xxxx性欧美18vr| 欧美日韩一区在线观看| 亚洲欧美激情插| 91亚洲精华国产精华精华液| 亚洲欧洲美洲综合色网| 国产一区二区成人久久免费影院| 欧美成人猛片aaaaaaa| 午夜精品福利在线| 7777精品久久久大香线蕉| 性久久久久久久久久久久| 欧美三级电影一区| 午夜婷婷国产麻豆精品| 4hu四虎永久在线影院成人| 亚洲成人一区在线| 欧美人与性动xxxx| 亚洲.国产.中文慕字在线| 欧美精选一区二区| 日韩电影在线看| 日韩精品最新网址| 久久99国产精品成人| 亚洲精品一区二区三区福利| 国产一区欧美二区| 国产欧美日韩精品a在线观看| 国产成人鲁色资源国产91色综| 国产欧美va欧美不卡在线| 成人黄色综合网站| 亚洲人成伊人成综合网小说| 色偷偷一区二区三区| 亚洲成年人影院| 日韩精品影音先锋| 国产精品一区久久久久| 国产精品丝袜一区| 91蜜桃视频在线| 日韩在线卡一卡二| 欧美成人一区二区三区在线观看| 国产又粗又猛又爽又黄91精品| 中文字幕成人在线观看| 91视频国产观看| 日韩av中文字幕一区二区三区| 91精品国产高清一区二区三区 | 亚洲精品欧美二区三区中文字幕| 在线日韩av片| 免费成人小视频| 欧美国产在线观看| 欧美三级日韩三级| 国产一区二区剧情av在线| 亚洲女厕所小便bbb| 欧美一区二区视频在线观看2022| 国产精品中文字幕日韩精品| 最新欧美精品一区二区三区| 在线电影欧美成精品|