TA-REF
tee_client_api.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
3 * All rights reserved.
4 * Copyright (c) 2015, Linaro Limited
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29#ifndef TEE_CLIENT_API_H
30#define TEE_CLIENT_API_H
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#include <stdint.h>
37#include <stddef.h>
38#include <stdbool.h>
39#include <limits.h>
40#include "tee-common.h"
41
42#ifndef DOXYGEN_SHOULD_SKIP_THIS
43/*
44 * Defines the number of available memory references in an open session or
45 * invoke command operation payload.
46 */
47#define TEEC_CONFIG_PAYLOAD_REF_COUNT 4
48
55#define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ULONG_MAX
56
111#define TEEC_NONE 0x00000000
112#define TEEC_VALUE_INPUT 0x00000001
113#define TEEC_VALUE_OUTPUT 0x00000002
114#define TEEC_VALUE_INOUT 0x00000003
115#define TEEC_MEMREF_TEMP_INPUT 0x00000005
116#define TEEC_MEMREF_TEMP_OUTPUT 0x00000006
117#define TEEC_MEMREF_TEMP_INOUT 0x00000007
118#define TEEC_MEMREF_WHOLE 0x0000000C
119#define TEEC_MEMREF_PARTIAL_INPUT 0x0000000D
120#define TEEC_MEMREF_PARTIAL_OUTPUT 0x0000000E
121#define TEEC_MEMREF_PARTIAL_INOUT 0x0000000F
122
134#define TEEC_MEM_INPUT 0x00000001
135#define TEEC_MEM_OUTPUT 0x00000002
136
169#define TEEC_SUCCESS 0x00000000
170#define TEEC_ERROR_GENERIC 0xFFFF0000
171#define TEEC_ERROR_ACCESS_DENIED 0xFFFF0001
172#define TEEC_ERROR_CANCEL 0xFFFF0002
173#define TEEC_ERROR_ACCESS_CONFLICT 0xFFFF0003
174#define TEEC_ERROR_EXCESS_DATA 0xFFFF0004
175#define TEEC_ERROR_BAD_FORMAT 0xFFFF0005
176#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006
177#define TEEC_ERROR_BAD_STATE 0xFFFF0007
178#define TEEC_ERROR_ITEM_NOT_FOUND 0xFFFF0008
179#define TEEC_ERROR_NOT_IMPLEMENTED 0xFFFF0009
180#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A
181#define TEEC_ERROR_NO_DATA 0xFFFF000B
182#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C
183#define TEEC_ERROR_BUSY 0xFFFF000D
184#define TEEC_ERROR_COMMUNICATION 0xFFFF000E
185#define TEEC_ERROR_SECURITY 0xFFFF000F
186#define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010
187#define TEEC_ERROR_EXTERNAL_CANCEL 0xFFFF0011
188#define TEEC_ERROR_TARGET_DEAD 0xFFFF3024
189
203#define TEEC_ORIGIN_API 0x00000001
204#define TEEC_ORIGIN_COMMS 0x00000002
205#define TEEC_ORIGIN_TEE 0x00000003
206#define TEEC_ORIGIN_TRUSTED_APP 0x00000004
207
224#define TEEC_LOGIN_PUBLIC 0x00000000
225#define TEEC_LOGIN_USER 0x00000001
226#define TEEC_LOGIN_GROUP 0x00000002
227#define TEEC_LOGIN_APPLICATION 0x00000004
228#define TEEC_LOGIN_USER_APPLICATION 0x00000005
229#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
230
239#define TEEC_PARAM_TYPES(p0, p1, p2, p3) \
240 ((p0) | ((p1) << 4) | ((p2) << 8) | ((p3) << 12))
241
248#define TEEC_PARAM_TYPE_GET(p, i) (((p) >> (i * 4)) & 0xF)
249#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
250
251typedef uint32_t TEEC_Result;
252
257typedef struct {
258 /* Implementation defined */
259 int fd;
262
268typedef struct {
269 uint32_t timeLow;
270 uint16_t timeMid;
272 uint8_t clockSeqAndNode[8];
273} TEEC_UUID;
274
291typedef struct {
292 void *buffer;
293 size_t size;
294 uint32_t flags;
295 /*
296 * Implementation-Defined
297 */
298 int id;
304
317typedef struct {
318 void *buffer;
319 size_t size;
321
337typedef struct {
339 size_t size;
340 size_t offset;
342
353typedef struct {
354 uint32_t a;
355 uint32_t b;
356} TEEC_Value;
357
372typedef union {
377
382typedef struct {
383 /* Implementation defined */
385 uint32_t session_id;
387
402typedef struct {
403 uint32_t started;
404 uint32_t paramTypes;
405 TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT];
406 /* Implementation-Defined */
409
424TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context);
425
438
466 TEEC_Session *session,
467 const TEEC_UUID *destination,
468 uint32_t connectionMethod,
469 const void *connectionData,
470 TEEC_Operation *operation,
471 uint32_t *returnOrigin);
472
479void TEEC_CloseSession(TEEC_Session *session);
480
499 uint32_t commandID,
500 TEEC_Operation *operation,
501 uint32_t *returnOrigin);
502
516 TEEC_SharedMemory *sharedMem);
517
530 TEEC_SharedMemory *sharedMem);
531
538
547
548#ifdef __cplusplus
549}
550#endif
551
552#endif
TEEC_Result TEEC_OpenSession(TEEC_Context *context, TEEC_Session *session, const TEEC_UUID *destination, uint32_t connectionMethod, const void *connectionData, TEEC_Operation *operation, uint32_t *returnOrigin)
Definition: teec_stub.c:97
TEEC_Result TEEC_InvokeCommand(TEEC_Session *session, uint32_t commandID, TEEC_Operation *operation, uint32_t *returnOrigin)
TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context)
Definition: teec_stub.c:49
TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context, TEEC_SharedMemory *sharedMem)
Definition: teec_stub.c:150
void TEEC_FinalizeContext(TEEC_Context *context)
Definition: teec_stub.c:66
uint32_t TEEC_Result
Definition: tee_client_api.h:251
void TEEC_RequestCancellation(TEEC_Operation *operation)
Definition: teec_stub.c:174
void TEEC_CloseSession(TEEC_Session *session)
Definition: teec_stub.c:115
TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context, TEEC_SharedMemory *sharedMem)
Definition: teec_stub.c:132
void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMemory)
Definition: teec_stub.c:162
Common type and definitions of RISC-V TEE.
Definition: tee_client_api.h:257
int fd
Definition: tee_client_api.h:259
bool reg_mem
Definition: tee_client_api.h:260
Definition: tee_client_api.h:268
uint16_t timeMid
Definition: tee_client_api.h:270
uint16_t timeHiAndVersion
Definition: tee_client_api.h:271
uint32_t timeLow
Definition: tee_client_api.h:269
Definition: tee_client_api.h:291
int registered_fd
Definition: tee_client_api.h:301
bool buffer_allocated
Definition: tee_client_api.h:302
void * buffer
Definition: tee_client_api.h:292
uint32_t flags
Definition: tee_client_api.h:294
void * shadow_buffer
Definition: tee_client_api.h:300
size_t size
Definition: tee_client_api.h:293
size_t alloced_size
Definition: tee_client_api.h:299
int id
Definition: tee_client_api.h:298
Definition: tee_client_api.h:317
void * buffer
Definition: tee_client_api.h:318
size_t size
Definition: tee_client_api.h:319
Definition: tee_client_api.h:337
size_t size
Definition: tee_client_api.h:339
TEEC_SharedMemory * parent
Definition: tee_client_api.h:338
size_t offset
Definition: tee_client_api.h:340
Definition: tee_client_api.h:353
uint32_t a
Definition: tee_client_api.h:354
uint32_t b
Definition: tee_client_api.h:355
Definition: tee_client_api.h:372
TEEC_RegisteredMemoryReference memref
Definition: tee_client_api.h:374
TEEC_Value value
Definition: tee_client_api.h:375
TEEC_TempMemoryReference tmpref
Definition: tee_client_api.h:373
Definition: tee_client_api.h:382
TEEC_Context * ctx
Definition: tee_client_api.h:384
uint32_t session_id
Definition: tee_client_api.h:385
Definition: tee_client_api.h:402
TEEC_Session * session
Definition: tee_client_api.h:407
uint32_t started
Definition: tee_client_api.h:403
uint32_t paramTypes
Definition: tee_client_api.h:404