OP-TEE: update optee_linuxdriver to match updated optee_os & optee_client
[firefly-linux-kernel-4.4.55.git] / security / optee_linuxdriver / include / linux / tee_ioc.h
1 /*
2  * Copyright (c) 2014, STMicroelectronics International N.V.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License Version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
13 #ifndef _TEE_IOC_H
14 #define _TEE_IOC_H
15
16 #include <linux/tee_client_api.h>
17
18 #ifndef __KERNEL__
19 #define __user
20 #endif
21
22 /**
23  * struct tee_cmd_io - The command sent to an open tee device.
24  * @err: Error code (as in Global Platform TEE Client API spec)
25  * @origin: Origin for the error code (also from spec).
26  * @cmd: The command to be executed in the trusted application.
27  * @uuid: The uuid for the trusted application.
28  * @data: The trusted application or memory block.
29  * @data_size: The size of the trusted application or memory block.
30  * @op: The cmd payload operation for the trusted application.
31  *
32  * This structure is mainly used in the Linux kernel for communication
33  * with the user space.
34  */
35 struct tee_cmd_io {
36         TEEC_Result err;
37         uint32_t origin;
38         uint32_t cmd;
39         int fd_sess;
40         /*
41          * Here fd_sess is 32-bit variable. Since TEEC_Result also is defined as
42          * "uint32_t", this structure is aligned.
43          */
44         union {
45                 TEEC_UUID __user *uuid;
46                 uint64_t padding_uuid;
47         };
48         union {
49                 void __user *data;
50                 uint64_t padding_data;
51         };
52         union {
53                 TEEC_Operation __user *op;
54                 uint64_t padding_op;
55         };
56         uint32_t data_size;
57         int32_t reserved;
58 };
59
60 struct tee_shm_io {
61         union {
62                 void __user *buffer;
63                 uint64_t padding_buf;
64         };
65         uint32_t size;
66         uint32_t flags;
67         /*
68          * Here fd_shm is 32-bit. To be compliant with the convention of file
69          * descriptor definition, fd_shm is defined as "int" type other
70          * than "int32_t". Even though using "int32_t" is more obvious to
71          * indicate that we intend to keep this structure aligned.
72          */
73         int fd_shm;
74         uint32_t registered;
75 };
76
77 #define TEE_OPEN_SESSION_IOC            _IOWR('t', 161, struct tee_cmd_io)
78 #define TEE_INVOKE_COMMAND_IOC          _IOWR('t', 163, struct tee_cmd_io)
79 #define TEE_REQUEST_CANCELLATION_IOC    _IOWR('t', 164, struct tee_cmd_io)
80 #define TEE_ALLOC_SHM_IOC               _IOWR('t', 165, struct tee_shm_io)
81 #define TEE_GET_FD_FOR_RPC_SHM_IOC      _IOWR('t', 167, struct tee_shm_io)
82
83 #endif /* _TEE_IOC_H */