TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
its_flash_fs.h File Reference

Internal Trusted Storage service filesystem abstraction APIs. The purpose of this abstraction is to have the ability to plug-in other filesystems or filesystem proxies (supplicant). More...

#include <stddef.h>
#include <stdint.h>
#include "its_flash_fs_mblock.h"
#include "psa/error.h"
#include "flash/its_flash.h"
Include dependency graph for its_flash_fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  its_file_info_t
 Structure to store the file information. More...
 

Macros

#define ITS_FLASH_FS_USER_FLAGS_MASK   ((1U << 16) - 1)
 
#define ITS_FLASH_FS_WRITE_FLAGS_MASK   ((1U << 24) - (1U << 16))
 
#define ITS_FLASH_FS_FLAG_CREATE   (1U << 16)
 
#define ITS_FLASH_FS_FLAG_TRUNCATE   (1U << 17)
 

Typedefs

typedef struct its_flash_fs_ctx_t its_flash_fs_ctx_t
 ITS flash filesystem context type, used to maintain state across FS operations. More...
 

Functions

psa_status_t its_flash_fs_prepare (its_flash_fs_ctx_t *fs_ctx, const struct its_flash_info_t *flash_info)
 Prepares the filesystem to accept operations on the files. More...
 
psa_status_t its_flash_fs_wipe_all (its_flash_fs_ctx_t *fs_ctx)
 Wipes all files from the filesystem. More...
 
psa_status_t its_flash_fs_file_exist (its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid)
 Checks if a file exists in the filesystem. More...
 
psa_status_t its_flash_fs_file_get_info (its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid, struct its_file_info_t *info)
 Gets the file information referenced by the file ID. More...
 
psa_status_t its_flash_fs_file_write (its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid, uint32_t flags, size_t max_size, size_t data_size, size_t offset, const uint8_t *data)
 Writes data to a file. More...
 
psa_status_t its_flash_fs_file_read (its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid, size_t size, size_t offset, uint8_t *data)
 Reads data from an existing file. More...
 
psa_status_t its_flash_fs_file_delete (its_flash_fs_ctx_t *fs_ctx, const uint8_t *fid)
 Deletes file referenced by the file ID. More...
 
psa_status_t its_flash_fs_validate_params (const struct its_flash_info_t *info)
 Validates the configuration of the flash filesystem. More...
 

Detailed Description

Internal Trusted Storage service filesystem abstraction APIs. The purpose of this abstraction is to have the ability to plug-in other filesystems or filesystem proxies (supplicant).

Definition in file its_flash_fs.h.

Macro Definition Documentation

#define ITS_FLASH_FS_FLAG_CREATE   (1U << 16)

Definition at line 39 of file its_flash_fs.h.

#define ITS_FLASH_FS_FLAG_TRUNCATE   (1U << 17)

Definition at line 41 of file its_flash_fs.h.

#define ITS_FLASH_FS_USER_FLAGS_MASK   ((1U << 16) - 1)

Definition at line 34 of file its_flash_fs.h.

#define ITS_FLASH_FS_WRITE_FLAGS_MASK   ((1U << 24) - (1U << 16))

Definition at line 37 of file its_flash_fs.h.

Typedef Documentation

ITS flash filesystem context type, used to maintain state across FS operations.

The user should allocate a variable of this type, initialised to zero, before calling its_flash_fs_prepare, and then pass it to each subsequent FS operation. The contents are internal to the filesystem.

Definition at line 52 of file its_flash_fs.h.

Function Documentation

psa_status_t its_flash_fs_file_delete ( its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid 
)

Deletes file referenced by the file ID.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
Returns
Returns error code as specified in psa_status_t

Definition at line 454 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_file_exist ( its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid 
)

Checks if a file exists in the filesystem.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
Returns
Returns PSA_SUCCESS if the file exists. If file does not exist, it returns PSA_ERROR_DOES_NOT_EXIST. Otherwise, it returns error code as specified in psa_status_t.

Definition at line 98 of file its_flash_fs.c.

Here is the call graph for this function:

psa_status_t its_flash_fs_file_get_info ( its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid,
struct its_file_info_t info 
)

Gets the file information referenced by the file ID.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
[out]infoPointer to the information structure to store the file information values its_file_info_t
Returns
Returns error code specified in psa_status_t

Definition at line 112 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_file_read ( its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid,
size_t  size,
size_t  offset,
uint8_t *  data 
)

Reads data from an existing file.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
[in]sizeSize to be read
[in]offsetOffset in the file
[out]dataPointer to buffer to store the data
Returns
Returns error code as specified in psa_status_t

Definition at line 469 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_file_write ( its_flash_fs_ctx_t fs_ctx,
const uint8_t *  fid,
uint32_t  flags,
size_t  max_size,
size_t  data_size,
size_t  offset,
const uint8_t *  data 
)

Writes data to a file.

Parameters
[in,out]fs_ctxFilesystem context
[in]fidFile ID
[in]flagsFlags of the file
[in]max_sizeMaximum size of the file to be created. Ignored if the file is not being created.
[in]data_sizeSize of the incoming write data.
[in]offsetOffset in the file to write. Must be less than or equal to the current file size.
[in]dataPointer to buffer containing data to be written
Returns
Returns error code as specified in psa_status_t

Definition at line 144 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_prepare ( its_flash_fs_ctx_t fs_ctx,
const struct its_flash_info_t flash_info 
)

Prepares the filesystem to accept operations on the files.

Parameters
[in,out]fs_ctxFilesystem context to prepare. Must have been initialised by the caller.
[in]flash_infoStruct containing information about the flash device to associate with the context.
Returns
Returns error code as specified in psa_status_t

Definition at line 58 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t its_flash_fs_validate_params ( const struct its_flash_info_t info)

Validates the configuration of the flash filesystem.

This function checks that the flash block provided is compatible with the flash_fs described by the info parameter

Parameters
[in]infoFilesystem information
Returns
Returns error code as specified in psa_status_t

Definition at line 541 of file its_flash_fs.c.

Here is the caller graph for this function:

psa_status_t its_flash_fs_wipe_all ( its_flash_fs_ctx_t fs_ctx)

Wipes all files from the filesystem.

Parameters
[in,out]fs_ctxFilesystem context to wipe. Must be prepared again before further use.
Returns
Returns error code as specified in psa_status_t

Definition at line 92 of file its_flash_fs.c.

Here is the call graph for this function:

Here is the caller graph for this function: