1*54fd6939SJiyong Park /* 2*54fd6939SJiyong Park * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. 3*54fd6939SJiyong Park * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. 4*54fd6939SJiyong Park * 5*54fd6939SJiyong Park * SPDX-License-Identifier: BSD-3-Clause 6*54fd6939SJiyong Park */ 7*54fd6939SJiyong Park 8*54fd6939SJiyong Park #ifndef SMCALL_H 9*54fd6939SJiyong Park #define SMCALL_H 10*54fd6939SJiyong Park 11*54fd6939SJiyong Park #define SMC_NUM_ENTITIES 64U 12*54fd6939SJiyong Park #define SMC_NUM_ARGS 4U 13*54fd6939SJiyong Park #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1U) 14*54fd6939SJiyong Park 15*54fd6939SJiyong Park #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000U) 16*54fd6939SJiyong Park #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000U) 17*54fd6939SJiyong Park #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000U) >> 24U) 18*54fd6939SJiyong Park #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFFU) 19*54fd6939SJiyong Park 20*54fd6939SJiyong Park #define SMC_NR(entity, fn, fastcall, smc64) \ 21*54fd6939SJiyong Park (((((uint32_t)(fastcall)) & 0x1U) << 31U) | \ 22*54fd6939SJiyong Park (((smc64) & 0x1U) << 30U) | \ 23*54fd6939SJiyong Park (((entity) & 0x3FU) << 24U) | \ 24*54fd6939SJiyong Park ((fn) & 0xFFFFU)) 25*54fd6939SJiyong Park 26*54fd6939SJiyong Park #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1U, 0U) 27*54fd6939SJiyong Park #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1U, 1U) 28*54fd6939SJiyong Park #define SMC_YIELDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0U, 0U) 29*54fd6939SJiyong Park #define SMC_YIELDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0U, 1U) 30*54fd6939SJiyong Park 31*54fd6939SJiyong Park #define SMC_ENTITY_ARCH 0U /* ARM Architecture calls */ 32*54fd6939SJiyong Park #define SMC_ENTITY_CPU 1U /* CPU Service calls */ 33*54fd6939SJiyong Park #define SMC_ENTITY_SIP 2U /* SIP Service calls */ 34*54fd6939SJiyong Park #define SMC_ENTITY_OEM 3U /* OEM Service calls */ 35*54fd6939SJiyong Park #define SMC_ENTITY_STD 4U /* Standard Service calls */ 36*54fd6939SJiyong Park #define SMC_ENTITY_RESERVED 5U /* Reserved for future use */ 37*54fd6939SJiyong Park #define SMC_ENTITY_TRUSTED_APP 48U /* Trusted Application calls */ 38*54fd6939SJiyong Park #define SMC_ENTITY_TRUSTED_OS 50U /* Trusted OS calls */ 39*54fd6939SJiyong Park #define SMC_ENTITY_LOGGING 51U /* Used for secure -> nonsecure logging */ 40*54fd6939SJiyong Park #define SMC_ENTITY_SECURE_MONITOR 60U /* Trusted OS calls internal to secure monitor */ 41*54fd6939SJiyong Park 42*54fd6939SJiyong Park /* FC = Fast call, YC = Yielding call */ 43*54fd6939SJiyong Park #define SMC_YC_RESTART_LAST SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 44*54fd6939SJiyong Park #define SMC_YC_NOP SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) 45*54fd6939SJiyong Park 46*54fd6939SJiyong Park /* 47*54fd6939SJiyong Park * Return from secure os to non-secure os with return value in r1 48*54fd6939SJiyong Park */ 49*54fd6939SJiyong Park #define SMC_YC_NS_RETURN SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 50*54fd6939SJiyong Park 51*54fd6939SJiyong Park #define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) 52*54fd6939SJiyong Park #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) 53*54fd6939SJiyong Park #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2U) 54*54fd6939SJiyong Park #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3U) 55*54fd6939SJiyong Park #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4U) 56*54fd6939SJiyong Park 57*54fd6939SJiyong Park #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5U) 58*54fd6939SJiyong Park #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6U) 59*54fd6939SJiyong Park 60*54fd6939SJiyong Park #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7U) 61*54fd6939SJiyong Park #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8U) 62*54fd6939SJiyong Park 63*54fd6939SJiyong Park #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9U) 64*54fd6939SJiyong Park #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10U) 65*54fd6939SJiyong Park 66*54fd6939SJiyong Park /* Trusted OS entity calls */ 67*54fd6939SJiyong Park #define SMC_YC_VIRTIO_GET_DESCR SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20U) 68*54fd6939SJiyong Park #define SMC_YC_VIRTIO_START SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21U) 69*54fd6939SJiyong Park #define SMC_YC_VIRTIO_STOP SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22U) 70*54fd6939SJiyong Park 71*54fd6939SJiyong Park #define SMC_YC_VDEV_RESET SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23U) 72*54fd6939SJiyong Park #define SMC_YC_VDEV_KICK_VQ SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24U) 73*54fd6939SJiyong Park #define SMC_YC_SET_ROT_PARAMS SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535U) 74*54fd6939SJiyong Park 75*54fd6939SJiyong Park /* 76*54fd6939SJiyong Park * Standard Trusted OS Function IDs that fall under Trusted OS call range 77*54fd6939SJiyong Park * according to SMC calling convention 78*54fd6939SJiyong Park */ 79*54fd6939SJiyong Park #define SMC_FC64_GET_UUID SMC_FASTCALL64_NR(63U, 0xFF01U) /* Implementation UID */ 80*54fd6939SJiyong Park #define SMC_FC_GET_UUID SMC_FASTCALL_NR(63U, 0xFF01U) /* Implementation.UID */ 81*54fd6939SJiyong Park 82*54fd6939SJiyong Park #endif /* SMCALL_H */ 83