blob: 06bd81a866434e4a5e4da2d8590e04dda37cff62 [file] [log] [blame]
Miklos Balint386b8b52017-11-29 13:12:32 +00001/*
Mingyang Sun7397b4f2020-06-17 15:07:45 +08002 * Copyright (c) 2020, Arm Limited. All rights reserved.
Miklos Balint386b8b52017-11-29 13:12:32 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Mingyang Sun7397b4f2020-06-17 15:07:45 +08008#ifndef __SPM_IPC_H__
9#define __SPM_IPC_H__
Miklos Balint386b8b52017-11-29 13:12:32 +000010
Mingyang Sun7397b4f2020-06-17 15:07:45 +080011#include <stdint.h>
Mingyang Sun37f6ced2020-07-08 16:30:28 +080012#include "spm_partition_defs.h"
Mingyang Sun7397b4f2020-06-17 15:07:45 +080013#include "tfm_arch.h"
Edison Ai66fbdf12019-07-08 16:05:07 +080014#include "tfm_list.h"
15#include "tfm_wait.h"
Mingyang Sunf3d29892019-07-10 17:50:23 +080016#include "tfm_secure_api.h"
Summer Qinb5da9cc2019-08-26 15:19:45 +080017#include "tfm_thread.h"
Mingyang Sun7397b4f2020-06-17 15:07:45 +080018#include "psa/service.h"
19
20#define TFM_VERSION_POLICY_RELAXED 0
21#define TFM_VERSION_POLICY_STRICT 1
22
23#define TFM_HANDLE_STATUS_IDLE 0
24#define TFM_HANDLE_STATUS_ACTIVE 1
25#define TFM_HANDLE_STATUS_CONNECT_ERROR 2
26
Mingyang Sun37f6ced2020-07-08 16:30:28 +080027#define PART_REGION_ADDR(partition, region) \
28 (uint32_t)&REGION_NAME(Image$$, partition, region)
29
Mingyang Sun7397b4f2020-06-17 15:07:45 +080030#define TFM_CONN_HANDLE_MAX_NUM 16
Miklos Balint386b8b52017-11-29 13:12:32 +000031
Mate Toth-Pal52674ab2018-02-26 09:47:56 +010032#define SPM_INVALID_PARTITION_IDX (~0U)
33
Summer Qineb537e52019-03-29 09:57:10 +080034/* Privileged definitions for partition thread mode */
Summer Qineb537e52019-03-29 09:57:10 +080035#define TFM_PARTITION_UNPRIVILEGED_MODE 0
Mingyang Sun7397b4f2020-06-17 15:07:45 +080036#define TFM_PARTITION_PRIVILEGED_MODE 1
37
38#define SPM_PART_FLAG_APP_ROT 0x01
39#define SPM_PART_FLAG_PSA_ROT 0x02
40#define SPM_PART_FLAG_IPC 0x04
Summer Qineb537e52019-03-29 09:57:10 +080041
Mingyang Sun37f6ced2020-07-08 16:30:28 +080042#define TFM_PRIORITY_HIGH THRD_PRIOR_HIGHEST
43#define TFM_PRIORITY_NORMAL THRD_PRIOR_MEDIUM
44#define TFM_PRIORITY_LOW THRD_PRIOR_LOWEST
45#define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL
46
Mingyang Sun73056b62020-07-03 15:18:46 +080047#define TFM_MSG_MAGIC 0x15154343
48
Miklos Balint386b8b52017-11-29 13:12:32 +000049enum spm_err_t {
50 SPM_ERR_OK = 0,
Mate Toth-Pal349714a2018-02-23 15:30:24 +010051 SPM_ERR_PARTITION_DB_NOT_INIT,
52 SPM_ERR_PARTITION_ALREADY_ACTIVE,
53 SPM_ERR_PARTITION_NOT_AVAILABLE,
Hugues de Valonf704c802019-02-19 14:51:41 +000054 SPM_ERR_INVALID_PARAMETER,
Miklos Balint386b8b52017-11-29 13:12:32 +000055 SPM_ERR_INVALID_CONFIG,
56};
57
Mingyang Sun73056b62020-07-03 15:18:46 +080058/* Message struct to collect parameter from client */
59struct tfm_msg_body_t {
60 int32_t magic;
61 struct tfm_spm_service_t *service; /* RoT service pointer */
62 struct tfm_event_t ack_evnt; /* Event for ack reponse */
63 psa_msg_t msg; /* PSA message body */
64 psa_invec invec[PSA_MAX_IOVEC]; /* Put in/out vectors in msg body */
65 psa_outvec outvec[PSA_MAX_IOVEC];
66 psa_outvec *caller_outvec; /*
67 * Save caller outvec pointer for
68 * write length update
69 */
70#ifdef TFM_MULTI_CORE_TOPOLOGY
71 const void *caller_data; /*
72 * Pointer to the private data of the
73 * caller. It identifies the NSPE PSA
74 * client calls in multi-core topology
75 */
76#endif
77 struct tfm_list_node_t msg_node; /* For list operators */
78};
79
Mate Toth-Pal3db437a2018-06-22 16:15:13 +020080/**
Mingyang Sun37f6ced2020-07-08 16:30:28 +080081 * Holds the fields of the partition DB used by the SPM code. The values of
82 * these fields are calculated at compile time, and set during initialisation
83 * phase.
84 */
Mingyang Sunae70d8d2020-06-30 15:56:05 +080085struct partition_static_t {
Mingyang Sun37f6ced2020-07-08 16:30:28 +080086 uint32_t psa_framework_version;
87 uint32_t partition_id;
88 uint32_t partition_flags;
89 uint32_t partition_priority;
90 sp_entry_point partition_init;
Mingyang Sunae70d8d2020-06-30 15:56:05 +080091 uintptr_t stack_base;
92 size_t stack_size;
93 uintptr_t heap_base;
94 size_t heap_size;
Mingyang Sun37f6ced2020-07-08 16:30:28 +080095 uint32_t dependencies_num;
Mingyang Sunae70d8d2020-06-30 15:56:05 +080096 uint32_t *p_dependencies;
Mingyang Sun37f6ced2020-07-08 16:30:28 +080097};
98
99/**
100 * Holds the fields that define a partition for SPM. The fields are further
101 * divided to structures, to keep the related fields close to each other.
102 */
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800103struct partition_t {
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800104 const struct partition_static_t *static_data;
105 void *p_platform;
106 void *p_interrupts;
107 void *p_metadata;
Mingyang Sunaf22ffa2020-07-09 17:48:37 +0800108 struct tfm_core_thread_t sp_thread;
109 struct tfm_event_t event;
110 struct tfm_list_node_t msg_list;
111 uint32_t signals_allowed;
112 uint32_t signals_waiting;
113 uint32_t signals_asserted;
Mingyang Sun37f6ced2020-07-08 16:30:28 +0800114 /** A list of platform_data pointers */
115 const struct tfm_spm_partition_platform_data_t **platform_data_list;
116 const struct tfm_spm_partition_memory_data_t *memory_data;
117};
118
119struct spm_partition_db_t {
120 uint32_t is_init;
121 uint32_t partition_count;
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800122 struct partition_t *partitions;
Mingyang Sun37f6ced2020-07-08 16:30:28 +0800123};
124
Mingyang Sunda01a972019-07-12 17:32:59 +0800125/* Service database defined by manifest */
126struct tfm_spm_service_db_t {
127 char *name; /* Service name */
128 uint32_t partition_id; /* Partition ID which service belong to */
129 psa_signal_t signal; /* Service signal */
130 uint32_t sid; /* Service identifier */
131 bool non_secure_client; /* If can be called by non secure client */
Shawn Shancc39fcb2019-11-13 15:38:16 +0800132 uint32_t version; /* Service version */
133 uint32_t version_policy; /* Service version policy */
Mingyang Sunda01a972019-07-12 17:32:59 +0800134};
135
136/* RoT Service data */
137struct tfm_spm_service_t {
Summer Qine578c5b2019-08-16 16:42:16 +0800138 const struct tfm_spm_service_db_t *service_db;/* Service database pointer */
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800139 struct partition_t *partition; /*
Mingyang Sunda01a972019-07-12 17:32:59 +0800140 * Point to secure partition
141 * data
142 */
143 struct tfm_list_node_t handle_list; /* Service handle list */
Mingyang Sunda01a972019-07-12 17:32:59 +0800144 struct tfm_list_node_t list; /* For list operation */
145};
Summer Qin5fdcf632020-06-22 16:49:24 +0800146
Mingyang Sun7397b4f2020-06-17 15:07:45 +0800147/* RoT connection handle list */
148struct tfm_conn_handle_t {
149 void *rhandle; /* Reverse handle value */
150 uint32_t status; /*
151 * Status of handle, three valid
152 * options:
153 * TFM_HANDLE_STATUS_ACTIVE,
154 * TFM_HANDLE_STATUS_IDLE and
155 * TFM_HANDLE_STATUS_CONNECT_ERROR
156 */
157 int32_t client_id; /*
158 * Partition ID of the sender of the
159 * message:
160 * - secure partition id;
161 * - non secure client endpoint id.
162 */
163 struct tfm_msg_body_t internal_msg; /* Internal message for message queue */
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800164 struct tfm_spm_service_t *service; /* RoT service pointer */
165 struct tfm_list_node_t list; /* list node */
Mingyang Sun7397b4f2020-06-17 15:07:45 +0800166};
167
Summer Qin5fdcf632020-06-22 16:49:24 +0800168enum tfm_memory_access_e {
169 TFM_MEMORY_ACCESS_RO = 1,
170 TFM_MEMORY_ACCESS_RW = 2,
171};
Summer Qinb4a854d2019-05-29 15:31:22 +0800172
173/**
Mingyang Sunda01a972019-07-12 17:32:59 +0800174 * \brief Initialize partition database
175 *
176 * \return Error code \ref spm_err_t
177 */
178enum spm_err_t tfm_spm_db_init(void);
179
180/**
Mate Toth-Pal5e6d0342019-11-22 11:43:20 +0100181 * \brief Get the current partition mode.
182 *
183 * \param[in] partition_flags Flags of current partition
184 *
185 * \retval TFM_PARTITION_PRIVILEGED_MODE Privileged mode
186 * \retval TFM_PARTITION_UNPRIVILEGED_MODE Unprivileged mode
187 */
188uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags);
189
Summer Qin830c5542020-02-14 13:44:20 +0800190/**
191 * \brief Handle an SPM request by a secure service
192 * \param[in] svc_ctx The stacked SVC context
193 */
194void tfm_spm_request_handler(const struct tfm_state_context_t *svc_ctx);
195
Edison Ai7aff9e82019-07-11 14:56:46 +0800196/**
Mingyang Sunf3d29892019-07-10 17:50:23 +0800197 * \brief Get the running partition ID.
198 *
199 * \return Returns the partition ID
200 */
201uint32_t tfm_spm_partition_get_running_partition_id(void);
202
Mingyang Sunf3d29892019-07-10 17:50:23 +0800203/******************** Service handle management functions ********************/
204
205/**
206 * \brief Create connection handle for client connect
207 *
208 * \param[in] service Target service context pointer
Summer Qin1ce712a2019-10-14 18:04:05 +0800209 * \param[in] client_id Partition ID of the sender of the message
Mingyang Sunf3d29892019-07-10 17:50:23 +0800210 *
Summer Qin630c76b2020-05-20 10:32:58 +0800211 * \retval NULL Create failed
212 * \retval "Not NULL" Service handle created
Mingyang Sunf3d29892019-07-10 17:50:23 +0800213 */
Summer Qin630c76b2020-05-20 10:32:58 +0800214struct tfm_conn_handle_t *tfm_spm_create_conn_handle(
215 struct tfm_spm_service_t *service,
Summer Qin1ce712a2019-10-14 18:04:05 +0800216 int32_t client_id);
217
218/**
219 * \brief Validate connection handle for client connect
220 *
221 * \param[in] conn_handle Handle to be validated
222 * \param[in] client_id Partition ID of the sender of the message
223 *
224 * \retval IPC_SUCCESS Success
225 * \retval IPC_ERROR_GENERIC Invalid handle
226 */
Summer Qin630c76b2020-05-20 10:32:58 +0800227int32_t tfm_spm_validate_conn_handle(
228 const struct tfm_conn_handle_t *conn_handle,
229 int32_t client_id);
Mingyang Sunf3d29892019-07-10 17:50:23 +0800230
Summer Qin02f7f072020-08-24 16:02:54 +0800231/**
232 * \brief Free connection handle which not used anymore.
233 *
234 * \param[in] service Target service context pointer
235 * \param[in] conn_handle Connection handle created by
236 * tfm_spm_create_conn_handle()
237 *
238 * \retval IPC_SUCCESS Success
239 * \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
240 * \retval "Does not return" Panic for not find service by handle
241 */
242int32_t tfm_spm_free_conn_handle(struct tfm_spm_service_t *service,
243 struct tfm_conn_handle_t *conn_handle);
244
Mingyang Sunf3d29892019-07-10 17:50:23 +0800245/******************** Partition management functions *************************/
246
247/**
Summer Qin02f7f072020-08-24 16:02:54 +0800248 * \brief Get the msg context by signal.
249 *
250 * \param[in] partition Partition context pointer
251 * \ref partition_t structures
252 * \param[in] signal Signal associated with inputs to the Secure
253 * Partition, \ref psa_signal_t
254 *
255 * \retval NULL Failed
256 * \retval "Not NULL" Target service context pointer,
257 * \ref tfm_msg_body_t structures
258 */
259struct tfm_msg_body_t *tfm_spm_get_msg_by_signal(struct partition_t *partition,
260 psa_signal_t signal);
261
262/**
Mingyang Sunf3d29892019-07-10 17:50:23 +0800263 * \brief Get current running partition context.
264 *
265 * \retval NULL Failed
266 * \retval "Not NULL" Return the parttion context pointer
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800267 * \ref partition_t structures
Mingyang Sunf3d29892019-07-10 17:50:23 +0800268 */
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800269struct partition_t *tfm_spm_get_running_partition(void);
Mingyang Sunf3d29892019-07-10 17:50:23 +0800270
271/**
Mingyang Sunf3d29892019-07-10 17:50:23 +0800272 * \brief Get the service context by service ID.
273 *
274 * \param[in] sid RoT Service identity
275 *
276 * \retval NULL Failed
277 * \retval "Not NULL" Target service context pointer,
278 * \ref tfm_spm_service_t structures
279 */
280struct tfm_spm_service_t *tfm_spm_get_service_by_sid(uint32_t sid);
281
Mingyang Sunf3d29892019-07-10 17:50:23 +0800282/************************ Message functions **********************************/
283
284/**
Summer Qin02f7f072020-08-24 16:02:54 +0800285 * \brief Get message context by message handle.
286 *
287 * \param[in] msg_handle Message handle which is a reference generated
288 * by the SPM to a specific message.
289 *
290 * \return The message body context pointer
291 * \ref tfm_msg_body_t structures
292 */
293struct tfm_msg_body_t *tfm_spm_get_msg_from_handle(psa_handle_t msg_handle);
294
295/**
Edison Ai97115822019-08-01 14:22:19 +0800296 * \brief Get message context by connect handle.
Mingyang Sunf3d29892019-07-10 17:50:23 +0800297 *
Edison Ai97115822019-08-01 14:22:19 +0800298 * \param[in] conn_handle Service connect handle.
299 *
300 * \return The message body context pointer
301 * \ref msg_body_t structures
302 */
303struct tfm_msg_body_t *
Summer Qin630c76b2020-05-20 10:32:58 +0800304 tfm_spm_get_msg_buffer_from_conn_handle(struct tfm_conn_handle_t *conn_handle);
Edison Ai97115822019-08-01 14:22:19 +0800305
306/**
307 * \brief Fill the message for PSA client call.
308 *
309 * \param[in] msg Service Message Queue buffer pointer
Mingyang Sunf3d29892019-07-10 17:50:23 +0800310 * \param[in] service Target service context pointer, which can be
311 * obtained by partition management functions
312 * \prarm[in] handle Connect handle return by psa_connect().
313 * \param[in] type Message type, PSA_IPC_CONNECT, PSA_IPC_CALL or
314 * PSA_IPC_DISCONNECT
Summer Qin1ce712a2019-10-14 18:04:05 +0800315 * \param[in] client_id Partition ID of the sender of the message
Mingyang Sunf3d29892019-07-10 17:50:23 +0800316 * \param[in] invec Array of input \ref psa_invec structures
317 * \param[in] in_len Number of input \ref psa_invec structures
318 * \param[in] outvec Array of output \ref psa_outvec structures
319 * \param[in] out_len Number of output \ref psa_outvec structures
320 * \param[in] caller_outvec Array of caller output \ref psa_outvec structures
Mingyang Sunf3d29892019-07-10 17:50:23 +0800321 */
Edison Ai97115822019-08-01 14:22:19 +0800322void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
323 struct tfm_spm_service_t *service,
Ken Liu505b1702020-05-29 13:19:58 +0800324 psa_handle_t handle,
Summer Qin1ce712a2019-10-14 18:04:05 +0800325 int32_t type, int32_t client_id,
Edison Ai97115822019-08-01 14:22:19 +0800326 psa_invec *invec, size_t in_len,
327 psa_outvec *outvec, size_t out_len,
328 psa_outvec *caller_outvec);
Mingyang Sunf3d29892019-07-10 17:50:23 +0800329
330/**
331 * \brief Send message and wake up the SP who is waiting on
332 * message queue, block the current thread and
333 * scheduler triggered
334 *
335 * \param[in] service Target service context pointer, which can be
336 * obtained by partition management functions
337 * \param[in] msg message created by tfm_spm_create_msg()
338 * \ref tfm_msg_body_t structures
339 *
340 * \retval IPC_SUCCESS Success
341 * \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
342 * \retval IPC_ERROR_GENERIC Failed to enqueue message to service message queue
343 */
344int32_t tfm_spm_send_event(struct tfm_spm_service_t *service,
345 struct tfm_msg_body_t *msg);
346
347/**
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +0530348 * \brief Check the client version according to
Mingyang Sunf3d29892019-07-10 17:50:23 +0800349 * version policy
350 *
351 * \param[in] service Target service context pointer, which can be get
352 * by partition management functions
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +0530353 * \param[in] version Client support version
Mingyang Sunf3d29892019-07-10 17:50:23 +0800354 *
355 * \retval IPC_SUCCESS Success
356 * \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
357 * \retval IPC_ERROR_VERSION Check failed
358 */
359int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +0530360 uint32_t version);
Mingyang Sunf3d29892019-07-10 17:50:23 +0800361
362/**
Edison Aie728fbf2019-11-13 09:37:12 +0800363 * \brief Check the client access authorization
364 *
365 * \param[in] sid Target RoT Service identity
366 * \param[in] service Target service context pointer, which can be get
367 * by partition management functions
368 * \param[in] ns_caller Whether from NS caller
369 *
370 * \retval IPC_SUCCESS Success
371 * \retval IPC_ERROR_GENERIC Authorization check failed
372 */
373int32_t tfm_spm_check_authorization(uint32_t sid,
374 struct tfm_spm_service_t *service,
Summer Qin618e8c32019-12-09 10:47:20 +0800375 bool ns_caller);
Edison Aie728fbf2019-11-13 09:37:12 +0800376
377/**
Mingyang Sunf3d29892019-07-10 17:50:23 +0800378 * \brief Check the memory reference is valid.
379 *
380 * \param[in] buffer Pointer of memory reference
381 * \param[in] len Length of memory reference in bytes
382 * \param[in] ns_caller From non-secure caller
383 * \param[in] access Type of access specified by the
384 * \ref tfm_memory_access_e
385 * \param[in] privileged Privileged mode or unprivileged mode:
386 * \ref TFM_PARTITION_UNPRIVILEGED_MODE
387 * \ref TFM_PARTITION_PRIVILEGED_MODE
388 *
389 * \retval IPC_SUCCESS Success
390 * \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
391 * \retval IPC_ERROR_MEMORY_CHECK Check failed
392 */
Summer Qin43c185d2019-10-10 15:44:42 +0800393int32_t tfm_memory_check(const void *buffer, size_t len, bool ns_caller,
Mingyang Sunf3d29892019-07-10 17:50:23 +0800394 enum tfm_memory_access_e access,
395 uint32_t privileged);
396
Mingyang Sunf3d29892019-07-10 17:50:23 +0800397/*
398 * PendSV specified function.
399 *
400 * Parameters :
Summer Qind2ad7e72020-01-06 18:16:35 +0800401 * p_actx - Architecture context storage pointer
Mingyang Sunf3d29892019-07-10 17:50:23 +0800402 *
403 * Notes:
404 * This is a staging API. Scheduler should be called in SPM finally and
405 * this function will be obsoleted later.
406 */
Summer Qind2ad7e72020-01-06 18:16:35 +0800407void tfm_pendsv_do_schedule(struct tfm_arch_ctx_t *p_actx);
Mingyang Sunf3d29892019-07-10 17:50:23 +0800408
Ken Liu490281d2019-12-30 15:55:26 +0800409/**
410 * \brief SPM initialization implementation
411 *
412 * \details This function must be called under handler mode.
Ken Liuce2692d2020-02-11 12:39:36 +0800413 * \retval This function returns an EXC_RETURN value. Other
414 * faults would panic the execution and never
415 * returned.
Ken Liu490281d2019-12-30 15:55:26 +0800416 */
Ken Liuce2692d2020-02-11 12:39:36 +0800417uint32_t tfm_spm_init(void);
Ken Liu490281d2019-12-30 15:55:26 +0800418
Mingyang Sund44522a2020-01-16 16:48:37 +0800419/**
Mingyang Sunc3123ec2020-06-11 17:43:58 +0800420 * \brief SVC handler of enabling irq_line of the specified irq_signal.
Mingyang Sund44522a2020-01-16 16:48:37 +0800421 *
422 * \param[in] args Include all input arguments: irq_signal.
423 *
424 * \retval void Success.
425 * \retval "Does not return" The call is invalid, one or more of the
426 * following are true:
427 * \arg irq_signal is not an interrupt signal.
428 * \arg irq_signal indicates more than one signal.
429 */
430void tfm_spm_enable_irq(uint32_t *args);
431
432/**
Mingyang Sunc3123ec2020-06-11 17:43:58 +0800433 * \brief SVC handler of disabling irq_line of the specified irq_signal.
Mingyang Sund44522a2020-01-16 16:48:37 +0800434 *
435 * \param[in] args Include all input arguments: irq_signal.
436 *
437 * \retval void Success.
438 * \retval "Does not return" The call is invalid, one or more of the
439 * following are true:
440 * \arg irq_signal is not an interrupt signal.
441 * \arg irq_signal indicates more than one signal.
442 */
443void tfm_spm_disable_irq(uint32_t *args);
444
445/**
446 * \brief Validate the whether NS caller re-enter.
447 *
448 * \param[in] p_cur_sp Pointer to current partition.
449 * \param[in] p_ctx Pointer to current stack context.
450 * \param[in] exc_return EXC_RETURN value.
451 * \param[in] ns_caller If 'true', call from non-secure client.
452 * Or from secure client.
453 *
454 * \retval void Success.
455 */
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800456void tfm_spm_validate_caller(struct partition_t *p_cur_sp, uint32_t *p_ctx,
457 uint32_t exc_return, bool ns_caller);
Mingyang Sund44522a2020-01-16 16:48:37 +0800458
459/**
Ken Liu505b1702020-05-29 13:19:58 +0800460 * \brief Converts a handle instance into a corresponded user handle.
461 */
462psa_handle_t tfm_spm_to_user_handle(struct tfm_conn_handle_t *handle_instance);
463
464/**
Summer Qin373feb12020-03-27 15:35:33 +0800465 * \brief Converts a user handle into a corresponded handle instance.
466 */
467struct tfm_conn_handle_t *tfm_spm_to_handle_instance(psa_handle_t user_handle);
468
Summer Qin9c1fba12020-08-12 15:49:12 +0800469/**
470 * \brief Move to handler mode by a SVC for specific purpose
471 */
472void tfm_core_handler_mode(void);
473
Summer Qin02f7f072020-08-24 16:02:54 +0800474/**
475 * \brief Set reverse handle value for connection.
476 *
477 * \param[in] service Target service context pointer
478 * \param[in] conn_handle Connection handle created by
479 * tfm_spm_create_conn_handle()
480 * \param[in] rhandle rhandle need to save
481 *
482 * \retval IPC_SUCCESS Success
483 * \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
484 * \retval "Does not return" Panic for not find handle node
485 */
486int32_t tfm_spm_set_rhandle(struct tfm_spm_service_t *service,
487 struct tfm_conn_handle_t *conn_handle,
488 void *rhandle);
489
490void update_caller_outvec_len(struct tfm_msg_body_t *msg);
491
492/**
493 * \brief notify the partition with the signal.
494 *
495 * \param[in] partition_id The ID of the partition to be notified.
496 * \param[in] signal The signal that the partition is to be notified
497 * with.
498 *
499 * \retval void Success.
500 * \retval "Does not return" If partition_id is invalid.
501 */
502void notify_with_signal(int32_t partition_id, psa_signal_t signal);
503
504/**
505 * \brief Return the IRQ line number associated with a signal
506 *
507 * \param[in] partition_id The ID of the partition in which we look for
508 * the signal.
509 * \param[in] signal The signal we do the query for.
510 * \param[out] irq_line The irq line associated with signal
511 *
512 * \retval IPC_SUCCESS Execution successful, irq_line contains a valid
513 * value.
514 * \retval IPC_ERROR_GENERIC There was an error finding the IRQ line for the
515 * signal. irq_line is unchanged.
516 */
517int32_t get_irq_line_for_signal(int32_t partition_id,
518 psa_signal_t signal,
519 IRQn_Type *irq_line);
520
Mingyang Sun7397b4f2020-06-17 15:07:45 +0800521#endif /* __SPM_IPC_H__ */