MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / peripheral_block_memory_info

Method peripheral_block_memory_info

plugins/svd/src/mapper.rs:291–344  ·  view source on GitHub ↗
(
        &self,
        peripheral: &PeripheralInfo,
        address_block: &AddressBlock,
        block_name: String,
    )

Source from the content-addressed store, hash-verified

289 }
290
291 pub fn peripheral_block_memory_info(
292 &self,
293 peripheral: &PeripheralInfo,
294 address_block: &AddressBlock,
295 block_name: String,
296 ) -> AddressBlockMemoryInfo {
297 let block_addr = peripheral.base_address + address_block.offset as u64;
298 let block_range = block_addr..(block_addr + address_block.size as u64);
299
300 let block_access = peripheral.default_register_properties.access;
301 let semantics = match block_access {
302 Some(Access::ReadOnly) => Semantics::ReadOnlyData,
303 Some(Access::ReadWrite | Access::ReadWriteOnce) => Semantics::ReadWriteData,
304 // NOTE: Binary Ninja has no concept of write-only section semantics.
305 Some(Access::WriteOnce | Access::WriteOnly) => Semantics::ReadWriteData,
306 // TODO: This should never happen. We use the expand feature of svd_parser
307 None => Semantics::ReadWriteData,
308 };
309
310 let (readable, writable) = match block_access {
311 Some(Access::ReadOnly) => (true, false),
312 Some(Access::ReadWrite | Access::ReadWriteOnce) => (true, true),
313 Some(Access::WriteOnce | Access::WriteOnly) => (false, true),
314 None => (true, true),
315 };
316
317 let section_type_str = match address_block.protection {
318 Some(protection) => {
319 // Section type: "peripheral:s"
320 format!("peripheral:{}", protection.as_str())
321 }
322 None => {
323 // Section type: "peripheral"
324 "peripheral".to_string()
325 }
326 };
327
328 let section = SectionBuilder::new(block_name, block_range.clone())
329 .section_type(section_type_str)
330 .semantics(semantics);
331 let segment_flags = SegmentFlags::new()
332 .contains_code(false)
333 .contains_data(true)
334 .deny_execute(true)
335 .readable(readable)
336 .writable(writable);
337 let segment = SegmentBuilder::new(block_range).flags(segment_flags);
338
339 AddressBlockMemoryInfo {
340 segment,
341 segment_flags,
342 section,
343 }
344 }
345
346 // TODO: In the future we might need to have partial types for each [`AddressBlock`]
347 // TODO: Support using header name, this requires we define the peripheral type id as the real peripheral name.

Callers 1

Calls 9

section_typeMethod · 0.80
deny_executeMethod · 0.80
contains_dataMethod · 0.80
contains_codeMethod · 0.80
semanticsMethod · 0.45
cloneMethod · 0.45
writableMethod · 0.45
readableMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected