Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions tool/microkit/src/sdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ impl SysMapPerms {
}

impl SysMap {
pub fn new(mr: String, vaddr: u64, perms: u8, cached: bool) -> Result<SysMap, String> {
Ok(SysMap {
mr,
vaddr,
perms,
cached,
text_pos: None,
})
}
fn from_xml(
xml_sdf: &XmlSystemDescription,
node: &roxmltree::Node,
Expand Down Expand Up @@ -439,6 +448,52 @@ impl ProtectionDomain {
ioports
}

pub fn new(
id: Option<u64>,
name: String,
priority: u8,
budget: u64,
period: u64,
passive: bool,
stack_size: u64,
smc: bool,
cpu: CpuCore,
program_image: PathBuf,
maps: Vec<SysMap>,
irqs: Vec<SysIrq>,
ioports: Vec<IOPort>,
setvars: Vec<SysSetVar>,
virtual_machine: Option<VirtualMachine>,
child_pds: Vec<ProtectionDomain>,
has_children: bool,
setvar_id: Option<String>,
) -> Result<ProtectionDomain, String> {
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,
Expand Down Expand Up @@ -1078,6 +1133,23 @@ impl ProtectionDomain {
}

impl VirtualMachine {
pub fn new(
vcpus: Vec<VirtualCpu>,
name: String,
maps: Vec<SysMap>,
priority: u8,
budget: u64,
period: u64,
) -> Result<VirtualMachine, String> {
Ok(VirtualMachine {
vcpus,
name,
maps,
priority,
budget,
period,
})
}
fn from_xml(
config: &Config,
xml_sdf: &XmlSystemDescription,
Expand Down Expand Up @@ -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<SysMemoryRegion, String> {
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,
Expand Down Expand Up @@ -1272,6 +1364,22 @@ impl SysMemoryRegion {
}

impl ChannelEnd {
pub fn new(
pd_idx: usize,
id: u64,
notify: bool,
pp: bool,
setvar_id: Option<String>,
) -> Result<ChannelEnd, String> {
Ok(ChannelEnd {
pd: pd_idx,
id: id,
notify,
pp,
setvar_id,
})
}

fn from_xml<'a>(
xml_sdf: &'a XmlSystemDescription,
node: &'a roxmltree::Node,
Expand Down Expand Up @@ -1343,6 +1451,12 @@ impl ChannelEnd {
}

impl Channel {
pub fn new(end_a: ChannelEnd, end_b: ChannelEnd) -> Result<Channel, String> {
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.
Expand Down