1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use crate::target::Core; use std::collections::HashMap; pub mod m0; pub mod m33; pub mod m4; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CortexDump { pub regs: [u32; 16], stack_addr: u32, stack: Vec<u8>, } impl CortexDump { pub fn new(stack_addr: u32, stack: Vec<u8>) -> CortexDump { CortexDump { regs: [0u32; 16], stack_addr, stack, } } } pub fn get_core(name: impl AsRef<str>) -> Option<Box<dyn Core>> { let map: HashMap<&'static str, Box<dyn Core>> = hashmap! { "m0" => Box::new(self::m0::M0) as _, "m4" => Box::new(self::m4::M4) as _, "m33" => Box::new(self::m33::M33) as _, }; map.get(&name.as_ref().to_ascii_lowercase()[..]).cloned() }