Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 1 | /* |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 2 | * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | /******************************************************************************* |
| 33 | * This is the Secure Payload Dispatcher (SPD). The dispatcher is meant to be a |
| 34 | * plug-in component to the Secure Monitor, registered as a runtime service. The |
| 35 | * SPD is expected to be a functional extension of the Secure Payload (SP) that |
| 36 | * executes in Secure EL1. The Secure Monitor will delegate all SMCs targeting |
| 37 | * the Trusted OS/Applications range to the dispatcher. The SPD will either |
| 38 | * handle the request locally or delegate it to the Secure Payload. It is also |
| 39 | * responsible for initialising and maintaining communication with the SP. |
| 40 | ******************************************************************************/ |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 41 | #include <arch_helpers.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 42 | #include <assert.h> |
| 43 | #include <bl_common.h> |
| 44 | #include <bl31.h> |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 45 | #include <context_mgmt.h> |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 46 | #include <debug.h> |
| 47 | #include <errno.h> |
| 48 | #include <platform.h> |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 49 | #include <runtime_svc.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 50 | #include <stddef.h> |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 51 | #include <string.h> |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 52 | #include <tsp.h> |
Jeenu Viswambharan | df1ddb5 | 2014-02-28 11:23:35 +0000 | [diff] [blame] | 53 | #include <uuid.h> |
Dan Handley | 714a0d2 | 2014-04-09 13:13:04 +0100 | [diff] [blame] | 54 | #include "tspd_private.h" |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 55 | |
| 56 | /******************************************************************************* |
Andrew Thoelke | 891c4ca | 2014-05-20 21:43:27 +0100 | [diff] [blame] | 57 | * Address of the entrypoint vector table in the Secure Payload. It is |
| 58 | * initialised once on the primary core after a cold boot. |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 59 | ******************************************************************************/ |
Andrew Thoelke | 891c4ca | 2014-05-20 21:43:27 +0100 | [diff] [blame] | 60 | tsp_vectors_t *tsp_vectors; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 61 | |
| 62 | /******************************************************************************* |
| 63 | * Array to keep track of per-cpu Secure Payload state |
| 64 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 65 | tsp_context_t tspd_sp_context[TSPD_CORE_COUNT]; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 66 | |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 67 | |
Jeenu Viswambharan | df1ddb5 | 2014-02-28 11:23:35 +0000 | [diff] [blame] | 68 | /* TSP UID */ |
| 69 | DEFINE_SVC_UUID(tsp_uuid, |
| 70 | 0x5b3056a0, 0x3291, 0x427b, 0x98, 0x11, |
| 71 | 0x71, 0x68, 0xca, 0x50, 0xf3, 0xfa); |
| 72 | |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 73 | int32_t tspd_init(void); |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 74 | |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 75 | uint64_t tspd_handle_sp_preemption(void *handle) |
| 76 | { |
| 77 | cpu_context_t *ns_cpu_context; |
| 78 | assert(handle == cm_get_context(SECURE)); |
| 79 | cm_el1_sysregs_context_save(SECURE); |
| 80 | /* Get a reference to the non-secure context */ |
| 81 | ns_cpu_context = cm_get_context(NON_SECURE); |
| 82 | assert(ns_cpu_context); |
| 83 | |
| 84 | /* |
| 85 | * Restore non-secure state. The secure system |
| 86 | * register context will be saved when required. |
| 87 | */ |
| 88 | cm_el1_sysregs_context_restore(NON_SECURE); |
| 89 | cm_set_next_eret_context(NON_SECURE); |
| 90 | |
| 91 | SMC_RET1(ns_cpu_context, SMC_PREEMPTED); |
| 92 | } |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 93 | /******************************************************************************* |
| 94 | * This function is the handler registered for S-EL1 interrupts by the TSPD. It |
| 95 | * validates the interrupt and upon success arranges entry into the TSP at |
| 96 | * 'tsp_fiq_entry()' for handling the interrupt. |
| 97 | ******************************************************************************/ |
| 98 | static uint64_t tspd_sel1_interrupt_handler(uint32_t id, |
| 99 | uint32_t flags, |
| 100 | void *handle, |
| 101 | void *cookie) |
| 102 | { |
| 103 | uint32_t linear_id; |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 104 | tsp_context_t *tsp_ctx; |
| 105 | |
| 106 | /* Check the security state when the exception was generated */ |
| 107 | assert(get_interrupt_src_ss(flags) == NON_SECURE); |
| 108 | |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 109 | /* Sanity check the pointer to this cpu's context */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 110 | assert(handle == cm_get_context(NON_SECURE)); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 111 | |
| 112 | /* Save the non-secure context before entering the TSP */ |
| 113 | cm_el1_sysregs_context_save(NON_SECURE); |
| 114 | |
| 115 | /* Get a reference to this cpu's TSP context */ |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 116 | linear_id = plat_my_core_pos(); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 117 | tsp_ctx = &tspd_sp_context[linear_id]; |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 118 | assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE)); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 119 | |
| 120 | /* |
| 121 | * Determine if the TSP was previously preempted. Its last known |
| 122 | * context has to be preserved in this case. |
| 123 | * The TSP should return control to the TSPD after handling this |
| 124 | * FIQ. Preserve essential EL3 context to allow entry into the |
| 125 | * TSP at the FIQ entry point using the 'cpu_context' structure. |
| 126 | * There is no need to save the secure system register context |
| 127 | * since the TSP is supposed to preserve it during S-EL1 interrupt |
| 128 | * handling. |
| 129 | */ |
| 130 | if (get_std_smc_active_flag(tsp_ctx->state)) { |
| 131 | tsp_ctx->saved_spsr_el3 = SMC_GET_EL3(&tsp_ctx->cpu_ctx, |
| 132 | CTX_SPSR_EL3); |
| 133 | tsp_ctx->saved_elr_el3 = SMC_GET_EL3(&tsp_ctx->cpu_ctx, |
| 134 | CTX_ELR_EL3); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 135 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 136 | /*Need to save the previously interrupted secure context */ |
| 137 | memcpy(&tsp_ctx->sp_ctx, &tsp_ctx->cpu_ctx, TSPD_SP_CTX_SIZE); |
| 138 | #endif |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 141 | cm_el1_sysregs_context_restore(SECURE); |
Andrew Thoelke | 4e12607 | 2014-06-04 21:10:52 +0100 | [diff] [blame] | 142 | cm_set_elr_spsr_el3(SECURE, (uint64_t) &tsp_vectors->fiq_entry, |
| 143 | SPSR_64(MODE_EL1, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS)); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 144 | |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 145 | cm_set_next_eret_context(SECURE); |
| 146 | |
| 147 | /* |
| 148 | * Tell the TSP that it has to handle an FIQ synchronously. Also the |
| 149 | * instruction in normal world where the interrupt was generated is |
| 150 | * passed for debugging purposes. It is safe to retrieve this address |
| 151 | * from ELR_EL3 as the secure context will not take effect until |
| 152 | * el3_exit(). |
| 153 | */ |
| 154 | SMC_RET2(&tsp_ctx->cpu_ctx, TSP_HANDLE_FIQ_AND_RETURN, read_elr_el3()); |
| 155 | } |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 156 | |
| 157 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 158 | /******************************************************************************* |
| 159 | * This function is the handler registered for S-EL1 interrupts by the TSPD. It |
| 160 | * validates the interrupt and upon success arranges entry into the TSP at |
| 161 | * 'tsp_fiq_entry()' for handling the interrupt. |
| 162 | ******************************************************************************/ |
| 163 | static uint64_t tspd_ns_interrupt_handler(uint32_t id, |
| 164 | uint32_t flags, |
| 165 | void *handle, |
| 166 | void *cookie) |
| 167 | { |
| 168 | /* Check the security state when the exception was generated */ |
| 169 | assert(get_interrupt_src_ss(flags) == SECURE); |
| 170 | |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 171 | /* |
| 172 | * Disable the routing of NS interrupts from secure world to EL3 while |
| 173 | * interrupted on this core. |
| 174 | */ |
| 175 | disable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 176 | |
| 177 | return tspd_handle_sp_preemption(handle); |
| 178 | } |
| 179 | #endif |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 180 | |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 181 | /******************************************************************************* |
| 182 | * Secure Payload Dispatcher setup. The SPD finds out the SP entrypoint and type |
| 183 | * (aarch32/aarch64) if not already known and initialises the context for entry |
| 184 | * into the SP for its initialisation. |
| 185 | ******************************************************************************/ |
| 186 | int32_t tspd_setup(void) |
| 187 | { |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 188 | entry_point_info_t *tsp_ep_info; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 189 | uint32_t linear_id; |
| 190 | |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 191 | linear_id = plat_my_core_pos(); |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 192 | |
| 193 | /* |
| 194 | * Get information about the Secure Payload (BL32) image. Its |
| 195 | * absence is a critical failure. TODO: Add support to |
| 196 | * conditionally include the SPD service |
| 197 | */ |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 198 | tsp_ep_info = bl31_plat_get_next_image_ep_info(SECURE); |
| 199 | if (!tsp_ep_info) { |
| 200 | WARN("No TSP provided by BL2 boot loader, Booting device" |
| 201 | " without TSP initialization. SMC`s destined for TSP" |
| 202 | " will return SMC_UNK\n"); |
| 203 | return 1; |
| 204 | } |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 205 | |
| 206 | /* |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 207 | * If there's no valid entry point for SP, we return a non-zero value |
| 208 | * signalling failure initializing the service. We bail out without |
| 209 | * registering any handlers |
| 210 | */ |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 211 | if (!tsp_ep_info->pc) |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 212 | return 1; |
| 213 | |
| 214 | /* |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 215 | * We could inspect the SP image and determine it's execution |
| 216 | * state i.e whether AArch32 or AArch64. Assuming it's AArch64 |
| 217 | * for the time being. |
| 218 | */ |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 219 | tspd_init_tsp_ep_state(tsp_ep_info, |
| 220 | TSP_AARCH64, |
| 221 | tsp_ep_info->pc, |
| 222 | &tspd_sp_context[linear_id]); |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 223 | |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 224 | #if TSP_INIT_ASYNC |
| 225 | bl31_set_next_image_type(SECURE); |
| 226 | #else |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 227 | /* |
| 228 | * All TSPD initialization done. Now register our init function with |
| 229 | * BL31 for deferred invocation |
| 230 | */ |
| 231 | bl31_register_bl32_init(&tspd_init); |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 232 | #endif |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 233 | return 0; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /******************************************************************************* |
| 237 | * This function passes control to the Secure Payload image (BL32) for the first |
| 238 | * time on the primary cpu after a cold boot. It assumes that a valid secure |
| 239 | * context has already been created by tspd_setup() which can be directly used. |
| 240 | * It also assumes that a valid non-secure context has been initialised by PSCI |
| 241 | * so it does not need to save and restore any non-secure state. This function |
| 242 | * performs a synchronous entry into the Secure payload. The SP passes control |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 243 | * back to this routine through a SMC. |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 244 | ******************************************************************************/ |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 245 | int32_t tspd_init(void) |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 246 | { |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 247 | uint32_t linear_id = plat_my_core_pos(); |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 248 | tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 249 | entry_point_info_t *tsp_entry_point; |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 250 | uint64_t rc; |
Vikram Kanigiri | 9d70f0f | 2014-07-15 16:46:43 +0100 | [diff] [blame] | 251 | |
| 252 | /* |
| 253 | * Get information about the Secure Payload (BL32) image. Its |
| 254 | * absence is a critical failure. |
| 255 | */ |
| 256 | tsp_entry_point = bl31_plat_get_next_image_ep_info(SECURE); |
| 257 | assert(tsp_entry_point); |
| 258 | |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 259 | cm_init_my_context(tsp_entry_point); |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 260 | |
| 261 | /* |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 262 | * Arrange for an entry into the test secure payload. It will be |
| 263 | * returned via TSP_ENTRY_DONE case |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 264 | */ |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 265 | rc = tspd_synchronous_sp_entry(tsp_ctx); |
| 266 | assert(rc != 0); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 267 | |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 268 | return rc; |
| 269 | } |
| 270 | |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 271 | |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 272 | /******************************************************************************* |
| 273 | * This function is responsible for handling all SMCs in the Trusted OS/App |
| 274 | * range from the non-secure state as defined in the SMC Calling Convention |
| 275 | * Document. It is also responsible for communicating with the Secure payload |
| 276 | * to delegate work and return results back to the non-secure state. Lastly it |
| 277 | * will also return any information that the secure payload needs to do the |
| 278 | * work assigned to it. |
| 279 | ******************************************************************************/ |
| 280 | uint64_t tspd_smc_handler(uint32_t smc_fid, |
| 281 | uint64_t x1, |
| 282 | uint64_t x2, |
| 283 | uint64_t x3, |
| 284 | uint64_t x4, |
| 285 | void *cookie, |
| 286 | void *handle, |
| 287 | uint64_t flags) |
| 288 | { |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 289 | cpu_context_t *ns_cpu_context; |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 290 | uint32_t linear_id = plat_my_core_pos(), ns; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 291 | tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 292 | uint64_t rc; |
| 293 | #if TSP_INIT_ASYNC |
| 294 | entry_point_info_t *next_image_info; |
| 295 | #endif |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 296 | |
| 297 | /* Determine which security state this SMC originated from */ |
| 298 | ns = is_caller_non_secure(flags); |
| 299 | |
| 300 | switch (smc_fid) { |
| 301 | |
| 302 | /* |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 303 | * This function ID is used by TSP to indicate that it was |
| 304 | * preempted by a normal world IRQ. |
| 305 | * |
| 306 | */ |
| 307 | case TSP_PREEMPTED: |
| 308 | if (ns) |
| 309 | SMC_RET1(handle, SMC_UNK); |
| 310 | |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 311 | return tspd_handle_sp_preemption(handle); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 312 | |
| 313 | /* |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 314 | * This function ID is used only by the TSP to indicate that it has |
| 315 | * finished handling a S-EL1 FIQ interrupt. Execution should resume |
| 316 | * in the normal world. |
| 317 | */ |
| 318 | case TSP_HANDLED_S_EL1_FIQ: |
| 319 | if (ns) |
| 320 | SMC_RET1(handle, SMC_UNK); |
| 321 | |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 322 | assert(handle == cm_get_context(SECURE)); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 323 | |
| 324 | /* |
| 325 | * Restore the relevant EL3 state which saved to service |
| 326 | * this SMC. |
| 327 | */ |
| 328 | if (get_std_smc_active_flag(tsp_ctx->state)) { |
| 329 | SMC_SET_EL3(&tsp_ctx->cpu_ctx, |
| 330 | CTX_SPSR_EL3, |
| 331 | tsp_ctx->saved_spsr_el3); |
| 332 | SMC_SET_EL3(&tsp_ctx->cpu_ctx, |
| 333 | CTX_ELR_EL3, |
| 334 | tsp_ctx->saved_elr_el3); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 335 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 336 | /* |
| 337 | * Need to restore the previously interrupted |
| 338 | * secure context. |
| 339 | */ |
| 340 | memcpy(&tsp_ctx->cpu_ctx, &tsp_ctx->sp_ctx, |
| 341 | TSPD_SP_CTX_SIZE); |
| 342 | #endif |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /* Get a reference to the non-secure context */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 346 | ns_cpu_context = cm_get_context(NON_SECURE); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 347 | assert(ns_cpu_context); |
| 348 | |
| 349 | /* |
| 350 | * Restore non-secure state. There is no need to save the |
| 351 | * secure system register context since the TSP was supposed |
| 352 | * to preserve it during S-EL1 interrupt handling. |
| 353 | */ |
| 354 | cm_el1_sysregs_context_restore(NON_SECURE); |
| 355 | cm_set_next_eret_context(NON_SECURE); |
| 356 | |
| 357 | SMC_RET0((uint64_t) ns_cpu_context); |
| 358 | |
| 359 | |
| 360 | /* |
| 361 | * This function ID is used only by the TSP to indicate that it was |
| 362 | * interrupted due to a EL3 FIQ interrupt. Execution should resume |
| 363 | * in the normal world. |
| 364 | */ |
| 365 | case TSP_EL3_FIQ: |
| 366 | if (ns) |
| 367 | SMC_RET1(handle, SMC_UNK); |
| 368 | |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 369 | assert(handle == cm_get_context(SECURE)); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 370 | |
| 371 | /* Assert that standard SMC execution has been preempted */ |
| 372 | assert(get_std_smc_active_flag(tsp_ctx->state)); |
| 373 | |
| 374 | /* Save the secure system register state */ |
| 375 | cm_el1_sysregs_context_save(SECURE); |
| 376 | |
| 377 | /* Get a reference to the non-secure context */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 378 | ns_cpu_context = cm_get_context(NON_SECURE); |
Achin Gupta | aeaab68 | 2014-05-09 13:21:31 +0100 | [diff] [blame] | 379 | assert(ns_cpu_context); |
| 380 | |
| 381 | /* Restore non-secure state */ |
| 382 | cm_el1_sysregs_context_restore(NON_SECURE); |
| 383 | cm_set_next_eret_context(NON_SECURE); |
| 384 | |
| 385 | SMC_RET1(ns_cpu_context, TSP_EL3_FIQ); |
| 386 | |
| 387 | |
| 388 | /* |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 389 | * This function ID is used only by the SP to indicate it has |
| 390 | * finished initialising itself after a cold boot |
| 391 | */ |
| 392 | case TSP_ENTRY_DONE: |
| 393 | if (ns) |
| 394 | SMC_RET1(handle, SMC_UNK); |
| 395 | |
| 396 | /* |
| 397 | * Stash the SP entry points information. This is done |
| 398 | * only once on the primary cpu |
| 399 | */ |
Andrew Thoelke | 891c4ca | 2014-05-20 21:43:27 +0100 | [diff] [blame] | 400 | assert(tsp_vectors == NULL); |
| 401 | tsp_vectors = (tsp_vectors_t *) x1; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 402 | |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 403 | if (tsp_vectors) { |
| 404 | set_tsp_pstate(tsp_ctx->state, TSP_PSTATE_ON); |
| 405 | |
| 406 | /* |
| 407 | * TSP has been successfully initialized. Register power |
| 408 | * managemnt hooks with PSCI |
| 409 | */ |
| 410 | psci_register_spd_pm_hook(&tspd_pm); |
| 411 | |
| 412 | /* |
| 413 | * Register an interrupt handler for S-EL1 interrupts |
| 414 | * when generated during code executing in the |
| 415 | * non-secure state. |
| 416 | */ |
| 417 | flags = 0; |
| 418 | set_interrupt_rm_flag(flags, NON_SECURE); |
| 419 | rc = register_interrupt_type_handler(INTR_TYPE_S_EL1, |
| 420 | tspd_sel1_interrupt_handler, |
| 421 | flags); |
| 422 | if (rc) |
| 423 | panic(); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 424 | |
| 425 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 426 | /* |
| 427 | * Register an interrupt handler for NS interrupts when |
| 428 | * generated during code executing in secure state are |
| 429 | * routed to EL3. |
| 430 | */ |
| 431 | flags = 0; |
| 432 | set_interrupt_rm_flag(flags, SECURE); |
| 433 | |
| 434 | rc = register_interrupt_type_handler(INTR_TYPE_NS, |
| 435 | tspd_ns_interrupt_handler, |
| 436 | flags); |
| 437 | if (rc) |
| 438 | panic(); |
| 439 | |
| 440 | /* |
| 441 | * Disable the interrupt NS locally since it will be enabled globally |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 442 | * within cm_init_my_context. |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 443 | */ |
| 444 | disable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 445 | #endif |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | |
| 449 | #if TSP_INIT_ASYNC |
| 450 | /* Save the Secure EL1 system register context */ |
| 451 | assert(cm_get_context(SECURE) == &tsp_ctx->cpu_ctx); |
| 452 | cm_el1_sysregs_context_save(SECURE); |
| 453 | |
| 454 | /* Program EL3 registers to enable entry into the next EL */ |
| 455 | next_image_info = bl31_plat_get_next_image_ep_info(NON_SECURE); |
| 456 | assert(next_image_info); |
| 457 | assert(NON_SECURE == |
| 458 | GET_SECURITY_STATE(next_image_info->h.attr)); |
| 459 | |
Soby Mathew | da43b66 | 2015-07-08 21:45:46 +0100 | [diff] [blame] | 460 | cm_init_my_context(next_image_info); |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 461 | cm_prepare_el3_exit(NON_SECURE); |
| 462 | SMC_RET0(cm_get_context(NON_SECURE)); |
| 463 | #else |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 464 | /* |
| 465 | * SP reports completion. The SPD must have initiated |
| 466 | * the original request through a synchronous entry |
| 467 | * into the SP. Jump back to the original C runtime |
| 468 | * context. |
| 469 | */ |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 470 | tspd_synchronous_sp_exit(tsp_ctx, x1); |
Vikram Kanigiri | 4e81341 | 2014-07-15 16:49:22 +0100 | [diff] [blame] | 471 | #endif |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 472 | |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 473 | /* |
| 474 | * These function IDs is used only by the SP to indicate it has |
| 475 | * finished: |
| 476 | * 1. turning itself on in response to an earlier psci |
| 477 | * cpu_on request |
| 478 | * 2. resuming itself after an earlier psci cpu_suspend |
| 479 | * request. |
| 480 | */ |
| 481 | case TSP_ON_DONE: |
| 482 | case TSP_RESUME_DONE: |
| 483 | |
| 484 | /* |
| 485 | * These function IDs is used only by the SP to indicate it has |
| 486 | * finished: |
| 487 | * 1. suspending itself after an earlier psci cpu_suspend |
| 488 | * request. |
| 489 | * 2. turning itself off in response to an earlier psci |
| 490 | * cpu_off request. |
| 491 | */ |
| 492 | case TSP_OFF_DONE: |
| 493 | case TSP_SUSPEND_DONE: |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 494 | case TSP_SYSTEM_OFF_DONE: |
| 495 | case TSP_SYSTEM_RESET_DONE: |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 496 | if (ns) |
| 497 | SMC_RET1(handle, SMC_UNK); |
| 498 | |
| 499 | /* |
| 500 | * SP reports completion. The SPD must have initiated the |
| 501 | * original request through a synchronous entry into the SP. |
| 502 | * Jump back to the original C runtime context, and pass x1 as |
| 503 | * return value to the caller |
| 504 | */ |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 505 | tspd_synchronous_sp_exit(tsp_ctx, x1); |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 506 | |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 507 | /* |
| 508 | * Request from non-secure client to perform an |
| 509 | * arithmetic operation or response from secure |
| 510 | * payload to an earlier request. |
| 511 | */ |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 512 | case TSP_FAST_FID(TSP_ADD): |
| 513 | case TSP_FAST_FID(TSP_SUB): |
| 514 | case TSP_FAST_FID(TSP_MUL): |
| 515 | case TSP_FAST_FID(TSP_DIV): |
| 516 | |
| 517 | case TSP_STD_FID(TSP_ADD): |
| 518 | case TSP_STD_FID(TSP_SUB): |
| 519 | case TSP_STD_FID(TSP_MUL): |
| 520 | case TSP_STD_FID(TSP_DIV): |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 521 | if (ns) { |
| 522 | /* |
| 523 | * This is a fresh request from the non-secure client. |
| 524 | * The parameters are in x1 and x2. Figure out which |
| 525 | * registers need to be preserved, save the non-secure |
| 526 | * state and send the request to the secure payload. |
| 527 | */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 528 | assert(handle == cm_get_context(NON_SECURE)); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 529 | |
| 530 | /* Check if we are already preempted */ |
| 531 | if (get_std_smc_active_flag(tsp_ctx->state)) |
| 532 | SMC_RET1(handle, SMC_UNK); |
| 533 | |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 534 | cm_el1_sysregs_context_save(NON_SECURE); |
| 535 | |
| 536 | /* Save x1 and x2 for use by TSP_GET_ARGS call below */ |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 537 | store_tsp_args(tsp_ctx, x1, x2); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 538 | |
| 539 | /* |
| 540 | * We are done stashing the non-secure context. Ask the |
| 541 | * secure payload to do the work now. |
| 542 | */ |
| 543 | |
| 544 | /* |
| 545 | * Verify if there is a valid context to use, copy the |
| 546 | * operation type and parameters to the secure context |
| 547 | * and jump to the fast smc entry point in the secure |
| 548 | * payload. Entry into S-EL1 will take place upon exit |
| 549 | * from this function. |
| 550 | */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 551 | assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE)); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 552 | |
| 553 | /* Set appropriate entry for SMC. |
| 554 | * We expect the TSP to manage the PSTATE.I and PSTATE.F |
| 555 | * flags as appropriate. |
| 556 | */ |
| 557 | if (GET_SMC_TYPE(smc_fid) == SMC_TYPE_FAST) { |
| 558 | cm_set_elr_el3(SECURE, (uint64_t) |
Andrew Thoelke | 891c4ca | 2014-05-20 21:43:27 +0100 | [diff] [blame] | 559 | &tsp_vectors->fast_smc_entry); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 560 | } else { |
| 561 | set_std_smc_active_flag(tsp_ctx->state); |
| 562 | cm_set_elr_el3(SECURE, (uint64_t) |
Andrew Thoelke | 891c4ca | 2014-05-20 21:43:27 +0100 | [diff] [blame] | 563 | &tsp_vectors->std_smc_entry); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 564 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 565 | /* |
| 566 | * Enable the routing of NS interrupts to EL3 |
| 567 | * during STD SMC processing on this core. |
| 568 | */ |
| 569 | enable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 570 | #endif |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 571 | } |
| 572 | |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 573 | cm_el1_sysregs_context_restore(SECURE); |
| 574 | cm_set_next_eret_context(SECURE); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 575 | SMC_RET3(&tsp_ctx->cpu_ctx, smc_fid, x1, x2); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 576 | } else { |
| 577 | /* |
| 578 | * This is the result from the secure client of an |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 579 | * earlier request. The results are in x1-x3. Copy it |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 580 | * into the non-secure context, save the secure state |
| 581 | * and return to the non-secure state. |
| 582 | */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 583 | assert(handle == cm_get_context(SECURE)); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 584 | cm_el1_sysregs_context_save(SECURE); |
| 585 | |
| 586 | /* Get a reference to the non-secure context */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 587 | ns_cpu_context = cm_get_context(NON_SECURE); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 588 | assert(ns_cpu_context); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 589 | |
| 590 | /* Restore non-secure state */ |
| 591 | cm_el1_sysregs_context_restore(NON_SECURE); |
| 592 | cm_set_next_eret_context(NON_SECURE); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 593 | if (GET_SMC_TYPE(smc_fid) == SMC_TYPE_STD) { |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 594 | clr_std_smc_active_flag(tsp_ctx->state); |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 595 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 596 | /* |
| 597 | * Disable the routing of NS interrupts to EL3 |
| 598 | * after STD SMC processing is finished on this |
| 599 | * core. |
| 600 | */ |
| 601 | disable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 602 | #endif |
| 603 | } |
| 604 | |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 605 | SMC_RET3(ns_cpu_context, x1, x2, x3); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | break; |
| 609 | |
| 610 | /* |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 611 | * Request from non secure world to resume the preempted |
| 612 | * Standard SMC call. |
| 613 | */ |
| 614 | case TSP_FID_RESUME: |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 615 | /* RESUME should be invoked only by normal world */ |
| 616 | if (!ns) { |
| 617 | assert(0); |
| 618 | break; |
| 619 | } |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 620 | |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 621 | /* |
| 622 | * This is a resume request from the non-secure client. |
| 623 | * save the non-secure state and send the request to |
| 624 | * the secure payload. |
| 625 | */ |
Andrew Thoelke | a2f6553 | 2014-05-14 17:09:32 +0100 | [diff] [blame] | 626 | assert(handle == cm_get_context(NON_SECURE)); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 627 | |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 628 | /* Check if we are already preempted before resume */ |
| 629 | if (!get_std_smc_active_flag(tsp_ctx->state)) |
| 630 | SMC_RET1(handle, SMC_UNK); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 631 | |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 632 | cm_el1_sysregs_context_save(NON_SECURE); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 633 | |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 634 | /* |
| 635 | * We are done stashing the non-secure context. Ask the |
| 636 | * secure payload to do the work now. |
| 637 | */ |
Soby Mathew | 47903c0 | 2015-01-13 15:48:26 +0000 | [diff] [blame] | 638 | #if TSPD_ROUTE_IRQ_TO_EL3 |
| 639 | /* |
| 640 | * Enable the routing of NS interrupts to EL3 during resumption |
| 641 | * of STD SMC call on this core. |
| 642 | */ |
| 643 | enable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 644 | #endif |
| 645 | |
| 646 | |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 647 | |
Soby Mathew | 3d57851 | 2014-05-27 10:20:01 +0100 | [diff] [blame] | 648 | /* We just need to return to the preempted point in |
| 649 | * TSP and the execution will resume as normal. |
| 650 | */ |
| 651 | cm_el1_sysregs_context_restore(SECURE); |
| 652 | cm_set_next_eret_context(SECURE); |
| 653 | SMC_RET0(&tsp_ctx->cpu_ctx); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 654 | |
| 655 | /* |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 656 | * This is a request from the secure payload for more arguments |
| 657 | * for an ongoing arithmetic operation requested by the |
| 658 | * non-secure world. Simply return the arguments from the non- |
| 659 | * secure client in the original call. |
| 660 | */ |
| 661 | case TSP_GET_ARGS: |
| 662 | if (ns) |
| 663 | SMC_RET1(handle, SMC_UNK); |
| 664 | |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 665 | get_tsp_args(tsp_ctx, x1, x2); |
| 666 | SMC_RET2(handle, x1, x2); |
Achin Gupta | 916a2c1 | 2014-02-09 23:11:46 +0000 | [diff] [blame] | 667 | |
Jeenu Viswambharan | df1ddb5 | 2014-02-28 11:23:35 +0000 | [diff] [blame] | 668 | case TOS_CALL_COUNT: |
| 669 | /* |
| 670 | * Return the number of service function IDs implemented to |
| 671 | * provide service to non-secure |
| 672 | */ |
| 673 | SMC_RET1(handle, TSP_NUM_FID); |
| 674 | |
| 675 | case TOS_UID: |
| 676 | /* Return TSP UID to the caller */ |
| 677 | SMC_UUID_RET(handle, tsp_uuid); |
| 678 | |
| 679 | case TOS_CALL_VERSION: |
| 680 | /* Return the version of current implementation */ |
| 681 | SMC_RET2(handle, TSP_VERSION_MAJOR, TSP_VERSION_MINOR); |
| 682 | |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 683 | default: |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 684 | break; |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 685 | } |
| 686 | |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 687 | SMC_RET1(handle, SMC_UNK); |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 688 | } |
| 689 | |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 690 | /* Define a SPD runtime service descriptor for fast SMC calls */ |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 691 | DECLARE_RT_SVC( |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 692 | tspd_fast, |
Achin Gupta | 375f538 | 2014-02-18 18:12:48 +0000 | [diff] [blame] | 693 | |
| 694 | OEN_TOS_START, |
| 695 | OEN_TOS_END, |
| 696 | SMC_TYPE_FAST, |
| 697 | tspd_setup, |
| 698 | tspd_smc_handler |
| 699 | ); |
Soby Mathew | 9f71f70 | 2014-05-09 20:49:17 +0100 | [diff] [blame] | 700 | |
| 701 | /* Define a SPD runtime service descriptor for standard SMC calls */ |
| 702 | DECLARE_RT_SVC( |
| 703 | tspd_std, |
| 704 | |
| 705 | OEN_TOS_START, |
| 706 | OEN_TOS_END, |
| 707 | SMC_TYPE_STD, |
| 708 | NULL, |
| 709 | tspd_smc_handler |
| 710 | ); |