xref: /rk3399_ARM-atf/bl1/bl1.ld.S (revision 883d1b5d4a1a4da956310a951df9eb2056c84597)
14f6ad66aSAchin Gupta/*
2*883d1b5dSAntonio Nino Diaz * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
54f6ad66aSAchin Gupta */
64f6ad66aSAchin Gupta
75f0cdb05SDan Handley#include <platform_def.h>
8a2aedac2SAntonio Nino Diaz#include <xlat_tables_defs.h>
94f6ad66aSAchin Gupta
104f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
114f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
129f98aa1aSJeenu ViswambharanENTRY(bl1_entrypoint)
134f6ad66aSAchin Gupta
144f6ad66aSAchin GuptaMEMORY {
15d7fbf132SJuan Castillo    ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
16d7fbf132SJuan Castillo    RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
174f6ad66aSAchin Gupta}
184f6ad66aSAchin Gupta
194f6ad66aSAchin GuptaSECTIONS
204f6ad66aSAchin Gupta{
214f59d835SSandrine Bailleux    . = BL1_RO_BASE;
22a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
234f59d835SSandrine Bailleux           "BL1_RO_BASE address is not aligned on a page boundary.")
244f59d835SSandrine Bailleux
255d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
265d1c104fSSandrine Bailleux    .text . : {
275d1c104fSSandrine Bailleux        __TEXT_START__ = .;
285d1c104fSSandrine Bailleux        *bl1_entrypoint.o(.text*)
295d1c104fSSandrine Bailleux        *(.text*)
305d1c104fSSandrine Bailleux        *(.vectors)
31a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
325d1c104fSSandrine Bailleux        __TEXT_END__ = .;
335d1c104fSSandrine Bailleux     } >ROM
345d1c104fSSandrine Bailleux
355d1c104fSSandrine Bailleux    .rodata . : {
365d1c104fSSandrine Bailleux        __RODATA_START__ = .;
375d1c104fSSandrine Bailleux        *(.rodata*)
385d1c104fSSandrine Bailleux
395d1c104fSSandrine Bailleux        /* Ensure 8-byte alignment for descriptors and ensure inclusion */
405d1c104fSSandrine Bailleux        . = ALIGN(8);
415d1c104fSSandrine Bailleux        __PARSER_LIB_DESCS_START__ = .;
425d1c104fSSandrine Bailleux        KEEP(*(.img_parser_lib_descs))
435d1c104fSSandrine Bailleux        __PARSER_LIB_DESCS_END__ = .;
445d1c104fSSandrine Bailleux
455d1c104fSSandrine Bailleux        /*
465d1c104fSSandrine Bailleux         * Ensure 8-byte alignment for cpu_ops so that its fields are also
475d1c104fSSandrine Bailleux         * aligned. Also ensure cpu_ops inclusion.
485d1c104fSSandrine Bailleux         */
495d1c104fSSandrine Bailleux        . = ALIGN(8);
505d1c104fSSandrine Bailleux        __CPU_OPS_START__ = .;
515d1c104fSSandrine Bailleux        KEEP(*(cpu_ops))
525d1c104fSSandrine Bailleux        __CPU_OPS_END__ = .;
535d1c104fSSandrine Bailleux
545d1c104fSSandrine Bailleux        /*
555d1c104fSSandrine Bailleux         * No need to pad out the .rodata section to a page boundary. Next is
565d1c104fSSandrine Bailleux         * the .data section, which can mapped in ROM with the same memory
575d1c104fSSandrine Bailleux         * attributes as the .rodata section.
585d1c104fSSandrine Bailleux         */
595d1c104fSSandrine Bailleux        __RODATA_END__ = .;
605d1c104fSSandrine Bailleux    } >ROM
615d1c104fSSandrine Bailleux#else
624f59d835SSandrine Bailleux    ro . : {
638d69a03fSSandrine Bailleux        __RO_START__ = .;
64dccc537aSAndrew Thoelke        *bl1_entrypoint.o(.text*)
65dccc537aSAndrew Thoelke        *(.text*)
668d69a03fSSandrine Bailleux        *(.rodata*)
679b476841SSoby Mathew
6805799ae0SJuan Castillo        /* Ensure 8-byte alignment for descriptors and ensure inclusion */
6905799ae0SJuan Castillo        . = ALIGN(8);
7005799ae0SJuan Castillo        __PARSER_LIB_DESCS_START__ = .;
7105799ae0SJuan Castillo        KEEP(*(.img_parser_lib_descs))
7205799ae0SJuan Castillo        __PARSER_LIB_DESCS_END__ = .;
7305799ae0SJuan Castillo
749b476841SSoby Mathew        /*
759b476841SSoby Mathew         * Ensure 8-byte alignment for cpu_ops so that its fields are also
769b476841SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
779b476841SSoby Mathew         */
789b476841SSoby Mathew        . = ALIGN(8);
799b476841SSoby Mathew        __CPU_OPS_START__ = .;
809b476841SSoby Mathew        KEEP(*(cpu_ops))
819b476841SSoby Mathew        __CPU_OPS_END__ = .;
829b476841SSoby Mathew
83b739f22aSAchin Gupta        *(.vectors)
848d69a03fSSandrine Bailleux        __RO_END__ = .;
854f6ad66aSAchin Gupta    } >ROM
865d1c104fSSandrine Bailleux#endif
874f6ad66aSAchin Gupta
889b476841SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
899b476841SSoby Mathew           "cpu_ops not defined for this platform.")
909b476841SSoby Mathew
9151faada7SDouglas Raillard    . = BL1_RW_BASE;
92a2aedac2SAntonio Nino Diaz    ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
9351faada7SDouglas Raillard           "BL1_RW_BASE address is not aligned on a page boundary.")
9451faada7SDouglas Raillard
958d69a03fSSandrine Bailleux    /*
968d69a03fSSandrine Bailleux     * The .data section gets copied from ROM to RAM at runtime.
9751faada7SDouglas Raillard     * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes
9851faada7SDouglas Raillard     * aligned regions in it.
994f59d835SSandrine Bailleux     * Its VMA must be page-aligned as it marks the first read/write page.
10051faada7SDouglas Raillard     *
10151faada7SDouglas Raillard     * It must be placed at a lower address than the stacks if the stack
10251faada7SDouglas Raillard     * protector is enabled. Alternatively, the .data.stack_protector_canary
10351faada7SDouglas Raillard     * section can be placed independently of the main .data section.
1048d69a03fSSandrine Bailleux     */
1054f59d835SSandrine Bailleux    .data . : ALIGN(16) {
1064f6ad66aSAchin Gupta        __DATA_RAM_START__ = .;
107dccc537aSAndrew Thoelke        *(.data*)
1088d69a03fSSandrine Bailleux        __DATA_RAM_END__ = .;
1094f6ad66aSAchin Gupta    } >RAM AT>ROM
1104f6ad66aSAchin Gupta
1114f59d835SSandrine Bailleux    stacks . (NOLOAD) : {
1128d69a03fSSandrine Bailleux        __STACKS_START__ = .;
1134f6ad66aSAchin Gupta        *(tzfw_normal_stacks)
1148d69a03fSSandrine Bailleux        __STACKS_END__ = .;
1154f6ad66aSAchin Gupta    } >RAM
1164f6ad66aSAchin Gupta
1178d69a03fSSandrine Bailleux    /*
1188d69a03fSSandrine Bailleux     * The .bss section gets initialised to 0 at runtime.
119308d359bSDouglas Raillard     * Its base address should be 16-byte aligned for better performance of the
120308d359bSDouglas Raillard     * zero-initialization code.
1218d69a03fSSandrine Bailleux     */
1228d69a03fSSandrine Bailleux    .bss : ALIGN(16) {
1238d69a03fSSandrine Bailleux        __BSS_START__ = .;
124dccc537aSAndrew Thoelke        *(.bss*)
1258d69a03fSSandrine Bailleux        *(COMMON)
1268d69a03fSSandrine Bailleux        __BSS_END__ = .;
1278d69a03fSSandrine Bailleux    } >RAM
1284f6ad66aSAchin Gupta
1298d69a03fSSandrine Bailleux    /*
130a0cd989dSAchin Gupta     * The xlat_table section is for full, aligned page tables (4K).
13174cbb839SJeenu Viswambharan     * Removing them from .bss avoids forcing 4K alignment on
132*883d1b5dSAntonio Nino Diaz     * the .bss section. The tables are initialized to zero by the translation
133*883d1b5dSAntonio Nino Diaz     * tables library.
13474cbb839SJeenu Viswambharan     */
13574cbb839SJeenu Viswambharan    xlat_table (NOLOAD) : {
13674cbb839SJeenu Viswambharan        *(xlat_table)
13774cbb839SJeenu Viswambharan    } >RAM
13874cbb839SJeenu Viswambharan
139ab8707e6SSoby Mathew#if USE_COHERENT_MEM
14074cbb839SJeenu Viswambharan    /*
1418d69a03fSSandrine Bailleux     * The base address of the coherent memory section must be page-aligned (4K)
1428d69a03fSSandrine Bailleux     * to guarantee that the coherent data are stored on their own pages and
1438d69a03fSSandrine Bailleux     * are not mixed with normal data.  This is required to set up the correct
1448d69a03fSSandrine Bailleux     * memory attributes for the coherent data page tables.
1458d69a03fSSandrine Bailleux     */
146a2aedac2SAntonio Nino Diaz    coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
1478d69a03fSSandrine Bailleux        __COHERENT_RAM_START__ = .;
1488d69a03fSSandrine Bailleux        *(tzfw_coherent_mem)
1498d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ = .;
1508d69a03fSSandrine Bailleux        /*
1518d69a03fSSandrine Bailleux         * Memory page(s) mapped to this section will be marked
1528d69a03fSSandrine Bailleux         * as device memory.  No other unexpected data must creep in.
1538d69a03fSSandrine Bailleux         * Ensure the rest of the current memory page is unused.
1548d69a03fSSandrine Bailleux         */
155a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
1568d69a03fSSandrine Bailleux        __COHERENT_RAM_END__ = .;
1578d69a03fSSandrine Bailleux    } >RAM
158ab8707e6SSoby Mathew#endif
1594f6ad66aSAchin Gupta
1608d69a03fSSandrine Bailleux    __BL1_RAM_START__ = ADDR(.data);
1618d69a03fSSandrine Bailleux    __BL1_RAM_END__ = .;
1624f6ad66aSAchin Gupta
1638d69a03fSSandrine Bailleux    __DATA_ROM_START__ = LOADADDR(.data);
1648d69a03fSSandrine Bailleux    __DATA_SIZE__ = SIZEOF(.data);
165c02fcc4aSSandrine Bailleux
166a37255a2SSandrine Bailleux    /*
167a37255a2SSandrine Bailleux     * The .data section is the last PROGBITS section so its end marks the end
168c02fcc4aSSandrine Bailleux     * of BL1's actual content in Trusted ROM.
169a37255a2SSandrine Bailleux     */
170c02fcc4aSSandrine Bailleux    __BL1_ROM_END__ =  __DATA_ROM_START__ + __DATA_SIZE__;
171c02fcc4aSSandrine Bailleux    ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
172c02fcc4aSSandrine Bailleux           "BL1's ROM content has exceeded its limit.")
1738d69a03fSSandrine Bailleux
1748d69a03fSSandrine Bailleux    __BSS_SIZE__ = SIZEOF(.bss);
1758d69a03fSSandrine Bailleux
176ab8707e6SSoby Mathew#if USE_COHERENT_MEM
1778d69a03fSSandrine Bailleux    __COHERENT_RAM_UNALIGNED_SIZE__ =
1788d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
179ab8707e6SSoby Mathew#endif
1808d69a03fSSandrine Bailleux
181a37255a2SSandrine Bailleux    ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
1824f6ad66aSAchin Gupta}
183