Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 1 | /* |
David Cunado | 2e36de8 | 2017-01-19 10:26:16 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef SMCALL_H |
| 8 | #define SMCALL_H |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 9 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 10 | #define SMC_NUM_ENTITIES 64U |
| 11 | #define SMC_NUM_ARGS 4U |
| 12 | #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 13 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 14 | #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000U) |
| 15 | #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000U) |
| 16 | #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000U) >> 24U) |
| 17 | #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFFU) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 18 | |
David Cunado | 2e36de8 | 2017-01-19 10:26:16 +0000 | [diff] [blame] | 19 | #define SMC_NR(entity, fn, fastcall, smc64) \ |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 20 | (((((uint32_t)(fastcall)) & 0x1U) << 31U) | \ |
| 21 | (((smc64) & 0x1U) << 30U) | \ |
| 22 | (((entity) & 0x3FU) << 24U) | \ |
| 23 | ((fn) & 0xFFFFU)) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 24 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 25 | #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1U, 0U) |
| 26 | #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1U, 1U) |
| 27 | #define SMC_YIELDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0U, 0U) |
| 28 | #define SMC_YIELDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0U, 1U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 29 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 30 | #define SMC_ENTITY_ARCH 0U /* ARM Architecture calls */ |
| 31 | #define SMC_ENTITY_CPU 1U /* CPU Service calls */ |
| 32 | #define SMC_ENTITY_SIP 2U /* SIP Service calls */ |
| 33 | #define SMC_ENTITY_OEM 3U /* OEM Service calls */ |
| 34 | #define SMC_ENTITY_STD 4U /* Standard Service calls */ |
| 35 | #define SMC_ENTITY_RESERVED 5U /* Reserved for future use */ |
| 36 | #define SMC_ENTITY_TRUSTED_APP 48U /* Trusted Application calls */ |
| 37 | #define SMC_ENTITY_TRUSTED_OS 50U /* Trusted OS calls */ |
| 38 | #define SMC_ENTITY_LOGGING 51U /* Used for secure -> nonsecure logging */ |
| 39 | #define SMC_ENTITY_SECURE_MONITOR 60U /* Trusted OS calls internal to secure monitor */ |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 40 | |
David Cunado | c8833ea | 2017-04-16 17:15:08 +0100 | [diff] [blame] | 41 | /* FC = Fast call, YC = Yielding call */ |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 42 | #define SMC_YC_RESTART_LAST SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) |
| 43 | #define SMC_YC_NOP SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 44 | |
| 45 | /* |
| 46 | * Return from secure os to non-secure os with return value in r1 |
| 47 | */ |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 48 | #define SMC_YC_NS_RETURN SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 49 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 50 | #define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U) |
| 51 | #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U) |
| 52 | #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2U) |
| 53 | #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3U) |
| 54 | #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 55 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 56 | #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5U) |
| 57 | #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 58 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 59 | #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7U) |
| 60 | #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 61 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 62 | #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9U) |
| 63 | #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 64 | |
| 65 | /* Trusted OS entity calls */ |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 66 | #define SMC_YC_VIRTIO_GET_DESCR SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20U) |
| 67 | #define SMC_YC_VIRTIO_START SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21U) |
| 68 | #define SMC_YC_VIRTIO_STOP SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 69 | |
Anthony Zhou | 50b328a | 2017-09-19 16:36:22 +0800 | [diff] [blame] | 70 | #define SMC_YC_VDEV_RESET SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23U) |
| 71 | #define SMC_YC_VDEV_KICK_VQ SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24U) |
| 72 | #define SMC_YC_SET_ROT_PARAMS SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535U) |
Varun Wadekar | c1d2a28 | 2016-11-08 15:46:48 -0800 | [diff] [blame] | 73 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 74 | #endif /* SMCALL_H */ |