⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inftl.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*
 * $Log:   V:/Flite/archives/TrueFFS5/Src/inftl.c_V  $
 * 
 *    Rev 1.50   Oct 31 2002 17:50:16   oris
 * Format routine now checks TrueFFS version of 5.1.0-5.1.3 and if they placed the media header on a bad block, erase that block in order to allow BDK package to work with the device.
 * 
 *    Rev 1.49   Jul 31 2002 11:28:18   oris
 * Bug fix - bad block in first block of quick mount area, prevents it from being disvalidated.
 * 
 *    Rev 1.48   Jul 18 2002 15:19:56   ORIS
 * Removed warnings
 * 
 *    Rev 1.47   Jul 18 2002 10:54:10   oris
 * Bug fix - leave of binary partition greater then a single floor - problem with last floor and with the DPS.
 * 
 *    Rev 1.46   Jul 17 2002 17:41:02   oris
 * Removed warnings
 * 
 *    Rev 1.45   Jul 07 2002 09:11:16   oris
 * Removed warnings.
 * Added support for FL_REPORT_MOUNT_PROGRESS compilation flag.
 * Added support for FL_LEAVE_SOME_BINARY_AREA.
 * Bug fix - Header buffer was not 4-bytes aligned, while the record it is required to read is.
 * Bug fix - Leave previous binary partition when it was read protected and the Disk partition was also protected.
 * Bug fix - Not all progress call back were checked.
 * 
 *    Rev 1.44   06 May 2002 19:11:16   andreyk
 * removed FL_STATIC conditional compilation directive
 * 
 *    Rev 1.43   May 05 2002 16:57:28   oris
 * Added the static qualifier to the verifySectors routine under the FL_STATIC compilation flag.
 * 
 *    Rev 1.42   May 01 2002 19:03:38   oris
 * Removed warnings
 * Bug fix - adjusted default protection on DPS's for DiskOnChip Millennium Plus 16MB.
 * 
 *    Rev 1.41   Apr 22 2002 13:55:56   oris
 * Bad Littel endian convertion for quick mount information.
 * 
 *    Rev 1.40   Apr 15 2002 20:14:40   oris
 * Changed the use of SecondUnitStructure for INFTLTEST utility.
 * 
 *    Rev 1.39   Apr 15 2002 08:39:32   oris
 * Placed quick mount under if def of CHECK_MOUNT for INFTLTST.
 * 
 *    Rev 1.38   Apr 15 2002 07:37:20   oris
 * Improved power failure resistant:
 *  - setUnavail macro was changed for improved code readability.
 *  - MarkSectorAsChecking macro was changed to  MarkSectorAsChecked
 *  - Bug fix - getSectorFlags - in case invalid sector flags are found do not forget to reset TL buffer to ff's and mark it as remapped.
 *  - Added support for VERIFY_ERASED_SECTOR compilation flag - make sure a sector is free before writing it - most of the code
 *    is found in writeAndCheck routine.
 *  - Added MAKE_SURE_IGNORE_HAS_BAD_EDC compilation flag - make sure that the sector is really marked
 *    as ignored. If not mark   the entire sector as 0.
 *  - Initialize a addition 1k buffer for the TL - used for verify erase.
 *  - Bug fix - verifySector routine had several bugs.
 *  - Bug fix - foldUnit routine bad comparison in FL_OFF mode.
 *  - Bug fix - foldBestChain routine missing update of sector count after folding failed and bad search for free unit.
 *  - Bug fix - mountUnit routine had bad handling for corrupted unit header.
 * Added support for RAM based MTD power failure tests.
 * Remove cache allocation checks - They are not needed since the cache routine itself check for proper allocation.
 * Bug fix - prevent initialization of flash record in case flash is NULL.
 * Bug fix - defragment routine used to call allocateUnit instead of foldBestChain.
 * Bug fix - bad debug print when format routine none INFTL media.
 * Bug fix - missing several dismount in INFTL format.
 * Bug fix - format routine could not place protection onto binary partition containing only the bios driver.
 * Changed format debug massages.
 *
 *    Rev 1.37   Feb 19 2002 21:00:22   oris
 * Fixed FL_READ_ONLY compilation problems.
 * Replaced TL_LEAVE_BINARY_AREA with FL_LEAVE_BINARY_AREA
 * Improved protection against power failures:
 * - formatUnit/getUnitTailer and setUnitTailer - Added argument to support temporary units (unit with erase mark on an invalid offset so that if not fixed before next mount they will be considered as free).
 * - foldUnit - Removed setUnavailable (not called only from foldBestChain) and added code to restore temporary unit into permanent ones(mark erase mark in proper place).
 * - foldBestChain - added folding not in place and several bug fixes.
 * - AllocatUnit - Change sequence to be more robust.
 * - checkFolding/applyWearLeveling - Bug fix - read newest unit in chain after allocate call it might change as part of the allocate process.
 * - deleteSector - check status of write operation.
 * - mountInftl - perforce space reclamation only if no free units.
 *
 *    Rev 1.36   Jan 29 2002 20:09:28   oris
 * Removed warnings.
 * Buf fix - chainging protection attributes of a DiskOnChip with more then a single floor.
 * Bug fix - if an invalid sector flag is found in getSectorFlags routine and read operation failed, SECTOR_IGNORED should have been returned.
 *
 *    Rev 1.35   Jan 28 2002 21:25:46   oris
 * Bug fix - discard mark write operation had bad casting causing the
 * mark to be written to much lower addresses.
 * Changed discard variable to static const.
 * allocateAndWriteSectors - improved going along chain algorithm to scan
 * chain only once.
 *
 *    Rev 1.34   Jan 23 2002 23:33:20   oris
 * Removed CHECK_DISCARD compilation flag.
 * Bug fix - bad casting caused discard mark to be written to a different unit then was expected in formatUnit().
 * Changed discardQuickMount\Info to mark quick mount area as discarded instead of erasing it.
 * Improved markAsIgnored routine.
 * Bug fix - Problems with insert and remove key routines.
 * Bug fix - write BBT for INFTL formatted DiskOnChip was not supported.
 * Changed DFORMAT_PRINT syntax
 *
 *    Rev 1.33   Jan 21 2002 20:44:56   oris
 * Bug fix - Erase of quick mount information does not take block multiplication into account.
 *
 *    Rev 1.32   Jan 20 2002 20:28:48   oris
 * Removed warnings
 * Changed putGetBuffer to handle FAR pointers (prototype and pointers arithmetic's).
 * Quick mount is now saved if either of the following occurs
 *  - Last mount did not use quick mount information.
 *  - A write operation was made in this mount
 * Bug in quickMount units size calculation (affected large DiskOnChips).
 *
 *    Rev 1.31   Jan 20 2002 10:49:52   oris
 * Added initialization of Bnand record in mount and format.
 * Removed badFormat field from Bnand record.
 * Improoved last sector cache mechanism
 * Removed support for PPP=3 interleave-2
 * Changed FL_MALLOC allocation calls to FL_FAR_MALLOC and changed RAM tables pointers to FAR1.
 * Split preMount routine into protection routine and other premount routins.
 * Added DOUBLE_MAX_UNIT_CHAIN instead of MAX_UNIT_CHAIN*2
 * Added protection agains power failures.
 *  - Added several modes of verify write :
 *     - FL_UPS no protection
 *     - FL_ON verify each and every write operation
 *     - FL_OFF full protection with minmal performance penalty.
 *     - Added verifyVolume API to scan the media for slower mount, but with not further performance penalty.
 *     - default after mount is FL_OFF
 *  - Added folding not in place.
 *  - Added verification of last sector of the chains (in folding).
 *  - Added discard mark before erasing.
 *  - Changed sector flags and unit data retrival error correction logic.
 *  - Limit foldBestChain folding tryies.
 *  - Improoved mount logic for choosing between invalid chains.
 * Quick mount mechanism
 *  - Forced quick mount as default
 *  - Delete previous data only after first write operation.
 *  - Remove previous quick mount info with an erase operation.
 *  - Added remove previous quick mount info API (In preMount).
 * Imprroved error report mechanizm of brocken chains (should never happen):
 *  - error on read return unused area of flash
 *  - error on write report flGeneralFailure
 *  - error on mount fix chains. If error on a chain that was already validated , report flGeneralFailure
 * Format routine
 *  - Force quick mount (ignoring user flag)
 *  - Bug fix - format with leave binary partition of a protected binary partition.
 *  - Removed single floor support.
 *
 *    Rev 1.30   Nov 21 2001 11:38:26   oris
 * Changed FL_MARK_DELETE to FL_ON.
 * Changed FL_WITH_VERIFY_WRITE and FL_WITHOUT_VERIFY_WRITE to FL_ON and FL_OFF.
 *
 *    Rev 1.29   Nov 16 2001 00:22:22   oris
 * Reorganized - removed function declaration, moved debug routines to a
 * separated file.
 * Bug fix - VERIFY_WRITE logic - marking unit as unavailable was done on the
 * virtual unit and not the last physical unit plus the least sector count and
 * max chain length , where not reinitialized in foldBestChange. The result
 * might cause infinite loop in foldbestchain if foldUnit fails.
 * Bug fix - Support for DiskOnChip with last floors having less chips.
 * Improved progress callback routine to show current unit starting from 1 and
 not 0 and to indicate bad and unavailable blocks as well.
 * Bug fix - all routines that changed protection attributes might not use
 * Bug fix - formatting with LEAVE_BINARY_PARTITION when binary partition is
 * exactly the floor size (virtual size). and improved it for bootAreaLen not
 * 0 and not -1 (leave only part of the previous binary partition).
 * Quick mount feature - Made sure the mount operation changes quick_mount
 * validity even if QUICK_MOUNT_FEATURE is commented.
 * Support 2 unchangeable protected partitions (not only 1).
 * Added discard mark before erase and placed this option under ifdef (default off).
 * Changed isValidUnitFlags to check all fields (isValidParityResult) not just
 * PUN and VUN.
 * getUnitData - bug in the logic of using second unit data structure.
 * No need to reread the unit data if verify write is activated after setUnitData.
 * Added check in virtual2physical to make sure this the unit found is valid.
 * initINFTLbasic - Use dword variable to calculate blocks per unit (support 64k blocks).
 * Change block multiplication from MORE then 32K units (not equal)
 * Improved support for read only mode including mount - FL_READ_ONLY
 * Add runtime option of VERIFY_WRITE
 * Bug fix - Binary partition in the first floor used only 1001 units while in
 * other floors 1002 units.
 *
 *    Rev 1.28   Oct 11 2001 23:54:58   oris
 * Bug fix - When changing protection attribute of a BDTL partition (change
 * key, change lock , change protection type) on a DiskOnChip with more then
 * a single floor, an error massage might be returned since changing
 * protection attributes uses the same buffer as the structure holding the
 * protection area to work on.
 *
 *    Rev 1.27   Sep 24 2001 18:23:50   oris
 * Bug fix - missing break in foldBestChain - very rare case.
 * Removed warnings.
 *
 *    Rev 1.26   Sep 16 2001 21:47:54   oris
 * Placed intergrity check of sector in the last unit of the virtual unit under
 * VERIFY_WRITE compilation flag.
 * Bug fix - missing big-endian conversion when using static memory allocation.
 *
 *    Rev 1.25   Sep 15 2001 23:46:54   oris
 * Removed redundant isAvailable checks.
 * Make sure mount operation does not reconstruct BBT.
 * Bug fix - folding in wear leveling does not change NAC to 1.
 * Bug fix - Bad casting caused bad protection type to be returned under BIG_ENDIAN.
 * Changed change protection attributes routine applied on protected partition
 * from flWrongKey to flHWProtection.
 * Improved algorithm reliability with VERIFY_WRITE. Following are the changes in the algorithm:
 * 1) virtual2Physical -
 * a) added flag stating if the specific sector is not free in the last unit of the chain.
 * 2) foldUnit -
 * a) if can not copy sector to the last unit of the chain, mark unit as
 * unavailable and return error code.
 * b) If verify write is enabled check even sectors that re marked as used and
 * are found on the last unit of the chain.
 * 3) foldBestChain -
 * a) Ignore unavailable units
 * b) If folding failed start looking from the beginning (it will be marked as
 * unavailable by the foldunit routine).
 * c) when done make all unit available.
 * 4) Added checkFolding routine - after folding check if succeeded. If not
 * loop up to MAX_FOLDING_LOOP each time free a unit with foldbestchain,
 * append a unit to the problematic chain and try to fold it.
 * 5) allocateUnit - Now when there are less then 2 unit reclaim space. This is
 * to minimize the chance of folding within a fold operation.
 * 6) MountINFTL - Make sure there are at least 2 free units.
 *
 *    Rev 1.24   Jul 29 2001 16:10:00   oris
 * eraseOrphanUnit bug was fixed ( we did not add vol.firstUnit to the unitNo).
 *
 *    Rev 1.23   Jul 15 2001 20:45:12   oris
 * Improoved documentation.
 * Changed unitBaseAddress function to a macro.
 * Removed unneccesary if statments in applyWearLeveling().
 *
 *    Rev 1.22   Jul 13 2001 01:06:14   oris
 * Changed multiBufferCounter to signed allowing a better buffer management.
 * Changed consequtiveNumbers routine into a macro.
 * Reorganized the DEBUG chains routines.
 * Bug fix - H/W read protected partition did not report as such.
 * Changed swapUnits routine name to applyWearleveling.
 * Added basics for last sector return mechanism -
 *     foldUnit receives an additional field.
 *     read2Sectors returns edc error sector address and actually read sector address
 * Added several static prefixes for static routines.
 * Added edc check for media header read operation.
 * Bug fix - parturition size smaller then a unit was acceptable.
 * Added default protection for unused DPSes.
 * Bug fix - formatINFTL with leave binary partition flag when previous binary
 * partition was larger then a single floor.
 * Improved mount documentation.
 * Changed policy - do not erase unit with bad erase mark.
 *
 *    Rev 1.21   Jun 17 2001 08:20:06   oris
 * Added NO_READ_BBT_CODE compilation flag to reduce code size.
 * Improoved Reliability:
 * 1) Try to return next sector in chain if the current one has EDC error
 * 2) Mount routine erases all blocks not marked with the erase mark.
 *
 * Affected routines:
 * 1) virtual2Physical can recive the physical address to start looking for and
 * not the last virtual unit of the chain.
 * 2) copySector ,foldUnit, mapSector, read2sectors- if EDC error accures
 * return try returning the next sector.
 * 3) foldUnit - if EDC error accures return try returning the next sector.
 * 4) writeMultiSecotr - improove ppp = 3
 * 5) mountINFTL - erase all units not marked with the erase mark.
 *
 *    Rev 1.21   Jun 17 2001 08:18:02   oris
 * Changed recusive include define to INFTL_H.
 * Added FL_BAD_ERASE_MARK    definition for units without the erase mark on
 * mount operation.
 *
 * For the rest of the revisions see revision 1.24 in the PVCS.
 */

/***********************************************************************************/
/*                        M-Systems Confidential                                   */
/*           Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001            */
/*                         All Rights Reserved                                     */
/***********************************************************************************/
/*                            NOTICE OF M-SYSTEMS OEM                              */
/*                           SOFTWARE LICENSE AGREEMENT                            */
/*                                                                                 */
/*      THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE                 */
/*      AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT           */
/*      FOR THE SPECIFIC TERMS AND CONDITIONS OF USE,                              */
/*      OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE:                               */
/*      E-MAIL = info@m-sys.com                                                    */
/***********************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -