1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <sizes.h>
7
8ENTRY(rmm_entry)
9
10MEMORY {
11	RAM (rwx): ORIGIN = 0x0, LENGTH = RMM_MAX_SIZE
12}
13
14SECTIONS
15{
16	rmm_base = .;
17
18	.text . : {
19		rmm_text_start = .;
20		*head.S.obj(.text*)
21		. = ALIGN(8);
22		*(.text*)
23		. = ALIGN(GRANULE_SIZE);
24	} >RAM
25
26	rmm_text_end = .;
27
28	ASSERT(rmm_text_end == ALIGN(GRANULE_SIZE), "rmm_text_end is not page aligned")
29
30	.rodata ALIGN(GRANULE_SIZE) : {
31		rmm_ro_start = .;
32		*(.rodata*)
33		. = ALIGN(8);
34		rmm_got_start = .;
35		*(.got)
36		rmm_got_end = .;
37	} >RAM
38
39	/*
40	 * The xlat_static_table section is for full, aligned page tables.
41	 * The static tables must not change once the MMU is enabled, so
42	 * allocate them on the RO area to keep them protected from writing.
43	 *
44	 * The memory will be cleared by the xlat library during start up.
45	 */
46	xlat_table ALIGN(GRANULE_SIZE) : {
47		*(xlat_static_tables)
48	} >RAM
49
50	rmm_ro_end = .;
51
52	ASSERT(rmm_ro_end == ALIGN(GRANULE_SIZE), "rmm_ro_end is not page aligned")
53
54	/* Align rw data to the next 2MB block */
55	.data ALIGN(SZ_2M) : {
56		rmm_rw_start = .;
57		*(.data*)
58	} >RAM
59
60	/*
61	 * .rela.dyn needs to come after .data for the read-elf utility to
62	 * parse this section correctly.
63	 */
64	.rela.dyn ALIGN(8) : {
65		rmm_rela_start = .;
66		*(.rela*)
67		rmm_rela_end = .;
68	} >RAM
69
70	.percpu ALIGN(GRANULE_SIZE) (NOLOAD) : {
71		stack_start = .;
72		. = . + (RMM_NUM_PAGES_PER_STACK * GRANULE_SIZE * MAX_CPUS);
73		stack_end = .;
74	} >RAM
75
76	.bss ALIGN(16) (NOLOAD) : {
77		bss_start = .;
78		*(.bss*)
79		bss_end = .;
80	} >RAM
81
82	/*
83	 * The slot_buffer_xlat_tbl section is for full, aligned page tables.
84	 * The dynamic tables are used for transient memory areas that can
85	 * change at any time, so the tables must have RW access.
86	 *
87	 * The tables will be erased by the xlat library during start up.
88	 */
89	slot_buffer_xlat_tbl ALIGN(GRANULE_SIZE) (NOLOAD) : {
90		*(slot_buffer_xlat_tbls)
91	} >RAM
92
93	rmm_rw_end = .;
94	rmm_end = rmm_rw_end;
95
96	ASSERT(rmm_rw_end == ALIGN(GRANULE_SIZE), "rmm_rw_end is not page aligned")
97
98	/DISCARD/ : { *(.dynstr*) }
99	/DISCARD/ : { *(.dynsym*) }
100	/DISCARD/ : { *(.dynamic*) }
101	/DISCARD/ : { *(.hash*) }
102	/DISCARD/ : { *(.plt*) }
103	/DISCARD/ : { *(.interp*) }
104	/DISCARD/ : { *(.gnu*) }
105	/DISCARD/ : { *(.note*) }
106}
107