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

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

?? smc_core.c

?? vivi的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * vivi/drivers/mtd/nand/smc_core.c:  * * Based on linux/drivers/mtd/nand/smc.c * * $Id: smc_core.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 nand_select()	this->hwcontrol(NAND_CTL_SETNCE); \			nand_command(mtd, NAND_CMD_RESET, -1, -1); \			udelay(10);#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);		/* 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) {			DEBUG(MTD_DEBUG_LEVEL0,				__FUNCTION__"(): Failed write, page 0x%08x, " \				"%6i bytes were sucesful\n", page, *retlen);			i = -EIO;			goto nand_write_exit;		}#ifdef CONFIG_MTD_NAND_VERIFY_WRITE		/*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情综合五月色丁香 | a在线播放不卡| 久久久久88色偷偷免费| 国产精品综合在线视频| 国产人成一区二区三区影院| 成人一二三区视频| 国产一区二区在线影院| 久久久.com| 91在线观看美女| 手机精品视频在线观看| 日韩欧美另类在线| 成人国产视频在线观看| 亚洲一级电影视频| 欧美一级久久久久久久大片| 国产精品一区在线观看你懂的| 国产精品萝li| 91麻豆精品国产91久久久久久 | 成人三级伦理片| 一区二区三区**美女毛片| 欧美日韩国产综合视频在线观看| 九九视频精品免费| 亚洲精品福利视频网站| 日韩欧美国产综合在线一区二区三区| 国产成人啪午夜精品网站男同| 亚洲人被黑人高潮完整版| 91精品啪在线观看国产60岁| 福利一区二区在线观看| 亚洲一区在线观看视频| 久久先锋影音av鲁色资源网| 一本色道久久综合亚洲91| 日本在线不卡视频| 亚洲人成精品久久久久久| 精品国产免费人成电影在线观看四季 | 一区视频在线播放| 日韩免费视频线观看| 色综合久久中文综合久久97| 精品午夜一区二区三区在线观看| 一区二区三区四区亚洲| 欧美成人福利视频| 欧美日韩一区二区三区在线| 成人高清视频在线| 久久99精品网久久| 亚洲gay无套男同| 综合电影一区二区三区| 久久精品夜色噜噜亚洲a∨| 欧美日韩午夜在线| 色8久久精品久久久久久蜜| 国产麻豆成人传媒免费观看| 全部av―极品视觉盛宴亚洲| 一区二区三区日韩精品视频| 中文字幕不卡在线观看| 精品国产青草久久久久福利| 欧美日韩国产高清一区二区三区 | 亚洲电影一级黄| 国产精品久久久久四虎| 日韩一区二区电影网| 91网站在线观看视频| 国产91精品精华液一区二区三区 | 制服.丝袜.亚洲.中文.综合| 欧美三级中文字| 色婷婷久久久久swag精品 | 五月婷婷色综合| 亚洲精品成人悠悠色影视| 国产精品免费免费| 国产欧美日产一区| 久久嫩草精品久久久精品一| 91精品国产日韩91久久久久久| 色欧美日韩亚洲| 91丨九色丨蝌蚪富婆spa| 97精品超碰一区二区三区| 成人午夜短视频| 成人av资源在线| 粉嫩一区二区三区在线看| 国产福利一区在线| 国产91富婆露脸刺激对白| 国产高清久久久久| jlzzjlzz亚洲日本少妇| 91首页免费视频| 一本到不卡精品视频在线观看 | 在线看国产一区| 色综合久久88色综合天天免费| 99r国产精品| 色妞www精品视频| 欧美亚洲国产一区在线观看网站| 欧美综合一区二区| 91精品欧美福利在线观看| 日韩写真欧美这视频| 精品欧美黑人一区二区三区| 国产亚洲精品超碰| 国产精品久久精品日日| 一区二区三区成人| 天天影视网天天综合色在线播放| 天堂va蜜桃一区二区三区| 麻豆精品一区二区综合av| 国产最新精品精品你懂的| thepron国产精品| 欧美视频你懂的| 欧美刺激午夜性久久久久久久 | 欧美一级高清大全免费观看| 欧美成人女星排名| 欧美激情中文字幕一区二区| 国产精品国产自产拍在线| 亚洲一区日韩精品中文字幕| 日本伊人午夜精品| 成人免费毛片嘿嘿连载视频| 精品国产乱码久久久久久牛牛 | 欧美日本在线一区| 久久综合九色欧美综合狠狠| 中文字幕av免费专区久久| 亚洲成人一区在线| 国产激情视频一区二区三区欧美| 91欧美一区二区| 日韩一卡二卡三卡| 亚洲欧美视频在线观看| 美女视频一区二区三区| bt7086福利一区国产| 欧美一区二区在线不卡| 国产精品女主播在线观看| 日韩不卡在线观看日韩不卡视频| 成人午夜又粗又硬又大| 777色狠狠一区二区三区| 国产免费观看久久| 日欧美一区二区| 99精品视频免费在线观看| 精品少妇一区二区三区在线视频| 综合久久久久久| 国产在线精品视频| 欧美色手机在线观看| 中文字幕av不卡| 精品影视av免费| 欧美日韩电影在线播放| 国产乱妇无码大片在线观看| 欧美无乱码久久久免费午夜一区| wwwwxxxxx欧美| 亚洲成人tv网| 91在线国产福利| 国产日韩三级在线| 精品午夜一区二区三区在线观看 | 99久久免费精品高清特色大片| 欧美精品一卡二卡| 亚洲人成在线播放网站岛国| 国产精品123| 欧美xxxxx裸体时装秀| 亚洲午夜视频在线| 91伊人久久大香线蕉| 国产精品美女久久久久久久| 激情文学综合网| 欧美一区二区女人| 性感美女极品91精品| 欧洲生活片亚洲生活在线观看| 国产拍欧美日韩视频二区| 免费高清不卡av| 欧美精品丝袜中出| 亚洲高清视频的网址| 日本道精品一区二区三区| 亚洲欧洲精品一区二区三区| 国产.欧美.日韩| 欧美一区三区二区| 青青草伊人久久| 91精品国产综合久久福利软件| 午夜欧美视频在线观看| 欧美日韩免费高清一区色橹橹| 亚洲男人天堂av| 色国产综合视频| 亚洲一区二区美女| 欧美日韩精品免费观看视频| 五月天婷婷综合| 7777精品伊人久久久大香线蕉经典版下载 | 国产美女久久久久| 国产亚洲精品福利| 成人免费精品视频| 国产精品久久久久久久蜜臀 | 欧美日韩国产乱码电影| 天堂资源在线中文精品| 欧美日韩成人综合在线一区二区| 亚洲国产日韩综合久久精品| 欧美日韩大陆在线| 免费看欧美女人艹b| 精品电影一区二区三区| 久久99精品久久久久久久久久久久 | 国产精品一区二区三区99| 中文久久乱码一区二区| 91丨九色丨黑人外教| 一区二区三区免费观看| 欧美精品电影在线播放| 国产真实乱对白精彩久久| 国产精品不卡视频| 欧美日韩国产电影| 韩国一区二区在线观看| 国产精品视频线看| 91久久精品一区二区| 蜜臀av亚洲一区中文字幕| 久久久久国产精品人| 色综合天天天天做夜夜夜夜做| 天堂av在线一区| 国产日韩欧美精品电影三级在线| 成人污污视频在线观看| 性欧美大战久久久久久久久| 久久午夜羞羞影院免费观看| 91麻豆视频网站|