122038315SVarun Wadekar /* 2*bbbbcdaeSDavid Cunado * Copyright (c) 2015-2017, 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 <bl_common.h> 1922038315SVarun Wadekar #include <bl31.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 ******************************************************************************/ 4026670c82SVarun Wadekar static int 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 4722038315SVarun Wadekar 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 ******************************************************************************/ 5422038315SVarun Wadekar 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 ******************************************************************************/ 10322038315SVarun Wadekar 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 ******************************************************************************/ 13622038315SVarun Wadekar uint64_t tlkd_smc_handler(uint32_t smc_fid, 13722038315SVarun Wadekar uint64_t x1, 13822038315SVarun Wadekar uint64_t x2, 13922038315SVarun Wadekar uint64_t x3, 14022038315SVarun Wadekar uint64_t x4, 14122038315SVarun Wadekar void *cookie, 14222038315SVarun Wadekar void *handle, 14322038315SVarun Wadekar uint64_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. 1966693962cSVarun Wadekar * c. open/close sessions 1976693962cSVarun Wadekar * d. issue commands to the Trusted Apps 198*bbbbcdaeSDavid Cunado * e. resume the preempted yielding SMC call. 19977199df7SVarun Wadekar */ 20077199df7SVarun Wadekar case TLK_REGISTER_LOGBUF: 20177199df7SVarun Wadekar case TLK_REGISTER_REQBUF: 2026693962cSVarun Wadekar case TLK_OPEN_TA_SESSION: 2036693962cSVarun Wadekar case TLK_CLOSE_TA_SESSION: 2046693962cSVarun Wadekar case TLK_TA_LAUNCH_OP: 2056693962cSVarun Wadekar case TLK_TA_SEND_EVENT: 206ca15d9bcSVarun Wadekar case TLK_RESUME_FID: 2076693962cSVarun Wadekar 208709a3c47SVarun Wadekar if (!ns) 20977199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 21077199df7SVarun Wadekar 21177199df7SVarun Wadekar /* 21277199df7SVarun Wadekar * This is a fresh request from the non-secure client. 21377199df7SVarun Wadekar * The parameters are in x1 and x2. Figure out which 21477199df7SVarun Wadekar * registers need to be preserved, save the non-secure 21577199df7SVarun Wadekar * state and send the request to the secure payload. 21677199df7SVarun Wadekar */ 21777199df7SVarun Wadekar assert(handle == cm_get_context(NON_SECURE)); 21877199df7SVarun Wadekar 219ca15d9bcSVarun Wadekar /* 220*bbbbcdaeSDavid Cunado * Check if we are already processing a yielding SMC 221ca15d9bcSVarun Wadekar * call. Of all the supported fids, only the "resume" 222ca15d9bcSVarun Wadekar * fid expects the flag to be set. 223ca15d9bcSVarun Wadekar */ 224ca15d9bcSVarun Wadekar if (smc_fid == TLK_RESUME_FID) { 225*bbbbcdaeSDavid Cunado if (!get_yield_smc_active_flag(tlk_ctx.state)) 226ca15d9bcSVarun Wadekar SMC_RET1(handle, SMC_UNK); 227ca15d9bcSVarun Wadekar } else { 228*bbbbcdaeSDavid Cunado if (get_yield_smc_active_flag(tlk_ctx.state)) 22977199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 230ca15d9bcSVarun Wadekar } 23177199df7SVarun Wadekar 23277199df7SVarun Wadekar cm_el1_sysregs_context_save(NON_SECURE); 23377199df7SVarun Wadekar 23477199df7SVarun Wadekar /* 23577199df7SVarun Wadekar * Verify if there is a valid context to use. 23677199df7SVarun Wadekar */ 23777199df7SVarun Wadekar assert(&tlk_ctx.cpu_ctx == cm_get_context(SECURE)); 23877199df7SVarun Wadekar 23977199df7SVarun Wadekar /* 24077199df7SVarun Wadekar * Mark the SP state as active. 24177199df7SVarun Wadekar */ 242*bbbbcdaeSDavid Cunado set_yield_smc_active_flag(tlk_ctx.state); 24377199df7SVarun Wadekar 24477199df7SVarun Wadekar /* 24577199df7SVarun Wadekar * We are done stashing the non-secure context. Ask the 24677199df7SVarun Wadekar * secure payload to do the work now. 24777199df7SVarun Wadekar */ 24877199df7SVarun Wadekar cm_el1_sysregs_context_restore(SECURE); 24977199df7SVarun Wadekar cm_set_next_eret_context(SECURE); 25077199df7SVarun Wadekar 25177199df7SVarun Wadekar /* 252709a3c47SVarun Wadekar * TLK is a 32-bit Trusted OS and so expects the SMC 253709a3c47SVarun Wadekar * arguments via r0-r7. TLK expects the monitor frame 254709a3c47SVarun Wadekar * registers to be 64-bits long. Hence, we pass x0 in 255709a3c47SVarun Wadekar * r0-r1, x1 in r2-r3, x3 in r4-r5 and x4 in r6-r7. 256709a3c47SVarun Wadekar * 257709a3c47SVarun Wadekar * As smc_fid is a uint32 value, r1 contains 0. 258709a3c47SVarun Wadekar */ 259709a3c47SVarun Wadekar gp_regs = get_gpregs_ctx(&tlk_ctx.cpu_ctx); 260709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X4, (uint32_t)x2); 261709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X5, (uint32_t)(x2 >> 32)); 262709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X6, (uint32_t)x3); 263709a3c47SVarun Wadekar write_ctx_reg(gp_regs, CTX_GPREG_X7, (uint32_t)(x3 >> 32)); 264709a3c47SVarun Wadekar SMC_RET4(&tlk_ctx.cpu_ctx, smc_fid, 0, (uint32_t)x1, 265709a3c47SVarun Wadekar (uint32_t)(x1 >> 32)); 266709a3c47SVarun Wadekar 267709a3c47SVarun Wadekar /* 268709a3c47SVarun Wadekar * Translate NS/EL1-S virtual addresses. 269709a3c47SVarun Wadekar * 270709a3c47SVarun Wadekar * x1 = virtual address 271709a3c47SVarun Wadekar * x3 = type (NS/S) 272709a3c47SVarun Wadekar * 273709a3c47SVarun Wadekar * Returns PA:lo in r0, PA:hi in r1. 2746e159e7aSVarun Wadekar */ 2756e159e7aSVarun Wadekar case TLK_VA_TRANSLATE: 276709a3c47SVarun Wadekar 277709a3c47SVarun Wadekar /* Should be invoked only by secure world */ 278709a3c47SVarun Wadekar if (ns) 2796e159e7aSVarun Wadekar SMC_RET1(handle, SMC_UNK); 2806e159e7aSVarun Wadekar 281709a3c47SVarun Wadekar /* NS virtual addresses are 64-bit long */ 282709a3c47SVarun Wadekar if (x3 & TLK_TRANSLATE_NS_VADDR) 283709a3c47SVarun Wadekar x1 = (uint32_t)x1 | (x2 << 32); 284709a3c47SVarun Wadekar 285709a3c47SVarun Wadekar if (!x1) 286709a3c47SVarun Wadekar SMC_RET1(handle, SMC_UNK); 287709a3c47SVarun Wadekar 288709a3c47SVarun Wadekar /* 289709a3c47SVarun Wadekar * TODO: Sanity check x1. This would require platform 290709a3c47SVarun Wadekar * support. 291709a3c47SVarun Wadekar */ 292709a3c47SVarun Wadekar 2936e159e7aSVarun Wadekar /* virtual address and type: ns/s */ 294709a3c47SVarun Wadekar par = tlkd_va_translate(x1, x3); 2956e159e7aSVarun Wadekar 296709a3c47SVarun Wadekar /* return physical address in r0-r1 */ 297709a3c47SVarun Wadekar SMC_RET4(handle, (uint32_t)par, (uint32_t)(par >> 32), 0, 0); 2986e159e7aSVarun Wadekar 2996e159e7aSVarun Wadekar /* 30077199df7SVarun Wadekar * This is a request from the SP to mark completion of 301*bbbbcdaeSDavid Cunado * a yielding function ID. 30277199df7SVarun Wadekar */ 30377199df7SVarun Wadekar case TLK_REQUEST_DONE: 304709a3c47SVarun Wadekar if (ns) 30577199df7SVarun Wadekar SMC_RET1(handle, SMC_UNK); 30677199df7SVarun Wadekar 30777199df7SVarun Wadekar /* 30877199df7SVarun Wadekar * Mark the SP state as inactive. 30977199df7SVarun Wadekar */ 310*bbbbcdaeSDavid Cunado clr_yield_smc_active_flag(tlk_ctx.state); 31177199df7SVarun Wadekar 31277199df7SVarun Wadekar /* Get a reference to the non-secure context */ 31377199df7SVarun Wadekar ns_cpu_context = cm_get_context(NON_SECURE); 31477199df7SVarun Wadekar assert(ns_cpu_context); 31577199df7SVarun Wadekar 31677199df7SVarun Wadekar /* 31777199df7SVarun Wadekar * This is a request completion SMC and we must switch to 31877199df7SVarun Wadekar * the non-secure world to pass the result. 31977199df7SVarun Wadekar */ 32077199df7SVarun Wadekar cm_el1_sysregs_context_save(SECURE); 32177199df7SVarun Wadekar 32277199df7SVarun Wadekar /* 32377199df7SVarun Wadekar * We are done stashing the secure context. Switch to the 32477199df7SVarun Wadekar * non-secure context and return the result. 32577199df7SVarun Wadekar */ 32677199df7SVarun Wadekar cm_el1_sysregs_context_restore(NON_SECURE); 32777199df7SVarun Wadekar cm_set_next_eret_context(NON_SECURE); 328709a3c47SVarun Wadekar SMC_RET1(ns_cpu_context, x1); 32977199df7SVarun Wadekar 33077199df7SVarun Wadekar /* 33122038315SVarun Wadekar * This function ID is used only by the SP to indicate it has 33222038315SVarun Wadekar * finished initialising itself after a cold boot 33322038315SVarun Wadekar */ 33422038315SVarun Wadekar case TLK_ENTRY_DONE: 335709a3c47SVarun Wadekar if (ns) 33622038315SVarun Wadekar SMC_RET1(handle, SMC_UNK); 33722038315SVarun Wadekar 33822038315SVarun Wadekar /* 33922038315SVarun Wadekar * SP has been successfully initialized. Register power 34022038315SVarun Wadekar * managemnt hooks with PSCI 34122038315SVarun Wadekar */ 34222038315SVarun Wadekar psci_register_spd_pm_hook(&tlkd_pm_ops); 34322038315SVarun Wadekar 34422038315SVarun Wadekar /* 34522038315SVarun Wadekar * TLK reports completion. The SPD must have initiated 34622038315SVarun Wadekar * the original request through a synchronous entry 34722038315SVarun Wadekar * into the SP. Jump back to the original C runtime 34822038315SVarun Wadekar * context. 34922038315SVarun Wadekar */ 350709a3c47SVarun Wadekar tlkd_synchronous_sp_exit(&tlk_ctx, x1); 35122038315SVarun Wadekar 35222038315SVarun Wadekar /* 353cb790c5eSVarun Wadekar * These function IDs are used only by TLK to indicate it has 354cb790c5eSVarun Wadekar * finished: 355cb790c5eSVarun Wadekar * 1. suspending itself after an earlier psci cpu_suspend 356cb790c5eSVarun Wadekar * request. 357cb790c5eSVarun Wadekar * 2. resuming itself after an earlier psci cpu_suspend 358cb790c5eSVarun Wadekar * request. 359cb790c5eSVarun Wadekar * 3. powering down after an earlier psci system_off/system_reset 360cb790c5eSVarun Wadekar * request. 361cb790c5eSVarun Wadekar */ 362cb790c5eSVarun Wadekar case TLK_SUSPEND_DONE: 363cb790c5eSVarun Wadekar case TLK_RESUME_DONE: 364cb790c5eSVarun Wadekar case TLK_SYSTEM_OFF_DONE: 365cb790c5eSVarun Wadekar 366cb790c5eSVarun Wadekar if (ns) 367cb790c5eSVarun Wadekar SMC_RET1(handle, SMC_UNK); 368cb790c5eSVarun Wadekar 369cb790c5eSVarun Wadekar /* 370cb790c5eSVarun Wadekar * TLK reports completion. TLKD must have initiated the 371cb790c5eSVarun Wadekar * original request through a synchronous entry into the SP. 372cb790c5eSVarun Wadekar * Jump back to the original C runtime context, and pass x1 as 373cb790c5eSVarun Wadekar * return value to the caller 374cb790c5eSVarun Wadekar */ 375cb790c5eSVarun Wadekar tlkd_synchronous_sp_exit(&tlk_ctx, x1); 376cb790c5eSVarun Wadekar 377cb790c5eSVarun Wadekar /* 37822038315SVarun Wadekar * Return the number of service function IDs implemented to 37922038315SVarun Wadekar * provide service to non-secure 38022038315SVarun Wadekar */ 38122038315SVarun Wadekar case TOS_CALL_COUNT: 38222038315SVarun Wadekar SMC_RET1(handle, TLK_NUM_FID); 38322038315SVarun Wadekar 38422038315SVarun Wadekar /* 38522038315SVarun Wadekar * Return TLK's UID to the caller 38622038315SVarun Wadekar */ 38722038315SVarun Wadekar case TOS_UID: 38822038315SVarun Wadekar SMC_UUID_RET(handle, tlk_uuid); 38922038315SVarun Wadekar 39022038315SVarun Wadekar /* 39122038315SVarun Wadekar * Return the version of current implementation 39222038315SVarun Wadekar */ 39322038315SVarun Wadekar case TOS_CALL_VERSION: 39422038315SVarun Wadekar SMC_RET2(handle, TLK_VERSION_MAJOR, TLK_VERSION_MINOR); 39522038315SVarun Wadekar 39622038315SVarun Wadekar default: 39722038315SVarun Wadekar break; 39822038315SVarun Wadekar } 39922038315SVarun Wadekar 40022038315SVarun Wadekar SMC_RET1(handle, SMC_UNK); 40122038315SVarun Wadekar } 40222038315SVarun Wadekar 40322038315SVarun Wadekar /* Define a SPD runtime service descriptor for fast SMC calls */ 40422038315SVarun Wadekar DECLARE_RT_SVC( 40522038315SVarun Wadekar tlkd_tos_fast, 40622038315SVarun Wadekar 40722038315SVarun Wadekar OEN_TOS_START, 40822038315SVarun Wadekar OEN_TOS_END, 40922038315SVarun Wadekar SMC_TYPE_FAST, 41022038315SVarun Wadekar tlkd_setup, 41122038315SVarun Wadekar tlkd_smc_handler 41222038315SVarun Wadekar ); 41322038315SVarun Wadekar 414*bbbbcdaeSDavid Cunado /* Define a SPD runtime service descriptor for yielding SMC calls */ 41522038315SVarun Wadekar DECLARE_RT_SVC( 41622038315SVarun Wadekar tlkd_tos_std, 41722038315SVarun Wadekar 41822038315SVarun Wadekar OEN_TOS_START, 41922038315SVarun Wadekar OEN_TOS_END, 420*bbbbcdaeSDavid Cunado SMC_TYPE_YIELD, 42122038315SVarun Wadekar NULL, 42222038315SVarun Wadekar tlkd_smc_handler 42322038315SVarun Wadekar ); 4246693962cSVarun Wadekar 4256693962cSVarun Wadekar /* Define a SPD runtime service descriptor for fast SMC calls */ 4266693962cSVarun Wadekar DECLARE_RT_SVC( 4276693962cSVarun Wadekar tlkd_tap_fast, 4286693962cSVarun Wadekar 4296693962cSVarun Wadekar OEN_TAP_START, 4306693962cSVarun Wadekar OEN_TAP_END, 4316693962cSVarun Wadekar SMC_TYPE_FAST, 4326693962cSVarun Wadekar NULL, 4336693962cSVarun Wadekar tlkd_smc_handler 4346693962cSVarun Wadekar ); 4356693962cSVarun Wadekar 436*bbbbcdaeSDavid Cunado /* Define a SPD runtime service descriptor for yielding SMC calls */ 4376693962cSVarun Wadekar DECLARE_RT_SVC( 4386693962cSVarun Wadekar tlkd_tap_std, 4396693962cSVarun Wadekar 4406693962cSVarun Wadekar OEN_TAP_START, 4416693962cSVarun Wadekar OEN_TAP_END, 442*bbbbcdaeSDavid Cunado SMC_TYPE_YIELD, 4436693962cSVarun Wadekar NULL, 4446693962cSVarun Wadekar tlkd_smc_handler 4456693962cSVarun Wadekar ); 446