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 | /* |
| 151 | * Was OPTEE_MSG_RPC_CMD_SQL_FS, which isn't supported any longer |
| 152 | */ |
| 153 | #define OPTEE_MSG_RPC_CMD_SQL_FS_RESERVED 8 |
| 154 | |
| 155 | /* |
| 156 | * GPROF support management commands |
| 157 | */ |
| 158 | #define OPTEE_MSG_RPC_CMD_GPROF 9 |
| 159 | |
| 160 | /* |
| 161 | * Socket commands |
| 162 | */ |
| 163 | #define OPTEE_MSG_RPC_CMD_SOCKET 10 |
| 164 | |
| 165 | /* |
| 166 | * Define protocol for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET |
| 167 | */ |
| 168 | |
| 169 | #define OPTEE_MRC_SOCKET_TIMEOUT_NONBLOCKING 0 |
| 170 | #define OPTEE_MRC_SOCKET_TIMEOUT_BLOCKING 0xffffffff |
| 171 | |
| 172 | /* |
| 173 | * Open socket |
| 174 | * |
| 175 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_OPEN |
| 176 | * [in] param[0].u.value.b TA instance id |
| 177 | * [in] param[1].u.value.a server port number |
| 178 | * [in] param[1].u.value.b protocol, TEE_ISOCKET_PROTOCOLID_* |
| 179 | * [in] param[1].u.value.c ip version TEE_IP_VERSION_* from tee_ipsocket.h |
| 180 | * [in] param[2].u.tmem server address |
| 181 | * [out] param[3].u.value.a socket handle (32-bit) |
| 182 | */ |
| 183 | #define OPTEE_MRC_SOCKET_OPEN 0 |
| 184 | |
| 185 | /* |
| 186 | * Close socket |
| 187 | * |
| 188 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE |
| 189 | * [in] param[0].u.value.b TA instance id |
| 190 | * [in] param[0].u.value.c socket handle |
| 191 | */ |
| 192 | #define OPTEE_MRC_SOCKET_CLOSE 1 |
| 193 | |
| 194 | /* |
| 195 | * Close all sockets |
| 196 | * |
| 197 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE_ALL |
| 198 | * [in] param[0].u.value.b TA instance id |
| 199 | */ |
| 200 | #define OPTEE_MRC_SOCKET_CLOSE_ALL 2 |
| 201 | |
| 202 | /* |
| 203 | * Send data on socket |
| 204 | * |
| 205 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_SEND |
| 206 | * [in] param[0].u.value.b TA instance id |
| 207 | * [in] param[0].u.value.c socket handle |
| 208 | * [in] param[1].u.tmem buffer to transmit |
| 209 | * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_* |
| 210 | * [out] param[2].u.value.b number of transmitted bytes |
| 211 | */ |
| 212 | #define OPTEE_MRC_SOCKET_SEND 3 |
| 213 | |
| 214 | /* |
| 215 | * Receive data on socket |
| 216 | * |
| 217 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_RECV |
| 218 | * [in] param[0].u.value.b TA instance id |
| 219 | * [in] param[0].u.value.c socket handle |
| 220 | * [out] param[1].u.tmem buffer to receive |
| 221 | * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_* |
| 222 | */ |
| 223 | #define OPTEE_MRC_SOCKET_RECV 4 |
| 224 | |
| 225 | /* |
| 226 | * Perform IOCTL on socket |
| 227 | * |
| 228 | * [in] param[0].u.value.a OPTEE_MRC_SOCKET_IOCTL |
| 229 | * [in] param[0].u.value.b TA instance id |
| 230 | * [in] param[0].u.value.c socket handle |
| 231 | * [in/out] param[1].u.tmem buffer |
| 232 | * [in] param[2].u.value.a ioctl command |
| 233 | */ |
| 234 | #define OPTEE_MRC_SOCKET_IOCTL 5 |
| 235 | |
| 236 | /* |
| 237 | * End of definitions for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET |
| 238 | */ |
| 239 | |
| 240 | #endif /* __OPTEE_MSG_SUPPLICANT_H */ |