2 * =====================================================================================
4 * Filename: tee_client_api.h
6 * Description: TEEC API Header file
9 * Created: Thursday 26 March 2015 12:42:45 IST
13 * Author: CHERYL (cb), cheryl.b@samsung.com
14 * Organization: Samsung Electronics
16 * =====================================================================================
19 #ifndef __TEE_CLIENT_API_H__
20 #define __TEE_CLIENT_API_H__
22 /*-----------------------------------------------------------------------------
24 *-----------------------------------------------------------------------------*/
36 /*-----------------------------------------------------------------------------
37 * TEE Client API types and constants definitions
38 *-----------------------------------------------------------------------------*/
39 #define TEEC_SUCCESS 0x00000000 // The operation was successful
40 #define TEEC_ERROR_GENERIC 0xFFFF0000 // Non-specific cause
41 #define TEEC_ERROR_ACCESS_DENIED 0xFFFF0001 // Access privileges are not sufficient
42 #define TEEC_ERROR_CANCEL 0xFFFF0002 // The operation was cancelled
43 #define TEEC_ERROR_ACCESS_CONFLICT 0xFFFF0003 // Concurrent accesses caused conflict
44 #define TEEC_ERROR_EXCESS_DATA 0xFFFF0004 // Too much data for the requested operation was passed
45 #define TEEC_ERROR_BAD_FORMAT 0xFFFF0005 // Input data was of invalid format
46 #define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 // Input parameters were invalid
47 #define TEEC_ERROR_BAD_STATE 0xFFFF0007 // Operation is not valid in the current state
48 #define TEEC_ERROR_ITEM_NOT_FOUND 0xFFFF0008 // The requested data item is not found
49 #define TEEC_ERROR_NOT_IMPLEMENTED 0xFFFF0009 // The requested operation should exist but is not yet implemented
50 #define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A // The requested operation is valid but is not supported in this Implementation
51 #define TEEC_ERROR_NO_DATA 0xFFFF000B // Expected data was missing
52 #define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C // System ran out of resources
53 #define TEEC_ERROR_BUSY 0xFFFF000D // The system is busy working on something else.
54 #define TEEC_ERROR_COMMUNICATION 0xFFFF000E // Communication with a remote party failed.
55 #define TEEC_ERROR_SECURITY 0xFFFF000F // A security fault was detected.
56 #define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010 // The supplied buffer is too short for the generated output.
57 #define TEEC_ERROR_TARGET_DEAD 0xFFFF3024 // Targed TA panic'ed
58 #define TEEC_IMP_MIN 0x00000001
59 #define TEEC_IMP_MAX 0xFFFEFFFF
60 #define TEEC_RFU_MIN 0xFFFF0011
61 #define TEEC_RFU_MAX 0xFFFFFFFF
63 #define TEEC_ORIGIN_API 0x1
64 #define TEEC_ORIGIN_COMMS 0x2
65 #define TEEC_ORIGIN_TEE 0x3
66 #define TEEC_ORIGIN_TRUSTED_APP 0x4
68 #define TEEC_CONFIG_SHAREDMEM_MAX_SIZE 0x800000
70 #define TEEC_MEM_INPUT (1 << 0)
71 #define TEEC_MEM_OUTPUT (1 << 1)
73 #define TEEC_NONE 0x00000000
74 #define TEEC_VALUE_INPUT 0x00000001
75 #define TEEC_VALUE_OUTPUT 0x00000002
76 #define TEEC_VALUE_INOUT 0x00000003
77 #define TEEC_MEMREF_TEMP_INPUT 0x00000005
78 #define TEEC_MEMREF_TEMP_OUTPUT 0x00000006
79 #define TEEC_MEMREF_TEMP_INOUT 0x00000007
80 #define TEEC_MEMREF_WHOLE 0x0000000C
81 #define TEEC_MEMREF_PARTIAL_INPUT 0x0000000D
82 #define TEEC_MEMREF_PARTIAL_OUTPUT 0x0000000E
83 #define TEEC_MEMREF_PARTIAL_INOUT 0x0000000F
85 #define TEE_PARAM_TYPE_NONE 0x00000000
86 #define TEE_PARAM_TYPE_VALUE_INPUT 0x00000001
87 #define TEE_PARAM_TYPE_VALUE_OUTPUT 0x00000002
88 #define TEE_PARAM_TYPE_VALUE_INOUT 0x00000003
89 #define TEE_PARAM_TYPE_MEMREF_INPUT 0x00000005
90 #define TEE_PARAM_TYPE_MEMREF_OUTPUT 0x00000006
91 #define TEE_PARAM_TYPE_MEMREF_INOUT 0x00000007
93 #define TEEC_LOGIN_PUBLIC 0x00000000
94 #define TEEC_LOGIN_USER 0x00000001
95 #define TEEC_LOGIN_GROUP 0x00000002
96 #define TEEC_LOGIN_APPLICATION 0x00000004
97 #define TEEC_LOGIN_USER_APPLICATION 0x00000005
98 #define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
100 #define MAX_CONTEXT_NAME_LEN 128
102 typedef uint32_t TEEC_Result;
107 uint16_t timeHiAndVersion;
108 uint8_t clockSeqAndNode[8];
129 } TEEC_TempMemoryReference;
132 TEEC_SharedMemory* parent;
135 } TEEC_RegisteredMemoryReference;
143 TEEC_TempMemoryReference tmpref;
144 TEEC_RegisteredMemoryReference memref;
151 TEEC_Parameter params[4];
155 /*-----------------------------------------------------------------------------
156 * TEE Client API functions and macros definitions
157 *-----------------------------------------------------------------------------*/
158 TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context);
160 void TEEC_FinalizeContext(TEEC_Context *context);
162 TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context,
163 TEEC_SharedMemory *sharedMem);
165 TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context,
166 TEEC_SharedMemory *sharedMem);
168 void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMem);
170 TEEC_Result TEEC_OpenSession(TEEC_Context *context,
171 TEEC_Session *session,
172 const TEEC_UUID *destination,
173 uint32_t connectionMethod,
174 const void *connectionData,
175 TEEC_Operation *operation,
176 uint32_t *returnOrigin);
178 void TEEC_CloseSession(TEEC_Session *session);
180 TEEC_Result TEEC_InvokeCommand(TEEC_Session *session,
182 TEEC_Operation *operation,
183 uint32_t *returnOrigin);
185 void TEEC_RequestCancellation(TEEC_Operation *operation);
187 #define TEEC_PARAM_TYPES(param0Type, param1Type, param2Type, param3Type) \
188 (uint32_t)(((param0Type) & 0x7f) | \
189 (((param1Type) & 0x7f) << 8) | \
190 (((param2Type) & 0x7f) << 16) | \
191 (((param3Type) & 0x7f) << 24))
197 #endif /* __TEE_CLIENT_API_H__ */