uffs_blockInfo.h File Reference

data structure for operating block information More...

#include "uffs/uffs_types.h"
#include "uffs/uffs_public.h"

Go to the source code of this file.

Data Structures

struct  uffs_blockInfoSt
 block information data. Block info is frequently accessed, UFFS use a cache system to speed up block info access. More...
struct  uffs_pageSpareSt
 this structure is for storing uffs tag and more. More...

Functions

void uffs_CheckPageSpare (uffs_Device *dev, uffs_pageSpare *spare)
 check spare data, set .checkOk value.
void uffs_ExpireAllBlockInfo (uffs_Device *dev)
void uffs_ExpireBlockInfo (uffs_Device *dev, uffs_blockInfo *p, int page)
 make the given pages expired in given block info buffer
uffs_blockInfouffs_FindBlockInfoInCache (uffs_Device *dev, int block)
 find a block cache with given block number
uffs_blockInfouffs_GetBlockInfo (uffs_Device *dev, int block)
 Find a cached block in cache pool, if the cached block exist then return the pointer, if the block does not cached already, find a non-used cache. if all of cached are used out, return NULL.
URET uffs_InitBlockInfoCache (uffs_Device *dev, int maxCachedBlocks)
 before block info cache is enable, this function should be called to initialize it
UBOOL uffs_IsAllBlockInfoFree (uffs_Device *dev)
URET uffs_LoadBlockInfo (uffs_Device *dev, uffs_blockInfo *work, int page)
 load page spare data to given block info structure with given page number
void uffs_PutBlockInfo (uffs_Device *dev, uffs_blockInfo *p)
 put block info buffer back to pool, should be called with uffs_GetBlockInfo in pairs.
URET uffs_ReleaseBlockInfoCache (uffs_Device *dev)
 release all allocated memory in initialize process, this function should be called when unmount file system


Detailed Description

data structure for operating block information

Author:
Ricky Zheng

Definition in file uffs_blockInfo.h.


Function Documentation

void uffs_CheckPageSpare ( uffs_Device dev,
uffs_pageSpare spare 
)

check spare data, set .checkOk value.

Parameters:
[in] dev uffs device
[in,out] spare page spare

Definition at line 150 of file uffs_blockInfo.c.

References uffs_pageSpareSt::checkOk, uffs_TagsSt::checkSum, uffs_pageSpareSt::tag, and uffs_CalTagCheckSum().

Referenced by uffs_LoadBlockInfo().

void uffs_ExpireAllBlockInfo ( uffs_Device dev  ) 

Definition at line 340 of file uffs_blockInfo.c.

References uffs_DeviceSt::bc, uffs_blockInfoCacheSt::head, uffs_blockInfoSt::next, UFFS_ALL_PAGES, and uffs_ExpireBlockInfo().

Referenced by uffs_FormatDevice().

void uffs_ExpireBlockInfo ( uffs_Device dev,
uffs_blockInfo p,
int  page 
)

make the given pages expired in given block info buffer

Parameters:
[in] dev uffs device
[in] p pointer of block info buffer
[in] page given page number. if UFFS_ALL_PAGES presented, all pages in the block should be made expired.

Definition at line 299 of file uffs_blockInfo.c.

References uffs_DeviceSt::attr, uffs_pageSpareSt::expired, uffs_blockInfoSt::expiredCount, uffs_storageAttrSt::pages_per_block, uffs_blockInfoSt::spares, and UFFS_ALL_PAGES.

Referenced by uffs_ExpireAllBlockInfo(), uffs_RecoverBadBlock(), and uffs_TruncateObject().

uffs_blockInfo* uffs_FindBlockInfoInCache ( uffs_Device dev,
int  block 
)

find a block cache with given block number

Parameters:
[in] dev uffs device
[in] block block number
Returns:
found block cache
Return values:
NULL cache not found
non-NULL found cache pointer

Definition at line 218 of file uffs_blockInfo.c.

References uffs_DeviceSt::bc, uffs_blockInfoSt::blockNum, uffs_blockInfoCacheSt::head, uffs_blockInfoSt::next, NULL, and uffs_blockInfoSt::refCount.

Referenced by uffs_GetBlockInfo().

uffs_blockInfo* uffs_GetBlockInfo ( uffs_Device dev,
int  block 
)

Find a cached block in cache pool, if the cached block exist then return the pointer, if the block does not cached already, find a non-used cache. if all of cached are used out, return NULL.

Parameters:
[in] dev uffs device
[in] block block number to be found
Returns:
found block cache buffer
Return values:
NULL caches used out
non-NULL buffer pointer of given block

Definition at line 243 of file uffs_blockInfo.c.

References uffs_DeviceSt::attr, uffs_DeviceSt::bc, uffs_blockInfoSt::blockNum, uffs_pageSpareSt::expired, uffs_blockInfoSt::expiredCount, uffs_blockInfoCacheSt::head, uffs_blockInfoSt::next, NULL, uffs_storageAttrSt::pages_per_block, PFX, uffs_blockInfoSt::refCount, uffs_blockInfoSt::spares, UFFS_ERR_SERIOUS, uffs_FindBlockInfoInCache(), and uffs_Perror().

Referenced by uffs_BufFlush(), uffs_BufGetEx(), uffs_CompareFileNameWithTreeNode(), uffs_RecoverBadBlock(), and uffs_TruncateObject().

URET uffs_InitBlockInfoCache ( uffs_Device dev,
int  maxCachedBlocks 
)

before block info cache is enable, this function should be called to initialize it

Parameters:
[in] dev uffs device
[in] maxCachedBlocks maximum cache buffers to be allocated
Returns:
result of initialization
Return values:
U_SUCC successful
U_FAIL failed

Definition at line 24 of file uffs_blockInfo.c.

References uffs_DeviceSt::attr, uffs_DeviceSt::bc, uffs_blockInfoSt::blockNum, uffs_pageSpareSt::expired, uffs_blockInfoSt::expiredCount, uffs_blockInfoCacheSt::head, uffs_blockInfoCacheSt::internalBufHead, uffs_blockInfoCacheSt::maxBlockCached, uffs_blockInfoSt::next, NULL, uffs_storageAttrSt::pages_per_block, PFX, uffs_blockInfoSt::prev, uffs_blockInfoSt::refCount, uffs_blockInfoSt::spares, uffs_blockInfoCacheSt::tail, U_FAIL, UFFS_ERR_DEAD, UFFS_ERR_NOISY, UFFS_INVALID_BLOCK, uffs_MemAlloc(), uffs_Perror(), and uffs_ReleaseBlockInfoCache().

Referenced by uffs_InitDevice().

UBOOL uffs_IsAllBlockInfoFree ( uffs_Device dev  ) 

Is all blcok info cache free (not referenced) ?

Definition at line 327 of file uffs_blockInfo.c.

References uffs_DeviceSt::bc, uffs_blockInfoCacheSt::head, uffs_blockInfoSt::next, uffs_blockInfoSt::refCount, U_FALSE, and U_TRUE.

Referenced by uffs_FormatDevice().

URET uffs_LoadBlockInfo ( uffs_Device dev,
uffs_blockInfo work,
int  page 
)

load page spare data to given block info structure with given page number

Parameters:
[in] dev uffs device
[in] work given block info to be filled with
[in] page given page number to be read from, if UFFS_ALL_PAGES is presented, it will read all pages, otherwise it will read only one given page.
Returns:
load result
Return values:
U_SUCC successful
U_FAIL fail to load
Note:
work->blockNum must be set before load block info

Definition at line 171 of file uffs_blockInfo.c.

References uffs_DeviceSt::attr, uffs_blockInfoSt::blockNum, uffs_pageSpareSt::expired, uffs_blockInfoSt::expiredCount, uffs_DeviceSt::flash, uffs_FlashOpsSt::LoadPageSpare, uffs_storageAttrSt::pages_per_block, PFX, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, U_FAIL, U_SUCC, UFFS_ALL_PAGES, uffs_CheckPageSpare(), UFFS_ERR_SERIOUS, and uffs_Perror().

Referenced by Samsung_IsBlockBad(), uffs_BufFlush(), uffs_CompareFileNameWithTreeNode(), uffs_CreateNewFile(), uffs_FindBestPageInBlock(), uffs_FindFirstFreePage(), uffs_FindFirstValidPage(), uffs_FindPageInBlockWithPageId(), uffs_GetBlockFileDataLength(), uffs_GetBlockTimeStamp(), uffs_GetFreePagesCount(), uffs_IsBlockPagesFullUsed(), uffs_IsDataBlockReguFull(), uffs_IsPageErased(), and uffs_IsThisBlockUsed().

void uffs_PutBlockInfo ( uffs_Device dev,
uffs_blockInfo p 
)

put block info buffer back to pool, should be called with uffs_GetBlockInfo in pairs.

Parameters:
[in] dev uffs device
[in] p pointer of block info buffer

Definition at line 282 of file uffs_blockInfo.c.

References PFX, uffs_blockInfoSt::refCount, UFFS_ERR_SERIOUS, and uffs_Perror().

Referenced by uffs_BufFlush(), uffs_BufGetEx(), uffs_CompareFileNameWithTreeNode(), uffs_RecoverBadBlock(), and uffs_TruncateObject().

URET uffs_ReleaseBlockInfoCache ( uffs_Device dev  ) 

release all allocated memory in initialize process, this function should be called when unmount file system

Parameters:
[in] dev uffs device

Definition at line 100 of file uffs_blockInfo.c.

References uffs_DeviceSt::bc, uffs_blockInfoCacheSt::head, uffs_blockInfoCacheSt::internalBufHead, uffs_blockInfoSt::next, NULL, PFX, uffs_blockInfoSt::refCount, uffs_blockInfoCacheSt::tail, U_FAIL, U_SUCC, UFFS_ERR_SERIOUS, uffs_MemFree(), and uffs_Perror().

Referenced by uffs_InitBlockInfoCache(), and uffs_ReleaseDevice().


Generated on Sat Mar 17 15:45:45 2007 for uffs-doc by  doxygen 1.5.0