1 /* 2 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. 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 #ifndef __LIB_SM_SMCALL_H 32 #define __LIB_SM_SMCALL_H 33 34 #define SMC_NUM_ENTITIES 64 35 #define SMC_NUM_ARGS 4 36 #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1) 37 38 #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000) 39 #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000) 40 #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000) >> 24) 41 #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFF) 42 43 #define SMC_NR(entity, fn, fastcall, smc64) \ 44 (((((unsigned int) (fastcall)) & 0x1) << 31) | \ 45 (((smc64) & 0x1) << 30) | \ 46 (((entity) & 0x3F) << 24) | \ 47 ((fn) & 0xFFFF) \ 48 ) 49 50 #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0) 51 #define SMC_STDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0) 52 #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1) 53 #define SMC_STDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1) 54 55 #define SMC_ENTITY_ARCH 0 /* ARM Architecture calls */ 56 #define SMC_ENTITY_CPU 1 /* CPU Service calls */ 57 #define SMC_ENTITY_SIP 2 /* SIP Service calls */ 58 #define SMC_ENTITY_OEM 3 /* OEM Service calls */ 59 #define SMC_ENTITY_STD 4 /* Standard Service calls */ 60 #define SMC_ENTITY_RESERVED 5 /* Reserved for future use */ 61 #define SMC_ENTITY_TRUSTED_APP 48 /* Trusted Application calls */ 62 #define SMC_ENTITY_TRUSTED_OS 50 /* Trusted OS calls */ 63 #define SMC_ENTITY_LOGGING 51 /* Used for secure -> nonsecure logging */ 64 #define SMC_ENTITY_SECURE_MONITOR 60 /* Trusted OS calls internal to secure monitor */ 65 66 /* FC = Fast call, SC = Standard call */ 67 #define SMC_SC_RESTART_LAST SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) 68 #define SMC_SC_NOP SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1) 69 70 /* 71 * Return from secure os to non-secure os with return value in r1 72 */ 73 #define SMC_SC_NS_RETURN SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) 74 75 #define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0) 76 #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1) 77 #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2) 78 #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3) 79 #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4) 80 81 #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5) 82 #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6) 83 84 #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7) 85 #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8) 86 87 #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9) 88 #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10) 89 90 /* Trusted OS entity calls */ 91 #define SMC_SC_VIRTIO_GET_DESCR SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20) 92 #define SMC_SC_VIRTIO_START SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21) 93 #define SMC_SC_VIRTIO_STOP SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22) 94 95 #define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23) 96 #define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24) 97 #define SMC_SC_SET_ROT_PARAMS SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535) 98 99 #endif /* __LIB_SM_SMCALL_H */ 100