blob: c38f2ec94923ad57d767588333f1a0d32363c767 [file] [log] [blame]
Roberto Vargas52207802017-11-17 13:22:18 +00001/*
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Roberto Vargas52207802017-11-17 13:22:18 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
Daniel Boulby45a2c9e2018-07-06 16:54:44 +01007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <drivers/generic_delay_timer.h>
10#include <plat/common/platform.h>
Antonio Nino Diaza320ecd2019-01-15 14:19:50 +000011#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012
Roberto Vargas52207802017-11-17 13:22:18 +000013#include <plat_arm.h>
Roberto Vargas52207802017-11-17 13:22:18 +000014
15#pragma weak bl2_el3_early_platform_setup
16#pragma weak bl2_el3_plat_arch_setup
17#pragma weak bl2_el3_plat_prepare_exit
18
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010019#define MAP_BL2_EL3_TOTAL MAP_REGION_FLAT( \
20 bl2_el3_tzram_layout.total_base, \
21 bl2_el3_tzram_layout.total_size, \
22 MT_MEMORY | MT_RW | MT_SECURE)
23
Roberto Vargas52207802017-11-17 13:22:18 +000024static meminfo_t bl2_el3_tzram_layout;
25
26/*
27 * Perform arm specific early platform setup. At this moment we only initialize
28 * the console and the memory layout.
29 */
30void arm_bl2_el3_early_platform_setup(void)
31{
32 /* Initialize the console to provide early debug support */
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010033 arm_console_boot_init();
Roberto Vargas52207802017-11-17 13:22:18 +000034
35 /*
36 * Allow BL2 to see the whole Trusted RAM. This is determined
37 * statically since we cannot rely on BL1 passing this information
38 * in the BL2_AT_EL3 case.
39 */
40 bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE;
41 bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE;
42
43 /* Initialise the IO layer and register platform IO devices */
44 plat_arm_io_setup();
45}
46
47void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
48 u_register_t arg1 __unused,
49 u_register_t arg2 __unused,
50 u_register_t arg3 __unused)
51{
52 arm_bl2_el3_early_platform_setup();
53
54 /*
55 * Initialize Interconnect for this cluster during cold boot.
56 * No need for locks as no other CPU is active.
57 */
58 plat_arm_interconnect_init();
59 /*
60 * Enable Interconnect coherency for the primary CPU's cluster.
61 */
62 plat_arm_interconnect_enter_coherency();
63
64 generic_delay_timer_init();
65}
66
67/*******************************************************************************
68 * Perform the very early platform specific architectural setup here. At the
69 * moment this is only initializes the mmu in a quick and dirty way.
70 ******************************************************************************/
71void arm_bl2_el3_plat_arch_setup(void)
72{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010073
Roberto Vargas52207802017-11-17 13:22:18 +000074#if USE_COHERENT_MEM
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010075 /* Ensure ARM platforms dont use coherent memory in BL2_AT_EL3 */
76 assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U);
Roberto Vargas52207802017-11-17 13:22:18 +000077#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010078
79 const mmap_region_t bl_regions[] = {
80 MAP_BL2_EL3_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010081 ARM_MAP_BL_RO,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010082 {0}
83 };
84
Roberto Vargas344ff022018-10-19 16:44:18 +010085 setup_page_tables(bl_regions, plat_arm_get_mmap());
Roberto Vargas52207802017-11-17 13:22:18 +000086
87#ifdef AARCH32
Antonio Nino Diaz533d3a82018-08-07 16:35:19 +010088 enable_mmu_svc_mon(0);
Roberto Vargas52207802017-11-17 13:22:18 +000089#else
90 enable_mmu_el3(0);
91#endif
92}
93
94void bl2_el3_plat_arch_setup(void)
95{
96 arm_bl2_el3_plat_arch_setup();
97}
98
99void bl2_el3_plat_prepare_exit(void)
100{
101}