1/* Copyright 2024 The ChromiumOS Authors
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5#include <zephyr/linker/linker-defs.h>
6#include <zephyr/linker/linker-tool.h>
7
8#define SRAM_START DT_REG_ADDR(DT_NODELABEL(sram0))
9#define SRAM_SIZE  DT_REG_SIZE(DT_NODELABEL(sram0))
10#define DRAM_START DT_REG_ADDR(DT_NODELABEL(dram0))
11#define DRAM_SIZE  DT_REG_SIZE(DT_NODELABEL(dram0))
12
13MEMORY {
14  sram (rwx) : ORIGIN = SRAM_START, LENGTH = SRAM_SIZE
15  dram (rwx) : ORIGIN = DRAM_START, LENGTH = DRAM_SIZE
16
17  IDT_LIST (rwx) : ORIGIN = 0xfff00000, LENGTH = 0x00100000 /* see below */
18}
19
20/* Included files want this API defined */
21#define RAMABLE_REGION dram
22#define ROMABLE_REGION dram
23
24ENTRY(mtk_adsp_boot_entry)
25
26SECTIONS {
27
28  /* kluged-in entry point for Linux loader */
29  .sof_entry : {
30    KEEP(*(.sof_entry.text))
31  } > sram
32
33#include <xtensa_vectors.ld>
34  > sram
35
36  .iram : {
37    *(.iram0.*)
38    *(.literal.iram .iram.*)
39  } > sram
40
41  _mtk_adsp_sram_end = .;
42
43  .text : {
44    __text_region_start = .;
45    KEEP(*(.literal.init .init))
46    *(.literal.init.* .init.*)
47    *(.literal .text .literal.* .text.*)
48    *(.gnu.linkonce.literal.* .gnu.linkone.t.*)
49    *(.fini.literal .fini .fini.literal.* .fini.*)
50    __text_region_end = .;
51  } > dram
52
53  .rodata : {
54    __rodata_region_start = .;
55    *(.rodata)
56    *(.rodata.*)
57    *(.gnu.linkonce.r.*)
58    *(.rodata1)
59
60#include <snippets-rodata.ld>
61
62    *(.gnu.linkonce.e.*)
63    *(.gnu.version_r)
64    KEEP (*(.eh_frame))
65    *(.gnu.linkonce.h.*)
66  } > dram
67
68#include <zephyr/linker/common-rom.ld>
69#include <snippets-rom-sections.ld>
70
71  __rodata_region_end = .;
72
73    . = ALIGN(4096); /* Switching MPU permissions, align by 4k */
74
75  _image_ram_start = .;
76
77  .data : {
78    __data_start = .;
79    *(.data .data.*)
80    _trace_ctx_start = ABSOLUTE(.);
81    *(.trace_ctx)
82    _trace_ctx_end = ABSOLUTE(.);
83    __data_end = .;
84  } > dram
85
86#include <zephyr/linker/common-ram.ld>
87
88  .bss (NOLOAD) :
89  {
90    _bss_start = .;
91    *(.bss .bss.*)
92    *(.gnu.linkonce.b.*)
93    *(COMMON)
94    _bss_end = .;
95  } > dram
96
97#include <zephyr/linker/common-noinit.ld>
98#include <snippets-sections.ld>
99
100  . = ALIGN(4096);
101  _end = .;
102  _mtk_adsp_dram_end = .;
103
104  /* Non-runtime-loaded sections below */
105
106#include <zephyr/linker/debug-sections.ld>
107
108   /DISCARD/ : { *(.note.GNU-stack) }
109
110  .xtensa.info 0 : { *(.xtensa.info) }
111  .xt.insn 0 : {
112    KEEP (*(.xt.insn))
113    KEEP (*(.gnu.linkonce.x.*))
114  }
115  .xt.prop 0 : {
116    KEEP (*(.xt.prop))
117    KEEP (*(.xt.prop.*))
118    KEEP (*(.gnu.linkonce.prop.*))
119  }
120  .xt.lit 0 : {
121    KEEP (*(.xt.lit))
122    KEEP (*(.xt.lit.*))
123    KEEP (*(.gnu.linkonce.p.*))
124  }
125  .xt.profile_range 0 : {
126    KEEP (*(.xt.profile_range))
127    KEEP (*(.gnu.linkonce.profile_range.*))
128  }
129  .xt.profile_ranges 0 : {
130    KEEP (*(.xt.profile_ranges))
131    KEEP (*(.gnu.linkonce.xt.profile_ranges.*))
132  }
133  .xt.profile_files 0 : {
134    KEEP (*(.xt.profile_files))
135    KEEP (*(.gnu.linkonce.xt.profile_files.*))
136  }
137
138/* Boilerplate.  The Xtensa arch uses CONFIG_GEN_ISR_TABLES to
139 * generate the handler table, but doesn't actually use the (x86
140 * specific) stuff that wants to go to a IDT_LIST memory area.  We
141 * just dump it in an unreadable area at the top of memory.
142 */
143#include <zephyr/linker/intlist.ld>
144
145#ifdef CONFIG_LLEXT
146#include <zephyr/linker/llext-sections.ld>
147#endif
148
149} /* SECTIONS */
150