Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 1 | /* |
Gyorgy Szing | 40a7af0 | 2019-02-06 14:19:47 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __SPM_API_H__ |
| 9 | #define __SPM_API_H__ |
| 10 | |
| 11 | /* This file contains the apis exported by the SPM to tfm core */ |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 12 | #include "tfm_api.h" |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 13 | #include "spm_partition_defs.h" |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 14 | #include "secure_fw/core/tfm_secure_api.h" |
| 15 | |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 16 | #define SPM_INVALID_PARTITION_IDX (~0U) |
| 17 | |
Summer Qin | eb537e5 | 2019-03-29 09:57:10 +0800 | [diff] [blame] | 18 | /* Privileged definitions for partition thread mode */ |
| 19 | #define TFM_PARTITION_PRIVILEGED_MODE 1 |
| 20 | #define TFM_PARTITION_UNPRIVILEGED_MODE 0 |
| 21 | |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 22 | enum spm_err_t { |
| 23 | SPM_ERR_OK = 0, |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 24 | SPM_ERR_PARTITION_DB_NOT_INIT, |
| 25 | SPM_ERR_PARTITION_ALREADY_ACTIVE, |
| 26 | SPM_ERR_PARTITION_NOT_AVAILABLE, |
Hugues de Valon | f704c80 | 2019-02-19 14:51:41 +0000 | [diff] [blame] | 27 | SPM_ERR_INVALID_PARAMETER, |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 28 | SPM_ERR_INVALID_CONFIG, |
| 29 | }; |
| 30 | |
Hugues de Valon | 9957856 | 2019-06-18 16:08:51 +0100 | [diff] [blame] | 31 | #define SPM_PARTITION_STATE_UNINIT 0 |
| 32 | #define SPM_PARTITION_STATE_IDLE 1 |
| 33 | #define SPM_PARTITION_STATE_RUNNING 2 |
| 34 | #define SPM_PARTITION_STATE_HANDLING_IRQ 3 |
| 35 | #define SPM_PARTITION_STATE_SUSPENDED 4 |
| 36 | #define SPM_PARTITION_STATE_BLOCKED 5 |
| 37 | #define SPM_PARTITION_STATE_CLOSED 6 |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 38 | |
Hugues de Valon | 9957856 | 2019-06-18 16:08:51 +0100 | [diff] [blame] | 39 | #define SPM_PART_FLAG_APP_ROT 0x01 |
| 40 | #define SPM_PART_FLAG_PSA_ROT 0x02 |
| 41 | #define SPM_PART_FLAG_IPC 0x04 |
Mate Toth-Pal | 5939871 | 2018-02-28 17:06:40 +0100 | [diff] [blame] | 42 | |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 43 | /** |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 44 | * \brief Holds the iovec parameters that are passed to a service |
| 45 | * |
| 46 | * \note The size of the structure is (and have to be) multiple of 8 bytes |
| 47 | */ |
| 48 | struct iovec_args_t { |
| 49 | psa_invec in_vec[PSA_MAX_IOVEC]; /*!< Array of psa_invec objects */ |
| 50 | size_t in_len; /*!< Number psa_invec objects in in_vec |
| 51 | */ |
| 52 | psa_outvec out_vec[PSA_MAX_IOVEC]; /*!< Array of psa_outvec objects */ |
| 53 | size_t out_len; /*!< Number psa_outvec objects in out_vec |
| 54 | */ |
| 55 | }; |
| 56 | |
| 57 | /** |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 58 | * \brief Runtime context information of a partition |
| 59 | */ |
| 60 | struct spm_partition_runtime_data_t { |
| 61 | uint32_t partition_state; |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 62 | uint32_t caller_partition_idx; |
Mate Toth-Pal | 21a74c9 | 2018-04-13 14:05:41 +0200 | [diff] [blame] | 63 | int32_t caller_client_id; |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 64 | uint32_t share; |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 65 | uint32_t stack_ptr; |
Miklos Balint | ace4c3f | 2018-07-30 12:31:15 +0200 | [diff] [blame] | 66 | uint32_t lr; |
Mate Toth-Pal | 2a6f8c2 | 2018-12-13 16:37:17 +0100 | [diff] [blame] | 67 | int32_t iovec_api; /*!< Whether the function in the partition |
| 68 | * had been called using the iovec API. |
| 69 | * FIXME: Remove the field once this is the |
| 70 | * only option |
| 71 | */ |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 72 | struct iovec_args_t iovec_args; |
| 73 | psa_outvec *orig_outvec; |
Mate Toth-Pal | 4341de0 | 2018-10-02 12:55:47 +0200 | [diff] [blame] | 74 | uint32_t *ctx_stack_ptr; |
| 75 | /* |
| 76 | * FIXME: There is a 'signal_mask' defined in the structure |
| 77 | * 'tfm_spm_ipc_partition_t'. It should be eliminated, and the IPC |
| 78 | * implementation should use the 'signal_mask' define in this structure. |
| 79 | * However currently the content of 'spm_partition_runtime_data_t' structure |
| 80 | * is not maintained by the IPC implementation. This is to be fixed with the |
| 81 | * effort of restructuring common code among library and IPC model. |
| 82 | */ |
| 83 | uint32_t signal_mask; |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 86 | |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 87 | /** |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 88 | * \brief Returns the index of the partition with the given partition ID. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 89 | * |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 90 | * \param[in] partition_id Partition id |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 91 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 92 | * \return the partition idx if partition_id is valid, |
| 93 | * \ref SPM_INVALID_PARTITION_IDX othervise |
| 94 | */ |
| 95 | uint32_t get_partition_idx(uint32_t partition_id); |
| 96 | |
Miklos Balint | dd02bb3 | 2019-05-26 21:13:12 +0200 | [diff] [blame] | 97 | #if (TFM_LVL != 1) || defined(TFM_PSA_API) |
Summer Qin | d00e4db | 2019-05-09 18:03:52 +0800 | [diff] [blame] | 98 | /** |
| 99 | * \brief Get bottom of stack region for a partition |
| 100 | * |
| 101 | * \param[in] partition_idx Partition index |
| 102 | * |
| 103 | * \return Stack region bottom value |
| 104 | * |
| 105 | * \note This function doesn't check if partition_idx is valid. |
| 106 | */ |
| 107 | uint32_t tfm_spm_partition_get_stack_bottom(uint32_t partition_idx); |
| 108 | |
| 109 | /** |
| 110 | * \brief Get top of stack region for a partition |
| 111 | * |
| 112 | * \param[in] partition_idx Partition index |
| 113 | * |
| 114 | * \return Stack region top value |
| 115 | * |
| 116 | * \note This function doesn't check if partition_idx is valid. |
| 117 | */ |
| 118 | uint32_t tfm_spm_partition_get_stack_top(uint32_t partition_idx); |
Miklos Balint | dd02bb3 | 2019-05-26 21:13:12 +0200 | [diff] [blame] | 119 | #endif |
Summer Qin | d00e4db | 2019-05-09 18:03:52 +0800 | [diff] [blame] | 120 | |
Miklos Balint | dd02bb3 | 2019-05-26 21:13:12 +0200 | [diff] [blame] | 121 | #if (TFM_LVL != 1) && !defined(TFM_PSA_API) |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 122 | /** |
| 123 | * \brief Configure isolated sandbox for a partition |
| 124 | * |
| 125 | * \param[in] partition_idx Partition index |
| 126 | * |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 127 | * \return Error code \ref spm_err_t |
| 128 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 129 | * \note This function doesn't check if partition_idx is valid. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 130 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 131 | enum spm_err_t tfm_spm_partition_sandbox_config(uint32_t partition_idx); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 132 | |
| 133 | /** |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 134 | * \brief Deconfigure sandbox for a partition |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 135 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 136 | * \param[in] partition_idx Partition index |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 137 | * |
| 138 | * \return Error code \ref spm_err_t |
| 139 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 140 | * \note This function doesn't check if partition_idx is valid. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 141 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 142 | enum spm_err_t tfm_spm_partition_sandbox_deconfig(uint32_t partition_idx); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 143 | |
| 144 | /** |
Mate Toth-Pal | 21a74c9 | 2018-04-13 14:05:41 +0200 | [diff] [blame] | 145 | * \brief Get the start of the zero-initialised region for a partition |
| 146 | * |
| 147 | * \param[in] partition_idx Partition idx |
| 148 | * |
| 149 | * \return Start of the zero-initialised region |
| 150 | * |
| 151 | * \note This function doesn't check if partition_idx is valid. |
| 152 | */ |
| 153 | uint32_t tfm_spm_partition_get_zi_start(uint32_t partition_idx); |
| 154 | |
| 155 | /** |
| 156 | * \brief Get the limit of the zero-initialised region for a partition |
| 157 | * |
| 158 | * \param[in] partition_idx Partition idx |
| 159 | * |
| 160 | * \return Limit of the zero-initialised region |
| 161 | * |
| 162 | * \note This function doesn't check if partition_idx is valid. |
| 163 | * \note The address returned is not part of the region. |
| 164 | */ |
| 165 | uint32_t tfm_spm_partition_get_zi_limit(uint32_t partition_idx); |
| 166 | |
| 167 | /** |
| 168 | * \brief Get the start of the read-write region for a partition |
| 169 | * |
| 170 | * \param[in] partition_idx Partition idx |
| 171 | * |
| 172 | * \return Start of the read-write region |
| 173 | * |
| 174 | * \note This function doesn't check if partition_idx is valid. |
| 175 | */ |
| 176 | uint32_t tfm_spm_partition_get_rw_start(uint32_t partition_idx); |
| 177 | |
| 178 | /** |
| 179 | * \brief Get the limit of the read-write region for a partition |
| 180 | * |
| 181 | * \param[in] partition_idx Partition idx |
| 182 | * |
| 183 | * \return Limit of the read-write region |
| 184 | * |
| 185 | * \note This function doesn't check if partition_idx is valid. |
| 186 | * \note The address returned is not part of the region. |
| 187 | */ |
| 188 | uint32_t tfm_spm_partition_get_rw_limit(uint32_t partition_idx); |
| 189 | |
| 190 | /** |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 191 | * \brief Save stack pointer for partition in database |
| 192 | * |
| 193 | * \param[in] partition_idx Partition index |
| 194 | * \param[in] stack_ptr Stack pointer to be stored |
| 195 | * |
| 196 | * \note This function doesn't check if partition_idx is valid. |
| 197 | */ |
Gyorgy Szing | 40a7af0 | 2019-02-06 14:19:47 +0100 | [diff] [blame] | 198 | void tfm_spm_partition_set_stack(uint32_t partition_idx, uint32_t stack_ptr); |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 199 | #endif |
| 200 | |
| 201 | /** |
Summer Qin | b4a854d | 2019-05-29 15:31:22 +0800 | [diff] [blame] | 202 | * \brief Get the id of the partition for its index from the db |
| 203 | * |
| 204 | * \param[in] partition_idx Partition index |
| 205 | * |
| 206 | * \return Partition ID for that partition |
| 207 | * |
| 208 | * \note This function doesn't check if partition_idx is valid. |
| 209 | */ |
| 210 | uint32_t tfm_spm_partition_get_partition_id(uint32_t partition_idx); |
| 211 | |
| 212 | /** |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 213 | * \brief Get the flags associated with a partition |
| 214 | * |
| 215 | * \param[in] partition_idx Partition index |
| 216 | * |
| 217 | * \return Flags associated with the partition |
| 218 | * |
| 219 | * \note This function doesn't check if partition_idx is valid. |
| 220 | */ |
| 221 | uint32_t tfm_spm_partition_get_flags(uint32_t partition_idx); |
| 222 | |
Summer Qin | b4a854d | 2019-05-29 15:31:22 +0800 | [diff] [blame] | 223 | #ifndef TFM_PSA_API |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 224 | /** |
Mate Toth-Pal | 4341de0 | 2018-10-02 12:55:47 +0200 | [diff] [blame] | 225 | * \brief Save interrupted partition context on ctx stack |
| 226 | * |
| 227 | * \param[in] partition_idx Partition index |
| 228 | * |
| 229 | * \note This function doesn't check if partition_idx is valid. |
| 230 | * \note This function doesn't whether the ctx stack overflows. |
| 231 | */ |
| 232 | void tfm_spm_partition_push_interrupted_ctx(uint32_t partition_idx); |
| 233 | |
| 234 | /** |
| 235 | * \brief Restores interrupted partition context on ctx stack |
| 236 | * |
| 237 | * \param[in] partition_idx Partition index |
| 238 | * |
| 239 | * \note This function doesn't check if partition_idx is valid. |
| 240 | * \note This function doesn't whether the ctx stack underflows. |
| 241 | */ |
| 242 | void tfm_spm_partition_pop_interrupted_ctx(uint32_t partition_idx); |
| 243 | |
| 244 | /** |
| 245 | * \brief Save handler partition context on ctx stack |
| 246 | * |
| 247 | * \param[in] partition_idx Partition index |
| 248 | * |
| 249 | * \note This function doesn't check if partition_idx is valid. |
| 250 | * \note This function doesn't whether the ctx stack overflows. |
| 251 | */ |
| 252 | void tfm_spm_partition_push_handler_ctx(uint32_t partition_idx); |
| 253 | |
| 254 | /** |
| 255 | * \brief Restores handler partition context on ctx stack |
| 256 | * |
| 257 | * \param[in] partition_idx Partition index |
| 258 | * |
| 259 | * \note This function doesn't check if partition_idx is valid. |
| 260 | * \note This function doesn't whether the ctx stack underflows. |
| 261 | */ |
| 262 | void tfm_spm_partition_pop_handler_ctx(uint32_t partition_idx); |
| 263 | |
| 264 | /** |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 265 | * \brief Get the current runtime data of a partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 266 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 267 | * \param[in] partition_idx Partition index |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 268 | * |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 269 | * \return The runtime data of the specified partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 270 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 271 | * \note This function doesn't check if partition_idx is valid. |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 272 | */ |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 273 | const struct spm_partition_runtime_data_t * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 274 | tfm_spm_partition_get_runtime_data(uint32_t partition_idx); |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 275 | |
| 276 | /** |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 277 | * \brief Returns the index of the partition that has running state |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 278 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 279 | * \return The index of the partition with the running state, if there is any |
| 280 | * set. 0 otherwise. |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 281 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 282 | uint32_t tfm_spm_partition_get_running_partition_idx(void); |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 283 | |
| 284 | /** |
Miklos Balint | ace4c3f | 2018-07-30 12:31:15 +0200 | [diff] [blame] | 285 | * \brief Save stack pointer and link register for partition in database |
| 286 | * |
| 287 | * \param[in] partition_idx Partition index |
| 288 | * \param[in] stack_ptr Stack pointer to be stored |
| 289 | * \param[in] lr Link register to be stored |
| 290 | * |
| 291 | * \note This function doesn't check if partition_idx is valid. |
| 292 | */ |
| 293 | void tfm_spm_partition_store_context(uint32_t partition_idx, |
| 294 | uint32_t stack_ptr, uint32_t lr); |
| 295 | |
| 296 | /** |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 297 | * \brief Set the current state of a partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 298 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 299 | * \param[in] partition_idx Partition index |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 300 | * \param[in] state The state to be set |
| 301 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 302 | * \note This function doesn't check if partition_idx is valid. |
Gyorgy Szing | 40a7af0 | 2019-02-06 14:19:47 +0100 | [diff] [blame] | 303 | * \note The state has to have the value set of \ref spm_part_state_t. |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 304 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 305 | void tfm_spm_partition_set_state(uint32_t partition_idx, uint32_t state); |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 306 | |
| 307 | /** |
Miklos Balint | 6a139ae | 2018-04-04 19:44:37 +0200 | [diff] [blame] | 308 | * \brief Set the caller partition index for a given partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 309 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 310 | * \param[in] partition_idx Partition index |
Miklos Balint | 6a139ae | 2018-04-04 19:44:37 +0200 | [diff] [blame] | 311 | * \param[in] caller_partition_idx The index of the caller partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 312 | * |
Miklos Balint | 6a139ae | 2018-04-04 19:44:37 +0200 | [diff] [blame] | 313 | * \note This function doesn't check if any of the partition_idxs are valid. |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 314 | */ |
Miklos Balint | 6a139ae | 2018-04-04 19:44:37 +0200 | [diff] [blame] | 315 | void tfm_spm_partition_set_caller_partition_idx(uint32_t partition_idx, |
| 316 | uint32_t caller_partition_idx); |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 317 | |
| 318 | /** |
Mate Toth-Pal | 21a74c9 | 2018-04-13 14:05:41 +0200 | [diff] [blame] | 319 | * \brief Set the caller client ID for a given partition |
| 320 | * |
| 321 | * \param[in] partition_idx Partition index |
| 322 | * \param[in] caller_client_id The ID of the calling client |
| 323 | * |
| 324 | * \note This function doesn't check if any of the partition_idxs are valid. |
| 325 | */ |
| 326 | void tfm_spm_partition_set_caller_client_id(uint32_t partition_idx, |
| 327 | int32_t caller_client_id); |
| 328 | |
| 329 | /** |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 330 | * \brief Set the buffer share region of the partition |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 331 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 332 | * \param[in] partition_idx Partition index |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 333 | * \param[in] share The buffer share region to be set |
| 334 | * |
| 335 | * \return Error code \ref spm_err_t |
| 336 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 337 | * \note This function doesn't check if partition_idx is valid. |
Hugues de Valon | 9957856 | 2019-06-18 16:08:51 +0100 | [diff] [blame] | 338 | * \note share has to have one of the buffer share values: |
| 339 | * - TFM_BUFFER_SHARE_DISABLE |
| 340 | * - TFM_BUFFER_SHARE_NS_CODE |
| 341 | * - TFM_BUFFER_SHARE_SCRATCH |
| 342 | * - TFM_BUFFER_SHARE_PRIV |
| 343 | * - TFM_BUFFER_SHARE_DEFAULT |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 344 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 345 | enum spm_err_t tfm_spm_partition_set_share(uint32_t partition_idx, |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 346 | uint32_t share); |
Mate Toth-Pal | 65291f3 | 2018-02-23 14:35:22 +0100 | [diff] [blame] | 347 | |
| 348 | /** |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 349 | * \brief Set the iovec parameters for the partition |
| 350 | * |
| 351 | * \param[in] partition_idx Partition index |
| 352 | * \param[in] args The arguments of the secure function |
| 353 | * |
| 354 | * args is expected to be of type int32_t[4] where: |
| 355 | * args[0] is in_vec |
| 356 | * args[1] is in_len |
| 357 | * args[2] is out_vec |
| 358 | * args[3] is out_len |
| 359 | * |
Hugues de Valon | f704c80 | 2019-02-19 14:51:41 +0000 | [diff] [blame] | 360 | * \return Error code \ref spm_err_t |
| 361 | * |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 362 | * \note This function doesn't check if partition_idx is valid. |
| 363 | * \note This function assumes that the iovecs that are passed in args are |
| 364 | * valid, and does no sanity check on them at all. |
| 365 | */ |
Hugues de Valon | f704c80 | 2019-02-19 14:51:41 +0000 | [diff] [blame] | 366 | enum spm_err_t tfm_spm_partition_set_iovec(uint32_t partition_idx, |
| 367 | const int32_t *args); |
Mate Toth-Pal | 3db437a | 2018-06-22 16:15:13 +0200 | [diff] [blame] | 368 | |
| 369 | /** |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 370 | * \brief Execute partition init function |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 371 | * |
| 372 | * \return Error code \ref spm_err_t |
| 373 | */ |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 374 | enum spm_err_t tfm_spm_partition_init(void); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 375 | |
| 376 | /** |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 377 | * \brief Clears the context info from the database for a partition. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 378 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 379 | * \param[in] partition_idx Partition index |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 380 | * |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 381 | * \note This function doesn't check if partition_idx is valid. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 382 | */ |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 383 | void tfm_spm_partition_cleanup_context(uint32_t partition_idx); |
Mate Toth-Pal | 4341de0 | 2018-10-02 12:55:47 +0200 | [diff] [blame] | 384 | |
| 385 | /** |
| 386 | * \brief Set the signal mask for a given partition |
| 387 | * |
| 388 | * \param[in] partition_idx Partition index |
| 389 | * \param[in] signal_mask The signal mask to be set for the partition |
| 390 | * |
| 391 | * \note This function doesn't check if any of the partition_idxs are valid. |
| 392 | */ |
| 393 | void tfm_spm_partition_set_signal_mask(uint32_t partition_idx, |
| 394 | uint32_t signal_mask); |
Summer Qin | b4a854d | 2019-05-29 15:31:22 +0800 | [diff] [blame] | 395 | #endif /* !defined(TFM_PSA_API) */ |
| 396 | |
| 397 | /** |
| 398 | * \brief Initialize partition database |
| 399 | * |
| 400 | * \return Error code \ref spm_err_t |
| 401 | */ |
| 402 | enum spm_err_t tfm_spm_db_init(void); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 403 | |
Edison Ai | b557135 | 2019-03-22 10:49:52 +0800 | [diff] [blame] | 404 | /** |
| 405 | * \brief Change the privilege mode for partition thread mode. |
| 406 | * |
| 407 | * \param[in] privileged Privileged mode, |
| 408 | * \ref TFM_PARTITION_PRIVILEGED_MODE |
| 409 | * and \ref TFM_PARTITION_UNPRIVILEGED_MODE |
| 410 | * |
| 411 | * \note Barrier instructions are not called by this function, and if |
| 412 | * it is called in thread mode, it might be necessary to call |
| 413 | * them after this function returns (just like it is done in |
| 414 | * jump_to_ns_code()). |
| 415 | */ |
| 416 | void tfm_spm_partition_change_privilege(uint32_t privileged); |
| 417 | |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 418 | #endif /*__SPM_API_H__ */ |