mTower
tee_client
libteec
include
freertos
tee.h
1
/*
2
* Copyright (c) 2015-2016, Linaro 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 notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
* POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#ifndef __TEE_H
29
#define __TEE_H
30
31
//#include <linux/ioctl.h>
32
//#include <linux/types.h>
33
34
/*
35
* This file describes the API provided by a TEE driver to user space.
36
*
37
* Each TEE driver defines a TEE specific protocol which is used for the
38
* data passed back and forth using TEE_IOC_CMD.
39
*/
40
41
/* Helpers to make the ioctl defines */
42
#define TEE_IOC_MAGIC 0xa4
43
#define TEE_IOC_BASE 0
44
#define TEE_IOC_OPEN_SESSION TEE_IOC_BASE + 2
45
#define TEE_IOC_INVOKE TEE_IOC_BASE + 3
46
#define TEE_IOC_CLOSE_SESSION TEE_IOC_BASE + 5
47
48
49
/* Flags relating to shared memory */
50
#define TEE_IOCTL_SHM_MAPPED 0x1
/* memory mapped in normal world */
51
#define TEE_IOCTL_SHM_DMA_BUF 0x2
/* dma-buf handle on shared memory */
52
53
#define TEE_MAX_ARG_SIZE 1024
54
55
#define TEE_GEN_CAP_GP (1 << 0)
/* GlobalPlatform compliant TEE */
56
#define TEE_GEN_CAP_REG_MEM (1 << 2)
/* Supports registering shared memory */
57
58
/*
59
* TEE Implementation ID
60
*/
61
#define TEE_IMPL_ID_OPTEE 1
62
63
/*
64
* OP-TEE specific capabilities
65
*/
66
#define TEE_OPTEE_CAP_TZ (1 << 0)
67
78
struct
tee_ioctl_version_data
{
79
uint32_t impl_id;
80
uint32_t impl_caps;
81
uint32_t gen_caps;
82
};
83
90
#define TEE_IOC_VERSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 0, \
91
struct tee_ioctl_version_data)
92
103
struct
tee_ioctl_shm_alloc_data
{
104
uint32_t size;
105
uint32_t flags;
106
int32_t id;
107
};
108
120
#define TEE_IOC_SHM_ALLOC _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 1, \
121
struct tee_ioctl_shm_alloc_data)
122
134
struct
tee_ioctl_shm_register_fd_data
{
135
uint32_t fd;
136
uint32_t size;
137
uint32_t flags;
138
int32_t id;
139
} __aligned(4);
140
149
#define TEE_IOC_SHM_REGISTER_FD _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 8, \
150
struct tee_ioctl_shm_register_fd_data)
151
163
struct
tee_ioctl_shm_register_data
{
164
uint32_t addr;
165
uint32_t length;
166
uint32_t flags;
167
int32_t id;
168
};
169
179
#define TEE_IOC_SHM_REGISTER _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 9, \
180
struct tee_ioctl_shm_register_data)
181
190
struct
tee_ioctl_buf_data
{
191
uint32_t buf_ptr;
192
uint32_t buf_len;
193
};
194
195
/*
196
* Attributes for struct tee_ioctl_param, selects field in the union
197
*/
198
#define TEE_IOCTL_PARAM_ATTR_TYPE_NONE 0
/* parameter not used */
199
200
/*
201
* These defines value parameters (struct tee_ioctl_param_value)
202
*/
203
#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT 1
204
#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT 2
205
#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT 3
/* input and output */
206
207
/*
208
* These defines shared memory reference parameters (struct
209
* tee_ioctl_param_memref)
210
*/
211
#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT 5
212
#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6
213
#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT 7
/* input and output */
214
215
/*
216
* Mask for the type part of the attribute, leaves room for more types
217
*/
218
#define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff
219
220
/* Meta parameter carrying extra information about the message. */
221
#define TEE_IOCTL_PARAM_ATTR_META 0x100
222
223
/* Mask of all known attr bits */
224
#define TEE_IOCTL_PARAM_ATTR_MASK \
225
(TEE_IOCTL_PARAM_ATTR_TYPE_MASK | TEE_IOCTL_PARAM_ATTR_META)
226
227
/*
228
* Matches TEEC_LOGIN_* in GP TEE Client API
229
* Are only defined for GP compliant TEEs
230
*/
231
#define TEE_IOCTL_LOGIN_PUBLIC 0
232
#define TEE_IOCTL_LOGIN_USER 1
233
#define TEE_IOCTL_LOGIN_GROUP 2
234
#define TEE_IOCTL_LOGIN_APPLICATION 4
235
#define TEE_IOCTL_LOGIN_USER_APPLICATION 5
236
#define TEE_IOCTL_LOGIN_GROUP_APPLICATION 6
237
250
struct
tee_ioctl_param_memref
{
251
uint32_t shm_offs;
252
uint32_t size;
253
int32_t shm_id;
254
};
255
264
struct
tee_ioctl_param_value
{
265
uint32_t a;
266
uint32_t b;
267
uint32_t c;
268
};
269
281
struct
tee_ioctl_param
{
282
uint32_t attr;
283
union
{
284
struct
tee_ioctl_param_memref
memref;
285
struct
tee_ioctl_param_value
value;
286
} u;
287
};
288
289
#define TEE_IOCTL_UUID_LEN 16
290
302
struct
tee_ioctl_open_session_arg
{
303
uint8_t uuid[TEE_IOCTL_UUID_LEN];
304
uint8_t clnt_uuid[TEE_IOCTL_UUID_LEN];
305
uint32_t clnt_login;
306
uint32_t cancel_id;
307
uint32_t session;
308
uint32_t ret;
309
uint32_t ret_origin;
310
uint32_t num_params;
311
/*
312
* this struct is 8 byte aligned since the 'struct tee_ioctl_param'
313
* which follows requires 8 byte alignment.
314
*
315
* Commented out element used to visualize the layout dynamic part
316
* of the struct. This field is not available at all if
317
* num_params == 0.
318
*
319
* struct tee_ioctl_param params[num_params];
320
*/
321
} __aligned(4);
322
330
//#define TEE_IOC_OPEN_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 2, \
331
// struct tee_ioctl_buf_data)
332
343
struct
tee_ioctl_invoke_arg
{
344
uint32_t func;
345
uint32_t session;
346
uint32_t cancel_id;
347
uint32_t ret;
348
uint32_t ret_origin;
349
uint32_t num_params;
350
/*
351
* this struct is 8 byte aligned since the 'struct tee_ioctl_param'
352
* which follows requires 8 byte alignment.
353
*
354
* Commented out element used to visualize the layout dynamic part
355
* of the struct. This field is not available at all if
356
* num_params == 0.
357
*
358
* struct tee_ioctl_param params[num_params];
359
*/
360
} __aligned(4);
361
368
//#define TEE_IOC_INVOKE _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 3, \
369
// struct tee_ioctl_buf_data)
370
376
struct
tee_ioctl_cancel_arg
{
377
uint32_t cancel_id;
378
uint32_t session;
379
};
380
384
#define TEE_IOC_CANCEL _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 4, \
385
struct tee_ioctl_cancel_arg)
386
391
struct
tee_ioctl_close_session_arg
{
392
uint32_t session;
393
};
394
398
//#define TEE_IOC_CLOSE_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 5, \
399
// struct tee_ioctl_close_session_arg)
400
410
struct
tee_iocl_supp_recv_arg
{
411
uint32_t func;
412
uint32_t num_params;
413
/*
414
* this struct is 8 byte aligned since the 'struct tee_ioctl_param'
415
* which follows requires 8 byte alignment.
416
*
417
* Commented out element used to visualize the layout dynamic part
418
* of the struct. This field is not available at all if
419
* num_params == 0.
420
*
421
* struct tee_ioctl_param params[num_params];
422
*/
423
} __aligned(4);
424
431
#define TEE_IOC_SUPPL_RECV _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 6, \
432
struct tee_ioctl_buf_data)
433
439
struct
tee_iocl_supp_send_arg
{
440
uint32_t ret;
441
uint32_t num_params;
442
/*
443
* this struct is 8 byte aligned since the 'struct tee_ioctl_param'
444
* which follows requires 8 byte alignment.
445
*
446
* Commented out element used to visualize the layout dynamic part
447
* of the struct. This field is not available at all if
448
* num_params == 0.
449
*
450
* struct tee_ioctl_param params[num_params];
451
*/
452
} __aligned(4);
459
#define TEE_IOC_SUPPL_SEND _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 7, \
460
struct tee_ioctl_buf_data)
461
462
/*
463
* Five syscalls are used when communicating with the TEE driver.
464
* open(): opens the device associated with the driver
465
* ioctl(): as described above operating on the file descriptor from open()
466
* close(): two cases
467
* - closes the device file descriptor
468
* - closes a file descriptor connected to allocated shared memory
469
* mmap(): maps shared memory into user space using information from struct
470
* tee_ioctl_shm_alloc_data
471
* munmap(): unmaps previously shared memory
472
*/
473
474
#endif
/*__TEE_H*/
tee_ioctl_param
Definition:
tee.h:281
tee_ioctl_open_session_arg
Definition:
tee.h:302
tee_ioctl_invoke_arg
!! change from 8 to 4
Definition:
tee.h:343
tee_ioctl_version_data
Definition:
tee.h:78
tee_ioctl_param_value
Definition:
tee.h:264
tee_ioctl_param_memref
Definition:
tee.h:250
tee_ioctl_shm_register_fd_data
Definition:
tee.h:134
tee_ioctl_cancel_arg
Definition:
tee.h:376
tee_ioctl_shm_register_data
Definition:
tee.h:163
tee_iocl_supp_send_arg
Definition:
tee.h:439
tee_ioctl_buf_data
Definition:
tee.h:190
tee_ioctl_close_session_arg
Definition:
tee.h:391
tee_iocl_supp_recv_arg
Definition:
tee.h:410
tee_ioctl_shm_alloc_data
Definition:
tee.h:103
Generated by
1.8.13