1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2021, Arm Limited.
4  */
5 #ifndef __KERNEL_SPMC_SP_HANDLER_H
6 #define __KERNEL_SPMC_SP_HANDLER_H
7 
8 #include <assert.h>
9 #include <kernel/secure_partition.h>
10 #include <kernel/user_mode_ctx_struct.h>
11 #include <tee_api_types.h>
12 #include <tee/entry_std.h>
13 
14 #define FFA_DST(x)	((x) & UINT16_MAX)
15 #define FFA_SRC(x)	(((x) >> 16) & UINT16_MAX)
16 
17 void spmc_sp_thread_entry(uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3);
18 void spmc_sp_msg_handler(struct thread_smc_args *args,
19 			 struct sp_session *caller_sp);
20 bool ffa_mem_reclaim(struct thread_smc_args *args,
21 		     struct sp_session *caller_sp);
22 
23 #ifdef CFG_SECURE_PARTITION
24 void spmc_sp_start_thread(struct thread_smc_args *args);
25 int spmc_sp_add_share(struct ffa_mem_transaction_x *mem_trans,
26 		      struct ffa_rxtx *rxtx, size_t blen, size_t flen,
27 		      uint64_t *global_handle, struct sp_session *owner_sp);
28 void spmc_sp_set_to_preempted(struct ts_session *ts_sess);
29 int spmc_sp_resume_from_preempted(uint16_t endpoint_id);
30 #else
spmc_sp_start_thread(struct thread_smc_args * args __unused)31 static inline void spmc_sp_start_thread(struct thread_smc_args *args __unused)
32 {
33 }
34 
35 static inline int
spmc_sp_add_share(struct ffa_mem_transaction_x * mem_trans __unused,struct ffa_rxtx * rxtx __unused,size_t blen __unused,size_t flen __unused,uint64_t * global_handle __unused,struct sp_session * owner_sp __unused)36 spmc_sp_add_share(struct ffa_mem_transaction_x *mem_trans __unused,
37 		  struct ffa_rxtx *rxtx __unused, size_t blen __unused,
38 		  size_t flen __unused, uint64_t *global_handle __unused,
39 		  struct sp_session *owner_sp __unused)
40 {
41 	return FFA_NOT_SUPPORTED;
42 }
43 
spmc_sp_set_to_preempted(struct ts_session * ts_sess __unused)44 static inline void spmc_sp_set_to_preempted(struct ts_session *ts_sess __unused)
45 {
46 }
47 
spmc_sp_resume_from_preempted(uint16_t endpoint_id __unused)48 static inline int spmc_sp_resume_from_preempted(uint16_t endpoint_id __unused)
49 {
50 	return FFA_NOT_SUPPORTED;
51 }
52 #endif
53 
54 #endif /* __KERNEL_SPMC_SP_HANDLER_H */
55