mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /*
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * SPDX-License-Identifier: BSD-3-Clause
kenjiArai 0:5b88d5760320 5 *
kenjiArai 0:5b88d5760320 6 */
kenjiArai 0:5b88d5760320 7
kenjiArai 0:5b88d5760320 8 #ifndef __TFM_SPM_HAL_H__
kenjiArai 0:5b88d5760320 9 #define __TFM_SPM_HAL_H__
kenjiArai 0:5b88d5760320 10
kenjiArai 0:5b88d5760320 11 #include <stdint.h>
kenjiArai 0:5b88d5760320 12 #include "tfm_secure_api.h"
kenjiArai 0:5b88d5760320 13 #include "spm_api.h"
kenjiArai 0:5b88d5760320 14
kenjiArai 0:5b88d5760320 15 /**
kenjiArai 0:5b88d5760320 16 * \brief Holds peripheral specific data fields required to manage the
kenjiArai 0:5b88d5760320 17 * peripherals isolation
kenjiArai 0:5b88d5760320 18 *
kenjiArai 0:5b88d5760320 19 * This structure has to be defined in the platform directory, and may have
kenjiArai 0:5b88d5760320 20 * different definition for each platform. The structure should contain fields
kenjiArai 0:5b88d5760320 21 * that describe the peripheral for the functions that are prototyped in this
kenjiArai 0:5b88d5760320 22 * file and are responsible for configuring the isolation of the peripherals.
kenjiArai 0:5b88d5760320 23 *
kenjiArai 0:5b88d5760320 24 * Pointers to structures of this type are managed by the SPM, and passed to the
kenjiArai 0:5b88d5760320 25 * necessary function on isolation request. The pointers are also defined by the
kenjiArai 0:5b88d5760320 26 * platform in the header file tfm_peripherals_def.h. For details on this, see
kenjiArai 0:5b88d5760320 27 * the documentation of that file.
kenjiArai 0:5b88d5760320 28 */
kenjiArai 0:5b88d5760320 29 struct tfm_spm_partition_platform_data_t;
kenjiArai 0:5b88d5760320 30
kenjiArai 0:5b88d5760320 31 #if defined (TFM_PSA_API) || (TFM_LVL != 1)
kenjiArai 0:5b88d5760320 32 /**
kenjiArai 0:5b88d5760320 33 * \brief Holds SPM db fields that define the memory regions used by a
kenjiArai 0:5b88d5760320 34 * partition.
kenjiArai 0:5b88d5760320 35 */
kenjiArai 0:5b88d5760320 36 struct tfm_spm_partition_memory_data_t
kenjiArai 0:5b88d5760320 37 {
kenjiArai 0:5b88d5760320 38 uint32_t code_start; /*!< Start of the code memory of this partition. */
kenjiArai 0:5b88d5760320 39 uint32_t code_limit; /*!< Address of the byte beyond the end of the code
kenjiArai 0:5b88d5760320 40 * memory of this partition.
kenjiArai 0:5b88d5760320 41 */
kenjiArai 0:5b88d5760320 42 uint32_t ro_start; /*!< Start of the read only memory of this
kenjiArai 0:5b88d5760320 43 * partition.
kenjiArai 0:5b88d5760320 44 */
kenjiArai 0:5b88d5760320 45 uint32_t ro_limit; /*!< Address of the byte beyond the end of the read
kenjiArai 0:5b88d5760320 46 * only memory of this partition.
kenjiArai 0:5b88d5760320 47 */
kenjiArai 0:5b88d5760320 48 uint32_t rw_start; /*!< Start of the data region of this partition. */
kenjiArai 0:5b88d5760320 49 uint32_t rw_limit; /*!< Address of the byte beyond the end of the data
kenjiArai 0:5b88d5760320 50 * region of this partition.
kenjiArai 0:5b88d5760320 51 */
kenjiArai 0:5b88d5760320 52 uint32_t zi_start; /*!< Start of the zero initialised data region of
kenjiArai 0:5b88d5760320 53 * this partition.
kenjiArai 0:5b88d5760320 54 */
kenjiArai 0:5b88d5760320 55 uint32_t zi_limit; /*!< Address of the byte beyond the end of the zero
kenjiArai 0:5b88d5760320 56 * initialised region of this partition.
kenjiArai 0:5b88d5760320 57 */
kenjiArai 0:5b88d5760320 58 uint32_t stack_bottom; /*!< The bottom of the stack for the partition. */
kenjiArai 0:5b88d5760320 59 uint32_t stack_top; /*!< The top of the stack for the partition. */
kenjiArai 0:5b88d5760320 60 };
kenjiArai 0:5b88d5760320 61 #endif
kenjiArai 0:5b88d5760320 62
kenjiArai 0:5b88d5760320 63 /**
kenjiArai 0:5b88d5760320 64 * \brief This function initialises the HW used for isolation, and sets the
kenjiArai 0:5b88d5760320 65 * default configuration for them.
kenjiArai 0:5b88d5760320 66 *
kenjiArai 0:5b88d5760320 67 * This function is called during TF-M core early startup, before DB init
kenjiArai 0:5b88d5760320 68 */
kenjiArai 0:5b88d5760320 69 void tfm_spm_hal_init_isolation_hw(void);
kenjiArai 0:5b88d5760320 70
kenjiArai 0:5b88d5760320 71 /**
kenjiArai 0:5b88d5760320 72 * \brief This function initialises the HW used for isolation, and sets the
kenjiArai 0:5b88d5760320 73 * default configuration for them.
kenjiArai 0:5b88d5760320 74 * This function is called during TF-M core early startup, after DB init
kenjiArai 0:5b88d5760320 75 */
kenjiArai 0:5b88d5760320 76 void tfm_spm_hal_setup_isolation_hw(void);
kenjiArai 0:5b88d5760320 77
kenjiArai 0:5b88d5760320 78 /**
kenjiArai 0:5b88d5760320 79 * \brief Configure peripherals for a partition based on the platfotm data from
kenjiArai 0:5b88d5760320 80 * the DB
kenjiArai 0:5b88d5760320 81 *
kenjiArai 0:5b88d5760320 82 * This function is called during partition initialisation (before calling the
kenjiArai 0:5b88d5760320 83 * init function for the partition)
kenjiArai 0:5b88d5760320 84 *
kenjiArai 0:5b88d5760320 85 * \param[in] platform_data The platform fields of the partition DB record to
kenjiArai 0:5b88d5760320 86 * be used for configuration. Can be NULL.
kenjiArai 0:5b88d5760320 87 */
kenjiArai 0:5b88d5760320 88 void tfm_spm_hal_configure_default_isolation(
kenjiArai 0:5b88d5760320 89 const struct tfm_spm_partition_platform_data_t *platform_data);
kenjiArai 0:5b88d5760320 90 /**
kenjiArai 0:5b88d5760320 91 * \brief Configures the system debug properties.
kenjiArai 0:5b88d5760320 92 * The default configuration of this function should disable secure debug
kenjiArai 0:5b88d5760320 93 * when either DAUTH_NONE or DAUTH_NS_ONLY define is set. It is up to the
kenjiArai 0:5b88d5760320 94 * platform owner to decide if secure debug can be turned on in their
kenjiArai 0:5b88d5760320 95 * system, if DAUTH_FULL define is present.
kenjiArai 0:5b88d5760320 96 * The DAUTH_CHIP_DEFAULT define should not be considered a safe default
kenjiArai 0:5b88d5760320 97 * option unless explicitly noted by the chip vendor.
kenjiArai 0:5b88d5760320 98 * The implementation has to expect that one of those defines is going to
kenjiArai 0:5b88d5760320 99 * be set. Otherwise, a compile error needs to be triggered.
kenjiArai 0:5b88d5760320 100 */
kenjiArai 0:5b88d5760320 101 void tfm_spm_hal_init_debug(void);
kenjiArai 0:5b88d5760320 102
kenjiArai 0:5b88d5760320 103 /**
kenjiArai 0:5b88d5760320 104 * \brief Enables the fault handlers
kenjiArai 0:5b88d5760320 105 */
kenjiArai 0:5b88d5760320 106 void enable_fault_handlers(void);
kenjiArai 0:5b88d5760320 107
kenjiArai 0:5b88d5760320 108 /**
kenjiArai 0:5b88d5760320 109 * \brief Configures the system reset request properties
kenjiArai 0:5b88d5760320 110 */
kenjiArai 0:5b88d5760320 111 void system_reset_cfg(void);
kenjiArai 0:5b88d5760320 112
kenjiArai 0:5b88d5760320 113 /**
kenjiArai 0:5b88d5760320 114 * \brief Configures all external interrupts to target the
kenjiArai 0:5b88d5760320 115 * NS state, apart for the ones associated to secure
kenjiArai 0:5b88d5760320 116 * peripherals (plus MPC and PPC)
kenjiArai 0:5b88d5760320 117 */
kenjiArai 0:5b88d5760320 118 void nvic_interrupt_target_state_cfg(void);
kenjiArai 0:5b88d5760320 119
kenjiArai 0:5b88d5760320 120 /**
kenjiArai 0:5b88d5760320 121 * \brief This function enable the interrupts associated
kenjiArai 0:5b88d5760320 122 * to the secure peripherals (plus the isolation boundary violation
kenjiArai 0:5b88d5760320 123 * interrupts)
kenjiArai 0:5b88d5760320 124 */
kenjiArai 0:5b88d5760320 125 void nvic_interrupt_enable(void);
kenjiArai 0:5b88d5760320 126
kenjiArai 0:5b88d5760320 127 /**
kenjiArai 0:5b88d5760320 128 * \brief Get the VTOR value of non-secure image
kenjiArai 0:5b88d5760320 129 *
kenjiArai 0:5b88d5760320 130 * \return Returns the address where the vector table of the non-secure image
kenjiArai 0:5b88d5760320 131 * is located
kenjiArai 0:5b88d5760320 132 */
kenjiArai 0:5b88d5760320 133 uint32_t tfm_spm_hal_get_ns_VTOR(void);
kenjiArai 0:5b88d5760320 134
kenjiArai 0:5b88d5760320 135 /**
kenjiArai 0:5b88d5760320 136 * \brief Get the initial address of non-secure image main stack
kenjiArai 0:5b88d5760320 137 *
kenjiArai 0:5b88d5760320 138 * \return Returns the initial non-secure MSP
kenjiArai 0:5b88d5760320 139 */
kenjiArai 0:5b88d5760320 140 uint32_t tfm_spm_hal_get_ns_MSP(void);
kenjiArai 0:5b88d5760320 141
kenjiArai 0:5b88d5760320 142 /**
kenjiArai 0:5b88d5760320 143 * \brief Get the entry point of the non-secure image
kenjiArai 0:5b88d5760320 144 *
kenjiArai 0:5b88d5760320 145 * \return Returns the address of the non-secure image entry point
kenjiArai 0:5b88d5760320 146 */
kenjiArai 0:5b88d5760320 147 uint32_t tfm_spm_hal_get_ns_entry_point(void);
kenjiArai 0:5b88d5760320 148
kenjiArai 0:5b88d5760320 149
kenjiArai 0:5b88d5760320 150 #if (TFM_LVL != 1) && !defined(TFM_PSA_API)
kenjiArai 0:5b88d5760320 151 /**
kenjiArai 0:5b88d5760320 152 * \brief Configure the sandbox for a partition.
kenjiArai 0:5b88d5760320 153 *
kenjiArai 0:5b88d5760320 154 * \param[in] memory_data The memory ranges from the partition DB for this
kenjiArai 0:5b88d5760320 155 * partition
kenjiArai 0:5b88d5760320 156 * \param[in] platform_data The platform fields of the partition DB record
kenjiArai 0:5b88d5760320 157 * for this partition. Can be NULL.
kenjiArai 0:5b88d5760320 158 *
kenjiArai 0:5b88d5760320 159 * \return Returns the result operation as per \ref spm_err_t
kenjiArai 0:5b88d5760320 160 */
kenjiArai 0:5b88d5760320 161 enum spm_err_t tfm_spm_hal_partition_sandbox_config(
kenjiArai 0:5b88d5760320 162 const struct tfm_spm_partition_memory_data_t *memory_data,
kenjiArai 0:5b88d5760320 163 const struct tfm_spm_partition_platform_data_t *platform_data);
kenjiArai 0:5b88d5760320 164
kenjiArai 0:5b88d5760320 165 /**
kenjiArai 0:5b88d5760320 166 * \brief Deconfigure the sandbox for a partition.
kenjiArai 0:5b88d5760320 167 *
kenjiArai 0:5b88d5760320 168 * \param[in] memory_data The memory ranges from the partition DB for this
kenjiArai 0:5b88d5760320 169 * partition
kenjiArai 0:5b88d5760320 170 * \param[in] platform_data The platform fields of the partition DB record
kenjiArai 0:5b88d5760320 171 * for this partition. Can be NULL.
kenjiArai 0:5b88d5760320 172 *
kenjiArai 0:5b88d5760320 173 * \return Returns the result operation as per \ref spm_err_t
kenjiArai 0:5b88d5760320 174 */
kenjiArai 0:5b88d5760320 175 enum spm_err_t tfm_spm_hal_partition_sandbox_deconfig(
kenjiArai 0:5b88d5760320 176 const struct tfm_spm_partition_memory_data_t *memory_data,
kenjiArai 0:5b88d5760320 177 const struct tfm_spm_partition_platform_data_t *platform_data);
kenjiArai 0:5b88d5760320 178
kenjiArai 0:5b88d5760320 179 /**
kenjiArai 0:5b88d5760320 180 * \brief Set the share region mode
kenjiArai 0:5b88d5760320 181 *
kenjiArai 0:5b88d5760320 182 * \param[in] share The mode to set
kenjiArai 0:5b88d5760320 183 *
kenjiArai 0:5b88d5760320 184 * \return Returns the result operation as per \ref spm_err_t
kenjiArai 0:5b88d5760320 185 */
kenjiArai 0:5b88d5760320 186 enum spm_err_t tfm_spm_hal_set_share_region(
kenjiArai 0:5b88d5760320 187 enum tfm_buffer_share_region_e share);
kenjiArai 0:5b88d5760320 188 #endif
kenjiArai 0:5b88d5760320 189
kenjiArai 0:5b88d5760320 190 #endif /* __TFM_SPM_HAL_H__ */