forked from OP-TEE/optee_os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
optee_rpc_cmd.h
415 lines (367 loc) · 11.5 KB
/
optee_rpc_cmd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2016-2021, Linaro Limited
*/
#ifndef __OPTEE_RPC_CMD_H
#define __OPTEE_RPC_CMD_H
/*
* All RPC is done with a struct optee_msg_arg as bearer of information,
* struct optee_msg_arg::arg holds values defined by OPTEE_RPC_CMD_* below.
* Only the commands handled by the kernel driver are defined here.
*
* RPC communication with tee-supplicant is reversed compared to normal
* client communication described above. The supplicant receives requests
* and sends responses.
*/
/*
* Load a TA into memory
*
* Since the size of the TA isn't known in advance the size of the TA is
* can be queried with a NULL buffer.
*
* [in] value[0].a-b UUID
* [out] memref[1] Buffer with TA
*/
#define OPTEE_RPC_CMD_LOAD_TA U(0)
/*
* Replay Protected Memory Block access
*
* [in] memref[0] Frames to device
* [out] memref[1] Frames from device
*/
#define OPTEE_RPC_CMD_RPMB U(1)
/*
* File system access, see definition of protocol below
*/
#define OPTEE_RPC_CMD_FS U(2)
/*
* Get time
*
* Returns number of seconds and nano seconds since the Epoch,
* 1970-01-01 00:00:00 +0000 (UTC).
*
* [out] value[0].a Number of seconds
* [out] value[0].b Number of nano seconds.
*/
#define OPTEE_RPC_CMD_GET_TIME U(3)
/*
* Notification from/to secure world.
*
* If secure world needs to wait for something, for instance a mutex, it
* does a notification wait request instead of spinning in secure world.
* Conversely a synchronous notification can be sent when a secure
* world mutex with a thread waiting thread is unlocked.
*
* This interface can also be used to wait for a asynchronous notification
* which instead is sent via a non-secure interrupt.
*
* Waiting on notification
* [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT
* [in] value[0].b notification value
*
* Sending a synchronous notification
* [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND
* [in] value[0].b notification value
*/
#define OPTEE_RPC_CMD_NOTIFICATION U(4)
#define OPTEE_RPC_NOTIFICATION_WAIT U(0)
#define OPTEE_RPC_NOTIFICATION_SEND U(1)
/*
* Suspend execution
*
* [in] value[0].a Number of milliseconds to suspend
*/
#define OPTEE_RPC_CMD_SUSPEND U(5)
/*
* Allocate a piece of shared memory
*
* [in] value[0].a Type of memory one of
* OPTEE_RPC_SHM_TYPE_* below
* [in] value[0].b Requested size
* [in] value[0].c Required alignment
* [out] memref[0] Buffer
*/
#define OPTEE_RPC_CMD_SHM_ALLOC U(6)
/* Memory that can be shared with a non-secure user space application */
#define OPTEE_RPC_SHM_TYPE_APPL U(0)
/* Memory only shared with non-secure kernel */
#define OPTEE_RPC_SHM_TYPE_KERNEL U(1)
/*
* Memory shared with non-secure kernel and exported to a non-secure user
* space application
*/
#define OPTEE_RPC_SHM_TYPE_GLOBAL U(2)
/*
* Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
*
* [in] value[0].a Type of memory one of
* OPTEE_RPC_SHM_TYPE_* above
* [in] value[0].b Value of shared memory reference or cookie
*/
#define OPTEE_RPC_CMD_SHM_FREE U(7)
/* Was OPTEE_RPC_CMD_SQL_FS, which isn't supported any longer */
#define OPTEE_RPC_CMD_SQL_FS_RESERVED U(8)
/*
* Send TA profiling information to normal world
*
* [in/out] value[0].a File identifier. Must be set to 0 on
* first call. A value >= 1 will be
* returned on success. Re-use this value
* to append data to the same file.
* [in] memref[1] TA UUID
* [in] memref[2] Profile data
*/
#define OPTEE_RPC_CMD_GPROF U(9)
/*
* Socket command, see definition of protocol below
*/
#define OPTEE_RPC_CMD_SOCKET U(10)
/*
* Send TA function graph data to normal world
*
* [in/out] value[0].a File identifier. Must be set to 0 on
* first call. A value >= 1 will be
* returned on success. Re-use this value
* to append data to the same file.
* [in] memref[1] TA UUID
* [in] memref[2] function graph data
*/
#define OPTEE_RPC_CMD_FTRACE U(11)
/*
* tee-supplicant plugin command, see definition of protocol below
*/
#define OPTEE_RPC_CMD_SUPP_PLUGIN U(12)
/*
* Register timestamp buffer in the linux kernel optee driver
*
* [in] value[0].a Subcommand (register buffer, unregister buffer)
* [in] value[0].b Physical address of timestamp buffer
* [in] value[0].c Size of buffer
*/
#define OPTEE_RPC_CMD_BENCH_REG U(20)
/*
* Issue master requests (read and write operations) to an I2C chip.
*
* [in] value[0].a Transfer mode (OPTEE_RPC_I2C_TRANSFER_*)
* [in] value[0].b The I2C bus (a.k.a adapter).
* 16 bit field.
* [in] value[0].c The I2C chip (a.k.a address).
* 16 bit field (either 7 or 10 bit effective).
* [in] value[1].a The I2C master control flags (ie, 10 bit address).
* 16 bit field.
* [in/out] memref[2] Buffer used for data transfers.
* [out] value[3].a Number of bytes transferred by the REE.
*/
#define OPTEE_RPC_CMD_I2C_TRANSFER U(21)
/* I2C master transfer modes */
#define OPTEE_RPC_I2C_TRANSFER_RD U(0)
#define OPTEE_RPC_I2C_TRANSFER_WR U(1)
/* I2C master control flags */
#define OPTEE_RPC_I2C_FLAGS_TEN_BIT BIT(0)
/*
* Reset RPMB probing
*
* Releases an eventually already used RPMB devices and starts over searching
* for RPMB devices. Returns the kind of shared memory to use in subsequent
* OPTEE_RPC_CMD_RPMB_PROBE_NEXT and OPTEE_RPC_CMD_RPMB calls.
*
* [out] value[0].a OPTEE_RPC_SHM_TYPE_*, the parameter for
* OPTEE_RPC_CMD_SHM_ALLOC
*/
#define OPTEE_RPC_CMD_RPMB_PROBE_RESET U(22)
/*
* Probe next RPMB device
*
* [out] value[0].a Must be OPTEE_RPC_RPMB_EMMC
* [out] value[0].b EXT CSD-slice 168 "RPMB Size"
* [out] value[0].c EXT CSD-slice 222 "Reliable Write Sector Count"
* [out] memref[1] Buffer with the raw CID
*/
#define OPTEE_RPC_CMD_RPMB_PROBE_NEXT U(23)
#define OPTEE_RPC_RPMB_EMMC U(0)
/*
* Definition of protocol for command OPTEE_RPC_CMD_FS
*/
/*
* Open a file
*
* [in] value[0].a OPTEE_RPC_FS_OPEN
* [in] memref[1] A string holding the file name
* [out] value[2].a File descriptor of open file
*/
#define OPTEE_RPC_FS_OPEN U(0)
/*
* Create a file
*
* [in] value[0].a OPTEE_RPC_FS_CREATE
* [in] memref[1] A string holding the file name
* [out] value[2].a File descriptor of open file
*/
#define OPTEE_RPC_FS_CREATE U(1)
/*
* Close a file
*
* [in] value[0].a OPTEE_RPC_FS_CLOSE
* [in] value[0].b File descriptor of open file.
*/
#define OPTEE_RPC_FS_CLOSE U(2)
/*
* Read from a file
*
* [in] value[0].a OPTEE_RPC_FS_READ
* [in] value[0].b File descriptor of open file
* [in] value[0].c Offset into file
* [out] memref[1] Buffer to hold returned data
*/
#define OPTEE_RPC_FS_READ U(3)
/*
* Write to a file
*
* [in] value[0].a OPTEE_RPC_FS_WRITE
* [in] value[0].b File descriptor of open file
* [in] value[0].c Offset into file
* [in] memref[1] Buffer holding data to be written
*/
#define OPTEE_RPC_FS_WRITE U(4)
/*
* Truncate a file
*
* [in] value[0].a OPTEE_RPC_FS_TRUNCATE
* [in] value[0].b File descriptor of open file
* [in] value[0].c Length of file.
*/
#define OPTEE_RPC_FS_TRUNCATE U(5)
/*
* Remove a file
*
* [in] value[0].a OPTEE_RPC_FS_REMOVE
* [in] memref[1] A string holding the file name
*/
#define OPTEE_RPC_FS_REMOVE U(6)
/*
* Rename a file
*
* [in] value[0].a OPTEE_RPC_FS_RENAME
* [in] value[0].b True if existing target should be removed
* [in] memref[1] A string holding the old file name
* [in] memref[2] A string holding the new file name
*/
#define OPTEE_RPC_FS_RENAME U(7)
/*
* Opens a directory for file listing
*
* [in] value[0].a OPTEE_RPC_FS_OPENDIR
* [in] memref[1] A string holding the name of the directory
* [out] value[2].a Handle to open directory
*/
#define OPTEE_RPC_FS_OPENDIR U(8)
/*
* Closes a directory handle
*
* [in] value[0].a OPTEE_RPC_FS_CLOSEDIR
* [in] value[0].b Handle to open directory
*/
#define OPTEE_RPC_FS_CLOSEDIR U(9)
/*
* Read next file name of directory
*
*
* [in] value[0].a OPTEE_RPC_FS_READDIR
* [in] value[0].b Handle to open directory
* [out] memref[1] A string holding the file name
*/
#define OPTEE_RPC_FS_READDIR U(10)
/* End of definition of protocol for command OPTEE_RPC_CMD_FS */
/*
* Definition of protocol for command OPTEE_RPC_CMD_SOCKET
*/
#define OPTEE_RPC_SOCKET_TIMEOUT_NONBLOCKING U(0)
#define OPTEE_RPC_SOCKET_TIMEOUT_BLOCKING U(0xffffffff)
/*
* Open socket
*
* [in] value[0].a OPTEE_RPC_SOCKET_OPEN
* [in] value[0].b TA instance id
* [in] value[1].a Server port number
* [in] value[1].b Protocol, TEE_ISOCKET_PROTOCOLID_*
* [in] value[1].c Ip version TEE_IP_VERSION_* from tee_ipsocket.h
* [in] memref[2] Server address
* [out] value[3].a Socket handle (32-bit)
*/
#define OPTEE_RPC_SOCKET_OPEN U(0)
/*
* Close socket
*
* [in] value[0].a OPTEE_RPC_SOCKET_CLOSE
* [in] value[0].b TA instance id
* [in] value[0].c Socket handle
*/
#define OPTEE_RPC_SOCKET_CLOSE U(1)
/*
* Close all sockets
*
* [in] value[0].a OPTEE_RPC_SOCKET_CLOSE_ALL
* [in] value[0].b TA instance id
*/
#define OPTEE_RPC_SOCKET_CLOSE_ALL U(2)
/*
* Send data on socket
*
* [in] value[0].a OPTEE_RPC_SOCKET_SEND
* [in] value[0].b TA instance id
* [in] value[0].c Socket handle
* [in] memref[1] Buffer to transmit
* [in] value[2].a Timeout ms or OPTEE_RPC_SOCKET_TIMEOUT_*
* [out] value[2].b Number of transmitted bytes
*/
#define OPTEE_RPC_SOCKET_SEND U(3)
/*
* Receive data on socket
*
* [in] value[0].a OPTEE_RPC_SOCKET_RECV
* [in] value[0].b TA instance id
* [in] value[0].c Socket handle
* [out] memref[1] Buffer to receive
* [in] value[2].a Timeout ms or OPTEE_RPC_SOCKET_TIMEOUT_*
*/
#define OPTEE_RPC_SOCKET_RECV U(4)
/*
* Perform IOCTL on socket
*
* [in] value[0].a OPTEE_RPC_SOCKET_IOCTL
* [in] value[0].b TA instance id
* [in] value[0].c Socket handle
* [in/out] memref[1] Buffer
* [in] value[2].a Ioctl command
*/
#define OPTEE_RPC_SOCKET_IOCTL U(5)
/* End of definition of protocol for command OPTEE_RPC_CMD_SOCKET */
/*
* Definition of protocol for command OPTEE_RPC_CMD_SUPP_PLUGIN
*/
/*
* Invoke tee-supplicant's plugin.
*
* [in] value[0].a OPTEE_RPC_SUPP_PLUGIN_INVOKE
* [in] value[0].b uuid.d1
* [in] value[0].c uuid.d2
* [in] value[1].a uuid.d3
* [in] value[1].b uuid.d4
* [in] value[1].c cmd for plugin
* [in] value[2].a sub_cmd for plugin
* [out] value[2].b length of the outbuf (memref[3]), if out is needed.
* [in/out] memref[3] buffer holding data for plugin
*
* UUID serialized into octets:
* b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15
* d1 | d2 | d3 | d4
*
* The endianness of words d1, d2, d3 and d4 must be little-endian.
* d1 word contains [b3 b2 b1 b0]
* d2 word contains [b7 b6 b5 b4]
* d3 word contains [b11 b10 b9 b8]
* d4 word contains [b15 b14 b13 b12]
*/
#define OPTEE_RPC_SUPP_PLUGIN_INVOKE U(0)
/* End of definition of protocol for command OPTEE_RPC_CMD_SUPP_PLUGIN */
#endif /*__OPTEE_RPC_CMD_H*/