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

📄 nandfblk.h

📁 嵌入式系统中文件系统源代码
💻 H
字号:

/****************************************************************
;*								*
;*		 INSTUTITE FOR INFORMATION INDUSTRY		*
;*			FLASH BLOCK HEADER			*
;*			  Oct. 6, 2000				*
;*								*
;****************************************************************/
#ifndef _NAND_FLASH_BLOCK_H
#define _NAND_FLASH_BLOCK_H

// added by chilong 
#include "FFS_NAND.h"
/*************************************************************
Function: NAND_FFS_readFlashBlock
Description:
	program the flash block
Input:
	block - the flash block number
	pData - the buffer
Output:
	0	succeeded
	-1	failed
**************************************************************/
int NAND_FFS_readFlashBlock(int block, unsigned char *pData);


/*************************************************************
Function: NAND_FFS_eraseFlashBlock
Description:
	erase the flash block
Input:
	block - the flash block number
Output:
	0	succeeded
	-1	failed
**************************************************************/
int NAND_FFS_eraseFlashBlock(int block);


/*************************************************************
Function: NAND_FFS_programFlashBlock
Description:
	program the flash block
Input:
	block - the flash block number
	pData - the buffer
Output:
	0	succeeded
	-1	failed
**************************************************************/
int NAND_FFS_programFlashBlock(int block, unsigned char *pData);


/*************************************************************
Function: NAND_FFS_readBlock
Description:
	read a flash block to buffer
Input:
	block - the flash block number
	pData - the pointer to address of the buffer
Output:
	0	succeeded
	-1	failed
Note:
	The pointer to the address of the buffer is used to
	reduce data copying.
**************************************************************/
//int NAND_FFS_readBlock(int block, unsigned char **pData);

/**** modified by chilong 01/14/2002 ****/
int NAND_FFS_readBlock(int block, unsigned char **pData, int bUseBuf2);
/**** modified by chilong 01/14/2002 ****/


/*************************************************************
Function: NAND_FFS_writeBlock
Description:
	read a flash block to buffer
Input:
	block - the flash block number
	pData - the buffer
Output:
	0	succeeded
	-1	failed
**************************************************************/
int NAND_FFS_writeBlock(int block, unsigned char *pData);


/*************************************************************
Function: NAND_FFS_findLeastErasedNonFullBlock
Description:
	find a least erased non full block
Input:
	nThLumpEntry -- this one would be the lump entry used
			by NAND_findFreeLump();
	NONE
Output:
	block number of the least erased free block
	-1 if there is no free block (disk full)
**************************************************************/
//int NAND_FFS_findLeastErasedNonFullBlock(void);
int NAND_FFS_findLeastErasedNonFullBlock(int *pNthLumpEntry);


/*************************************************************
Function: NAND_FFS_block2Offset
Description:
	get the address offset of the target flash block
Input:
	block - the block number
Output:
	the address offset of the block
	-1	error block number
**************************************************************/
long NAND_FFS_block2Offset(int block);


/*************************************************************
Function: NAND_FFS_offset2Block
Description:
	get the block number of the target flash block from offset
Input:
	offset - the address offset
	block - the resulting block number (-1 if failed)
	lump - the resulting lump number within the block (-1 if failed)
Output:
	NONE
**************************************************************/
void NAND_FFS_offset2Block(long offset, int *block, int *lump);


/*************************************************************
Function: NAND_FFS_block2Address
Description:
	get the address of the target flash block
Input:
	block - the block number
Output:
	the address of the block
	-1	error block number
**************************************************************/
void *NAND_FFS_block2Address(int block);


/*************************************************************
Function: NAND_FFS_address2Block
Description:
	get the block number of the target flash block from address
Input:
	address - the starting address of a flash block or lump
	block - the resulting block number (-1 if failed)
	lump - the resulting lump number within the block (-1 if failed)
Output:
	NONE
**************************************************************/
void NAND_FFS_address2Block(void *address, int *block, int *lump);



/*************************************************************
Function: NAND_FFS_address2Block
Description:
	check if the target block is valid
Input:
	block - the target block
Output:
	 0 - block is ok
	-1 - block is invalid
**************************************************************/
int NAND_FFS_checkBlock(int block);



/*************************************************************
	The following cache functions are used only when
	cache is active (NAND_FFS_USE_CACHE is defined in
	FFS_NAND.H).
*************************************************************/

/*************************************************************
Function: NAND_FFS_clearCache
Description:
	clear the FFS block cache
Input:
	cacheNum - the cache number
Output:
	none
Note:
	Called only when the cache is corrupted.
**************************************************************/
void NAND_FFS_clearCache(int cacheNum);


/*************************************************************
Function: NAND_FFS_clearAllCache
Description:
	clear all FFS lump cache
Input:
	none
Output:
	none
Note:
**************************************************************/
void NAND_FFS_clearAllCache(void);


/*************************************************************
Function: NAND_FFS_vertifyCache
Description:
	vertify the cache content
Input:
	cacheNum - the cache number
Output:
	0	valid cache content
	-1	invalid cache content
**************************************************************/
int NAND_FFS_vertifyCache(int cacheNum);


/*************************************************************
Function: NAND_FFS_flushCache
Description:
	flush the cache content
Input:
	cacheNum - the cache number
Output:
	0	flush ok
	-1	flush failed
**************************************************************/
int NAND_FFS_flushCache(int cacheNum);


/*************************************************************
Function: NAND_FFS_flushCacheByHandle
Description:
	flush the cache lumps belonging to the specified handle
Input:
	handle - the file handle
Output:
	0	flush ok
	-1	flush failed
**************************************************************/
int NAND_FFS_flushCacheByHandle(int handle);


/*************************************************************
Function: NAND_FFS_flushAllCache
Description:
	flush the whole cache
Input:
	none
Output:
	0	all cache lumps flush ok
	-1	some cache lumps failed flushing
**************************************************************/
int NAND_FFS_flushAllCache(void);


/*************************************************************
Function: NAND_FFS_putBlockInCache
Description:
	Put a new block into the cache
Input:
	newBlock - the lump to be cached
	readFlag - 1 = read data from flash to cache
		   0 = does not copy
Output:
	the cache number if swap ok
	-1 if swap failed
**************************************************************/
#ifdef NAND_FFS_CACHE_DEBUG
	int NAND_FFS_putBlockInCache(int newBlock, int readFlag, char bFromReadLump);
#else
	int NAND_FFS_putBlockInCache(int newBlock, int readFlag);
#endif


/*************************************************************
Function: NAND_FFS_modifyCache
Description:
	modify the cache content
Input:
	cacheNum - the target cache number
Output:
	none
**************************************************************/
void NAND_FFS_modifyCache(int cacheNum);


/*************************************************************
Function: NAND_FFS_searchBlockInCache
Description:
	search the specified lump in cache
Input:
	lump - the specified lump
Output:
	the cache number if found
	-1 if not found
**************************************************************/
int NAND_FFS_searchBlockInCache(int block);


#endif


⌨️ 快捷键说明

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