diff options
Diffstat (limited to 'security/tf_driver/tf_protocol.h')
-rw-r--r-- | security/tf_driver/tf_protocol.h | 690 |
1 files changed, 690 insertions, 0 deletions
diff --git a/security/tf_driver/tf_protocol.h b/security/tf_driver/tf_protocol.h new file mode 100644 index 00000000000..403df8ec8ef --- /dev/null +++ b/security/tf_driver/tf_protocol.h | |||
@@ -0,0 +1,690 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2011 Trusted Logic S.A. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * version 2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
17 | * MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #ifndef __TF_PROTOCOL_H__ | ||
21 | #define __TF_PROTOCOL_H__ | ||
22 | |||
23 | /*---------------------------------------------------------------------------- | ||
24 | * | ||
25 | * This header file defines the structure used in the SChannel Protocol. | ||
26 | * See your Product Reference Manual for a specification of the SChannel | ||
27 | * protocol. | ||
28 | *---------------------------------------------------------------------------*/ | ||
29 | |||
30 | /* | ||
31 | * The driver interface version returned by the version ioctl | ||
32 | */ | ||
33 | #define TF_DRIVER_INTERFACE_VERSION 0x04000000 | ||
34 | |||
35 | /* | ||
36 | * Protocol version handling | ||
37 | */ | ||
38 | #define TF_S_PROTOCOL_MAJOR_VERSION (0x06) | ||
39 | #define GET_PROTOCOL_MAJOR_VERSION(a) (a >> 24) | ||
40 | #define GET_PROTOCOL_MINOR_VERSION(a) ((a >> 16) & 0xFF) | ||
41 | |||
42 | /* | ||
43 | * The S flag of the config_flag_s register. | ||
44 | */ | ||
45 | #define TF_CONFIG_FLAG_S (1 << 3) | ||
46 | |||
47 | /* | ||
48 | * The TimeSlot field of the sync_serial_n register. | ||
49 | */ | ||
50 | #define TF_SYNC_SERIAL_TIMESLOT_N (1) | ||
51 | |||
52 | /* | ||
53 | * status_s related defines. | ||
54 | */ | ||
55 | #define TF_STATUS_P_MASK (0X00000001) | ||
56 | #define TF_STATUS_POWER_STATE_SHIFT (3) | ||
57 | #define TF_STATUS_POWER_STATE_MASK (0x1F << TF_STATUS_POWER_STATE_SHIFT) | ||
58 | |||
59 | /* | ||
60 | * Possible power states of the POWER_STATE field of the status_s register | ||
61 | */ | ||
62 | #define TF_POWER_MODE_COLD_BOOT (0) | ||
63 | #define TF_POWER_MODE_WARM_BOOT (1) | ||
64 | #define TF_POWER_MODE_ACTIVE (3) | ||
65 | #define TF_POWER_MODE_READY_TO_SHUTDOWN (5) | ||
66 | #define TF_POWER_MODE_READY_TO_HIBERNATE (7) | ||
67 | #define TF_POWER_MODE_WAKEUP (8) | ||
68 | #define TF_POWER_MODE_PANIC (15) | ||
69 | |||
70 | /* | ||
71 | * Possible command values for MANAGEMENT commands | ||
72 | */ | ||
73 | #define TF_MANAGEMENT_HIBERNATE (1) | ||
74 | #define TF_MANAGEMENT_SHUTDOWN (2) | ||
75 | #define TF_MANAGEMENT_PREPARE_FOR_CORE_OFF (3) | ||
76 | #define TF_MANAGEMENT_RESUME_FROM_CORE_OFF (4) | ||
77 | |||
78 | /* | ||
79 | * The capacity of the Normal Word message queue, in number of slots. | ||
80 | */ | ||
81 | #define TF_N_MESSAGE_QUEUE_CAPACITY (512) | ||
82 | |||
83 | /* | ||
84 | * The capacity of the Secure World message answer queue, in number of slots. | ||
85 | */ | ||
86 | #define TF_S_ANSWER_QUEUE_CAPACITY (256) | ||
87 | |||
88 | /* | ||
89 | * The value of the S-timeout register indicating an infinite timeout. | ||
90 | */ | ||
91 | #define TF_S_TIMEOUT_0_INFINITE (0xFFFFFFFF) | ||
92 | #define TF_S_TIMEOUT_1_INFINITE (0xFFFFFFFF) | ||
93 | |||
94 | /* | ||
95 | * The value of the S-timeout register indicating an immediate timeout. | ||
96 | */ | ||
97 | #define TF_S_TIMEOUT_0_IMMEDIATE (0x0) | ||
98 | #define TF_S_TIMEOUT_1_IMMEDIATE (0x0) | ||
99 | |||
100 | /* | ||
101 | * Identifies the get protocol version SMC. | ||
102 | */ | ||
103 | #define TF_SMC_GET_PROTOCOL_VERSION (0XFFFFFFFB) | ||
104 | |||
105 | /* | ||
106 | * Identifies the init SMC. | ||
107 | */ | ||
108 | #define TF_SMC_INIT (0XFFFFFFFF) | ||
109 | |||
110 | /* | ||
111 | * Identifies the reset irq SMC. | ||
112 | */ | ||
113 | #define TF_SMC_RESET_IRQ (0xFFFFFFFE) | ||
114 | |||
115 | /* | ||
116 | * Identifies the SET_W3B SMC. | ||
117 | */ | ||
118 | #define TF_SMC_WAKE_UP (0xFFFFFFFD) | ||
119 | |||
120 | /* | ||
121 | * Identifies the STOP SMC. | ||
122 | */ | ||
123 | #define TF_SMC_STOP (0xFFFFFFFC) | ||
124 | |||
125 | /* | ||
126 | * Identifies the n-yield SMC. | ||
127 | */ | ||
128 | #define TF_SMC_N_YIELD (0X00000003) | ||
129 | |||
130 | |||
131 | /* Possible stop commands for SMC_STOP */ | ||
132 | #define SCSTOP_HIBERNATE (0xFFFFFFE1) | ||
133 | #define SCSTOP_SHUTDOWN (0xFFFFFFE2) | ||
134 | |||
135 | /* | ||
136 | * representation of an UUID. | ||
137 | */ | ||
138 | struct tf_uuid { | ||
139 | u32 time_low; | ||
140 | u16 time_mid; | ||
141 | u16 time_hi_and_version; | ||
142 | u8 clock_seq_and_node[8]; | ||
143 | }; | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Command parameters. | ||
148 | */ | ||
149 | struct tf_command_param_value { | ||
150 | u32 a; | ||
151 | u32 b; | ||
152 | }; | ||
153 | |||
154 | struct tf_command_param_temp_memref { | ||
155 | u32 descriptor; /* data pointer for exchange message.*/ | ||
156 | u32 size; | ||
157 | u32 offset; | ||
158 | }; | ||
159 | |||
160 | struct tf_command_param_memref { | ||
161 | u32 block; | ||
162 | u32 size; | ||
163 | u32 offset; | ||
164 | }; | ||
165 | |||
166 | union tf_command_param { | ||
167 | struct tf_command_param_value value; | ||
168 | struct tf_command_param_temp_memref temp_memref; | ||
169 | struct tf_command_param_memref memref; | ||
170 | }; | ||
171 | |||
172 | /** | ||
173 | * Answer parameters. | ||
174 | */ | ||
175 | struct tf_answer_param_value { | ||
176 | u32 a; | ||
177 | u32 b; | ||
178 | }; | ||
179 | |||
180 | struct tf_answer_param_size { | ||
181 | u32 _ignored; | ||
182 | u32 size; | ||
183 | }; | ||
184 | |||
185 | union tf_answer_param { | ||
186 | struct tf_answer_param_size size; | ||
187 | struct tf_answer_param_value value; | ||
188 | }; | ||
189 | |||
190 | /* | ||
191 | * Descriptor tables capacity | ||
192 | */ | ||
193 | #define TF_MAX_W3B_COARSE_PAGES (2) | ||
194 | /* TF_MAX_COARSE_PAGES is the number of level 1 descriptors (describing | ||
195 | * 1MB each) that can be shared with the secure world in a single registered | ||
196 | * shared memory block. It must be kept in synch with | ||
197 | * SCHANNEL6_MAX_DESCRIPTORS_PER_REGISTERED_SHARED_MEM in the SChannel | ||
198 | * protocol spec. */ | ||
199 | #define TF_MAX_COARSE_PAGES 128 | ||
200 | #define TF_DESCRIPTOR_TABLE_CAPACITY_BIT_SHIFT (8) | ||
201 | #define TF_DESCRIPTOR_TABLE_CAPACITY \ | ||
202 | (1 << TF_DESCRIPTOR_TABLE_CAPACITY_BIT_SHIFT) | ||
203 | #define TF_DESCRIPTOR_TABLE_CAPACITY_MASK \ | ||
204 | (TF_DESCRIPTOR_TABLE_CAPACITY - 1) | ||
205 | /* Shared memories coarse pages can map up to 1MB */ | ||
206 | #define TF_MAX_COARSE_PAGE_MAPPED_SIZE \ | ||
207 | (PAGE_SIZE * TF_DESCRIPTOR_TABLE_CAPACITY) | ||
208 | /* Shared memories cannot exceed 8MB */ | ||
209 | #define TF_MAX_SHMEM_SIZE \ | ||
210 | (TF_MAX_COARSE_PAGE_MAPPED_SIZE << 3) | ||
211 | |||
212 | /* | ||
213 | * Buffer size for version description fields | ||
214 | */ | ||
215 | #define TF_DESCRIPTION_BUFFER_LENGTH 64 | ||
216 | |||
217 | /* | ||
218 | * Shared memory type flags. | ||
219 | */ | ||
220 | #define TF_SHMEM_TYPE_READ (0x00000001) | ||
221 | #define TF_SHMEM_TYPE_WRITE (0x00000002) | ||
222 | |||
223 | /* | ||
224 | * Shared mem flags | ||
225 | */ | ||
226 | #define TF_SHARED_MEM_FLAG_INPUT 1 | ||
227 | #define TF_SHARED_MEM_FLAG_OUTPUT 2 | ||
228 | #define TF_SHARED_MEM_FLAG_INOUT 3 | ||
229 | |||
230 | |||
231 | /* | ||
232 | * Parameter types | ||
233 | */ | ||
234 | #define TF_PARAM_TYPE_NONE 0x0 | ||
235 | #define TF_PARAM_TYPE_VALUE_INPUT 0x1 | ||
236 | #define TF_PARAM_TYPE_VALUE_OUTPUT 0x2 | ||
237 | #define TF_PARAM_TYPE_VALUE_INOUT 0x3 | ||
238 | #define TF_PARAM_TYPE_MEMREF_TEMP_INPUT 0x5 | ||
239 | #define TF_PARAM_TYPE_MEMREF_TEMP_OUTPUT 0x6 | ||
240 | #define TF_PARAM_TYPE_MEMREF_TEMP_INOUT 0x7 | ||
241 | #define TF_PARAM_TYPE_MEMREF_INPUT 0xD | ||
242 | #define TF_PARAM_TYPE_MEMREF_OUTPUT 0xE | ||
243 | #define TF_PARAM_TYPE_MEMREF_INOUT 0xF | ||
244 | |||
245 | #define TF_PARAM_TYPE_MEMREF_FLAG 0x4 | ||
246 | #define TF_PARAM_TYPE_REGISTERED_MEMREF_FLAG 0x8 | ||
247 | |||
248 | |||
249 | #define TF_MAKE_PARAM_TYPES(t0, t1, t2, t3) \ | ||
250 | ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12)) | ||
251 | #define TF_GET_PARAM_TYPE(t, i) (((t) >> (4 * i)) & 0xF) | ||
252 | |||
253 | /* | ||
254 | * Login types. | ||
255 | */ | ||
256 | #define TF_LOGIN_PUBLIC 0x00000000 | ||
257 | #define TF_LOGIN_USER 0x00000001 | ||
258 | #define TF_LOGIN_GROUP 0x00000002 | ||
259 | #define TF_LOGIN_APPLICATION 0x00000004 | ||
260 | #define TF_LOGIN_APPLICATION_USER 0x00000005 | ||
261 | #define TF_LOGIN_APPLICATION_GROUP 0x00000006 | ||
262 | #define TF_LOGIN_AUTHENTICATION 0x80000000 | ||
263 | #define TF_LOGIN_PRIVILEGED 0x80000002 | ||
264 | |||
265 | /* Login variants */ | ||
266 | |||
267 | #define TF_LOGIN_VARIANT(main_type, os, variant) \ | ||
268 | ((main_type) | (1 << 27) | ((os) << 16) | ((variant) << 8)) | ||
269 | |||
270 | #define TF_LOGIN_GET_MAIN_TYPE(type) \ | ||
271 | ((type) & ~TF_LOGIN_VARIANT(0, 0xFF, 0xFF)) | ||
272 | |||
273 | #define TF_LOGIN_OS_ANY 0x00 | ||
274 | #define TF_LOGIN_OS_LINUX 0x01 | ||
275 | #define TF_LOGIN_OS_ANDROID 0x04 | ||
276 | |||
277 | /* OS-independent variants */ | ||
278 | #define TF_LOGIN_USER_NONE \ | ||
279 | TF_LOGIN_VARIANT(TF_LOGIN_USER, TF_LOGIN_OS_ANY, 0xFF) | ||
280 | #define TF_LOGIN_GROUP_NONE \ | ||
281 | TF_LOGIN_VARIANT(TF_LOGIN_GROUP, TF_LOGIN_OS_ANY, 0xFF) | ||
282 | #define TF_LOGIN_APPLICATION_USER_NONE \ | ||
283 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION_USER, TF_LOGIN_OS_ANY, 0xFF) | ||
284 | #define TF_LOGIN_AUTHENTICATION_BINARY_SHA1_HASH \ | ||
285 | TF_LOGIN_VARIANT(TF_LOGIN_AUTHENTICATION, TF_LOGIN_OS_ANY, 0x01) | ||
286 | #define TF_LOGIN_PRIVILEGED_KERNEL \ | ||
287 | TF_LOGIN_VARIANT(TF_LOGIN_PRIVILEGED, TF_LOGIN_OS_ANY, 0x01) | ||
288 | |||
289 | /* Linux variants */ | ||
290 | #define TF_LOGIN_USER_LINUX_EUID \ | ||
291 | TF_LOGIN_VARIANT(TF_LOGIN_USER, TF_LOGIN_OS_LINUX, 0x01) | ||
292 | #define TF_LOGIN_GROUP_LINUX_GID \ | ||
293 | TF_LOGIN_VARIANT(TF_LOGIN_GROUP, TF_LOGIN_OS_LINUX, 0x01) | ||
294 | #define TF_LOGIN_APPLICATION_LINUX_PATH_SHA1_HASH \ | ||
295 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION, TF_LOGIN_OS_LINUX, 0x01) | ||
296 | #define TF_LOGIN_APPLICATION_USER_LINUX_PATH_EUID_SHA1_HASH \ | ||
297 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION_USER, TF_LOGIN_OS_LINUX, 0x01) | ||
298 | #define TF_LOGIN_APPLICATION_GROUP_LINUX_PATH_GID_SHA1_HASH \ | ||
299 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION_GROUP, TF_LOGIN_OS_LINUX, 0x01) | ||
300 | |||
301 | /* Android variants */ | ||
302 | #define TF_LOGIN_USER_ANDROID_EUID \ | ||
303 | TF_LOGIN_VARIANT(TF_LOGIN_USER, TF_LOGIN_OS_ANDROID, 0x01) | ||
304 | #define TF_LOGIN_GROUP_ANDROID_GID \ | ||
305 | TF_LOGIN_VARIANT(TF_LOGIN_GROUP, TF_LOGIN_OS_ANDROID, 0x01) | ||
306 | #define TF_LOGIN_APPLICATION_ANDROID_UID \ | ||
307 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION, TF_LOGIN_OS_ANDROID, 0x01) | ||
308 | #define TF_LOGIN_APPLICATION_USER_ANDROID_UID_EUID \ | ||
309 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION_USER, TF_LOGIN_OS_ANDROID, \ | ||
310 | 0x01) | ||
311 | #define TF_LOGIN_APPLICATION_GROUP_ANDROID_UID_GID \ | ||
312 | TF_LOGIN_VARIANT(TF_LOGIN_APPLICATION_GROUP, TF_LOGIN_OS_ANDROID, \ | ||
313 | 0x01) | ||
314 | |||
315 | /* | ||
316 | * return origins | ||
317 | */ | ||
318 | #define TF_ORIGIN_COMMS 2 | ||
319 | #define TF_ORIGIN_TEE 3 | ||
320 | #define TF_ORIGIN_TRUSTED_APP 4 | ||
321 | /* | ||
322 | * The message types. | ||
323 | */ | ||
324 | #define TF_MESSAGE_TYPE_CREATE_DEVICE_CONTEXT 0x02 | ||
325 | #define TF_MESSAGE_TYPE_DESTROY_DEVICE_CONTEXT 0xFD | ||
326 | #define TF_MESSAGE_TYPE_REGISTER_SHARED_MEMORY 0xF7 | ||
327 | #define TF_MESSAGE_TYPE_RELEASE_SHARED_MEMORY 0xF9 | ||
328 | #define TF_MESSAGE_TYPE_OPEN_CLIENT_SESSION 0xF0 | ||
329 | #define TF_MESSAGE_TYPE_CLOSE_CLIENT_SESSION 0xF2 | ||
330 | #define TF_MESSAGE_TYPE_INVOKE_CLIENT_COMMAND 0xF5 | ||
331 | #define TF_MESSAGE_TYPE_CANCEL_CLIENT_COMMAND 0xF4 | ||
332 | #define TF_MESSAGE_TYPE_MANAGEMENT 0xFE | ||
333 | |||
334 | |||
335 | /* | ||
336 | * The SChannel error codes. | ||
337 | */ | ||
338 | #define S_SUCCESS 0x00000000 | ||
339 | #define S_ERROR_OUT_OF_MEMORY 0xFFFF000C | ||
340 | |||
341 | |||
342 | struct tf_command_header { | ||
343 | u8 message_size; | ||
344 | u8 message_type; | ||
345 | u16 message_info; | ||
346 | u32 operation_id; | ||
347 | }; | ||
348 | |||
349 | struct tf_answer_header { | ||
350 | u8 message_size; | ||
351 | u8 message_type; | ||
352 | u16 message_info; | ||
353 | u32 operation_id; | ||
354 | u32 error_code; | ||
355 | }; | ||
356 | |||
357 | /* | ||
358 | * CREATE_DEVICE_CONTEXT command message. | ||
359 | */ | ||
360 | struct tf_command_create_device_context { | ||
361 | u8 message_size; | ||
362 | u8 message_type; | ||
363 | u16 message_info_rfu; | ||
364 | u32 operation_id; | ||
365 | u32 device_context_id; | ||
366 | }; | ||
367 | |||
368 | /* | ||
369 | * CREATE_DEVICE_CONTEXT answer message. | ||
370 | */ | ||
371 | struct tf_answer_create_device_context { | ||
372 | u8 message_size; | ||
373 | u8 message_type; | ||
374 | u16 message_info_rfu; | ||
375 | /* an opaque Normal World identifier for the operation */ | ||
376 | u32 operation_id; | ||
377 | u32 error_code; | ||
378 | /* an opaque Normal World identifier for the device context */ | ||
379 | u32 device_context; | ||
380 | }; | ||
381 | |||
382 | /* | ||
383 | * DESTROY_DEVICE_CONTEXT command message. | ||
384 | */ | ||
385 | struct tf_command_destroy_device_context { | ||
386 | u8 message_size; | ||
387 | u8 message_type; | ||
388 | u16 message_info_rfu; | ||
389 | u32 operation_id; | ||
390 | u32 device_context; | ||
391 | }; | ||
392 | |||
393 | /* | ||
394 | * DESTROY_DEVICE_CONTEXT answer message. | ||
395 | */ | ||
396 | struct tf_answer_destroy_device_context { | ||
397 | u8 message_size; | ||
398 | u8 message_type; | ||
399 | u16 message_info_rfu; | ||
400 | /* an opaque Normal World identifier for the operation */ | ||
401 | u32 operation_id; | ||
402 | u32 error_code; | ||
403 | u32 device_context_id; | ||
404 | }; | ||
405 | |||
406 | /* | ||
407 | * OPEN_CLIENT_SESSION command message. | ||
408 | */ | ||
409 | struct tf_command_open_client_session { | ||
410 | u8 message_size; | ||
411 | u8 message_type; | ||
412 | u16 param_types; | ||
413 | /* an opaque Normal World identifier for the operation */ | ||
414 | u32 operation_id; | ||
415 | u32 device_context; | ||
416 | u32 cancellation_id; | ||
417 | u64 timeout; | ||
418 | struct tf_uuid destination_uuid; | ||
419 | union tf_command_param params[4]; | ||
420 | u32 login_type; | ||
421 | /* | ||
422 | * Size = 0 for public, [16] for group identification, [20] for | ||
423 | * authentication | ||
424 | */ | ||
425 | u8 login_data[20]; | ||
426 | }; | ||
427 | |||
428 | /* | ||
429 | * OPEN_CLIENT_SESSION answer message. | ||
430 | */ | ||
431 | struct tf_answer_open_client_session { | ||
432 | u8 message_size; | ||
433 | u8 message_type; | ||
434 | u8 error_origin; | ||
435 | u8 __reserved; | ||
436 | /* an opaque Normal World identifier for the operation */ | ||
437 | u32 operation_id; | ||
438 | u32 error_code; | ||
439 | u32 client_session; | ||
440 | union tf_answer_param answers[4]; | ||
441 | }; | ||
442 | |||
443 | /* | ||
444 | * CLOSE_CLIENT_SESSION command message. | ||
445 | */ | ||
446 | struct tf_command_close_client_session { | ||
447 | u8 message_size; | ||
448 | u8 message_type; | ||
449 | u16 message_info_rfu; | ||
450 | /* an opaque Normal World identifier for the operation */ | ||
451 | u32 operation_id; | ||
452 | u32 device_context; | ||
453 | u32 client_session; | ||
454 | }; | ||
455 | |||
456 | /* | ||
457 | * CLOSE_CLIENT_SESSION answer message. | ||
458 | */ | ||
459 | struct tf_answer_close_client_session { | ||
460 | u8 message_size; | ||
461 | u8 message_type; | ||
462 | u16 message_info_rfu; | ||
463 | /* an opaque Normal World identifier for the operation */ | ||
464 | u32 operation_id; | ||
465 | u32 error_code; | ||
466 | }; | ||
467 | |||
468 | |||
469 | /* | ||
470 | * REGISTER_SHARED_MEMORY command message | ||
471 | */ | ||
472 | struct tf_command_register_shared_memory { | ||
473 | u8 message_size; | ||
474 | u8 message_type; | ||
475 | u16 memory_flags; | ||
476 | u32 operation_id; | ||
477 | u32 device_context; | ||
478 | u32 block_id; | ||
479 | u32 shared_mem_size; | ||
480 | u32 shared_mem_start_offset; | ||
481 | u32 shared_mem_descriptors[TF_MAX_COARSE_PAGES]; | ||
482 | }; | ||
483 | |||
484 | /* | ||
485 | * REGISTER_SHARED_MEMORY answer message. | ||
486 | */ | ||
487 | struct tf_answer_register_shared_memory { | ||
488 | u8 message_size; | ||
489 | u8 message_type; | ||
490 | u16 message_info_rfu; | ||
491 | /* an opaque Normal World identifier for the operation */ | ||
492 | u32 operation_id; | ||
493 | u32 error_code; | ||
494 | u32 block; | ||
495 | }; | ||
496 | |||
497 | /* | ||
498 | * RELEASE_SHARED_MEMORY command message. | ||
499 | */ | ||
500 | struct tf_command_release_shared_memory { | ||
501 | u8 message_size; | ||
502 | u8 message_type; | ||
503 | u16 message_info_rfu; | ||
504 | /* an opaque Normal World identifier for the operation */ | ||
505 | u32 operation_id; | ||
506 | u32 device_context; | ||
507 | u32 block; | ||
508 | }; | ||
509 | |||
510 | /* | ||
511 | * RELEASE_SHARED_MEMORY answer message. | ||
512 | */ | ||
513 | struct tf_answer_release_shared_memory { | ||
514 | u8 message_size; | ||
515 | u8 message_type; | ||
516 | u16 message_info_rfu; | ||
517 | u32 operation_id; | ||
518 | u32 error_code; | ||
519 | u32 block_id; | ||
520 | }; | ||
521 | |||
522 | /* | ||
523 | * INVOKE_CLIENT_COMMAND command message. | ||
524 | */ | ||
525 | struct tf_command_invoke_client_command { | ||
526 | u8 message_size; | ||
527 | u8 message_type; | ||
528 | u16 param_types; | ||
529 | u32 operation_id; | ||
530 | u32 device_context; | ||
531 | u32 client_session; | ||
532 | u64 timeout; | ||
533 | u32 cancellation_id; | ||
534 | u32 client_command_identifier; | ||
535 | union tf_command_param params[4]; | ||
536 | }; | ||
537 | |||
538 | /* | ||
539 | * INVOKE_CLIENT_COMMAND command answer. | ||
540 | */ | ||
541 | struct tf_answer_invoke_client_command { | ||
542 | u8 message_size; | ||
543 | u8 message_type; | ||
544 | u8 error_origin; | ||
545 | u8 __reserved; | ||
546 | u32 operation_id; | ||
547 | u32 error_code; | ||
548 | union tf_answer_param answers[4]; | ||
549 | }; | ||
550 | |||
551 | /* | ||
552 | * CANCEL_CLIENT_OPERATION command message. | ||
553 | */ | ||
554 | struct tf_command_cancel_client_operation { | ||
555 | u8 message_size; | ||
556 | u8 message_type; | ||
557 | u16 message_info_rfu; | ||
558 | /* an opaque Normal World identifier for the operation */ | ||
559 | u32 operation_id; | ||
560 | u32 device_context; | ||
561 | u32 client_session; | ||
562 | u32 cancellation_id; | ||
563 | }; | ||
564 | |||
565 | struct tf_answer_cancel_client_operation { | ||
566 | u8 message_size; | ||
567 | u8 message_type; | ||
568 | u16 message_info_rfu; | ||
569 | u32 operation_id; | ||
570 | u32 error_code; | ||
571 | }; | ||
572 | |||
573 | /* | ||
574 | * MANAGEMENT command message. | ||
575 | */ | ||
576 | struct tf_command_management { | ||
577 | u8 message_size; | ||
578 | u8 message_type; | ||
579 | u16 command; | ||
580 | u32 operation_id; | ||
581 | u32 w3b_size; | ||
582 | u32 w3b_start_offset; | ||
583 | u32 shared_mem_descriptors[1]; | ||
584 | }; | ||
585 | |||
586 | /* | ||
587 | * POWER_MANAGEMENT answer message. | ||
588 | * The message does not provide message specific parameters. | ||
589 | * Therefore no need to define a specific answer structure | ||
590 | */ | ||
591 | |||
592 | /* | ||
593 | * Structure for L2 messages | ||
594 | */ | ||
595 | union tf_command { | ||
596 | struct tf_command_header header; | ||
597 | struct tf_command_create_device_context create_device_context; | ||
598 | struct tf_command_destroy_device_context destroy_device_context; | ||
599 | struct tf_command_open_client_session open_client_session; | ||
600 | struct tf_command_close_client_session close_client_session; | ||
601 | struct tf_command_register_shared_memory register_shared_memory; | ||
602 | struct tf_command_release_shared_memory release_shared_memory; | ||
603 | struct tf_command_invoke_client_command invoke_client_command; | ||
604 | struct tf_command_cancel_client_operation cancel_client_operation; | ||
605 | struct tf_command_management management; | ||
606 | }; | ||
607 | |||
608 | /* | ||
609 | * Structure for any L2 answer | ||
610 | */ | ||
611 | |||
612 | union tf_answer { | ||
613 | struct tf_answer_header header; | ||
614 | struct tf_answer_create_device_context create_device_context; | ||
615 | struct tf_answer_open_client_session open_client_session; | ||
616 | struct tf_answer_close_client_session close_client_session; | ||
617 | struct tf_answer_register_shared_memory register_shared_memory; | ||
618 | struct tf_answer_release_shared_memory release_shared_memory; | ||
619 | struct tf_answer_invoke_client_command invoke_client_command; | ||
620 | struct tf_answer_destroy_device_context destroy_device_context; | ||
621 | struct tf_answer_cancel_client_operation cancel_client_operation; | ||
622 | }; | ||
623 | |||
624 | /* Structure of the Communication Buffer */ | ||
625 | struct tf_l1_shared_buffer { | ||
626 | #ifdef CONFIG_TF_ZEBRA | ||
627 | u32 exit_code; | ||
628 | u32 l1_shared_buffer_descr; | ||
629 | u32 backing_store_addr; | ||
630 | u32 backext_storage_addr; | ||
631 | u32 workspace_addr; | ||
632 | u32 workspace_size; | ||
633 | u32 conf_descriptor; | ||
634 | u32 conf_size; | ||
635 | u32 conf_offset; | ||
636 | u32 protocol_version; | ||
637 | u32 rpc_command; | ||
638 | u32 rpc_status; | ||
639 | u8 reserved1[16]; | ||
640 | #else | ||
641 | u32 config_flag_s; | ||
642 | u32 w3b_size_max_s; | ||
643 | u32 reserved0; | ||
644 | u32 w3b_size_current_s; | ||
645 | u8 reserved1[48]; | ||
646 | #endif | ||
647 | u8 version_description[TF_DESCRIPTION_BUFFER_LENGTH]; | ||
648 | u32 status_s; | ||
649 | u32 reserved2; | ||
650 | u32 sync_serial_n; | ||
651 | u32 sync_serial_s; | ||
652 | u64 time_n[2]; | ||
653 | u64 timeout_s[2]; | ||
654 | u32 first_command; | ||
655 | u32 first_free_command; | ||
656 | u32 first_answer; | ||
657 | u32 first_free_answer; | ||
658 | u32 w3b_descriptors[128]; | ||
659 | #ifdef CONFIG_TF_ZEBRA | ||
660 | u8 rpc_trace_buffer[140]; | ||
661 | u8 rpc_cus_buffer[180]; | ||
662 | #else | ||
663 | u8 reserved3[320]; | ||
664 | #endif | ||
665 | u32 command_queue[TF_N_MESSAGE_QUEUE_CAPACITY]; | ||
666 | u32 answer_queue[TF_S_ANSWER_QUEUE_CAPACITY]; | ||
667 | }; | ||
668 | |||
669 | |||
670 | /* | ||
671 | * tf_version_information_buffer structure description | ||
672 | * Description of the sVersionBuffer handed over from user space to kernel space | ||
673 | * This field is filled by the driver during a CREATE_DEVICE_CONTEXT ioctl | ||
674 | * and handed back to user space | ||
675 | */ | ||
676 | struct tf_version_information_buffer { | ||
677 | u8 driver_description[65]; | ||
678 | u8 secure_world_description[65]; | ||
679 | }; | ||
680 | |||
681 | |||
682 | /* The IOCTLs the driver supports */ | ||
683 | #include <linux/ioctl.h> | ||
684 | |||
685 | #define IOCTL_TF_GET_VERSION _IO('z', 0) | ||
686 | #define IOCTL_TF_EXCHANGE _IOWR('z', 1, union tf_command) | ||
687 | #define IOCTL_TF_GET_DESCRIPTION _IOR('z', 2, \ | ||
688 | struct tf_version_information_buffer) | ||
689 | |||
690 | #endif /* !defined(__TF_PROTOCOL_H__) */ | ||