diff --git a/tool/microkit/src/sdf.rs b/tool/microkit/src/sdf.rs index e254a2e2d..e4059252d 100644 --- a/tool/microkit/src/sdf.rs +++ b/tool/microkit/src/sdf.rs @@ -336,6 +336,15 @@ impl SysMapPerms { } impl SysMap { + pub fn new(mr: String, vaddr: u64, perms: u8, cached: bool) -> Result { + Ok(SysMap { + mr, + vaddr, + perms, + cached, + text_pos: None, + }) + } fn from_xml( xml_sdf: &XmlSystemDescription, node: &roxmltree::Node, @@ -439,6 +448,52 @@ impl ProtectionDomain { ioports } + pub fn new( + id: Option, + name: String, + priority: u8, + budget: u64, + period: u64, + passive: bool, + stack_size: u64, + smc: bool, + cpu: CpuCore, + program_image: PathBuf, + maps: Vec, + irqs: Vec, + ioports: Vec, + setvars: Vec, + virtual_machine: Option, + child_pds: Vec, + has_children: bool, + setvar_id: Option, + ) -> Result { + Ok(ProtectionDomain { + id, + name, + // This downcast is safe as we have checked that this is less than + // the maximum PD priority, which fits in a u8. + priority, + budget, + period, + passive, + stack_size, + smc, + cpu, + program_image, + maps, + irqs, + ioports, + setvars, + child_pds, + virtual_machine, + has_children, + parent: None, + setvar_id, + text_pos: None, + }) + } + fn from_xml( config: &Config, xml_sdf: &XmlSystemDescription, @@ -1078,6 +1133,23 @@ impl ProtectionDomain { } impl VirtualMachine { + pub fn new( + vcpus: Vec, + name: String, + maps: Vec, + priority: u8, + budget: u64, + period: u64, + ) -> Result { + Ok(VirtualMachine { + vcpus, + name, + maps, + priority, + budget, + period, + }) + } fn from_xml( config: &Config, xml_sdf: &XmlSystemDescription, @@ -1204,6 +1276,26 @@ impl VirtualMachine { } impl SysMemoryRegion { + pub fn new( + name: String, + size: u64, + page_size: PageSize, + page_size_specified_by_user: bool, + phys_addr: SysMemoryRegionPaddr, + kind: SysMemoryRegionKind, + ) -> Result { + Ok(SysMemoryRegion { + name, + size, + page_size, + page_size_specified_by_user, + page_count, + phys_addr, + text_pos: None, + kind, + }) + } + fn from_xml( config: &Config, xml_sdf: &XmlSystemDescription, @@ -1272,6 +1364,22 @@ impl SysMemoryRegion { } impl ChannelEnd { + pub fn new( + pd_idx: usize, + id: u64, + notify: bool, + pp: bool, + setvar_id: Option, + ) -> Result { + Ok(ChannelEnd { + pd: pd_idx, + id: id, + notify, + pp, + setvar_id, + }) + } + fn from_xml<'a>( xml_sdf: &'a XmlSystemDescription, node: &'a roxmltree::Node, @@ -1343,6 +1451,12 @@ impl ChannelEnd { } impl Channel { + pub fn new(end_a: ChannelEnd, end_b: ChannelEnd) -> Result { + Ok(Channel { + end_a: end_a, + end_b: end_b, + }) + } /// It should be noted that this function assumes that `pds` is populated /// with all the Protection Domains that could potentially be connected with /// the channel.