xref: /rk3399_ARM-atf/bl32/tsp/tsp.ld.S (revision 7c88f3f633288856dd691dfda222e60092e4dab9)
1*7c88f3f6SAchin Gupta/*
2*7c88f3f6SAchin Gupta * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
3*7c88f3f6SAchin Gupta *
4*7c88f3f6SAchin Gupta * Redistribution and use in source and binary forms, with or without
5*7c88f3f6SAchin Gupta * modification, are permitted provided that the following conditions are met:
6*7c88f3f6SAchin Gupta *
7*7c88f3f6SAchin Gupta * Redistributions of source code must retain the above copyright notice, this
8*7c88f3f6SAchin Gupta * list of conditions and the following disclaimer.
9*7c88f3f6SAchin Gupta *
10*7c88f3f6SAchin Gupta * Redistributions in binary form must reproduce the above copyright notice,
11*7c88f3f6SAchin Gupta * this list of conditions and the following disclaimer in the documentation
12*7c88f3f6SAchin Gupta * and/or other materials provided with the distribution.
13*7c88f3f6SAchin Gupta *
14*7c88f3f6SAchin Gupta * Neither the name of ARM nor the names of its contributors may be used
15*7c88f3f6SAchin Gupta * to endorse or promote products derived from this software without specific
16*7c88f3f6SAchin Gupta * prior written permission.
17*7c88f3f6SAchin Gupta *
18*7c88f3f6SAchin Gupta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*7c88f3f6SAchin Gupta * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*7c88f3f6SAchin Gupta * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*7c88f3f6SAchin Gupta * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*7c88f3f6SAchin Gupta * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*7c88f3f6SAchin Gupta * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*7c88f3f6SAchin Gupta * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*7c88f3f6SAchin Gupta * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*7c88f3f6SAchin Gupta * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*7c88f3f6SAchin Gupta * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*7c88f3f6SAchin Gupta * POSSIBILITY OF SUCH DAMAGE.
29*7c88f3f6SAchin Gupta */
30*7c88f3f6SAchin Gupta
31*7c88f3f6SAchin Gupta#include <platform.h>
32*7c88f3f6SAchin Gupta
33*7c88f3f6SAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
34*7c88f3f6SAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
35*7c88f3f6SAchin Gupta
36*7c88f3f6SAchin GuptaMEMORY {
37*7c88f3f6SAchin Gupta    RAM (rwx): ORIGIN = TZDRAM_BASE, LENGTH = TZDRAM_SIZE
38*7c88f3f6SAchin Gupta}
39*7c88f3f6SAchin Gupta
40*7c88f3f6SAchin Gupta
41*7c88f3f6SAchin GuptaSECTIONS
42*7c88f3f6SAchin Gupta{
43*7c88f3f6SAchin Gupta    . = BL32_BASE;
44*7c88f3f6SAchin Gupta    ASSERT(. == ALIGN(4096),
45*7c88f3f6SAchin Gupta           "BL32_BASE address is not aligned on a page boundary.")
46*7c88f3f6SAchin Gupta
47*7c88f3f6SAchin Gupta    ro . : {
48*7c88f3f6SAchin Gupta        __RO_START__ = .;
49*7c88f3f6SAchin Gupta        *tsp_entrypoint.o(.text)
50*7c88f3f6SAchin Gupta        *(.text)
51*7c88f3f6SAchin Gupta        *(.rodata*)
52*7c88f3f6SAchin Gupta        *(.vectors)
53*7c88f3f6SAchin Gupta        __RO_END_UNALIGNED__ = .;
54*7c88f3f6SAchin Gupta        /*
55*7c88f3f6SAchin Gupta         * Memory page(s) mapped to this section will be marked as
56*7c88f3f6SAchin Gupta         * read-only, executable.  No RW data from the next section must
57*7c88f3f6SAchin Gupta         * creep in.  Ensure the rest of the current memory page is unused.
58*7c88f3f6SAchin Gupta         */
59*7c88f3f6SAchin Gupta        . = NEXT(4096);
60*7c88f3f6SAchin Gupta        __RO_END__ = .;
61*7c88f3f6SAchin Gupta    } >RAM
62*7c88f3f6SAchin Gupta
63*7c88f3f6SAchin Gupta    .data . : {
64*7c88f3f6SAchin Gupta        __DATA_START__ = .;
65*7c88f3f6SAchin Gupta        *(.data)
66*7c88f3f6SAchin Gupta        __DATA_END__ = .;
67*7c88f3f6SAchin Gupta    } >RAM
68*7c88f3f6SAchin Gupta
69*7c88f3f6SAchin Gupta    stacks (NOLOAD) : {
70*7c88f3f6SAchin Gupta        __STACKS_START__ = .;
71*7c88f3f6SAchin Gupta        *(tzfw_normal_stacks)
72*7c88f3f6SAchin Gupta        __STACKS_END__ = .;
73*7c88f3f6SAchin Gupta    } >RAM
74*7c88f3f6SAchin Gupta
75*7c88f3f6SAchin Gupta    /*
76*7c88f3f6SAchin Gupta     * The .bss section gets initialised to 0 at runtime.
77*7c88f3f6SAchin Gupta     * Its base address must be 16-byte aligned.
78*7c88f3f6SAchin Gupta     */
79*7c88f3f6SAchin Gupta    .bss : ALIGN(16) {
80*7c88f3f6SAchin Gupta        __BSS_START__ = .;
81*7c88f3f6SAchin Gupta        *(SORT_BY_ALIGNMENT(.bss))
82*7c88f3f6SAchin Gupta        *(COMMON)
83*7c88f3f6SAchin Gupta        __BSS_END__ = .;
84*7c88f3f6SAchin Gupta    } >RAM
85*7c88f3f6SAchin Gupta
86*7c88f3f6SAchin Gupta    /*
87*7c88f3f6SAchin Gupta     * The xlat_table section is for full, aligned page tables (4K).
88*7c88f3f6SAchin Gupta     * Removing them from .bss avoids forcing 4K alignment on
89*7c88f3f6SAchin Gupta     * the .bss section and eliminates the unecessary zero init
90*7c88f3f6SAchin Gupta     */
91*7c88f3f6SAchin Gupta    xlat_table (NOLOAD) : {
92*7c88f3f6SAchin Gupta        *(xlat_table)
93*7c88f3f6SAchin Gupta    } >RAM
94*7c88f3f6SAchin Gupta
95*7c88f3f6SAchin Gupta    /*
96*7c88f3f6SAchin Gupta     * The base address of the coherent memory section must be page-aligned (4K)
97*7c88f3f6SAchin Gupta     * to guarantee that the coherent data are stored on their own pages and
98*7c88f3f6SAchin Gupta     * are not mixed with normal data.  This is required to set up the correct
99*7c88f3f6SAchin Gupta     * memory attributes for the coherent data page tables.
100*7c88f3f6SAchin Gupta     */
101*7c88f3f6SAchin Gupta    coherent_ram (NOLOAD) : ALIGN(4096) {
102*7c88f3f6SAchin Gupta        __COHERENT_RAM_START__ = .;
103*7c88f3f6SAchin Gupta        *(tzfw_coherent_mem)
104*7c88f3f6SAchin Gupta        __COHERENT_RAM_END_UNALIGNED__ = .;
105*7c88f3f6SAchin Gupta        /*
106*7c88f3f6SAchin Gupta         * Memory page(s) mapped to this section will be marked
107*7c88f3f6SAchin Gupta         * as device memory.  No other unexpected data must creep in.
108*7c88f3f6SAchin Gupta         * Ensure the rest of the current memory page is unused.
109*7c88f3f6SAchin Gupta         */
110*7c88f3f6SAchin Gupta        . = NEXT(4096);
111*7c88f3f6SAchin Gupta        __COHERENT_RAM_END__ = .;
112*7c88f3f6SAchin Gupta    } >RAM
113*7c88f3f6SAchin Gupta
114*7c88f3f6SAchin Gupta    __BL2_END__ = .;
115*7c88f3f6SAchin Gupta
116*7c88f3f6SAchin Gupta    __BSS_SIZE__ = SIZEOF(.bss);
117*7c88f3f6SAchin Gupta    __COHERENT_RAM_UNALIGNED_SIZE__ =
118*7c88f3f6SAchin Gupta        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
119*7c88f3f6SAchin Gupta
120*7c88f3f6SAchin Gupta    ASSERT(. <= TZDRAM_BASE + (1 << 21), "BL32 image does not fit in the first 2MB of Trusted DRAM.")
121*7c88f3f6SAchin Gupta}
122