2 * Copyright (c) 2014, Linaro Limited
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.
18 * This section depends on uint64_t, uint32_t uint8_t already being
19 * defined. Since this file is used in several different environments
20 * (secure world OS and normal world Linux kernel to start with) where
21 * stdint.h may not be available it's the responsibility of the one
22 * including this file to provide those types.
26 * Trusted OS SMC interface.
28 * The SMC interface follows SMC Calling Convention
29 * (ARM_DEN0028A_SMC_Calling_Convention).
31 * The primary objective of this API is to provide a transport layer on
32 * which a Global Platform compliant TEE interfaces can be deployed. But the
33 * interface can also be used for other implementations.
35 * This file is divided in two parts.
36 * Part 1 deals with passing parameters to Trusted Applications running in
37 * a trusted OS in secure world.
38 * Part 2 deals with the lower level handling of the SMC.
42 *******************************************************************************
43 * Part 1 - passing parameters to Trusted Applications
44 *******************************************************************************
48 * Same values as TEE_PARAM_* from TEE Internal API
50 #define TEESMC_ATTR_TYPE_NONE 0
51 #define TEESMC_ATTR_TYPE_VALUE_INPUT 1
52 #define TEESMC_ATTR_TYPE_VALUE_OUTPUT 2
53 #define TEESMC_ATTR_TYPE_VALUE_INOUT 3
54 #define TEESMC_ATTR_TYPE_MEMREF_INPUT 5
55 #define TEESMC_ATTR_TYPE_MEMREF_OUTPUT 6
56 #define TEESMC_ATTR_TYPE_MEMREF_INOUT 7
58 #define TEESMC_ATTR_TYPE_MASK 0x7
61 * Meta parameter to be absorbed by the Secure OS and not passed
62 * to the Trusted Application.
64 * One example of this is a struct teesmc_meta_open_session which
65 * is added to TEESMC{32,64}_CMD_OPEN_SESSION.
67 #define TEESMC_ATTR_META 0x8
70 * Used as an indication from normal world of compatible cache usage.
71 * 'I' stands for inner cache and 'O' for outer cache.
73 #define TEESMC_ATTR_CACHE_I_NONCACHE 0x0
74 #define TEESMC_ATTR_CACHE_I_WRITE_THR 0x1
75 #define TEESMC_ATTR_CACHE_I_WRITE_BACK 0x2
76 #define TEESMC_ATTR_CACHE_O_NONCACHE 0x0
77 #define TEESMC_ATTR_CACHE_O_WRITE_THR 0x4
78 #define TEESMC_ATTR_CACHE_O_WRITE_BACK 0x8
80 #define TEESMC_ATTR_CACHE_NONCACHE (TEESMC_ATTR_CACHE_I_NONCACHE | \
81 TEESMC_ATTR_CACHE_O_NONCACHE)
82 #define TEESMC_ATTR_CACHE_DEFAULT (TEESMC_ATTR_CACHE_I_WRITE_BACK | \
83 TEESMC_ATTR_CACHE_O_WRITE_BACK)
85 #define TEESMC_ATTR_CACHE_SHIFT 4
86 #define TEESMC_ATTR_CACHE_MASK 0xf
88 #define TEESMC_CMD_OPEN_SESSION 0
89 #define TEESMC_CMD_INVOKE_COMMAND 1
90 #define TEESMC_CMD_CLOSE_SESSION 2
91 #define TEESMC_CMD_CANCEL 3
94 * struct teesmc32_param_memref - memory reference
95 * @buf_ptr: Address of the buffer
96 * @size: Size of the buffer
98 * Secure and normal world communicates pointer via physical address instead of
99 * the virtual address with is usually used for pointers. This is because
100 * Secure and normal world has completely independant memory mapping. Normal
101 * world can even have a hypervisor which need to translate the guest
102 * physical address (AKA IPA in ARM lingo) to a real physical address
103 * before passing the structure to secure world.
105 struct teesmc32_param_memref {
111 * struct teesmc32_param_memref - memory reference
112 * @buf_ptr: Address of the buffer
113 * @size: Size of the buffer
115 * See description of struct teesmc32_param_memref.
117 struct teesmc64_param_memref {
123 * struct teesmc32_param_value - values
127 struct teesmc32_param_value {
133 * struct teesmc64_param_value - values
137 struct teesmc64_param_value {
143 * struct teesmc32_param - parameter
145 * @memref: a memory reference
148 * attr & TEESMC_ATTR_TYPE_MASK indicates if memref or value is used in the
149 * union. TEESMC_ATTR_TYPE_VALUE_* indicates value and
150 * TEESMC_ATTR_TYPE_MEMREF_* indicates memref. TEESMC_ATTR_TYPE_NONE
151 * indicates that none of the members are used.
153 struct teesmc32_param {
156 struct teesmc32_param_memref memref;
157 struct teesmc32_param_value value;
162 * struct teesmc64_param - parameter
164 * @memref: a memory reference
167 * See description of union teesmc32_param.
169 struct teesmc64_param {
172 struct teesmc64_param_memref memref;
173 struct teesmc64_param_value value;
178 * struct teesmc32_arg - SMC argument for Trusted OS
179 * @cmd: Command, one of TEESMC_CMD_*
180 * @ta_func: Trusted Application function, specific to the Trusted Application,
181 * used if cmd == TEESMC_CMD_INVOKE_COMMAND
182 * @session: In parameter for all TEESMC_CMD_* except
183 * TEESMC_CMD_OPEN_SESSION where it's an output paramter instead
185 * @ret_origin: origin of the return value
186 * @num_params: number of parameters supplied to the OS Command
187 * @params: the parameters supplied to the OS Command
189 * All normal SMC calls to Trusted OS uses this struct. If cmd requires
190 * further information than what these field holds it can be passed as a
191 * parameter tagged as meta (setting the TEESMC_ATTR_META bit in
192 * corresponding param_attrs). This is used for TEESMC_CMD_OPEN_SESSION
193 * to pass a struct teesmc32_meta_open_session which is needed find the
194 * Trusted Application and to indicate the credentials of the client.
196 struct teesmc32_arg {
204 * Commented out elements used to visualize the layout dynamic part
205 * of the struct. Note that these fields are not available at all
206 * if num_params == 0.
208 * params is accessed through the macro TEESMC32_GET_PARAMS
211 /* struct teesmc32_param params[num_params]; */
215 * TEESMC32_GET_PARAMS - return pointer to union teesmc32_param *
217 * @x: Pointer to a struct teesmc32_arg
219 * Returns a pointer to the params[] inside a struct teesmc32_arg.
221 #define TEESMC32_GET_PARAMS(x) \
222 (struct teesmc32_param *)(((struct teesmc32_arg *)(x)) + 1)
225 * TEESMC32_GET_ARG_SIZE - return size of struct teesmc32_arg
227 * @num_params: Number of parameters embedded in the struct teesmc32_arg
229 * Returns the size of the struct teesmc32_arg together with the number
230 * of embedded paramters.
232 #define TEESMC32_GET_ARG_SIZE(num_params) \
233 (sizeof(struct teesmc32_arg) + \
234 sizeof(struct teesmc32_param) * (num_params))
237 * struct teesmc64_arg - SMC argument for Trusted OS
238 * @cmd: OS Command, one of TEESMC_CMD_*
239 * @ta_func: Trusted Application function, specific to the Trusted Application
240 * @session: In parameter for all TEESMC_CMD_* but
241 * TEESMC_CMD_OPEN_SESSION
243 * @ret_origin: origin of the return value
244 * @num_params: number of parameters supplied to the OS Command
245 * @params: the parameters supplied to the OS Command
247 * See description of struct teesmc32_arg.
249 struct teesmc64_arg {
257 * Commented out elements used to visualize the layout dynamic part
258 * of the struct. Note that these fields are not available at all
259 * if num_params == 0.
261 * params is accessed through the macro TEESMC64_GET_PARAMS
264 /* struct teesmc64_param params[num_params]; */
268 * TEESMC64_GET_PARAMS - return pointer to union teesmc64_param *
270 * @x: Pointer to a struct teesmc64_arg
272 * Returns a pointer to the params[] inside a struct teesmc64_arg.
274 #define TEESMC64_GET_PARAMS(x) \
275 (struct teesmc64_param *)(((struct teesmc64_arg *)(x)) + 1)
278 * TEESMC64_GET_ARG_SIZE - return size of struct teesmc64_arg
280 * @num_params: Number of parameters embedded in the struct teesmc64_arg
282 * Returns the size of the struct teesmc64_arg together with the number
283 * of embedded paramters.
285 #define TEESMC64_GET_ARG_SIZE(num_params) \
286 (sizeof(struct teesmc64_arg) + \
287 sizeof(union teesmc64_param) * (num_params))
289 #define TEESMC_UUID_LEN 16
292 * struct teesmc_meta_open_session - additional parameters for
293 * TEESMC32_CMD_OPEN_SESSION and
294 * TEESMC64_CMD_OPEN_SESSION
295 * @uuid: UUID of the Trusted Application
296 * @clnt_uuid: UUID of client
297 * @clnt_login: Login class of client, TEE_LOGIN_* if being Global Platform
300 * This struct is passed in the first parameter as an input memref tagged
301 * as meta on an TEESMC{32,64}_CMD_OPEN_SESSION cmd. It's important
302 * that it really is the first parameter to make it easy for an eventual
303 * hypervisor to inspect and possibly update clnt_* values.
305 struct teesmc_meta_open_session {
306 uint8_t uuid[TEESMC_UUID_LEN];
307 uint8_t clnt_uuid[TEESMC_UUID_LEN];
315 *******************************************************************************
316 * Part 2 - low level SMC interaction
317 *******************************************************************************
321 #define TEESMC_64 0x40000000
322 #define TEESMC_FAST_CALL 0x80000000
323 #define TEESMC_STD_CALL 0
325 #define TEESMC_OWNER_MASK 0x3F
326 #define TEESMC_OWNER_SHIFT 24
328 #define TEESMC_FUNC_MASK 0xFFFF
330 #define TEESMC_IS_FAST_CALL(smc_val) ((smc_val) & TEESMC_FAST_CALL)
331 #define TEESMC_IS_64(smc_val) ((smc_val) & TEESMC_64)
332 #define TEESMC_FUNC_NUM(smc_val) ((smc_val) & TEESMC_FUNC_MASK)
333 #define TEESMC_OWNER_NUM(smc_val) (((smc_val) >> TEESMC_OWNER_SHIFT) & \
336 #define TEESMC_CALL_VAL(type, calling_convention, owner, func_num) \
337 ((type) | (calling_convention) | \
338 (((owner) & TEESMC_OWNER_MASK) << TEESMC_OWNER_SHIFT) |\
339 ((func_num) & TEESMC_FUNC_MASK))
341 #define TEESMC_OWNER_ARCH 0
342 #define TEESMC_OWNER_CPU 1
343 #define TEESMC_OWNER_SIP 2
344 #define TEESMC_OWNER_OEM 3
345 #define TEESMC_OWNER_STANDARD 4
346 #define TEESMC_OWNER_TRUSTED_APP 48
347 #define TEESMC_OWNER_TRUSTED_OS 50
349 #define TEESMC_OWNER_TRUSTED_OS_API 63
352 * Function specified by SMC Calling convention.
354 #define TEESMC32_FUNCID_CALLS_COUNT 0xFF00
355 #define TEESMC32_CALLS_COUNT \
356 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, \
357 TEESMC_OWNER_TRUSTED_OS_API, \
358 TEESMC32_FUNCID_CALLS_COUNT)
361 * Function specified by SMC Calling convention
363 * Return one of the following UIDs if using API specified in this file
364 * without further extentions:
365 * 65cb6b93-af0c-4617-8ed6-644a8d1140f8 : Only 32 bit calls are supported
366 * 65cb6b93-af0c-4617-8ed6-644a8d1140f9 : Both 32 and 64 bit calls are supported
368 #define TEESMC_UID_R0 0x65cb6b93
369 #define TEESMC_UID_R1 0xaf0c4617
370 #define TEESMC_UID_R2 0x8ed6644a
371 #define TEESMC_UID32_R3 0x8d1140f8
372 #define TEESMC_UID64_R3 0x8d1140f9
373 #define TEESMC32_FUNCID_CALLS_UID 0xFF01
374 #define TEESMC32_CALLS_UID \
375 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, \
376 TEESMC_OWNER_TRUSTED_OS_API, \
377 TEESMC32_FUNCID_CALLS_UID)
380 * Function specified by SMC Calling convention
382 * Returns 1.0 if using API specified in this file without further extentions.
384 #define TEESMC_REVISION_MAJOR 1
385 #define TEESMC_REVISION_MINOR 0
386 #define TEESMC32_FUNCID_CALLS_REVISION 0xFF03
387 #define TEESMC32_CALLS_REVISION \
388 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, \
389 TEESMC_OWNER_TRUSTED_OS_API, \
390 TEESMC32_FUNCID_CALLS_REVISION)
393 * Get UUID of Trusted OS.
395 * Used by non-secure world to figure out which Trusted OS is installed.
396 * Note that returned UUID is the UUID of the Trusted OS, not of the API.
398 * Returns UUID in r0-4/w0-4 in the same way as TEESMC32_CALLS_UID
401 #define TEESMC_FUNCID_GET_OS_UUID 0
402 #define TEESMC32_CALL_GET_OS_UUID \
403 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
404 TEESMC_FUNCID_GET_OS_UUID)
407 * Get revision of Trusted OS.
409 * Used by non-secure world to figure out which version of the Trusted OS
410 * is installed. Note that the returned revision is the revision of the
411 * Trusted OS, not of the API.
413 * Returns revision in r0-1/w0-1 in the same way as TEESMC32_CALLS_REVISION
416 #define TEESMC_FUNCID_GET_OS_REVISION 1
417 #define TEESMC32_CALL_GET_OS_REVISION \
418 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
419 TEESMC_FUNCID_GET_OS_REVISION)
424 * Call with struct teesmc32_arg as argument
426 * Call register usage:
427 * r0/x0 SMC Function ID, TEESMC32_CALL_WITH_ARG
428 * r1/x1 Physical pointer to a struct teesmc32_arg
430 * r7/x7 Hypervisor Client ID register
432 * Normal return register usage:
433 * r0/x0 Return value, TEESMC_RETURN_*
435 * r4-7/x4-7 Preserved
437 * Ebusy return register usage:
438 * r0/x0 Return value, TEESMC_RETURN_EBUSY
439 * r1-3/x1-3 Preserved
440 * r4-7/x4-7 Preserved
442 * RPC return register usage:
443 * r0/x0 Return value, TEESMC_RETURN_IS_RPC(val)
444 * r1-2/x1-2 RPC parameters
445 * r3-7/x3-7 Resume information, must be preserved
447 * Possible return values:
448 * TEESMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this
450 * TEESMC_RETURN_OK Call completed, result updated in
451 * the previously supplied struct
453 * TEESMC_RETURN_EBUSY Trusted OS busy, try again later.
454 * TEESMC_RETURN_EBADADDR Bad physcial pointer to struct
456 * TEESMC_RETURN_EBADCMD Bad/unknown cmd in struct teesmc32_arg
457 * TEESMC_RETURN_IS_RPC() Call suspended by RPC call to normal
460 #define TEESMC_FUNCID_CALL_WITH_ARG 2
461 #define TEESMC32_CALL_WITH_ARG \
462 TEESMC_CALL_VAL(TEESMC_32, TEESMC_STD_CALL, TEESMC_OWNER_TRUSTED_OS, \
463 TEESMC_FUNCID_CALL_WITH_ARG)
464 /* Same as TEESMC32_CALL_WITH_ARG but a "fast call". */
465 #define TEESMC32_FASTCALL_WITH_ARG \
466 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
467 TEESMC_FUNCID_CALL_WITH_ARG)
470 * Call with struct teesmc64_arg as argument
472 * See description of TEESMC32_CALL_WITH_ARG above, uses struct
473 * teesmc64_arg in x1 instead.
475 #define TEESMC64_CALL_WITH_ARG \
476 TEESMC_CALL_VAL(TEESMC_64, TEESMC_STD_CALL, TEESMC_OWNER_TRUSTED_OS, \
477 TEESMC_FUNCID_CALL_WITH_ARG)
478 /* Same as TEESMC64_CALL_WITH_ARG but a "fast call". */
479 #define TEESMC64_FASTCALL_WITH_ARG \
480 TEESMC_CALL_VAL(TEESMC_64, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
481 TEESMC_FUNCID_CALL_WITH_ARG)
484 * Resume from RPC (for example after processing an IRQ)
486 * Call register usage:
487 * r0/x0 SMC Function ID,
488 * TEESMC32_CALL_RETURN_FROM_RPC or
489 * TEESMC32_FASTCALL_RETURN_FROM_RPC
490 * r1-3/x1-3 Value of r1-3/x1-3 when TEESMC32_CALL_WITH_ARG returned
491 * TEESMC_RETURN_RPC in r0/x0
493 * Return register usage is the same as for TEESMC32_CALL_WITH_ARG above.
495 * Possible return values
496 * TEESMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this
498 * TEESMC_RETURN_OK Original call completed, result
499 * updated in the previously supplied.
500 * struct teesmc32_arg
501 * TEESMC_RETURN_RPC Call suspended by RPC call to normal
503 * TEESMC_RETURN_EBUSY Trusted OS busy, try again later.
504 * TEESMC_RETURN_ERESUME Resume failed, the opaque resume
505 * information was corrupt.
507 #define TEESMC_FUNCID_RETURN_FROM_RPC 3
508 #define TEESMC32_CALL_RETURN_FROM_RPC \
509 TEESMC_CALL_VAL(TEESMC_32, TEESMC_STD_CALL, TEESMC_OWNER_TRUSTED_OS, \
510 TEESMC_FUNCID_RETURN_FROM_RPC)
511 /* Same as TEESMC32_CALL_RETURN_FROM_RPC but a "fast call". */
512 #define TEESMC32_FASTCALL_RETURN_FROM_RPC \
513 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
514 TEESMC_FUNCID_RETURN_FROM_RPC)
517 * Resume from RPC (for example after processing an IRQ)
519 * See description of TEESMC32_CALL_RETURN_FROM_RPC above, used when
520 * it's a 64bit call that has returned.
522 #define TEESMC64_CALL_RETURN_FROM_RPC \
523 TEESMC_CALL_VAL(TEESMC_64, TEESMC_STD_CALL, TEESMC_OWNER_TRUSTED_OS, \
524 TEESMC_FUNCID_RETURN_FROM_RPC)
525 /* Same as TEESMC64_CALL_RETURN_FROM_RPC but a "fast call". */
526 #define TEESMC64_FASTCALL_RETURN_FROM_RPC \
527 TEESMC_CALL_VAL(TEESMC_64, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
528 TEESMC_FUNCID_RETURN_FROM_RPC)
531 * From secure monitor to Trusted OS, handle FIQ
533 * A virtual call which is injected by the Secure Monitor when an FIQ is
534 * raised while in normal world (SCR_NS is set). The monitor restores
535 * secure architecture registers and secure EL_SP1 and jumps to previous
536 * secure EL3_ELR. Trusted OS should preserve all general purpose
539 * Call register usage:
540 * r0/x0 SMC Function ID, TEESMC32_CALL_HANDLE_FIQ
541 * r1-7/x1-7 Not used, but must be preserved
543 * Return register usage:
546 #define TEESMC_FUNCID_CALL_HANDLE_FIQ 0xf000
547 #define TEESMC32_CALL_HANDLE_FIQ \
548 TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS, \
549 TEESMC_FUNCID_CALL_HANDLE_FIQ)
551 #define TEESMC_RETURN_RPC_PREFIX_MASK 0xFFFF0000
552 #define TEESMC_RETURN_RPC_PREFIX 0xFFFF0000
553 #define TEESMC_RETURN_RPC_FUNC_MASK 0x0000FFFF
555 #define TEESMC_RETURN_GET_RPC_FUNC(ret) ((ret) & TEESMC_RETURN_RPC_FUNC_MASK)
557 #define TEESMC_RPC_VAL(func) ((func) | TEESMC_RETURN_RPC_PREFIX)
560 * Allocate argument memory for RPC parameter passing.
561 * Argument memory is used to hold a struct teesmc32_arg.
563 * "Call" register usage:
564 * r0/x0 This value, TEESMC_RETURN_RPC_ALLOC
565 * r1/x1 Size in bytes of required argument memory
566 * r2-7/x2-7 Resume information, must be preserved
568 * "Return" register usage:
569 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
570 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
572 * r1/x1 Physical pointer to allocated argument memory, 0 if size
573 * was 0 or if memory can't be allocated
574 * r2-7/x2-7 Preserved
576 #define TEESMC_RPC_FUNC_ALLOC_ARG 0
577 #define TEESMC_RETURN_RPC_ALLOC_ARG \
578 TEESMC_RPC_VAL(TEESMC_RPC_FUNC_ALLOC_ARG)
581 * Allocate payload memory for RPC parameter passing.
582 * Payload memory is used to hold the memory referred to by struct
583 * teesmc32_param_memref.
585 * "Call" register usage:
586 * r0/x0 This value, TEESMC_RETURN_RPC_ALLOC
587 * r1/x1 Size in bytes of required payload memory
588 * r2-7/x2-7 Resume information, must be preserved
590 * "Return" register usage:
591 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
592 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
594 * r1/x1 Physical pointer to allocated payload memory, 0 if size
595 * was 0 or if memory can't be allocated
596 * r2-7/x2-7 Preserved
598 #define TEESMC_RPC_FUNC_ALLOC_PAYLOAD 1
599 #define TEESMC_RETURN_RPC_ALLOC_PAYLOAD \
600 TEESMC_RPC_VAL(TEESMC_RPC_FUNC_ALLOC_PAYLOAD)
603 * Free memory previously allocated by TEESMC_RETURN_RPC_ALLOC_ARG.
605 * "Call" register usage:
606 * r0/x0 This value, TEESMC_RETURN_RPC_FREE
607 * r1/x1 Physical pointer to previously allocated argument memory
608 * r2-7/x2-7 Resume information, must be preserved
610 * "Return" register usage:
611 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
612 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
615 * r2-7/x2-7 Preserved
617 #define TEESMC_RPC_FUNC_FREE_ARG 2
618 #define TEESMC_RETURN_RPC_FREE_ARG TEESMC_RPC_VAL(TEESMC_RPC_FUNC_FREE_ARG)
621 * Free memory previously allocated by TEESMC_RETURN_RPC_ALLOC_PAYLOAD.
623 * "Call" register usage:
624 * r0/x0 This value, TEESMC_RETURN_RPC_FREE
625 * r1/x1 Physical pointer to previously allocated payload memory
626 * r3-7/x3-7 Resume information, must be preserved
628 * "Return" register usage:
629 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
630 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
633 * r3-7/x3-7 Preserved
635 #define TEESMC_RPC_FUNC_FREE_PAYLOAD 3
636 #define TEESMC_RETURN_RPC_FREE_PAYLOAD \
637 TEESMC_RPC_VAL(TEESMC_RPC_FUNC_FREE_PAYLOAD)
640 * Deliver an IRQ in normal world.
642 * "Call" register usage:
643 * r0/x0 TEESMC_RETURN_RPC_IRQ
644 * r1-7/x1-7 Resume information, must be preserved
646 * "Return" register usage:
647 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
648 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
650 * r1-7/x1-7 Preserved
652 #define TEESMC_RPC_FUNC_IRQ 4
653 #define TEESMC_RETURN_RPC_IRQ TEESMC_RPC_VAL(TEESMC_RPC_FUNC_IRQ)
656 * Do an RPC request. The supplied struct teesmc{32,64}_arg tells which
657 * request to do and the paramters for the request. The following fields
658 * are used (the rest are unused):
659 * - cmd the Request ID
660 * - ret return value of the request, filled in by normal world
661 * - num_params number of parameters for the request
662 * - params the parameters
663 * - param_attrs attributes of the parameters
665 * "Call" register usage:
666 * r0/x0 TEESMC_RETURN_RPC_CMD
667 * r1/x1 Physical pointer to a struct teesmc32_arg if returning from
668 * a AArch32 SMC or a struct teesmc64_arg if returning from a
669 * AArch64 SMC, must be preserved, only the data should
671 * r2-7/x2-7 Resume information, must be preserved
673 * "Return" register usage:
674 * r0/x0 SMC Function ID, TEESMC32_CALL_RETURN_FROM_RPC if it was an
675 * AArch32 SMC return or TEESMC64_CALL_RETURN_FROM_RPC for
677 * r1-7/x1-7 Preserved
679 #define TEESMC_RPC_FUNC_CMD 5
680 #define TEESMC_RETURN_RPC_CMD TEESMC_RPC_VAL(TEESMC_RPC_FUNC_CMD)
684 #define TEESMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF
686 /* Returned in r0 only from Trusted OS functions */
687 #define TEESMC_RETURN_OK 0x0
688 #define TEESMC_RETURN_EBUSY 0x1
689 #define TEESMC_RETURN_ERESUME 0x2
690 #define TEESMC_RETURN_EBADADDR 0x3
691 #define TEESMC_RETURN_EBADCMD 0x4
692 #define TEESMC_RETURN_IS_RPC(ret) \
693 (((ret) & TEESMC_RETURN_RPC_PREFIX_MASK) == TEESMC_RETURN_RPC_PREFIX)
696 * Returned in r1 by Trusted OS functions if r0 = TEESMC_RETURN_RPC
698 #define TEESMC_RPC_REQUEST_IRQ 0x0
700 #endif /* TEESMC_H */