xref: /rk3399_ARM-atf/services/spd/trusty/smcall.h (revision a41ca4c3449c51822d318e295b21d452efac2848)
1948c090dSVarun Wadekar /*
29edac047SDavid Cunado  * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
3*fc198188SVarun Wadekar  * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
4948c090dSVarun Wadekar  *
582cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
6948c090dSVarun Wadekar  */
7948c090dSVarun Wadekar 
8c3cf06f1SAntonio Nino Diaz #ifndef SMCALL_H
9c3cf06f1SAntonio Nino Diaz #define SMCALL_H
10948c090dSVarun Wadekar 
11591054a3SAnthony Zhou #define SMC_NUM_ENTITIES	64U
12591054a3SAnthony Zhou #define SMC_NUM_ARGS		4U
13591054a3SAnthony Zhou #define SMC_NUM_PARAMS		(SMC_NUM_ARGS - 1U)
14948c090dSVarun Wadekar 
15591054a3SAnthony Zhou #define SMC_IS_FASTCALL(smc_nr)	((smc_nr) & 0x80000000U)
16591054a3SAnthony Zhou #define SMC_IS_SMC64(smc_nr)	((smc_nr) & 0x40000000U)
17591054a3SAnthony Zhou #define SMC_ENTITY(smc_nr)	(((smc_nr) & 0x3F000000U) >> 24U)
18591054a3SAnthony Zhou #define SMC_FUNCTION(smc_nr)	((smc_nr) & 0x0000FFFFU)
19948c090dSVarun Wadekar 
209edac047SDavid Cunado #define SMC_NR(entity, fn, fastcall, smc64)			\
21591054a3SAnthony Zhou 		(((((uint32_t)(fastcall)) & 0x1U) << 31U) |	\
22591054a3SAnthony Zhou 		(((smc64) & 0x1U) << 30U) |			\
23591054a3SAnthony Zhou 		(((entity) & 0x3FU) << 24U) |			\
24591054a3SAnthony Zhou 		((fn) & 0xFFFFU))
25948c090dSVarun Wadekar 
26591054a3SAnthony Zhou #define SMC_FASTCALL_NR(entity, fn)	SMC_NR((entity), (fn), 1U, 0U)
27591054a3SAnthony Zhou #define SMC_FASTCALL64_NR(entity, fn)	SMC_NR((entity), (fn), 1U, 1U)
28591054a3SAnthony Zhou #define SMC_YIELDCALL_NR(entity, fn)	SMC_NR((entity), (fn), 0U, 0U)
29591054a3SAnthony Zhou #define SMC_YIELDCALL64_NR(entity, fn)	SMC_NR((entity), (fn), 0U, 1U)
30948c090dSVarun Wadekar 
31591054a3SAnthony Zhou #define	SMC_ENTITY_ARCH			0U	/* ARM Architecture calls */
32591054a3SAnthony Zhou #define	SMC_ENTITY_CPU			1U	/* CPU Service calls */
33591054a3SAnthony Zhou #define	SMC_ENTITY_SIP			2U	/* SIP Service calls */
34591054a3SAnthony Zhou #define	SMC_ENTITY_OEM			3U	/* OEM Service calls */
35591054a3SAnthony Zhou #define	SMC_ENTITY_STD			4U	/* Standard Service calls */
36591054a3SAnthony Zhou #define	SMC_ENTITY_RESERVED		5U	/* Reserved for future use */
37591054a3SAnthony Zhou #define	SMC_ENTITY_TRUSTED_APP		48U	/* Trusted Application calls */
38591054a3SAnthony Zhou #define	SMC_ENTITY_TRUSTED_OS		50U	/* Trusted OS calls */
39591054a3SAnthony Zhou #define SMC_ENTITY_LOGGING              51U	/* Used for secure -> nonsecure logging */
40591054a3SAnthony Zhou #define	SMC_ENTITY_SECURE_MONITOR	60U	/* Trusted OS calls internal to secure monitor */
41948c090dSVarun Wadekar 
42bbbbcdaeSDavid Cunado /* FC = Fast call, YC = Yielding call */
43591054a3SAnthony Zhou #define SMC_YC_RESTART_LAST	SMC_YIELDCALL_NR  (SMC_ENTITY_SECURE_MONITOR, 0U)
44591054a3SAnthony Zhou #define SMC_YC_NOP		SMC_YIELDCALL_NR  (SMC_ENTITY_SECURE_MONITOR, 1U)
45948c090dSVarun Wadekar 
46948c090dSVarun Wadekar /*
47948c090dSVarun Wadekar  * Return from secure os to non-secure os with return value in r1
48948c090dSVarun Wadekar  */
49591054a3SAnthony Zhou #define SMC_YC_NS_RETURN	SMC_YIELDCALL_NR  (SMC_ENTITY_SECURE_MONITOR, 0U)
50948c090dSVarun Wadekar 
51591054a3SAnthony Zhou #define SMC_FC_RESERVED		SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0U)
52591054a3SAnthony Zhou #define SMC_FC_FIQ_EXIT		SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1U)
53591054a3SAnthony Zhou #define SMC_FC_REQUEST_FIQ	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 2U)
54591054a3SAnthony Zhou #define SMC_FC_GET_NEXT_IRQ	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 3U)
55591054a3SAnthony Zhou #define SMC_FC_FIQ_ENTER	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 4U)
56948c090dSVarun Wadekar 
57591054a3SAnthony Zhou #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5U)
58591054a3SAnthony Zhou #define SMC_FC64_GET_FIQ_REGS	SMC_FASTCALL64_NR (SMC_ENTITY_SECURE_MONITOR, 6U)
59948c090dSVarun Wadekar 
60591054a3SAnthony Zhou #define SMC_FC_CPU_SUSPEND	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 7U)
61591054a3SAnthony Zhou #define SMC_FC_CPU_RESUME	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 8U)
62948c090dSVarun Wadekar 
63591054a3SAnthony Zhou #define SMC_FC_AARCH_SWITCH	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 9U)
64591054a3SAnthony Zhou #define SMC_FC_GET_VERSION_STR	SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10U)
65948c090dSVarun Wadekar 
66948c090dSVarun Wadekar /* Trusted OS entity calls */
67591054a3SAnthony Zhou #define SMC_YC_VIRTIO_GET_DESCR	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20U)
68591054a3SAnthony Zhou #define SMC_YC_VIRTIO_START	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21U)
69591054a3SAnthony Zhou #define SMC_YC_VIRTIO_STOP	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22U)
70948c090dSVarun Wadekar 
71591054a3SAnthony Zhou #define SMC_YC_VDEV_RESET	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23U)
72591054a3SAnthony Zhou #define SMC_YC_VDEV_KICK_VQ	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24U)
73591054a3SAnthony Zhou #define SMC_YC_SET_ROT_PARAMS	  SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535U)
74948c090dSVarun Wadekar 
75*fc198188SVarun Wadekar /*
76*fc198188SVarun Wadekar  * Standard Trusted OS Function IDs that fall under Trusted OS call range
77*fc198188SVarun Wadekar  * according to SMC calling convention
78*fc198188SVarun Wadekar  */
79*fc198188SVarun Wadekar #define SMC_FC64_GET_UUID		SMC_FASTCALL64_NR(63U, 0xFF01U) /* Implementation UID */
80*fc198188SVarun Wadekar #define SMC_FC_GET_UUID			SMC_FASTCALL_NR(63U, 0xFF01U) /* Implementation.UID */
81*fc198188SVarun Wadekar 
82c3cf06f1SAntonio Nino Diaz #endif /* SMCALL_H */
83