xref: /rk3399_ARM-atf/bl32/sp_min/sp_min.ld.S (revision ad92509476ca9c0a675bd484b7dc48ce69cc37fb)
1c11ba852SSoby Mathew/*
2883d1b5dSAntonio Nino Diaz * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
3c11ba852SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5c11ba852SSoby Mathew */
6c11ba852SSoby Mathew
7c11ba852SSoby Mathew#include <platform_def.h>
8a2aedac2SAntonio Nino Diaz#include <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
18c11ba852SSoby Mathew
19c11ba852SSoby MathewSECTIONS
20c11ba852SSoby Mathew{
21c11ba852SSoby Mathew    . = BL32_BASE;
22a2aedac2SAntonio Nino Diaz   ASSERT(. == ALIGN(PAGE_SIZE),
23c11ba852SSoby Mathew          "BL32_BASE address is not aligned on a page boundary.")
24c11ba852SSoby Mathew
25c11ba852SSoby Mathew#if SEPARATE_CODE_AND_RODATA
26c11ba852SSoby Mathew    .text . : {
27c11ba852SSoby Mathew        __TEXT_START__ = .;
28c11ba852SSoby Mathew        *entrypoint.o(.text*)
29c11ba852SSoby Mathew        *(.text*)
303bdf0e5dSYatharth Kochar        *(.vectors)
315629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
32c11ba852SSoby Mathew        __TEXT_END__ = .;
33c11ba852SSoby Mathew    } >RAM
34c11ba852SSoby Mathew
35*ad925094SRoberto Vargas     /* .ARM.extab and .ARM.exidx are only added because Clang need them */
36*ad925094SRoberto Vargas     .ARM.extab . : {
37*ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
38*ad925094SRoberto Vargas     } >RAM
39*ad925094SRoberto Vargas
40*ad925094SRoberto Vargas     .ARM.exidx . : {
41*ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
42*ad925094SRoberto Vargas     } >RAM
43*ad925094SRoberto Vargas
44c11ba852SSoby Mathew    .rodata . : {
45c11ba852SSoby Mathew        __RODATA_START__ = .;
46c11ba852SSoby Mathew        *(.rodata*)
47c11ba852SSoby Mathew
48c11ba852SSoby Mathew        /* Ensure 4-byte alignment for descriptors and ensure inclusion */
49c11ba852SSoby Mathew        . = ALIGN(4);
50c11ba852SSoby Mathew        __RT_SVC_DESCS_START__ = .;
51c11ba852SSoby Mathew        KEEP(*(rt_svc_descs))
52c11ba852SSoby Mathew        __RT_SVC_DESCS_END__ = .;
53c11ba852SSoby Mathew
54c11ba852SSoby Mathew        /*
55c11ba852SSoby Mathew         * Ensure 4-byte alignment for cpu_ops so that its fields are also
56c11ba852SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
57c11ba852SSoby Mathew         */
58c11ba852SSoby Mathew        . = ALIGN(4);
59c11ba852SSoby Mathew        __CPU_OPS_START__ = .;
60c11ba852SSoby Mathew        KEEP(*(cpu_ops))
61c11ba852SSoby Mathew        __CPU_OPS_END__ = .;
62c11ba852SSoby Mathew
638e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
648e743bcdSJeenu Viswambharan        . = ALIGN(8);
658e743bcdSJeenu Viswambharan#include <pubsub_events.h>
668e743bcdSJeenu Viswambharan
675629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
68c11ba852SSoby Mathew        __RODATA_END__ = .;
69c11ba852SSoby Mathew    } >RAM
70c11ba852SSoby Mathew#else
71c11ba852SSoby Mathew    ro . : {
72c11ba852SSoby Mathew        __RO_START__ = .;
73c11ba852SSoby Mathew        *entrypoint.o(.text*)
74c11ba852SSoby Mathew        *(.text*)
75c11ba852SSoby Mathew        *(.rodata*)
76c11ba852SSoby Mathew
77c11ba852SSoby Mathew        /* Ensure 4-byte alignment for descriptors and ensure inclusion */
78c11ba852SSoby Mathew        . = ALIGN(4);
79c11ba852SSoby Mathew        __RT_SVC_DESCS_START__ = .;
80c11ba852SSoby Mathew        KEEP(*(rt_svc_descs))
81c11ba852SSoby Mathew        __RT_SVC_DESCS_END__ = .;
82c11ba852SSoby Mathew
83c11ba852SSoby Mathew        /*
84c11ba852SSoby Mathew         * Ensure 4-byte alignment for cpu_ops so that its fields are also
85c11ba852SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
86c11ba852SSoby Mathew         */
87c11ba852SSoby Mathew        . = ALIGN(4);
88c11ba852SSoby Mathew        __CPU_OPS_START__ = .;
89c11ba852SSoby Mathew        KEEP(*(cpu_ops))
90c11ba852SSoby Mathew        __CPU_OPS_END__ = .;
91c11ba852SSoby Mathew
928e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
938e743bcdSJeenu Viswambharan        . = ALIGN(8);
948e743bcdSJeenu Viswambharan#include <pubsub_events.h>
958e743bcdSJeenu Viswambharan
963bdf0e5dSYatharth Kochar        *(.vectors)
97c11ba852SSoby Mathew        __RO_END_UNALIGNED__ = .;
98c11ba852SSoby Mathew
99c11ba852SSoby Mathew        /*
100c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked as
101c11ba852SSoby Mathew         * read-only, executable.  No RW data from the next section must
102c11ba852SSoby Mathew         * creep in.  Ensure the rest of the current memory block is unused.
103c11ba852SSoby Mathew         */
1045629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
105c11ba852SSoby Mathew        __RO_END__ = .;
106c11ba852SSoby Mathew    } >RAM
107c11ba852SSoby Mathew#endif
108c11ba852SSoby Mathew
109c11ba852SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
110c11ba852SSoby Mathew           "cpu_ops not defined for this platform.")
111c11ba852SSoby Mathew    /*
112c11ba852SSoby Mathew     * Define a linker symbol to mark start of the RW memory area for this
113c11ba852SSoby Mathew     * image.
114c11ba852SSoby Mathew     */
115c11ba852SSoby Mathew    __RW_START__ = . ;
116c11ba852SSoby Mathew
117c11ba852SSoby Mathew    .data . : {
118c11ba852SSoby Mathew        __DATA_START__ = .;
119c11ba852SSoby Mathew        *(.data*)
120c11ba852SSoby Mathew        __DATA_END__ = .;
121c11ba852SSoby Mathew    } >RAM
122c11ba852SSoby Mathew
1235744e874SSoby Mathew#ifdef BL32_PROGBITS_LIMIT
1245744e874SSoby Mathew    ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
1255744e874SSoby Mathew#endif
1265744e874SSoby Mathew
127c11ba852SSoby Mathew    stacks (NOLOAD) : {
128c11ba852SSoby Mathew        __STACKS_START__ = .;
129c11ba852SSoby Mathew        *(tzfw_normal_stacks)
130c11ba852SSoby Mathew        __STACKS_END__ = .;
131c11ba852SSoby Mathew    } >RAM
132c11ba852SSoby Mathew
133c11ba852SSoby Mathew    /*
134c11ba852SSoby Mathew     * The .bss section gets initialised to 0 at runtime.
135308d359bSDouglas Raillard     * Its base address should be 8-byte aligned for better performance of the
136308d359bSDouglas Raillard     * zero-initialization code.
137c11ba852SSoby Mathew     */
138308d359bSDouglas Raillard    .bss (NOLOAD) : ALIGN(8) {
139c11ba852SSoby Mathew        __BSS_START__ = .;
140c11ba852SSoby Mathew        *(.bss*)
141c11ba852SSoby Mathew        *(COMMON)
142c11ba852SSoby Mathew#if !USE_COHERENT_MEM
143c11ba852SSoby Mathew        /*
144c11ba852SSoby Mathew         * Bakery locks are stored in normal .bss memory
145c11ba852SSoby Mathew         *
146c11ba852SSoby Mathew         * Each lock's data is spread across multiple cache lines, one per CPU,
147c11ba852SSoby Mathew         * but multiple locks can share the same cache line.
148c11ba852SSoby Mathew         * The compiler will allocate enough memory for one CPU's bakery locks,
149c11ba852SSoby Mathew         * the remaining cache lines are allocated by the linker script
150c11ba852SSoby Mathew         */
151c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
152c11ba852SSoby Mathew        __BAKERY_LOCK_START__ = .;
153c11ba852SSoby Mathew        *(bakery_lock)
154c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
155c11ba852SSoby Mathew        __PERCPU_BAKERY_LOCK_SIZE__ = ABSOLUTE(. - __BAKERY_LOCK_START__);
156c11ba852SSoby Mathew        . = . + (__PERCPU_BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1));
157c11ba852SSoby Mathew        __BAKERY_LOCK_END__ = .;
158c11ba852SSoby Mathew#ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE
159c11ba852SSoby Mathew    ASSERT(__PERCPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE,
160c11ba852SSoby Mathew        "PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements");
161c11ba852SSoby Mathew#endif
162c11ba852SSoby Mathew#endif
163c11ba852SSoby Mathew
164c11ba852SSoby Mathew#if ENABLE_PMF
165c11ba852SSoby Mathew        /*
166c11ba852SSoby Mathew         * Time-stamps are stored in normal .bss memory
167c11ba852SSoby Mathew         *
168c11ba852SSoby Mathew         * The compiler will allocate enough memory for one CPU's time-stamps,
169c11ba852SSoby Mathew         * the remaining memory for other CPU's is allocated by the
170c11ba852SSoby Mathew         * linker script
171c11ba852SSoby Mathew         */
172c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
173c11ba852SSoby Mathew        __PMF_TIMESTAMP_START__ = .;
174c11ba852SSoby Mathew        KEEP(*(pmf_timestamp_array))
175c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
176c11ba852SSoby Mathew        __PMF_PERCPU_TIMESTAMP_END__ = .;
177c11ba852SSoby Mathew        __PERCPU_TIMESTAMP_SIZE__ = ABSOLUTE(. - __PMF_TIMESTAMP_START__);
178c11ba852SSoby Mathew        . = . + (__PERCPU_TIMESTAMP_SIZE__ * (PLATFORM_CORE_COUNT - 1));
179c11ba852SSoby Mathew        __PMF_TIMESTAMP_END__ = .;
180c11ba852SSoby Mathew#endif /* ENABLE_PMF */
181c11ba852SSoby Mathew
182c11ba852SSoby Mathew        __BSS_END__ = .;
183c11ba852SSoby Mathew    } >RAM
184c11ba852SSoby Mathew
185c11ba852SSoby Mathew    /*
186c11ba852SSoby Mathew     * The xlat_table section is for full, aligned page tables (4K).
187c11ba852SSoby Mathew     * Removing them from .bss avoids forcing 4K alignment on
188883d1b5dSAntonio Nino Diaz     * the .bss section. The tables are initialized to zero by the translation
189883d1b5dSAntonio Nino Diaz     * tables library.
190c11ba852SSoby Mathew     */
191c11ba852SSoby Mathew    xlat_table (NOLOAD) : {
192c11ba852SSoby Mathew        *(xlat_table)
193c11ba852SSoby Mathew    } >RAM
194c11ba852SSoby Mathew
195c11ba852SSoby Mathew     __BSS_SIZE__ = SIZEOF(.bss);
196c11ba852SSoby Mathew
197c11ba852SSoby Mathew#if USE_COHERENT_MEM
198c11ba852SSoby Mathew    /*
199c11ba852SSoby Mathew     * The base address of the coherent memory section must be page-aligned (4K)
200c11ba852SSoby Mathew     * to guarantee that the coherent data are stored on their own pages and
201c11ba852SSoby Mathew     * are not mixed with normal data.  This is required to set up the correct
202c11ba852SSoby Mathew     * memory attributes for the coherent data page tables.
203c11ba852SSoby Mathew     */
204a2aedac2SAntonio Nino Diaz    coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
205c11ba852SSoby Mathew        __COHERENT_RAM_START__ = .;
206c11ba852SSoby Mathew        /*
207c11ba852SSoby Mathew         * Bakery locks are stored in coherent memory
208c11ba852SSoby Mathew         *
209c11ba852SSoby Mathew         * Each lock's data is contiguous and fully allocated by the compiler
210c11ba852SSoby Mathew         */
211c11ba852SSoby Mathew        *(bakery_lock)
212c11ba852SSoby Mathew        *(tzfw_coherent_mem)
213c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ = .;
214c11ba852SSoby Mathew        /*
215c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked
216c11ba852SSoby Mathew         * as device memory.  No other unexpected data must creep in.
217c11ba852SSoby Mathew         * Ensure the rest of the current memory page is unused.
218c11ba852SSoby Mathew         */
2195629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
220c11ba852SSoby Mathew        __COHERENT_RAM_END__ = .;
221c11ba852SSoby Mathew    } >RAM
222c11ba852SSoby Mathew
223c11ba852SSoby Mathew    __COHERENT_RAM_UNALIGNED_SIZE__ =
224c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
225c11ba852SSoby Mathew#endif
226c11ba852SSoby Mathew
227c11ba852SSoby Mathew    /*
228c11ba852SSoby Mathew     * Define a linker symbol to mark end of the RW memory area for this
229c11ba852SSoby Mathew     * image.
230c11ba852SSoby Mathew     */
231c11ba852SSoby Mathew    __RW_END__ = .;
232c11ba852SSoby Mathew
233c11ba852SSoby Mathew   __BL32_END__ = .;
234c11ba852SSoby Mathew}
235