📄 m512_mtd.c
字号:
/***********************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003 */
/* 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 */
/***********************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/mtd/m512_mtd.c-arc $
*
* Rev 1.46 Jan 27 2004 08:14:00 oris
* Changed comments
*
* Rev 1.45 Jan 14 2004 22:31:12 oris
* Replaced FL_SLEEP with FL_TFFS_SLEEP (FL_SLEEP was used by Linux)
*
* Rev 1.44 Dec 09 2003 18:44:58 oris
* Bad debug print message.
*
* Rev 1.43 Dec 01 2003 13:42:22 roneng
* Fix IPL size returned from MTD when (number of floors>2)
*
* Rev 1.42 Dec 01 2003 11:33:56 roneng
* Remove calling to setBusType when FL_NO_USE_FUNC compilation flag is used
*
* Rev 1.41 Oct 30 2003 00:52:12 OriS
* changed flSuspendMode to be socket specific and to accept FL_IGNORE_WRITE and FL_IGNORE_ERASE modes
*
* Rev 1.40 Oct 29 2003 17:18:56 roneng
* Bug Fix: When BCH error occurs in RAW mode checking HM caused exception
*
* Rev 1.39 Oct 23 2003 22:35:12 OriS
* Added support for FL_HW_CONTROLL_OVER_DPD compilation flag. This flag simplifies the use of the H/w DPD mode by customizing the FL_M512_DPD_MODE_BIT_VALUE flag.
*
* Rev 1.38 Oct 23 2003 13:55:52 oris
* Replaced flsleep calls with FL_SLEEP macro.
*
* Rev 1.37 Oct 20 2003 08:58:56 oris
* Bug fix - floors higher then the first could never enter DPD mode.
*
* Rev 1.36 Oct 16 2003 11:23:34 roneng
* - Add recovery whenever necessary from sequence or timeout
* error
* - Add error printing when flGeneralFailure
*
*
* Rev 1.35 Sep 30 2003 17:54:48 oris
* changed comments
*
* Rev 1.34 11 Sep 2003 16:02:24 oris
* Bug fix in floor identification routine might indentify more floors then there actually are.
*
* Rev 1.33 Sep 01 2003 19:06:28 oris
* - Add support to FL_USE_ONLY_2_COPIES. This feature does not erase/write to redundancy unit when updatinG the Dps.
* - Added default FLTXT macro for converting text to printable text strings.
* - Removed tffsRAMXXX calls.
* - search DiskOnChip bug fix - can now search OREN before or after M512 devices. Used to cause exceptions.
* - Changed Debug print in case of correctable BCH error to warnings instead of error.
* - Removed warnings
* - search DiskOnChip bug fix - can now search OREN before or after M512 devices. Used to cause exceptions.
* - Changed Debug print in case of correctable BCH error to warnings instead of error.
* - Bug fix - memory buffer is too small and gets corrupted in the following routines:
* M512_readIPL_Page, M512_writeIPL_Page, M512_isGoodBlock,
* - Bug fix - Busy signal while S/W download was not disabled.
*
* Rev 1.32 Aug 10 2003 13:55:40 roneng
* Change name of one of CompleteOpVars struct
*
* Rev 1.31 Jul 10 2003 17:18:44 roneng
* - search DiskOnChip bug fix and prevent exception.
* - Fix Windows XP warnings
* - The current patch was changed to allow updating the DPS
* while keeping the IPL.
* A static buffer was used to store the
* IPL buffer.
* - Busy signal while S/W download is disabled
*
* Rev 1.30 Jul 02 2003 18:57:58 roneng
* Add support to FL_USE_ONLY_2_COPIES
* This feature does not erase/write to redundancy unit
*
* Rev 1.29 Jun 18 2003 21:42:04 OriS
* Fix compiler warnings
*
* Rev 1.28 Jun 18 2003 19:13:22 roneng
* Fix compiler warnings
*
* Rev 1.27 Jun 17 2003 13:30:20 roneng
* 1. Bug Fix: When BCH fails to correct the buffer write to END_OF_DATA register (caused timeout on the next operation)
* 2. convert LastOpStruct to be static variable.
* 3. Bug Fix: When BCH find bit flip in the Hamming byte , flip it
* and use the corrected hamming byte for hamming check
*
* Rev 1.26 Jun 17 2003 10:01:10 roneng
* Bug fix in entering/exiting DPD mode:
* - Reset CE in FLASH_CONTROL_REG before entering DPD
* - While exiting from DPD perform DirectRead instead of regular read
*
* Rev 1.25 Jun 15 2003 19:00:02 roneng
* Check that DiskOnChip in all floors has the same product type
*
* Rev 1.24 Jun 15 2003 18:23:30 roneng
* - Fix warnings
*
* Rev 1.23 Jun 12 2003 21:43:58 oris
* Bug fix - wrong initialization of ecc register when more the 1 floor.
*
* Rev 1.22 Jun 12 2003 15:35:28 roneng
* 1. In case that BCH indicated that 1..4 bit flips were found than
* after correcting the bit flips an hamming ECC check on the
* fixed buffer was added.
* 2. In case of failure reading of BBT return flBadBBT instead of
* flDataError
*
*
*
* Rev 1.21 Jun 09 2003 22:20:06 oris
* Bug fix - write operation while in verify write mode could have returned flDataError instead of flWriteFault.
*
* Rev 1.20 Jun 03 2003 11:57:26 roneng
* - Clear WP before reset_seq when recovering from sequence/protection error
*
* Rev 1.19 Jun 02 2003 09:00:22 roneng
* close M512_IsGoodBlock with MTD_READ_BBT compilation flag
*
* Rev 1.18 May 28 2003 18:41:18 oris
* Fixed error status returned as a result of a sequance error in the identification routine.
*
* Rev 1.17 May 28 2003 18:03:24 roneng
* - Change MTD_VARS->wNumOfUnits from 1024 to 2048
* - Remove MTD_VARS->bNumOfUnitsBits
*
* Rev 1.16 May 28 2003 12:07:30 roneng
* - IPL is read using DirectRead instead of regular Read
* - MAX_ID is returned to its previous value after Read IPL ends
* - Add print if Recovering from access error failed
*
* Rev 1.14 May 19 2003 17:18:24 roneng
* - Change Debug print when readstatus after erase fails
* - Remove extra ; from end of line
*
* Rev 1.13 May 19 2003 13:51:50 roneng
* - Bug Fix: When ReadProductID fails return flUnknownmedia
* - Bug Fix: When PageProgram_Seq recieves opFlags = DATA
* return flBadParameter
*
* Rev 1.12 May 18 2003 18:44:44 OriS
* Fixed debug messages
*
* Rev 1.11 May 18 2003 15:23:06 OriS
* Removed warnings when FL_READ_ONLY is defined.
*
* Rev 1.10 May 16 2003 00:57:58 OriS
* Fixed compilation errors in Linux
* Bug fix - Wait for download to finish code when using more then one floor was incorrect
* Bug fix - Remove write protection from first good unit in case of more then 1 floor was incorrect.
* Bug fix - Bad support for disabled VERIFY_WRITE compilation flag in case of flash write failure.
* Bug fix - compilation when HW_PROTECTION is turned off.
* Bug fix - check for download error of floors higher then 1
*
* Rev 1.9 May 12 2003 20:36:44 roneng
* - Remove checking if the if_cfg is legal
* - Write & use macro to read/write 8 bit of data
* - Fix bug in while reading in S/W_EDC mode more than one sector
* - Remove verifiying buffer when working in SW_EDC mode
* - Size of internal extra buffer in reading should be 16 and not 8
* - Fix bug in COTP_Write and COTP_Size when working in BIG_ENDIAN
*
* Rev 1.8 May 11 2003 19:48:24 roneng
* Fix bug in page program with Verify_Write when working
* with SW_EDC flag
*
* Rev 1.7 May 11 2003 17:37:14 roneng
* 1. Fix bug in writing/reading the dummy byte
* 2. Fix compilation error when working w/o HW_PROTECTION
*
* Rev 1.6 May 11 2003 08:28:16 OriS
* Bug fix - IPL and HW_PROTECTION compilation flags where intermixed.
*
* Rev 1.5 May 08 2003 23:37:58 OriS
* Bug fix - Wrong FLASH write performance.
* Bug fix - verify write did not function in odd sectors.
* Removed warnings.
*
* Rev 1.4 May 06 2003 11:56:36 OriS
* Bug fix could not install user defined access layer
* Added LowerPriorityThread & HigherPriorityThread calls to WaitForReady
* Changed D2TST compilation flag to !NO_PHYSICAL_IO
* Bug fix in the KEY_INSERTED attribute reported by the MTD
* Changed TFFSCPY to tffsRAMcpy
* Changed TFFSCMP to tffsRAMcmp
* Changed TFFSSET to tffsRAMset
* Bug fix - Check that if Timeout occurred check also that if
* sequence error occurred perform recovery from sequence error.
* Bug fix in do not wait for ready support
* Changed sharedSector of P3 devices to 1
*
* Rev 1.3 Apr 27 2003 14:12:28 Oris
* Make sure only the correct MTD tries to identify a media that was already found
* Bug fix - Recover from sequence error in reset sequence.
* Bug fix - did not compile when NO_IPL_CODE was defined.
*
* Rev 1.2 Apr 27 2003 09:03:14 Oris
* Changed debug messages.
* Bug fix - wrong sharedSectors and flashTechnolegy arguments and flashTechnolegy.
* Changed D2TST flag to be default and to be removed by NO_PHYSICAL_IO.
*
* Rev 1.1 Apr 13 2003 20:30:02 OriS
* Removed global compilation flags.
* Added support for both SLC modes
* Bug fix - missing op code in reliable SLC sequance routine
* Bug fix - page program of main + extra where main is null
* Bug fix - verify write code did not work
* Improper place for reset sequance in read routine
* Bug fix - BCH and humming correctin did not work.
* Compilation errors when HW_PROTECTION is not defined
* Bug fix - bad report of max BBT for P3 devices.
* Bug fix - bad report of shared sectors
*
* Rev 1.0 Apr 09 2003 12:15:54 OriS
* Initial revision.
*
*/
/************************************************************************
* Name : m512_mtd.c *
* *
* Written : Ronen Golan *
* *
* Abstract : This file contains the routines of the MDOC-512 MTD *
************************************************************************/
/********************* Compilation flags *************************/
/* #define DEBUG_MTD */ /* Mode for debugging the MTD */
/* #define TURBO_MODE_SUPPORT */ /* Turbo Mode support within the MTD */
/* #define AUTO_COMPLETE_OPERATION */ /* Do not poll all erase & write operations */
/* #define FL_USE_ONLY_2_COPIES */
/***********************************************************************/
/***************************** #include ***************************/
#include "docsys.h"
#include "logicmtd.h"
#include "m512_mtd.h"
#include "m512_exp.h"
#include "bch_hm.h"
/***************************** extern ***************************/
extern void MATCH_init (FLFlash *flashPtr) ;
/***************************** Static Vars ****************************/
#ifdef AUTO_COMPLETE_OPERATION
static LastOperationResults LastOpResults ;
#endif
/***************************** Prototypes ***************************/
FLStatus M512_doc2Identify (FLFlash *flashPtr);
#ifndef FL_NO_USE_FUNC
static FLBoolean M512_setBusType (FLFlash *flashPtr,FLDword dBusConfig,
FLByte bInterleave,FLByte bIF_CFG) ;
#endif
#if (!defined(NO_IPL_CODE) || defined(HW_PROTECTION))
FLStatus M512_readIPL_Page (FLFlash *flashPtr,FLByte FAR1 *bIPL_PagePtr,
FLByte bPage,FLByte bCopyFlag,FLByte bFloor,
FLBoolean *bPageErased);
#ifndef FL_READ_ONLY
static FLStatus M512_writeIPL_Page (FLFlash *flashPtr,FLByte *IPL_Page,FLByte page,
FLByte CopyFlag,FLByte Floor,FLByte VerifyWrite);
#endif
#endif /* (!defined(NO_IPL_CODE) || defined(HW_PROTECTION)) */
FLStatus M512_phyWriteEraseMark (FLFlash *flashPtr,PhyUnitType phyUnit,
FLByte bEraseMark) ;
FLByte M512_Read8BitReg (FLFlash *flashPtr,FLWord wOffset) ;
FLStatus M512_reset_Seq (FLFlash *flashPtr) ;
void M512_asicSetMode (FLFlash *flashPtr, FL_AsicModeE AsicMode);
#ifndef FL_READ_ONLY
static void M512_completeOperationErase (FLFlash *flashPtr,
LastOperationResults *completeOpStruct,
completeOpVarsStruct *completeOpVars) ;
static void M512_completeOperationWrite (FLFlash *flashPtr,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -