xref: /optee_os/core/include/kernel/tee_ta_manager.h (revision 9403c583381528e7fb391e3769644cc9653cfbb6)
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 
28 #ifndef TEE_TA_MANAGER_H
29 #define TEE_TA_MANAGER_H
30 
31 #include <tee_api_types.h>
32 #include <utee_types.h>
33 #include <kernel/tee_common.h>
34 #include <kernel/tee_ta_manager_unpg.h>
35 
36 /* Magic TEE identity pointer: set when teecore requests a TA close */
37 #define KERN_IDENTITY	((TEE_Identity *)-1)
38 /* Operation is initiated by a client (non-secure) app */
39 #define NSAPP_IDENTITY	(NULL)
40 
41 TEE_Result tee_ta_open_session(TEE_ErrorOrigin *err,
42 			       struct tee_ta_session **sess,
43 			       struct tee_ta_session_head *open_sessions,
44 			       const TEE_UUID *uuid,
45 			       const TEE_Identity *clnt_id,
46 			       uint32_t cancel_req_to,
47 			       struct tee_ta_param *param);
48 
49 TEE_Result tee_ta_invoke_command(TEE_ErrorOrigin *err,
50 				 struct tee_ta_session *sess,
51 				 const TEE_Identity *clnt_id,
52 				 uint32_t cancel_req_to, uint32_t cmd,
53 				 struct tee_ta_param *param);
54 
55 TEE_Result tee_ta_cancel_command(TEE_ErrorOrigin *err,
56 				 struct tee_ta_session *sess,
57 				 const TEE_Identity *clnt_id);
58 
59 /*-----------------------------------------------------------------------------
60  * Function called to close a TA.
61  * Parameters:
62  * id   - The session id (in)
63  * Returns:
64  *        TEE_Result
65  *---------------------------------------------------------------------------*/
66 TEE_Result tee_ta_close_session(struct tee_ta_session *sess,
67 				struct tee_ta_session_head *open_sessions,
68 				const TEE_Identity *clnt_id);
69 
70 TEE_Result tee_ta_get_current_session(struct tee_ta_session **sess);
71 
72 void tee_ta_set_current_session(struct tee_ta_session *sess);
73 
74 TEE_Result tee_ta_get_client_id(TEE_Identity *id);
75 
76 struct tee_ta_session *tee_ta_get_session(uint32_t id, bool exclusive,
77 			struct tee_ta_session_head *open_sessions);
78 
79 void tee_ta_put_session(struct tee_ta_session *sess);
80 
81 int tee_ta_set_trace_level(int level);
82 void tee_ta_dump_current(void);
83 void tee_ta_dump_all(void);
84 
85 #ifdef CFG_CACHE_API
86 TEE_Result tee_uta_cache_operation(struct tee_ta_session *s,
87 				   enum utee_cache_operation op,
88 				   void *va, size_t len);
89 #endif
90 
91 #endif
92