1948c090dSVarun Wadekar /* 29edac047SDavid Cunado * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. 3948c090dSVarun Wadekar * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5948c090dSVarun Wadekar */ 6948c090dSVarun Wadekar 7c3cf06f1SAntonio Nino Diaz #ifndef SMCALL_H 8c3cf06f1SAntonio Nino Diaz #define SMCALL_H 9948c090dSVarun Wadekar 10*591054a3SAnthony Zhou #define SMC_NUM_ENTITIES 64U 11*591054a3SAnthony Zhou #define SMC_NUM_ARGS 4U 12*591054a3SAnthony Zhou #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1U) 13948c090dSVarun Wadekar 14*591054a3SAnthony Zhou #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000U) 15*591054a3SAnthony Zhou #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000U) 16*591054a3SAnthony Zhou #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000U) >> 24U) 17*591054a3SAnthony Zhou #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFFU) 18948c090dSVarun Wadekar 199edac047SDavid Cunado #define SMC_NR(entity, fn, fastcall, smc64) \ 20*591054a3SAnthony Zhou (((((uint32_t)(fastcall)) & 0x1U) << 31U) | \ 21*591054a3SAnthony Zhou (((smc64) & 0x1U) << 30U) | \ 22*591054a3SAnthony Zhou (((entity) & 0x3FU) << 24U) | \ 23*591054a3SAnthony Zhou ((fn) & 0xFFFFU)) 24948c090dSVarun Wadekar 25*591054a3SAnthony Zhou #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1U, 0U) 26*591054a3SAnthony Zhou #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1U, 1U) 27*591054a3SAnthony Zhou #define SMC_YIELDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0U, 0U) 28*591054a3SAnthony Zhou #define SMC_YIELDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0U, 1U) 29948c090dSVarun Wadekar 30*591054a3SAnthony Zhou #define SMC_ENTITY_ARCH 0U /* ARM Architecture calls */ 31*591054a3SAnthony Zhou #define SMC_ENTITY_CPU 1U /* CPU Service calls */ 32*591054a3SAnthony Zhou #define SMC_ENTITY_SIP 2U /* SIP Service calls */ 33*591054a3SAnthony Zhou #define SMC_ENTITY_OEM 3U /* OEM Service calls */ 34*591054a3SAnthony Zhou #define SMC_ENTITY_STD 4U /* Standard Service calls */ 35*591054a3SAnthony Zhou #define SMC_ENTITY_RESERVED 5U /* Reserved for future use */ 36*591054a3SAnthony Zhou #define SMC_ENTITY_TRUSTED_APP 48U /* Trusted Application calls */ 37*591054a3SAnthony Zhou #define SMC_ENTITY_TRUSTED_OS 50U /* Trusted OS calls */ 38*591054a3SAnthony Zhou #define SMC_ENTITY_LOGGING 51U /* Used for secure -> nonsecure logging */ 39*591054a3SAnthony Zhou #define SMC_ENTITY_SECURE_MONITOR 60U /* Trusted OS calls internal to secure monitor */ 40948c090dSVarun Wadekar 41bbbbcdaeSDavid Cunado /* FC = Fast call, YC = Yielding call */ 42*591054a3SAnthony Zhou #define SMC_YC_RESTART_LAST SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 43*591054a3SAnthony Zhou #define SMC_YC_NOP SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) 44948c090dSVarun Wadekar 45948c090dSVarun Wadekar /* 46948c090dSVarun Wadekar * Return from secure os to non-secure os with return value in r1 47948c090dSVarun Wadekar */ 48*591054a3SAnthony Zhou #define SMC_YC_NS_RETURN SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 49948c090dSVarun Wadekar 50*591054a3SAnthony Zhou #define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 51*591054a3SAnthony Zhou #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) 52*591054a3SAnthony Zhou #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2U) 53*591054a3SAnthony Zhou #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3U) 54*591054a3SAnthony Zhou #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4U) 55948c090dSVarun Wadekar 56*591054a3SAnthony Zhou #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5U) 57*591054a3SAnthony Zhou #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6U) 58948c090dSVarun Wadekar 59*591054a3SAnthony Zhou #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7U) 60*591054a3SAnthony Zhou #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8U) 61948c090dSVarun Wadekar 62*591054a3SAnthony Zhou #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9U) 63*591054a3SAnthony Zhou #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10U) 64948c090dSVarun Wadekar 65948c090dSVarun Wadekar /* Trusted OS entity calls */ 66*591054a3SAnthony Zhou #define SMC_YC_VIRTIO_GET_DESCR SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20U) 67*591054a3SAnthony Zhou #define SMC_YC_VIRTIO_START SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21U) 68*591054a3SAnthony Zhou #define SMC_YC_VIRTIO_STOP SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22U) 69948c090dSVarun Wadekar 70*591054a3SAnthony Zhou #define SMC_YC_VDEV_RESET SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23U) 71*591054a3SAnthony Zhou #define SMC_YC_VDEV_KICK_VQ SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24U) 72*591054a3SAnthony Zhou #define SMC_YC_SET_ROT_PARAMS SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535U) 73948c090dSVarun Wadekar 74c3cf06f1SAntonio Nino Diaz #endif /* SMCALL_H */ 75