developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 2 | * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved. |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 7 | #include <common/bl_common.ld.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <lib/xlat_tables/xlat_tables_defs.h> |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 9 | |
| 10 | OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) |
| 11 | OUTPUT_ARCH(PLATFORM_LINKER_ARCH) |
| 12 | ENTRY(bl31_entrypoint) |
| 13 | |
| 14 | |
| 15 | MEMORY { |
| 16 | RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_TZRAM_SIZE |
| 17 | RAM2 (rwx): ORIGIN = TZRAM2_BASE, LENGTH = TZRAM2_SIZE |
| 18 | } |
| 19 | |
| 20 | |
| 21 | SECTIONS |
| 22 | { |
| 23 | . = BL31_BASE; |
| 24 | |
| 25 | ASSERT(. == ALIGN(2048), |
| 26 | "vector base is not aligned on a 2K boundary.") |
| 27 | |
| 28 | __RO_START__ = .; |
| 29 | vector . : { |
| 30 | *(.vectors) |
| 31 | } >RAM |
| 32 | |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 33 | ASSERT(. == ALIGN(PAGE_SIZE), |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 34 | "BL31_BASE address is not aligned on a page boundary.") |
| 35 | |
| 36 | ro . : { |
| 37 | *bl31_entrypoint.o(.text*) |
| 38 | *(.text*) |
| 39 | *(.rodata*) |
| 40 | |
Masahiro Yamada | 583f8dd | 2020-03-26 10:57:12 +0900 | [diff] [blame] | 41 | RODATA_COMMON |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 42 | |
| 43 | __RO_END_UNALIGNED__ = .; |
| 44 | /* |
| 45 | * Memory page(s) mapped to this section will be marked as read-only, |
| 46 | * executable. No RW data from the next section must creep in. |
| 47 | * Ensure the rest of the current memory page is unused. |
| 48 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 49 | . = ALIGN(PAGE_SIZE); |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 50 | __RO_END__ = .; |
| 51 | } >RAM |
| 52 | |
| 53 | ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, |
| 54 | "cpu_ops not defined for this platform.") |
| 55 | |
| 56 | /* |
| 57 | * Define a linker symbol to mark start of the RW memory area for this |
| 58 | * image. |
| 59 | */ |
| 60 | __RW_START__ = . ; |
| 61 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 62 | /* |
| 63 | * .data must be placed at a lower address than the stacks if the stack |
| 64 | * protector is enabled. Alternatively, the .data.stack_protector_canary |
| 65 | * section can be placed independently of the main .data section. |
| 66 | */ |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 67 | .data . : { |
| 68 | __DATA_START__ = .; |
| 69 | *(.data*) |
| 70 | __DATA_END__ = .; |
| 71 | } >RAM |
| 72 | |
| 73 | #ifdef BL31_PROGBITS_LIMIT |
| 74 | ASSERT(. <= BL31_PROGBITS_LIMIT, "BL3-1 progbits has exceeded its limit.") |
| 75 | #endif |
| 76 | |
| 77 | stacks (NOLOAD) : { |
| 78 | __STACKS_START__ = .; |
| 79 | *(tzfw_normal_stacks) |
| 80 | __STACKS_END__ = .; |
| 81 | } >RAM |
| 82 | |
Masahiro Yamada | dd053b6 | 2020-03-26 13:16:33 +0900 | [diff] [blame] | 83 | BSS_SECTION >RAM |
| 84 | __RW_END__ = __BSS_END__; |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 85 | |
| 86 | ASSERT(. <= BL31_LIMIT, "BL3-1 image has exceeded its limit.") |
| 87 | |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 88 | XLAT_TABLE_SECTION >RAM2 |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 89 | |
| 90 | #if USE_COHERENT_MEM |
| 91 | /* |
| 92 | * The base address of the coherent memory section must be page-aligned (4K) |
| 93 | * to guarantee that the coherent data are stored on their own pages and |
| 94 | * are not mixed with normal data. This is required to set up the correct |
| 95 | * memory attributes for the coherent data page tables. |
| 96 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 97 | coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 98 | __COHERENT_RAM_START__ = .; |
| 99 | /* |
| 100 | * Bakery locks are stored in coherent memory |
| 101 | * |
| 102 | * Each lock's data is contiguous and fully allocated by the compiler |
| 103 | */ |
| 104 | *(bakery_lock) |
| 105 | *(tzfw_coherent_mem) |
| 106 | __COHERENT_RAM_END_UNALIGNED__ = .; |
| 107 | /* |
| 108 | * Memory page(s) mapped to this section will be marked |
| 109 | * as device memory. No other unexpected data must creep in. |
| 110 | * Ensure the rest of the current memory page is unused. |
| 111 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 112 | . = ALIGN(PAGE_SIZE); |
developer | 550bf5e | 2016-07-11 16:05:23 +0800 | [diff] [blame] | 113 | __COHERENT_RAM_END__ = .; |
| 114 | } >RAM2 |
| 115 | #endif |
| 116 | |
| 117 | /* |
| 118 | * Define a linker symbol to mark end of the RW memory area for this |
| 119 | * image. |
| 120 | */ |
| 121 | __BL31_END__ = .; |
| 122 | |
| 123 | __BSS_SIZE__ = SIZEOF(.bss); |
| 124 | #if USE_COHERENT_MEM |
| 125 | __COHERENT_RAM_UNALIGNED_SIZE__ = |
| 126 | __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; |
| 127 | #endif |
| 128 | |
| 129 | ASSERT(. <= TZRAM2_LIMIT, "TZRAM2 image has exceeded its limit.") |
| 130 | } |