xref: /rk3399_ARM-atf/bl32/sp_min/sp_min.ld.S (revision 0a0a7a9ac82cb79af91f098cedc69cc67bca3978)
1c11ba852SSoby Mathew/*
2665e71b8SMasahiro Yamada * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
3c11ba852SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5c11ba852SSoby Mathew */
6c11ba852SSoby Mathew
7665e71b8SMasahiro Yamada#include <common/bl_common.ld.h>
809d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
9c11ba852SSoby Mathew
10c11ba852SSoby MathewOUTPUT_FORMAT(elf32-littlearm)
11c11ba852SSoby MathewOUTPUT_ARCH(arm)
12c11ba852SSoby MathewENTRY(sp_min_vector_table)
13c11ba852SSoby Mathew
14c11ba852SSoby MathewMEMORY {
15c11ba852SSoby Mathew    RAM (rwx): ORIGIN = BL32_BASE, LENGTH = BL32_LIMIT - BL32_BASE
16c11ba852SSoby Mathew}
17c11ba852SSoby Mathew
1814e09cc4SHeiko Stuebner#ifdef PLAT_SP_MIN_EXTRA_LD_SCRIPT
1914e09cc4SHeiko Stuebner#include <plat_sp_min.ld.S>
2014e09cc4SHeiko Stuebner#endif
21c11ba852SSoby Mathew
22c11ba852SSoby MathewSECTIONS
23c11ba852SSoby Mathew{
24c11ba852SSoby Mathew    . = BL32_BASE;
25a2aedac2SAntonio Nino Diaz   ASSERT(. == ALIGN(PAGE_SIZE),
26c11ba852SSoby Mathew          "BL32_BASE address is not aligned on a page boundary.")
27c11ba852SSoby Mathew
28c11ba852SSoby Mathew#if SEPARATE_CODE_AND_RODATA
29c11ba852SSoby Mathew    .text . : {
30c11ba852SSoby Mathew        __TEXT_START__ = .;
31c11ba852SSoby Mathew        *entrypoint.o(.text*)
32c11ba852SSoby Mathew        *(.text*)
333bdf0e5dSYatharth Kochar        *(.vectors)
345629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
35c11ba852SSoby Mathew        __TEXT_END__ = .;
36c11ba852SSoby Mathew    } >RAM
37c11ba852SSoby Mathew
38ad925094SRoberto Vargas     /* .ARM.extab and .ARM.exidx are only added because Clang need them */
39ad925094SRoberto Vargas     .ARM.extab . : {
40ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
41ad925094SRoberto Vargas     } >RAM
42ad925094SRoberto Vargas
43ad925094SRoberto Vargas     .ARM.exidx . : {
44ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
45ad925094SRoberto Vargas     } >RAM
46ad925094SRoberto Vargas
47c11ba852SSoby Mathew    .rodata . : {
48c11ba852SSoby Mathew        __RODATA_START__ = .;
49c11ba852SSoby Mathew        *(.rodata*)
50c11ba852SSoby Mathew
51*0a0a7a9aSMasahiro Yamada	RODATA_COMMON
52c11ba852SSoby Mathew
538e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
548e743bcdSJeenu Viswambharan        . = ALIGN(8);
5509d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/pubsub_events.h>
568e743bcdSJeenu Viswambharan
575629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
58c11ba852SSoby Mathew        __RODATA_END__ = .;
59c11ba852SSoby Mathew    } >RAM
60c11ba852SSoby Mathew#else
61c11ba852SSoby Mathew    ro . : {
62c11ba852SSoby Mathew        __RO_START__ = .;
63c11ba852SSoby Mathew        *entrypoint.o(.text*)
64c11ba852SSoby Mathew        *(.text*)
65c11ba852SSoby Mathew        *(.rodata*)
66c11ba852SSoby Mathew
67*0a0a7a9aSMasahiro Yamada	RODATA_COMMON
68c11ba852SSoby Mathew
698e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
708e743bcdSJeenu Viswambharan        . = ALIGN(8);
7109d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/pubsub_events.h>
728e743bcdSJeenu Viswambharan
733bdf0e5dSYatharth Kochar        *(.vectors)
74c11ba852SSoby Mathew        __RO_END_UNALIGNED__ = .;
75c11ba852SSoby Mathew
76c11ba852SSoby Mathew        /*
77c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked as
78c11ba852SSoby Mathew         * read-only, executable.  No RW data from the next section must
79c11ba852SSoby Mathew         * creep in.  Ensure the rest of the current memory block is unused.
80c11ba852SSoby Mathew         */
815629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
82c11ba852SSoby Mathew        __RO_END__ = .;
83c11ba852SSoby Mathew    } >RAM
84c11ba852SSoby Mathew#endif
85c11ba852SSoby Mathew
86c11ba852SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
87c11ba852SSoby Mathew           "cpu_ops not defined for this platform.")
88c11ba852SSoby Mathew    /*
89c11ba852SSoby Mathew     * Define a linker symbol to mark start of the RW memory area for this
90c11ba852SSoby Mathew     * image.
91c11ba852SSoby Mathew     */
92c11ba852SSoby Mathew    __RW_START__ = . ;
93c11ba852SSoby Mathew
94c11ba852SSoby Mathew    .data . : {
95c11ba852SSoby Mathew        __DATA_START__ = .;
96c11ba852SSoby Mathew        *(.data*)
97c11ba852SSoby Mathew        __DATA_END__ = .;
98c11ba852SSoby Mathew    } >RAM
99c11ba852SSoby Mathew
1005744e874SSoby Mathew#ifdef BL32_PROGBITS_LIMIT
1015744e874SSoby Mathew    ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
1025744e874SSoby Mathew#endif
1035744e874SSoby Mathew
104c11ba852SSoby Mathew    stacks (NOLOAD) : {
105c11ba852SSoby Mathew        __STACKS_START__ = .;
106c11ba852SSoby Mathew        *(tzfw_normal_stacks)
107c11ba852SSoby Mathew        __STACKS_END__ = .;
108c11ba852SSoby Mathew    } >RAM
109c11ba852SSoby Mathew
110c11ba852SSoby Mathew    /*
111c11ba852SSoby Mathew     * The .bss section gets initialised to 0 at runtime.
112308d359bSDouglas Raillard     * Its base address should be 8-byte aligned for better performance of the
113308d359bSDouglas Raillard     * zero-initialization code.
114c11ba852SSoby Mathew     */
115308d359bSDouglas Raillard    .bss (NOLOAD) : ALIGN(8) {
116c11ba852SSoby Mathew        __BSS_START__ = .;
117c11ba852SSoby Mathew        *(.bss*)
118c11ba852SSoby Mathew        *(COMMON)
1199fb288a0SMasahiro Yamada	BAKERY_LOCK_NORMAL
1209fb288a0SMasahiro Yamada	PMF_TIMESTAMP
121c11ba852SSoby Mathew        __BSS_END__ = .;
122c11ba852SSoby Mathew    } >RAM
123c11ba852SSoby Mathew
124665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
125c11ba852SSoby Mathew
126c11ba852SSoby Mathew     __BSS_SIZE__ = SIZEOF(.bss);
127c11ba852SSoby Mathew
128c11ba852SSoby Mathew#if USE_COHERENT_MEM
129c11ba852SSoby Mathew    /*
130c11ba852SSoby Mathew     * The base address of the coherent memory section must be page-aligned (4K)
131c11ba852SSoby Mathew     * to guarantee that the coherent data are stored on their own pages and
132c11ba852SSoby Mathew     * are not mixed with normal data.  This is required to set up the correct
133c11ba852SSoby Mathew     * memory attributes for the coherent data page tables.
134c11ba852SSoby Mathew     */
135a2aedac2SAntonio Nino Diaz    coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
136c11ba852SSoby Mathew        __COHERENT_RAM_START__ = .;
137c11ba852SSoby Mathew        /*
138c11ba852SSoby Mathew         * Bakery locks are stored in coherent memory
139c11ba852SSoby Mathew         *
140c11ba852SSoby Mathew         * Each lock's data is contiguous and fully allocated by the compiler
141c11ba852SSoby Mathew         */
142c11ba852SSoby Mathew        *(bakery_lock)
143c11ba852SSoby Mathew        *(tzfw_coherent_mem)
144c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ = .;
145c11ba852SSoby Mathew        /*
146c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked
147c11ba852SSoby Mathew         * as device memory.  No other unexpected data must creep in.
148c11ba852SSoby Mathew         * Ensure the rest of the current memory page is unused.
149c11ba852SSoby Mathew         */
1505629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
151c11ba852SSoby Mathew        __COHERENT_RAM_END__ = .;
152c11ba852SSoby Mathew    } >RAM
153c11ba852SSoby Mathew
154c11ba852SSoby Mathew    __COHERENT_RAM_UNALIGNED_SIZE__ =
155c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
156c11ba852SSoby Mathew#endif
157c11ba852SSoby Mathew
158c11ba852SSoby Mathew    /*
159c11ba852SSoby Mathew     * Define a linker symbol to mark end of the RW memory area for this
160c11ba852SSoby Mathew     * image.
161c11ba852SSoby Mathew     */
162c11ba852SSoby Mathew    __RW_END__ = .;
163c11ba852SSoby Mathew
164c11ba852SSoby Mathew   __BL32_END__ = .;
165c11ba852SSoby Mathew}
166