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

📄 nandlump.h

📁 PDA上的CF CARD 文件系统的建立程式
💻 H
字号:
/****************************************************************
;*								*
;*		 INSTUTITE FOR INFORMATION INDUSTRY		*
;*			   LUMP HEADER				*
;*			  Sept. 15, 2000			*
;*								*
;****************************************************************/
#ifndef _NAND_LUMP_H
#define _NAND_LUMP_H


/*************************************************************
Function: NAND_initLump
Description:
	initialize the disk lump parameters
Input:
	NONE
Output:
	NONE
**************************************************************/
void NAND_initLump(void);



/*************************************************************
Function: NAND_FFS_readLump
Description:
	read a flash lump to buffer
Input:
	lump - the flash lump number
	pData - the buffer
Output:
	0	succeeded
	-1	lump address out of bound
Note:
	The size of a lump must be a multiple of integer.
	Also note that NAND_FFS_readBlock() actually read data
	to its internal buffer.
**************************************************************/
int NAND_FFS_readLump(int lump, unsigned char **pData);



/*************************************************************
Function: NAND_FFS_writeLump
Description:
	write a lump from buffer to flash
Input:
	lump - the flash lump number
	pData - the buffer
Output:
	0	succeeded
	-1	lump address out of bound
Note:
	The size of a lump must be a multiple of integer
	Also note that NAND_FFS_readBlock() actually read data
	to its internal buffer.
**************************************************************/
int NAND_FFS_writeLump(int lump, unsigned char *pData);


/*************************************************************
Function: NAND_FFS_freeLumpLink
Description:
	free all blocks in a file block link
Input:
	startBlock - the starting block in the link
Output:
	NONE
**************************************************************/
void NAND_FFS_freeLumpLink(int startLumpNo);

/*************************************************************
Function: NAND_FFS_freeLump
Description:
	release a disk lump back to the NAND_FFS
Input:
	lumpNo - the number of the lump that is going to be released
Output:
**************************************************************/
void NAND_FFS_freeLump(int lumpNo);
void NAND_FFS_freeLump_r(int lumpNo);


/*************************************************************
Function: NAND_getNextLump
Description:
	get the total data size in a link of lumps
Input:
	lump - the target lump
Output:
	the next lump
**************************************************************/
int NAND_getNextLump(int lump);



/*************************************************************
Function: NAND_totalDataSizeInLumpLink
Description:
	get the total data size in a link of lumps
Input:
	lump - the beginning lump
Output:
	the total data size
**************************************************************/
unsigned long NAND_totalDataSizeInLumpLink(int lump);



/*************************************************************
Function: NAND_deleteLumpChain
Description:
	delete the lumps in the chain
Input:
	beginLump - the beginning lump
	keepFirst - keep the first lump in the link?
			0: no
			1: yes
	dataSize - the size of data to be kept if keepFirst is 1
Output:
	0	succeeded
	1	failed - memory allocation error
	2	failed - flash write error
	3	failed - flash read error
	4	failed - invalid block
**************************************************************/
int NAND_deleteLumpChain(int beginLump, int keepFirst, unsigned long dataSize);


/**** added by chilong 01/18/2002 ****/
/*************************************************************
Function: NAND_checkBadLump
Description:
	check if the requested lump can be used
Input:
	lumpNo - the lump number
Output:
	1 - ok
	0 - bad
Note:
**************************************************************/
int NAND_checkBadLump(int lumpNo);
/**** added by chilong 01/18/2002 ****/

/*************************************************************
Function: NAND_countFreeLumpsInBlock
Description:
	counts the number of free lumps in a flash block
Input:
	block - the specified flash block
	pNthLumpEntry - the pointer to the lump entry which will
			be used in NAND_findFreeLump()
Output:
	number of free lumps
	-1 if the block is invalid
Note:
	Note that NAND_FFS_readBlock() read block content into
	its internal buffer.
**************************************************************/
//int NAND_countFreeLumpsInBlock(int block);

/**** modified by chilong 01/17/2002 ****/
int NAND_countFreeLumpsInBlock(int block, int *pNThLumpEntry);
/**** modified by chilong 01/17/2002 ****/



/*************************************************************
Function: NAND_findFreeLump
Description:
	find a free lump
Input:
	none
Output:
	the lump number
	NAND_END_LUMP if error
**************************************************************/
int NAND_findFreeLump(void);



/*************************************************************
Function: NAND_findFreeLumpByAdjLump
Description:
	find a free lump in the same block as the specific lump
Input:
	lump - the specific lump
Output:
	the lump number
	NAND_END_LUMP if not found
**************************************************************/
int NAND_findFreeLumpByAdjLump(int lump);



/*************************************************************
Function: NAND_checkLumpNum
Description:
	check if the lump address is valid
Input:
	lump - the specific lump
Output:
	0	lump ok
	-1	lump invalid
**************************************************************/
int NAND_checkLumpNum(int lump);



/*************************************************************
Function: NAND_lump2Block
Description:
	convert lump to block and entry
Input:
	lump - the specific lump
Output:
	block		the block number
	nthEntry	the entry number in the block
	both equal to -1 if error
**************************************************************/
void NAND_lump2Block(int lump, int *block, int *nthEntry);



/*************************************************************
Function: NAND_readLumpStructure
Description:
	read the data structure of a lump
Input:
	lump - the specific lump
	lumpType - 0 = get any lump
		   1 = get only the starting lump
		   2 = get only the free lump
Output:
	the pointer to the lump structure
Note:
	If the lump is in cache, the cache content is used.
	If the lump is not in cache, the corresponding frames
	are read from flash and the cache is kept inact.
**************************************************************/
struct NAND_diskLump *NAND_readLumpStructure(int lump, int lumpType);


/**** added by chilong 01/12/2002 ****/
/*************************************************************
Function: NAND_checkLump
Description:
	check if the lump address is valid
Input:
	lump - the specific lump
Output:
	1	lump address ok
	0	lump address out of bound
**************************************************************/
int NAND_checkLump(int lumpNo);
/**** added by chilong 01/12/2002 ****/

#endif

⌨️ 快捷键说明

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