Skip to main content

MemorySection

Struct MemorySection 

Source
pub struct MemorySection { /* private fields */ }

Implementations§

Source§

impl MemorySection

Source

pub fn new(name: impl Into<String>, origin: u64, length: u64) -> MemorySection

Source

pub fn offset(self, offset: u64) -> MemorySection

Source

pub fn pagesize(self, pagesize: u64) -> MemorySection

Source

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.

Source

pub fn from_env(self) -> MemorySection

Read options from environment

This will evaluate the following environment variables:

VariableDefault
LDMEMORY_OFFSET0
LDMEMORY_PAGESIZE1
LDMEMORY_NUM_SLOTS2
LDMEMORY_SLOT_OFFSET0
LDMEMORY_SLOTNone

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>_SLOTth (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_.

Source

pub fn from_env_with_prefix(self, prefix: &str) -> MemorySection

Read slot options from environment with custom prefix

See from_env().

Source

pub fn attrs(self, attrs: &str) -> MemorySection

Source

pub fn to_ldmemory(&self) -> String

Source

pub fn start_symbol(&self) -> String

Creates a String with symbol for the start of the section

let section = MemorySection::new("FLASH", 0, 4096);
assert_eq!(section.start_symbol(), "_FLASH_start");
Source

pub fn length_symbol(&self) -> String

Creates a String with symbol for the length of the section

let section = MemorySection::new("FLASH", 0, 4096);
assert_eq!(section.length_symbol(), "_FLASH_length");
Source

pub fn ldmemory_start_symbol(&self) -> String

Creates the line for the linker script with the start of the symbol.

let section = MemorySection::new("FLASH", 0, 4096);
assert_eq!(section.ldmemory_start_symbol(), "_FLASH_start = 0x0;");
Source

pub fn ldmemory_length_symbol(&self) -> String

Creates the line for the linker script with the length of the symbol.

let section = MemorySection::new("FLASH", 0, 4096);
assert_eq!(section.ldmemory_length_symbol(), "_FLASH_length = 0x1000;");
Source

pub fn get_name(&self) -> &String

Get this section’s name.

Source

pub fn get_length(&self) -> u64

Get this section’s length.

Source

pub fn get_origin(&self) -> u64

Get this section’s origin.

Source

pub fn get_attrs(&self) -> Option<&String>

Get this section’s attributes.

Source

pub fn get_pagesize(&self) -> u64

Get this section’s pagesize.

Trait Implementations§

Source§

impl Debug for MemorySection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.