📄 blockdev.c
字号:
/*
* $Log: V:/Flite/archives/TrueFFS5/Src/BLOCKDEV.C_V $
*
* Rev 1.52 Nov 07 2002 12:33:56 oris
* Remove warnings.
*
* Rev 1.51 Oct 31 2002 14:55:56 oris
* Moved readIPL of the ALON device to the MTD (there was a bug in the blockdev implementation).
*
* Rev 1.50 Oct 21 2002 22:59:16 oris
* Bug fix in flExit() routine caused the routine to be executed even if flInit was not called.
*
* Rev 1.49 Jul 18 2002 10:54:00 oris
* Bad fix for warnings
*
* Rev 1.48 Jul 17 2002 17:40:52 oris
* Removed warnings
*
* Rev 1.47 Jul 07 2002 09:05:34 oris
* Removed warnings
* Added support for FL_REPORT_MOUNT_PROGRESS compilation flag.
* Added support for the TL_FORMAT_SOME_BINARY_PARTITIONS.
*
* Rev 1.46 May 02 2002 09:41:54 oris
* Changed memIntereleaveChanged to memSetGetMode.
*
* Rev 1.45 May 01 2002 19:02:16 oris
* Removed warnings
* Added support for change interleave call back routine - memInterleaveChanged.
*
* Rev 1.44 Apr 22 2002 13:53:02 oris
* Bug fix - initialization of flflash records in flInit() prevents the insertion of user defined memory access routines.
*
* Rev 1.43 Apr 15 2002 20:14:20 oris
* Prevent any change to the flPolicy environment variable. It must be set to FL_DEFAULT_POLICY.
*
* Rev 1.42 Apr 15 2002 07:33:56 oris
* Moved doc2exb functions declaration to blockdev.c
* Moved bdkCall function declaration to docbdk.h
* Bug fix - Bad arguments sanity check for FL_MTD_BUS_ACCESS_TYPE.
* Bug fix - Missing initialization of global variables:
* - bus access in flSetDocBusRoutine() and flGetDocBusRoutine() and when ENVIRONMENT_VARS compilation flag is not defined.
* - verify write when ENVIRONMENT_VARS compilation flag is not defined.
* - All global (for all sockets and volumes) environment variables where not reinitialized after flExit call.
* - Renamed initEnvVarsDone to initGlobalVarsDone.
* - Renamed flInitEnvVars() to flInitGlobalVars().
* Changed flBusConfig environment array to dword variables instead of single byte.
* Added support for VERIFY_ERASED_SECTOR compilation flag.
* Placed multi-doc environment variable under the MULTI_DOC compilation flag.
* VolumeInfo routine - remove warning by placing eraseCyclesPerUnit variable under FL_LOW_LEVEL compilation flag.
*
* Rev 1.41 Feb 19 2002 20:58:08 oris
* Moved include directives to blockdev.h file.
* Bug fix - findFreeVolume routine did not initialize flfash records of the volume. It caused exception when formatting a DiskOnChip with more then 1 partition.
* Compilation error missing ifdef EXIT.
* Convert TL_LEAVE_BINARY_AREA to FL_LEAVE_BINARY_AREA before sending it to the TL.
* Bug fix - volumeInfo routine might cause exception if osak version or driver version is larger the designated field.
* use intermediate variable before sending irFlags to otpSize routine.
*
* Rev 1.40 Jan 29 2002 20:07:42 oris
* Added NAMING_CONVENTION prefix and extern "C" for cpp files to all public routines:
* flSetEnvVolume, flSetEnvSocket , flSetEnvAll , flSetDocBusRoutine , flGetDocBusRoutine, flBuildGeometry , bdCall and flExit
* Changed LOW_LEVEL compilation flag with FL_LOW_LEVEL to prevent definition clashes.
* Removed warnings.
* Moved writeIPL sanity check to MTD level.
* Removed download operation after writeIPL call (it is now one of the routines parameters).
* Added sanity check (null pointer passed) to flSetEnvVolume, flSetDocBusRoutine and flGetDocBusRoutine.
*
* Rev 1.39 Jan 28 2002 21:23:32 oris
* Bug fix - initialization of flPolicy variable caused a memory lick (set max unit chain to 0).
* Changed FL_NFTL_CACHE_ENABLED to FL_TL_CACHE_ENABLED.
* Changed flSetDocBusRoutine interface and added flGetDocBusRoutine.
* Added FL_IPL_DOWNLOAD flag to writeIPL routine in order to control whether the IPL will be reloaded after the update.
*
* Rev 1.38 Jan 23 2002 23:30:46 oris
* Added a call to flExit() in case flSuspend was restored to FL_OFF.
* Moved Alon based DiskOnChip write IPL routine from blockdev, to diskonc.
* Added sanity check to flCheckVolume() - Make sure irData is NULL and irLength is set to 0.
*
* Rev 1.37 Jan 21 2002 20:43:36 oris
* Bug fix - Missing\bad support for FL_SECTORS_VERIFIED_PER_FOLDING and FL_VERIFY_WRITE_BDTL environment variables.
*
* Rev 1.36 Jan 20 2002 20:40:20 oris
* Improved documentation of bdFormatPhisycalDrive - Added TL_NORMAL_FORMAT flag was added.
* Removed ifdef NO_PHYSICAL_IO from flGetBPB routine.
*
* Rev 1.35 Jan 17 2002 22:56:22 oris
* Placed docbdk.h under BDK_ACCESS ifdef
* Added include directive to docsys.h
* Removed function prototypes from header.
* Changed FLFlash record in the volume structure into a pointer
* Added flBusConfig variable and flSetDocBusRoutine() routine for runtime control over memory access routines - under the FL_NO_USE_FUNC definition.
* Added flSectorsVerfiedPerFolding environment variable was added
* Added flSuspendMode environment variable was added.
* Changed flVerifyWrite environment variable : 4 for Disk partitions 3 for Binary and 1 for the rest.
* Changed flPolicy to be partition specific.
* Changed flSetEnv() routine was changed into 3 different routines: flSetEnvVolume / flSetEnvSocket / flSetEnvAll
* Variables types for environment variables were changed to the minimal size needed.
* Added flInitEnvVars() routine for setting default values to environment variables.
* Use single FLFlash record for each volume - (change vol.flash to a pointer instead of the record itself).
* Added \r to all DEBUG_PRINT routines.
* Removed SINGLE_BUFFER ifdef.
* Added volume verification after format for faster write performance with FL_OFF.
* Removed FLFlash parameter to all TL calls (flMount / flFormat / flPreMount )
* Added support for firmware other then the 3 defaults (getExbInfo additional parameter)
* Added support for M+ 16MB
* Added partition parameter to setBusy - Stores current partition in the socket record for the use of lower TrueFFS layers .
* Changed tffsmin to TFFSMIN
* Added FL_VERIFY_VOLUME functionNo.
* Made sure flInit() initializes all sockets and flashes volumes
* Added flClearQuickMountInfo() routine (FL_CLEAR_QUICK_MOUNT_INFO)
* readIPL routine now supports all DiskOnChip
*
* Rev 1.34 Nov 29 2001 20:53:44 oris
* Bug fix - flInquireCapabilities() returned bad status for SUPPORT_WRITE_IPL_ROUTINE.
*
* Rev 1.33 Nov 21 2001 11:40:44 oris
* Changed FL_MULTI_DOC_NOT_ACTIVE to FL_OFF, FL_VERIFY_WRITE_MODE to FL_MTD_VERIFY_WRITE , FL_WITHOUT_VERIFY_WRITE to FL_OFF , FL_MARK_DELETE to FL_ON.
*
* Rev 1.32 Nov 08 2001 10:44:04 oris
* Added flVerifyWrite environment variable that controls the verify write mode at run-time.
* Added support for large DiskOnChip in flBuildGeometry.
* Remove s/w protection from binary partition.
* Placed flAbsMount under ABS_READ_WRITE compilation flag.
*
* Rev 1.31 Sep 24 2001 18:23:04 oris
* Removed warnings.
*
* Rev 1.30 Sep 15 2001 23:44:22 oris
* Changed BIG_ENDIAN to FL_BIG_ENDIAN
*
* Rev 1.29 Aug 02 2001 20:04:04 oris
* Added support for 1k IPL for DiskOnChip 2000 TSOP - writeIPL()
*
* Rev 1.28 Jul 29 2001 19:14:24 oris
* Bug fix for TrueFFS internal mutex when using multi-doc and environment variables (when no multi-doc feature is disbaled)
*
* Rev 1.27 Jul 13 2001 00:59:28 oris
* Changed flash lifetime calculation according to specific flash.
*
* Rev 1.26 Jun 17 2001 08:16:50 oris
* Added NO_PHISICAL_IO compilation flag to reduce code size.
* Added NO_READ_BBT_CODE compilation flag to reduce code size.
* Changed placeExbByBuffer exbflags argument to word instead of byte to support /empty flag.
* Deleted redundent #ifdef MULTI_DOC in flInit().
*
* Rev 1.25 May 31 2001 18:11:52 oris
* Removed readBBT routine from under the #ifndef FL_READ_ONLY.
*
* Rev 1.24 May 16 2001 21:16:08 oris
* Changed the Binary state (0,1) of the environment variables to meaningful definitions.
* Added flMtlDefragMode environment variable.
* Added the FL_ prefix to the following defines: ON, OFF
* Bug fix - One of the "ifndef" statement of NO_IPL_CODE was coded as "ifdef"
* Change "data" named variables to flData to avoid name clashes.
*
* Rev 1.23 May 09 2001 00:31:00 oris
* Added NO_PHYSICAL_IO , NO_IPL_CODE and NO_INQUIRE_CAPABILITY compilation flags to reduce code size.
*
* Rev 1.22 May 06 2001 22:41:04 oris
* Bug fix - flInquireCapabilities routine did not return the correct value when capability was not supported.
* Added SUPPORT_WRITE_IPL_ROUTIN capability.
* Removed warnings.
*
* Rev 1.21 May 01 2001 17:05:10 oris
* Bug fix - bad argument check in flSetEnv routine.
*
* Rev 1.20 Apr 30 2001 17:57:00 oris
* Added new environment variable flMarkDeleteOnFlash.
*
* Rev 1.19 Apr 24 2001 17:05:38 oris
* Bug fix flMoutVolume routine return the correct hidden sectors even if high level mount fails.
* Bug fix Write IPL routine supports Doc2000 TSOP as well as Millennium Plus.
* Support readBBT new interface.
*
* Rev 1.18 Apr 18 2001 20:43:00 oris
* Added force download call after writing IPL.
*
* Rev 1.17 Apr 18 2001 19:14:24 oris
* Bug fix - binary partition insert and remove key routine no longer stop the place exb proccess.
*
* Rev 1.16 Apr 18 2001 09:26:22 oris
* noOfDrives variable was changed to unsigned. This is a bug fix for vxWorks boot code.
* Make sure blockdev does not try to mount more volumes then the VOLUMES definition.
*
* Rev 1.15 Apr 16 2001 13:02:38 oris
* Removed warrnings.
*
* Rev 1.14 Apr 12 2001 06:48:22 oris
* Added call to download routine after physical format in order
* to load new IPL and to initialize new protection information.
* Removed warnings.
*
* Rev 1.13 Apr 03 2001 16:33:10 oris
* Removed unused variables.
* Added proper casting in otpSize call.
*
* Rev 1.12 Apr 03 2001 14:33:16 oris
* Bug fix in absRead sectors when reading multiple sectors.
*
* Rev 1.11 Apr 01 2001 14:57:58 oris
* Bug fix in read multiple sectors.
*
* Rev 1.10 Mar 28 2001 06:19:12 oris
* Removed flChangeEnvVar prototype.
* Left alligned all # directives.
* Bug fix in flSetEnv ((value !=0)||(value!=1)) => ((value !=0)&&(value!=1)) + downcast for given argument + add return status code
* Removed unused variables.
* Remove casting warnnings.
* Add arg check in bdFormatPhysicalDrive for BDTLPartitionInfo != NULL.
* Bug fix for absWrite - multi-secotr write should be initialized with zeros to prevent sector found return code.
* Replaced the numbers in writeProtect routine to defines (moved from ioctl.h to blockdev.h).
* Add break for mdocp identification in getPhysicalInfo.
* Added readIPL routine.
* Added LOG_FILE compilation flag for EDC errors for mdocp.
* Added initialization of tl table in flInit.
* flExit mutex bug fix.
*
* Rev 1.9 Mar 05 2001 21:00:34 oris
* Bug fix - initialize exbLen argument in bdFormatVolume.
* Bug fix - initialize bdtlFp flags fiels in bdFormatVolume.
* Restored the flExit pragma under __BORLANDC__ compilation flag
*
* Rev 1.8 Feb 22 2001 20:21:34 oris
* Bug fix in flExit with multi-doc release uncreated mutxe.
*
* Rev 1.7 Feb 20 2001 15:44:58 oris
* Bug fix for mutex initialization in flInit.
*
* Rev 1.6 Feb 18 2001 23:29:28 oris
* Bug fix - Added findFreeVolume call in flFormatPhysicalDrive.
* bug fix - Added partition sanity check in bdcall entrence.
* bug fix - Increamented pVol before entering loop in flExit.
*
* Rev 1.5 Feb 18 2001 14:13:22 oris
* Restored FL_BACKGROUND.
* Place bdkCall extern prototype under BDK_ACCESS compilation flag.
* Changed multiple volume mechanism - Replaced removeVolumeHandles and
* flConvertDriveHandle routines with flInit + findFreeVolume and changed
* dismountPhysicalDrive + flEacit to comply.
* Changed bdcall volume validity check.
* Added new volume flag VOLUME_ACCUPIED.
* Moved all the new environment variable (flPolicy,flUseMultiDoc and flMaxUnitChain)
* from flcustom.c in order to allow backwards competability.
* Removed globalMutex (for now).
* Allocate only 1 mutex when multi-doc is registered therfore setBusy takes only 1 mutex .
* Bug fix - absRead and absWrite add bootSectors to the given sectors.
* Bug fix - INVALID_VOLUME_HANDLE changed to INVALID_VOLUME_NUMBER.
* Bug fix - Added (byte FAR1 *) casting in readBBT call.
* Bug fix - Added (FLCapability FAR2 *) casting in inquire capability call.
*
* Rev 1.4 Feb 14 2001 01:51:32 oris
* Completly revised flInquireCapabilities routine.
* Added oldFormat flag to flBuildGeometry routine.
* Remove FL_BACKGROUND compilation flag.
* Added arg check for flSetEnv + new FL_SET_MAX_CHAIN.
* Changed FL_COMPLETE_ASAP_POLICY to FL_SET_POLICY.
* Moved argument check in flFormatPhysicalDrive to fltl.c.
* Moved readBBT routine inside bdcall.
* Placed volumeInfo C\H\S data under ABS_READ_WRITE.
*
* Rev 1.3 Feb 13 2001 02:10:48 oris
* Changed flChangeEnvVar routine name to flSetEnv
*
* Rev 1.2 Feb 12 2001 11:51:12 oris
* Added function prototype in begining of the file.
* Change routine order in the file.
* Added mutex support for TrueFFS 5.0 partitions while changing bdcall order.
* flMountVolume returns the number of boot sectors.
* Moved the writeBBT routine to FLTL.C.
* Added static before changePassword.
* Added static before writeProtect.
* Added static before dismountLowLevel.
* Added static before writeIPL.
* Added static before inquireCapabilities.
* window base is returned by getPhysicalInfo in irLength.
* Added MULTI_DOC compliation flag.
*
* Rev 1.1 Feb 07 2001 17:55:06 oris
* Buf fix for writeBBT of no bad blocks
* Moved readBBT routine from under the fl_read_only define
* Added casting in calls to readBBT and writeBBT
* Added checkStatus check for flAbsWrite and flAbsRead routines
* Added initialization of noOfMTDs and noOfSockets in flInit
*
* Rev 1.0 Feb 04 2001 18:53:04 oris
* Initial revision.
*
*/
/*************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
/* All Rights Reserved */
/*************************************************************************/
/* NOTICE OF M-SYSTEMS OEM */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -