blob: 0dc66e647ec1e3f83579bd07dcadf61a633c8a38 [file] [log] [blame]
Yatharth Kochardcda29f2015-10-14 15:28:11 +01001/*
Roberto Vargas1af540e2018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kochardcda29f2015-10-14 15:28:11 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochardcda29f2015-10-14 15:28:11 +01005 */
6
Daniel Boulbyd323af92018-07-06 16:54:44 +01007#include <assert.h>
Yatharth Kochardcda29f2015-10-14 15:28:11 +01008#include <string.h>
9
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000010#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 <arm_def.h>
18#include <plat_arm.h>
19
Yatharth Kochardcda29f2015-10-14 15:28:11 +010020/* Weak definitions may be overridden in specific ARM standard platform */
21#pragma weak bl2u_platform_setup
22#pragma weak bl2u_early_platform_setup
23#pragma weak bl2u_plat_arch_setup
24
Daniel Boulbyd323af92018-07-06 16:54:44 +010025#define MAP_BL2U_TOTAL MAP_REGION_FLAT( \
26 BL2U_BASE, \
27 BL2U_LIMIT - BL2U_BASE, \
28 MT_MEMORY | MT_RW | MT_SECURE)
29
Yatharth Kochardcda29f2015-10-14 15:28:11 +010030/*
31 * Perform ARM standard platform setup for BL2U
32 */
33void arm_bl2u_platform_setup(void)
34{
35 /* Initialize the secure environment */
36 plat_arm_security_setup();
37}
38
39void bl2u_platform_setup(void)
40{
41 arm_bl2u_platform_setup();
42}
43
Sandrine Bailleux6c77e742018-07-11 12:44:22 +020044void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochardcda29f2015-10-14 15:28:11 +010045{
46 /* Initialize the console to provide early debug support */
Antonio Nino Diaz88a05232018-06-19 09:29:36 +010047 arm_console_boot_init();
48
Soby Mathew74847ab2018-03-06 15:22:55 +000049 generic_delay_timer_init();
Yatharth Kochardcda29f2015-10-14 15:28:11 +010050}
51
52/*******************************************************************************
53 * BL1 can pass platform dependent information to BL2U in x1.
54 * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
55 * In case of ARM FVP platforms x1 is not used.
56 * In both cases, x0 contains the extents of the memory available to BL2U
57 ******************************************************************************/
Sandrine Bailleux6c77e742018-07-11 12:44:22 +020058void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochardcda29f2015-10-14 15:28:11 +010059{
60 arm_bl2u_early_platform_setup(mem_layout, plat_info);
61}
62
63/*******************************************************************************
64 * Perform the very early platform specific architectural setup here. At the
65 * moment this is only initializes the mmu in a quick and dirty way.
66 * The memory that is used by BL2U is only mapped.
67 ******************************************************************************/
68void arm_bl2u_plat_arch_setup(void)
69{
Daniel Boulbyd323af92018-07-06 16:54:44 +010070
Yatharth Kochardcda29f2015-10-14 15:28:11 +010071#if USE_COHERENT_MEM
Daniel Boulbyd323af92018-07-06 16:54:44 +010072 /* Ensure ARM platforms dont use coherent memory in BL2U */
73 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
Yatharth Kochardcda29f2015-10-14 15:28:11 +010074#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +010075
76 const mmap_region_t bl_regions[] = {
77 MAP_BL2U_TOTAL,
Daniel Boulby2ecaafd2018-07-16 14:09:15 +010078 ARM_MAP_BL_RO,
Roberto Vargas1eb735d2018-05-23 09:27:06 +010079#if USE_ROMLIB
80 ARM_MAP_ROMLIB_CODE,
81 ARM_MAP_ROMLIB_DATA,
82#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +010083 {0}
84 };
85
Roberto Vargas0916c382018-10-19 16:44:18 +010086 setup_page_tables(bl_regions, plat_arm_get_mmap());
Daniel Boulbyd323af92018-07-06 16:54:44 +010087
Yatharth Kochar1bd61d02016-11-22 11:06:03 +000088#ifdef AARCH32
Antonio Nino Diaz1e54cbb2018-08-07 16:35:19 +010089 enable_mmu_svc_mon(0);
Yatharth Kochar1bd61d02016-11-22 11:06:03 +000090#else
Sandrine Bailleuxb5fa6562016-05-18 16:11:47 +010091 enable_mmu_el1(0);
Yatharth Kochar1bd61d02016-11-22 11:06:03 +000092#endif
Roberto Vargas1eb735d2018-05-23 09:27:06 +010093 arm_setup_romlib();
Yatharth Kochardcda29f2015-10-14 15:28:11 +010094}
95
96void bl2u_plat_arch_setup(void)
97{
98 arm_bl2u_plat_arch_setup();
99}