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