![]() |
TF-M Reference Manual
1.2.0
TrustedFirmware-M
|
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "flash/its_flash.h"
#include "its_utils.h"
#include "psa/error.h"
Go to the source code of this file.
Data Structures | |
struct | its_metadata_block_header_t |
Structure to store the metadata block header. More... | |
struct | its_block_meta_t |
Structure to store information about each physical flash memory block. More... | |
struct | its_file_meta_t |
Structure to store file metadata. More... | |
struct | its_flash_fs_ctx_t |
Structure to store the ITS flash file system context. More... | |
Macros | |
#define | ITS_SUPPORTED_VERSION 0x01 |
Defines the supported version. More... | |
#define | ITS_METADATA_INVALID_INDEX 0xFFFF |
Defines the invalid index value when the metadata table is full. More... | |
#define | ITS_LOGICAL_DBLOCK0 0 |
Defines logical data block 0 ID. More... | |
#define | _T1 |
#define | _T2 |
#define | _T3 |
Functions | |
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_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_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 *file_meta_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... | |
#define _T1 |
Physical block ID of the data
Definition at line 55 of file its_flash_fs_mblock.h.
#define _T2 |
Number of bytes free at end of block (set during \ block compaction for gap reuse) \
Definition at line 79 of file its_flash_fs_mblock.h.
#define _T3 |
ID of this file
Definition at line 107 of file its_flash_fs_mblock.h.
#define ITS_LOGICAL_DBLOCK0 0 |
Defines logical data block 0 ID.
Definition at line 42 of file its_flash_fs_mblock.h.
#define ITS_METADATA_INVALID_INDEX 0xFFFF |
Defines the invalid index value when the metadata table is full.
Definition at line 35 of file its_flash_fs_mblock.h.
#define ITS_SUPPORTED_VERSION 0x01 |
Defines the supported version.
Definition at line 28 of file its_flash_fs_mblock.h.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | idx_start | File metadata entry index to start copy, inclusive |
[in] | idx_end | File metadata entry index to end copy, exclusive |
Definition at line 716 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | lblock | Logical block number |
Definition at line 733 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | fid | ID of the file |
[out] | idx | Index of the file metadata in the file system |
Definition at line 745 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | flags | Flags to search for |
[out] | idx | Index of the file metadata in the file system |
Definition at line 770 of file its_flash_fs_mblock.c.
psa_status_t its_flash_fs_mblock_init | ( | struct its_flash_fs_ctx_t * | fs_ctx | ) |
Initializes metadata block with the valid/active metablock.
[in,out] | fs_ctx | Filesystem context |
Definition at line 795 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
Definition at line 819 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
Definition at line 843 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | lblock | Logical block number |
[out] | block_meta | Pointer to block meta structure |
Definition at line 890 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | idx | File metadata entry index |
[out] | file_meta | Pointer to file meta structure |
Definition at line 868 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | fid | File ID |
[in] | use_spare | If true then the spare file will be used, otherwise at least one file will be left free |
[in] | size | Size of the file for which space is reserve |
[in] | flags | Flags set when the file was created |
[out] | file_meta_idx | File metadata entry index |
[out] | file_meta | File metadata entry |
[out] | block_meta | Block metadata entry |
Definition at line 912 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
Definition at line 936 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | phy_id | Physical ID of scratch data block |
[in] | lblock | Logical block number |
Definition at line 1046 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | lblock | Logical block number |
[in] | block_meta | Pointer to block's metadata |
Definition at line 1054 of file its_flash_fs_mblock.c.
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.
[in,out] | fs_ctx | Filesystem context |
[in] | idx | File's index in the metadata table |
[in] | file_meta | Metadata pointer |
Definition at line 1077 of file its_flash_fs_mblock.c.