blob: 742c8c43e930f51d3cb90f8813c57c36ae6af209 [file] [log] [blame]
Varun Wadekarc1d2a282016-11-08 15:46:48 -08001/*
David Cunado2e36de82017-01-19 10:26:16 +00002 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
Varun Wadekarc1d2a282016-11-08 15:46:48 -08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekarc1d2a282016-11-08 15:46:48 -08005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef SMCALL_H
8#define SMCALL_H
Varun Wadekarc1d2a282016-11-08 15:46:48 -08009
10#define SMC_NUM_ENTITIES 64
11#define SMC_NUM_ARGS 4
12#define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1)
13
14#define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000)
15#define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000)
16#define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000) >> 24)
17#define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFF)
18
David Cunado2e36de82017-01-19 10:26:16 +000019#define SMC_NR(entity, fn, fastcall, smc64) \
20 (((((unsigned int) (fastcall)) & 0x1) << 31) | \
21 (((smc64) & 0x1) << 30) | \
22 (((entity) & 0x3F) << 24) | \
23 ((fn) & 0xFFFF) \
24 )
Varun Wadekarc1d2a282016-11-08 15:46:48 -080025
26#define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080027#define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1)
David Cunadoc8833ea2017-04-16 17:15:08 +010028#define SMC_YIELDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0)
29#define SMC_YIELDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080030
31#define SMC_ENTITY_ARCH 0 /* ARM Architecture calls */
32#define SMC_ENTITY_CPU 1 /* CPU Service calls */
33#define SMC_ENTITY_SIP 2 /* SIP Service calls */
34#define SMC_ENTITY_OEM 3 /* OEM Service calls */
35#define SMC_ENTITY_STD 4 /* Standard Service calls */
36#define SMC_ENTITY_RESERVED 5 /* Reserved for future use */
37#define SMC_ENTITY_TRUSTED_APP 48 /* Trusted Application calls */
38#define SMC_ENTITY_TRUSTED_OS 50 /* Trusted OS calls */
39#define SMC_ENTITY_LOGGING 51 /* Used for secure -> nonsecure logging */
40#define SMC_ENTITY_SECURE_MONITOR 60 /* Trusted OS calls internal to secure monitor */
41
David Cunadoc8833ea2017-04-16 17:15:08 +010042/* FC = Fast call, YC = Yielding call */
43#define SMC_YC_RESTART_LAST SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
44#define SMC_YC_NOP SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080045
46/*
47 * Return from secure os to non-secure os with return value in r1
48 */
David Cunadoc8833ea2017-04-16 17:15:08 +010049#define SMC_YC_NS_RETURN SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080050
51#define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
52#define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1)
53#define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2)
54#define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3)
55#define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4)
56
57#define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5)
58#define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6)
59
60#define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7)
61#define SMC_FC_CPU_RESUME SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8)
62
63#define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9)
64#define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10)
65
66/* Trusted OS entity calls */
David Cunadoc8833ea2017-04-16 17:15:08 +010067#define SMC_YC_VIRTIO_GET_DESCR SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20)
68#define SMC_YC_VIRTIO_START SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21)
69#define SMC_YC_VIRTIO_STOP SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080070
David Cunadoc8833ea2017-04-16 17:15:08 +010071#define SMC_YC_VDEV_RESET SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
72#define SMC_YC_VDEV_KICK_VQ SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
73#define SMC_YC_SET_ROT_PARAMS SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535)
Varun Wadekarc1d2a282016-11-08 15:46:48 -080074
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000075#endif /* SMCALL_H */