blob: a45148504db37c27270fad9b22608b7eb3ca7d94 [file] [log] [blame]
Chris Brandc47d7102020-02-20 11:12:18 -08001/*
2 * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
Jamie Fox6a3946a2020-12-07 21:50:31 +00003 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Chris Brandc47d7102020-02-20 11:12:18 -08004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 */
8
9#ifndef __TFM_HAL_ITS_H__
10#define __TFM_HAL_ITS_H__
11
Chris Brand8a6b5c52020-10-30 16:49:56 -070012#include <stddef.h>
Jamie Fox6a3946a2020-12-07 21:50:31 +000013#include <stdint.h>
14
15#include "Driver_Flash.h"
16#include "flash_layout.h"
17#include "tfm_hal_defs.h"
Chris Brand8a6b5c52020-10-30 16:49:56 -070018
Chris Brandc47d7102020-02-20 11:12:18 -080019#ifdef __cplusplus
20extern "C" {
21#endif
22
Jamie Fox6a3946a2020-12-07 21:50:31 +000023/* 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 */
44struct 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 */
56extern ARM_DRIVER_FLASH TFM_HAL_ITS_FLASH_DRIVER;
57
Chris Brandc47d7102020-02-20 11:12:18 -080058/**
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 Fox6a3946a2020-12-07 21:50:31 +000064 * \param [out] fs_info Filesystem config information
Chris Brandc47d7102020-02-20 11:12:18 -080065 *
Jamie Fox6a3946a2020-12-07 21:50:31 +000066 * \return A status code as specified in \ref tfm_hal_status_t
Chris Brandc47d7102020-02-20 11:12:18 -080067 * If an error is detected within this function, is should leave the
68 * content of the parameters unchanged.
Jamie Fox6a3946a2020-12-07 21:50:31 +000069 *
70 * \retval TFM_HAL_SUCCESS The operation completed successfully
71 * \retval TFM_HAL_ERROR_INVALID_INPUT Invalid parameter
Chris Brandc47d7102020-02-20 11:12:18 -080072 */
Jamie Fox6a3946a2020-12-07 21:50:31 +000073enum tfm_hal_status_t
74tfm_hal_its_fs_info(struct tfm_hal_its_fs_info_t *fs_info);
Chris Brandc47d7102020-02-20 11:12:18 -080075
76#ifdef __cplusplus
77}
78#endif
79
80#endif /* __TFM_HAL_ITS_H__ */