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

📄 oren_mtd.c

📁 M-System DOC(Disk on a Chip) Flash芯片映像读写工具, 可以进行二片Flash芯片的内容互相拷贝, 提高烧录程序的效率.
💻 C
📖 第 1 页 / 共 5 页
字号:
 /***********************************************************************************/
/*                        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/oren_mtd.c-arc  $
 * 
 *    Rev 1.43   Jan 14 2004 22:31:22   oris
 * Replaced FL_SLEEP with FL_TFFS_SLEEP (FL_SLEEP was used by Linux)
 * 
 *    Rev 1.42   Dec 09 2003 18:45:04   oris
 * Bad debug print message.
 * 
 *    Rev 1.41   Dec 04 2003 11:38:08   roneng
 * Bug Fix - in identification of 2GBit Toshiba flashes 
 * 
 *    Rev 1.40   Dec 03 2003 18:03:44   roneng
 * Add support to new flashes supported by 6.2 version
 * 
 *  
 * 
 *    Rev 1.39   Dec 01 2003 11:34:24   roneng
 * Remove calling to setBusType when FL_NO_USE_FUNC compilation flag is used 
 * 
 *    Rev 1.38   Nov 19 2003 16:44:04   roneng
 * Remove checking if key inserted in the 2nd time in
 * M512_WriteIpl MTD routine 
 * 
 *    Rev 1.37   Nov 16 2003 18:26:40   roneng
 * Changes in order to support new 0.13u Toshiba flashes
 * & 0.12u Samsung flashes
 * 
 *    Rev 1.36   Oct 30 2003 00:51:56   OriS
 * changed flSuspendMode to be socket specific and to accept FL_IGNORE_WRITE and FL_IGNORE_ERASE modes
 * 
 *    Rev 1.35   Oct 23 2003 13:55:30   oris
 * Replaced flsleep calls with FL_SLEEP macro.
 * 
 *    Rev 1.34   Oct 16 2003 11:42:46   roneng
 * fix compilation error 
 * 
 *    Rev 1.33   Oct 16 2003 11:24:28   roneng
 * - Add recovery whenever necessary from sequence or timeout   
 *   error 
 * - Add error printing when flGeneralFailure 
 * 
 *    Rev 1.32   Sep 30 2003 17:54:54   oris
 * changed comments
 * 
 *    Rev 1.31   11 Sep 2003 16:02:30   oris
 * Bug fix in floor identification routine might indentify more floors then there actually are.
 * 
 *    Rev 1.30   Sep 01 2003 19:04:24   oris
 * - Bug fix - search DiskOnChip bug fix - can now search OREN before or after M512 devices. Used to cause exceptions.
 * - Bug fix - Work always with access time=60nSec
 * - Bug fix - When reading in SW_EDC the extra buffer data is not correct (due to pointer calculation bug).
 * - 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.
 * - Added 2K Page support
 * - Reading from NOP_REG (for delay) was changed to Writing from NOP_REG 
 * - Add support to FL_USE_ONLY_2_COPIES This feature does not erase/write to redundancy unit. It also support updating of the DPS while keeping the IPL. A static buffer was used to store the IPL buffer.
 * - Change flsleep from /100 to >>10
 * - Added support to 64MB Infineon flash
 * - Removed tffsRAMXXX calls.
 * - Added default FLTXT macro for converting text to printable text strings.
 * - Changed Debug print in case of correctable BCH error to warnings instead of error.
 * 
 *    Rev 1.29   Aug 10 2003 14:33:04   roneng
 * oren_mtd.c
 * ----------------
 * - Added 2K Page support
 * - Reading from NOP_REG (for delay) was changed to Writing from NOP_REG 
 * - 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     
 *  - Add support to FL_USE_ONLY_2_COPIES
 *   This feature does not erase/write to redundancy unit      
 *  - Fix bug: When reading in SW_EDC the extra buffer data is not   
 *     correct (due to pointer calculation bug).
 * - Change flsleep from /100 to >>10
 * - Work always with access time=60nSec
 * - Added support to 64MB Infineon flash
 * 
 *    Rev 1.28   Jul 17 2003 10:39:10   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.27   Jul 02 2003 19:02:28   roneng
 * Add support to FL_USE_ONLY_2_COPIES
 * This feature does not erase/write to redundancy unit
 * 
 *    Rev 1.26   Jun 29 2003 15:45:16   roneng
 * - Fix bug: When reading in SW_EDC the extra buffer data is not   
 *    correct (due to pointer calculation bug).
 * 
 *    Rev 1.25   Jun 19 2003 13:22:54   roneng
 * - Add NOPS between command & address (and vice versa)
 * - Change number of NOPS before polling the flash R/B# signal 
 *    from 4 to 6 
 * 
 *    Rev 1.24   Jun 18 2003 21:42:10   OriS
 * Fix compiler warnings
 * 
 *    Rev 1.23   Jun 18 2003 19:14:54   roneng
 * - Fix compiler warnings
 * - Fix bug in ReadStatus routine: 2 Nops were added
 * 
 *    Rev 1.22   Jun 17 2003 18:22:16   roneng
 * Remove warning when working with FL_READ_ONLY
 * 
 *    Rev 1.21   Jun 17 2003 13:33:36   roneng
 * 1. convert LastOpStruct to be static variable.
 * 2. Bug Fix: When BCH find bit flip in the Hamming byte , flip it
 *     and use the corrected hamming byte for hamming check 
 * 
 *    Rev 1.20   Jun 15 2003 18:24:02   roneng
 * - Fix warnings
 * 
 *    Rev 1.19   Jun 12 2003 15:39:40   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.18   Jun 09 2003 22:20:10   oris
 * Bug fix - write operation while in verify write mode could have returned flDataError instead of flWriteFault.
 * 
 *    Rev 1.17   Jun 05 2003 03:16:58   oris
 * OREN_phyGetEraseMark routines was missing a FAR qualifier.
 * 
 *    Rev 1.16   Jun 02 2003 20:16:04   roneng
 * write to  flashPtr->socket->DPDState only if socket exist
 * 
 *    Rev 1.15   Jun 02 2003 09:15:18   roneng
 * - Return with flWriteFault when readStatus after erase failed 
 * - close M512_IsGoodBlock with MTD_READ_BBT compilation flag
 * 
 *    Rev 1.14   May 28 2003 18:41:16   oris
 * Fixed error status returned as a result of a sequance error in the identification routine.
 * 
 *    Rev 1.13   May 28 2003 18:04:24   roneng
 * - Remove MTD_VARS->bUnitSizeBits
 * 
 *    Rev 1.12   May 28 2003 12:16:40   roneng
 * - Remove MTD_VARS_OREN struct
 * - RecoverFromAccessError in all floors & add print if recovering  
 *    failed.
 * 
 *    Rev 1.10   May 18 2003 18:44:50   OriS
 * Fixed debug messages
 * 
 *    Rev 1.9   May 18 2003 15:23:04   OriS
 * Removed warnings when FL_READ_ONLY is defined.
 * 
 *    Rev 1.8   May 16 2003 00:58:32   OriS
 * Bug fix - Some missing set floor calls.
 * 
 *    Rev 1.7   May 12 2003 20:46:10   roneng
 * - Remove checking if the if_cfg is legal
 * - Write & use macro to read/write 8 bit of data 
 * - 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 
 * 
 * - Fix bug: when working with FL_READ_ONLY completeOperation should be defined
 * - Add break in switch case while finding flash type
 * 
 *    Rev 1.6   May 11 2003 17:39:42   roneng
 * Fix compilation error when working w/o HW_PROTECTION
 * 
 *    Rev 1.5   May 11 2003 08:28:24   OriS
 * Bug fix - IPL and HW_PROTECTION compilation flags where intermixed.
 * NO MATCHIN technology was reported even for single plane flashes.
 * 
 *    Rev 1.4   May 06 2003 11:56:26   OriS
 * 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
 * Bug fix in getting the protection attributes : logic changed for KEY_INSERTED attribute:
 *   - KEY_INSERTED is off when the MTD detected RP or WP 
 *     + The KEY_OK was set (Previously we checked only the KEY_OK)
 *  -  KEY_INSERTED is off when the MTD detected OTW 
 * Bug fix could not install user defined access layer
 * Bug fix in media identification 
 *   - All eraseCycles are 100,000
 *   - Change PageProgram timing for SLC & MLC 
 * 
 *    Rev 1.3   Apr 27 2003 14:09:08   Oris
 * Bug fix when NO_IPL_CODE is defined.
 * Make sure only the correct MTD tries to identify a media that was already found.
 * 
 *    Rev 1.2   Apr 27 2003 09:04:00   Oris
 * Changed debug messages.
 * Changed D2TST flag to be default and to be removed by NO_PHYSICAL_IO.
 * Changed internal clock to 60ns instead of default 80ns.
 * 
 *    Rev 1.1   Apr 13 2003 20:30:12   OriS
 * Compilation errors when HW_PROTECTION is not defined
 * 
 *    Rev 1.0   Apr 09 2003 12:15:56   OriS
 * Initial revision.
 * 
 */

/************************************************************************
 * Name     : oren_mtd.c                                                *
 *                                                                      *
 * Written  : Ronen Golan                                               *
 *                                                                      *
 * Abstract : This file contains the routines of the OREN MTD           *
 ************************************************************************/

/*****************************   #include     ***************************/
#include "docsys.h"
#include "logicmtd.h"
#include "oren_mtd.h"
#include "oren_exp.h"
#include "bch_hm.h"

 /*****************************    Compilation flags  **************************/
#define ACTIVATE_STOP_CLOCK  
/* #define DEBUG_MTD                */
/* #define AUTO_COMPLETE_OPERATION  */
/* #define ERASED_FLASH             */
 /******************************************************************************/  
#ifdef ERASED_FLASH 
#include "prod_exp.h"
#endif

/*****************************  extern        ***************************/
extern void MATCH_init (FLFlash *flashPtr) ;

/*****************************  Static Vars   ****************************/ 
#ifdef AUTO_COMPLETE_OPERATION
 static LastOperationResults  LastOpResults ;
#endif

/*****************************  Prototypes    ***************************/
FLStatus         OREN_doc2Identify      (FLFlash *flashPtr);
#ifndef FL_NO_USE_FUNC
static FLBoolean OREN_setBusType        (FLFlash *flashPtr,FLDword dBusConfig,
                                           FLByte bInterleave,FLByte bIF_CFG) ;
#endif
static FLStatus  OREN_readID_Seq        (FLFlash *flashPtr,FLByte *MakerCode,FLByte *DeviceCode);
static FLStatus  OREN_readID_2_Seq      (FLFlash *flashPtr,FLByte *bReadIdCodePtr);
static FLStatus OREN_enhancedReadID_Seq (FLFlash *flashPtr,FLByte *enhancedData) ;
#if (!defined(NO_IPL_CODE) || defined(HW_PROTECTION))
#ifndef FL_READ_ONLY
static FLStatus  OREN_readIPL_Page      (FLFlash *flashPtr,FLByte FAR1 *bIPL_PagePtr,
                                           FLByte bPage,FLByte bCopyFlag,FLByte bFloor,
                                          FLBoolean *bPageErased);
static FLStatus  OREN_writeIPL_Page     (FLFlash *flashPtr,FLByte FAR1 *IPL_Page,FLByte page,
                                          FLByte CopyFlag,FLByte Floor,FLByte VerifyWrite);
#endif /* FL_READ_ONLY */
#endif /* !NO_IPL_CODE || HW_PROTECTION*/
FLStatus OREN_phyWriteEraseMark (FLFlash *flashPtr,PhyUnitType phyUnit,FLByte bEraseMark,
                                           FLByte bFloor,FLByte bBank) ;

⌨️ 快捷键说明

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