1 /*
2  * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
3  * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  */
8 
9 #include "tfm_hal_its.h"
10 
11 #include "cmsis_compiler.h"
12 #include "flash_layout.h"
13 
14 /* The base address of the dedicated flash area for ITS */
15 #ifndef TFM_HAL_ITS_FLASH_AREA_ADDR
16 #error "TFM_HAL_ITS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
17 #endif
18 
19 /* The size of the dedicated flash area for ITS in bytes */
20 #ifndef TFM_HAL_ITS_FLASH_AREA_SIZE
21 #error "TFM_HAL_ITS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
22 #endif
23 
24 /* The number of contiguous physical flash erase sectors per logical filesystem
25  * erase block. Adjust so that the maximum required asset size will fit in one
26  * logical block.
27  */
28 #ifndef TFM_HAL_ITS_SECTORS_PER_BLOCK
29 #error "TFM_HAL_ITS_SECTORS_PER_BLOCK must be defined by the target in flash_layout.h"
30 #endif
31 
32 __WEAK enum tfm_hal_status_t
tfm_hal_its_fs_info(struct tfm_hal_its_fs_info_t * fs_info)33 tfm_hal_its_fs_info(struct tfm_hal_its_fs_info_t *fs_info)
34 {
35     if (!fs_info) {
36         return TFM_HAL_ERROR_INVALID_INPUT;
37     }
38 
39     fs_info->flash_area_addr = TFM_HAL_ITS_FLASH_AREA_ADDR;
40     fs_info->flash_area_size = TFM_HAL_ITS_FLASH_AREA_SIZE;
41     fs_info->sectors_per_block = TFM_HAL_ITS_SECTORS_PER_BLOCK;
42 
43     return TFM_HAL_SUCCESS;
44 }
45