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