Struct ld_memory::MemorySection
source · pub struct MemorySection { /* private fields */ }
Implementations§
source§impl MemorySection
impl MemorySection
pub fn new(name: &str, origin: u64, length: u64) -> MemorySection
pub fn offset(self, offset: u64) -> MemorySection
pub fn pagesize(self, pagesize: u64) -> MemorySection
sourcepub fn slot(self, slot: usize, num_slots: usize) -> MemorySection
pub fn slot(self, slot: usize, num_slots: usize) -> MemorySection
Divide memory section into slots.
This can be used to divide a memory section into multiple slots of equal size, e.g., for an active / passive image scheme on MCUs.
slot
starts at zero for the first slot.
sourcepub fn from_env(self) -> MemorySection
pub fn from_env(self) -> MemorySection
Read options from environment
This will evaluate the following environment variables:
Variable | Default |
---|---|
LDMEMORY_OFFSET | 0 |
LDMEMORY_PAGESIZE | 1 |
LDMEMORY_NUM_SLOTS | 2 |
LDMEMORY_SLOT_OFFSET | 0 |
LDMEMORY_SLOT | None |
If an offset is given, the whole section will be offset and shortened
by the given value.
If a pagesize is given, the slots will start and end will be aligned at
the pagesize.
If a slot number is given, the remaining section will be divided into
<prefix>_NUM_SLOTS
slots, aligned to <prefix>_PAGESIZE
, and the
<prefix>_SLOT
th (starting at 0) will be returned.
If a slot offset is given, each slot will be offset and shortened by
that value.
Note: from_env_with_prefix
can be used to use a different prefix than
the default prefix LDMEMORY_
.
sourcepub fn from_env_with_prefix(self, prefix: &str) -> MemorySection
pub fn from_env_with_prefix(self, prefix: &str) -> MemorySection
Read slot options from environment with custom prefix
See from_env()
.