pub struct MemorySpec { /* private fields */ }Implementations§
Source§impl MemorySpec
impl MemorySpec
Sourcepub fn regions(&self) -> &HashMap<String, Regions>
pub fn regions(&self) -> &HashMap<String, Regions>
Examples found in repository?
examples/print_to_stdout.rs (line 14)
4fn main() {
5 let content = std::fs::read_to_string("examples/memory.kdl").unwrap();
6 let memoryspec = match MemorySpec::from_str(&content) {
7 Ok(m) => m,
8 Err(e) => {
9 eprintln!("{}", e);
10 return;
11 }
12 };
13
14 let primary_slot = &memoryspec.regions()["appcore_flash"]["primary_slot"];
15 let primary_slot_origin = primary_slot.origin();
16 let primary_slot_length = primary_slot.length();
17 let appcore_ram = &memoryspec.regions()["appcore_ram"]["low_ram"];
18 let appcore_ram_origin = appcore_ram.origin();
19 let appcore_ram_length = appcore_ram.length();
20 let symbols = memoryspec.render_symbols();
21 let consts = memoryspec.render_consts();
22
23 let output = println!(
24 "\
25memory.x:
26MEMORY
27{{
28 FLASH : ORIGIN = 0x{primary_slot_origin:08x}, LENGTH = 0x{primary_slot_length:04x}
29 RAM : ORIGIN = 0x{appcore_ram_origin:08x}, LENGTH = 0x{appcore_ram_length:04x}
30}}
31{symbols}
32
33
34consts.rs:
35{consts}"
36 );
37}Sourcepub fn render_symbols(&self) -> String
pub fn render_symbols(&self) -> String
Render out all symbols into a string that can be included in a linker script.
Examples found in repository?
examples/print_to_stdout.rs (line 20)
4fn main() {
5 let content = std::fs::read_to_string("examples/memory.kdl").unwrap();
6 let memoryspec = match MemorySpec::from_str(&content) {
7 Ok(m) => m,
8 Err(e) => {
9 eprintln!("{}", e);
10 return;
11 }
12 };
13
14 let primary_slot = &memoryspec.regions()["appcore_flash"]["primary_slot"];
15 let primary_slot_origin = primary_slot.origin();
16 let primary_slot_length = primary_slot.length();
17 let appcore_ram = &memoryspec.regions()["appcore_ram"]["low_ram"];
18 let appcore_ram_origin = appcore_ram.origin();
19 let appcore_ram_length = appcore_ram.length();
20 let symbols = memoryspec.render_symbols();
21 let consts = memoryspec.render_consts();
22
23 let output = println!(
24 "\
25memory.x:
26MEMORY
27{{
28 FLASH : ORIGIN = 0x{primary_slot_origin:08x}, LENGTH = 0x{primary_slot_length:04x}
29 RAM : ORIGIN = 0x{appcore_ram_origin:08x}, LENGTH = 0x{appcore_ram_length:04x}
30}}
31{symbols}
32
33
34consts.rs:
35{consts}"
36 );
37}Sourcepub fn render_consts(&self) -> String
pub fn render_consts(&self) -> String
Render out all consts into a string that can be included in a rust source file.
Examples found in repository?
examples/print_to_stdout.rs (line 21)
4fn main() {
5 let content = std::fs::read_to_string("examples/memory.kdl").unwrap();
6 let memoryspec = match MemorySpec::from_str(&content) {
7 Ok(m) => m,
8 Err(e) => {
9 eprintln!("{}", e);
10 return;
11 }
12 };
13
14 let primary_slot = &memoryspec.regions()["appcore_flash"]["primary_slot"];
15 let primary_slot_origin = primary_slot.origin();
16 let primary_slot_length = primary_slot.length();
17 let appcore_ram = &memoryspec.regions()["appcore_ram"]["low_ram"];
18 let appcore_ram_origin = appcore_ram.origin();
19 let appcore_ram_length = appcore_ram.length();
20 let symbols = memoryspec.render_symbols();
21 let consts = memoryspec.render_consts();
22
23 let output = println!(
24 "\
25memory.x:
26MEMORY
27{{
28 FLASH : ORIGIN = 0x{primary_slot_origin:08x}, LENGTH = 0x{primary_slot_length:04x}
29 RAM : ORIGIN = 0x{appcore_ram_origin:08x}, LENGTH = 0x{appcore_ram_length:04x}
30}}
31{symbols}
32
33
34consts.rs:
35{consts}"
36 );
37}Trait Implementations§
Source§impl Clone for MemorySpec
impl Clone for MemorySpec
Source§fn clone(&self) -> MemorySpec
fn clone(&self) -> MemorySpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemorySpec
impl Debug for MemorySpec
Source§impl Default for MemorySpec
impl Default for MemorySpec
Source§fn default() -> MemorySpec
fn default() -> MemorySpec
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemorySpec
impl RefUnwindSafe for MemorySpec
impl Send for MemorySpec
impl Sync for MemorySpec
impl Unpin for MemorySpec
impl UnwindSafe for MemorySpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more