xref: /rk3399_ARM-atf/bl32/sp_min/sp_min.ld.S (revision 883d1b5d4a1a4da956310a951df9eb2056c84597)
1c11ba852SSoby Mathew/*
2*883d1b5dSAntonio 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)
31a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
32c11ba852SSoby Mathew        __TEXT_END__ = .;
33c11ba852SSoby Mathew    } >RAM
34c11ba852SSoby Mathew
35c11ba852SSoby Mathew    .rodata . : {
36c11ba852SSoby Mathew        __RODATA_START__ = .;
37c11ba852SSoby Mathew        *(.rodata*)
38c11ba852SSoby Mathew
39c11ba852SSoby Mathew        /* Ensure 4-byte alignment for descriptors and ensure inclusion */
40c11ba852SSoby Mathew        . = ALIGN(4);
41c11ba852SSoby Mathew        __RT_SVC_DESCS_START__ = .;
42c11ba852SSoby Mathew        KEEP(*(rt_svc_descs))
43c11ba852SSoby Mathew        __RT_SVC_DESCS_END__ = .;
44c11ba852SSoby Mathew
45c11ba852SSoby Mathew        /*
46c11ba852SSoby Mathew         * Ensure 4-byte alignment for cpu_ops so that its fields are also
47c11ba852SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
48c11ba852SSoby Mathew         */
49c11ba852SSoby Mathew        . = ALIGN(4);
50c11ba852SSoby Mathew        __CPU_OPS_START__ = .;
51c11ba852SSoby Mathew        KEEP(*(cpu_ops))
52c11ba852SSoby Mathew        __CPU_OPS_END__ = .;
53c11ba852SSoby Mathew
548e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
558e743bcdSJeenu Viswambharan        . = ALIGN(8);
568e743bcdSJeenu Viswambharan#include <pubsub_events.h>
578e743bcdSJeenu Viswambharan
58a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
59c11ba852SSoby Mathew        __RODATA_END__ = .;
60c11ba852SSoby Mathew    } >RAM
61c11ba852SSoby Mathew#else
62c11ba852SSoby Mathew    ro . : {
63c11ba852SSoby Mathew        __RO_START__ = .;
64c11ba852SSoby Mathew        *entrypoint.o(.text*)
65c11ba852SSoby Mathew        *(.text*)
66c11ba852SSoby Mathew        *(.rodata*)
67c11ba852SSoby Mathew
68c11ba852SSoby Mathew        /* Ensure 4-byte alignment for descriptors and ensure inclusion */
69c11ba852SSoby Mathew        . = ALIGN(4);
70c11ba852SSoby Mathew        __RT_SVC_DESCS_START__ = .;
71c11ba852SSoby Mathew        KEEP(*(rt_svc_descs))
72c11ba852SSoby Mathew        __RT_SVC_DESCS_END__ = .;
73c11ba852SSoby Mathew
74c11ba852SSoby Mathew        /*
75c11ba852SSoby Mathew         * Ensure 4-byte alignment for cpu_ops so that its fields are also
76c11ba852SSoby Mathew         * aligned. Also ensure cpu_ops inclusion.
77c11ba852SSoby Mathew         */
78c11ba852SSoby Mathew        . = ALIGN(4);
79c11ba852SSoby Mathew        __CPU_OPS_START__ = .;
80c11ba852SSoby Mathew        KEEP(*(cpu_ops))
81c11ba852SSoby Mathew        __CPU_OPS_END__ = .;
82c11ba852SSoby Mathew
838e743bcdSJeenu Viswambharan        /* Place pubsub sections for events */
848e743bcdSJeenu Viswambharan        . = ALIGN(8);
858e743bcdSJeenu Viswambharan#include <pubsub_events.h>
868e743bcdSJeenu Viswambharan
873bdf0e5dSYatharth Kochar        *(.vectors)
88c11ba852SSoby Mathew        __RO_END_UNALIGNED__ = .;
89c11ba852SSoby Mathew
90c11ba852SSoby Mathew        /*
91c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked as
92c11ba852SSoby Mathew         * read-only, executable.  No RW data from the next section must
93c11ba852SSoby Mathew         * creep in.  Ensure the rest of the current memory block is unused.
94c11ba852SSoby Mathew         */
95a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
96c11ba852SSoby Mathew        __RO_END__ = .;
97c11ba852SSoby Mathew    } >RAM
98c11ba852SSoby Mathew#endif
99c11ba852SSoby Mathew
100c11ba852SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
101c11ba852SSoby Mathew           "cpu_ops not defined for this platform.")
102c11ba852SSoby Mathew    /*
103c11ba852SSoby Mathew     * Define a linker symbol to mark start of the RW memory area for this
104c11ba852SSoby Mathew     * image.
105c11ba852SSoby Mathew     */
106c11ba852SSoby Mathew    __RW_START__ = . ;
107c11ba852SSoby Mathew
108c11ba852SSoby Mathew    .data . : {
109c11ba852SSoby Mathew        __DATA_START__ = .;
110c11ba852SSoby Mathew        *(.data*)
111c11ba852SSoby Mathew        __DATA_END__ = .;
112c11ba852SSoby Mathew    } >RAM
113c11ba852SSoby Mathew
1145744e874SSoby Mathew#ifdef BL32_PROGBITS_LIMIT
1155744e874SSoby Mathew    ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
1165744e874SSoby Mathew#endif
1175744e874SSoby Mathew
118c11ba852SSoby Mathew    stacks (NOLOAD) : {
119c11ba852SSoby Mathew        __STACKS_START__ = .;
120c11ba852SSoby Mathew        *(tzfw_normal_stacks)
121c11ba852SSoby Mathew        __STACKS_END__ = .;
122c11ba852SSoby Mathew    } >RAM
123c11ba852SSoby Mathew
124c11ba852SSoby Mathew    /*
125c11ba852SSoby Mathew     * The .bss section gets initialised to 0 at runtime.
126308d359bSDouglas Raillard     * Its base address should be 8-byte aligned for better performance of the
127308d359bSDouglas Raillard     * zero-initialization code.
128c11ba852SSoby Mathew     */
129308d359bSDouglas Raillard    .bss (NOLOAD) : ALIGN(8) {
130c11ba852SSoby Mathew        __BSS_START__ = .;
131c11ba852SSoby Mathew        *(.bss*)
132c11ba852SSoby Mathew        *(COMMON)
133c11ba852SSoby Mathew#if !USE_COHERENT_MEM
134c11ba852SSoby Mathew        /*
135c11ba852SSoby Mathew         * Bakery locks are stored in normal .bss memory
136c11ba852SSoby Mathew         *
137c11ba852SSoby Mathew         * Each lock's data is spread across multiple cache lines, one per CPU,
138c11ba852SSoby Mathew         * but multiple locks can share the same cache line.
139c11ba852SSoby Mathew         * The compiler will allocate enough memory for one CPU's bakery locks,
140c11ba852SSoby Mathew         * the remaining cache lines are allocated by the linker script
141c11ba852SSoby Mathew         */
142c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
143c11ba852SSoby Mathew        __BAKERY_LOCK_START__ = .;
144c11ba852SSoby Mathew        *(bakery_lock)
145c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
146c11ba852SSoby Mathew        __PERCPU_BAKERY_LOCK_SIZE__ = ABSOLUTE(. - __BAKERY_LOCK_START__);
147c11ba852SSoby Mathew        . = . + (__PERCPU_BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1));
148c11ba852SSoby Mathew        __BAKERY_LOCK_END__ = .;
149c11ba852SSoby Mathew#ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE
150c11ba852SSoby Mathew    ASSERT(__PERCPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE,
151c11ba852SSoby Mathew        "PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements");
152c11ba852SSoby Mathew#endif
153c11ba852SSoby Mathew#endif
154c11ba852SSoby Mathew
155c11ba852SSoby Mathew#if ENABLE_PMF
156c11ba852SSoby Mathew        /*
157c11ba852SSoby Mathew         * Time-stamps are stored in normal .bss memory
158c11ba852SSoby Mathew         *
159c11ba852SSoby Mathew         * The compiler will allocate enough memory for one CPU's time-stamps,
160c11ba852SSoby Mathew         * the remaining memory for other CPU's is allocated by the
161c11ba852SSoby Mathew         * linker script
162c11ba852SSoby Mathew         */
163c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
164c11ba852SSoby Mathew        __PMF_TIMESTAMP_START__ = .;
165c11ba852SSoby Mathew        KEEP(*(pmf_timestamp_array))
166c11ba852SSoby Mathew        . = ALIGN(CACHE_WRITEBACK_GRANULE);
167c11ba852SSoby Mathew        __PMF_PERCPU_TIMESTAMP_END__ = .;
168c11ba852SSoby Mathew        __PERCPU_TIMESTAMP_SIZE__ = ABSOLUTE(. - __PMF_TIMESTAMP_START__);
169c11ba852SSoby Mathew        . = . + (__PERCPU_TIMESTAMP_SIZE__ * (PLATFORM_CORE_COUNT - 1));
170c11ba852SSoby Mathew        __PMF_TIMESTAMP_END__ = .;
171c11ba852SSoby Mathew#endif /* ENABLE_PMF */
172c11ba852SSoby Mathew
173c11ba852SSoby Mathew        __BSS_END__ = .;
174c11ba852SSoby Mathew    } >RAM
175c11ba852SSoby Mathew
176c11ba852SSoby Mathew    /*
177c11ba852SSoby Mathew     * The xlat_table section is for full, aligned page tables (4K).
178c11ba852SSoby Mathew     * Removing them from .bss avoids forcing 4K alignment on
179*883d1b5dSAntonio Nino Diaz     * the .bss section. The tables are initialized to zero by the translation
180*883d1b5dSAntonio Nino Diaz     * tables library.
181c11ba852SSoby Mathew     */
182c11ba852SSoby Mathew    xlat_table (NOLOAD) : {
183c11ba852SSoby Mathew        *(xlat_table)
184c11ba852SSoby Mathew    } >RAM
185c11ba852SSoby Mathew
186c11ba852SSoby Mathew     __BSS_SIZE__ = SIZEOF(.bss);
187c11ba852SSoby Mathew
188c11ba852SSoby Mathew#if USE_COHERENT_MEM
189c11ba852SSoby Mathew    /*
190c11ba852SSoby Mathew     * The base address of the coherent memory section must be page-aligned (4K)
191c11ba852SSoby Mathew     * to guarantee that the coherent data are stored on their own pages and
192c11ba852SSoby Mathew     * are not mixed with normal data.  This is required to set up the correct
193c11ba852SSoby Mathew     * memory attributes for the coherent data page tables.
194c11ba852SSoby Mathew     */
195a2aedac2SAntonio Nino Diaz    coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
196c11ba852SSoby Mathew        __COHERENT_RAM_START__ = .;
197c11ba852SSoby Mathew        /*
198c11ba852SSoby Mathew         * Bakery locks are stored in coherent memory
199c11ba852SSoby Mathew         *
200c11ba852SSoby Mathew         * Each lock's data is contiguous and fully allocated by the compiler
201c11ba852SSoby Mathew         */
202c11ba852SSoby Mathew        *(bakery_lock)
203c11ba852SSoby Mathew        *(tzfw_coherent_mem)
204c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ = .;
205c11ba852SSoby Mathew        /*
206c11ba852SSoby Mathew         * Memory page(s) mapped to this section will be marked
207c11ba852SSoby Mathew         * as device memory.  No other unexpected data must creep in.
208c11ba852SSoby Mathew         * Ensure the rest of the current memory page is unused.
209c11ba852SSoby Mathew         */
210a2aedac2SAntonio Nino Diaz        . = NEXT(PAGE_SIZE);
211c11ba852SSoby Mathew        __COHERENT_RAM_END__ = .;
212c11ba852SSoby Mathew    } >RAM
213c11ba852SSoby Mathew
214c11ba852SSoby Mathew    __COHERENT_RAM_UNALIGNED_SIZE__ =
215c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
216c11ba852SSoby Mathew#endif
217c11ba852SSoby Mathew
218c11ba852SSoby Mathew    /*
219c11ba852SSoby Mathew     * Define a linker symbol to mark end of the RW memory area for this
220c11ba852SSoby Mathew     * image.
221c11ba852SSoby Mathew     */
222c11ba852SSoby Mathew    __RW_END__ = .;
223c11ba852SSoby Mathew
224c11ba852SSoby Mathew   __BL32_END__ = .;
225c11ba852SSoby Mathew}
226