arm_bl2u_setup.c 2.52 KB
Newer Older
1
/*
Roberto Vargas's avatar
Roberto Vargas committed
2
 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
8
9
10
11
#include <assert.h>
#include <string.h>

#include <platform_def.h>

12
#include <arch_helpers.h>
13
14
15
16
#include <common/bl_common.h>
#include <drivers/generic_delay_timer.h>
#include <plat/common/platform.h>

17
18
19
20
21
22
23
24
#include <arm_def.h>
#include <plat_arm.h>

/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak bl2u_platform_setup
#pragma weak bl2u_early_platform_setup
#pragma weak bl2u_plat_arch_setup

25
26
27
28
29
#define MAP_BL2U_TOTAL		MAP_REGION_FLAT(			\
					BL2U_BASE,			\
					BL2U_LIMIT - BL2U_BASE,		\
					MT_MEMORY | MT_RW | MT_SECURE)

30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Perform ARM standard platform setup for BL2U
 */
void arm_bl2u_platform_setup(void)
{
	/* Initialize the secure environment */
	plat_arm_security_setup();
}

void bl2u_platform_setup(void)
{
	arm_bl2u_platform_setup();
}

44
void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
45
46
{
	/* Initialize the console to provide early debug support */
47
48
	arm_console_boot_init();

49
	generic_delay_timer_init();
50
51
52
53
54
55
56
57
}

/*******************************************************************************
 * BL1 can pass platform dependent information to BL2U in x1.
 * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
 * In case of ARM FVP platforms x1 is not used.
 * In both cases, x0 contains the extents of the memory available to BL2U
 ******************************************************************************/
58
void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
59
60
61
62
63
64
65
66
67
68
69
{
	arm_bl2u_early_platform_setup(mem_layout, plat_info);
}

/*******************************************************************************
 * Perform the very early platform specific architectural setup here. At the
 * moment this is only initializes the mmu in a quick and dirty way.
 * The memory that is used by BL2U is only mapped.
 ******************************************************************************/
void arm_bl2u_plat_arch_setup(void)
{
70

71
#if USE_COHERENT_MEM
72
73
	/* Ensure ARM platforms dont use coherent memory in BL2U */
	assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
74
#endif
75
76
77

	const mmap_region_t bl_regions[] = {
		MAP_BL2U_TOTAL,
78
		ARM_MAP_BL_RO,
Roberto Vargas's avatar
Roberto Vargas committed
79
80
81
82
#if USE_ROMLIB
		ARM_MAP_ROMLIB_CODE,
		ARM_MAP_ROMLIB_DATA,
#endif
83
84
85
		{0}
	};

86
	setup_page_tables(bl_regions, plat_arm_get_mmap());
87

Yatharth Kochar's avatar
Yatharth Kochar committed
88
#ifdef AARCH32
89
	enable_mmu_svc_mon(0);
Yatharth Kochar's avatar
Yatharth Kochar committed
90
#else
91
	enable_mmu_el1(0);
Yatharth Kochar's avatar
Yatharth Kochar committed
92
#endif
Roberto Vargas's avatar
Roberto Vargas committed
93
	arm_setup_romlib();
94
95
96
97
98
99
}

void bl2u_plat_arch_setup(void)
{
	arm_bl2u_plat_arch_setup();
}