blob: 01e0db0bc8e763d43d6845aec7817c81c4b18a20 [file] [log] [blame]
Roberto Vargas52207802017-11-17 13:22:18 +00001/*
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -06002 * Copyright (c) 2017-2023, 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>
Harsimran Singh Tungaldc16c8f2023-10-20 11:24:07 +010010#include <drivers/partition/partition.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000011#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <plat/common/platform.h>
Antonio Nino Diaza320ecd2019-01-15 14:19:50 +000013#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014
Roberto Vargas52207802017-11-17 13:22:18 +000015#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
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -060038 * in the RESET_TO_BL2 case.
Roberto Vargas52207802017-11-17 13:22:18 +000039 */
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
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -060075 /* Ensure ARM platforms dont use coherent memory
76 * in RESET_TO_BL2
77 */
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010078 assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U);
Roberto Vargas52207802017-11-17 13:22:18 +000079#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010080
81 const mmap_region_t bl_regions[] = {
82 MAP_BL2_EL3_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010083 ARM_MAP_BL_RO,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010084 {0}
85 };
86
Roberto Vargas344ff022018-10-19 16:44:18 +010087 setup_page_tables(bl_regions, plat_arm_get_mmap());
Roberto Vargas52207802017-11-17 13:22:18 +000088
Julius Werner8e0ef0f2019-07-09 14:02:43 -070089#ifdef __aarch64__
Roberto Vargas52207802017-11-17 13:22:18 +000090 enable_mmu_el3(0);
Julius Werner8e0ef0f2019-07-09 14:02:43 -070091#else
92 enable_mmu_svc_mon(0);
Roberto Vargas52207802017-11-17 13:22:18 +000093#endif
94}
95
96void bl2_el3_plat_arch_setup(void)
97{
Harsimran Singh Tungaldc16c8f2023-10-20 11:24:07 +010098 int __maybe_unused ret;
Roberto Vargas52207802017-11-17 13:22:18 +000099 arm_bl2_el3_plat_arch_setup();
Harsimran Singh Tungaldc16c8f2023-10-20 11:24:07 +0100100#if ARM_GPT_SUPPORT
101 ret = gpt_partition_init();
102 if (ret != 0) {
103 ERROR("GPT partition initialisation failed!\n");
104 panic();
105 }
106#endif /* ARM_GPT_SUPPORT */
Roberto Vargas52207802017-11-17 13:22:18 +0000107}
108
109void bl2_el3_plat_prepare_exit(void)
110{
111}