122038315SVarun Wadekar /* 262d862ebSVarun Wadekar * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 322038315SVarun Wadekar * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 522038315SVarun Wadekar */ 622038315SVarun Wadekar 722038315SVarun Wadekar /******************************************************************************* 822038315SVarun Wadekar * This is the Secure Payload Dispatcher (SPD). The dispatcher is meant to be a 922038315SVarun Wadekar * plug-in component to the Secure Monitor, registered as a runtime service. The 1022038315SVarun Wadekar * SPD is expected to be a functional extension of the Secure Payload (SP) that 1122038315SVarun Wadekar * executes in Secure EL1. The Secure Monitor will delegate all SMCs targeting 1222038315SVarun Wadekar * the Trusted OS/Applications range to the dispatcher. The SPD will either 1322038315SVarun Wadekar * handle the request locally or delegate it to the Secure Payload. It is also 1422038315SVarun Wadekar * responsible for initialising and maintaining communication with the SP. 1522038315SVarun Wadekar ******************************************************************************/ 1622038315SVarun Wadekar #include <arch_helpers.h> 1722038315SVarun Wadekar #include <assert.h> 1822038315SVarun Wadekar #include <bl31.h> 192a4b4b71SIsla Mitchell #include <bl_common.h> 2022038315SVarun Wadekar #include <context_mgmt.h> 2122038315SVarun Wadekar #include <debug.h> 2222038315SVarun Wadekar #include <errno.h> 2322038315SVarun Wadekar #include <platform.h> 2422038315SVarun Wadekar #include <runtime_svc.h> 2522038315SVarun Wadekar #include <stddef.h> 2622038315SVarun Wadekar #include <tlk.h> 2722038315SVarun Wadekar #include <uuid.h> 2822038315SVarun Wadekar #include "tlkd_private.h" 2922038315SVarun Wadekar 3022038315SVarun Wadekar extern const spd_pm_ops_t tlkd_pm_ops; 3122038315SVarun Wadekar 3222038315SVarun Wadekar /******************************************************************************* 33cb790c5eSVarun Wadekar * Per-cpu Secure Payload state 3422038315SVarun Wadekar ******************************************************************************/ 35cb790c5eSVarun Wadekar tlk_context_t tlk_ctx; 3622038315SVarun Wadekar 3726670c82SVarun Wadekar /******************************************************************************* 3826670c82SVarun Wadekar * CPU number on which TLK booted up 3926670c82SVarun Wadekar ******************************************************************************/ 406311f63dSVarun Wadekar static uint32_t boot_cpu; 4126670c82SVarun Wadekar 4222038315SVarun Wadekar /* TLK UID: RFC-4122 compliant UUID (version-5, sha-1) */ 4322038315SVarun Wadekar DEFINE_SVC_UUID(tlk_uuid, 4422038315SVarun Wadekar 0xbd11e9c9, 0x2bba, 0x52ee, 0xb1, 0x72, 4522038315SVarun Wadekar 0x46, 0x1f, 0xba, 0x97, 0x7f, 0x63); 4622038315SVarun Wadekar 47724fd958SMasahiro Yamada static int32_t tlkd_init(void); 4822038315SVarun Wadekar 4922038315SVarun Wadekar /******************************************************************************* 5022038315SVarun Wadekar * Secure Payload Dispatcher setup. The SPD finds out the SP entrypoint and type 5122038315SVarun Wadekar * (aarch32/aarch64) if not already known and initialises the context for entry 5222038315SVarun Wadekar * into the SP for its initialisation. 5322038315SVarun Wadekar ******************************************************************************/ 54724fd958SMasahiro Yamada static int32_t tlkd_setup(void) 5522038315SVarun Wadekar { 5622038315SVarun Wadekar entry_point_info_t *tlk_ep_info; 5722038315SVarun Wadekar 5822038315SVarun Wadekar /* 5922038315SVarun Wadekar * Get information about the Secure Payload (BL32) image. Its 6022038315SVarun Wadekar * absence is a critical failure. 6122038315SVarun Wadekar */ 6222038315SVarun Wadekar tlk_ep_info = bl31_plat_get_next_image_ep_info(SECURE); 6322038315SVarun Wadekar if (!tlk_ep_info) { 6422038315SVarun Wadekar WARN("No SP provided. Booting device without SP" 6522038315SVarun Wadekar " initialization. SMC`s destined for SP" 6622038315SVarun Wadekar " will return SMC_UNK\n"); 6722038315SVarun Wadekar return 1; 6822038315SVarun Wadekar } 6922038315SVarun Wadekar 7022038315SVarun Wadekar /* 7122038315SVarun Wadekar * If there's no valid entry point for SP, we return a non-zero value 7222038315SVarun Wadekar * signalling failure initializing the service. We bail out without 7322038315SVarun Wadekar * registering any handlers 7422038315SVarun Wadekar */ 7522038315SVarun Wadekar if (!tlk_ep_info->pc) 7622038315SVarun Wadekar return 1; 7722038315SVarun Wadekar 7822038315SVarun Wadekar /* 7922038315SVarun Wadekar * Inspect the SP image's SPSR and determine it's execution state 8022038315SVarun Wadekar * i.e whether AArch32 or AArch64. 8122038315SVarun Wadekar */ 8222038315SVarun Wadekar tlkd_init_tlk_ep_state(tlk_ep_info, 8322038315SVarun Wadekar (tlk_ep_info->spsr >> MODE_RW_SHIFT) & MODE_RW_MASK, 8422038315SVarun Wadekar tlk_ep_info->pc, 8522038315SVarun Wadekar &tlk_ctx); 8622038315SVarun Wadekar 8722038315SVarun Wadekar /* 8822038315SVarun Wadekar * All TLK SPD initialization done. Now register our init function 8922038315SVarun Wadekar * with BL31 for deferred invocation 9022038315SVarun Wadekar */ 9122038315SVarun Wadekar bl31_register_bl32_init(&tlkd_init); 9222038315SVarun Wadekar 9322038315SVarun Wadekar return 0; 9422038315SVarun Wadekar } 9522038315SVarun Wadekar 9622038315SVarun Wadekar /******************************************************************************* 9722038315SVarun Wadekar * This function passes control to the Secure Payload image (BL32) for the first 9822038315SVarun Wadekar * time on the primary cpu after a cold boot. It assumes that a valid secure 9922038315SVarun Wadekar * context has already been created by tlkd_setup() which can be directly 10022038315SVarun Wadekar * used. This function performs a synchronous entry into the Secure payload. 10122038315SVarun Wadekar * The SP passes control back to this routine through a SMC. 10222038315SVarun Wadekar ******************************************************************************/ 103724fd958SMasahiro Yamada static int32_t tlkd_init(void) 10422038315SVarun Wadekar { 10522038315SVarun Wadekar entry_point_info_t *tlk_entry_point; 10622038315SVarun Wadekar 10722038315SVarun Wadekar /* 10822038315SVarun Wadekar * Get information about the Secure Payload (BL32) image. Its 10922038315SVarun Wadekar * absence is a critical failure. 11022038315SVarun Wadekar */ 11122038315SVarun Wadekar tlk_entry_point = bl31_plat_get_next_image_ep_info(SECURE); 11222038315SVarun Wadekar assert(tlk_entry_point); 11322038315SVarun Wadekar 114fd650ff6SSoby Mathew cm_init_my_context(tlk_entry_point); 11522038315SVarun Wadekar 11622038315SVarun Wadekar /* 11726670c82SVarun Wadekar * TLK runs only on a single CPU. Store the value of the boot 11826670c82SVarun Wadekar * CPU for sanity checking later. 11926670c82SVarun Wadekar */ 12026670c82SVarun Wadekar boot_cpu = plat_my_core_pos(); 12126670c82SVarun Wadekar 12226670c82SVarun Wadekar /* 12322038315SVarun Wadekar * Arrange for an entry into the test secure payload. 12422038315SVarun Wadekar */ 12522038315SVarun Wadekar return tlkd_synchronous_sp_entry(&tlk_ctx); 12622038315SVarun Wadekar } 12722038315SVarun Wadekar 12822038315SVarun Wadekar /******************************************************************************* 12922038315SVarun Wadekar * This function is responsible for handling all SMCs in the Trusted OS/App 13022038315SVarun Wadekar * range from the non-secure state as defined in the SMC Calling Convention 13122038315SVarun Wadekar * Document. It is also responsible for communicating with the Secure payload 13222038315SVarun Wadekar * to delegate work and return results back to the non-secure state. Lastly it 13322038315SVarun Wadekar * will also return any information that the secure payload needs to do the 13422038315SVarun Wadekar * work assigned to it. 13522038315SVarun Wadekar ******************************************************************************/ 136*57d1e5faSMasahiro Yamada static uintptr_t tlkd_smc_handler(uint32_t smc_fid, 137*57d1e5faSMasahiro Yamada u_register_t x1, 138*57d1e5faSMasahiro Yamada u_register_t x2, 139*57d1e5faSMasahiro Yamada u_register_t x3, 140*57d1e5faSMasahiro Yamada u_register_t x4, 14122038315SVarun Wadekar void *cookie, 14222038315SVarun Wadekar void *handle, 143*57d1e5faSMasahiro Yamada u_register_t flags) 14422038315SVarun Wadekar { 14577199df7SVarun Wadekar cpu_context_t *ns_cpu_context; 146709a3c47SVarun Wadekar gp_regs_t *gp_regs; 14722038315SVarun Wadekar uint32_t ns; 148709a3c47SVarun Wadekar uint64_t par; 14922038315SVarun Wadekar 15022038315SVarun Wadekar /* Passing a NULL context is a critical programming error */ 15122038315SVarun Wadekar assert(handle); 15222038315SVarun Wadekar 15326670c82SVarun Wadekar /* These SMCs are only supported by a single CPU */ 15426670c82SVarun Wadekar if (boot_cpu != plat_my_core_pos()) 1556693962cSVarun Wadekar SMC_RET1(handle, SMC_UNK); 1566693962cSVarun Wadekar 15722038315SVarun Wadekar /* Determine which security state this SMC originated from */ 15822038315SVarun Wadekar ns = is_caller_non_secure(flags); 15922038315SVarun Wadekar 16022038315SVarun Wadekar switch (smc_fid) { 16122038315SVarun Wadekar 16222038315SVarun Wadekar /* 163f9d25054SVarun Wadekar * This function ID is used by SP to indicate that it was 164f9d25054SVarun Wadekar * preempted by a non-secure world IRQ. 165f9d25054SVarun Wadekar */ 166f9d25054SVarun Wadekar case TLK_PREEMPTED: 167f9d25054SVarun Wadekar 168f9d25054SVarun Wadekar if (ns) 169f9d25054SVarun Wadekar SMC_RET1(handle, SMC_UNK); 170f9d25054SVarun Wadekar 171f9d25054SVarun Wadekar assert(handle == cm_get_context(SECURE)); 172f9d25054SVarun Wadekar cm_el1_sysregs_context_save(SECURE); 173f9d25054SVarun Wadekar 174f9d25054SVarun Wadekar /* Get a reference to the non-secure context */ 175f9d25054SVarun Wadekar ns_cpu_context = cm_get_context(NON_SECURE); 176f9d25054SVarun Wadekar assert(ns_cpu_context); 177f9d25054SVarun Wadekar 178f9d25054SVarun Wadekar /* 179f9d25054SVarun Wadekar * Restore non-secure state. There is no need to save the 180f9d25054SVarun Wadekar * secure system register context since the SP was supposed 181f9d25054SVarun Wadekar * to preserve it during S-EL1 interrupt handling. 182f9d25054SVarun Wadekar */ 183f9d25054SVarun Wadekar cm_el1_sysregs_context_restore(NON_SECURE); 184f9d25054SVarun Wadekar cm_set_next_eret_context(NON_SECURE); 185f9d25054SVarun Wadekar 186709a3c47SVarun Wadekar SMC_RET1(ns_cpu_context, x1); 187f9d25054SVarun Wadekar 188f9d25054SVarun Wadekar /* 18977199df7SVarun Wadekar * This is a request from the non-secure context to: 19077199df7SVarun Wadekar * 19177199df7SVarun Wadekar * a. register shared memory with the SP for storing it's 19277199df7SVarun Wadekar * activity logs. 19377199df7SVarun Wadekar * b. register shared memory with the SP for passing args 19477199df7SVarun Wadekar * required for maintaining sessions with the Trusted 19577199df7SVarun Wadekar * Applications. 19662d862ebSVarun Wadekar * c. register non-secure world's memory map with the OS 19762d862ebSVarun Wadekar * d. open/close sessions 19862d862ebSVarun Wadekar * e. issue commands to the Trusted Apps 19962d862ebSVarun Wadekar * f. resume the preempted yielding SMC call. 20077199df7SVarun Wadekar */ 20177199df7SVarun Wadekar case TLK_REGISTER_LOGBUF: 20277199df7SVarun Wadekar case TLK_REGISTER_REQBUF: 20362d862ebSVarun Wadekar case TLK_REGISTER_NS_DRAM: 2046693962cSVarun Wadekar case TLK_OPEN_TA_SESSION: 2056693962cSVarun Wadekar case TLK_CLOSE_TA_SESSION: 2066693962cSVarun Wadekar case TLK_TA_LAUNCH_OP: 2076693962cSVarun Wadekar case TLK_TA_SEND_EVENT: 208ca15d9bcSVarun Wadekar case TLK_RESUME_FID: 2096693962cSVarun Wadekar 210709a3c47SVarun Wadekar if (!ns) 21177199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 21277199df7SVarun Wadekar 21377199df7SVarun Wadekar /* 21477199df7SVarun Wadekar * This is a fresh request from the non-secure client. 21577199df7SVarun Wadekar * The parameters are in x1 and x2. Figure out which 21677199df7SVarun Wadekar * registers need to be preserved, save the non-secure 21777199df7SVarun Wadekar * state and send the request to the secure payload. 21877199df7SVarun Wadekar */ 21977199df7SVarun Wadekar assert(handle == cm_get_context(NON_SECURE)); 22077199df7SVarun Wadekar 221ca15d9bcSVarun Wadekar /* 222bbbbcdaeSDavid Cunado * Check if we are already processing a yielding SMC 223ca15d9bcSVarun Wadekar * call. Of all the supported fids, only the "resume" 224ca15d9bcSVarun Wadekar * fid expects the flag to be set. 225ca15d9bcSVarun Wadekar */ 226ca15d9bcSVarun Wadekar if (smc_fid == TLK_RESUME_FID) { 227bbbbcdaeSDavid Cunado if (!get_yield_smc_active_flag(tlk_ctx.state)) 228ca15d9bcSVarun Wadekar SMC_RET1(handle, SMC_UNK); 229ca15d9bcSVarun Wadekar } else { 230bbbbcdaeSDavid Cunado if (get_yield_smc_active_flag(tlk_ctx.state)) 23177199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 232ca15d9bcSVarun Wadekar } 23377199df7SVarun Wadekar 23477199df7SVarun Wadekar cm_el1_sysregs_context_save(NON_SECURE); 23577199df7SVarun Wadekar 23677199df7SVarun Wadekar /* 23777199df7SVarun Wadekar * Verify if there is a valid context to use. 23877199df7SVarun Wadekar */ 23977199df7SVarun Wadekar assert(&tlk_ctx.cpu_ctx == cm_get_context(SECURE)); 24077199df7SVarun Wadekar 24177199df7SVarun Wadekar /* 24277199df7SVarun Wadekar * Mark the SP state as active. 24377199df7SVarun Wadekar */ 244bbbbcdaeSDavid Cunado set_yield_smc_active_flag(tlk_ctx.state); 24577199df7SVarun Wadekar 24677199df7SVarun Wadekar /* 24777199df7SVarun Wadekar * We are done stashing the non-secure context. Ask the 24877199df7SVarun Wadekar * secure payload to do the work now. 24977199df7SVarun Wadekar */ 25077199df7SVarun Wadekar cm_el1_sysregs_context_restore(SECURE); 25177199df7SVarun Wadekar cm_set_next_eret_context(SECURE); 25277199df7SVarun Wadekar 25377199df7SVarun Wadekar /* 254709a3c47SVarun Wadekar * TLK is a 32-bit Trusted OS and so expects the SMC 255709a3c47SVarun Wadekar * arguments via r0-r7. TLK expects the monitor frame 256709a3c47SVarun Wadekar * registers to be 64-bits long. Hence, we pass x0 in 257709a3c47SVarun Wadekar * r0-r1, x1 in r2-r3, x3 in r4-r5 and x4 in r6-r7. 258709a3c47SVarun Wadekar * 259709a3c47SVarun Wadekar * As smc_fid is a uint32 value, r1 contains 0. 260709a3c47SVarun Wadekar */ 261709a3c47SVarun Wadekar gp_regs = get_gpregs_ctx(&tlk_ctx.cpu_ctx); 262709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X4, (uint32_t)x2); 263709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X5, (uint32_t)(x2 >> 32)); 264709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X6, (uint32_t)x3); 265709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X7, (uint32_t)(x3 >> 32)); 266709a3c47SVarun Wadekar SMC_RET4(&tlk_ctx.cpu_ctx, smc_fid, 0, (uint32_t)x1, 267709a3c47SVarun Wadekar (uint32_t)(x1 >> 32)); 268709a3c47SVarun Wadekar 269709a3c47SVarun Wadekar /* 270709a3c47SVarun Wadekar * Translate NS/EL1-S virtual addresses. 271709a3c47SVarun Wadekar * 272709a3c47SVarun Wadekar * x1 = virtual address 273709a3c47SVarun Wadekar * x3 = type (NS/S) 274709a3c47SVarun Wadekar * 275709a3c47SVarun Wadekar * Returns PA:lo in r0, PA:hi in r1. 2766e159e7aSVarun Wadekar */ 2776e159e7aSVarun Wadekar case TLK_VA_TRANSLATE: 278709a3c47SVarun Wadekar 279709a3c47SVarun Wadekar /* Should be invoked only by secure world */ 280709a3c47SVarun Wadekar if (ns) 2816e159e7aSVarun Wadekar SMC_RET1(handle, SMC_UNK); 2826e159e7aSVarun Wadekar 283709a3c47SVarun Wadekar /* NS virtual addresses are 64-bit long */ 284709a3c47SVarun Wadekar if (x3 & TLK_TRANSLATE_NS_VADDR) 285709a3c47SVarun Wadekar x1 = (uint32_t)x1 | (x2 << 32); 286709a3c47SVarun Wadekar 287709a3c47SVarun Wadekar if (!x1) 288709a3c47SVarun Wadekar SMC_RET1(handle, SMC_UNK); 289709a3c47SVarun Wadekar 290709a3c47SVarun Wadekar /* 291709a3c47SVarun Wadekar * TODO: Sanity check x1. This would require platform 292709a3c47SVarun Wadekar * support. 293709a3c47SVarun Wadekar */ 294709a3c47SVarun Wadekar 2956e159e7aSVarun Wadekar /* virtual address and type: ns/s */ 296709a3c47SVarun Wadekar par = tlkd_va_translate(x1, x3); 2976e159e7aSVarun Wadekar 298709a3c47SVarun Wadekar /* return physical address in r0-r1 */ 299709a3c47SVarun Wadekar SMC_RET4(handle, (uint32_t)par, (uint32_t)(par >> 32), 0, 0); 3006e159e7aSVarun Wadekar 3016e159e7aSVarun Wadekar /* 30277199df7SVarun Wadekar * This is a request from the SP to mark completion of 303bbbbcdaeSDavid Cunado * a yielding function ID. 30477199df7SVarun Wadekar */ 30577199df7SVarun Wadekar case TLK_REQUEST_DONE: 306709a3c47SVarun Wadekar if (ns) 30777199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 30877199df7SVarun Wadekar 30977199df7SVarun Wadekar /* 31077199df7SVarun Wadekar * Mark the SP state as inactive. 31177199df7SVarun Wadekar */ 312bbbbcdaeSDavid Cunado clr_yield_smc_active_flag(tlk_ctx.state); 31377199df7SVarun Wadekar 31477199df7SVarun Wadekar /* Get a reference to the non-secure context */ 31577199df7SVarun Wadekar ns_cpu_context = cm_get_context(NON_SECURE); 31677199df7SVarun Wadekar assert(ns_cpu_context); 31777199df7SVarun Wadekar 31877199df7SVarun Wadekar /* 31977199df7SVarun Wadekar * This is a request completion SMC and we must switch to 32077199df7SVarun Wadekar * the non-secure world to pass the result. 32177199df7SVarun Wadekar */ 32277199df7SVarun Wadekar cm_el1_sysregs_context_save(SECURE); 32377199df7SVarun Wadekar 32477199df7SVarun Wadekar /* 32577199df7SVarun Wadekar * We are done stashing the secure context. Switch to the 32677199df7SVarun Wadekar * non-secure context and return the result. 32777199df7SVarun Wadekar */ 32877199df7SVarun Wadekar cm_el1_sysregs_context_restore(NON_SECURE); 32977199df7SVarun Wadekar cm_set_next_eret_context(NON_SECURE); 330709a3c47SVarun Wadekar SMC_RET1(ns_cpu_context, x1); 33177199df7SVarun Wadekar 33277199df7SVarun Wadekar /* 33322038315SVarun Wadekar * This function ID is used only by the SP to indicate it has 33422038315SVarun Wadekar * finished initialising itself after a cold boot 33522038315SVarun Wadekar */ 33622038315SVarun Wadekar case TLK_ENTRY_DONE: 337709a3c47SVarun Wadekar if (ns) 33822038315SVarun Wadekar SMC_RET1(handle, SMC_UNK); 33922038315SVarun Wadekar 34022038315SVarun Wadekar /* 34122038315SVarun Wadekar * SP has been successfully initialized. Register power 34222038315SVarun Wadekar * managemnt hooks with PSCI 34322038315SVarun Wadekar */ 34422038315SVarun Wadekar psci_register_spd_pm_hook(&tlkd_pm_ops); 34522038315SVarun Wadekar 34622038315SVarun Wadekar /* 34722038315SVarun Wadekar * TLK reports completion. The SPD must have initiated 34822038315SVarun Wadekar * the original request through a synchronous entry 34922038315SVarun Wadekar * into the SP. Jump back to the original C runtime 35022038315SVarun Wadekar * context. 35122038315SVarun Wadekar */ 352709a3c47SVarun Wadekar tlkd_synchronous_sp_exit(&tlk_ctx, x1); 353185a23ffSJonathan Wright break; 35422038315SVarun Wadekar 35522038315SVarun Wadekar /* 356cb790c5eSVarun Wadekar * These function IDs are used only by TLK to indicate it has 357cb790c5eSVarun Wadekar * finished: 358cb790c5eSVarun Wadekar * 1. suspending itself after an earlier psci cpu_suspend 359cb790c5eSVarun Wadekar * request. 360cb790c5eSVarun Wadekar * 2. resuming itself after an earlier psci cpu_suspend 361cb790c5eSVarun Wadekar * request. 362cb790c5eSVarun Wadekar * 3. powering down after an earlier psci system_off/system_reset 363cb790c5eSVarun Wadekar * request. 364cb790c5eSVarun Wadekar */ 365cb790c5eSVarun Wadekar case TLK_SUSPEND_DONE: 366cb790c5eSVarun Wadekar case TLK_RESUME_DONE: 367cb790c5eSVarun Wadekar case TLK_SYSTEM_OFF_DONE: 368cb790c5eSVarun Wadekar 369cb790c5eSVarun Wadekar if (ns) 370cb790c5eSVarun Wadekar SMC_RET1(handle, SMC_UNK); 371cb790c5eSVarun Wadekar 372cb790c5eSVarun Wadekar /* 373cb790c5eSVarun Wadekar * TLK reports completion. TLKD must have initiated the 374cb790c5eSVarun Wadekar * original request through a synchronous entry into the SP. 375cb790c5eSVarun Wadekar * Jump back to the original C runtime context, and pass x1 as 376cb790c5eSVarun Wadekar * return value to the caller 377cb790c5eSVarun Wadekar */ 378cb790c5eSVarun Wadekar tlkd_synchronous_sp_exit(&tlk_ctx, x1); 379185a23ffSJonathan Wright break; 380cb790c5eSVarun Wadekar 381cb790c5eSVarun Wadekar /* 38222038315SVarun Wadekar * Return the number of service function IDs implemented to 38322038315SVarun Wadekar * provide service to non-secure 38422038315SVarun Wadekar */ 38522038315SVarun Wadekar case TOS_CALL_COUNT: 38622038315SVarun Wadekar SMC_RET1(handle, TLK_NUM_FID); 38722038315SVarun Wadekar 38822038315SVarun Wadekar /* 38922038315SVarun Wadekar * Return TLK's UID to the caller 39022038315SVarun Wadekar */ 39122038315SVarun Wadekar case TOS_UID: 39222038315SVarun Wadekar SMC_UUID_RET(handle, tlk_uuid); 39322038315SVarun Wadekar 39422038315SVarun Wadekar /* 39522038315SVarun Wadekar * Return the version of current implementation 39622038315SVarun Wadekar */ 39722038315SVarun Wadekar case TOS_CALL_VERSION: 39822038315SVarun Wadekar SMC_RET2(handle, TLK_VERSION_MAJOR, TLK_VERSION_MINOR); 39922038315SVarun Wadekar 40022038315SVarun Wadekar default: 40122038315SVarun Wadekar break; 40222038315SVarun Wadekar } 40322038315SVarun Wadekar 40422038315SVarun Wadekar SMC_RET1(handle, SMC_UNK); 40522038315SVarun Wadekar } 40622038315SVarun Wadekar 40722038315SVarun Wadekar /* Define a SPD runtime service descriptor for fast SMC calls */ 40822038315SVarun Wadekar DECLARE_RT_SVC( 40922038315SVarun Wadekar tlkd_tos_fast, 41022038315SVarun Wadekar 41122038315SVarun Wadekar OEN_TOS_START, 41222038315SVarun Wadekar OEN_TOS_END, 41322038315SVarun Wadekar SMC_TYPE_FAST, 41422038315SVarun Wadekar tlkd_setup, 41522038315SVarun Wadekar tlkd_smc_handler 41622038315SVarun Wadekar ); 41722038315SVarun Wadekar 418bbbbcdaeSDavid Cunado /* Define a SPD runtime service descriptor for yielding SMC calls */ 41922038315SVarun Wadekar DECLARE_RT_SVC( 42022038315SVarun Wadekar tlkd_tos_std, 42122038315SVarun Wadekar 42222038315SVarun Wadekar OEN_TOS_START, 42322038315SVarun Wadekar OEN_TOS_END, 424bbbbcdaeSDavid Cunado SMC_TYPE_YIELD, 42522038315SVarun Wadekar NULL, 42622038315SVarun Wadekar tlkd_smc_handler 42722038315SVarun Wadekar ); 4286693962cSVarun Wadekar 4296693962cSVarun Wadekar /* Define a SPD runtime service descriptor for fast SMC calls */ 4306693962cSVarun Wadekar DECLARE_RT_SVC( 4316693962cSVarun Wadekar tlkd_tap_fast, 4326693962cSVarun Wadekar 4336693962cSVarun Wadekar OEN_TAP_START, 4346693962cSVarun Wadekar OEN_TAP_END, 4356693962cSVarun Wadekar SMC_TYPE_FAST, 4366693962cSVarun Wadekar NULL, 4376693962cSVarun Wadekar tlkd_smc_handler 4386693962cSVarun Wadekar ); 4396693962cSVarun Wadekar 440bbbbcdaeSDavid Cunado /* Define a SPD runtime service descriptor for yielding SMC calls */ 4416693962cSVarun Wadekar DECLARE_RT_SVC( 4426693962cSVarun Wadekar tlkd_tap_std, 4436693962cSVarun Wadekar 4446693962cSVarun Wadekar OEN_TAP_START, 4456693962cSVarun Wadekar OEN_TAP_END, 446bbbbcdaeSDavid Cunado SMC_TYPE_YIELD, 4476693962cSVarun Wadekar NULL, 4486693962cSVarun Wadekar tlkd_smc_handler 4496693962cSVarun Wadekar ); 450