2 * Copyright (c) 2013 TRUSTONIC LIMITED
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
33 * This header file corresponds to V1.0 of the GlobalPlatform
34 * TEE Client API Specification
36 #ifndef __TEE_CLIENT_API_H__
37 #define __TEE_CLIENT_API_H__
40 #include "tee_error.h"
42 #if TBASE_API_LEVEL >= 3
44 #if (!defined(TEEC_EXPORT)) && __cplusplus
45 #define TEEC_EXPORT extern "C"
52 /* The header tee_client_api_imp.h must define implementation-dependent
53 types, constants and macros.
55 The implementation-dependent types are:
58 - TEEC_SharedMemory_IMP
61 The implementation-dependent constants are:
62 - TEEC_CONFIG_SHAREDMEM_MAX_SIZE
63 The implementation-dependent macros are:
73 #include "tee_client_api_imp.h"
75 /* Type definitions */
76 typedef struct TEEC_Context
{
80 typedef struct TEEC_Session
{
84 typedef struct TEEC_SharedMemory
{
88 TEEC_SharedMemory_IMP imp
;
94 } TEEC_TempMemoryReference
;
97 TEEC_SharedMemory
*parent
;
100 } TEEC_RegisteredMemoryReference
;
105 TEEC_TempMemoryReference tmpref
;
106 TEEC_RegisteredMemoryReference memref
;
110 typedef struct TEEC_Operation
{
111 volatile uint32_t started
;
113 TEEC_Parameter params
[4];
114 TEEC_Operation_IMP imp
;
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
123 #define TEEC_MEM_INPUT 0x00000001
124 #define TEEC_MEM_OUTPUT 0x00000002
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
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
145 #pragma GCC visibility push(default)
147 TEEC_EXPORT TEEC_Result
TEEC_InitializeContext(
149 TEEC_Context
*context
);
151 TEEC_EXPORT
void TEEC_FinalizeContext(
152 TEEC_Context
*context
);
154 TEEC_EXPORT TEEC_Result
TEEC_RegisterSharedMemory(
155 TEEC_Context
*context
,
156 TEEC_SharedMemory
*sharedMem
);
158 TEEC_EXPORT TEEC_Result
TEEC_AllocateSharedMemory(
159 TEEC_Context
*context
,
160 TEEC_SharedMemory
*sharedMem
);
162 TEEC_EXPORT
void TEEC_ReleaseSharedMemory (
163 TEEC_SharedMemory
*sharedMem
);
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
);
174 TEEC_EXPORT
void TEEC_CloseSession (
175 TEEC_Session
*session
);
177 TEEC_EXPORT TEEC_Result
TEEC_InvokeCommand(
178 TEEC_Session
*session
,
180 TEEC_Operation
*operation
,
181 uint32_t *returnOrigin
);
183 TEEC_EXPORT
void TEEC_RequestCancellation(
184 TEEC_Operation
*operation
);
186 #pragma GCC visibility pop
188 #endif /* TBASE_API_LEVEL */
190 #endif /* __TEE_CLIENT_API_H__ */