pub unsafe trait ExecutableMemory: Sync {
// Required methods
fn allocate(&self, layout: Layout) -> Result<NonNull<u8>, Error>;
unsafe fn finish_writes(
&self,
allocation: NonNull<u8>,
layout: Layout,
regions: &mut dyn Iterator<Item = Region>,
) -> Result<(), Error>;
unsafe fn free(&self, allocation: NonNull<u8>, layout: Layout);
// Provided method
fn execution_base(&self, allocation: NonNull<u8>) -> NonNull<u8> { ... }
}Expand description
Platform-specific executable RAM or PSRAM.
§Safety
Successful allocations supply an exclusive writable allocation of the given
layout. On unified-address platforms, the same virtual addresses are used
for data access and execution (Self::execution_base returns
allocation). On split-bus (Harvard) platforms where instruction fetch
uses a separate address alias of the same physical memory,
Self::execution_base returns that alias with at least the same
alignment and size as allocation, valid until Self::free.
Finalization must make written instructions visible to instruction fetch,
apply permissions supported by the platform and preserve region contents.
Memory must remain mapped until freed, including on finalization failure.
Required Methods§
fn allocate(&self, layout: Layout) -> Result<NonNull<u8>, Error>
Sourceunsafe fn finish_writes(
&self,
allocation: NonNull<u8>,
layout: Layout,
regions: &mut dyn Iterator<Item = Region>,
) -> Result<(), Error>
unsafe fn finish_writes( &self, allocation: NonNull<u8>, layout: Layout, regions: &mut dyn Iterator<Item = Region>, ) -> Result<(), Error>
Synchronize caches and apply final executable/data permissions. Return an error if the region layout cannot be supported.
§Safety
The allocation must have come from allocate with this layout. All
writes by the loader are complete and no references to the bytes remain.
Provided Methods§
Sourcefn execution_base(&self, allocation: NonNull<u8>) -> NonNull<u8>
fn execution_base(&self, allocation: NonNull<u8>) -> NonNull<u8>
Instruction-fetch base address aliasing allocation.
Unified-address platforms inherit the default, which returns
allocation. Split-bus platforms (such as ESP32-S2/S3 internal D/IRAM)
override this to return the instruction-bus alias of the same physical
bytes.