606 lines · c
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */2/*3 * Copyright (c) 2015-2021, Linaro Limited4 */5#ifndef OPTEE_SMC_H6#define OPTEE_SMC_H7 8#include <linux/arm-smccc.h>9#include <linux/bitops.h>10 11#define OPTEE_SMC_STD_CALL_VAL(func_num) \12 ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_SMC_32, \13 ARM_SMCCC_OWNER_TRUSTED_OS, (func_num))14#define OPTEE_SMC_FAST_CALL_VAL(func_num) \15 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \16 ARM_SMCCC_OWNER_TRUSTED_OS, (func_num))17 18/*19 * Function specified by SMC Calling convention.20 */21#define OPTEE_SMC_FUNCID_CALLS_COUNT 0xFF0022#define OPTEE_SMC_CALLS_COUNT \23 ARM_SMCCC_CALL_VAL(OPTEE_SMC_FAST_CALL, SMCCC_SMC_32, \24 SMCCC_OWNER_TRUSTED_OS_END, \25 OPTEE_SMC_FUNCID_CALLS_COUNT)26 27/*28 * Normal cached memory (write-back), shareable for SMP systems and not29 * shareable for UP systems.30 */31#define OPTEE_SMC_SHM_CACHED 132 33/*34 * a0..a7 is used as register names in the descriptions below, on arm3235 * that translates to r0..r7 and on arm64 to w0..w7. In both cases it's36 * 32-bit registers.37 */38 39/*40 * Function specified by SMC Calling convention41 *42 * Return the following UID if using API specified in this file43 * without further extensions:44 * 384fb3e0-e7f8-11e3-af63-0002a5d5c51b.45 * see also OPTEE_MSG_UID_* in optee_msg.h46 */47#define OPTEE_SMC_FUNCID_CALLS_UID OPTEE_MSG_FUNCID_CALLS_UID48#define OPTEE_SMC_CALLS_UID \49 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \50 ARM_SMCCC_OWNER_TRUSTED_OS_END, \51 OPTEE_SMC_FUNCID_CALLS_UID)52 53/*54 * Function specified by SMC Calling convention55 *56 * Returns 2.0 if using API specified in this file without further extensions.57 * see also OPTEE_MSG_REVISION_* in optee_msg.h58 */59#define OPTEE_SMC_FUNCID_CALLS_REVISION OPTEE_MSG_FUNCID_CALLS_REVISION60#define OPTEE_SMC_CALLS_REVISION \61 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \62 ARM_SMCCC_OWNER_TRUSTED_OS_END, \63 OPTEE_SMC_FUNCID_CALLS_REVISION)64 65struct optee_smc_calls_revision_result {66 unsigned long major;67 unsigned long minor;68 unsigned long reserved0;69 unsigned long reserved1;70};71 72/*73 * Get UUID of Trusted OS.74 *75 * Used by non-secure world to figure out which Trusted OS is installed.76 * Note that returned UUID is the UUID of the Trusted OS, not of the API.77 *78 * Returns UUID in a0-4 in the same way as OPTEE_SMC_CALLS_UID79 * described above.80 */81#define OPTEE_SMC_FUNCID_GET_OS_UUID OPTEE_MSG_FUNCID_GET_OS_UUID82#define OPTEE_SMC_CALL_GET_OS_UUID \83 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_UUID)84 85/*86 * Get revision of Trusted OS.87 *88 * Used by non-secure world to figure out which version of the Trusted OS89 * is installed. Note that the returned revision is the revision of the90 * Trusted OS, not of the API.91 *92 * Returns revision in a0-1 in the same way as OPTEE_SMC_CALLS_REVISION93 * described above. May optionally return a 32-bit build identifier in a2,94 * with zero meaning unspecified.95 */96#define OPTEE_SMC_FUNCID_GET_OS_REVISION OPTEE_MSG_FUNCID_GET_OS_REVISION97#define OPTEE_SMC_CALL_GET_OS_REVISION \98 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_REVISION)99 100struct optee_smc_call_get_os_revision_result {101 unsigned long major;102 unsigned long minor;103 unsigned long build_id;104 unsigned long reserved1;105};106 107/*108 * Load Trusted OS from optee/tee.bin in the Linux firmware.109 *110 * WARNING: Use this cautiously as it could lead to insecure loading of the111 * Trusted OS.112 * This SMC instructs EL3 to load a binary and execute it as the Trusted OS.113 *114 * Call register usage:115 * a0 SMC Function ID, OPTEE_SMC_CALL_LOAD_IMAGE116 * a1 Upper 32bit of a 64bit size for the payload117 * a2 Lower 32bit of a 64bit size for the payload118 * a3 Upper 32bit of the physical address for the payload119 * a4 Lower 32bit of the physical address for the payload120 *121 * The payload is in the OP-TEE image format.122 *123 * Returns result in a0, 0 on success and an error code otherwise.124 */125#define OPTEE_SMC_FUNCID_LOAD_IMAGE 2126#define OPTEE_SMC_CALL_LOAD_IMAGE \127 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \128 ARM_SMCCC_OWNER_TRUSTED_OS_END, \129 OPTEE_SMC_FUNCID_LOAD_IMAGE)130 131/*132 * Call with struct optee_msg_arg as argument133 *134 * When called with OPTEE_SMC_CALL_WITH_RPC_ARG or135 * OPTEE_SMC_CALL_WITH_REGD_ARG in a0 there is one RPC struct optee_msg_arg136 * following after the first struct optee_msg_arg. The RPC struct137 * optee_msg_arg has reserved space for the number of RPC parameters as138 * returned by OPTEE_SMC_EXCHANGE_CAPABILITIES.139 *140 * When calling these functions, normal world has a few responsibilities:141 * 1. It must be able to handle eventual RPCs142 * 2. Non-secure interrupts should not be masked143 * 3. If asynchronous notifications has been negotiated successfully, then144 * the interrupt for asynchronous notifications should be unmasked145 * during this call.146 *147 * Call register usage, OPTEE_SMC_CALL_WITH_ARG and148 * OPTEE_SMC_CALL_WITH_RPC_ARG:149 * a0 SMC Function ID, OPTEE_SMC_CALL_WITH_ARG or OPTEE_SMC_CALL_WITH_RPC_ARG150 * a1 Upper 32 bits of a 64-bit physical pointer to a struct optee_msg_arg151 * a2 Lower 32 bits of a 64-bit physical pointer to a struct optee_msg_arg152 * a3 Cache settings, not used if physical pointer is in a predefined shared153 * memory area else per OPTEE_SMC_SHM_*154 * a4-6 Not used155 * a7 Hypervisor Client ID register156 *157 * Call register usage, OPTEE_SMC_CALL_WITH_REGD_ARG:158 * a0 SMC Function ID, OPTEE_SMC_CALL_WITH_REGD_ARG159 * a1 Upper 32 bits of a 64-bit shared memory cookie160 * a2 Lower 32 bits of a 64-bit shared memory cookie161 * a3 Offset of the struct optee_msg_arg in the shared memory with the162 * supplied cookie163 * a4-6 Not used164 * a7 Hypervisor Client ID register165 *166 * Normal return register usage:167 * a0 Return value, OPTEE_SMC_RETURN_*168 * a1-3 Not used169 * a4-7 Preserved170 *171 * OPTEE_SMC_RETURN_ETHREAD_LIMIT return register usage:172 * a0 Return value, OPTEE_SMC_RETURN_ETHREAD_LIMIT173 * a1-3 Preserved174 * a4-7 Preserved175 *176 * RPC return register usage:177 * a0 Return value, OPTEE_SMC_RETURN_IS_RPC(val)178 * a1-2 RPC parameters179 * a3-7 Resume information, must be preserved180 *181 * Possible return values:182 * OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this183 * function.184 * OPTEE_SMC_RETURN_OK Call completed, result updated in185 * the previously supplied struct186 * optee_msg_arg.187 * OPTEE_SMC_RETURN_ETHREAD_LIMIT Number of Trusted OS threads exceeded,188 * try again later.189 * OPTEE_SMC_RETURN_EBADADDR Bad physical pointer to struct190 * optee_msg_arg.191 * OPTEE_SMC_RETURN_EBADCMD Bad/unknown cmd in struct optee_msg_arg192 * OPTEE_SMC_RETURN_IS_RPC() Call suspended by RPC call to normal193 * world.194 */195#define OPTEE_SMC_FUNCID_CALL_WITH_ARG OPTEE_MSG_FUNCID_CALL_WITH_ARG196#define OPTEE_SMC_CALL_WITH_ARG \197 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_CALL_WITH_ARG)198#define OPTEE_SMC_CALL_WITH_RPC_ARG \199 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_CALL_WITH_RPC_ARG)200#define OPTEE_SMC_CALL_WITH_REGD_ARG \201 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_CALL_WITH_REGD_ARG)202 203/*204 * Get Shared Memory Config205 *206 * Returns the Secure/Non-secure shared memory config.207 *208 * Call register usage:209 * a0 SMC Function ID, OPTEE_SMC_GET_SHM_CONFIG210 * a1-6 Not used211 * a7 Hypervisor Client ID register212 *213 * Have config return register usage:214 * a0 OPTEE_SMC_RETURN_OK215 * a1 Physical address of start of SHM216 * a2 Size of SHM217 * a3 Cache settings of memory, as defined by the218 * OPTEE_SMC_SHM_* values above219 * a4-7 Preserved220 *221 * Not available register usage:222 * a0 OPTEE_SMC_RETURN_ENOTAVAIL223 * a1-3 Not used224 * a4-7 Preserved225 */226#define OPTEE_SMC_FUNCID_GET_SHM_CONFIG 7227#define OPTEE_SMC_GET_SHM_CONFIG \228 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_SHM_CONFIG)229 230struct optee_smc_get_shm_config_result {231 unsigned long status;232 unsigned long start;233 unsigned long size;234 unsigned long settings;235};236 237/*238 * Exchanges capabilities between normal world and secure world239 *240 * Call register usage:241 * a0 SMC Function ID, OPTEE_SMC_EXCHANGE_CAPABILITIES242 * a1 bitfield of normal world capabilities OPTEE_SMC_NSEC_CAP_*243 * a2-6 Not used244 * a7 Hypervisor Client ID register245 *246 * Normal return register usage:247 * a0 OPTEE_SMC_RETURN_OK248 * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_*249 * a2 The maximum secure world notification number250 * a3 Bit[7:0]: Number of parameters needed for RPC to be supplied251 * as the second MSG arg struct for252 * OPTEE_SMC_CALL_WITH_ARG253 * Bit[31:8]: Reserved (MBZ)254 * a4-7 Preserved255 *256 * Error return register usage:257 * a0 OPTEE_SMC_RETURN_ENOTAVAIL, can't use the capabilities from normal world258 * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_*259 * a2-7 Preserved260 */261/* Normal world works as a uniprocessor system */262#define OPTEE_SMC_NSEC_CAP_UNIPROCESSOR BIT(0)263/* Secure world has reserved shared memory for normal world to use */264#define OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM BIT(0)265/* Secure world can communicate via previously unregistered shared memory */266#define OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM BIT(1)267 268/*269 * Secure world supports commands "register/unregister shared memory",270 * secure world accepts command buffers located in any parts of non-secure RAM271 */272#define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM BIT(2)273/* Secure world is built with virtualization support */274#define OPTEE_SMC_SEC_CAP_VIRTUALIZATION BIT(3)275/* Secure world supports Shared Memory with a NULL reference */276#define OPTEE_SMC_SEC_CAP_MEMREF_NULL BIT(4)277/* Secure world supports asynchronous notification of normal world */278#define OPTEE_SMC_SEC_CAP_ASYNC_NOTIF BIT(5)279/* Secure world supports pre-allocating RPC arg struct */280#define OPTEE_SMC_SEC_CAP_RPC_ARG BIT(6)281/* Secure world supports probing for RPMB device if needed */282#define OPTEE_SMC_SEC_CAP_RPMB_PROBE BIT(7)283 284#define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9285#define OPTEE_SMC_EXCHANGE_CAPABILITIES \286 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES)287 288struct optee_smc_exchange_capabilities_result {289 unsigned long status;290 unsigned long capabilities;291 unsigned long max_notif_value;292 unsigned long data;293};294 295/*296 * Disable and empties cache of shared memory objects297 *298 * Secure world can cache frequently used shared memory objects, for299 * example objects used as RPC arguments. When secure world is idle this300 * function returns one shared memory reference to free. To disable the301 * cache and free all cached objects this function has to be called until302 * it returns OPTEE_SMC_RETURN_ENOTAVAIL.303 *304 * Call register usage:305 * a0 SMC Function ID, OPTEE_SMC_DISABLE_SHM_CACHE306 * a1-6 Not used307 * a7 Hypervisor Client ID register308 *309 * Normal return register usage:310 * a0 OPTEE_SMC_RETURN_OK311 * a1 Upper 32 bits of a 64-bit Shared memory cookie312 * a2 Lower 32 bits of a 64-bit Shared memory cookie313 * a3-7 Preserved314 *315 * Cache empty return register usage:316 * a0 OPTEE_SMC_RETURN_ENOTAVAIL317 * a1-7 Preserved318 *319 * Not idle return register usage:320 * a0 OPTEE_SMC_RETURN_EBUSY321 * a1-7 Preserved322 */323#define OPTEE_SMC_FUNCID_DISABLE_SHM_CACHE 10324#define OPTEE_SMC_DISABLE_SHM_CACHE \325 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_DISABLE_SHM_CACHE)326 327struct optee_smc_disable_shm_cache_result {328 unsigned long status;329 unsigned long shm_upper32;330 unsigned long shm_lower32;331 unsigned long reserved0;332};333 334/*335 * Enable cache of shared memory objects336 *337 * Secure world can cache frequently used shared memory objects, for338 * example objects used as RPC arguments. When secure world is idle this339 * function returns OPTEE_SMC_RETURN_OK and the cache is enabled. If340 * secure world isn't idle OPTEE_SMC_RETURN_EBUSY is returned.341 *342 * Call register usage:343 * a0 SMC Function ID, OPTEE_SMC_ENABLE_SHM_CACHE344 * a1-6 Not used345 * a7 Hypervisor Client ID register346 *347 * Normal return register usage:348 * a0 OPTEE_SMC_RETURN_OK349 * a1-7 Preserved350 *351 * Not idle return register usage:352 * a0 OPTEE_SMC_RETURN_EBUSY353 * a1-7 Preserved354 */355#define OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE 11356#define OPTEE_SMC_ENABLE_SHM_CACHE \357 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE)358 359/*360 * Query OP-TEE about number of supported threads361 *362 * Normal World OS or Hypervisor issues this call to find out how many363 * threads OP-TEE supports. That is how many standard calls can be issued364 * in parallel before OP-TEE will return OPTEE_SMC_RETURN_ETHREAD_LIMIT.365 *366 * Call requests usage:367 * a0 SMC Function ID, OPTEE_SMC_GET_THREAD_COUNT368 * a1-6 Not used369 * a7 Hypervisor Client ID register370 *371 * Normal return register usage:372 * a0 OPTEE_SMC_RETURN_OK373 * a1 Number of threads374 * a2-7 Preserved375 *376 * Error return:377 * a0 OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Requested call is not implemented378 * a1-7 Preserved379 */380#define OPTEE_SMC_FUNCID_GET_THREAD_COUNT 15381#define OPTEE_SMC_GET_THREAD_COUNT \382 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_THREAD_COUNT)383 384/*385 * Inform OP-TEE that normal world is able to receive asynchronous386 * notifications.387 *388 * Call requests usage:389 * a0 SMC Function ID, OPTEE_SMC_ENABLE_ASYNC_NOTIF390 * a1-6 Not used391 * a7 Hypervisor Client ID register392 *393 * Normal return register usage:394 * a0 OPTEE_SMC_RETURN_OK395 * a1-7 Preserved396 *397 * Not supported return register usage:398 * a0 OPTEE_SMC_RETURN_ENOTAVAIL399 * a1-7 Preserved400 */401#define OPTEE_SMC_FUNCID_ENABLE_ASYNC_NOTIF 16402#define OPTEE_SMC_ENABLE_ASYNC_NOTIF \403 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_ASYNC_NOTIF)404 405/*406 * Retrieve a value of notifications pending since the last call of this407 * function.408 *409 * OP-TEE keeps a record of all posted values. When an interrupt is410 * received which indicates that there are posted values this function411 * should be called until all pended values have been retrieved. When a412 * value is retrieved, it's cleared from the record in secure world.413 *414 * It is expected that this function is called from an interrupt handler415 * in normal world.416 *417 * Call requests usage:418 * a0 SMC Function ID, OPTEE_SMC_GET_ASYNC_NOTIF_VALUE419 * a1-6 Not used420 * a7 Hypervisor Client ID register421 *422 * Normal return register usage:423 * a0 OPTEE_SMC_RETURN_OK424 * a1 value425 * a2 Bit[0]: OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID if the value in a1 is426 * valid, else 0 if no values where pending427 * a2 Bit[1]: OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING if another value is428 * pending, else 0.429 * Bit[31:2]: MBZ430 * a3-7 Preserved431 *432 * Not supported return register usage:433 * a0 OPTEE_SMC_RETURN_ENOTAVAIL434 * a1-7 Preserved435 */436#define OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID BIT(0)437#define OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING BIT(1)438 439/*440 * Notification that OP-TEE expects a yielding call to do some bottom half441 * work in a driver.442 */443#define OPTEE_SMC_ASYNC_NOTIF_VALUE_DO_BOTTOM_HALF 0444 445#define OPTEE_SMC_FUNCID_GET_ASYNC_NOTIF_VALUE 17446#define OPTEE_SMC_GET_ASYNC_NOTIF_VALUE \447 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_ASYNC_NOTIF_VALUE)448 449/* See OPTEE_SMC_CALL_WITH_RPC_ARG above */450#define OPTEE_SMC_FUNCID_CALL_WITH_RPC_ARG 18451 452/* See OPTEE_SMC_CALL_WITH_REGD_ARG above */453#define OPTEE_SMC_FUNCID_CALL_WITH_REGD_ARG 19454 455/*456 * Resume from RPC (for example after processing a foreign interrupt)457 *458 * Call register usage:459 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC460 * a1-3 Value of a1-3 when OPTEE_SMC_CALL_WITH_ARG returned461 * OPTEE_SMC_RETURN_RPC in a0462 *463 * Return register usage is the same as for OPTEE_SMC_*CALL_WITH_ARG above.464 *465 * Possible return values466 * OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this467 * function.468 * OPTEE_SMC_RETURN_OK Original call completed, result469 * updated in the previously supplied.470 * struct optee_msg_arg471 * OPTEE_SMC_RETURN_RPC Call suspended by RPC call to normal472 * world.473 * OPTEE_SMC_RETURN_ERESUME Resume failed, the opaque resume474 * information was corrupt.475 */476#define OPTEE_SMC_FUNCID_RETURN_FROM_RPC 3477#define OPTEE_SMC_CALL_RETURN_FROM_RPC \478 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_RETURN_FROM_RPC)479 480#define OPTEE_SMC_RETURN_RPC_PREFIX_MASK 0xFFFF0000481#define OPTEE_SMC_RETURN_RPC_PREFIX 0xFFFF0000482#define OPTEE_SMC_RETURN_RPC_FUNC_MASK 0x0000FFFF483 484#define OPTEE_SMC_RETURN_GET_RPC_FUNC(ret) \485 ((ret) & OPTEE_SMC_RETURN_RPC_FUNC_MASK)486 487#define OPTEE_SMC_RPC_VAL(func) ((func) | OPTEE_SMC_RETURN_RPC_PREFIX)488 489/*490 * Allocate memory for RPC parameter passing. The memory is used to hold a491 * struct optee_msg_arg.492 *493 * "Call" register usage:494 * a0 This value, OPTEE_SMC_RETURN_RPC_ALLOC495 * a1 Size in bytes of required argument memory496 * a2 Not used497 * a3 Resume information, must be preserved498 * a4-5 Not used499 * a6-7 Resume information, must be preserved500 *501 * "Return" register usage:502 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.503 * a1 Upper 32 bits of 64-bit physical pointer to allocated504 * memory, (a1 == 0 && a2 == 0) if size was 0 or if memory can't505 * be allocated.506 * a2 Lower 32 bits of 64-bit physical pointer to allocated507 * memory, (a1 == 0 && a2 == 0) if size was 0 or if memory can't508 * be allocated509 * a3 Preserved510 * a4 Upper 32 bits of 64-bit Shared memory cookie used when freeing511 * the memory or doing an RPC512 * a5 Lower 32 bits of 64-bit Shared memory cookie used when freeing513 * the memory or doing an RPC514 * a6-7 Preserved515 */516#define OPTEE_SMC_RPC_FUNC_ALLOC 0517#define OPTEE_SMC_RETURN_RPC_ALLOC \518 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_ALLOC)519 520/*521 * Free memory previously allocated by OPTEE_SMC_RETURN_RPC_ALLOC522 *523 * "Call" register usage:524 * a0 This value, OPTEE_SMC_RETURN_RPC_FREE525 * a1 Upper 32 bits of 64-bit shared memory cookie belonging to this526 * argument memory527 * a2 Lower 32 bits of 64-bit shared memory cookie belonging to this528 * argument memory529 * a3-7 Resume information, must be preserved530 *531 * "Return" register usage:532 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.533 * a1-2 Not used534 * a3-7 Preserved535 */536#define OPTEE_SMC_RPC_FUNC_FREE 2537#define OPTEE_SMC_RETURN_RPC_FREE \538 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FREE)539 540/*541 * Deliver a foreign interrupt in normal world.542 *543 * "Call" register usage:544 * a0 OPTEE_SMC_RETURN_RPC_FOREIGN_INTR545 * a1-7 Resume information, must be preserved546 *547 * "Return" register usage:548 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.549 * a1-7 Preserved550 */551#define OPTEE_SMC_RPC_FUNC_FOREIGN_INTR 4552#define OPTEE_SMC_RETURN_RPC_FOREIGN_INTR \553 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FOREIGN_INTR)554 555/*556 * Do an RPC request. The supplied struct optee_msg_arg tells which557 * request to do and the parameters for the request. The following fields558 * are used (the rest are unused):559 * - cmd the Request ID560 * - ret return value of the request, filled in by normal world561 * - num_params number of parameters for the request562 * - params the parameters563 * - param_attrs attributes of the parameters564 *565 * "Call" register usage:566 * a0 OPTEE_SMC_RETURN_RPC_CMD567 * a1 Upper 32 bits of a 64-bit Shared memory cookie holding a568 * struct optee_msg_arg, must be preserved, only the data should569 * be updated570 * a2 Lower 32 bits of a 64-bit Shared memory cookie holding a571 * struct optee_msg_arg, must be preserved, only the data should572 * be updated573 * a3-7 Resume information, must be preserved574 *575 * "Return" register usage:576 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.577 * a1-2 Not used578 * a3-7 Preserved579 */580#define OPTEE_SMC_RPC_FUNC_CMD 5581#define OPTEE_SMC_RETURN_RPC_CMD \582 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_CMD)583 584/* Returned in a0 */585#define OPTEE_SMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF586 587/* Returned in a0 only from Trusted OS functions */588#define OPTEE_SMC_RETURN_OK 0x0589#define OPTEE_SMC_RETURN_ETHREAD_LIMIT 0x1590#define OPTEE_SMC_RETURN_EBUSY 0x2591#define OPTEE_SMC_RETURN_ERESUME 0x3592#define OPTEE_SMC_RETURN_EBADADDR 0x4593#define OPTEE_SMC_RETURN_EBADCMD 0x5594#define OPTEE_SMC_RETURN_ENOMEM 0x6595#define OPTEE_SMC_RETURN_ENOTAVAIL 0x7596#define OPTEE_SMC_RETURN_IS_RPC(ret) __optee_smc_return_is_rpc((ret))597 598static inline bool __optee_smc_return_is_rpc(u32 ret)599{600 return ret != OPTEE_SMC_RETURN_UNKNOWN_FUNCTION &&601 (ret & OPTEE_SMC_RETURN_RPC_PREFIX_MASK) ==602 OPTEE_SMC_RETURN_RPC_PREFIX;603}604 605#endif /* OPTEE_SMC_H */606