TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
its_flash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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 
9 #ifndef __ITS_FLASH_H__
10 #define __ITS_FLASH_H__
11 
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 #include "flash_layout.h"
16 #include "psa/error.h"
17 #include "its_utils.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /* Invalid block index */
24 #define ITS_BLOCK_INVALID_ID 0xFFFFFFFFU
25 
26 /* FIXME: Duplicated from flash info */
27 #if (ITS_FLASH_PROGRAM_UNIT <= 16)
28 #define ITS_FLASH_ALIGNMENT ITS_FLASH_PROGRAM_UNIT
29 #else
30 #define ITS_FLASH_ALIGNMENT 1
31 #endif
32 
33 #if (PS_FLASH_PROGRAM_UNIT <= 16)
34 #define PS_FLASH_ALIGNMENT PS_FLASH_PROGRAM_UNIT
35 #else
36 #define PS_FLASH_ALIGNMENT 1
37 #endif
38 
43 #define ITS_FLASH_MAX_ALIGNMENT ITS_UTILS_MAX(ITS_FLASH_ALIGNMENT, \
44  PS_FLASH_ALIGNMENT)
45 
55 };
56 
62  /* TODO - move flash_dev here from struct its_flash_info_t */
63  uint32_t flash_area_addr;
64  size_t flash_area_size;
65 };
66 
82  psa_status_t (*init)(const struct its_flash_info_t *info);
83 
101  psa_status_t (*read)(const struct its_flash_info_t *info, uint32_t block_id,
102  uint8_t *buff, size_t offset, size_t size);
103 
121  psa_status_t (*write)(const struct its_flash_info_t *info,
122  uint32_t block_id, const uint8_t *buff, size_t offset,
123  size_t size);
124 
139  psa_status_t (*flush)(const struct its_flash_info_t *info);
140 
152  psa_status_t (*erase)(const struct its_flash_info_t *info,
153  uint32_t block_id);
154 
155  void *flash_dev;
157  uint16_t sector_size;
160  uint16_t block_size;
164  uint16_t num_blocks;
165  uint16_t program_unit;
166  uint16_t max_file_size;
167  uint16_t max_num_files;
168  uint8_t erase_val;
171 };
172 
180 const struct its_flash_info_t *its_flash_get_info(enum its_flash_id_t id);
181 
203  uint32_t dst_block,
204  size_t dst_offset,
205  uint32_t src_block,
206  size_t src_offset,
207  size_t size);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* __ITS_FLASH_H__ */
const struct its_flash_info_t * its_flash_get_info(enum its_flash_id_t id)
Gets the flash info structure for the provided flash device.
Definition: its_flash.c:27
uint16_t program_unit
Definition: its_flash.h:165
uint32_t flash_area_addr
Definition: its_flash.h:63
psa_status_t(* erase)(const struct its_flash_info_t *info, uint32_t block_id)
Erases block ID data.
Definition: its_flash.h:152
uint16_t block_size
Definition: its_flash.h:160
psa_status_t its_flash_block_to_block_move(const struct its_flash_info_t *info, uint32_t dst_block, size_t dst_offset, uint32_t src_block, size_t src_offset, size_t size)
Moves data from source block ID to destination block ID.
Definition: its_flash.c:56
Standard error codes for the SPM and RoT Services.
its_flash_id_t
Enumerates the available flash devices.
Definition: its_flash.h:52
psa_status_t(* read)(const struct its_flash_info_t *info, uint32_t block_id, uint8_t *buff, size_t offset, size_t size)
Reads block data from the position specified by block ID and offset.
Definition: its_flash.h:101
uint16_t num_blocks
Definition: its_flash.h:164
uint16_t max_file_size
Definition: its_flash.h:166
psa_status_t(* flush)(const struct its_flash_info_t *info)
Flushes modifications to a block to flash. Must be called after a sequence of calls to write() (inclu...
Definition: its_flash.h:139
size_t flash_area_size
Definition: its_flash.h:64
void * flash_dev
Definition: its_flash.h:155
struct flash_fs_info_t fs_info
Definition: its_flash.h:156
uint8_t erase_val
Definition: its_flash.h:168
uint16_t sector_size
Definition: its_flash.h:157
flash filesystem configuration structure
Definition: its_flash.h:61
Structure containing the required information about a flash device to be used by the ITS Flash FS...
Definition: its_flash.h:73
psa_status_t(* init)(const struct its_flash_info_t *info)
Initialize the Flash Interface.
Definition: its_flash.h:82
uint16_t max_num_files
Definition: its_flash.h:167
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
psa_status_t(* write)(const struct its_flash_info_t *info, uint32_t block_id, const uint8_t *buff, size_t offset, size_t size)
Writes block data to the position specified by block ID and offset.
Definition: its_flash.h:121