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