blob: 4fdef8b33b58a5bb5a8aa8af88e263b02f89cceb [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
2 * Copyright (c) 2013, ARM Limited. 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 <string.h>
32#include <assert.h>
33#include <arch_helpers.h>
34#include <platform.h>
35#include <bl2.h>
36#include <bl_common.h>
37
38/*******************************************************************************
39 * Declarations of linker defined symbols which will help us find the layout
40 * of trusted SRAM
41 ******************************************************************************/
42#if defined (__GNUC__)
43extern unsigned long __BL2_RO_BASE__;
44extern unsigned long __BL2_STACKS_BASE__;
45extern unsigned long __BL2_COHERENT_RAM_BASE__;
46extern unsigned long __BL2_RW_BASE__;
47
48#define BL2_RO_BASE __BL2_RO_BASE__
49#define BL2_STACKS_BASE __BL2_STACKS_BASE__
50#define BL2_COHERENT_RAM_BASE __BL2_COHERENT_RAM_BASE__
51#define BL2_RW_BASE __BL2_RW_BASE__
52
53#else
54 #error "Unknown compiler."
55#endif
56
57/* Pointer to memory visible to both BL2 and BL31 for passing data */
58extern unsigned char **bl2_el_change_mem_ptr;
59
60/* Data structure which holds the extents of the trusted SRAM for BL2 */
61static meminfo bl2_tzram_layout
62__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
Sandrine Bailleux204aa032013-10-28 15:14:00 +000063 section("tzfw_coherent_mem")));
Achin Gupta4f6ad662013-10-25 09:08:21 +010064
Achin Gupta4f6ad662013-10-25 09:08:21 +010065meminfo bl2_get_sec_mem_layout(void)
66{
67 return bl2_tzram_layout;
68}
69
Achin Gupta4f6ad662013-10-25 09:08:21 +010070/*******************************************************************************
71 * BL1 has passed the extents of the trusted SRAM that should be visible to BL2
72 * in x0. This memory layout is sitting at the base of the free trusted SRAM.
73 * Copy it to a safe loaction before its reclaimed by later BL2 functionality.
74 ******************************************************************************/
75void bl2_early_platform_setup(meminfo *mem_layout,
76 void *data)
77{
78 /* Setup the BL2 memory layout */
79 bl2_tzram_layout.total_base = mem_layout->total_base;
80 bl2_tzram_layout.total_size = mem_layout->total_size;
81 bl2_tzram_layout.free_base = mem_layout->free_base;
82 bl2_tzram_layout.free_size = mem_layout->free_size;
83 bl2_tzram_layout.attr = mem_layout->attr;
84 bl2_tzram_layout.next = 0;
85
86 /* Initialize the platform config for future decision making */
87 platform_config_setup();
88
89 return;
90}
91
92/*******************************************************************************
Sandrine Bailleux942f4052013-11-19 17:14:22 +000093 * Perform platform specific setup. For now just initialize the memory location
94 * to use for passing arguments to BL31.
Achin Gupta4f6ad662013-10-25 09:08:21 +010095 ******************************************************************************/
96void bl2_platform_setup()
97{
Achin Gupta4f6ad662013-10-25 09:08:21 +010098 /* Use the Trusted DRAM for passing args to BL31 */
99 bl2_el_change_mem_ptr = (unsigned char **) TZDRAM_BASE;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100100}
101
102/*******************************************************************************
103 * Perform the very early platform specific architectural setup here. At the
104 * moment this is only intializes the mmu in a quick and dirty way.
105 ******************************************************************************/
106void bl2_plat_arch_setup()
107{
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108 configure_mmu(&bl2_tzram_layout,
109 (unsigned long) &BL2_RO_BASE,
110 (unsigned long) &BL2_STACKS_BASE,
111 (unsigned long) &BL2_COHERENT_RAM_BASE,
112 (unsigned long) &BL2_RW_BASE);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100113}