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
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  */
8 
17 #ifndef __ITS_FLASH_FS_H__
18 #define __ITS_FLASH_FS_H__
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #include "its_flash_fs_mblock.h"
24 #include "psa/error.h"
25 #include "flash/its_flash.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /* Space reserved for user-defined flags. These are stored in the file metadata
32  * and can be retrieved by getting the file info.
33  */
34 #define ITS_FLASH_FS_USER_FLAGS_MASK ((1U << 16) - 1)
35 
36 /* Filesystem flags that can be provided when calling the write function */
37 #define ITS_FLASH_FS_WRITE_FLAGS_MASK ((1U << 24) - (1U << 16))
38 /* Create the file if it does not already exist */
39 #define ITS_FLASH_FS_FLAG_CREATE (1U << 16)
40 /* Remove existing file data if it exists */
41 #define ITS_FLASH_FS_FLAG_TRUNCATE (1U << 17)
42 
53 
60  size_t size_current;
61  size_t size_max;
64  uint32_t flags;
65 };
66 
78  const struct its_flash_info_t *flash_info);
79 
89 
101  const uint8_t *fid);
102 
114  const uint8_t *fid,
115  struct its_file_info_t *info);
116 
133  const uint8_t *fid,
134  uint32_t flags,
135  size_t max_size,
136  size_t data_size,
137  size_t offset,
138  const uint8_t *data);
139 
152  const uint8_t *fid,
153  size_t size,
154  size_t offset,
155  uint8_t *data);
156 
166  const uint8_t *fid);
167 
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* __ITS_FLASH_FS_H__ */
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.
Definition: its_flash_fs.c:98
uint32_t flags
Definition: its_flash_fs.h:64
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.
Definition: its_flash_fs.c:454
size_t size_current
Definition: its_flash_fs.h:60
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.
Definition: its_flash_fs.c:469
Standard error codes for the SPM and RoT Services.
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.
Definition: its_flash_fs.c:58
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.
Definition: its_flash_fs.c:144
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.
Definition: its_flash_fs.c:112
psa_status_t its_flash_fs_validate_params(const struct its_flash_info_t *info)
Validates the configuration of the flash filesystem.
Definition: its_flash_fs.c:541
Structure to store the file information.
Definition: its_flash_fs.h:59
Structure containing the required information about a flash device to be used by the ITS Flash FS...
Definition: its_flash.h:73
Structure to store the ITS flash file system context.
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
psa_status_t its_flash_fs_wipe_all(its_flash_fs_ctx_t *fs_ctx)
Wipes all files from the filesystem.
Definition: its_flash_fs.c:92