Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | */ |
| 5 | |
| 6 | #include <sizes.h> |
| 7 | |
Mate Toth-Pal | 7f5b27d | 2023-08-08 13:49:19 +0200 | [diff] [blame] | 8 | #if ((RMM_NUM_PAGES_PER_STACK == 0) || (GRANULE_SIZE == 0) || (MAX_CPUS== 0)) |
| 9 | #error "Required config options not set for the linker script." |
| 10 | #endif |
| 11 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 12 | ENTRY(rmm_entry) |
| 13 | |
| 14 | MEMORY { |
| 15 | RAM (rwx): ORIGIN = 0x0, LENGTH = RMM_MAX_SIZE |
| 16 | } |
| 17 | |
| 18 | SECTIONS |
| 19 | { |
| 20 | rmm_base = .; |
| 21 | |
| 22 | .text . : { |
| 23 | rmm_text_start = .; |
| 24 | *head.S.obj(.text*) |
| 25 | . = ALIGN(8); |
| 26 | *(.text*) |
| 27 | . = ALIGN(GRANULE_SIZE); |
| 28 | } >RAM |
| 29 | |
| 30 | rmm_text_end = .; |
| 31 | |
| 32 | ASSERT(rmm_text_end == ALIGN(GRANULE_SIZE), "rmm_text_end is not page aligned") |
| 33 | |
| 34 | .rodata ALIGN(GRANULE_SIZE) : { |
| 35 | rmm_ro_start = .; |
| 36 | *(.rodata*) |
| 37 | . = ALIGN(8); |
| 38 | rmm_got_start = .; |
| 39 | *(.got) |
| 40 | rmm_got_end = .; |
| 41 | } >RAM |
| 42 | |
| 43 | /* |
| 44 | * The xlat_static_table section is for full, aligned page tables. |
| 45 | * The static tables must not change once the MMU is enabled, so |
| 46 | * allocate them on the RO area to keep them protected from writing. |
| 47 | * |
| 48 | * The memory will be cleared by the xlat library during start up. |
| 49 | */ |
| 50 | xlat_table ALIGN(GRANULE_SIZE) : { |
| 51 | *(xlat_static_tables) |
| 52 | } >RAM |
| 53 | |
| 54 | rmm_ro_end = .; |
| 55 | |
| 56 | ASSERT(rmm_ro_end == ALIGN(GRANULE_SIZE), "rmm_ro_end is not page aligned") |
| 57 | |
| 58 | /* Align rw data to the next 2MB block */ |
| 59 | .data ALIGN(SZ_2M) : { |
| 60 | rmm_rw_start = .; |
| 61 | *(.data*) |
| 62 | } >RAM |
| 63 | |
| 64 | /* |
| 65 | * .rela.dyn needs to come after .data for the read-elf utility to |
| 66 | * parse this section correctly. |
| 67 | */ |
| 68 | .rela.dyn ALIGN(8) : { |
| 69 | rmm_rela_start = .; |
| 70 | *(.rela*) |
| 71 | rmm_rela_end = .; |
| 72 | } >RAM |
| 73 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 74 | .bss ALIGN(16) (NOLOAD) : { |
| 75 | bss_start = .; |
| 76 | *(.bss*) |
| 77 | bss_end = .; |
| 78 | } >RAM |
| 79 | |
Shanker Donthineni | ea0213a | 2025-01-12 09:28:12 -0600 | [diff] [blame^] | 80 | .granules_memory ALIGN(GRANULE_SIZE) (NOLOAD) : { |
| 81 | granules_memory_start = .; |
| 82 | *(granules_memory) |
| 83 | . = ALIGN(GRANULE_SIZE); |
| 84 | granules_memory_end = .; |
| 85 | } >RAM |
| 86 | |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame] | 87 | . = ALIGN(GRANULE_SIZE); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 88 | rmm_rw_end = .; |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 89 | |
| 90 | ASSERT(rmm_rw_end == ALIGN(GRANULE_SIZE), "rmm_rw_end is not page aligned") |
| 91 | |
Mate Toth-Pal | 7f5b27d | 2023-08-08 13:49:19 +0200 | [diff] [blame] | 92 | .stack ALIGN(GRANULE_SIZE) (NOLOAD) : { |
| 93 | rmm_stack_start = .; |
| 94 | . = . + (RMM_NUM_PAGES_PER_STACK * GRANULE_SIZE * MAX_CPUS); |
| 95 | rmm_stack_end = .; |
Mate Toth-Pal | c9f55e2 | 2023-08-14 09:45:45 +0200 | [diff] [blame] | 96 | rmm_eh_stack_start = .; |
| 97 | . = . + (GRANULE_SIZE * MAX_CPUS); |
| 98 | rmm_eh_stack_end = .; |
Mate Toth-Pal | 7f5b27d | 2023-08-08 13:49:19 +0200 | [diff] [blame] | 99 | } >RAM |
| 100 | |
| 101 | rmm_end = .; |
| 102 | |
| 103 | ASSERT(rmm_end == ALIGN(GRANULE_SIZE), "rmm_end is not page aligned") |
| 104 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 105 | /DISCARD/ : { *(.dynstr*) } |
| 106 | /DISCARD/ : { *(.dynsym*) } |
| 107 | /DISCARD/ : { *(.dynamic*) } |
| 108 | /DISCARD/ : { *(.hash*) } |
| 109 | /DISCARD/ : { *(.plt*) } |
| 110 | /DISCARD/ : { *(.interp*) } |
| 111 | /DISCARD/ : { *(.gnu*) } |
| 112 | /DISCARD/ : { *(.note*) } |
| 113 | } |