uffs_public.c File Reference

public and miscellaneous functions More...

#include "uffs/uffs_types.h"
#include "uffs/uffs_config.h"
#include "uffs/uffs_core.h"
#include "uffs/uffs_device.h"
#include "uffs/uffs_os.h"
#include <string.h>

Go to the source code of this file.

Defines

#define PFX   "public:"

Functions

u8 uffs_CalTagCheckSum (uffs_Tags *tag)
 Calculate tag checksum.
URET uffs_CreateNewFile (uffs_Device *dev, u16 father, u16 serial, uffs_blockInfo *bc, uffs_fileInfo *fi)
URET uffs_ECCCheck (uffs_Device *dev, uffs_Buf *buf)
u16 uffs_FindBestPageInBlock (uffs_Device *dev, uffs_blockInfo *bc, u16 page)
 find a best page than given page from page.
u16 uffs_FindFirstFreePage (uffs_Device *dev, uffs_blockInfo *bc, u16 pageFrom)
u16 uffs_FindFirstValidPage (uffs_Device *dev, uffs_blockInfo *bc)
u16 uffs_FindPageInBlockWithPageId (uffs_Device *dev, uffs_blockInfo *bc, u16 pageID)
 find a valid page with given pageID
int uffs_GetBlockFileDataLength (uffs_Device *dev, uffs_blockInfo *bc, u8 type)
 calculate data length of a file block
int uffs_GetBlockTimeStamp (uffs_Device *dev, uffs_blockInfo *bc)
int uffs_GetDeviceFree (uffs_Device *dev)
int uffs_GetDeviceTotal (uffs_Device *dev)
int uffs_GetDeviceUsed (uffs_Device *dev)
int uffs_GetFirstBlockTimeStamp (void)
int uffs_GetFreePagesCount (uffs_Device *dev, uffs_blockInfo *bc)
int uffs_GetNextBlockTimeStamp (int prev)
UBOOL uffs_IsBlockPagesFullUsed (uffs_Device *dev, uffs_blockInfo *bc)
UBOOL uffs_IsDataBlockReguFull (uffs_Device *dev, uffs_blockInfo *bc)
 Is this block the last block of file ? (no free pages, and full filled with full pageID).
UBOOL uffs_IsPageErased (uffs_Device *dev, uffs_blockInfo *bc, u16 page)
 Is the block erased ?
UBOOL uffs_IsSrcNewerThanObj (int src, int obj)
UBOOL uffs_IsThisBlockUsed (uffs_Device *dev, uffs_blockInfo *bc)
u16 uffs_MakeSum16 (void *p, int len)
u8 uffs_MakeSum8 (void *p, int len)
 recover a page in block
URET uffs_WriteDataToNewPage (uffs_Device *dev, u16 block, u16 page, uffs_Tags *tag, uffs_Buf *buf)


Detailed Description

public and miscellaneous functions

Author:
Ricky Zheng, created 10th May, 2005

Definition in file uffs_public.c.


Define Documentation

#define PFX   "public:"

Definition at line 15 of file uffs_public.c.


Function Documentation

u8 uffs_CalTagCheckSum ( uffs_Tags tag  ) 

Calculate tag checksum.

Parameters:
[in] tag input tag
Returns:
checksum of tag

Definition at line 58 of file uffs_public.c.

References NULL.

Referenced by uffs_CheckPageSpare(), and uffs_WriteDataToNewPage().

URET uffs_CreateNewFile ( uffs_Device dev,
u16  father,
u16  serial,
uffs_blockInfo bc,
uffs_fileInfo fi 
)

create a new file on a free block

Parameters:
[in] dev uffs device
[in] father father dir serial num
[in] serial serial num of this new file
[in] bc block information
[in] fi file information
Note:
father, serial, bc must be provided before, and all information in fi should be filled well before.

Definition at line 354 of file uffs_public.c.

References uffs_fileInfoSt::createTime, uffs_BufSt::data, uffs_BufSt::dataLen, uffs_TagsSt::dataLength, uffs_TagsSt::dataSum, uffs_TagsSt::father, uffs_fileInfoSt::lastModify, uffs_fileInfoSt::name, uffs_fileInfoSt::name_len, NULL, PFX, uffs_TagsSt::serial, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, U_FAIL, uffs_BufGet(), uffs_BufPut(), UFFS_ERR_SERIOUS, uffs_GetCurDateTime(), uffs_LoadBlockInfo(), uffs_MakeSum16(), and uffs_Perror().

URET uffs_ECCCheck ( uffs_Device dev,
uffs_Buf buf 
)

Definition at line 48 of file uffs_public.c.

References U_SUCC.

u16 uffs_FindBestPageInBlock ( uffs_Device dev,
uffs_blockInfo bc,
u16  page 
)

find a best page than given page from page.

Parameters:
[in] dev uffs device
[in] bc block info
[in] page page number to be compared with
Returns:
the better page number, could be the same with given page

Definition at line 80 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_TagsSt::dirty, uffs_TagsSt::father, uffs_TagsSt::pageID, uffs_storageAttrSt::pages_per_block, uffs_TagsSt::serial, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, TAG_DIRTY, TAG_VALID, UFFS_ALL_PAGES, uffs_LoadBlockInfo(), and uffs_TagsSt::valid.

Referenced by uffs_BufGetEx(), uffs_CompareFileNameWithTreeNode(), uffs_GetBlockFileDataLength(), and uffs_RecoverBadBlock().

u16 uffs_FindFirstFreePage ( uffs_Device dev,
uffs_blockInfo bc,
u16  pageFrom 
)

find first free page from 'pageFrom'

Parameters:
[in] dev uffs device
[in] bc block info
[in] pageFrom search from this page
Returns:
return first free page number from 'pageFrom'
Return values:
UFFS_INVALID_PAGE no free page found
>=0 the first free page number

Definition at line 191 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_storageAttrSt::pages_per_block, U_TRUE, UFFS_INVALID_PAGE, uffs_IsPageErased(), and uffs_LoadBlockInfo().

u16 uffs_FindFirstValidPage ( uffs_Device dev,
uffs_blockInfo bc 
)

Find first valid page from a block, just used in mounting a partition

Definition at line 207 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_pageSpareSt::checkOk, uffs_storageAttrSt::pages_per_block, uffs_blockInfoSt::spares, UFFS_INVALID_PAGE, and uffs_LoadBlockInfo().

u16 uffs_FindPageInBlockWithPageId ( uffs_Device dev,
uffs_blockInfo bc,
u16  pageID 
)

find a valid page with given pageID

Parameters:
[in] dev uffs device
[in] bc block info
[in] pageID pageID to be find
Returns:
the valid page number which has given pageID
Return values:
>=0 page number
UFFS_INVALID_PAGE page not found

Definition at line 126 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_TagsSt::pageID, uffs_storageAttrSt::pages_per_block, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, UFFS_INVALID_PAGE, and uffs_LoadBlockInfo().

Referenced by uffs_BufGetEx(), and uffs_RecoverBadBlock().

int uffs_GetBlockFileDataLength ( uffs_Device dev,
uffs_blockInfo bc,
u8  type 
)

calculate data length of a file block

Parameters:
[in] dev uffs device
[in] bc block info

Definition at line 387 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_DeviceSt::com, uffs_TagsSt::dataLength, uffs_TagsSt::pageID, uffs_storageAttrSt::pages_per_block, uffs_commInfoSt::pgDataSize, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, uffs_TagsSt::type, UFFS_ALL_PAGES, uffs_FindBestPageInBlock(), uffs_LoadBlockInfo(), UFFS_TYPE_DATA, and UFFS_TYPE_FILE.

int uffs_GetBlockTimeStamp ( uffs_Device dev,
uffs_blockInfo bc 
)

get block time stamp from a exist block

Parameters:
[in] dev uffs device
[in] bc block info

Definition at line 171 of file uffs_public.c.

References uffs_TagsSt::blockTimeStamp, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, U_FALSE, uffs_GetFirstBlockTimeStamp(), uffs_IsThisBlockUsed(), and uffs_LoadBlockInfo().

int uffs_GetDeviceFree ( uffs_Device dev  ) 

get partition free (bytes)

Definition at line 505 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_storageAttrSt::block_data_size, uffs_treeSt::erasedCount, and uffs_DeviceSt::tree.

Referenced by cmdSt().

int uffs_GetDeviceTotal ( uffs_Device dev  ) 

get partition total size (bytes)

Definition at line 513 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_storageAttrSt::block_data_size, uffs_partitionSt::end, uffs_DeviceSt::par, and uffs_partitionSt::start.

Referenced by cmdSt().

int uffs_GetDeviceUsed ( uffs_Device dev  ) 

get partition used (bytes)

Definition at line 496 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_treeSt::badCount, uffs_storageAttrSt::block_data_size, uffs_partitionSt::end, uffs_treeSt::erasedCount, uffs_DeviceSt::par, uffs_partitionSt::start, and uffs_DeviceSt::tree.

Referenced by cmdSt().

int uffs_GetFirstBlockTimeStamp ( void   ) 

Definition at line 18 of file uffs_public.c.

Referenced by uffs_GetBlockTimeStamp().

int uffs_GetFreePagesCount ( uffs_Device dev,
uffs_blockInfo bc 
)

get free pages number

Parameters:
[in] dev uffs device
[in] bc block info

Definition at line 442 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_storageAttrSt::pages_per_block, U_TRUE, uffs_IsPageErased(), and uffs_LoadBlockInfo().

Referenced by uffs_BufFlush().

int uffs_GetNextBlockTimeStamp ( int  prev  ) 

Definition at line 23 of file uffs_public.c.

Referenced by uffs_RecoverBadBlock().

UBOOL uffs_IsBlockPagesFullUsed ( uffs_Device dev,
uffs_blockInfo bc 
)

Are all the pages in the block used ?

Definition at line 143 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_TagsSt::dirty, uffs_storageAttrSt::pages_per_block, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, TAG_DIRTY, U_FALSE, U_TRUE, and uffs_LoadBlockInfo().

UBOOL uffs_IsDataBlockReguFull ( uffs_Device dev,
uffs_blockInfo bc 
)

Is this block the last block of file ? (no free pages, and full filled with full pageID).

Definition at line 483 of file uffs_public.c.

References uffs_DeviceSt::attr, uffs_DeviceSt::com, uffs_TagsSt::dataLength, uffs_TagsSt::pageID, uffs_storageAttrSt::pages_per_block, uffs_commInfoSt::pgDataSize, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, U_FALSE, U_TRUE, and uffs_LoadBlockInfo().

UBOOL uffs_IsPageErased ( uffs_Device dev,
uffs_blockInfo bc,
u16  page 
)

Is the block erased ?

Parameters:
[in] dev uffs device
[in] bc block info
[in] page page number to be check
Return values:
U_TRUE block is erased, ready to use
U_FALSE block is dirty, maybe use by file

Definition at line 464 of file uffs_public.c.

References uffs_TagsSt::checkSum, uffs_TagsSt::dirty, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, TAG_CLEAR, TAG_INVALID, U_FALSE, U_TRUE, uffs_LoadBlockInfo(), and uffs_TagsSt::valid.

Referenced by uffs_FindFirstFreePage(), and uffs_GetFreePagesCount().

UBOOL uffs_IsSrcNewerThanObj ( int  src,
int  obj 
)

Definition at line 28 of file uffs_public.c.

References PFX, U_FALSE, U_TRUE, UFFS_ERR_SERIOUS, and uffs_Perror().

UBOOL uffs_IsThisBlockUsed ( uffs_Device dev,
uffs_blockInfo bc 
)

Is this block used ?

Parameters:
[in] dev uffs device
[in] bc block info
Return values:
U_TRUE block is used
U_FALSE block is free

Definition at line 158 of file uffs_public.c.

References uffs_TagsSt::dirty, uffs_blockInfoSt::spares, uffs_pageSpareSt::tag, TAG_DIRTY, U_FALSE, U_TRUE, and uffs_LoadBlockInfo().

Referenced by uffs_GetBlockTimeStamp().

u16 uffs_MakeSum16 ( void *  p,
int  len 
)

calculate sum of datam, 16bit version

Parameters:
[in] p data pointer
[in] len length of data
Returns:
return sum of data, 16bit

Definition at line 331 of file uffs_public.c.

Referenced by uffs_CreateNewFile(), and uffs_RenameObject().

u8 uffs_MakeSum8 ( void *  p,
int  len 
)

recover a page in block

calculate sum of data, 8bit version

Parameters:
[in] p data pointer
[in] len length of data
Returns:
return sum of data, 8bit

Definition at line 314 of file uffs_public.c.

URET uffs_WriteDataToNewPage ( uffs_Device dev,
u16  block,
u16  page,
uffs_Tags tag,
uffs_Buf buf 
)

write data to a new page

Parameters:
[in] dev uffs device
[in] block block number to be wrote to
[in] page page number to be wrote to
[in] tag new page tag
[in] buf new page data

Definition at line 225 of file uffs_public.c.

References uffs_TagsSt::checkSum, uffs_DeviceSt::com, uffs_BufSt::data, uffs_TagsSt::dirty, uffs_BufSt::ecc, uffs_DeviceSt::flash, uffs_FlashOpsSt::MakeEcc, uffs_FlashOpsSt::MakePageValid, uffs_DeviceSt::ops, uffs_commInfoSt::pgSize, U_SUCC, uffs_CalTagCheckSum(), uffs_TagsSt::valid, uffs_DeviceOpsSt::WritePageData, and uffs_FlashOpsSt::WritePageSpare.

Referenced by uffs_RecoverBadBlock().


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