summaryrefslogtreecommitdiff
path: root/plugins/svd/src/mapper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/svd/src/mapper.rs')
-rw-r--r--plugins/svd/src/mapper.rs37
1 files changed, 21 insertions, 16 deletions
diff --git a/plugins/svd/src/mapper.rs b/plugins/svd/src/mapper.rs
index c0ca5e99..0a476481 100644
--- a/plugins/svd/src/mapper.rs
+++ b/plugins/svd/src/mapper.rs
@@ -163,24 +163,29 @@ impl DeviceMapper {
let memory_info =
self.peripheral_block_memory_info(peripheral, address_block, block_name.clone());
- // Add the block segment, section and backing memory.
- let data_memory = DataBuffer::new(&vec![0; address_block.size as usize]).unwrap();
- let added_memory = view.memory_map().add_data_memory_region(
- &block_name,
- block_addr,
- &data_memory,
- Some(memory_info.segment_flags),
- );
- view.add_segment(memory_info.segment);
- view.add_section(memory_info.section);
-
- if !added_memory {
- log::error!(
- "Failed to add memory for peripheral block! {} @ 0x{:x}",
- block_name,
- block_addr
+ // Add the block segment, section and backing memory (optional).
+ if self.settings.add_backing_regions {
+ // Because adding a memory region will add a possibly large memory buffer in the BNDB, this
+ // is optional. if a user disables this, they cannot write to the segment until they add a backing memory region.
+ let data_memory = DataBuffer::new(&vec![0; address_block.size as usize]).unwrap();
+ let added_memory = view.memory_map().add_data_memory_region(
+ &block_name,
+ block_addr,
+ &data_memory,
+ Some(memory_info.segment_flags),
);
+
+ if !added_memory {
+ log::error!(
+ "Failed to add memory for peripheral block! {} @ 0x{:x}",
+ block_name,
+ block_addr
+ );
+ }
}
+
+ view.add_segment(memory_info.segment);
+ view.add_section(memory_info.section);
// Handle usage specific stuff like adding registers.
match address_block.usage {