Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved. |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 3 | * Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef __TFM_HAL_ITS_H__ |
| 10 | #define __TFM_HAL_ITS_H__ |
| 11 | |
Chris Brand | 8a6b5c5 | 2020-10-30 16:49:56 -0700 | [diff] [blame] | 12 | #include <stddef.h> |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | |
| 15 | #include "Driver_Flash.h" |
| 16 | #include "flash_layout.h" |
| 17 | #include "tfm_hal_defs.h" |
Chris Brand | 8a6b5c5 | 2020-10-30 16:49:56 -0700 | [diff] [blame] | 18 | |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 23 | /* The name of the ARM_DRIVER_FLASH to use for ITS */ |
| 24 | #ifndef TFM_HAL_ITS_FLASH_DRIVER |
| 25 | #error "TFM_HAL_ITS_FLASH_DRIVER must be defined by the target in flash_layout.h" |
| 26 | #endif |
| 27 | |
| 28 | /* The size of the ITS flash device's physical program unit. Must be equal to |
| 29 | * TFM_HAL_ITS_FLASH_DRIVER.GetInfo()->program_unit, but required at compile |
| 30 | * time. |
| 31 | */ |
| 32 | #ifndef TFM_HAL_ITS_PROGRAM_UNIT |
| 33 | #error "TFM_HAL_ITS_PROGRAM_UNIT must be defined by the target in flash_layout.h" |
| 34 | #elif (TFM_HAL_ITS_PROGRAM_UNIT < 1) |
| 35 | #error "TFM_HAL_ITS_PROGRAM_UNIT must be greater than 1" |
| 36 | #elif (TFM_HAL_ITS_PROGRAM_UNIT & (TFM_HAL_ITS_PROGRAM_UNIT - 1) != 0) |
| 37 | #error "TFM_HAL_ITS_PROGRAM_UNIT must be a power of two" |
| 38 | #endif |
| 39 | |
| 40 | /** |
| 41 | * \brief Struct containing information required from the platform at runtime |
| 42 | * to configure the ITS filesystem. |
| 43 | */ |
| 44 | struct tfm_hal_its_fs_info_t { |
| 45 | uint32_t flash_area_addr; /**< Location of the block of flash to use for |
| 46 | * ITS |
| 47 | */ |
| 48 | size_t flash_area_size; /**< Number of bytes of flash to use for ITS */ |
| 49 | uint8_t sectors_per_block; /**< Number of erase sectors per logical FS block |
| 50 | */ |
| 51 | }; |
| 52 | |
| 53 | /** |
| 54 | * \brief The flash driver to use for ITS. |
| 55 | */ |
| 56 | extern ARM_DRIVER_FLASH TFM_HAL_ITS_FLASH_DRIVER; |
| 57 | |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 58 | /** |
| 59 | * \brief Retrieve the filesystem config for ITS. |
| 60 | * |
| 61 | * Note that this function should ensure that the values returned do |
| 62 | * not result in a security compromise. |
| 63 | * |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 64 | * \param [out] fs_info Filesystem config information |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 65 | * |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 66 | * \return A status code as specified in \ref tfm_hal_status_t |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 67 | * If an error is detected within this function, is should leave the |
| 68 | * content of the parameters unchanged. |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 69 | * |
| 70 | * \retval TFM_HAL_SUCCESS The operation completed successfully |
| 71 | * \retval TFM_HAL_ERROR_INVALID_INPUT Invalid parameter |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 72 | */ |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame] | 73 | enum tfm_hal_status_t |
| 74 | tfm_hal_its_fs_info(struct tfm_hal_its_fs_info_t *fs_info); |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 75 | |
| 76 | #ifdef __cplusplus |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | #endif /* __TFM_HAL_ITS_H__ */ |