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

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

?? inftlmount.c

?? nandflash k9g808u0a在pxa270的驅動,由于pxa270沒有nandflash接口
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*  * inftlmount.c -- INFTL mount code with extensive checks. * * Author: Greg Ungerer (gerg@snapgear.com) * (C) Copyright 2002-2003, Greg Ungerer (gerg@snapgear.com) * * Based heavily on the nftlmount.c code which is: * Author: Fabrice Bellard (fabrice.bellard@netgem.com)  * Copyright (C) 2000 Netgem S.A. * * $Id: inftlmount.c,v 1.2 2007/09/21 03:09:24 quy Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <linux/kernel.h>#include <linux/module.h>#include <asm/errno.h>#include <asm/io.h>#include <asm/uaccess.h>#include <linux/miscdevice.h>#include <linux/pci.h>#include <linux/delay.h>#include <linux/slab.h>#include <linux/sched.h>#include <linux/init.h>#include <linux/mtd/mtd.h>#include <linux/mtd/nftl.h>#include <linux/mtd/inftl.h>#include <linux/mtd/compatmac.h>char inftlmountrev[]="$Revision: 1.2 $";/* * find_boot_record: Find the INFTL Media Header and its Spare copy which *	contains the various device information of the INFTL partition and *	Bad Unit Table. Update the PUtable[] table according to the Bad *	Unit Table. PUtable[] is used for management of Erase Unit in *	other routines in inftlcore.c and inftlmount.c. */static int find_boot_record(struct INFTLrecord *inftl){	struct inftl_unittail h1;	//struct inftl_oob oob;	unsigned int i, block;	u8 buf[SECTORSIZE];	struct INFTLMediaHeader *mh = &inftl->MediaHdr;	struct INFTLPartition *ip;	size_t retlen;	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: find_boot_record(inftl=%p)\n", inftl);        /*	 * Assume logical EraseSize == physical erasesize for starting the	 * scan. We'll sort it out later if we find a MediaHeader which says	 * otherwise.	 */	inftl->EraseSize = inftl->mbd.mtd->erasesize;        inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize;	inftl->MediaUnit = BLOCK_NIL;	/* Search for a valid boot record */	for (block = 0; block < inftl->nb_blocks; block++) {		int ret;		/*		 * Check for BNAND header first. Then whinge if it's found		 * but later checks fail.		 */		ret = MTD_READ(inftl->mbd.mtd, block * inftl->EraseSize,		    SECTORSIZE, &retlen, buf);		/* We ignore ret in case the ECC of the MediaHeader is invalid		   (which is apparently acceptable) */		if (retlen != SECTORSIZE) {			static int warncount = 5;			if (warncount) {				printk(KERN_WARNING "INFTL: block read at 0x%x "					"of mtd%d failed: %d\n",					block * inftl->EraseSize,					inftl->mbd.mtd->index, ret);				if (!--warncount)					printk(KERN_WARNING "INFTL: further "						"failures for this block will "						"not be printed\n");			}			continue;		}		if (retlen < 6 || memcmp(buf, "BNAND", 6)) {			/* BNAND\0 not found. Continue */			continue;		}		/* To be safer with BIOS, also use erase mark as discriminant */		if ((ret = MTD_READOOB(inftl->mbd.mtd, block * inftl->EraseSize +		    SECTORSIZE + 8, 8, &retlen, (char *)&h1) < 0)) {			printk(KERN_WARNING "INFTL: ANAND header found at "				"0x%x in mtd%d, but OOB data read failed "				"(err %d)\n", block * inftl->EraseSize,				inftl->mbd.mtd->index, ret);			continue;		}		/*		 * This is the first we've seen.		 * Copy the media header structure into place.		 */		memcpy(mh, buf, sizeof(struct INFTLMediaHeader));		/* Read the spare media header at offset 4096 */		MTD_READ(inftl->mbd.mtd, block * inftl->EraseSize + 4096,		    SECTORSIZE, &retlen, buf);		if (retlen != SECTORSIZE) {			printk(KERN_WARNING "INFTL: Unable to read spare "			       "Media Header\n");			return -1;		}		/* Check if this one is the same as the first one we found. */		if (memcmp(mh, buf, sizeof(struct INFTLMediaHeader))) {			printk(KERN_WARNING "INFTL: Primary and spare Media "			       "Headers disagree.\n");			return -1;		}		mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks);		mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions);		mh->NoOfBDTLPartitions = le32_to_cpu(mh->NoOfBDTLPartitions);		mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits);		mh->FormatFlags = le32_to_cpu(mh->FormatFlags);		mh->PercentUsed = le32_to_cpu(mh->PercentUsed);#ifdef CONFIG_MTD_DEBUG_VERBOSE		if (CONFIG_MTD_DEBUG_VERBOSE >= 2) {			printk("INFTL: Media Header ->\n"				"    bootRecordID          = %s\n"				"    NoOfBootImageBlocks   = %d\n"				"    NoOfBinaryPartitions  = %d\n"				"    NoOfBDTLPartitions    = %d\n"				"    BlockMultiplerBits    = %d\n"				"    FormatFlgs            = %d\n"				"    OsakVersion           = 0x%x\n"				"    PercentUsed           = %d\n",				mh->bootRecordID, mh->NoOfBootImageBlocks,				mh->NoOfBinaryPartitions,				mh->NoOfBDTLPartitions,				mh->BlockMultiplierBits, mh->FormatFlags,				mh->OsakVersion, mh->PercentUsed);		}#endif		if (mh->NoOfBDTLPartitions == 0) {			printk(KERN_WARNING "INFTL: Media Header sanity check "				"failed: NoOfBDTLPartitions (%d) == 0, "				"must be at least 1\n", mh->NoOfBDTLPartitions);			return -1;		}		if ((mh->NoOfBDTLPartitions + mh->NoOfBinaryPartitions) > 4) {			printk(KERN_WARNING "INFTL: Media Header sanity check "				"failed: Total Partitions (%d) > 4, "				"BDTL=%d Binary=%d\n", mh->NoOfBDTLPartitions +				mh->NoOfBinaryPartitions,				mh->NoOfBDTLPartitions,				mh->NoOfBinaryPartitions);			return -1;		}		if (mh->BlockMultiplierBits > 1) {			printk(KERN_WARNING "INFTL: sorry, we don't support "				"UnitSizeFactor 0x%02x\n",				mh->BlockMultiplierBits);			return -1;		} else if (mh->BlockMultiplierBits == 1) {			printk(KERN_WARNING "INFTL: support for INFTL with "				"UnitSizeFactor 0x%02x is experimental\n",				mh->BlockMultiplierBits);			inftl->EraseSize = inftl->mbd.mtd->erasesize <<				mh->BlockMultiplierBits;			inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize;			block >>= mh->BlockMultiplierBits;		}		/* Scan the partitions */		for (i = 0; (i < 4); i++) {			ip = &mh->Partitions[i];			ip->virtualUnits = le32_to_cpu(ip->virtualUnits);			ip->firstUnit = le32_to_cpu(ip->firstUnit);			ip->lastUnit = le32_to_cpu(ip->lastUnit);			ip->flags = le32_to_cpu(ip->flags);			ip->spareUnits = le32_to_cpu(ip->spareUnits);			ip->Reserved0 = le32_to_cpu(ip->Reserved0);#ifdef CONFIG_MTD_DEBUG_VERBOSE			if (CONFIG_MTD_DEBUG_VERBOSE >= 2) {				printk("    PARTITION[%d] ->\n"					"        virtualUnits    = %d\n"					"        firstUnit       = %d\n"					"        lastUnit        = %d\n"					"        flags           = 0x%x\n"					"        spareUnits      = %d\n",					i, ip->virtualUnits, ip->firstUnit,					ip->lastUnit, ip->flags,					ip->spareUnits);			}#endif			if (ip->Reserved0 != ip->firstUnit) {				struct erase_info *instr = &inftl->instr;				/*				 * 	Most likely this is using the				 * 	undocumented qiuck mount feature.				 * 	We don't support that, we will need				 * 	to erase the hidden block for full				 * 	compatibility.				 */				instr->addr = ip->Reserved0 * inftl->EraseSize;				instr->len = inftl->EraseSize;				MTD_ERASE(inftl->mbd.mtd, instr);			}			if ((ip->lastUnit - ip->firstUnit + 1) < ip->virtualUnits) {				printk(KERN_WARNING "INFTL: Media Header "					"Partition %d sanity check failed\n"					"    firstUnit %d : lastUnit %d  >  "					"virtualUnits %d\n", i, ip->lastUnit,					ip->firstUnit, ip->Reserved0);				return -1;			}			if (ip->Reserved1 != 0) {				printk(KERN_WARNING "INFTL: Media Header "					"Partition %d sanity check failed: "					"Reserved1 %d != 0\n",					i, ip->Reserved1);				return -1;			}			if (ip->flags & INFTL_BDTL)				break;		}		if (i >= 4) {			printk(KERN_WARNING "INFTL: Media Header Partition "				"sanity check failed:\n       No partition "				"marked as Disk Partition\n");			return -1;		}		inftl->nb_boot_blocks = ip->firstUnit;		inftl->numvunits = ip->virtualUnits;		if (inftl->numvunits > (inftl->nb_blocks -		    inftl->nb_boot_blocks - 2)) {			printk(KERN_WARNING "INFTL: Media Header sanity check "				"failed:\n        numvunits (%d) > nb_blocks "				"(%d) - nb_boot_blocks(%d) - 2\n",				inftl->numvunits, inftl->nb_blocks,				inftl->nb_boot_blocks);			return -1;		}				inftl->mbd.size  = inftl->numvunits *			(inftl->EraseSize / SECTORSIZE);		/*		 * Block count is set to last used EUN (we won't need to keep		 * any meta-data past that point).		 */		inftl->firstEUN = ip->firstUnit;		inftl->lastEUN = ip->lastUnit;		inftl->nb_blocks = ip->lastUnit + 1;		/* Memory alloc */		inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);		if (!inftl->PUtable) {			printk(KERN_WARNING "INFTL: allocation of PUtable "				"failed (%zd bytes)\n",				inftl->nb_blocks * sizeof(u16));			return -ENOMEM;		}		inftl->VUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);		if (!inftl->VUtable) {			kfree(inftl->PUtable);			printk(KERN_WARNING "INFTL: allocation of VUtable "				"failed (%zd bytes)\n",				inftl->nb_blocks * sizeof(u16));			return -ENOMEM;		}				/* Mark the blocks before INFTL MediaHeader as reserved */		for (i = 0; i < inftl->nb_boot_blocks; i++)			inftl->PUtable[i] = BLOCK_RESERVED;		/* Mark all remaining blocks as potentially containing data */		for (; i < inftl->nb_blocks; i++)			inftl->PUtable[i] = BLOCK_NOTEXPLORED;		/* Mark this boot record (NFTL MediaHeader) block as reserved */		inftl->PUtable[block] = BLOCK_RESERVED;		/* Read Bad Erase Unit Table and modify PUtable[] accordingly */		for (i = 0; i < inftl->nb_blocks; i++) {			int physblock;			/* If any of the physical eraseblocks are bad, don't			   use the unit. */			for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) {				if (inftl->mbd.mtd->block_isbad(inftl->mbd.mtd, i * inftl->EraseSize + physblock))					inftl->PUtable[i] = BLOCK_RESERVED;			}		}		inftl->MediaUnit = block;		return 0;	}	/* Not found. */	return -1;}static int memcmpb(void *a, int c, int n){	int i;	for (i = 0; i < n; i++) {		if (c != ((unsigned char *)a)[i])			return 1;	}	return 0;}/* * check_free_sector: check if a free sector is actually FREE, *	i.e. All 0xff in data and oob area. */static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,	int len, int check_oob){	u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];	size_t retlen;	int i;	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: check_free_sectors(inftl=%p,"		"address=0x%x,len=%d,check_oob=%d)\n", inftl,		address, len, check_oob);	for (i = 0; i < len; i += SECTORSIZE) {		if (MTD_READECC(inftl->mbd.mtd, address, SECTORSIZE, &retlen, buf, &buf[SECTORSIZE], &inftl->oobinfo) < 0)			return -1;		if (memcmpb(buf, 0xff, SECTORSIZE) != 0)			return -1;		if (check_oob) {			if (memcmpb(buf + SECTORSIZE, 0xff, inftl->mbd.mtd->oobsize) != 0)				return -1;		}		address += SECTORSIZE;	}	return 0;}/* * INFTL_format: format a Erase Unit by erasing ALL Erase Zones in the Erase *		 Unit and Update INFTL metadata. Each erase operation is *		 checked with check_free_sectors. * * Return: 0 when succeed, -1 on error. * * ToDo: 1. Is it neceressary to check_free_sector after erasing ??  */int INFTL_formatblock(struct INFTLrecord *inftl, int block){	size_t retlen;	struct inftl_unittail uci;	struct erase_info *instr = &inftl->instr;	int physblock;	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p,"		"block=%d)\n", inftl, block);	memset(instr, 0, sizeof(struct erase_info));	/* FIXME: Shouldn't we be setting the 'discarded' flag to zero	   _first_? */	/* Use async erase interface, test return code */	instr->addr = block * inftl->EraseSize;	instr->len = inftl->mbd.mtd->erasesize;	/* Erase one physical eraseblock at a time, even though the NAND api

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区在线影院| 国产性色一区二区| 99re热视频这里只精品| 成人免费视频免费观看| 国产91在线观看丝袜| 国产高清精品在线| av一区二区三区黑人| a美女胸又www黄视频久久| 豆国产96在线|亚洲| youjizz国产精品| 色偷偷一区二区三区| 91久久人澡人人添人人爽欧美| www.99精品| 在线观看日韩一区| 在线不卡免费av| 欧美大片在线观看一区| 中文字幕欧美激情一区| 成人免费在线播放视频| 亚洲一区免费视频| 日韩国产欧美在线播放| 国产乱人伦偷精品视频不卡| 成人午夜伦理影院| 欧美视频一区二区三区四区| 日韩女优av电影| 欧美国产一区二区| 亚洲国产精品视频| 另类欧美日韩国产在线| 99热这里都是精品| 91超碰这里只有精品国产| 精品999久久久| 亚洲欧洲一区二区三区| 一区二区三区在线播| 亚洲免费在线播放| 亚洲国产精品久久久久婷婷884 | 97aⅴ精品视频一二三区| 国产不卡在线一区| 色网站国产精品| 成人99免费视频| 欧美人与禽zozo性伦| 91久久精品国产91性色tv| 欧美丰满一区二区免费视频| 26uuu久久天堂性欧美| 国产精品二三区| 亚洲一区二区三区视频在线| 精品制服美女久久| 精品无人码麻豆乱码1区2区| 国产又粗又猛又爽又黄91精品| 不卡的电影网站| 欧美日韩国产乱码电影| 亚洲精品一区在线观看| 国产精品久久久99| 日本免费在线视频不卡一不卡二| 精品一区二区三区欧美| 99精品视频在线观看| 337p亚洲精品色噜噜| 久久蜜桃香蕉精品一区二区三区| 亚洲男女毛片无遮挡| 久久精品国产精品亚洲综合| 91视频xxxx| 精品乱码亚洲一区二区不卡| 最新中文字幕一区二区三区| 蜜臀av国产精品久久久久| 国产精品99久久久久久宅男| 国产精品一区2区| 欧美日韩精品一区二区三区| 国产婷婷色一区二区三区四区| 亚洲高清免费观看高清完整版在线观看| 久久av资源网| 欧美精品在线视频| 亚洲视频每日更新| 国产一区二区精品在线观看| 欧美精品 国产精品| 久久久久久久久一| 国产制服丝袜一区| 在线综合视频播放| 夜夜嗨av一区二区三区四季av| 从欧美一区二区三区| 日韩欧美一区二区三区在线| 亚洲国产精品久久人人爱蜜臀 | 国产精品一区二区在线看| 欧美日韩免费一区二区三区 | 国产做a爰片久久毛片| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 国产亚洲欧美一级| 久久精品国产成人一区二区三区| 欧美日韩色综合| 亚洲精品伦理在线| 91丨九色丨尤物| 日韩一区二区三区在线| 亚洲高清免费在线| 538在线一区二区精品国产| 国产精品伦一区| thepron国产精品| 日韩欧美123| 国产一区二区三区精品视频| 欧美一区二区三区在线电影| 无码av免费一区二区三区试看 | 国产精品一区2区| 久久中文字幕电影| 国产乱码精品1区2区3区| 亚洲精品一区二区三区精华液| 另类中文字幕网| 久久久www免费人成精品| 激情亚洲综合在线| 国产亚洲综合在线| 狠狠色综合播放一区二区| 国产亚洲视频系列| 99久久精品免费看国产免费软件| 亚洲图片欧美激情| 欧美日韩免费不卡视频一区二区三区| 亚洲一区二区三区美女| 678五月天丁香亚洲综合网| 久久精品国产精品青草| 国产偷v国产偷v亚洲高清| 97精品久久久午夜一区二区三区| 中文字幕中文字幕一区二区 | 国产精品久99| 99久久久精品| 日本一道高清亚洲日美韩| 2欧美一区二区三区在线观看视频| 久久99久久精品| 国产精品卡一卡二| 欧美一区二区人人喊爽| 国产麻豆精品视频| 亚洲私人影院在线观看| 欧美精品99久久久**| 国产在线观看一区二区| 亚洲欧美日韩在线不卡| 日韩午夜精品电影| 丁香婷婷综合五月| 亚洲另类中文字| 久久免费国产精品| 欧美日韩中文字幕一区二区| 精品一区二区三区在线播放| 精品国精品国产尤物美女| caoporn国产精品| 久久国产欧美日韩精品| 亚洲激情第一区| 精品国产免费一区二区三区香蕉| 91丨九色丨国产丨porny| 麻豆国产欧美一区二区三区| 国产精品不卡一区| 26uuu国产电影一区二区| av网站免费线看精品| 激情文学综合丁香| 日韩av中文字幕一区二区三区| 国产蜜臀97一区二区三区| 91精品欧美综合在线观看最新| 成人在线综合网站| 国内精品不卡在线| 日韩激情视频网站| 亚洲一区二区av电影| 久久精品一区二区三区不卡牛牛| 欧美xxx久久| 91精品国产综合久久精品麻豆| www..com久久爱| 国产成人aaaa| 国内精品第一页| 久久精品久久综合| 首页国产丝袜综合| 一区二区三区精品久久久| 国产三级一区二区| 国产精品美女久久福利网站| 亚洲精品在线电影| 精品欧美一区二区三区精品久久| 色素色在线综合| 欧美亚洲综合色| 日本国产一区二区| 91日韩精品一区| 99天天综合性| 欧美日韩精品一二三区| 欧美无砖砖区免费| 欧美亚洲动漫制服丝袜| 欧美日韩一区二区三区免费看| 欧美主播一区二区三区| 欧洲一区二区三区在线| 色综合久久久网| 91视频一区二区三区| 91精品国产色综合久久不卡电影 | 一区二区三区欧美| 一区二区三区在线不卡| 日韩精彩视频在线观看| 久久精品国产一区二区| 国内成人精品2018免费看| 国产一区二区三区电影在线观看 | 国产一区二区在线影院| 国产一区二区在线视频| 精品亚洲成a人| 国产91丝袜在线播放0| av成人动漫在线观看| 欧美最新大片在线看| 欧美精品久久天天躁| 日韩欧美激情在线| 国产视频在线观看一区二区三区 | 成人免费毛片a| 91成人在线观看喷潮| 精品国产凹凸成av人网站| 国产午夜亚洲精品理论片色戒| 日韩美女精品在线| 日韩 欧美一区二区三区|