xref: /optee_os/lib/libutee/include/user_ta_header.h (revision a50cb361d9e5735f197ccc87beb0d24af8315369)
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 USER_TA_HEADER_H
29 #define USER_TA_HEADER_H
30 
31 #include <tee_api_types.h>
32 
33 
34 #define TA_FLAG_USER_MODE		(1 << 0)
35 #define TA_FLAG_EXEC_DDR		(1 << 1)
36 #define TA_FLAG_SINGLE_INSTANCE		(1 << 2)
37 #define TA_FLAG_MULTI_SESSION		(1 << 3)
38 #define TA_FLAG_INSTANCE_KEEP_ALIVE	(1 << 4) /* remains after last close */
39 /*
40  * TA_FLAG_UNSAFE_NW_PARAMS: May manipulate some secure memory based on
41  * physical pointers from non-secure world
42  */
43 #define TA_FLAG_UNSAFE_NW_PARAMS	(1 << 5)
44 #define TA_FLAG_REMAP_SUPPORT		(1 << 6) /* use map/unmap syscalls */
45 #define TA_FLAG_CACHE_MAINTENANCE	(1 << 7) /* use cache flush syscall */
46 
47 union ta_head_func_ptr {
48 	uint64_t ptr64;
49 	struct ta_head_func_ptr32 {
50 		uint32_t lo;
51 		uint32_t hi;
52 	} ptr32;
53 };
54 
55 struct ta_head {
56 	TEE_UUID uuid;
57 	uint32_t stack_size;
58 	uint32_t flags;
59 	union ta_head_func_ptr entry;
60 };
61 
62 #define TA_PROP_STR_SINGLE_INSTANCE	"gpd.ta.singleInstance"
63 #define TA_PROP_STR_MULTI_SESSION	"gpd.ta.multiSession"
64 #define TA_PROP_STR_KEEP_ALIVE		"gpd.ta.instanceKeepAlive"
65 #define TA_PROP_STR_DATA_SIZE		"gpd.ta.dataSize"
66 #define TA_PROP_STR_STACK_SIZE		"gpd.ta.stackSize"
67 #define TA_PROP_STR_VERSION		"gpd.ta.version"
68 #define TA_PROP_STR_DESCRIPTION		"gpd.ta.description"
69 #define TA_PROP_STR_UNSAFE_PARAM	"op-tee.unsafe_param"
70 #define TA_PROP_STR_REMAP		"op-tee.remap"
71 #define TA_PROP_STR_CACHE_SYNC		"op-tee.cache_sync"
72 
73 enum user_ta_prop_type {
74 	USER_TA_PROP_TYPE_BOOL,	/* bool */
75 	USER_TA_PROP_TYPE_U32,	/* uint32_t */
76 	USER_TA_PROP_TYPE_UUID,	/* TEE_UUID */
77 	USER_TA_PROP_TYPE_IDENTITY,	/* TEE_Identity */
78 	USER_TA_PROP_TYPE_STRING,	/* zero terminated string of char */
79 	USER_TA_PROP_TYPE_BINARY_BLOCK,	/* zero terminated base64 coded string */
80 };
81 
82 enum user_ta_core_service_id {
83 	USER_TA_CORE_ENTRY_MATH_INIT = 0x00000010,
84 	USER_TA_CORE_ENTRY_GARBAGE = 0x00000011,
85 	USER_TA_CORE_ENTRY_CLOSESESSION = 0x00000012,
86 };
87 
88 struct user_ta_property {
89 	const char *name;
90 	enum user_ta_prop_type type;
91 	const void *value;
92 };
93 
94 extern const struct user_ta_property ta_props[];
95 extern const size_t ta_num_props;
96 
97 /* Needed by TEE_CheckMemoryAccessRights() */
98 extern uint32_t ta_param_types;
99 extern TEE_Param ta_params[4];
100 
101 /* Trusted Application Function header */
102 typedef struct ta_func_head {
103 	uint32_t cmd_id;	/* Trusted Application Function ID */
104 	uint32_t start;		/* offset to start func */
105 } ta_func_head_t;
106 
107 int tahead_get_trace_level(void);
108 
109 #endif /* USER_TA_HEADER_H */
110