xref: /optee_os/core/include/tee/tee_svc.h (revision 4e77495e8caa9fd9d05e28ef675fb64f8fcdedec)
1 /*
2  * Copyright (c) 2014, STMicroelectronics International N.V.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef TEE_SVC_H
28 #define TEE_SVC_H
29 
30 #include <stdint.h>
31 #include <kernel/tee_common_unpg.h>	/* tee_uaddr_t */
32 #include <tee_api_types.h>
33 #include <tee_api_types.h>
34 #include <utee_types.h>
35 #include <tee_trace.h>
36 
37 struct tee_ta_session;
38 
39 void tee_svc_user_ta_panic_from_pager(void);
40 
41 /*
42  * This function will not return itself, rather it will end with a system
43  * call to return to kernel mode. The syscall will unwinde the stack and
44  * the result will be as if this function had returned.
45  *
46  * User_func is called in user mode with stack setup and a0-a3 passed
47  * in r0-r3.
48  */
49 TEE_Result tee_svc_enter_user_mode(uint32_t a0, uint32_t a1, uint32_t a2,
50 				   uint32_t a3, tee_uaddr_t sp,
51 				   tee_uaddr_t user_func, uint32_t *panicked,
52 				   uint32_t *panic_code);
53 
54 void tee_svc_sys_return(uint32_t ret, uint32_t param_types, void *params);
55 
56 void tee_svc_sys_log(const void *buf, size_t len);
57 
58 void tee_svc_sys_panic(uint32_t code);
59 
60 TEE_Result tee_svc_reserved(void);
61 
62 uint32_t tee_svc_sys_dummy(uint32_t *a);
63 uint32_t tee_svc_sys_dummy_7args(uint32_t a1, uint32_t a2, uint32_t a3,
64 				 uint32_t a4, uint32_t a5, uint32_t a6,
65 				 uint32_t a7);
66 
67 uint32_t tee_svc_sys_nocall(void);
68 
69 TEE_Result tee_svc_sys_get_property(uint32_t prop, tee_uaddr_t buf,
70 				    size_t blen);
71 
72 TEE_Result tee_svc_open_ta_session(const TEE_UUID *dest,
73 				   uint32_t cancel_req_to, uint32_t param_types,
74 				   TEE_Param params[4],
75 				   TEE_TASessionHandle *sess,
76 				   uint32_t *ret_orig);
77 
78 TEE_Result tee_svc_close_ta_session(TEE_TASessionHandle sess);
79 
80 TEE_Result tee_svc_invoke_ta_command(TEE_TASessionHandle sess,
81 				     uint32_t cancel_req_to, uint32_t cmd_id,
82 				     uint32_t param_types, TEE_Param params[4],
83 				     uint32_t *ret_orig);
84 
85 TEE_Result tee_svc_check_access_rights(uint32_t flags, const void *buf,
86 				       size_t len);
87 
88 TEE_Result tee_svc_copy_from_user(struct tee_ta_session *sess, void *kaddr,
89 				  const void *uaddr, size_t len);
90 TEE_Result tee_svc_copy_to_user(struct tee_ta_session *sess, void *uaddr,
91 				const void *kaddr, size_t len);
92 
93 TEE_Result tee_svc_get_cancellation_flag(bool *cancel);
94 
95 TEE_Result tee_svc_unmask_cancellation(bool *old_mask);
96 
97 TEE_Result tee_svc_mask_cancellation(bool *old_mask);
98 
99 TEE_Result tee_svc_wait(uint32_t timeout);
100 
101 TEE_Result tee_svc_get_time(enum utee_time_category cat, TEE_Time *time);
102 TEE_Result tee_svc_set_ta_time(const TEE_Time *time);
103 
104 #endif /* TEE_SVC_H */
105