xref: /rk3399_ARM-atf/plat/arm/common/arm_bl2u_setup.c (revision c948f77136c42a92d0bb660543a3600c36dcf7f1)
1 /*
2  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 #include <string.h>
9 
10 #include <platform_def.h>
11 
12 #include <arch_helpers.h>
13 #include <common/bl_common.h>
14 #include <drivers/generic_delay_timer.h>
15 #include <plat/common/platform.h>
16 
17 #include <plat_arm.h>
18 
19 /* Weak definitions may be overridden in specific ARM standard platform */
20 #pragma weak bl2u_platform_setup
21 #pragma weak bl2u_early_platform_setup
22 #pragma weak bl2u_plat_arch_setup
23 
24 #define MAP_BL2U_TOTAL		MAP_REGION_FLAT(			\
25 					BL2U_BASE,			\
26 					BL2U_LIMIT - BL2U_BASE,		\
27 					MT_MEMORY | MT_RW | MT_SECURE)
28 
29 /*
30  * Perform ARM standard platform setup for BL2U
31  */
32 void arm_bl2u_platform_setup(void)
33 {
34 	/* Initialize the secure environment */
35 	plat_arm_security_setup();
36 }
37 
38 void bl2u_platform_setup(void)
39 {
40 	arm_bl2u_platform_setup();
41 }
42 
43 void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
44 {
45 	/* Initialize the console to provide early debug support */
46 	arm_console_boot_init();
47 
48 	generic_delay_timer_init();
49 }
50 
51 /*******************************************************************************
52  * BL1 can pass platform dependent information to BL2U in x1.
53  * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
54  * In case of ARM FVP platforms x1 is not used.
55  * In both cases, x0 contains the extents of the memory available to BL2U
56  ******************************************************************************/
57 void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
58 {
59 	arm_bl2u_early_platform_setup(mem_layout, plat_info);
60 }
61 
62 /*******************************************************************************
63  * Perform the very early platform specific architectural setup here. At the
64  * moment this is only initializes the mmu in a quick and dirty way.
65  * The memory that is used by BL2U is only mapped.
66  ******************************************************************************/
67 void arm_bl2u_plat_arch_setup(void)
68 {
69 
70 #if USE_COHERENT_MEM
71 	/* Ensure ARM platforms dont use coherent memory in BL2U */
72 	assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
73 #endif
74 
75 	const mmap_region_t bl_regions[] = {
76 		MAP_BL2U_TOTAL,
77 		ARM_MAP_BL_RO,
78 #if USE_ROMLIB
79 		ARM_MAP_ROMLIB_CODE,
80 		ARM_MAP_ROMLIB_DATA,
81 #endif
82 		{0}
83 	};
84 
85 	setup_page_tables(bl_regions, plat_arm_get_mmap());
86 
87 #ifdef AARCH32
88 	enable_mmu_svc_mon(0);
89 #else
90 	enable_mmu_el1(0);
91 #endif
92 	arm_setup_romlib();
93 }
94 
95 void bl2u_plat_arch_setup(void)
96 {
97 	arm_bl2u_plat_arch_setup();
98 }
99