Jens Wiklander | 2b7216b | 2018-09-25 16:40:11 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
| 2 | /* |
| 3 | * Copyright (c) 2016-2018, Linaro Limited |
| 4 | */ |
| 5 | |
| 6 | #ifndef __OPTEE_MSG_SUPPLICANT_H |
| 7 | #define __OPTEE_MSG_SUPPLICANT_H |
| 8 | |
| 9 | /* |
| 10 | * This file is based on |
| 11 | * https://github.com/OP-TEE/optee_os/blob/master/core/include/optee_msg_supplicant.h |
| 12 | * and may need to be updated when introducing new features. |
| 13 | */ |
| 14 | |
| 15 | /* |
| 16 | * Load a TA into memory |
| 17 | */ |
| 18 | #define OPTEE_MSG_RPC_CMD_LOAD_TA 0 |
| 19 | |
| 20 | /* |
| 21 | * Replay Protected Memory Block access |
| 22 | */ |
| 23 | #define OPTEE_MSG_RPC_CMD_RPMB 1 |
| 24 | |
| 25 | /* |
| 26 | * File system access |
| 27 | */ |
| 28 | #define OPTEE_MSG_RPC_CMD_FS 2 |
| 29 | |
| 30 | /* |
| 31 | * Define protocol for messages with .cmd == OPTEE_MSG_RPC_CMD_FS and first |
| 32 | * parameter has the attribute OPTEE_MSG_ATTR_TYPE_VALUE_INPUT. |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | * Open a file |
| 37 | * |
| 38 | * [in] param[0].u.value.a OPTEE_MRF_OPEN |
| 39 | * [in] param[1].u.tmem a string holding the file name |
| 40 | * [out] param[2].u.value.a file descriptor of open file |
| 41 | */ |
| 42 | #define OPTEE_MRF_OPEN 0 |
| 43 | |
| 44 | /* |
| 45 | * Create a file |
| 46 | * |
| 47 | * [in] param[0].u.value.a OPTEE_MRF_CREATE |
| 48 | * [in] param[1].u.tmem a string holding the file name |
| 49 | * [out] param[2].u.value.a file descriptor of open file |
| 50 | */ |
| 51 | #define OPTEE_MRF_CREATE 1 |
| 52 | |
| 53 | /* |
| 54 | * Close a file |
| 55 | * |
| 56 | * [in] param[0].u.value.a OPTEE_MRF_CLOSE |
| 57 | * [in] param[0].u.value.b file descriptor of open file. |
| 58 | */ |
| 59 | #define OPTEE_MRF_CLOSE 2 |
| 60 | |
| 61 | /* |
| 62 | * Read from a file |
| 63 | * |
| 64 | * [in] param[0].u.value.a OPTEE_MRF_READ |
| 65 | * [in] param[0].u.value.b file descriptor of open file |
| 66 | * [in] param[0].u.value.c offset into file |
| 67 | * [out] param[1].u.tmem buffer to hold returned data |
| 68 | */ |
| 69 | #define OPTEE_MRF_READ 3 |
| 70 | |
| 71 | /* |
| 72 | * Write to a file |
| 73 | * |
| 74 | * [in] param[0].u.value.a OPTEE_MRF_WRITE |
| 75 | * [in] param[0].u.value.b file descriptor of open file |
| 76 | * [in] param[0].u.value.c offset into file |
| 77 | * [in] param[1].u.tmem buffer holding data to be written |
| 78 | */ |
| 79 | #define OPTEE_MRF_WRITE 4 |
| 80 | |
| 81 | /* |
| 82 | * Truncate a file |
| 83 | * |
| 84 | * [in] param[0].u.value.a OPTEE_MRF_TRUNCATE |
| 85 | * [in] param[0].u.value.b file descriptor of open file |
| 86 | * [in] param[0].u.value.c length of file. |
| 87 | */ |
| 88 | #define OPTEE_MRF_TRUNCATE 5 |
| 89 | |
| 90 | /* |
| 91 | * Remove a file |
| 92 | * |
| 93 | * [in] param[0].u.value.a OPTEE_MRF_REMOVE |
| 94 | * [in] param[1].u.tmem a string holding the file name |
| 95 | */ |
| 96 | #define OPTEE_MRF_REMOVE 6 |
| 97 | |
| 98 | /* |
| 99 | * Rename a file |
| 100 | * |
| 101 | * [in] param[0].u.value.a OPTEE_MRF_RENAME |
| 102 | * [in] param[0].u.value.b true if existing target should be removed |
| 103 | * [in] param[1].u.tmem a string holding the old file name |
| 104 | * [in] param[2].u.tmem a string holding the new file name |
| 105 | */ |
| 106 | #define OPTEE_MRF_RENAME 7 |
| 107 | |
| 108 | /* |
| 109 | * Opens a directory for file listing |
| 110 | * |
| 111 | * [in] param[0].u.value.a OPTEE_MRF_OPENDIR |
| 112 | * [in] param[1].u.tmem a string holding the name of the directory |
| 113 | * [out] param[2].u.value.a handle to open directory |
| 114 | */ |
| 115 | #define OPTEE_MRF_OPENDIR 8 |
| 116 | |
| 117 | /* |
| 118 | * Closes a directory handle |
| 119 | * |
| 120 | * [in] param[0].u.value.a OPTEE_MRF_CLOSEDIR |
| 121 | * [in] param[0].u.value.b handle to open directory |
| 122 | */ |
| 123 | #define OPTEE_MRF_CLOSEDIR 9 |
| 124 | |
| 125 | /* |
| 126 | * Read next file name of directory |
| 127 | * |
| 128 | * |
| 129 | * [in] param[0].u.value.a OPTEE_MRF_READDIR |
| 130 | * [in] param[0].u.value.b handle to open directory |
| 131 | * [out] param[1].u.tmem a string holding the file name |
| 132 | */ |
| 133 | #define OPTEE_MRF_READDIR 10 |
| 134 | |
| 135 | /* |
| 136 | * End of definitions for messages with .cmd == OPTEE_MSG_RPC_CMD_FS |
| 137 | */ |
| 138 | |
| 139 | /* |
| 140 | * Command Ids 3, 4 and 5 of OPTEE_MSG_RPC_CMD_xxx macros are reserved for use |
| 141 | * by the kernel driver. |
| 142 | */ |
| 143 | |
| 144 | /* |
| 145 | * Shared memory allocation |
| 146 | */ |
| 147 | #define OPTEE_MSG_RPC_CMD_SHM_ALLOC 6 |
| 148 | #define OPTEE_MSG_RPC_CMD_SHM_FREE 7 |
| 149 | |
| 150 | /* |
Jorge Ramirez-Ortiz | d30807d | 2021-01-25 14:28:40 +0200 | [diff] [blame] | 151 | * I2C bus access |
| 152 | */ |
| 153 | #define OPTEE_MSG_RPC_CMD_I2C_TRANSFER 21 |
| 154 | |
| 155 | /* |
Jens Wiklander | 2b7216b | 2018-09-25 16:40:11 +0200 | [diff] [blame] | 156 | * Was OPTEE_MSG_RPC_CMD_SQL_FS, which isn't supported any longer |
| 157 | */ |
| 158 | #define OPTEE_MSG_RPC_CMD_SQL_FS_RESERVED 8 |
| 159 | |
| 160 | /* |
| 161 | * GPROF support management commands |
| 162 | */ |
| 163 | #define OPTEE_MSG_RPC_CMD_GPROF 9 |
| 164 | |
| 165 | /* |
| 166 | * Socket commands |
| 167 | */ |
| 168 | #define OPTEE_MSG_RPC_CMD_SOCKET 10 |
| 169 | |
| 170 | /* |
| 171 | * Define protocol for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET |
| 172 | */ |
| 173 | |
| 174 | #define OPTEE_MRC_SOCKET_TIMEOUT_NONBLOCKING 0 |
| 175 | #define OPTEE_MRC_SOCKET_TIMEOUT_BLOCKING 0xffffffff |
| 176 | |
| 177 | /* |
| 178 | * Open socket |
| 179 | * |
| 180 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_OPEN |
| 181 | * [in] param[0].u.value.b TA instance id |
| 182 | * [in] param[1].u.value.a server port number |
| 183 | * [in] param[1].u.value.b protocol, TEE_ISOCKET_PROTOCOLID_* |
| 184 | * [in] param[1].u.value.c ip version TEE_IP_VERSION_* from tee_ipsocket.h |
| 185 | * [in] param[2].u.tmem server address |
| 186 | * [out] param[3].u.value.a socket handle (32-bit) |
| 187 | */ |
| 188 | #define OPTEE_MRC_SOCKET_OPEN 0 |
| 189 | |
| 190 | /* |
| 191 | * Close socket |
| 192 | * |
| 193 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE |
| 194 | * [in] param[0].u.value.b TA instance id |
| 195 | * [in] param[0].u.value.c socket handle |
| 196 | */ |
| 197 | #define OPTEE_MRC_SOCKET_CLOSE 1 |
| 198 | |
| 199 | /* |
| 200 | * Close all sockets |
| 201 | * |
| 202 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE_ALL |
| 203 | * [in] param[0].u.value.b TA instance id |
| 204 | */ |
| 205 | #define OPTEE_MRC_SOCKET_CLOSE_ALL 2 |
| 206 | |
| 207 | /* |
| 208 | * Send data on socket |
| 209 | * |
| 210 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_SEND |
| 211 | * [in] param[0].u.value.b TA instance id |
| 212 | * [in] param[0].u.value.c socket handle |
| 213 | * [in] param[1].u.tmem buffer to transmit |
| 214 | * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_* |
| 215 | * [out] param[2].u.value.b number of transmitted bytes |
| 216 | */ |
| 217 | #define OPTEE_MRC_SOCKET_SEND 3 |
| 218 | |
| 219 | /* |
| 220 | * Receive data on socket |
| 221 | * |
| 222 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_RECV |
| 223 | * [in] param[0].u.value.b TA instance id |
| 224 | * [in] param[0].u.value.c socket handle |
| 225 | * [out] param[1].u.tmem buffer to receive |
| 226 | * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_* |
| 227 | */ |
| 228 | #define OPTEE_MRC_SOCKET_RECV 4 |
| 229 | |
| 230 | /* |
| 231 | * Perform IOCTL on socket |
| 232 | * |
| 233 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_IOCTL |
| 234 | * [in] param[0].u.value.b TA instance id |
| 235 | * [in] param[0].u.value.c socket handle |
| 236 | * [in/out] param[1].u.tmem buffer |
| 237 | * [in] param[2].u.value.a ioctl command |
| 238 | */ |
| 239 | #define OPTEE_MRC_SOCKET_IOCTL 5 |
| 240 | |
| 241 | /* |
| 242 | * End of definitions for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET |
| 243 | */ |
| 244 | |
| 245 | #endif /* __OPTEE_MSG_SUPPLICANT_H */ |