blob: 4f5e6a9e6e2794add41ef0cbd934c2db5dfc5c11 [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 */
Daniel Boulby45a2c9e2018-07-06 16:54:44 +01006#include <arm_def.h>
7#include <assert.h>
Roberto Vargas52207802017-11-17 13:22:18 +00008#include <generic_delay_timer.h>
9#include <plat_arm.h>
10#include <platform.h>
11
12#pragma weak bl2_el3_early_platform_setup
13#pragma weak bl2_el3_plat_arch_setup
14#pragma weak bl2_el3_plat_prepare_exit
15
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010016#define MAP_BL2_EL3_TOTAL MAP_REGION_FLAT( \
17 bl2_el3_tzram_layout.total_base, \
18 bl2_el3_tzram_layout.total_size, \
19 MT_MEMORY | MT_RW | MT_SECURE)
20
Roberto Vargas52207802017-11-17 13:22:18 +000021static meminfo_t bl2_el3_tzram_layout;
22
23/*
24 * Perform arm specific early platform setup. At this moment we only initialize
25 * the console and the memory layout.
26 */
27void arm_bl2_el3_early_platform_setup(void)
28{
29 /* Initialize the console to provide early debug support */
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010030 arm_console_boot_init();
Roberto Vargas52207802017-11-17 13:22:18 +000031
32 /*
33 * Allow BL2 to see the whole Trusted RAM. This is determined
34 * statically since we cannot rely on BL1 passing this information
35 * in the BL2_AT_EL3 case.
36 */
37 bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE;
38 bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE;
39
40 /* Initialise the IO layer and register platform IO devices */
41 plat_arm_io_setup();
42}
43
44void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
45 u_register_t arg1 __unused,
46 u_register_t arg2 __unused,
47 u_register_t arg3 __unused)
48{
49 arm_bl2_el3_early_platform_setup();
50
51 /*
52 * Initialize Interconnect for this cluster during cold boot.
53 * No need for locks as no other CPU is active.
54 */
55 plat_arm_interconnect_init();
56 /*
57 * Enable Interconnect coherency for the primary CPU's cluster.
58 */
59 plat_arm_interconnect_enter_coherency();
60
61 generic_delay_timer_init();
62}
63
64/*******************************************************************************
65 * Perform the very early platform specific architectural setup here. At the
66 * moment this is only initializes the mmu in a quick and dirty way.
67 ******************************************************************************/
68void arm_bl2_el3_plat_arch_setup(void)
69{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010070
Roberto Vargas52207802017-11-17 13:22:18 +000071#if USE_COHERENT_MEM
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010072 /* Ensure ARM platforms dont use coherent memory in BL2_AT_EL3 */
73 assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U);
Roberto Vargas52207802017-11-17 13:22:18 +000074#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010075
76 const mmap_region_t bl_regions[] = {
77 MAP_BL2_EL3_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010078 ARM_MAP_BL_RO,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010079 {0}
80 };
81
Roberto Vargas344ff022018-10-19 16:44:18 +010082 setup_page_tables(bl_regions, plat_arm_get_mmap());
Roberto Vargas52207802017-11-17 13:22:18 +000083
84#ifdef AARCH32
Antonio Nino Diaz533d3a82018-08-07 16:35:19 +010085 enable_mmu_svc_mon(0);
Roberto Vargas52207802017-11-17 13:22:18 +000086#else
87 enable_mmu_el3(0);
88#endif
89}
90
91void bl2_el3_plat_arch_setup(void)
92{
93 arm_bl2_el3_plat_arch_setup();
94}
95
96void bl2_el3_plat_prepare_exit(void)
97{
98}