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

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

?? nftllite.c

?? Nandflash翻譯層源代碼,在論壇上下載的
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*                                                                      */
/* Returns:                                                             */
/*	FLStatus	: 0 on success, failed otherwise		*/
/*----------------------------------------------------------------------*/

/*static*/ FLStatus formatNFTL(FLFlash *flash, FormatParams FAR1 *formatParams)
{
  Anand vol = &vols[flSocketNoOf(flash->socket)];
  long int unitSize;
  UnitNo iUnit, noOfBootUnits;
  BootRecord bootRecord;
  int noOfBadUnits = 0;

#ifdef DEBUG_PRINT
  DEBUG_PRINT("Debug: starting NFTL format.\n");
#endif

  vol.flash = *flash;
  checkStatus(initNFTL(&vol));

  /* Find the medium boot record */
  for (vol.orgUnit = 0; vol.orgUnit < vol.noOfUnits; vol.orgUnit++) {
    vol.flash.read(&vol.flash,
		   unitBaseAddress(&vol,vol.orgUnit),
		   &bootRecord,
		   sizeof bootRecord,
		   0);
    if (tffscmp(bootRecord.bootRecordId,"ANAND",sizeof bootRecord.bootRecordId) == 0)
      break;
  }

  noOfBootUnits = ((formatParams->bootImageLen - 1) >> vol.unitSizeBits) + 1;

  if (vol.orgUnit < vol.noOfUnits) {
    if (LE2(bootRecord.bootUnits) > noOfBootUnits )
      noOfBootUnits = LE2(bootRecord.bootUnits) ;
  }

  vol.unitOffsetMask = (1L << vol.unitSizeBits) - 1;
  vol.sectorsPerUnit = 1 << (vol.unitSizeBits - SECTOR_SIZE_BITS);
  vol.noOfTransferUnits = formatParams->noOfSpareUnits;

  vol.noOfTransferUnits += (long)(vol.noOfUnits - vol.bootUnits) *
				 (100 - formatParams->percentUse) / 100;

  if (vol.noOfUnits <= vol.bootUnits + vol.noOfTransferUnits)
    return flVolumeTooSmall;

  unitSize = 1L << vol.unitSizeBits;
  vol.noOfVirtualUnits = vol.noOfUnits-vol.bootUnits;

  checkStatus(initTables(&vol));

  for (iUnit = 0; iUnit < (vol.noOfUnits-vol.bootUnits); iUnit++)
    vol.virtualUnits[iUnit] = NO_UNIT;


  if (vol.orgUnit >= vol.noOfUnits) {
	    /* no boot record - virgin card, scan it for bad blocks */

	    /* Find a place for the boot record */
    for (vol.orgUnit = vol.bootUnits; vol.orgUnit < vol.noOfUnits; vol.orgUnit++)
      if (isErased(&vol,vol.orgUnit))
	break;

    if (vol.orgUnit >= vol.noOfUnits)
      return flVolumeTooSmall;

	    /* Generate the bad unit table */
    /* if a unit is not erased it is marked as bad */
    for (iUnit = 0; iUnit < vol.noOfUnits; iUnit++)
      vol.physicalUnits[iUnit] = isErased(&vol,iUnit) ? UNIT_FREE : UNIT_BAD_ORIGINAL;

  }
  else {  /* Read bad unit table from boot record */
    checkStatus(vol.flash.read(&vol.flash,
			       unitBaseAddress(&vol,vol.orgUnit) + SECTOR_SIZE,
			       vol.physicalUnits,
			       vol.noOfUnits * sizeof(PhysUnit),
			       EDC));
  }

  /*  count bad units */
  vol.noOfTransferUnits += 2;           /* include orgUnit & spareOrgUnit */

  /* extend bootimage area if there are bad units in it */
  for( iUnit = vol.bootUnits = 0;
       (vol.bootUnits < noOfBootUnits)  &&  (iUnit < vol.noOfUnits);
       iUnit++ )
      if( vol.physicalUnits[iUnit] & UNIT_AVAILABLE )
	vol.bootUnits++;

  if (vol.bootUnits < noOfBootUnits)
    return flVolumeTooSmall;

  vol.bootUnits = iUnit;

  if (vol.noOfUnits <= vol.bootUnits + vol.noOfTransferUnits)
    return flVolumeTooSmall;

  /* Discount transfer units taken by the boot image */
  for (iUnit = 0; iUnit < vol.bootUnits; iUnit++)
    if (!(vol.physicalUnits[iUnit] & UNIT_AVAILABLE))
      vol.noOfTransferUnits--;

  vol.virtualSectors = (vol.noOfUnits - vol.bootUnits - vol.noOfTransferUnits) *
		       (unitSize / SECTOR_SIZE);
  vol.noOfVirtualUnits = (unsigned short)((vol.virtualSectors + vol.sectorsPerUnit - 1) / vol.sectorsPerUnit);

  /* Find a place for the boot records and protect them */
  /* NOTE : We don't erase the old orgUnits, this might cause a problem
     when formatting with bootImageLen = 0 and then formatting with
     bootImageLen = 44Kbyte */
  for (vol.orgUnit = vol.bootUnits; vol.orgUnit < vol.noOfUnits; vol.orgUnit++)
    if (vol.physicalUnits[vol.orgUnit] == UNIT_FREE)
      break;
  vol.physicalUnits[vol.orgUnit] &= ~UNIT_AVAILABLE;
  for (vol.spareOrgUnit = vol.orgUnit + 1;
       vol.spareOrgUnit < vol.noOfUnits;
       vol.spareOrgUnit++)
    if (vol.physicalUnits[vol.spareOrgUnit] == UNIT_FREE)
      break;
  vol.physicalUnits[vol.spareOrgUnit] &= ~UNIT_AVAILABLE;

  for (iUnit = vol.bootUnits; iUnit < vol.noOfUnits; iUnit++) {
    FLStatus status = formatUnit(&vol,iUnit);
    if(status == flWriteFault) {
      if ((iUnit != vol.orgUnit) && (iUnit != vol.spareOrgUnit)) {
	noOfBadUnits++;
	if (vol.physicalUnits[iUnit] != UNIT_BAD_ORIGINAL)
	  vol.physicalUnits[iUnit] = UNIT_BAD_ORIGINAL;  /* Mark it bad in table */
	if (noOfBadUnits >= vol.noOfTransferUnits)
	  return status;
      }
    }
    else if (status != flOK)
      return status;

    if (formatParams->progressCallback)
      checkStatus((*formatParams->progressCallback)
		  (vol.noOfUnits - vol.bootUnits,
		  (iUnit + 1) - vol.bootUnits));
  }

  /* Prepare the boot record header */
  tffsset(&bootRecord,0xff,sizeof bootRecord);
  toLE2(bootRecord.noOfUnits,vol.noOfUnits - vol.bootUnits);
  toLE2(bootRecord.bootUnits,vol.bootUnits);
  tffscpy(bootRecord.bootRecordId,"ANAND",sizeof bootRecord.bootRecordId);
  toUNAL4(bootRecord.virtualMediumSize,(CardAddress) vol.virtualSectors * SECTOR_SIZE);

  /* Write boot records, spare unit first */
  vol.physicalUnits[vol.orgUnit] = UNIT_FREE;	/* Unprotect it */
  vol.physicalUnits[vol.spareOrgUnit] = UNIT_FREE;	/* Unprotect it */

  checkStatus(formatUnit(&vol,vol.spareOrgUnit));
  checkStatus(vol.flash.write(&vol.flash,
			      unitBaseAddress(&vol,vol.spareOrgUnit) + SECTOR_SIZE,
			      vol.physicalUnits,
			      vol.noOfUnits * sizeof(PhysUnit),
			      EDC));
  checkStatus(vol.flash.write(&vol.flash,
			      unitBaseAddress(&vol,vol.spareOrgUnit),
			      &bootRecord,
			      sizeof bootRecord,
			      0));

  checkStatus(formatUnit(&vol,vol.orgUnit));
  checkStatus(vol.flash.write(&vol.flash,
			      unitBaseAddress(&vol,vol.orgUnit) + SECTOR_SIZE,
			      vol.physicalUnits,
			      vol.noOfUnits * sizeof(PhysUnit),
			      EDC));
  checkStatus(vol.flash.write(&vol.flash,
			      unitBaseAddress(&vol,vol.orgUnit),
			      &bootRecord,
			      sizeof bootRecord,
			      0));

  /* Protect the units we mustn't access */
  for (iUnit = 0; iUnit < vol.bootUnits; iUnit++)
    vol.physicalUnits[iUnit] &= ~UNIT_AVAILABLE;
  vol.physicalUnits[vol.orgUnit] &= ~UNIT_AVAILABLE;
  vol.physicalUnits[vol.spareOrgUnit] &= ~UNIT_AVAILABLE;

#ifdef DEBUG_PRINT
  DEBUG_PRINT("Debug: finished NFTL format.\n");
#endif

  return flOK;
}

#endif


/*----------------------------------------------------------------------*/
/*      	         d i s m o u n t N F T L			*/
/*									*/
/* Dismount NFTL volume							*/
/*									*/
/* Parameters:                                                          */
/*	vol		: Pointer identifying drive			*/
/*									*/
/*----------------------------------------------------------------------*/

static void dismountNFTL(Anand vol)
{
#ifdef MALLOC_TFFS
  FREE_TFFS(vol.physicalUnits);
  FREE_TFFS(vol.virtualUnits);
#endif
}


/*----------------------------------------------------------------------*/
/*      	            m o u n t N F T L				*/
/*									*/
/* Mount the volume. Initialize data structures and conversion tables	*/
/*									*/
/* Parameters:                                                          */
/*	flash		: Flash media to mount				*/
/*	tl		: Mounted translation layer on exit		*/
/*      volForCallback	: Pointer to FLFlash structure for power on	*/
/*			  callback routine.				*/
/*                                                                      */
/* Returns:                                                             */
/*	FLStatus	: 0 on success, failed otherwise		*/
/*----------------------------------------------------------------------*/

/*static*/ FLStatus mountNFTL(FLFlash *flash, TL *tl, FLFlash **volForCallback)
{
  Anand vol = &vols[flSocketNoOf(flash->socket)];
  UnitNo iUnit;
  BootRecord bootRecord;

#ifdef DEBUG_PRINT
  DEBUG_PRINT("Debug: starting NFTL mount.\n");
#endif

  vol.flash = *flash;
  *volForCallback = &vol.flash;
  checkStatus(initNFTL(&vol));

  /* Find the medium boot record */
  for (vol.orgUnit = 0; vol.orgUnit < vol.noOfUnits; vol.orgUnit++) {
    vol.flash.read(&vol.flash,
		    unitBaseAddress(&vol,vol.orgUnit),
		    &bootRecord,
		    sizeof bootRecord,
		    0);
    if (tffscmp(bootRecord.bootRecordId,"ANAND",sizeof bootRecord.bootRecordId) == 0)
      break;
  }
  if (vol.orgUnit >= vol.noOfUnits) {
  #ifdef DEBUG_PRINT
    DEBUG_PRINT("Debug: not NFTL format.\n");
  #endif
    return flUnknownMedia;
  }

  for (vol.spareOrgUnit = vol.orgUnit + 1;
       vol.spareOrgUnit < vol.noOfUnits;
       vol.spareOrgUnit++) {
    BootRecord bootRecord;

    vol.flash.read(&vol.flash,
		    unitBaseAddress(&vol,vol.spareOrgUnit),
		    &bootRecord,
		    sizeof bootRecord,
		    0);
    if (tffscmp(bootRecord.bootRecordId,"ANAND",sizeof bootRecord.bootRecordId) == 0)
      break;
  }
  if (vol.spareOrgUnit >= vol.noOfUnits)
  vol.spareOrgUnit = NO_UNIT;  /* Get media information from unit header */
  vol.noOfUnits = LE2(bootRecord.noOfUnits);
  vol.bootUnits = LE2(bootRecord.bootUnits);
  vol.virtualSectors = UNAL4(bootRecord.virtualMediumSize) >> SECTOR_SIZE_BITS;
  vol.noOfUnits += vol.bootUnits;

  vol.unitOffsetMask = (1L << vol.unitSizeBits) - 1;
  vol.sectorsPerUnit = 1 << (vol.unitSizeBits - SECTOR_SIZE_BITS);
  vol.noOfVirtualUnits = (UnitNo)((vol.virtualSectors + vol.sectorsPerUnit - 1) / vol.sectorsPerUnit);

  if ((vol.virtualSectors >> (vol.unitSizeBits - SECTOR_SIZE_BITS)) >
      (unsigned long)(vol.noOfUnits - vol.bootUnits))
    return flBadFormat;

  checkStatus(initTables(&vol));

  vol.badFormat = FALSE;

  /* Read bad unit table from boot record */
  checkStatus(vol.flash.read(&vol.flash,
			      unitBaseAddress(&vol,vol.orgUnit) + SECTOR_SIZE,
			      vol.physicalUnits,
			      vol.noOfUnits * sizeof(PhysUnit),
			      EDC));

  /* Exclude boot-image units */
  for (iUnit = 0; iUnit < vol.noOfVirtualUnits; iUnit++)
    vol.virtualUnits[iUnit] = NO_UNIT;

  /* Mount all units */
  for (iUnit = 0 ; iUnit < vol.noOfUnits; iUnit++) {
    /* Exclude protected units */
    if (iUnit < vol.bootUnits || iUnit == vol.orgUnit || iUnit == vol.spareOrgUnit)
      vol.physicalUnits[iUnit] &= ~UNIT_AVAILABLE;

    if (vol.physicalUnits[iUnit] & UNIT_AVAILABLE)
      checkStatus(mountUnit(&vol,iUnit));
  }

  /* Scan for orphan units, and count free units */
  vol.freeUnits = 0;
  for (iUnit = vol.bootUnits; iUnit < vol.noOfUnits; iUnit++) {
    PhysUnit *pU = &vol.physicalUnits[iUnit];

    if (*pU == (UNIT_AVAILABLE | UNIT_ORPHAN) ||
	*pU == (UNIT_AVAILABLE | UNIT_REPLACED | UNIT_ORPHAN)) {
      if (formatUnit(&vol,iUnit) == flOK)	/* Get rid of orphan */
	vol.freeUnits--;		/* will count it later */
    }
    else if (*pU == (UNIT_FREE & ~UNIT_ORPHAN))
      *pU = UNIT_FREE;	/* Reference to free unit. That's OK */

    if (*pU == UNIT_FREE)
      vol.freeUnits++;
  }

  /* Initialize allocation rover */
  vol.roverUnit = vol.bootUnits;

  /* Initialize statistics */
  vol.sectorsRead = vol.sectorsWritten = vol.sectorsDeleted = 0;
  vol.parasiteWrites = vol.unitsFolded = 0;

  tl->rec = &vol;
  tl->mapSector = mapSector;
  tl->writeSector = writeSector;
  tl->deleteSector = deleteSector;
#if defined(DEFRAGMENT_VOLUME) || defined(SINGLE_BUFFER)
  tl->defragment = defragment;
#endif
#ifdef FORMAT_VOLUME
  tl->sectorsInVolume = sectorsInVolume;
#endif
  tl->tlSetBusy = tlSetBusy;
  tl->dismount = dismountNFTL;

#ifdef DEBUG_PRINT
  DEBUG_PRINT("Debug: finished NFTL mount.\n");
#endif

  return flOK;
}


#if FLASE
/*----------------------------------------------------------------------*/
/*      	         f l R e g i s t e r N F T L			*/
/*									*/
/* Register this translation layer					*/
/*									*/
/* Parameters:                                                          */
/*	None								*/
/*                                                                      */
/* Returns:								*/
/*	FLStatus	: 0 on success, otherwise failure		*/
/*----------------------------------------------------------------------*/

FLStatus flRegisterNFTL(void)
{
  if (noOfTLs >= TLS)
    return flTooManyComponents;

  tlTable[noOfTLs].mountRoutine = mountNFTL;
#ifdef FORMAT_VOLUME
  tlTable[noOfTLs].formatRoutine = formatNFTL;
#endif
  noOfTLs++;

  return flOK;
}
#endif /* FLASE */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜免费欧美电影| av午夜一区麻豆| 高清久久久久久| 欧美午夜影院一区| 久久久久九九视频| 亚洲成av人片在线| 99久久精品免费看国产| 欧美一级一区二区| 亚洲伦在线观看| 国产原创一区二区| 欧美日韩国产美女| 亚洲欧美电影一区二区| 老色鬼精品视频在线观看播放| 94-欧美-setu| 国产日韩av一区二区| 日韩av成人高清| 欧美又粗又大又爽| 国产精品久久久久久亚洲毛片 | 综合久久给合久久狠狠狠97色| 日韩精品视频网站| 色吧成人激情小说| 中文字幕av一区二区三区高| 久久成人18免费观看| 精品视频在线看| 亚洲一区免费视频| 91视频com| 亚洲欧洲日韩女同| 高清视频一区二区| 国产性做久久久久久| 久久国产欧美日韩精品| 7878成人国产在线观看| 一区二区视频在线看| av高清不卡在线| 国产精品天美传媒沈樵| 国产高清精品网站| 国产亚洲精品久| 国产一区二区三区香蕉| 久久免费美女视频| 国产风韵犹存在线视精品| 久久噜噜亚洲综合| 国产成人精品免费在线| 欧美国产日韩a欧美在线观看| 日本亚洲视频在线| 欧美刺激脚交jootjob| 美日韩一区二区| 精品国产青草久久久久福利| 精品无人区卡一卡二卡三乱码免费卡| 91精品午夜视频| 精品一区二区三区的国产在线播放| 欧美一区二区人人喊爽| 热久久免费视频| 精品对白一区国产伦| 国产成人在线影院| 亚洲丝袜制服诱惑| 欧美人体做爰大胆视频| 青青草视频一区| 26uuu国产电影一区二区| 国产传媒欧美日韩成人| 亚洲欧美色图小说| 在线播放91灌醉迷j高跟美女| 美脚の诱脚舐め脚责91 | 欧美午夜精品一区二区三区| 亚洲成在人线在线播放| 91精品国产品国语在线不卡| 国产伦精品一区二区三区免费迷| 久久久久久久久久久久电影 | 精品999久久久| 成人精品国产一区二区4080| 亚洲伦理在线精品| 精品国产伦一区二区三区观看体验| 国产福利一区二区三区| 一区二区三区在线影院| 精品福利一二区| 一本大道久久a久久精品综合| 日本成人在线不卡视频| 亚洲国产激情av| 欧美日韩一区二区在线观看| 国产麻豆成人传媒免费观看| 一区二区三区中文字幕在线观看| 91精品国产色综合久久| 不卡影院免费观看| 免费av网站大全久久| 最新高清无码专区| 精品99一区二区三区| 91国偷自产一区二区三区观看 | 欧美日韩国产综合视频在线观看 | 亚洲一区在线视频观看| 2021国产精品久久精品 | 丰满亚洲少妇av| 婷婷久久综合九色国产成人| 亚洲欧洲精品一区二区精品久久久| 欧美男男青年gay1069videost| 国产91精品精华液一区二区三区| 日韩精品乱码免费| 亚洲人成网站在线| 国产欧美1区2区3区| 欧美电影免费观看高清完整版在线| 99久精品国产| 国产精品69久久久久水密桃| 日韩精品一二三区| 亚洲国产一区二区在线播放| 中文字幕免费一区| 国产色综合一区| 精品三级av在线| 欧美日韩国产片| 日本福利一区二区| www.成人网.com| 风间由美一区二区三区在线观看| 国内成人精品2018免费看| 亚洲一二三级电影| 一区二区三区高清| 亚洲精品中文在线影院| 自拍偷拍亚洲激情| 亚洲天堂成人网| 国产精品久久影院| 国产精品久久久久婷婷二区次| 国产亚洲一区二区在线观看| 26uuu国产一区二区三区| 精品国产污污免费网站入口 | 蜜臀av国产精品久久久久| 亚洲国产成人av网| 香蕉成人伊视频在线观看| 亚洲成人资源在线| 午夜精品久久久久久久99樱桃| 亚洲国产成人高清精品| 天堂成人国产精品一区| 日本va欧美va欧美va精品| 美日韩黄色大片| 国产一区二区三区观看| 国产传媒一区在线| 91美女在线看| 欧美在线观看视频在线| 337p亚洲精品色噜噜| 91精品国产欧美一区二区成人| 在线综合亚洲欧美在线视频| 日韩免费视频一区二区| 精品电影一区二区三区| 日本一区二区三级电影在线观看 | 日韩精品影音先锋| 久久香蕉国产线看观看99| 久久久.com| 亚洲欧美日韩中文播放| 一区二区三区日韩欧美| 日本视频一区二区三区| 韩国成人福利片在线播放| 成人一区二区三区中文字幕| 一本大道久久a久久综合| 欧美二区三区91| 久久久蜜臀国产一区二区| 中文字幕的久久| 亚洲va国产天堂va久久en| 精品在线亚洲视频| 91麻豆国产香蕉久久精品| 欧美日韩一区二区三区四区五区| 日韩欧美一区二区三区在线| 亚洲国产精品精华液2区45| 亚洲一区二区四区蜜桃| 国产一区二三区| 日本道免费精品一区二区三区| 欧美一区在线视频| 国产精品久久久久久久久图文区 | 天天亚洲美女在线视频| 国内精品在线播放| 欧美探花视频资源| 久久精品在这里| 日韩激情中文字幕| 成人永久看片免费视频天堂| 6080日韩午夜伦伦午夜伦| 中文成人综合网| 日本v片在线高清不卡在线观看| 99精品久久只有精品| 日韩欧美久久久| 一区在线观看视频| 黑人巨大精品欧美一区| 欧美在线一区二区| 国产精品色婷婷| 麻豆精品视频在线| 欧美日韩五月天| 中文字幕一区二区三区色视频 | 国产高清视频一区| 91麻豆精品国产自产在线| 亚洲特黄一级片| 福利91精品一区二区三区| 日韩一级免费一区| 亚洲国产精品一区二区www| 粉嫩绯色av一区二区在线观看| 日韩写真欧美这视频| 亚洲国产精品一区二区www在线| 不卡的av中国片| 国产亚洲成aⅴ人片在线观看 | 亚洲综合在线第一页| 成人激情免费网站| 久久久欧美精品sm网站| 六月丁香婷婷久久| 欧美一级在线免费| 日韩成人av影视| 欧美一区二区视频在线观看2020| 亚洲午夜激情网页| 欧美三级韩国三级日本一级| 亚洲女人的天堂|