blob: 5b7354b3ebc13eab1546c7e97e167d13deb74ba0 [file] [log] [blame]
Yatharth Kochar3a11eda2015-10-14 15:28:11 +01001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <arch_helpers.h>
32#include <arm_def.h>
33#include <bl_common.h>
34#include <console.h>
35#include <platform_def.h>
36#include <plat_arm.h>
37#include <string.h>
38
39
40/*
41 * The next 2 constants identify the extents of the code & RO data region.
42 * These addresses are used by the MMU setup code and therefore they must be
43 * page-aligned. It is the responsibility of the linker script to ensure that
44 * __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses.
45 */
46#define BL2U_RO_BASE (unsigned long)(&__RO_START__)
47#define BL2U_RO_LIMIT (unsigned long)(&__RO_END__)
48
49#if USE_COHERENT_MEM
50/*
51 * The next 2 constants identify the extents of the coherent memory region.
52 * These addresses are used by the MMU setup code and therefore they must be
53 * page-aligned. It is the responsibility of the linker script to ensure that
54 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to
55 * page-aligned addresses.
56 */
57#define BL2U_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
58#define BL2U_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
59#endif
60
61/* Weak definitions may be overridden in specific ARM standard platform */
62#pragma weak bl2u_platform_setup
63#pragma weak bl2u_early_platform_setup
64#pragma weak bl2u_plat_arch_setup
65
66/*
67 * Perform ARM standard platform setup for BL2U
68 */
69void arm_bl2u_platform_setup(void)
70{
71 /* Initialize the secure environment */
72 plat_arm_security_setup();
73}
74
75void bl2u_platform_setup(void)
76{
77 arm_bl2u_platform_setup();
78}
79
80void arm_bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
81{
82 /* Initialize the console to provide early debug support */
83 console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
84 ARM_CONSOLE_BAUDRATE);
85}
86
87/*******************************************************************************
88 * BL1 can pass platform dependent information to BL2U in x1.
89 * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
90 * In case of ARM FVP platforms x1 is not used.
91 * In both cases, x0 contains the extents of the memory available to BL2U
92 ******************************************************************************/
93void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
94{
95 arm_bl2u_early_platform_setup(mem_layout, plat_info);
96}
97
98/*******************************************************************************
99 * Perform the very early platform specific architectural setup here. At the
100 * moment this is only initializes the mmu in a quick and dirty way.
101 * The memory that is used by BL2U is only mapped.
102 ******************************************************************************/
103void arm_bl2u_plat_arch_setup(void)
104{
105 arm_configure_mmu_el1(BL2U_RO_LIMIT,
106 BL31_LIMIT,
107 BL2U_RO_BASE,
108 BL2U_RO_LIMIT
109#if USE_COHERENT_MEM
110 ,
111 BL2U_COHERENT_RAM_BASE,
112 BL2U_COHERENT_RAM_LIMIT
113#endif
114 );
115}
116
117void bl2u_plat_arch_setup(void)
118{
119 arm_bl2u_plat_arch_setup();
120}