xref: /rk3399_ARM-atf/include/plat/arm/common/arm_spm_def.h (revision 5feb20822a68242b63d46f6811357e8c4cf1d74c)
1e29efeb1SAntonio Nino Diaz /*
278a6c8ffSYeoreum Yun  * Copyright (c) 2017-2025, ARM Limited and Contributors. All rights reserved.
3e29efeb1SAntonio Nino Diaz  *
4e29efeb1SAntonio Nino Diaz  * SPDX-License-Identifier: BSD-3-Clause
5e29efeb1SAntonio Nino Diaz  */
6c3cf06f1SAntonio Nino Diaz #ifndef ARM_SPM_DEF_H
7c3cf06f1SAntonio Nino Diaz #define ARM_SPM_DEF_H
8e29efeb1SAntonio Nino Diaz 
909d40e0eSAntonio Nino Diaz #include <lib/utils_def.h>
1009d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_defs.h>
1109d40e0eSAntonio Nino Diaz 
12e29efeb1SAntonio Nino Diaz /*
13e29efeb1SAntonio Nino Diaz  * If BL31 is placed in DRAM, place the Secure Partition in DRAM right after the
14e29efeb1SAntonio Nino Diaz  * region used by BL31. If BL31 it is placed in SRAM, put the Secure Partition
15e29efeb1SAntonio Nino Diaz  * at the base of DRAM.
16e29efeb1SAntonio Nino Diaz  */
17e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_BASE		BL32_BASE
18e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_LIMIT		BL32_LIMIT
19e29efeb1SAntonio Nino Diaz /* The maximum size of the S-EL0 payload can be 3MB */
20e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_SIZE		ULL(0x300000)
21e29efeb1SAntonio Nino Diaz 
22e29efeb1SAntonio Nino Diaz #ifdef IMAGE_BL2
23e29efeb1SAntonio Nino Diaz /* SPM Payload memory. Mapped as RW in BL2. */
24e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_MMAP		MAP_REGION_FLAT(			\
25e29efeb1SAntonio Nino Diaz 						ARM_SP_IMAGE_BASE,		\
26e29efeb1SAntonio Nino Diaz 						ARM_SP_IMAGE_SIZE,		\
27e29efeb1SAntonio Nino Diaz 						MT_MEMORY | MT_RW | MT_SECURE)
28e29efeb1SAntonio Nino Diaz #endif
2909d413a1SAntonio Nino Diaz 
30e29efeb1SAntonio Nino Diaz #ifdef IMAGE_BL31
31e29efeb1SAntonio Nino Diaz /* SPM Payload memory. Mapped as code in S-EL1 */
32e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_MMAP		MAP_REGION2(				\
33e29efeb1SAntonio Nino Diaz 						ARM_SP_IMAGE_BASE,		\
34e29efeb1SAntonio Nino Diaz 						ARM_SP_IMAGE_BASE,		\
35e29efeb1SAntonio Nino Diaz 						ARM_SP_IMAGE_SIZE,		\
36e29efeb1SAntonio Nino Diaz 						MT_CODE | MT_SECURE | MT_USER,	\
37e29efeb1SAntonio Nino Diaz 						PAGE_SIZE)
38e29efeb1SAntonio Nino Diaz #endif
39e29efeb1SAntonio Nino Diaz 
40e29efeb1SAntonio Nino Diaz /*
41e29efeb1SAntonio Nino Diaz  * Memory shared between EL3 and S-EL0. It is used by EL3 to push data into
42e29efeb1SAntonio Nino Diaz  * S-EL0, so it is mapped with RW permission from EL3 and with RO permission
43e29efeb1SAntonio Nino Diaz  * from S-EL0. Placed after SPM Payload memory.
44e29efeb1SAntonio Nino Diaz  */
45e29efeb1SAntonio Nino Diaz #define PLAT_SPM_BUF_BASE		(ARM_SP_IMAGE_BASE + ARM_SP_IMAGE_SIZE)
46e29efeb1SAntonio Nino Diaz #define PLAT_SPM_BUF_SIZE		ULL(0x100000)
47e29efeb1SAntonio Nino Diaz 
48e29efeb1SAntonio Nino Diaz #define ARM_SPM_BUF_EL3_MMAP		MAP_REGION_FLAT(			\
49e29efeb1SAntonio Nino Diaz 						PLAT_SPM_BUF_BASE,		\
50e29efeb1SAntonio Nino Diaz 						PLAT_SPM_BUF_SIZE,		\
51e29efeb1SAntonio Nino Diaz 						MT_RW_DATA | MT_SECURE)
52e29efeb1SAntonio Nino Diaz #define ARM_SPM_BUF_EL0_MMAP		MAP_REGION2(			\
53e29efeb1SAntonio Nino Diaz 						PLAT_SPM_BUF_BASE,		\
54e29efeb1SAntonio Nino Diaz 						PLAT_SPM_BUF_BASE,		\
55e29efeb1SAntonio Nino Diaz 						PLAT_SPM_BUF_SIZE,		\
56e29efeb1SAntonio Nino Diaz 						MT_RO_DATA | MT_SECURE | MT_USER,\
57e29efeb1SAntonio Nino Diaz 						PAGE_SIZE)
58e29efeb1SAntonio Nino Diaz 
59e29efeb1SAntonio Nino Diaz /*
6078a6c8ffSYeoreum Yun  * Memory shared between Normal world and Secure world.
6178a6c8ffSYeoreum Yun  * In this area, PLAT_SP_IMAGE_NS_BUF and etc memories are located.
6278a6c8ffSYeoreum Yun  */
6378a6c8ffSYeoreum Yun #define ARM_SPM_NS_MEM_BASE		(ARM_AP_TZC_DRAM1_BASE -		\
6478a6c8ffSYeoreum Yun 					 ARM_SPM_NS_MEM_SIZE)
6578a6c8ffSYeoreum Yun #define ARM_SPM_NS_MEM_SIZE		ULL(0x100000)
6678a6c8ffSYeoreum Yun 
6778a6c8ffSYeoreum Yun /*
68e29efeb1SAntonio Nino Diaz  * Memory shared between Normal world and S-EL0 for passing data during service
69e29efeb1SAntonio Nino Diaz  * requests. Mapped as RW and NS. Placed after the shared memory between EL3 and
70e29efeb1SAntonio Nino Diaz  * S-EL0.
71e29efeb1SAntonio Nino Diaz  */
7278a6c8ffSYeoreum Yun #define PLAT_SP_IMAGE_NS_BUF_BASE	(ARM_SPM_NS_MEM_BASE)
730560efb9SArd Biesheuvel #define PLAT_SP_IMAGE_NS_BUF_SIZE	ULL(0x10000)
74e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_NS_BUF_MMAP	MAP_REGION2(				\
750560efb9SArd Biesheuvel 						PLAT_SP_IMAGE_NS_BUF_BASE,	\
760560efb9SArd Biesheuvel 						PLAT_SP_IMAGE_NS_BUF_BASE,	\
770560efb9SArd Biesheuvel 						PLAT_SP_IMAGE_NS_BUF_SIZE,	\
78e29efeb1SAntonio Nino Diaz 						MT_RW_DATA | MT_NS | MT_USER,	\
79e29efeb1SAntonio Nino Diaz 						PAGE_SIZE)
80e29efeb1SAntonio Nino Diaz 
81e29efeb1SAntonio Nino Diaz /*
82e29efeb1SAntonio Nino Diaz  * RW memory, which uses the remaining Trusted DRAM. Placed after the memory
832e4a509dSSughosh Ganu  * shared between Secure and Non-secure worlds, or after the platform specific
842e4a509dSSughosh Ganu  * buffers, if defined. First there is the stack memory for all CPUs and then
852e4a509dSSughosh Ganu  * there is the common heap memory. Both are mapped with RW permissions.
86e29efeb1SAntonio Nino Diaz  */
872e4a509dSSughosh Ganu #define PLAT_SP_IMAGE_STACK_BASE	PLAT_ARM_SP_IMAGE_STACK_BASE
88e29efeb1SAntonio Nino Diaz #define PLAT_SP_IMAGE_STACK_PCPU_SIZE	ULL(0x2000)
89e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_STACK_TOTAL_SIZE	(PLATFORM_CORE_COUNT *			\
90e29efeb1SAntonio Nino Diaz 					 PLAT_SP_IMAGE_STACK_PCPU_SIZE)
91e29efeb1SAntonio Nino Diaz 
92e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_HEAP_BASE		(PLAT_SP_IMAGE_STACK_BASE +		\
93e29efeb1SAntonio Nino Diaz 					 ARM_SP_IMAGE_STACK_TOTAL_SIZE)
94*d771d57aSYeoreum Yun #define ARM_SP_IMAGE_HEAP_SIZE		(ARM_SP_IMAGE_LIMIT -			\
95*d771d57aSYeoreum Yun 					 PLAT_SP_PSEUDO_S_CRB_SIZE -		\
96*d771d57aSYeoreum Yun 					 ARM_SP_IMAGE_HEAP_BASE)
97e29efeb1SAntonio Nino Diaz 
98e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_RW_MMAP		MAP_REGION2(				\
99e29efeb1SAntonio Nino Diaz 						PLAT_SP_IMAGE_STACK_BASE,	\
100e29efeb1SAntonio Nino Diaz 						PLAT_SP_IMAGE_STACK_BASE,	\
101e29efeb1SAntonio Nino Diaz 						(ARM_SP_IMAGE_LIMIT -		\
102*d771d57aSYeoreum Yun 						 PLAT_SP_PSEUDO_S_CRB_SIZE -	\
103e29efeb1SAntonio Nino Diaz 						 PLAT_SP_IMAGE_STACK_BASE),	\
104e29efeb1SAntonio Nino Diaz 						MT_RW_DATA | MT_SECURE | MT_USER,\
105e29efeb1SAntonio Nino Diaz 						PAGE_SIZE)
106e29efeb1SAntonio Nino Diaz 
107*d771d57aSYeoreum Yun #define PLAT_SP_PSEUDO_NS_CRB_BASE		(PLAT_SP_IMAGE_NS_BUF_BASE +	\
108*d771d57aSYeoreum Yun 						 PLAT_SP_IMAGE_NS_BUF_SIZE)
109*d771d57aSYeoreum Yun #define PLAT_SP_PSEUDO_NS_CRB_SIZE		SZ_16K
110*d771d57aSYeoreum Yun #define ARM_SP_PSEUDO_NS_CRB_MMAP		MAP_REGION_FLAT(		\
111*d771d57aSYeoreum Yun 							PLAT_SP_PSEUDO_NS_CRB_BASE,\
112*d771d57aSYeoreum Yun 							PLAT_SP_PSEUDO_NS_CRB_SIZE,\
113*d771d57aSYeoreum Yun 							MT_DEVICE | MT_RW |	\
114*d771d57aSYeoreum Yun 							MT_NS | MT_USER)
115*d771d57aSYeoreum Yun 
116*d771d57aSYeoreum Yun #define PLAT_SP_PSEUDO_S_CRB_BASE		(ARM_SP_IMAGE_HEAP_BASE +	\
117*d771d57aSYeoreum Yun 						ARM_SP_IMAGE_HEAP_SIZE)
118*d771d57aSYeoreum Yun #define PLAT_SP_PSEUDO_S_CRB_SIZE		SZ_4K
119*d771d57aSYeoreum Yun #define ARM_SP_PSEUDO_S_CRB_MMAP		MAP_REGION_FLAT(		\
120*d771d57aSYeoreum Yun 							PLAT_SP_PSEUDO_S_CRB_BASE,\
121*d771d57aSYeoreum Yun 							PLAT_SP_PSEUDO_S_CRB_SIZE,\
122*d771d57aSYeoreum Yun 							MT_DEVICE | MT_RW |	\
123*d771d57aSYeoreum Yun 							MT_SECURE | MT_USER)
124*d771d57aSYeoreum Yun 
125*d771d57aSYeoreum Yun 
126e29efeb1SAntonio Nino Diaz /* Total number of memory regions with distinct properties */
127e29efeb1SAntonio Nino Diaz #define ARM_SP_IMAGE_NUM_MEM_REGIONS	6
128e29efeb1SAntonio Nino Diaz 
129e29efeb1SAntonio Nino Diaz /* Cookies passed to the Secure Partition at boot. Not used by ARM platforms. */
130e29efeb1SAntonio Nino Diaz #define PLAT_SPM_COOKIE_0		ULL(0)
131e29efeb1SAntonio Nino Diaz #define PLAT_SPM_COOKIE_1		ULL(0)
132e29efeb1SAntonio Nino Diaz 
133c3cf06f1SAntonio Nino Diaz #endif /* ARM_SPM_DEF_H */
134