Skip to content

Conversation

@danielRep
Copy link
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
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 3b8f45e to d3eccd8 Compare June 13, 2025 18:09
@DavidMCerdeira
Copy link
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)

Base automatically changed from ref/vmpu to main August 20, 2025 10:58
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 374e494 to 9ad59e5 Compare August 20, 2025 11:06
@josecm josecm self-assigned this Aug 21, 2025
@danielRep danielRep force-pushed the feat/non-unified-mem branch from 9ad59e5 to 474545c Compare September 1, 2025 15:56
@danielRep danielRep force-pushed the feat/non-unified-mem branch 6 times, most recently from 3d1e91a to 53e6ea9 Compare September 9, 2025 13:40
@josecm
Copy link
Member

josecm commented Sep 10, 2025

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

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 <[email protected]>
@josecm
Copy link
Member

josecm commented Sep 10, 2025

@DavidMCerdeira @miguelafsilva5 please give another pass when possible

@miguelafsilva5
Copy link
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

@josecm josecm merged commit cfe1677 into main Sep 10, 2025
31 checks passed
@josecm josecm deleted the feat/non-unified-mem branch September 10, 2025 13:32
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.

5 participants