TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
its_flash_fs_mblock.c File Reference
Include dependency graph for its_flash_fs_mblock.c:

Go to the source code of this file.

Macros

#define ITS_METADATA_BLOCK0   0
 
#define ITS_METADATA_BLOCK1   1
 
#define ITS_OTHER_META_BLOCK(metablock)
 Macro to get the the swap metadata block. More...
 
#define ITS_BLOCK_META_HEADER_SIZE   sizeof(struct its_metadata_block_header_t)
 
#define ITS_BLOCK_METADATA_SIZE   sizeof(struct its_block_meta_t)
 
#define ITS_FILE_METADATA_SIZE   sizeof(struct its_file_meta_t)
 

Functions

psa_status_t its_flash_fs_mblock_cp_file_meta (struct its_flash_fs_ctx_t *fs_ctx, uint32_t idx_start, uint32_t idx_end)
 Copies the file metadata entries between two indexes from the active metadata block to the scratch metadata block. More...
 
uint32_t its_flash_fs_mblock_cur_data_scratch_id (struct its_flash_fs_ctx_t *fs_ctx, uint32_t lblock)
 Gets current scratch datablock physical ID. More...
 
psa_status_t its_flash_fs_mblock_get_file_idx (struct its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid, uint32_t *idx)
 Gets file metadata entry index. More...
 
psa_status_t its_flash_fs_mblock_get_file_idx_flag (struct its_flash_fs_ctx_t *fs_ctx, uint32_t flags, uint32_t *idx)
 Gets file metadata entry index of the first file with one of the provided flags set. More...
 
psa_status_t its_flash_fs_mblock_init (struct its_flash_fs_ctx_t *fs_ctx)
 Initializes metadata block with the valid/active metablock. More...
 
psa_status_t its_flash_fs_mblock_meta_update_finalize (struct its_flash_fs_ctx_t *fs_ctx)
 Finalizes an update operation. Last step when a create/write/delete is performed. More...
 
psa_status_t its_flash_fs_mblock_migrate_lb0_data_to_scratch (struct its_flash_fs_ctx_t *fs_ctx)
 Writes the files data area of logical block 0 into the scratch block. More...
 
psa_status_t its_flash_fs_mblock_read_file_meta (struct its_flash_fs_ctx_t *fs_ctx, uint32_t idx, struct its_file_meta_t *file_meta)
 Reads specified file metadata. More...
 
psa_status_t its_flash_fs_mblock_read_block_metadata (struct its_flash_fs_ctx_t *fs_ctx, uint32_t lblock, struct its_block_meta_t *block_meta)
 Reads specified logical block metadata. More...
 
psa_status_t its_flash_fs_mblock_reserve_file (struct its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid, bool use_spare, size_t size, uint32_t flags, uint32_t *idx, struct its_file_meta_t *file_meta, struct its_block_meta_t *block_meta)
 Reserves space for a file. More...
 
psa_status_t its_flash_fs_mblock_reset_metablock (struct its_flash_fs_ctx_t *fs_ctx)
 Resets metablock by cleaning and initializing the metadatablock. More...
 
void its_flash_fs_mblock_set_data_scratch (struct its_flash_fs_ctx_t *fs_ctx, uint32_t phy_id, uint32_t lblock)
 Sets current data scratch block. More...
 
psa_status_t its_flash_fs_mblock_update_scratch_block_meta (struct its_flash_fs_ctx_t *fs_ctx, uint32_t lblock, struct its_block_meta_t *block_meta)
 Puts logical block's metadata in scratch metadata block. More...
 
psa_status_t its_flash_fs_mblock_update_scratch_file_meta (struct its_flash_fs_ctx_t *fs_ctx, uint32_t idx, const struct its_file_meta_t *file_meta)
 Writes a file metadata entry into scratch metadata block. More...
 

Macro Definition Documentation

#define ITS_BLOCK_META_HEADER_SIZE   sizeof(struct its_metadata_block_header_t)

Definition at line 29 of file its_flash_fs_mblock.c.

#define ITS_BLOCK_METADATA_SIZE   sizeof(struct its_block_meta_t)

Definition at line 30 of file its_flash_fs_mblock.c.

#define ITS_FILE_METADATA_SIZE   sizeof(struct its_file_meta_t)

Definition at line 31 of file its_flash_fs_mblock.c.

#define ITS_METADATA_BLOCK0   0

Definition at line 17 of file its_flash_fs_mblock.c.

#define ITS_METADATA_BLOCK1   1

Definition at line 18 of file its_flash_fs_mblock.c.

#define ITS_OTHER_META_BLOCK (   metablock)
Value:
(((metablock) == ITS_METADATA_BLOCK0) ? \
#define ITS_METADATA_BLOCK1
#define ITS_METADATA_BLOCK0

Macro to get the the swap metadata block.

Definition at line 25 of file its_flash_fs_mblock.c.

Function Documentation

psa_status_t its_flash_fs_mblock_cp_file_meta ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  idx_start,
uint32_t  idx_end 
)

Copies the file metadata entries between two indexes from the active metadata block to the scratch metadata block.

Parameters
[in,out]fs_ctxFilesystem context
[in]idx_startFile metadata entry index to start copy, inclusive
[in]idx_endFile metadata entry index to end copy, exclusive
Returns
Returns error code as specified in psa_status_t

Definition at line 716 of file its_flash_fs_mblock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t its_flash_fs_mblock_cur_data_scratch_id ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  lblock 
)

Gets current scratch datablock physical ID.

Parameters
[in,out]fs_ctxFilesystem context
[in]lblockLogical block number
Returns
current scratch data block

Definition at line 733 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_get_file_idx ( struct its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid,
uint32_t *  idx 
)

Gets file metadata entry index.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidID of the file
[out]idxIndex of the file metadata in the file system
Returns
Returns error code as specified in psa_status_t

Definition at line 745 of file its_flash_fs_mblock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_get_file_idx_flag ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  flags,
uint32_t *  idx 
)

Gets file metadata entry index of the first file with one of the provided flags set.

Parameters
[in,out]fs_ctxFilesystem context
[in]flagsFlags to search for
[out]idxIndex of the file metadata in the file system
Returns
Returns error code as specified in psa_status_t

Definition at line 770 of file its_flash_fs_mblock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_init ( struct its_flash_fs_ctx_t fs_ctx)

Initializes metadata block with the valid/active metablock.

Parameters
[in,out]fs_ctxFilesystem context
Returns
Returns value as specified in psa_status_t

Definition at line 795 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_meta_update_finalize ( struct its_flash_fs_ctx_t fs_ctx)

Finalizes an update operation. Last step when a create/write/delete is performed.

Parameters
[in,out]fs_ctxFilesystem context
Returns
Returns offset value in metadata block

Definition at line 819 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_migrate_lb0_data_to_scratch ( struct its_flash_fs_ctx_t fs_ctx)

Writes the files data area of logical block 0 into the scratch block.

Note
The files data in the logical block 0 is stored in same physical block where the metadata is stored. A change in the metadata requires a swap of physical blocks. So, the files data stored in the current medadata block needs to be copied in the scratch block, unless the data of the file processed is located in the logical block 0.
Parameters
[in,out]fs_ctxFilesystem context
Returns
Returns error code as specified in psa_status_t

Definition at line 843 of file its_flash_fs_mblock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_read_block_metadata ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  lblock,
struct its_block_meta_t block_meta 
)

Reads specified logical block metadata.

Parameters
[in,out]fs_ctxFilesystem context
[in]lblockLogical block number
[out]block_metaPointer to block meta structure
Returns
Returns error code as specified in psa_status_t

Definition at line 890 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_read_file_meta ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  idx,
struct its_file_meta_t file_meta 
)

Reads specified file metadata.

Parameters
[in,out]fs_ctxFilesystem context
[in]idxFile metadata entry index
[out]file_metaPointer to file meta structure
Returns
Returns error code as specified in psa_status_t

Definition at line 868 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_reserve_file ( struct its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid,
bool  use_spare,
size_t  size,
uint32_t  flags,
uint32_t *  file_meta_idx,
struct its_file_meta_t file_meta,
struct its_block_meta_t block_meta 
)

Reserves space for a file.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
[in]use_spareIf true then the spare file will be used, otherwise at least one file will be left free
[in]sizeSize of the file for which space is reserve
[in]flagsFlags set when the file was created
[out]file_meta_idxFile metadata entry index
[out]file_metaFile metadata entry
[out]block_metaBlock metadata entry
Returns
Returns error code as specified in psa_status_t

Definition at line 912 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_reset_metablock ( struct its_flash_fs_ctx_t fs_ctx)

Resets metablock by cleaning and initializing the metadatablock.

Parameters
[in,out]fs_ctxFilesystem context
Returns
Returns value as specified in psa_status_t

Definition at line 936 of file its_flash_fs_mblock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void its_flash_fs_mblock_set_data_scratch ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  phy_id,
uint32_t  lblock 
)

Sets current data scratch block.

Parameters
[in,out]fs_ctxFilesystem context
[in]phy_idPhysical ID of scratch data block
[in]lblockLogical block number

Definition at line 1046 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_update_scratch_block_meta ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  lblock,
struct its_block_meta_t block_meta 
)

Puts logical block's metadata in scratch metadata block.

Parameters
[in,out]fs_ctxFilesystem context
[in]lblockLogical block number
[in]block_metaPointer to block's metadata
Returns
Returns error code as specified in psa_status_t

Definition at line 1054 of file its_flash_fs_mblock.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_mblock_update_scratch_file_meta ( struct its_flash_fs_ctx_t fs_ctx,
uint32_t  idx,
const struct its_file_meta_t file_meta 
)

Writes a file metadata entry into scratch metadata block.

Parameters
[in,out]fs_ctxFilesystem context
[in]idxFile's index in the metadata table
[in]file_metaMetadata pointer
Returns
Returns error code as specified in psa_status_t

Definition at line 1077 of file its_flash_fs_mblock.c.

Here is the caller graph for this function: