import old mobicore
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos7580.git] / mobicore / daemon / ClientLib / public / GP / tee_client_api.h
1 /*
2 * Copyright (c) 2013 TRUSTONIC LIMITED
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
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * This header file corresponds to V1.0 of the GlobalPlatform
34 * TEE Client API Specification
35 */
36 #ifndef __TEE_CLIENT_API_H__
37 #define __TEE_CLIENT_API_H__
38
39 #include "tee_type.h"
40 #include "tee_error.h"
41
42 #if TBASE_API_LEVEL >= 3
43
44 #if (!defined(TEEC_EXPORT)) && __cplusplus
45 #define TEEC_EXPORT extern "C"
46 #else
47 #define TEEC_EXPORT
48 #endif // __cplusplus
49
50
51
52 /* The header tee_client_api_imp.h must define implementation-dependent
53 types, constants and macros.
54
55 The implementation-dependent types are:
56 - TEEC_Context_IMP
57 - TEEC_Session_IMP
58 - TEEC_SharedMemory_IMP
59 - TEEC_Operation_IMP
60
61 The implementation-dependent constants are:
62 - TEEC_CONFIG_SHAREDMEM_MAX_SIZE
63 The implementation-dependent macros are:
64 - TEEC_PARAM_TYPES
65 */
66
67 typedef struct {
68 uint32_t a;
69 uint32_t b;
70 } TEEC_Value;
71
72
73 #include "tee_client_api_imp.h"
74
75 /* Type definitions */
76 typedef struct TEEC_Context {
77 TEEC_Context_IMP imp;
78 } TEEC_Context;
79
80 typedef struct TEEC_Session {
81 TEEC_Session_IMP imp;
82 } TEEC_Session;
83
84 typedef struct TEEC_SharedMemory {
85 void *buffer;
86 size_t size;
87 uint32_t flags;
88 TEEC_SharedMemory_IMP imp;
89 } TEEC_SharedMemory;
90
91 typedef struct {
92 void *buffer;
93 size_t size;
94 } TEEC_TempMemoryReference;
95
96 typedef struct {
97 TEEC_SharedMemory *parent;
98 size_t size;
99 size_t offset;
100 } TEEC_RegisteredMemoryReference;
101
102
103
104 typedef union {
105 TEEC_TempMemoryReference tmpref;
106 TEEC_RegisteredMemoryReference memref;
107 TEEC_Value value;
108 } TEEC_Parameter;
109
110 typedef struct TEEC_Operation {
111 volatile uint32_t started;
112 uint32_t paramTypes;
113 TEEC_Parameter params[4];
114 TEEC_Operation_IMP imp;
115 } TEEC_Operation;
116
117
118 #define TEEC_ORIGIN_API 0x00000001
119 #define TEEC_ORIGIN_COMMS 0x00000002
120 #define TEEC_ORIGIN_TEE 0x00000003
121 #define TEEC_ORIGIN_TRUSTED_APP 0x00000004
122
123 #define TEEC_MEM_INPUT 0x00000001
124 #define TEEC_MEM_OUTPUT 0x00000002
125
126 #define TEEC_NONE 0x0
127 #define TEEC_VALUE_INPUT 0x1
128 #define TEEC_VALUE_OUTPUT 0x2
129 #define TEEC_VALUE_INOUT 0x3
130 #define TEEC_MEMREF_TEMP_INPUT 0x5
131 #define TEEC_MEMREF_TEMP_OUTPUT 0x6
132 #define TEEC_MEMREF_TEMP_INOUT 0x7
133 #define TEEC_MEMREF_WHOLE 0xC
134 #define TEEC_MEMREF_PARTIAL_INPUT 0xD
135 #define TEEC_MEMREF_PARTIAL_OUTPUT 0xE
136 #define TEEC_MEMREF_PARTIAL_INOUT 0xF
137
138 #define TEEC_LOGIN_PUBLIC 0x00000000
139 #define TEEC_LOGIN_USER 0x00000001
140 #define TEEC_LOGIN_GROUP 0x00000002
141 #define TEEC_LOGIN_APPLICATION 0x00000004
142 #define TEEC_LOGIN_USER_APPLICATION 0x00000005
143 #define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
144
145 #pragma GCC visibility push(default)
146
147 TEEC_EXPORT TEEC_Result TEEC_InitializeContext(
148 const char *name,
149 TEEC_Context *context);
150
151 TEEC_EXPORT void TEEC_FinalizeContext(
152 TEEC_Context *context);
153
154 TEEC_EXPORT TEEC_Result TEEC_RegisterSharedMemory(
155 TEEC_Context *context,
156 TEEC_SharedMemory *sharedMem);
157
158 TEEC_EXPORT TEEC_Result TEEC_AllocateSharedMemory(
159 TEEC_Context *context,
160 TEEC_SharedMemory *sharedMem);
161
162 TEEC_EXPORT void TEEC_ReleaseSharedMemory (
163 TEEC_SharedMemory *sharedMem);
164
165 TEEC_EXPORT TEEC_Result TEEC_OpenSession (
166 TEEC_Context *context,
167 TEEC_Session *session,
168 const TEEC_UUID *destination,
169 uint32_t connectionMethod,
170 void *connectionData,
171 TEEC_Operation *operation,
172 uint32_t *returnOrigin);
173
174 TEEC_EXPORT void TEEC_CloseSession (
175 TEEC_Session *session);
176
177 TEEC_EXPORT TEEC_Result TEEC_InvokeCommand(
178 TEEC_Session *session,
179 uint32_t commandID,
180 TEEC_Operation *operation,
181 uint32_t *returnOrigin);
182
183 TEEC_EXPORT void TEEC_RequestCancellation(
184 TEEC_Operation *operation);
185
186 #pragma GCC visibility pop
187
188 #endif /* TBASE_API_LEVEL */
189
190 #endif /* __TEE_CLIENT_API_H__ */