www.pudn.com > NAND.rar > Common.h


/******************************************************************************* 
   Filename:	Common.h 
   Description: Library containing general define used by all project files  
   Version: 	1.0 
   								 
Copyright (ST Microlectronics) <2004>   
  
 
	This library is free software; you can redistribute it and/or 
	modify it under the terms of the GNU Lesser General Public 
	License as published by the Free Software Foundation; either 
	version 2.1 of the License, or (at your option) any later version. 
 
	This library 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 
	Lesser General Public License for more details. 
 
	You should have received a copy of the GNU Lesser General Public 
	License along with this library; if not, write to the Free Software 
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
******************************************************************************** 
 
   Version History. 
 
   Ver.   Date  	  Comments 
   0.7   19/02/2004   Compiled in all project files 
   1.0   20/04/2004   Released ST_NFTL vesrsion 1.0 
   
******************************************************************************* 
 
		  CONFIDENTIAL - SUBJECTED TO NDA RESTRICTION 
 
********************************************************************************/ 
 
 
 
 
#ifndef __COMMON__H__ 
#define __COMMON__H__ 
 
 
 
 
/* Basic Data-type*/ 
typedef unsigned char UINT8; 
typedef signed char INT8; 
typedef unsigned short UINT16; 
typedef signed short INT16; 
typedef unsigned int UINT32; 
typedef signed int INT32; 
 
 
/**************************************************************************** 
			Return Codes 
****************************************************************************/ 
 
typedef INT8 NFTL_Return; 
 
#define SUCCESS 				0x01	/* the operation was  
																																		   successfully completed*/ 
#define FAILURE 				0x00	/* the operation failed */ 
#define WRONG_ADDRESS   		0x02	/* the address is not within partition*/ 
#define UNWRITTEN   			0x04	/* the page read is always written*/ 
#define PAGENOTFOUND			0x08	/* there is not a valid page in tree */		 
#define DEVICE_UNFORMATTED 		0x10	/*  */ 
#define FLUSH_ERROR				0x20	/*write error during flush*/ 
#define INVALID_ADDRESS			0x30	//address invalid 
#define DANGEROUS_VIRTUALBLOCK	0x12 
 
 
/************** END Return Codes ***************/  
 
#define BUFFER_SPARE_SIZE				16 
#define SECTOR_SIZE						512 
 
 
#define	SWAP_PAGE_BYTE					8 
#define PAGE_STATUS_COPY_BYTE			9 
//#define	ROOT_COUNTER_BYTE				10 
//#define ERASE_STATUS_BYTE   			11 
#define ERASE_STATUS_BYTE   			15 
 
 
#define ROOT_POSITION					0x0 
 
#define SECTOR_ZERO						0x00 
#define LEFT_NODE						0x00 
#define RIGHT_NODE						0x80 
#define WRITTEN							0x01 
#define LEVEL(N)						(0x00 | (N)) 
#define ERASED  						0x00 
#define NOT_ERASED  					0xFF 
 
 
/******************************************/ 
#if 0 
//bytes spare area 
#define ECC1_BYTE						0 
#define ECC2_BYTE						1 
#define ECC3_BYTE						2 
 
#define TREE_POSITION_BYTE				6/*3*/ 
#define COPY_TREE_POSITION_BYTE 		10 
 
#define PAGE_STATUS_BYTE				4 
 
#define BLOCK_STATUS_BYTE				5   
#define COPY_BLOCK_STATUS_BYTE  		11 
 
#define	ROOT_COUNTER_BYTE			3	/*6*/   
 
#define	INVALID_BLOCK_BYTE    			12  
 
 
#define VIRTUAL_BLOCK_NUMBER_BYTE		7  
//  	VIRTUAL_BLOCK_NUMBER_BYTE_2 	8  
 
 
#define COPY_VIRTUAL_BLOCK_NUMBER_BYTE	13 
//    COPY_VIRTUAL_BLOCK_NUMBER_BYTE_2  14   
 
#define SECTOR_NUMBER   				9    
#define COPY_SECTOR_NUMBER  			15 
#endif 
#if 1 
//bytes spare area 
#define ECC1_BYTE						0 
#define ECC2_BYTE						1 
#define ECC3_BYTE						2 
 
#define TREE_POSITION_BYTE				6/*3*/ 
#define COPY_TREE_POSITION_BYTE 		4/*10*/ //new 
 
#define PAGE_STATUS_BYTE				10/*4*/ //new 
 
#define BLOCK_STATUS_BYTE				5   
#define COPY_BLOCK_STATUS_BYTE  		15/*11*/ 
 
#define	ROOT_COUNTER_BYTE			3	/*6*/   
 
#define	INVALID_BLOCK_BYTE    			12  
 
 
#define VIRTUAL_BLOCK_NUMBER_BYTE		7  
//  	VIRTUAL_BLOCK_NUMBER_BYTE_2 	8  
 
 
#define COPY_VIRTUAL_BLOCK_NUMBER_BYTE	13 
//    COPY_VIRTUAL_BLOCK_NUMBER_BYTE_2  14   
 
#define SECTOR_NUMBER   				9    
#define COPY_SECTOR_NUMBER  			11/*15*/ 
#endif//new 
/************************************************/ 
#define ALL_ONE							0xFF 
#define NOT_VALUE						100	 
#define FREE_BLOCK						0xFF 
#define NO_FREE_BLOCKS					0x10 
#define NO_INVALID_BLOCKS				0x12 
#define BBT_ALREADY_EXISTING			(UINT16) -1 
#define DATA_STRUCTURE_FULL				0x11 
#define READ_OPERATION					0x01 
#define WRITE_OPERATION					0x03 
#define SECTOR_SWAPPED					0x07 
 
#define ABT_PAGE	0x02 
 
#define ECC_SIZE 3 
 
#define SEARCH_RANGE 10 
#define NODENOTFOUND			0x09 /* node not present in tree*/ 
 
 
/*************************Utility Values***************************/ 
#define TRUE 1 
#define FALSE 0 
 
#endif  //__COMMON__H__