14f6ad66aSAchin Gupta/* 2e83b0cadSDan Handley * Copyright (c) 2013-2014, 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(bl31_entrypoint) 364f6ad66aSAchin Gupta 374f6ad66aSAchin Gupta 384f6ad66aSAchin GuptaMEMORY { 39d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE 404f6ad66aSAchin Gupta} 414f6ad66aSAchin Gupta 424f6ad66aSAchin Gupta 434f6ad66aSAchin GuptaSECTIONS 444f6ad66aSAchin Gupta{ 454f6ad66aSAchin Gupta . = BL31_BASE; 468d69a03fSSandrine Bailleux ASSERT(. == ALIGN(4096), 478d69a03fSSandrine Bailleux "BL31_BASE address is not aligned on a page boundary.") 484f6ad66aSAchin Gupta 498d69a03fSSandrine Bailleux ro . : { 508d69a03fSSandrine Bailleux __RO_START__ = .; 51dccc537aSAndrew Thoelke *bl31_entrypoint.o(.text*) 52dccc537aSAndrew Thoelke *(.text*) 538d69a03fSSandrine Bailleux *(.rodata*) 547421b465SAchin Gupta 55dccc537aSAndrew Thoelke /* Ensure 8-byte alignment for descriptors and ensure inclusion */ 567421b465SAchin Gupta . = ALIGN(8); 577421b465SAchin Gupta __RT_SVC_DESCS_START__ = .; 58dccc537aSAndrew Thoelke KEEP(*(rt_svc_descs)) 597421b465SAchin Gupta __RT_SVC_DESCS_END__ = .; 607421b465SAchin Gupta 619b476841SSoby Mathew /* 629b476841SSoby Mathew * Ensure 8-byte alignment for cpu_ops so that its fields are also 639b476841SSoby Mathew * aligned. Also ensure cpu_ops inclusion. 649b476841SSoby Mathew */ 659b476841SSoby Mathew . = ALIGN(8); 669b476841SSoby Mathew __CPU_OPS_START__ = .; 679b476841SSoby Mathew KEEP(*(cpu_ops)) 689b476841SSoby Mathew __CPU_OPS_END__ = .; 699b476841SSoby Mathew 70b739f22aSAchin Gupta *(.vectors) 718d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 728d69a03fSSandrine Bailleux /* 738d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as read-only, 748d69a03fSSandrine Bailleux * executable. No RW data from the next section must creep in. 758d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 768d69a03fSSandrine Bailleux */ 778d69a03fSSandrine Bailleux . = NEXT(4096); 788d69a03fSSandrine Bailleux __RO_END__ = .; 794f6ad66aSAchin Gupta } >RAM 804f6ad66aSAchin Gupta 819b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 829b476841SSoby Mathew "cpu_ops not defined for this platform.") 839b476841SSoby Mathew 848d69a03fSSandrine Bailleux .data . : { 858d69a03fSSandrine Bailleux __DATA_START__ = .; 86dccc537aSAndrew Thoelke *(.data*) 878d69a03fSSandrine Bailleux __DATA_END__ = .; 888d69a03fSSandrine Bailleux } >RAM 898d69a03fSSandrine Bailleux 90a1b6db6cSSandrine Bailleux#ifdef BL31_PROGBITS_LIMIT 91a1b6db6cSSandrine Bailleux ASSERT(. <= BL31_PROGBITS_LIMIT, "BL3-1 progbits has exceeded its limit.") 92a1b6db6cSSandrine Bailleux#endif 93a1b6db6cSSandrine Bailleux 948d69a03fSSandrine Bailleux stacks (NOLOAD) : { 958d69a03fSSandrine Bailleux __STACKS_START__ = .; 964f6ad66aSAchin Gupta *(tzfw_normal_stacks) 978d69a03fSSandrine Bailleux __STACKS_END__ = .; 984f6ad66aSAchin Gupta } >RAM 994f6ad66aSAchin Gupta 1008d69a03fSSandrine Bailleux /* 1018d69a03fSSandrine Bailleux * The .bss section gets initialised to 0 at runtime. 1028d69a03fSSandrine Bailleux * Its base address must be 16-byte aligned. 1038d69a03fSSandrine Bailleux */ 104*ee7b35c4SAndrew Thoelke .bss (NOLOAD) : ALIGN(16) { 1058d69a03fSSandrine Bailleux __BSS_START__ = .; 106dccc537aSAndrew Thoelke *(.bss*) 1074f6ad66aSAchin Gupta *(COMMON) 108*ee7b35c4SAndrew Thoelke#if !USE_COHERENT_MEM 109*ee7b35c4SAndrew Thoelke /* 110*ee7b35c4SAndrew Thoelke * Bakery locks are stored in normal .bss memory 111*ee7b35c4SAndrew Thoelke * 112*ee7b35c4SAndrew Thoelke * Each lock's data is spread across multiple cache lines, one per CPU, 113*ee7b35c4SAndrew Thoelke * but multiple locks can share the same cache line. 114*ee7b35c4SAndrew Thoelke * The compiler will allocate enough memory for one CPU's bakery locks, 115*ee7b35c4SAndrew Thoelke * the remaining cache lines are allocated by the linker script 116*ee7b35c4SAndrew Thoelke */ 117*ee7b35c4SAndrew Thoelke . = ALIGN(CACHE_WRITEBACK_GRANULE); 118*ee7b35c4SAndrew Thoelke __BAKERY_LOCK_START__ = .; 119*ee7b35c4SAndrew Thoelke *(bakery_lock) 120*ee7b35c4SAndrew Thoelke . = ALIGN(CACHE_WRITEBACK_GRANULE); 121*ee7b35c4SAndrew Thoelke __PERCPU_BAKERY_LOCK_SIZE__ = . - __BAKERY_LOCK_START__; 122*ee7b35c4SAndrew Thoelke . = . + (__PERCPU_BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1)); 123*ee7b35c4SAndrew Thoelke __BAKERY_LOCK_END__ = .; 124*ee7b35c4SAndrew Thoelke#ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE 125*ee7b35c4SAndrew Thoelke ASSERT(__PERCPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE, 126*ee7b35c4SAndrew Thoelke "PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements"); 127*ee7b35c4SAndrew Thoelke#endif 128*ee7b35c4SAndrew Thoelke#endif 1298d69a03fSSandrine Bailleux __BSS_END__ = .; 1304f6ad66aSAchin Gupta } >RAM 1314f6ad66aSAchin Gupta 1328d69a03fSSandrine Bailleux /* 133e3fff153SJeenu Viswambharan * The xlat_table section is for full, aligned page tables (4K). 134a0cd989dSAchin Gupta * Removing them from .bss avoids forcing 4K alignment on 135a0cd989dSAchin Gupta * the .bss section and eliminates the unecessary zero init 136a0cd989dSAchin Gupta */ 137a0cd989dSAchin Gupta xlat_table (NOLOAD) : { 138a0cd989dSAchin Gupta *(xlat_table) 139a0cd989dSAchin Gupta } >RAM 140a0cd989dSAchin Gupta 141ab8707e6SSoby Mathew#if USE_COHERENT_MEM 142a0cd989dSAchin Gupta /* 1438d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1448d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1458d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1468d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1478d69a03fSSandrine Bailleux */ 1488d69a03fSSandrine Bailleux coherent_ram (NOLOAD) : ALIGN(4096) { 1498d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 150*ee7b35c4SAndrew Thoelke /* 151*ee7b35c4SAndrew Thoelke * Bakery locks are stored in coherent memory 152*ee7b35c4SAndrew Thoelke * 153*ee7b35c4SAndrew Thoelke * Each lock's data is contiguous and fully allocated by the compiler 154*ee7b35c4SAndrew Thoelke */ 155*ee7b35c4SAndrew Thoelke *(bakery_lock) 1568d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1578d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1588d69a03fSSandrine Bailleux /* 1598d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1608d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1618d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1628d69a03fSSandrine Bailleux */ 1638d69a03fSSandrine Bailleux . = NEXT(4096); 1648d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1654f6ad66aSAchin Gupta } >RAM 166ab8707e6SSoby Mathew#endif 1674f6ad66aSAchin Gupta 1688d69a03fSSandrine Bailleux __BL31_END__ = .; 1694f6ad66aSAchin Gupta 1708d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 171ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1728d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1738d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 174ab8707e6SSoby Mathew#endif 1754f6ad66aSAchin Gupta 176a37255a2SSandrine Bailleux ASSERT(. <= BL31_LIMIT, "BL3-1 image has exceeded its limit.") 1774f6ad66aSAchin Gupta} 178