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

📄 tffs_api.c

📁 H3 M-system NAND flash driver in Linux OS, M-DOC driver
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** *                                                                            * * Project: DOC Driver for Linux 2.4 Block device driver for mDOC H3  family  * * of devices under Linux kernel 2.4.                                         * *                                                                            * *   Version: 1.0                                                             * *   Email questions to: oemsupport@sandisk.com                               * *   Copyright (C) SanDisk IL Ltd. 1995 - 2007                                * *   SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel             * *                                                                            * ****************************************************************************** *                                                                            * * This program is free software; you can redistribute it and/or modify it    * * under the terms of the GNU General Public License as published by the Free * * Software Foundation; either version 2 of the License, or any later version.* * This program is distributed in the hope that it will be useful, but WITHOUT* * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      * * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  * * more details, which is set forth in the readme.txt file.                   * * You should have received a copy of the GNU General Public License along    * * with this program; if not, write to the Free Software Foundation, Inc., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                    * *                                                                            * * This License does not grant you any right to use the trademarks, service   * * marks or logos of SanDisk IL Ltd. or SanDisk Corporation.                  * * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its * * licensors, hereby reserves all intellectual property rights in the program,* * except for the rights expressly granted in this License.                   * *                                                                            * ******************************************************************************//*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/tffs_api.c-arc  $
 * 
 *    Rev 1.81.1.8   Nov 30 2006 10:24:16   Yaniv.Iarovici
 * Fixed compilation warnings.
 * 
 *    Rev 1.81.1.7   Nov 21 2006 14:26:32   Yaniv.Iarovici
 * Enable removing 'lock enabled' attribute from a partition.
 * 
 *    Rev 1.81.1.6   Nov 12 2006 09:48:00   Yaniv.Iarovici
 * Write default/customized delay cell configuration values in flWriteIPL().
 * 
 *    Rev 1.81.1.5   Nov 01 2006 08:56:28   Yaniv.Iarovici
 * Prevent leaving ALL existing partitions in flFlashFormat().
 * 
 *    Rev 1.81.1.4   Oct 31 2006 14:00:52   yaniv.iarovici
 * Prevent setting a NON-CHANGABLE partition to CHANGEABLE.
 * 
 *    Rev 1.81.1.3   Oct 30 2006 15:50:40   yaniv.iarovici
 * Fixed comment for flFlashFormat().
 * 
 *    Rev 1.81.1.2   Oct 29 2006 11:00:00   Yaniv.Iarovici
 * 1. All HW protection related routines enabled in bdCall() 
 *    (Removed '#ifdef HW_PROTECTION')
 * 2. Added casting to (void*) on 'DEFAULT_KEY' when calling tffsAPISetIoreq().
 * 
 *    Rev 1.81.1.1   Oct 25 2006 09:10:48   Yaniv.Iarovici
 * 1. Declare TFFSIdentifyProtection().
 * 2. Remove '#ifdef FL_EXTENDED_DISK_INFO' from implementation of TFFSGetExtendedDiskInfo().
 * 3. Change comment in description of TFFSFlashFormat().
 * 4. In TFFSUnFormat() - Check that all partitions are authenticated before trying to unformat.
 * 5. Remove '#ifdef HW_PROTECTION' from implementation of protection routines.
 * 6. Allow setting Normal IPL mode when using 8KB window.
 * 7. Allow removing the 'CHANGEABLE_PROTECTION' attribute from a partition.
 * 
 *    Rev 1.81.1.0   Oct 22 2006 14:54:14   yaniv.iarovici
 * 1. Fixed compilation warnings.
 * 2. Changed flRegisterDOCH3SOC()return type to FLStatus.
 * 
 *    Rev 1.81   Oct 09 2006 14:06:06   yaniv.iarovici
 * 1. Fixed compilation errors when FL_RDA_ONLY is defined
 * 2. Fix TrueFFS version in TFFSGetExtendedDiskInfo()
 * 
 *    Rev 1.80   Oct 05 2006 11:01:22   yaniv.iarovici
 * 1. Modified debug prints.
 * 2. Removed unnecessary use of #ifdef HW_OTP
 * 3. Fixed wrong protection attribute returned by TFFSIdentifyProtection() 
 *    for READ and WRITE protected partition.
 * 
 *    Rev 1.79   Sep 14 2006 09:56:50   yaniv.iarovici
 * Set IPL partition as 'protectable' upon its creation.
 * 
 *    Rev 1.78   Sep 13 2006 10:30:46   yaniv.iarovici
 * Fix compilation warnings
 * 
 *    Rev 1.77   Sep 11 2006 13:45:28   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.76   Sep 03 2006 14:45:22   Yaniv.Iarovici
 * 1. Allow calling TFFSGetExtendedDiskInfo() without request for specific partition info.
 * 2. Bug fix: In TFFSChangeProtectionType() - set dwLockControl correctly.
 * 
 *    Rev 1.75   Aug 24 2006 11:40:04   Yaniv.Iarovici
 * Bug fix in TFFSGetExtendedDiskInfo() - wrong return code checked.
 * 
 *    Rev 1.74   Aug 22 2006 13:26:56   Yaniv.Iarovici
 * Fix calculation of 'numOfBinaryParToLeave' when BDK_ACCESS is defined.
 * 
 *    Rev 1.73   Aug 17 2006 15:33:28   Yaniv.Iarovici
 * Remove Joint Protection
 * 
 *    Rev 1.71   Aug 17 2006 15:20:18   Yaniv.Iarovici
 * 1) Encapsulate Joint Protection code under '#ifdef FL_JOINT_PROTECTION' (NOT define by default!)
 * 2) Fix Joint protection support for Read protected partitions.
 * 
 *    Rev 1.69   Aug 16 2006 08:48:26   Yaniv.Iarovici
 * 1) Enable READ+Write protection:
 * 	- tffsFormatSetProtectionAttribs()
 * 	- TFFSChangeProtectionType()
 * 2) TFFSflashFormat():
 * 	- Add /LEAVE support for BDTL partitions as well as BDK
 * 	- Rename 'binParToLeave; to 'numOfParToLeave '
 * 	- Encasulate BDK related code by '#ifdef BDK_ACCESS'
 * 3) Fix description for TFFSChangeProtectionType()
 * 4) Encapsulate BDK related code under '#ifdef BDK_ACCESS'.
 * 5) Change error code returned by 'TFFSChangeProtectionKey()' to flHWProtection.
 * 
 *    Rev 1.67   Aug 09 2006 17:27:40   Polina.Marimont
 * initial for DOC Driver 1.0
 * 
 *    Rev 1.66   Aug 09 2006 17:20:28   Polina.Marimont
 * initial for DOC Driver 1.0, DPD fixes from branch  1.64... applied
 * 
 *    Rev 1.63   Jul 03 2006 22:13:56   polina.marimont
 * 1. bug fix - protection with leave failed to format
 * 2. bug fix - flags returned by identifyProtection on OTW protected partition
 * 
 *    Rev 1.62   Jun 28 2006 11:34:56   Polina.Marimont
 * bug fix - TFFSGetUniqueID() shoudl be enabled / disabled by HW_OTP flag and not by FL_EXTENDED_DISK_INFO
 * 
 *    Rev 1.61   Jun 28 2006 10:36:00   Polina.Marimont
 * bug fix - writeIPL() on non-first data chunk caused to wrong data to be written
 * 
 *    Rev 1.60   Jun 27 2006 15:53:26   Polina.Marimont
 * bug fix flVolumeInfo() API return base address 
 * 
 *    Rev 1.59   Jun 26 2006 11:05:22   Polina.Marimont
 * added include to hib.h file
 * 
 *    Rev 1.58   Jun 22 2006 17:55:38   Polina.Marimont
 * compilation warnings fixes
 * 
 *    Rev 1.57   Jun 22 2006 13:18:40   Polina.Marimont
 * updated comments
 * 
 *    Rev 1.56   Jun 22 2006 09:36:46   Polina.Marimont
 * error codes compatibility for extendedDiskInfo()
 * 
 *    Rev 1.55   Jun 22 2006 09:06:06   Polina.Marimont
 * TFFSRemoveProtectionKey() error code compatibily fix
 * 
 *    Rev 1.54   Jun 21 2006 18:25:42   Polina.Marimont
 * 1. enter/exit DPD function fix
 * 2. change protection to OTW updated
 * 3. identify prrotection updated
 * 
 *    Rev 1.53   Jun 20 2006 12:40:28   Polina.Marimont
 * error codes for insert key and authenticate partition fixed to be compatible to non mDOC h3 devices
 * 
 *    Rev 1.52   Jun 18 2006 13:09:00   Polina.Marimont
 * 1. error codes changed to be compatible to non mDOC H3 devices
 * 2. macros definition usage update
 * 3. AutoDPD and DPD parameters set changed, storage moved to SA SDK
 * 
 *    Rev 1.51   Jun 14 2006 17:59:48   Polina.Marimont
 * 1. structure definitions moved to header file
 * 2. special function added for set IOreq structure parameters
 * 3. printing fixes
 * 4. bug fix - flash lifetime indication fix
 * 5. bug fix - number of volume on unformatted device (returns 1)
 * 6. check BDTL size should not be equal to 0, while formatting
 * 7. unformat - remove all, including OTP and IPL partitions from the device
 * 8. wipe sectors usage restored
 * 9. bdkWriteInit() added check for requested size exceeded subpartition size
 * 10. bug fix - used unit on BDK subparition rounded to the low boundary
 * 11. When EDGE interrupt configured - print warning and configure to LEVEL interrupt.
 * 
 *    Rev 1.50   May 31 2006 15:41:44   polina.marimont
 * TrueFFS 7.1.0 EQA16
 * 
 *    Rev 1.49   May 28 2006 14:50:30   polina.marimont
 * fix for IDENTIFY DEVICE
 * 
 *    Rev 1.48   May 28 2006 13:03:10   polina.marimont
 * update for IDENTIFY DEVICE change
 * 
 *    Rev 1.47   May 24 2006 14:57:26   polina.marimont
 * bugfix - erase BDK subpartition always erases first unit of subpartition 0
 * 
 *    Rev 1.46   May 24 2006 08:17:06   polina.marimont
 * dochVol.intermediateBuf - free added to tffsApiExit() function
 * 
 *    Rev 1.45   May 24 2006 08:13:30   polina.marimont
 * TFFSbdkPartitionInfo() - wrong handle received from ioreq.
 * 
 *    Rev 1.44   May 21 2006 18:06:44   polina.marimont
 * compilation errors fix, when CHECK_BEFORE_EVERY_COMMAND defined
 * 
 *    Rev 1.43   May 18 2006 14:29:56   polina.marimont
 * TFFSBdkPartitionInfo() fixed to return flBadDriveHandle, when wrong number of partition specified, using migration variable
 * 
 *    Rev 1.42   May 18 2006 09:47:06   polina.marimont
 * 1. IOCTL fixed
 * 2. used size set back to 0
 * 
 *    Rev 1.41   May 17 2006 15:42:28   polina.marimont
 * 1. Error codes are fixed up to Legacy + SA package
 * 2. LOCK and CHANGABLE protection support 
 * 3. Format fixed - common functions used to add IPL and OTP partitions, also to set partition protection attributes
 * 4. PassThrough implemented
 * 5. bug fixes
 * 
 *    Rev 1.40   Apr 11 2006 13:21:34   tal.heller
 * enable EraseBD API.
 * Bug Fix - Last Partition size wasn't initialized.
 * Fix CC compilation 
 * adapt SecureDelete ioreq implementation to DOCH
 * Bug Fix - StickLock API
 * Comments syntax errors.
 * 
 *    Rev 1.39   Mar 29 2006 16:39:50   DoronC
 * Bug fix - compilation warnings ove various compilers.
 * 
 *    Rev 1.38   Mar 27 2006 16:21:58   DoronC
 * Add DMA support.
 * 
 *    Rev 1.37   Mar 22 2006 17:35:46   DoronC
 * Bug fix - add signature to disk attributes in order to use only 
 * format made by TrueFFS 7.1 and not by host SDK.
 * Other format will force reformatting of the media.
 * 
 *    Rev 1.36   Mar 20 2006 17:21:58   DoronC
 * Bug fix - read IPL using buffers failed.
 * 
 *    Rev 1.35   Mar 20 2006 10:41:16   DoronC
 * Bug fix - protection change was not working.
 * 
 *    Rev 1.34   Mar 15 2006 16:17:54   DoronC
 * Bug fix - wrong flag was checked when reading IPL.
 * 
 *    Rev 1.33   Mar 15 2006 15:58:04   DoronC
 * Bug fix - change protection key caused an exception.
 * 
 *    Rev 1.32   Mar 15 2006 14:14:46   DoronC
 * Bug fix - formating protected partition with no active protection failed.
 * Bug fix - IPL flags were not checked.
 * 
 *    Rev 1.31   Mar 15 2006 11:28:16   DoronC
 * Bug fix - IPL write was not working properly.
 * Bug fix - BDK used size was faulty.
 * 
 *    Rev 1.30   Mar 14 2006 09:53:52   DoronC
 * Bug fix - DOCFlash win field was not initialized by the init routine
 *  causing exception on some conditions.
 * 
 *    Rev 1.29   Mar 06 2006 08:40:52   DoronC
 * Bug fix - protection identify was reported wrong.
 * 
 *    Rev 1.28   Mar 05 2006 15:52:24   DoronC
 * Protection structure of H3 changed to contain dwords instead
 *  of words.
 * 
 *    Rev 1.27   Mar 02 2006 12:02:30   DoronC
 * Bug fix - mount was checked for wrong number of partitions.
 * 
 *    Rev 1.26   Mar 02 2006 08:30:26   DoronC
 * Host SDK API changed from IOreq2 to IOreq.
 * 
 *    Rev 1.25   Feb 16 2006 11:32:38   DoronC
 * Store binary partition flags in the attributes and return then 
 * when requested by extendedInfo for computability with legacy 
 * devices.
 * 
 *    Rev 1.24   Feb 16 2006 10:02:40   DoronC
 * Bug fix - Compilation warnings removed.
 * Bug fix - Combining DPS between BDK and BDTL was not 
 * working properly during format.
 * Bug fix - change protection key&type of combined DPS was not 
 * working.
 * 
 *    Rev 1.23   Feb 14 2006 10:50:02   DoronC
 * Remove large variables from stack. use one global buffer for 
 * all large buffers needs.
 */


#include "flsystem.h"
#include "flcustom.h"
#include "defs.h"
#include "flbase.h"
#include "flstdcmp.h"

#include "flsystyp.h"
#include "flchkdef.h"
#include "blockdev.h"
#include "_docsys.h"

#include "hib.h"
#include "doch_ata.h"
#include "doch_api.h"
#include "bdkemul.h"
#include "tffs_api.h"
#include "doch_func.h"
#include "dochtl.h"


#define MAX_MOUNT_COUNT	100	/*100 Times...*/
#define DOCH_NUM_OF_PLANES		1
#define DOCH_NUM_OF_BANKS		1
#define DOCH_SECTORS_PER_PAGE	4
#define DOCH_SHARED_SECTORS		32

#define DOCH_CAPACITY_128MB		0x40000		/*In Sectors*/

⌨️ 快捷键说明

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