arm_bl2_el3_setup.c 2.5 KB
Newer Older
1
/*
2
 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3
4
5
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
6

7
#include <assert.h>
8
9
10
11
12

#include <drivers/generic_delay_timer.h>
#include <plat/common/platform.h>

#include <arm_def.h>
13
14
15
16
17
18
#include <plat_arm.h>

#pragma weak bl2_el3_early_platform_setup
#pragma weak bl2_el3_plat_arch_setup
#pragma weak bl2_el3_plat_prepare_exit

19
20
21
22
23
#define MAP_BL2_EL3_TOTAL	MAP_REGION_FLAT(				\
					bl2_el3_tzram_layout.total_base,	\
					bl2_el3_tzram_layout.total_size,	\
					MT_MEMORY | MT_RW | MT_SECURE)

24
25
26
27
28
29
30
31
32
static meminfo_t bl2_el3_tzram_layout;

/*
 * Perform arm specific early platform setup. At this moment we only initialize
 * the console and the memory layout.
 */
void arm_bl2_el3_early_platform_setup(void)
{
	/* Initialize the console to provide early debug support */
33
	arm_console_boot_init();
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

	/*
	 * Allow BL2 to see the whole Trusted RAM. This is determined
	 * statically since we cannot rely on BL1 passing this information
	 * in the BL2_AT_EL3 case.
	 */
	bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE;
	bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE;

	/* Initialise the IO layer and register platform IO devices */
	plat_arm_io_setup();
}

void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
				  u_register_t arg1 __unused,
				  u_register_t arg2 __unused,
				  u_register_t arg3 __unused)
{
	arm_bl2_el3_early_platform_setup();

	/*
	 * Initialize Interconnect for this cluster during cold boot.
	 * No need for locks as no other CPU is active.
	 */
	plat_arm_interconnect_init();
	/*
	 * Enable Interconnect coherency for the primary CPU's cluster.
	 */
	plat_arm_interconnect_enter_coherency();

	generic_delay_timer_init();
}

/*******************************************************************************
 * Perform the very early platform specific architectural setup here. At the
 * moment this is only initializes the mmu in a quick and dirty way.
 ******************************************************************************/
void arm_bl2_el3_plat_arch_setup(void)
{
73

74
#if USE_COHERENT_MEM
75
76
	/* Ensure ARM platforms dont use coherent memory in BL2_AT_EL3 */
	assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U);
77
#endif
78
79
80

	const mmap_region_t bl_regions[] = {
		MAP_BL2_EL3_TOTAL,
81
		ARM_MAP_BL_RO,
82
83
84
		{0}
	};

85
	setup_page_tables(bl_regions, plat_arm_get_mmap());
86
87

#ifdef AARCH32
88
	enable_mmu_svc_mon(0);
89
90
91
92
93
94
95
96
97
98
99
100
101
#else
	enable_mmu_el3(0);
#endif
}

void bl2_el3_plat_arch_setup(void)
{
	arm_bl2_el3_plat_arch_setup();
}

void bl2_el3_plat_prepare_exit(void)
{
}