1 /* 2 * Copyright (c) 2014, STMicroelectronics International N.V. 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 #ifndef _TEE_IOC_H 28 #define _TEE_IOC_H 29 30 #include <tee_client_api.h> 31 32 #ifndef __KERNEL__ 33 #define __user 34 #endif 35 36 /** 37 * struct tee_cmd_io - The command sent to an open tee device. 38 * @err: Error code (as in Global Platform TEE Client API spec) 39 * @origin: Origin for the error code (also from spec). 40 * @cmd: The command to be executed in the trusted application. 41 * @uuid: The uuid for the trusted application. 42 * @data: The trusted application or memory block. 43 * @data_size: The size of the trusted application or memory block. 44 * @op: The cmd payload operation for the trusted application. 45 * 46 * This structure is mainly used in the Linux kernel for communication 47 * with the user space. 48 */ 49 struct tee_cmd_io { 50 TEEC_Result err; 51 uint32_t origin; 52 uint32_t cmd; 53 int fd_sess; 54 /* 55 * Here fd_sess is 32-bit variable. Since TEEC_Result also is defined as 56 * "uint32_t", this structure is aligned. 57 */ 58 union { 59 TEEC_UUID __user *uuid; 60 uint64_t padding_uuid; 61 }; 62 union { 63 void __user *data; 64 uint64_t padding_data; 65 }; 66 union { 67 TEEC_Operation __user *op; 68 uint64_t padding_op; 69 }; 70 uint32_t data_size; 71 int32_t reserved; 72 }; 73 74 struct tee_shm_io { 75 union { 76 void __user *buffer; 77 uint64_t padding_buf; 78 }; 79 uint32_t size; 80 uint32_t flags; 81 /* 82 * Here fd_shm is 32-bit. To be compliant with the convention of file 83 * descriptor definition, fd_shm is defined as "int" type other 84 * than "int32_t". Even though using "int32_t" is more obvious to 85 * indicate that we intend to keep this structure aligned. 86 */ 87 int fd_shm; 88 uint32_t registered; 89 }; 90 91 #define TEE_OPEN_SESSION_IOC _IOWR('t', 161, struct tee_cmd_io) 92 #define TEE_INVOKE_COMMAND_IOC _IOWR('t', 163, struct tee_cmd_io) 93 #define TEE_REQUEST_CANCELLATION_IOC _IOWR('t', 164, struct tee_cmd_io) 94 #define TEE_ALLOC_SHM_IOC _IOWR('t', 165, struct tee_shm_io) 95 #define TEE_GET_FD_FOR_RPC_SHM_IOC _IOWR('t', 167, struct tee_shm_io) 96 97 #define TEE_PM51CTL_IOC _IOWR('t', 190, uint32_t) 98 99 #endif /* _TEE_IOC_H */ 100