Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More ergonomic API in esp-alloc for create HeapRegions #3051

Open
Dominaezzz opened this issue Jan 28, 2025 · 1 comment
Open

More ergonomic API in esp-alloc for create HeapRegions #3051

Dominaezzz opened this issue Jan 28, 2025 · 1 comment
Labels
help wanted Extra attention is needed package:esp-alloc Issues related to the esp-alloc package

Comments

@Dominaezzz
Copy link
Collaborator

Dominaezzz commented Jan 28, 2025

This code to create heap regions could be made much nicer. Ideally user should be able to write this with only 5 lines of code and an unsafe block.

static mut HEAP: core::mem::MaybeUninit<[u8; 72 * 1024]> = core::mem::MaybeUninit::uninit();
#[link_section = ".dram2_uninit"]
static mut HEAP2: core::mem::MaybeUninit<[u8; 64 * 1024]> = core::mem::MaybeUninit::uninit();
unsafe {
esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new(
HEAP.as_mut_ptr() as *mut u8,
core::mem::size_of_val(&*core::ptr::addr_of!(HEAP)),
esp_alloc::MemoryCapability::Internal.into(),
));
// COEX needs more RAM - add some more
esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new(
HEAP2.as_mut_ptr() as *mut u8,
core::mem::size_of_val(&*core::ptr::addr_of!(HEAP2)),
esp_alloc::MemoryCapability::Internal.into(),
));
}

I'm thinking something along the lines of esp_alloc::HeapRegion::from_internal(HEAP2).

@Dominaezzz Dominaezzz added the status:needs-attention This should be prioritized label Jan 28, 2025
@MabezDev
Copy link
Member

I think think forwarding attributes to the underlying memory region that the macro defines is the most flexible way to solve this.

@MabezDev MabezDev added help wanted Extra attention is needed package:esp-alloc Issues related to the esp-alloc package and removed status:needs-attention This should be prioritized labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed package:esp-alloc Issues related to the esp-alloc package
Projects
Status: Todo
Development

No branches or pull requests

2 participants