xref: /optee_os/lib/libutee/include/user_ta_header.h (revision bc879b1765afacd8a2b7673236037181011cabea)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  * Copyright (c) 2018, Linaro Limited.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef USER_TA_HEADER_H
30 #define USER_TA_HEADER_H
31 
32 #include <tee_api_types.h>
33 #include <util.h>
34 
35 #define TA_FLAG_SINGLE_INSTANCE		(1 << 2)
36 #define TA_FLAG_MULTI_SESSION		(1 << 3)
37 #define TA_FLAG_INSTANCE_KEEP_ALIVE	(1 << 4) /* remains after last close */
38 #define TA_FLAG_SECURE_DATA_PATH	(1 << 5) /* accesses SDP memory */
39 #define TA_FLAG_REMAP_SUPPORT		(1 << 6) /* use map/unmap syscalls */
40 #define TA_FLAG_CACHE_MAINTENANCE	(1 << 7) /* use cache flush syscall */
41 	/*
42 	 * TA instance can execute multiple sessions concurrently
43 	 * (pseudo-TAs only).
44 	 */
45 #define TA_FLAG_CONCURRENT		(1 << 8)
46 
47 #define TA_FLAGS_MASK			GENMASK_32(8, 2)
48 
49 /* Deprecated macros that will be removed in the 3.2 release */
50 #define TA_FLAG_USER_MODE		0
51 #define TA_FLAG_EXEC_DDR		0
52 
53 union ta_head_func_ptr {
54 	uint64_t ptr64;
55 	struct ta_head_func_ptr32 {
56 		uint32_t lo;
57 		uint32_t hi;
58 	} ptr32;
59 };
60 
61 struct ta_head {
62 	TEE_UUID uuid;
63 	uint32_t stack_size;
64 	uint32_t flags;
65 	union ta_head_func_ptr entry;
66 };
67 
68 #define TA_PROP_STR_SINGLE_INSTANCE	"gpd.ta.singleInstance"
69 #define TA_PROP_STR_MULTI_SESSION	"gpd.ta.multiSession"
70 #define TA_PROP_STR_KEEP_ALIVE		"gpd.ta.instanceKeepAlive"
71 #define TA_PROP_STR_DATA_SIZE		"gpd.ta.dataSize"
72 #define TA_PROP_STR_STACK_SIZE		"gpd.ta.stackSize"
73 #define TA_PROP_STR_VERSION		"gpd.ta.version"
74 #define TA_PROP_STR_DESCRIPTION		"gpd.ta.description"
75 #define TA_PROP_STR_UNSAFE_PARAM	"op-tee.unsafe_param"
76 #define TA_PROP_STR_REMAP		"op-tee.remap"
77 #define TA_PROP_STR_CACHE_SYNC		"op-tee.cache_sync"
78 
79 enum user_ta_prop_type {
80 	USER_TA_PROP_TYPE_BOOL,	/* bool */
81 	USER_TA_PROP_TYPE_U32,	/* uint32_t */
82 	USER_TA_PROP_TYPE_UUID,	/* TEE_UUID */
83 	USER_TA_PROP_TYPE_IDENTITY,	/* TEE_Identity */
84 	USER_TA_PROP_TYPE_STRING,	/* zero terminated string of char */
85 	USER_TA_PROP_TYPE_BINARY_BLOCK,	/* zero terminated base64 coded string */
86 };
87 
88 enum user_ta_core_service_id {
89 	USER_TA_CORE_ENTRY_MATH_INIT = 0x00000010,
90 	USER_TA_CORE_ENTRY_GARBAGE = 0x00000011,
91 	USER_TA_CORE_ENTRY_CLOSESESSION = 0x00000012,
92 };
93 
94 struct user_ta_property {
95 	const char *name;
96 	enum user_ta_prop_type type;
97 	const void *value;
98 };
99 
100 extern const struct user_ta_property ta_props[];
101 extern const size_t ta_num_props;
102 
103 /* Needed by TEE_CheckMemoryAccessRights() */
104 extern uint32_t ta_param_types;
105 extern TEE_Param ta_params[TEE_NUM_PARAMS];
106 
107 /* Trusted Application Function header */
108 typedef struct ta_func_head {
109 	uint32_t cmd_id;	/* Trusted Application Function ID */
110 	uint32_t start;		/* offset to start func */
111 } ta_func_head_t;
112 
113 int tahead_get_trace_level(void);
114 
115 #endif /* USER_TA_HEADER_H */
116