blob: 332ed14cf123cd1454d963a776d6b1814235f41e [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
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <assert.h>
8#include <string.h>
9
10#include <platform_def.h>
11
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010012#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000013#include <common/bl_common.h>
14#include <drivers/generic_delay_timer.h>
15#include <plat/common/platform.h>
16
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010017#include <plat_arm.h>
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010018
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010019/* Weak definitions may be overridden in specific ARM standard platform */
20#pragma weak bl2u_platform_setup
21#pragma weak bl2u_early_platform_setup
22#pragma weak bl2u_plat_arch_setup
23
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010024#define MAP_BL2U_TOTAL MAP_REGION_FLAT( \
25 BL2U_BASE, \
26 BL2U_LIMIT - BL2U_BASE, \
27 MT_MEMORY | MT_RW | MT_SECURE)
28
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010029/*
30 * Perform ARM standard platform setup for BL2U
31 */
32void arm_bl2u_platform_setup(void)
33{
34 /* Initialize the secure environment */
35 plat_arm_security_setup();
36}
37
38void bl2u_platform_setup(void)
39{
40 arm_bl2u_platform_setup();
41}
42
Sandrine Bailleuxb3b6e222018-07-11 12:44:22 +020043void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010044{
45 /* Initialize the console to provide early debug support */
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010046 arm_console_boot_init();
47
Soby Mathewdb141302018-03-06 15:22:55 +000048 generic_delay_timer_init();
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010049}
50
51/*******************************************************************************
52 * BL1 can pass platform dependent information to BL2U in x1.
53 * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
54 * In case of ARM FVP platforms x1 is not used.
55 * In both cases, x0 contains the extents of the memory available to BL2U
56 ******************************************************************************/
Sandrine Bailleuxb3b6e222018-07-11 12:44:22 +020057void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010058{
59 arm_bl2u_early_platform_setup(mem_layout, plat_info);
60}
61
62/*******************************************************************************
63 * Perform the very early platform specific architectural setup here. At the
64 * moment this is only initializes the mmu in a quick and dirty way.
65 * The memory that is used by BL2U is only mapped.
66 ******************************************************************************/
67void arm_bl2u_plat_arch_setup(void)
68{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010069
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010070#if USE_COHERENT_MEM
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010071 /* Ensure ARM platforms dont use coherent memory in BL2U */
72 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010073#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010074
75 const mmap_region_t bl_regions[] = {
76 MAP_BL2U_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010077 ARM_MAP_BL_RO,
Roberto Vargase3adc372018-05-23 09:27:06 +010078#if USE_ROMLIB
79 ARM_MAP_ROMLIB_CODE,
80 ARM_MAP_ROMLIB_DATA,
81#endif
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());
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010086
Yatharth Kochar18dfb302016-11-22 11:06:03 +000087#ifdef AARCH32
Antonio Nino Diaz533d3a82018-08-07 16:35:19 +010088 enable_mmu_svc_mon(0);
Yatharth Kochar18dfb302016-11-22 11:06:03 +000089#else
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010090 enable_mmu_el1(0);
Yatharth Kochar18dfb302016-11-22 11:06:03 +000091#endif
Roberto Vargase3adc372018-05-23 09:27:06 +010092 arm_setup_romlib();
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010093}
94
95void bl2u_plat_arch_setup(void)
96{
97 arm_bl2u_plat_arch_setup();
98}