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

Method new

plugins/svd/src/mapper.rs:47–78  ·  view source on GitHub ↗
(settings: LoadSettings, address_size: usize, mut device: Device)

Source from the content-addressed store, hash-verified

45
46impl DeviceMapper {
47 pub fn new(settings: LoadSettings, address_size: usize, mut device: Device) -> Self {
48 svd_parser::expand_properties(&mut device);
49
50 // TODO: Until https://github.com/rust-embedded/svd/issues/288 is fixed
51 let mut new_device = device.clone();
52 new_device.peripherals.clear();
53 for peripheral in &device.peripherals {
54 let mut new_peripheral = peripheral.clone();
55 if let Some(derived_periph_name) = &peripheral.derived_from {
56 // Add derived address blocks.
57 // TODO: Should this not be done by svd_parser::expand?
58 // TODO: Should this be recursive?
59 if let Some(derived_peripheral) = device.get_peripheral(derived_periph_name) {
60 if let Some(address_blocks) = &derived_peripheral.address_block {
61 new_peripheral
62 .address_block
63 .get_or_insert_with(Vec::new)
64 .extend(address_blocks.to_owned());
65 }
66 }
67 }
68 new_device.peripherals.push(new_peripheral);
69 }
70
71 // TODO: Return error instead.
72 let expanded_device = svd_parser::expand(&new_device).expect("Failed to expand device!");
73 Self {
74 settings,
75 device: expanded_device,
76 address_size,
77 }
78 }
79
80 pub fn map_to_view(&self, view: &BinaryView) {
81 log::info!("Mapping device... {}", self.device.name);

Callers

nothing calls this directly

Calls 4

cloneMethod · 0.45
clearMethod · 0.45
to_ownedMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected