1 /* 2 * Copyright (c) 2014-2023, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* Copyright (c) 2014, Linaro Limited. All rights reserved. */ 8 9 #ifndef TEESMC_OPTEED_H 10 #define TEESMC_OPTEED_H 11 12 #include "teesmc_opteed_macros.h" 13 14 /* 15 * This section specifies SMC function IDs used when returning from TEE to the 16 * secure monitor. 17 * 18 * All SMC Function IDs indicates SMC32 Calling Convention but will carry 19 * full 64 bit values in the argument registers if invoked from Aarch64 20 * mode. This violates the SMC Calling Convention, but since this 21 * convention only coveres API towards Normal World it's something that 22 * only concerns the OP-TEE Dispatcher in Trusted Firmware-A and OP-TEE 23 * OS at Secure EL1. 24 */ 25 26 /* 27 * Issued when returning from initial entry. 28 * 29 * Register usage: 30 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE 31 * r1/x1 Pointer to entry vector 32 */ 33 #define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0 34 #define TEESMC_OPTEED_RETURN_ENTRY_DONE \ 35 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE) 36 37 38 39 /* 40 * Issued when returning from "cpu_on" vector 41 * 42 * Register usage: 43 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE 44 * r1/x1 0 on success and anything else to indicate error condition 45 */ 46 #define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1 47 #define TEESMC_OPTEED_RETURN_ON_DONE \ 48 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE) 49 50 /* 51 * Issued when returning from "cpu_off" vector 52 * 53 * Register usage: 54 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE 55 * r1/x1 0 on success and anything else to indicate error condition 56 */ 57 #define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2 58 #define TEESMC_OPTEED_RETURN_OFF_DONE \ 59 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE) 60 61 /* 62 * Issued when returning from "cpu_suspend" vector 63 * 64 * Register usage: 65 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE 66 * r1/x1 0 on success and anything else to indicate error condition 67 */ 68 #define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3 69 #define TEESMC_OPTEED_RETURN_SUSPEND_DONE \ 70 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE) 71 72 /* 73 * Issued when returning from "cpu_resume" vector 74 * 75 * Register usage: 76 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE 77 * r1/x1 0 on success and anything else to indicate error condition 78 */ 79 #define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4 80 #define TEESMC_OPTEED_RETURN_RESUME_DONE \ 81 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE) 82 83 /* 84 * Issued when returning from "std_smc" or "fast_smc" vector 85 * 86 * Register usage: 87 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_CALL_DONE 88 * r1-4/x1-4 Return value 0-3 which will passed to normal world in 89 * r0-3/x0-3 90 */ 91 #define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5 92 #define TEESMC_OPTEED_RETURN_CALL_DONE \ 93 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE) 94 95 /* 96 * Issued when returning from "fiq" vector 97 * 98 * Register usage: 99 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE 100 */ 101 #define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6 102 #define TEESMC_OPTEED_RETURN_FIQ_DONE \ 103 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE) 104 105 /* 106 * Issued when returning from "system_off" vector 107 * 108 * Register usage: 109 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE 110 */ 111 #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7 112 #define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \ 113 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE) 114 115 /* 116 * Issued when returning from "system_reset" vector 117 * 118 * Register usage: 119 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE 120 */ 121 #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8 122 #define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \ 123 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE) 124 125 /* 126 * This section specifies SMC function IDs used when the secure monitor is 127 * invoked from the non-secure world. 128 */ 129 130 /* 131 * Load OP-TEE image from the payload specified in the registers. 132 * 133 * WARNING: Use this cautiously as it could lead to insecure loading of the 134 * Trusted OS. Further details are in opteed.mk. 135 * 136 * Call register usage: 137 * x0 SMC Function ID, OPTEE_SMC_CALL_LOAD_IMAGE 138 * x1 Upper 32bit of a 64bit size for the payload 139 * x2 Lower 32bit of a 64bit size for the payload 140 * x3 Upper 32bit of the physical address for the payload 141 * x4 Lower 32bit of the physical address for the payload 142 * 143 * The payload consists of a optee_header struct that contains optee_image 144 * structs in a flex array, immediately following that in memory is the data 145 * referenced by the optee_image structs. 146 * Example: 147 * 148 * struct optee_header (with n images specified) 149 * image 0 data 150 * image 1 data 151 * ... 152 * image n-1 data 153 * 154 * Returns 0 on success and an error code otherwise. 155 */ 156 #define NSSMC_OPTEED_FUNCID_LOAD_IMAGE 2 157 #define NSSMC_OPTEED_CALL_LOAD_IMAGE \ 158 NSSMC_OPTEED_CALL(NSSMC_OPTEED_FUNCID_LOAD_IMAGE) 159 160 /* 161 * Returns the UID of the OP-TEE image loading service if image loading is 162 * enabled and the image had not been loaded yet. Otherwise this call will be 163 * passed through to OP-TEE where it will return the OP-TEE UID. 164 */ 165 #define NSSMC_OPTEED_FUNCID_CALLS_UID 0xFF01 166 #define NSSMC_OPTEED_CALL_UID \ 167 NSSMC_OPTEED_CALL(NSSMC_OPTEED_FUNCID_CALLS_UID) 168 169 #endif /*TEESMC_OPTEED_H*/ 170