1 /*
2  * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef TRP_PRIVATE_H
8 #define TRP_PRIVATE_H
9 
10 #include <services/rmmd_svc.h>
11 #include <trp_helpers.h>
12 
13 /* Definitions for RMM-EL3 Interface ABI VERSION */
14 #define TRP_RMM_EL3_ABI_VERS_MAJOR	RMM_EL3_IFC_VERSION_MAJOR
15 #define TRP_RMM_EL3_ABI_VERS_MINOR	RMM_EL3_IFC_VERSION_MINOR
16 #define TRP_RMM_EL3_ABI_VERS	(((TRP_RMM_EL3_ABI_VERS_MAJOR & 0x7FFF) << 16) | \
17 				 (TRP_RMM_EL3_ABI_VERS_MINOR & 0xFFFF))
18 
19 #define TRP_PLATFORM_CORE_COUNT		PLATFORM_CORE_COUNT
20 
21 #ifndef __ASSEMBLER__
22 
23 #include <stdint.h>
24 
25 #define write_trp_arg(args, offset, val) (((args)->regs[offset >> 3])	\
26 					 = val)
27 /* RMI SMC64 FIDs handled by the TRP */
28 #define RMI_RMM_REQ_VERSION		SMC64_RMI_FID(U(0))
29 #define RMI_RMM_GRANULE_DELEGATE	SMC64_RMI_FID(U(1))
30 #define RMI_RMM_GRANULE_UNDELEGATE	SMC64_RMI_FID(U(2))
31 
32 /* Definitions for RMI VERSION */
33 #define RMI_ABI_VERSION_MAJOR		U(0x0)
34 #define RMI_ABI_VERSION_MINOR		U(0x0)
35 #define RMI_ABI_VERSION			(((RMI_ABI_VERSION_MAJOR & 0x7FFF) \
36 								  << 16) | \
37 					 (RMI_ABI_VERSION_MINOR & 0xFFFF))
38 
39 #define TRP_RMM_EL3_VERSION_GET_MAJOR(x)		\
40 				RMM_EL3_IFC_VERSION_GET_MAJOR((x))
41 #define TRP_RMM_EL3_VERSION_GET_MINOR(x)		\
42 				RMM_EL3_IFC_VERSION_GET_MAJOR_MINOR((x))
43 
44 /* Helper to issue SMC calls to BL31 */
45 uint64_t trp_smc(trp_args_t *);
46 
47 /* The main function to executed only by Primary CPU */
48 void trp_main(void);
49 
50 /* Setup TRP. Executed only by Primary CPU */
51 void trp_setup(uint64_t x0,
52 	       uint64_t x1,
53 	       uint64_t x2,
54 	       uint64_t x3);
55 
56 #endif /* __ASSEMBLER__ */
57 #endif /* TRP_PRIVATE_H */
58