MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / fuzzware_init

Method fuzzware_init

icicle-cortexm/src/lib.rs:71–364  ·  view source on GitHub ↗
(
        &mut self,
        config: &config::FirmwareConfig,
        vm: &mut icicle_vm::Vm,
        mmio_handler: I,
    )

Source from the content-addressed store, hash-verified

69
70impl<I: IoMemory + 'static> CortexmTarget<FuzzwareMmioHandler<I>> {
71 pub fn fuzzware_init(
72 &mut self,
73 config: &config::FirmwareConfig,
74 vm: &mut icicle_vm::Vm,
75 mmio_handler: I,
76 ) -> anyhow::Result<()> {
77 self.ctx = Some(UnsafeCell::new(Box::new(Context::new(vm)?)));
78 let uc_ptr = unsafe { self.ctx.as_mut().unwrap().get_mut().uc_ptr() };
79
80 let mut vtor = None;
81
82 let mmio_handler = vm.cpu.mem.register_io_handler(FuzzwareMmioHandler::new(
83 &config.mmio_models,
84 uc_ptr,
85 config.use_access_contexts,
86 mmio_handler,
87 ));
88
89 self.mmio_handler = Some(mmio_handler);
90
91 let nvic_enabled = config.use_systick || config.use_nvic;
92 let nvic_handler = vm.cpu.mem.register_io_handler(FuzzwareNvicHandler { uc: uc_ptr });
93
94 // Keeps track of best file to use for loading debug info from. Note: currently we only
95 // support loading debug info from a single ELF file.
96 let mut debug_info_path = None;
97
98 for (name, region) in &config.memory_map {
99 tracing::info!(
100 "mapping {name} at {:#x} (size: {:#x}) perms: {:?}",
101 region.base_addr,
102 region.size,
103 region.permissions
104 );
105
106 if name == "nvic" && nvic_enabled {
107 // Handle special case for NVIC region (note: if NVIC emulation is disabled then it
108 // will be treated as a regular region).
109 anyhow::ensure!(
110 vm.cpu.mem.map_memory_len(region.base_addr, region.size, nvic_handler),
111 "failed to map NVIC memory"
112 );
113 continue;
114 }
115 else if name.starts_with("mmio") {
116 // Handle special case for MMIO regions.
117 anyhow::ensure!(
118 vm.cpu.mem.map_memory_len(region.base_addr, region.size, mmio_handler),
119 "failed to map MMIO memory"
120 );
121 continue;
122 }
123
124 let mut size = region.size;
125
126 // Make memory allocations aligned to 4KB, if they don't overlap with any other region.
127 // This is required for compatibility with some config files from Fuzzware.
128 //

Callers 1

setup_vmFunction · 0.80

Calls 15

write_ihex_bytesFunction · 0.85
write_raw_bytesFunction · 0.85
find_elf_for_pathFunction · 0.85
nvic_block_hookFunction · 0.85
add_arm_extrasFunction · 0.85
map_uc_to_varnodesFunction · 0.85
timer_countdown_expiredFunction · 0.85
map_uc_errFunction · 0.85
get_symbolFunction · 0.85
add_interrupt_triggerFunction · 0.85
init_systickFunction · 0.85
init_nvicFunction · 0.85

Tested by

no test coverage detected