#include "uffs/uffs_blockInfo.h"
#include "uffs/uffs_public.h"
#include "uffs/uffs_os.h"
#include <string.h>
Go to the source code of this file.
Defines | |
#define | PFX "bc:" |
#define | UFFS_CLONE_BLOCK_INFO_NEXT ((uffs_blockInfo *)(-2)) |
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_blockInfo * | uffs_FindBlockInfoInCache (uffs_Device *dev, int block) |
find a block cache with given block number | |
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. | |
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 |
Definition in file uffs_blockInfo.c.
#define PFX "bc:" |
Definition at line 13 of file uffs_blockInfo.c.
#define UFFS_CLONE_BLOCK_INFO_NEXT ((uffs_blockInfo *)(-2)) |
Definition at line 15 of file uffs_blockInfo.c.
void uffs_CheckPageSpare | ( | uffs_Device * | dev, | |
uffs_pageSpare * | spare | |||
) |
check spare data, set .checkOk value.
[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
[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
[in] | dev | uffs device |
[in] | block | block number |
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.
[in] | dev | uffs device |
[in] | block | block number to be found |
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
[in] | dev | uffs device |
[in] | maxCachedBlocks | maximum cache buffers to be allocated |
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
[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. |
U_SUCC | successful | |
U_FAIL | fail to load |
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.
[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
[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().