blob: a626830231ffad00d7faba8d83360fbbfdcebec3 [file] [log] [blame]
Yatharth Kochar3a11eda2015-10-14 15:28:11 +01001/*
Roberto Vargas2ca18d92018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kochar3a11eda2015-10-14 15:28:11 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochar3a11eda2015-10-14 15:28:11 +01005 */
6
7#include <arch_helpers.h>
8#include <arm_def.h>
Daniel Boulby45a2c9e2018-07-06 16:54:44 +01009#include <assert.h>
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010010#include <bl_common.h>
Soby Mathewdb141302018-03-06 15:22:55 +000011#include <generic_delay_timer.h>
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010012#include <plat_arm.h>
Isla Mitchelld2548792017-07-14 10:48:25 +010013#include <platform_def.h>
Roberto Vargas2ca18d92018-02-12 12:36:17 +000014#include <platform.h>
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010015#include <string.h>
16
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010017/* Weak definitions may be overridden in specific ARM standard platform */
18#pragma weak bl2u_platform_setup
19#pragma weak bl2u_early_platform_setup
20#pragma weak bl2u_plat_arch_setup
21
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010022#define MAP_BL2U_TOTAL MAP_REGION_FLAT( \
23 BL2U_BASE, \
24 BL2U_LIMIT - BL2U_BASE, \
25 MT_MEMORY | MT_RW | MT_SECURE)
26
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010027/*
28 * Perform ARM standard platform setup for BL2U
29 */
30void arm_bl2u_platform_setup(void)
31{
32 /* Initialize the secure environment */
33 plat_arm_security_setup();
34}
35
36void bl2u_platform_setup(void)
37{
38 arm_bl2u_platform_setup();
39}
40
Sandrine Bailleuxb3b6e222018-07-11 12:44:22 +020041void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010042{
43 /* Initialize the console to provide early debug support */
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010044 arm_console_boot_init();
45
Soby Mathewdb141302018-03-06 15:22:55 +000046 generic_delay_timer_init();
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010047}
48
49/*******************************************************************************
50 * BL1 can pass platform dependent information to BL2U in x1.
51 * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
52 * In case of ARM FVP platforms x1 is not used.
53 * In both cases, x0 contains the extents of the memory available to BL2U
54 ******************************************************************************/
Sandrine Bailleuxb3b6e222018-07-11 12:44:22 +020055void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010056{
57 arm_bl2u_early_platform_setup(mem_layout, plat_info);
58}
59
60/*******************************************************************************
61 * Perform the very early platform specific architectural setup here. At the
62 * moment this is only initializes the mmu in a quick and dirty way.
63 * The memory that is used by BL2U is only mapped.
64 ******************************************************************************/
65void arm_bl2u_plat_arch_setup(void)
66{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010067
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010068#if USE_COHERENT_MEM
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010069 /* Ensure ARM platforms dont use coherent memory in BL2U */
70 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010071#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010072
73 const mmap_region_t bl_regions[] = {
74 MAP_BL2U_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010075 ARM_MAP_BL_RO,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010076 {0}
77 };
78
79 arm_setup_page_tables(bl_regions, plat_arm_get_mmap());
80
Yatharth Kochar18dfb302016-11-22 11:06:03 +000081#ifdef AARCH32
82 enable_mmu_secure(0);
83#else
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010084 enable_mmu_el1(0);
Yatharth Kochar18dfb302016-11-22 11:06:03 +000085#endif
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010086}
87
88void bl2u_plat_arch_setup(void)
89{
90 arm_bl2u_plat_arch_setup();
91}