2 * Copyright (c) 2014, STMicroelectronics International N.V.
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.
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.
13 #ifndef TEE_SUPP_COMM_H
14 #define TEE_SUPP_COMM_H
16 #define TEE_RPC_ICMD_ALLOCATE 0x1001
17 #define TEE_RPC_ICMD_FREE 0x1002
18 #define TEE_RPC_ICMD_INVOKE 0x1003
20 #define TEE_RPC_NBR_BUFF 1
21 #define TEE_RPC_DATA_SIZE 64
22 #define TEE_RPC_BUFFER_NUMBER 5
24 #define TEE_RPC_STATE_IDLE 0x00
25 #define TEE_RPC_STATE_ACTIVE 0x01
27 /* Keep aligned with optee_client (user space) */
28 #define TEE_RPC_BUFFER 0x00000001
29 #define TEE_RPC_VALUE 0x00000002
30 #define TEE_RPC_LOAD_TA 0x10000001
32 * Handled within the driver only
33 * Keep aligned with optee_os (secure space)
35 #define TEE_RPC_MUTEX_WAIT 0x20000000
36 #define TEE_RPC_WAIT_QUEUE_SLEEP 0x20000001
37 #define TEE_RPC_WAIT_QUEUE_WAKEUP 0x20000002
38 #define TEE_RPC_WAIT 0x30000000
40 /* Parameters for TEE_RPC_WAIT_MUTEX above */
41 #define TEE_MUTEX_WAIT_SLEEP 0
42 #define TEE_MUTEX_WAIT_WAKEUP 1
43 #define TEE_MUTEX_WAIT_DELETE 2
45 #include <linux/semaphore.h>
48 * struct tee_rpc_bf - Contains definition of the tee com buffer
49 * @state: Buffer state
54 uint8_t data[TEE_RPC_DATA_SIZE];
57 struct tee_rpc_alloc {
58 uint32_t size; /* size of block */
59 void *data; /* pointer to data */
60 void *shm; /* pointer to an opaque data, being shm structure */
64 void *shm; /* pointer to an opaque data, being shm structure */
74 struct tee_rpc_invoke {
78 struct tee_rpc_cmd cmds[TEE_RPC_BUFFER_NUMBER];
82 struct tee_rpc_invoke commToUser;
83 struct tee_rpc_invoke commFromUser;
84 struct semaphore datatouser;
85 struct semaphore datafromuser;
86 struct mutex outsync; /* Out sync mutex */
87 struct mutex insync; /* In sync mutex */
88 struct mutex reqsync; /* Request sync mutex */
92 enum teec_rpc_result {
99 int tee_supp_init(struct tee *tee);
100 void tee_supp_deinit(struct tee *tee);
102 enum teec_rpc_result tee_supp_cmd(struct tee *tee,
103 uint32_t id, void *data, size_t datalen);
105 ssize_t tee_supp_read(struct file *filp, char __user *buffer,
106 size_t length, loff_t *offset);
108 ssize_t tee_supp_write(struct file *filp, const char __user *buffer,
109 size_t length, loff_t *offset);