1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2015, Linaro Limited 4 */ 5 #ifndef OPTEE_SMC_H 6 #define OPTEE_SMC_H 7 8 /* 9 * This file is exported by OP-TEE and is in kept in sync between secure 10 * world and normal world kernel driver. We're following ARM SMC Calling 11 * Convention as specified in 12 * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html 13 * 14 * This file depends on optee_msg.h being included to expand the SMC id 15 * macros below. 16 */ 17 18 19 #define OPTEE_SMC_STD_CALL_VAL(func_num) \ 20 ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_CONV_32, \ 21 ARM_SMCCC_OWNER_TRUSTED_OS, (func_num)) 22 #define OPTEE_SMC_FAST_CALL_VAL(func_num) \ 23 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_CONV_32, \ 24 ARM_SMCCC_OWNER_TRUSTED_OS, (func_num)) 25 26 /* 27 * Function specified by SMC Calling convention. 28 */ 29 #define OPTEE_SMC_FUNCID_CALLS_COUNT 0xFF00 30 #define OPTEE_SMC_CALLS_COUNT \ 31 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_CONV_32, \ 32 ARM_SMCCC_OWNER_TRUSTED_OS_END, \ 33 OPTEE_SMC_FUNCID_CALLS_COUNT) 34 35 /* 36 * Normal cached memory (write-back), shareable for SMP systems and not 37 * shareable for UP systems. 38 */ 39 #define OPTEE_SMC_SHM_CACHED 1 40 41 /* 42 * a0..a7 is used as register names in the descriptions below, on arm32 43 * that translates to r0..r7 and on arm64 to w0..w7. In both cases it's 44 * 32-bit registers. 45 */ 46 47 /* 48 * Function specified by SMC Calling convention 49 * 50 * Return the following UID if using API specified in this file 51 * without further extensions: 52 * 384fb3e0-e7f8-11e3-af63-0002a5d5c51b. 53 * see also OPTEE_MSG_UID_* in optee_msg.h 54 */ 55 #define OPTEE_SMC_FUNCID_CALLS_UID OPTEE_MSG_FUNCID_CALLS_UID 56 #define OPTEE_SMC_CALLS_UID \ 57 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_CONV_32, \ 58 ARM_SMCCC_OWNER_TRUSTED_OS_END, \ 59 OPTEE_SMC_FUNCID_CALLS_UID) 60 61 /* 62 * Function specified by SMC Calling convention 63 * 64 * Returns 2.0 if using API specified in this file without further extensions. 65 * see also OPTEE_MSG_REVISION_* in optee_msg.h 66 */ 67 #define OPTEE_SMC_FUNCID_CALLS_REVISION OPTEE_MSG_FUNCID_CALLS_REVISION 68 #define OPTEE_SMC_CALLS_REVISION \ 69 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_CONV_32, \ 70 ARM_SMCCC_OWNER_TRUSTED_OS_END, \ 71 OPTEE_SMC_FUNCID_CALLS_REVISION) 72 73 /* 74 * Get UUID of Trusted OS. 75 * 76 * Used by non-secure world to figure out which Trusted OS is installed. 77 * Note that returned UUID is the UUID of the Trusted OS, not of the API. 78 * 79 * Returns UUID in a0-4 in the same way as OPTEE_SMC_CALLS_UID 80 * described above. 81 */ 82 #define OPTEE_SMC_FUNCID_GET_OS_UUID OPTEE_MSG_FUNCID_GET_OS_UUID 83 #define OPTEE_SMC_CALL_GET_OS_UUID \ 84 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_UUID) 85 86 /* 87 * Get revision of Trusted OS. 88 * 89 * Used by non-secure world to figure out which version of the Trusted OS 90 * is installed. Note that the returned revision is the revision of the 91 * Trusted OS, not of the API. 92 * 93 * Returns revision in a0-1 in the same way as OPTEE_SMC_CALLS_REVISION 94 * described above. May optionally return a 32-bit build identifier in a2, 95 * with zero meaning unspecified. 96 */ 97 #define OPTEE_SMC_FUNCID_GET_OS_REVISION OPTEE_MSG_FUNCID_GET_OS_REVISION 98 #define OPTEE_SMC_CALL_GET_OS_REVISION \ 99 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_REVISION) 100 101 /* 102 * Call with struct optee_msg_arg as argument 103 * 104 * Call register usage: 105 * a0 SMC Function ID, OPTEE_SMC*CALL_WITH_ARG 106 * a1 Upper 32 bits of a 64-bit physical pointer to a struct optee_msg_arg 107 * a2 Lower 32 bits of a 64-bit physical pointer to a struct optee_msg_arg 108 * a3 Cache settings, not used if physical pointer is in a predefined shared 109 * memory area else per OPTEE_SMC_SHM_* 110 * a4-6 Not used 111 * a7 Hypervisor Client ID register 112 * 113 * Normal return register usage: 114 * a0 Return value, OPTEE_SMC_RETURN_* 115 * a1-3 Not used 116 * a4-7 Preserved 117 * 118 * OPTEE_SMC_RETURN_ETHREAD_LIMIT return register usage: 119 * a0 Return value, OPTEE_SMC_RETURN_ETHREAD_LIMIT 120 * a1-3 Preserved 121 * a4-7 Preserved 122 * 123 * RPC return register usage: 124 * a0 Return value, OPTEE_SMC_RETURN_IS_RPC(val) 125 * a1-2 RPC parameters 126 * a3-7 Resume information, must be preserved 127 * 128 * Possible return values: 129 * OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this 130 * function. 131 * OPTEE_SMC_RETURN_OK Call completed, result updated in 132 * the previously supplied struct 133 * optee_msg_arg. 134 * OPTEE_SMC_RETURN_ETHREAD_LIMIT Number of Trusted OS threads exceeded, 135 * try again later. 136 * OPTEE_SMC_RETURN_EBADADDR Bad physical pointer to struct 137 * optee_msg_arg. 138 * OPTEE_SMC_RETURN_EBADCMD Bad/unknown cmd in struct optee_msg_arg 139 * OPTEE_SMC_RETURN_IS_RPC() Call suspended by RPC call to normal 140 * world. 141 */ 142 #define OPTEE_SMC_FUNCID_CALL_WITH_ARG OPTEE_MSG_FUNCID_CALL_WITH_ARG 143 #define OPTEE_SMC_CALL_WITH_ARG \ 144 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_CALL_WITH_ARG) 145 146 /* 147 * Get Shared Memory Config 148 * 149 * Returns the Secure/Non-secure shared memory config. 150 * 151 * Call register usage: 152 * a0 SMC Function ID, OPTEE_SMC_GET_SHM_CONFIG 153 * a1-6 Not used 154 * a7 Hypervisor Client ID register 155 * 156 * Have config return register usage: 157 * a0 OPTEE_SMC_RETURN_OK 158 * a1 Physical address of start of SHM 159 * a2 Size of of SHM 160 * a3 Cache settings of memory, as defined by the 161 * OPTEE_SMC_SHM_* values above 162 * a4-7 Preserved 163 * 164 * Not available register usage: 165 * a0 OPTEE_SMC_RETURN_ENOTAVAIL 166 * a1-3 Not used 167 * a4-7 Preserved 168 */ 169 #define OPTEE_SMC_FUNCID_GET_SHM_CONFIG 7 170 #define OPTEE_SMC_GET_SHM_CONFIG \ 171 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_SHM_CONFIG) 172 173 /* 174 * Configures L2CC mutex 175 * 176 * Disables, enables usage of L2CC mutex. Returns or sets physical address 177 * of L2CC mutex. 178 * 179 * Call register usage: 180 * a0 SMC Function ID, OPTEE_SMC_L2CC_MUTEX 181 * a1 OPTEE_SMC_L2CC_MUTEX_GET_ADDR Get physical address of mutex 182 * OPTEE_SMC_L2CC_MUTEX_SET_ADDR Set physical address of mutex 183 * OPTEE_SMC_L2CC_MUTEX_ENABLE Enable usage of mutex 184 * OPTEE_SMC_L2CC_MUTEX_DISABLE Disable usage of mutex 185 * a2 if a1 == OPTEE_SMC_L2CC_MUTEX_SET_ADDR, upper 32bit of a 64bit 186 * physical address of mutex 187 * a3 if a1 == OPTEE_SMC_L2CC_MUTEX_SET_ADDR, lower 32bit of a 64bit 188 * physical address of mutex 189 * a3-6 Not used 190 * a7 Hypervisor Client ID register 191 * 192 * Have config return register usage: 193 * a0 OPTEE_SMC_RETURN_OK 194 * a1 Preserved 195 * a2 if a1 == OPTEE_SMC_L2CC_MUTEX_GET_ADDR, upper 32bit of a 64bit 196 * physical address of mutex 197 * a3 if a1 == OPTEE_SMC_L2CC_MUTEX_GET_ADDR, lower 32bit of a 64bit 198 * physical address of mutex 199 * a3-7 Preserved 200 * 201 * Error return register usage: 202 * a0 OPTEE_SMC_RETURN_ENOTAVAIL Physical address not available 203 * OPTEE_SMC_RETURN_EBADADDR Bad supplied physical address 204 * OPTEE_SMC_RETURN_EBADCMD Unsupported value in a1 205 * a1-7 Preserved 206 */ 207 #define OPTEE_SMC_L2CC_MUTEX_GET_ADDR 0 208 #define OPTEE_SMC_L2CC_MUTEX_SET_ADDR 1 209 #define OPTEE_SMC_L2CC_MUTEX_ENABLE 2 210 #define OPTEE_SMC_L2CC_MUTEX_DISABLE 3 211 #define OPTEE_SMC_FUNCID_L2CC_MUTEX 8 212 #define OPTEE_SMC_L2CC_MUTEX \ 213 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_L2CC_MUTEX) 214 215 /* 216 * Exchanges capabilities between normal world and secure world 217 * 218 * Call register usage: 219 * a0 SMC Function ID, OPTEE_SMC_EXCHANGE_CAPABILITIES 220 * a1 bitfield of normal world capabilities OPTEE_SMC_NSEC_CAP_* 221 * a2-6 Not used 222 * a7 Hypervisor Client ID register 223 * 224 * Normal return register usage: 225 * a0 OPTEE_SMC_RETURN_OK 226 * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_* 227 * a2-7 Preserved 228 * 229 * Error return register usage: 230 * a0 OPTEE_SMC_RETURN_ENOTAVAIL, can't use the capabilities from normal world 231 * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_* 232 * a2-7 Preserved 233 */ 234 /* Normal world works as a uniprocessor system */ 235 #define OPTEE_SMC_NSEC_CAP_UNIPROCESSOR (1 << 0) 236 /* Secure world has reserved shared memory for normal world to use */ 237 #define OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM (1 << 0) 238 /* Secure world can communicate via previously unregistered shared memory */ 239 #define OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM (1 << 1) 240 241 /* 242 * Secure world supports commands "register/unregister shared memory", 243 * secure world accepts command buffers located in any parts of non-secure RAM 244 */ 245 #define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM (1 << 2) 246 247 #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 248 #define OPTEE_SMC_EXCHANGE_CAPABILITIES \ 249 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES) 250 251 /* 252 * Disable and empties cache of shared memory objects 253 * 254 * Secure world can cache frequently used shared memory objects, for 255 * example objects used as RPC arguments. When secure world is idle this 256 * function returns one shared memory reference to free. To disable the 257 * cache and free all cached objects this function has to be called until 258 * it returns OPTEE_SMC_RETURN_ENOTAVAIL. 259 * 260 * Call register usage: 261 * a0 SMC Function ID, OPTEE_SMC_DISABLE_SHM_CACHE 262 * a1-6 Not used 263 * a7 Hypervisor Client ID register 264 * 265 * Normal return register usage: 266 * a0 OPTEE_SMC_RETURN_OK 267 * a1 Upper 32 bits of a 64-bit Shared memory cookie 268 * a2 Lower 32 bits of a 64-bit Shared memory cookie 269 * a3-7 Preserved 270 * 271 * Cache empty return register usage: 272 * a0 OPTEE_SMC_RETURN_ENOTAVAIL 273 * a1-7 Preserved 274 * 275 * Not idle return register usage: 276 * a0 OPTEE_SMC_RETURN_EBUSY 277 * a1-7 Preserved 278 */ 279 #define OPTEE_SMC_FUNCID_DISABLE_SHM_CACHE 10 280 #define OPTEE_SMC_DISABLE_SHM_CACHE \ 281 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_DISABLE_SHM_CACHE) 282 283 /* 284 * Enable cache of shared memory objects 285 * 286 * Secure world can cache frequently used shared memory objects, for 287 * example objects used as RPC arguments. When secure world is idle this 288 * function returns OPTEE_SMC_RETURN_OK and the cache is enabled. If 289 * secure world isn't idle OPTEE_SMC_RETURN_EBUSY is returned. 290 * 291 * Call register usage: 292 * a0 SMC Function ID, OPTEE_SMC_ENABLE_SHM_CACHE 293 * a1-6 Not used 294 * a7 Hypervisor Client ID register 295 * 296 * Normal return register usage: 297 * a0 OPTEE_SMC_RETURN_OK 298 * a1-7 Preserved 299 * 300 * Not idle return register usage: 301 * a0 OPTEE_SMC_RETURN_EBUSY 302 * a1-7 Preserved 303 */ 304 #define OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE 11 305 #define OPTEE_SMC_ENABLE_SHM_CACHE \ 306 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE) 307 308 /* 309 * Release of secondary cores 310 * 311 * OP-TEE in secure world is in charge of the release process of secondary 312 * cores. The Rich OS issue the this request to ask OP-TEE to boot up the 313 * secondary cores, go through the OP-TEE per-core initialization, and then 314 * switch to the Non-seCure world with the Rich OS provided entry address. 315 * The secondary cores enter Non-Secure world in SVC mode, with Thumb, FIQ, 316 * IRQ and Abort bits disabled. 317 * 318 * Call register usage: 319 * a0 SMC Function ID, OPTEE_SMC_BOOT_SECONDARY 320 * a1 Index of secondary core to boot 321 * a2 Upper 32 bits of a 64-bit Non-Secure world entry physical address 322 * a3 Lower 32 bits of a 64-bit Non-Secure world entry physical address 323 * a4-7 Not used 324 * 325 * Normal return register usage: 326 * a0 OPTEE_SMC_RETURN_OK 327 * a1-7 Preserved 328 * 329 * Error return: 330 * a0 OPTEE_SMC_RETURN_EBADCMD Core index out of range 331 * a1-7 Preserved 332 * 333 * Not idle return register usage: 334 * a0 OPTEE_SMC_RETURN_EBUSY 335 * a1-7 Preserved 336 */ 337 #define OPTEE_SMC_FUNCID_BOOT_SECONDARY 12 338 #define OPTEE_SMC_BOOT_SECONDARY \ 339 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_BOOT_SECONDARY) 340 341 /* 342 * Inform OP-TEE about a new virtual machine 343 * 344 * Hypervisor issues this call during virtual machine (guest) creation. 345 * OP-TEE records client id of new virtual machine and prepares 346 * to receive requests from it. This call is available only if OP-TEE 347 * was built with virtualization support. 348 * 349 * Call requests usage: 350 * a0 SMC Function ID, OPTEE_SMC_VM_CREATED 351 * a1 Hypervisor Client ID of newly created virtual machine 352 * a2-6 Not used 353 * a7 Hypervisor Client ID register. Must be 0, because only hypervisor 354 * can issue this call 355 * 356 * Normal return register usage: 357 * a0 OPTEE_SMC_RETURN_OK 358 * a1-7 Preserved 359 * 360 * Error return: 361 * a0 OPTEE_SMC_RETURN_ENOTAVAIL OP-TEE have no resources for 362 * another VM 363 * a1-7 Preserved 364 * 365 */ 366 #define OPTEE_SMC_FUNCID_VM_CREATED 13 367 #define OPTEE_SMC_VM_CREATED \ 368 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_VM_CREATED) 369 370 /* 371 * Inform OP-TEE about shutdown of a virtual machine 372 * 373 * Hypervisor issues this call during virtual machine (guest) destruction. 374 * OP-TEE will clean up all resources associated with this VM. This call is 375 * available only if OP-TEE was built with virtualization support. 376 * 377 * Call requests usage: 378 * a0 SMC Function ID, OPTEE_SMC_VM_DESTROYED 379 * a1 Hypervisor Client ID of virtual machine being shut down 380 * a2-6 Not used 381 * a7 Hypervisor Client ID register. Must be 0, because only hypervisor 382 * can issue this call 383 * 384 * Normal return register usage: 385 * a0 OPTEE_SMC_RETURN_OK 386 * a1-7 Preserved 387 * 388 */ 389 #define OPTEE_SMC_FUNCID_VM_DESTROYED 14 390 #define OPTEE_SMC_VM_DESTROYED \ 391 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_VM_DESTROYED) 392 393 /* 394 * Query OP-TEE about number of supported threads 395 * 396 * Normal World OS or Hypervisor issues this call to find out how many 397 * threads OP-TEE supports. That is how many standard calls can be issued 398 * in parallel before OP-TEE will return OPTEE_SMC_RETURN_ETHREAD_LIMIT. 399 * 400 * Call requests usage: 401 * a0 SMC Function ID, OPTEE_SMC_GET_THREAD_COUNT 402 * a1-6 Not used 403 * a7 Hypervisor Client ID register 404 * 405 * Normal return register usage: 406 * a0 OPTEE_SMC_RETURN_OK 407 * a1 Number of threads 408 * a2-7 Preserved 409 * 410 * Error return: 411 * a0 OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Requested call is not implemented 412 * a1-7 Preserved 413 */ 414 #define OPTEE_SMC_FUNCID_GET_THREAD_COUNT 15 415 #define OPTEE_SMC_GET_THREAD_COUNT \ 416 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_THREAD_COUNT) 417 418 /* 419 * Resume from RPC (for example after processing a foreign interrupt) 420 * 421 * Call register usage: 422 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC 423 * a1-3 Value of a1-3 when OPTEE_SMC_CALL_WITH_ARG returned 424 * OPTEE_SMC_RETURN_RPC in a0 425 * 426 * Return register usage is the same as for OPTEE_SMC_*CALL_WITH_ARG above. 427 * 428 * Possible return values 429 * OPTEE_SMC_RETURN_UNKNOWN_FUNCTION Trusted OS does not recognize this 430 * function. 431 * OPTEE_SMC_RETURN_OK Original call completed, result 432 * updated in the previously supplied. 433 * struct optee_msg_arg 434 * OPTEE_SMC_RETURN_RPC Call suspended by RPC call to normal 435 * world. 436 * OPTEE_SMC_RETURN_ERESUME Resume failed, the opaque resume 437 * information was corrupt. 438 */ 439 #define OPTEE_SMC_FUNCID_RETURN_FROM_RPC 3 440 #define OPTEE_SMC_CALL_RETURN_FROM_RPC \ 441 OPTEE_SMC_STD_CALL_VAL(OPTEE_SMC_FUNCID_RETURN_FROM_RPC) 442 443 #define OPTEE_SMC_RETURN_RPC_PREFIX_MASK 0xFFFF0000 444 #define OPTEE_SMC_RETURN_RPC_PREFIX 0xFFFF0000 445 #define OPTEE_SMC_RETURN_RPC_FUNC_MASK 0x0000FFFF 446 447 #define OPTEE_SMC_RETURN_GET_RPC_FUNC(ret) \ 448 ((ret) & OPTEE_SMC_RETURN_RPC_FUNC_MASK) 449 450 #define OPTEE_SMC_RPC_VAL(func) ((func) | OPTEE_SMC_RETURN_RPC_PREFIX) 451 452 /* 453 * Allocate memory for RPC parameter passing. The memory is used to hold a 454 * struct optee_msg_arg. 455 * 456 * "Call" register usage: 457 * a0 This value, OPTEE_SMC_RETURN_RPC_ALLOC 458 * a1 Size in bytes of required argument memory 459 * a2 Not used 460 * a3 Resume information, must be preserved 461 * a4-5 Not used 462 * a6-7 Resume information, must be preserved 463 * 464 * "Return" register usage: 465 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC. 466 * a1 Upper 32 bits of 64-bit physical pointer to allocated 467 * memory, (a1 == 0 && a2 == 0) if size was 0 or if memory can't 468 * be allocated. 469 * a2 Lower 32 bits of 64-bit physical pointer to allocated 470 * memory, (a1 == 0 && a2 == 0) if size was 0 or if memory can't 471 * be allocated 472 * a3 Preserved 473 * a4 Upper 32 bits of 64-bit Shared memory cookie used when freeing 474 * the memory or doing an RPC 475 * a5 Lower 32 bits of 64-bit Shared memory cookie used when freeing 476 * the memory or doing an RPC 477 * a6-7 Preserved 478 */ 479 #define OPTEE_SMC_RPC_FUNC_ALLOC 0 480 #define OPTEE_SMC_RETURN_RPC_ALLOC \ 481 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_ALLOC) 482 483 /* 484 * Free memory previously allocated by OPTEE_SMC_RETURN_RPC_ALLOC 485 * 486 * "Call" register usage: 487 * a0 This value, OPTEE_SMC_RETURN_RPC_FREE 488 * a1 Upper 32 bits of 64-bit shared memory cookie belonging to this 489 * argument memory 490 * a2 Lower 32 bits of 64-bit shared memory cookie belonging to this 491 * argument memory 492 * a3-7 Resume information, must be preserved 493 * 494 * "Return" register usage: 495 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC. 496 * a1-2 Not used 497 * a3-7 Preserved 498 */ 499 #define OPTEE_SMC_RPC_FUNC_FREE 2 500 #define OPTEE_SMC_RETURN_RPC_FREE \ 501 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FREE) 502 503 /* 504 * Deliver a foreign interrupt in normal world. 505 * 506 * "Call" register usage: 507 * a0 OPTEE_SMC_RETURN_RPC_FOREIGN_INTR 508 * a1-7 Resume information, must be preserved 509 * 510 * "Return" register usage: 511 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC. 512 * a1-7 Preserved 513 */ 514 #define OPTEE_SMC_RPC_FUNC_FOREIGN_INTR 4 515 #define OPTEE_SMC_RETURN_RPC_FOREIGN_INTR \ 516 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FOREIGN_INTR) 517 518 /* 519 * Do an RPC request. The supplied struct optee_msg_arg tells which 520 * request to do and the parameters for the request. The following fields 521 * are used (the rest are unused): 522 * - cmd the Request ID 523 * - ret return value of the request, filled in by normal world 524 * - num_params number of parameters for the request 525 * - params the parameters 526 * - param_attrs attributes of the parameters 527 * 528 * "Call" register usage: 529 * a0 OPTEE_SMC_RETURN_RPC_CMD 530 * a1 Upper 32 bits of a 64-bit Shared memory cookie holding a 531 * struct optee_msg_arg, must be preserved, only the data should 532 * be updated 533 * a2 Lower 32 bits of a 64-bit Shared memory cookie holding a 534 * struct optee_msg_arg, must be preserved, only the data should 535 * be updated 536 * a3-7 Resume information, must be preserved 537 * 538 * "Return" register usage: 539 * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC. 540 * a1-2 Not used 541 * a3-7 Preserved 542 */ 543 #define OPTEE_SMC_RPC_FUNC_CMD 5 544 #define OPTEE_SMC_RETURN_RPC_CMD \ 545 OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_CMD) 546 547 /* Returned in a0 */ 548 #define OPTEE_SMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF 549 550 /* Returned in a0 only from Trusted OS functions */ 551 #define OPTEE_SMC_RETURN_OK 0x0 552 #define OPTEE_SMC_RETURN_ETHREAD_LIMIT 0x1 553 #define OPTEE_SMC_RETURN_EBUSY 0x2 554 #define OPTEE_SMC_RETURN_ERESUME 0x3 555 #define OPTEE_SMC_RETURN_EBADADDR 0x4 556 #define OPTEE_SMC_RETURN_EBADCMD 0x5 557 #define OPTEE_SMC_RETURN_ENOMEM 0x6 558 #define OPTEE_SMC_RETURN_ENOTAVAIL 0x7 559 #define OPTEE_SMC_RETURN_IS_RPC(ret) \ 560 (((ret) != OPTEE_SMC_RETURN_UNKNOWN_FUNCTION) && \ 561 ((((ret) & OPTEE_SMC_RETURN_RPC_PREFIX_MASK) == \ 562 OPTEE_SMC_RETURN_RPC_PREFIX))) 563 564 #endif /* OPTEE_SMC_H */ 565