Skip to content

Commit 1a41cbc

Browse files
VitekSTfabiobaltieri
authored andcommitted
soc: mimxrt798s/hifi4: Rework linker and memory defs
Rename symbols so that they reflect purpose of defined memory regions. Point region symbols to nodes in the DT. Move bogus IDT section before DSP's ITCM. Move common ROM and RAM sections before the heap. The move had to be done as these sections and the heap did overlap. Signed-off-by: Vit Stanicek <[email protected]>
1 parent 7635d98 commit 1a41cbc

File tree

2 files changed

+131
-147
lines changed

2 files changed

+131
-147
lines changed
Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
/*
2-
* Copyright 2024 NXP
2+
* Copyright (c) 2023 Google LLC.
3+
* Copyright 2024, 2025 NXP
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
67

78
#ifndef __XTENSA_MEMORY_H__
89
#define __XTENSA_MEMORY_H__
910

10-
#include <zephyr/autoconf.h>
11+
#include <zephyr/devicetree.h>
1112

12-
#define IRAM_RESERVE_HEADER_SPACE 0x400
13+
#define TEXT_BASE (DT_REG_ADDR(DT_NODELABEL(adsp_text)))
14+
#define TEXT_SIZE (DT_REG_SIZE(DT_NODELABEL(adsp_text)))
15+
#define DATA_BASE (DT_REG_ADDR(DT_NODELABEL(adsp_data)))
16+
#define DATA_SIZE (DT_REG_SIZE(DT_NODELABEL(adsp_data)))
17+
#define RESET_BASE (DT_REG_ADDR(DT_NODELABEL(adsp_reset)))
18+
#define RESET_SIZE (DT_REG_SIZE(DT_NODELABEL(adsp_reset)))
1319

14-
#define IRAM_BASE 0x24020000
15-
#define IRAM_SIZE 0x10000
20+
#if TEXT_BASE == 0 || TEXT_SIZE == 0
21+
#error "Text memory region is improperly defined - missing adsp_text in DT?"
22+
#endif
1623

17-
#define DRAM_BASE 0x24000000
18-
#define DRAM_SIZE 0x10000
24+
#if DATA_BASE == 0 || DATA_SIZE == 0
25+
#error "Data memory region is improperly defined - missing adsp_data in DT?"
26+
#endif
1927

20-
#define SDRAM0_BASE 0x20200000
21-
#define SDRAM0_SIZE 0xFFFFF
28+
#if RESET_BASE == 0 || RESET_SIZE == 0
29+
#error "Reset memory region is improperly defined - missing adsp_reset in DT?"
30+
#endif
2231

23-
/* The reset vector address in IRAM and its size. */
24-
#define XCHAL_RESET_VECTOR0_PADDR_IRAM IRAM_BASE
25-
#define MEM_RESET_TEXT_SIZE (0x2E0)
32+
/* The reset vector address in SRAM and its size. */
33+
#define XCHAL_RESET_VECTOR0_PADDR_IRAM (RESET_BASE)
34+
#define MEM_RESET_TEXT_SIZE (0x2e0)
2635
#define MEM_RESET_LIT_SIZE (0x120)
2736

2837
/* Base address of all interrupt vectors in IRAM. */
29-
#define XCHAL_VECBASE_RESET_PADDR_IRAM (IRAM_BASE + IRAM_RESERVE_HEADER_SPACE)
38+
#define XCHAL_VECBASE_RESET_PADDR_IRAM (TEXT_BASE)
3039
#define MEM_VECBASE_LIT_SIZE (0x178)
40+
3141
/* Vector and literal sizes. */
3242
#define MEM_VECT_LIT_SIZE (0x4)
3343
#define MEM_VECT_TEXT_SIZE (0x1C)
@@ -42,13 +52,13 @@
4252
#define XCHAL_USER_VECTOR_PADDR_IRAM (XCHAL_INT_VECTOR_ADDR(0x21C))
4353
#define XCHAL_DOUBLEEXC_VECTOR_PADDR_IRAM (XCHAL_INT_VECTOR_ADDR(0x23C))
4454

45-
/* Location for the intList section which is later used to construct the
55+
56+
/* Size and location of the intList section. Later used to construct the
4657
* Interrupt Descriptor Table (IDT). This is a bogus address as this
47-
* section will be stripped off in the final image.
58+
* section will be stripped off in the final image. Situated before the DSP's
59+
* ITCM - prevents memory region inflation in zephyr_pre0.elf.
4860
*/
49-
#define IDT_BASE (IRAM_BASE + IRAM_SIZE)
50-
51-
/* Size of the Interrupt Descriptor Table (IDT). */
5261
#define IDT_SIZE (0x2000)
62+
#define IDT_BASE (RESET_BASE - IDT_SIZE)
5363

5464
#endif

0 commit comments

Comments
 (0)