Skip to content

feat(non-unified-mem): introduce support for non unified memory platforms#218

Merged
josecm merged 6 commits into
mainfrom
feat/non-unified-mem
Sep 10, 2025
Merged

feat(non-unified-mem): introduce support for non unified memory platforms#218
josecm merged 6 commits into
mainfrom
feat/non-unified-mem

Conversation

@danielRep
Copy link
Copy Markdown
Member

@danielRep danielRep commented Jun 6, 2025

PR Description

This PR builds on top of PR #216 and adds support for platforms with non-unified memory architectures—i.e., platforms where code (e.g., flash) and data (e.g., SRAM) reside in separate memory regions. Previously, Bao only supported platforms with unified DRAM-based memory.
To support this architectural change, the following modifications were made:

  • Refactored Bao’s memory reservation logic to handle the distinction between code and data memory.
  • Removed the load_addr argument from function calls within mem.c, as it is now a constant global variable. Passing it explicitly no longer made sense in the context of non-unified memory platforms.
  • Added memory permissions classification to reflect platform's memory restrictions (e.g., flash is read-only)
  • Refactored the linkerscript to add the concept of VMA (Virtual Memory Address) and LMA (Load Memory Address)

Refactored LinkerScript

The following table details the difference between the memory layout of unified vs non-unified platforms. Unified platforms keep the same layout as expected while non-unified platforms split addresses between VMA and LMA addresses to cope with the typical separation of code and data memory architecture.

Unified Platforms

fvp-r-aarch32
Sections Address (bottom) Linker Symbols
(top) 0x0001fe40 _image_end; _dmem_beg
.bss 0x0001cec0 _image_noload_start; _vm_image_end
.vm_images 0x0000cec0 _image_load_end; _vm_image_start
.ipi_cpumsg_handlers_id ...
.ipi_cpumsg_handlers ...
.data 0x0000c880
.rodata 0x0000ba00
.text 0x00000300
.boot 0x00000000 _image_start
qemu-aarch64-virt
Sections Addresses (bottom) Linker Symbols
0xfd800002c000 _image_noload_start; _vm_image_end
0xfd8000020000 _image_end; _dmem_beg
.glb_page_tables 0xfd800001c000
.bss 0xfd8000013000
.vm_images 0xfd8000013000 _image_load_end; _vm_image_start
.ipi_cpumsg_handlers_id ...
.ipi_cpumsg_handlers ...
.data 0xfd8000012000
.rodata 0xfd8000010000
.text 0xfd8000000800
.boot 0xfd8000000000 _image_start

Non-Unified Platform

tricore tc49
Sections Addresses (bottom) Linker Symbols
0x90008e40 _image_end; _dmem_beg
.bss 0x900014c0 _image_noload_start; _bss_start
0x800172c0 _vm_image_end
.vm_images 0x800130c0 _image_load_end; _vm_image_start
.ipi_cpumsg_handlers_id ...
.ipi_cpumsg_handlers ...
.data 0x90000000 _data_vma_start
.data : AT(_data_lma_start) 0x80011c00 _data_lma_start
.rodata 0x80010f80
.text 0x80000300
.boot 0x80000000 _image_start

@danielRep danielRep marked this pull request as draft June 6, 2025 16:01
@danielRep danielRep force-pushed the feat/non-unified-mem branch 2 times, most recently from 3b7f781 to d467724 Compare June 9, 2025 10:17
@miguelafsilva5 miguelafsilva5 force-pushed the ref/vmpu branch 5 times, most recently from 063a1b2 to 2f167aa Compare June 11, 2025 14:52
@danielRep danielRep force-pushed the feat/non-unified-mem branch 2 times, most recently from dbed9aa to 3b8f45e Compare June 13, 2025 14:28
Comment thread src/core/mem.c Outdated
Comment thread src/core/mem.c Outdated
Comment thread src/core/cpu.c Outdated
Comment thread src/arch/armv8/aarch32/boot.S Outdated
Comment thread src/linker.ld Outdated
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 3b8f45e to d3eccd8 Compare June 13, 2025 18:09
@DavidMCerdeira
Copy link
Copy Markdown
Member

In the PR description, alongside the other modifications, I also suggest adding that it is now possible to setup memory permissions to reflect platform's memory restrictions (e.g., flash is read-only)

Comment thread scripts/platform_defs_gen.c Outdated
Comment thread src/linker.ld Outdated
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 4b776b1 to c0bc27a Compare July 25, 2025 15:13
@miguelafsilva5 miguelafsilva5 force-pushed the ref/vmpu branch 4 times, most recently from 7406f96 to cc47c6a Compare August 18, 2025 12:44
@miguelafsilva5 miguelafsilva5 self-requested a review as a code owner August 18, 2025 12:44
@miguelafsilva5 miguelafsilva5 force-pushed the ref/vmpu branch 2 times, most recently from b5d134b to c058b4e Compare August 18, 2025 15:19
@josecm
Copy link
Copy Markdown
Member

josecm commented Aug 18, 2025

@danielRep can we rebase this on ref/vmpu?

@miguelafsilva5 miguelafsilva5 force-pushed the ref/vmpu branch 2 times, most recently from 91ac275 to 8e8c6a1 Compare August 19, 2025 10:33
@danielRep danielRep force-pushed the feat/non-unified-mem branch from c0bc27a to 374e494 Compare August 19, 2025 13:58
@danielRep
Copy link
Copy Markdown
Member Author

@danielRep can we rebase this on ref/vmpu?

Done.

Comment thread src/core/inc/mem.h Outdated
Comment thread src/core/inc/mem.h Outdated
Comment thread src/linker.ld
Comment thread src/core/mem.c Outdated
Comment thread src/core/mem.c
Comment thread src/core/mem.c Outdated
Comment thread src/core/mem.c Outdated
Comment thread src/core/mem.c Outdated
Comment thread src/core/inc/bao.h Outdated
Comment thread scripts/platform_defs_gen.c
Comment thread src/core/inc/mem.h Outdated
Comment thread src/core/mem.c Outdated
Comment thread src/core/mem.c Outdated
@josecm
Copy link
Copy Markdown
Member

josecm commented Sep 10, 2025

@danielRep please rebase on main and clean up commit history before proceeding

Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
These variables must be initialized in the boot.S of each arch.
Both are global variables, therefore we removed the passing as
argument of the load address throughout the internal APIs of
Bao.

Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
@josecm
Copy link
Copy Markdown
Member

josecm commented Sep 10, 2025

@DavidMCerdeira @miguelafsilva5 please give another pass when possible

@miguelafsilva5
Copy link
Copy Markdown
Member

@DavidMCerdeira @miguelafsilva5 please give another pass when possible

@josecm I've given it another pass and rebased it to TC4. Everything is working and seems OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants