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_1_2_regs *args,
19 struct sp_session *caller_sp);
20 bool ffa_mem_reclaim(struct thread_smc_1_2_regs *args,
21 struct sp_session *caller_sp);
22
23 #ifdef CFG_SECURE_PARTITION
24 int spmc_sp_start_thread(struct thread_smc_1_2_regs *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, uint16_t thread_id);
30 #else
31 static inline int
spmc_sp_start_thread(struct thread_smc_1_2_regs * args __unused)32 spmc_sp_start_thread(struct thread_smc_1_2_regs *args __unused)
33 {
34 return FFA_INVALID_PARAMETERS;
35 }
36
37 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)38 spmc_sp_add_share(struct ffa_mem_transaction_x *mem_trans __unused,
39 struct ffa_rxtx *rxtx __unused, size_t blen __unused,
40 size_t flen __unused, uint64_t *global_handle __unused,
41 struct sp_session *owner_sp __unused)
42 {
43 return FFA_NOT_SUPPORTED;
44 }
45
spmc_sp_set_to_preempted(struct ts_session * ts_sess __unused)46 static inline void spmc_sp_set_to_preempted(struct ts_session *ts_sess __unused)
47 {
48 }
49
spmc_sp_resume_from_preempted(uint16_t endpoint_id __unused,uint16_t thread_id __unused)50 static inline int spmc_sp_resume_from_preempted(uint16_t endpoint_id __unused,
51 uint16_t thread_id __unused)
52 {
53 return FFA_NOT_SUPPORTED;
54 }
55 #endif
56
57 #endif /* __KERNEL_SPMC_SP_HANDLER_H */
58