xref: /rk3399_ARM-atf/bl1/bl1.ld.S (revision 5d1c104f9aa7e1f52607679db96e5695cac266e7)
14f6ad66aSAchin Gupta/*
2c02fcc4aSSandrine Bailleux * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta *
44f6ad66aSAchin Gupta * Redistribution and use in source and binary forms, with or without
54f6ad66aSAchin Gupta * modification, are permitted provided that the following conditions are met:
64f6ad66aSAchin Gupta *
74f6ad66aSAchin Gupta * Redistributions of source code must retain the above copyright notice, this
84f6ad66aSAchin Gupta * list of conditions and the following disclaimer.
94f6ad66aSAchin Gupta *
104f6ad66aSAchin Gupta * Redistributions in binary form must reproduce the above copyright notice,
114f6ad66aSAchin Gupta * this list of conditions and the following disclaimer in the documentation
124f6ad66aSAchin Gupta * and/or other materials provided with the distribution.
134f6ad66aSAchin Gupta *
144f6ad66aSAchin Gupta * Neither the name of ARM nor the names of its contributors may be used
154f6ad66aSAchin Gupta * to endorse or promote products derived from this software without specific
164f6ad66aSAchin Gupta * prior written permission.
174f6ad66aSAchin Gupta *
184f6ad66aSAchin Gupta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
194f6ad66aSAchin Gupta * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
204f6ad66aSAchin Gupta * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
214f6ad66aSAchin Gupta * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
224f6ad66aSAchin Gupta * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
234f6ad66aSAchin Gupta * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
244f6ad66aSAchin Gupta * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
254f6ad66aSAchin Gupta * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
264f6ad66aSAchin Gupta * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
274f6ad66aSAchin Gupta * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
284f6ad66aSAchin Gupta * POSSIBILITY OF SUCH DAMAGE.
294f6ad66aSAchin Gupta */
304f6ad66aSAchin Gupta
315f0cdb05SDan Handley#include <platform_def.h>
324f6ad66aSAchin Gupta
334f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
344f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
359f98aa1aSJeenu ViswambharanENTRY(bl1_entrypoint)
364f6ad66aSAchin Gupta
374f6ad66aSAchin GuptaMEMORY {
38d7fbf132SJuan Castillo    ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
39d7fbf132SJuan Castillo    RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
404f6ad66aSAchin Gupta}
414f6ad66aSAchin Gupta
424f6ad66aSAchin GuptaSECTIONS
434f6ad66aSAchin Gupta{
444f59d835SSandrine Bailleux    . = BL1_RO_BASE;
454f59d835SSandrine Bailleux    ASSERT(. == ALIGN(4096),
464f59d835SSandrine Bailleux           "BL1_RO_BASE address is not aligned on a page boundary.")
474f59d835SSandrine Bailleux
48*5d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
49*5d1c104fSSandrine Bailleux    .text . : {
50*5d1c104fSSandrine Bailleux        __TEXT_START__ = .;
51*5d1c104fSSandrine Bailleux        *bl1_entrypoint.o(.text*)
52*5d1c104fSSandrine Bailleux        *(.text*)
53*5d1c104fSSandrine Bailleux        *(.vectors)
54*5d1c104fSSandrine Bailleux        . = NEXT(4096);
55*5d1c104fSSandrine Bailleux        __TEXT_END__ = .;
56*5d1c104fSSandrine Bailleux     } >ROM
57*5d1c104fSSandrine Bailleux
58*5d1c104fSSandrine Bailleux    .rodata . : {
59*5d1c104fSSandrine Bailleux        __RODATA_START__ = .;
60*5d1c104fSSandrine Bailleux        *(.rodata*)
61*5d1c104fSSandrine Bailleux
62*5d1c104fSSandrine Bailleux        /* Ensure 8-byte alignment for descriptors and ensure inclusion */
63*5d1c104fSSandrine Bailleux        . = ALIGN(8);
64*5d1c104fSSandrine Bailleux        __PARSER_LIB_DESCS_START__ = .;
65*5d1c104fSSandrine Bailleux        KEEP(*(.img_parser_lib_descs))
66*5d1c104fSSandrine Bailleux        __PARSER_LIB_DESCS_END__ = .;
67*5d1c104fSSandrine Bailleux
68*5d1c104fSSandrine Bailleux        /*
69*5d1c104fSSandrine Bailleux         * Ensure 8-byte alignment for cpu_ops so that its fields are also
70*5d1c104fSSandrine Bailleux         * aligned. Also ensure cpu_ops inclusion.
71*5d1c104fSSandrine Bailleux         */
72*5d1c104fSSandrine Bailleux        . = ALIGN(8);
73*5d1c104fSSandrine Bailleux        __CPU_OPS_START__ = .;
74*5d1c104fSSandrine Bailleux        KEEP(*(cpu_ops))
75*5d1c104fSSandrine Bailleux        __CPU_OPS_END__ = .;
76*5d1c104fSSandrine Bailleux
77*5d1c104fSSandrine Bailleux        /*
78*5d1c104fSSandrine Bailleux         * No need to pad out the .rodata section to a page boundary. Next is
79*5d1c104fSSandrine Bailleux         * the .data section, which can mapped in ROM with the same memory
80*5d1c104fSSandrine Bailleux         * attributes as the .rodata section.
81*5d1c104fSSandrine Bailleux         */
82*5d1c104fSSandrine Bailleux        __RODATA_END__ = .;
83*5d1c104fSSandrine Bailleux    } >ROM
84*5d1c104fSSandrine Bailleux#else
854f59d835SSandrine Bailleux    ro . : {
868d69a03fSSandrine Bailleux        __RO_START__ = .;
87dccc537aSAndrew Thoelke        *bl1_entrypoint.o(.text*)
88dccc537aSAndrew Thoelke        *(.text*)
898d69a03fSSandrine Bailleux        *(.rodata*)
909b476841SSoby Mathew
9105799ae0SJuan Castillo        /* Ensure 8-byte alignment for descriptors and ensure inclusion */
9205799ae0SJuan Castillo        . = ALIGN(8);
9305799ae0SJuan Castillo        __PARSER_LIB_DESCS_START__ = .;
9405799ae0SJuan Castillo        KEEP(*(.img_parser_lib_descs))
9505799ae0SJuan Castillo        __PARSER_LIB_DESCS_END__ = .;
9605799ae0SJuan Castillo
979b476841SSoby Mathew        /*
989b476841SSoby Mathew         * Ensure 8-byte alignment for cpu_ops so that its fields are also
999b476841SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
1009b476841SSoby Mathew         */
1019b476841SSoby Mathew        . = ALIGN(8);
1029b476841SSoby Mathew        __CPU_OPS_START__ = .;
1039b476841SSoby Mathew        KEEP(*(cpu_ops))
1049b476841SSoby Mathew        __CPU_OPS_END__ = .;
1059b476841SSoby Mathew
106b739f22aSAchin Gupta        *(.vectors)
1078d69a03fSSandrine Bailleux        __RO_END__ = .;
1084f6ad66aSAchin Gupta    } >ROM
109*5d1c104fSSandrine Bailleux#endif
1104f6ad66aSAchin Gupta
1119b476841SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
1129b476841SSoby Mathew           "cpu_ops not defined for this platform.")
1139b476841SSoby Mathew
1148d69a03fSSandrine Bailleux    /*
1158d69a03fSSandrine Bailleux     * The .data section gets copied from ROM to RAM at runtime.
1164f59d835SSandrine Bailleux     * Its LMA must be 16-byte aligned.
1174f59d835SSandrine Bailleux     * Its VMA must be page-aligned as it marks the first read/write page.
1188d69a03fSSandrine Bailleux     */
1194f59d835SSandrine Bailleux    . = BL1_RW_BASE;
1204f59d835SSandrine Bailleux    ASSERT(. == ALIGN(4096),
1214f59d835SSandrine Bailleux           "BL1_RW_BASE address is not aligned on a page boundary.")
1224f59d835SSandrine Bailleux    .data . : ALIGN(16) {
1234f6ad66aSAchin Gupta        __DATA_RAM_START__ = .;
124dccc537aSAndrew Thoelke        *(.data*)
1258d69a03fSSandrine Bailleux        __DATA_RAM_END__ = .;
1264f6ad66aSAchin Gupta    } >RAM AT>ROM
1274f6ad66aSAchin Gupta
1284f59d835SSandrine Bailleux    stacks . (NOLOAD) : {
1298d69a03fSSandrine Bailleux        __STACKS_START__ = .;
1304f6ad66aSAchin Gupta        *(tzfw_normal_stacks)
1318d69a03fSSandrine Bailleux        __STACKS_END__ = .;
1324f6ad66aSAchin Gupta    } >RAM
1334f6ad66aSAchin Gupta
1348d69a03fSSandrine Bailleux    /*
1358d69a03fSSandrine Bailleux     * The .bss section gets initialised to 0 at runtime.
1368d69a03fSSandrine Bailleux     * Its base address must be 16-byte aligned.
1378d69a03fSSandrine Bailleux     */
1388d69a03fSSandrine Bailleux    .bss : ALIGN(16) {
1398d69a03fSSandrine Bailleux        __BSS_START__ = .;
140dccc537aSAndrew Thoelke        *(.bss*)
1418d69a03fSSandrine Bailleux        *(COMMON)
1428d69a03fSSandrine Bailleux        __BSS_END__ = .;
1438d69a03fSSandrine Bailleux    } >RAM
1444f6ad66aSAchin Gupta
1458d69a03fSSandrine Bailleux    /*
146a0cd989dSAchin Gupta     * The xlat_table section is for full, aligned page tables (4K).
14774cbb839SJeenu Viswambharan     * Removing them from .bss avoids forcing 4K alignment on
14874cbb839SJeenu Viswambharan     * the .bss section and eliminates the unecessary zero init
14974cbb839SJeenu Viswambharan     */
15074cbb839SJeenu Viswambharan    xlat_table (NOLOAD) : {
15174cbb839SJeenu Viswambharan        *(xlat_table)
15274cbb839SJeenu Viswambharan    } >RAM
15374cbb839SJeenu Viswambharan
154ab8707e6SSoby Mathew#if USE_COHERENT_MEM
15574cbb839SJeenu Viswambharan    /*
1568d69a03fSSandrine Bailleux     * The base address of the coherent memory section must be page-aligned (4K)
1578d69a03fSSandrine Bailleux     * to guarantee that the coherent data are stored on their own pages and
1588d69a03fSSandrine Bailleux     * are not mixed with normal data.  This is required to set up the correct
1598d69a03fSSandrine Bailleux     * memory attributes for the coherent data page tables.
1608d69a03fSSandrine Bailleux     */
1618d69a03fSSandrine Bailleux    coherent_ram (NOLOAD) : ALIGN(4096) {
1628d69a03fSSandrine Bailleux        __COHERENT_RAM_START__ = .;
1638d69a03fSSandrine Bailleux        *(tzfw_coherent_mem)
1648d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ = .;
1658d69a03fSSandrine Bailleux        /*
1668d69a03fSSandrine Bailleux         * Memory page(s) mapped to this section will be marked
1678d69a03fSSandrine Bailleux         * as device memory.  No other unexpected data must creep in.
1688d69a03fSSandrine Bailleux         * Ensure the rest of the current memory page is unused.
1698d69a03fSSandrine Bailleux         */
1708d69a03fSSandrine Bailleux        . = NEXT(4096);
1718d69a03fSSandrine Bailleux        __COHERENT_RAM_END__ = .;
1728d69a03fSSandrine Bailleux    } >RAM
173ab8707e6SSoby Mathew#endif
1744f6ad66aSAchin Gupta
1758d69a03fSSandrine Bailleux    __BL1_RAM_START__ = ADDR(.data);
1768d69a03fSSandrine Bailleux    __BL1_RAM_END__ = .;
1774f6ad66aSAchin Gupta
1788d69a03fSSandrine Bailleux    __DATA_ROM_START__ = LOADADDR(.data);
1798d69a03fSSandrine Bailleux    __DATA_SIZE__ = SIZEOF(.data);
180c02fcc4aSSandrine Bailleux
181a37255a2SSandrine Bailleux    /*
182a37255a2SSandrine Bailleux     * The .data section is the last PROGBITS section so its end marks the end
183c02fcc4aSSandrine Bailleux     * of BL1's actual content in Trusted ROM.
184a37255a2SSandrine Bailleux     */
185c02fcc4aSSandrine Bailleux    __BL1_ROM_END__ =  __DATA_ROM_START__ + __DATA_SIZE__;
186c02fcc4aSSandrine Bailleux    ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
187c02fcc4aSSandrine Bailleux           "BL1's ROM content has exceeded its limit.")
1888d69a03fSSandrine Bailleux
1898d69a03fSSandrine Bailleux    __BSS_SIZE__ = SIZEOF(.bss);
1908d69a03fSSandrine Bailleux
191ab8707e6SSoby Mathew#if USE_COHERENT_MEM
1928d69a03fSSandrine Bailleux    __COHERENT_RAM_UNALIGNED_SIZE__ =
1938d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
194ab8707e6SSoby Mathew#endif
1958d69a03fSSandrine Bailleux
196a37255a2SSandrine Bailleux    ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
1974f6ad66aSAchin Gupta}
198