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 /* SOF extended manifest */ 69 . = ALIGN(16); 70 _fw_metadata_start = .; 71 .fw_metadata : { 72 KEEP (*(.fw_metadata)) 73 . = ALIGN(16); 74 } > dram 75 _fw_metadata_end = .; 76 77#include <zephyr/linker/common-rom.ld> 78#include <snippets-rom-sections.ld> 79 80 __rodata_region_end = .; 81 82 . = ALIGN(4096); /* Switching MPU permissions, align by 4k */ 83 84 _image_ram_start = .; 85 86 .data : { 87 __data_start = .; 88 *(.data .data.*) 89 _trace_ctx_start = ABSOLUTE(.); 90 *(.trace_ctx) 91 _trace_ctx_end = ABSOLUTE(.); 92 __data_end = .; 93 } > dram 94 95#include <zephyr/linker/common-ram.ld> 96 97 .bss (NOLOAD) : 98 { 99 _bss_start = .; 100 *(.bss .bss.*) 101 *(.gnu.linkonce.b.*) 102 *(COMMON) 103 _bss_end = .; 104 } > dram 105 106#include <zephyr/linker/common-noinit.ld> 107#include <snippets-sections.ld> 108 109 . = ALIGN(4096); 110 _end = .; 111 _mtk_adsp_dram_end = .; 112 113 .nocache (NOLOAD) : { 114 . = ALIGN(4096); 115 *(.nocache .nocache.*) 116 } > dram 117 118 /* Non-runtime-loaded sections below */ 119 120#include <zephyr/linker/debug-sections.ld> 121 122 /DISCARD/ : { *(.note.GNU-stack) } 123 124 .xtensa.info 0 : { *(.xtensa.info) } 125 .xt.insn 0 : { 126 KEEP (*(.xt.insn)) 127 KEEP (*(.gnu.linkonce.x.*)) 128 } 129 .xt.prop 0 : { 130 KEEP (*(.xt.prop)) 131 KEEP (*(.xt.prop.*)) 132 KEEP (*(.gnu.linkonce.prop.*)) 133 } 134 .xt.lit 0 : { 135 KEEP (*(.xt.lit)) 136 KEEP (*(.xt.lit.*)) 137 KEEP (*(.gnu.linkonce.p.*)) 138 } 139 .xt.profile_range 0 : { 140 KEEP (*(.xt.profile_range)) 141 KEEP (*(.gnu.linkonce.profile_range.*)) 142 } 143 .xt.profile_ranges 0 : { 144 KEEP (*(.xt.profile_ranges)) 145 KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) 146 } 147 .xt.profile_files 0 : { 148 KEEP (*(.xt.profile_files)) 149 KEEP (*(.gnu.linkonce.xt.profile_files.*)) 150 } 151 152/* Boilerplate. The Xtensa arch uses CONFIG_GEN_ISR_TABLES to 153 * generate the handler table, but doesn't actually use the (x86 154 * specific) stuff that wants to go to a IDT_LIST memory area. We 155 * just dump it in an unreadable area at the top of memory. 156 */ 157#include <zephyr/linker/intlist.ld> 158 159#ifdef CONFIG_LLEXT 160#include <zephyr/linker/llext-sections.ld> 161#endif 162 163} /* SECTIONS */ 164