Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions tool/microkit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use microkit_tool::argparse;
use microkit_tool::argparse::{Args, ArgsError};
use microkit_tool::build::build_system;
use microkit_tool::sdf::parse;
use microkit_tool::sdf::parse_xml;
use microkit_tool::sdk::Sdk;
use microkit_tool::sel4::Config;
use microkit_tool::util::bail_if_not_exists;
Expand Down Expand Up @@ -54,7 +54,7 @@ fn main() -> Result<(), String> {

let xml: String = fs::read_to_string(system_path).unwrap();

let mut system = match parse(
let mut system = match parse_xml(
system_path.as_path(),
&xml,
&kernel_config,
Expand Down
30 changes: 21 additions & 9 deletions tool/microkit/src/sdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct SdfLocation {
pub col: u32,
}

#[derive(Clone, Copy)]
pub struct SdfAttribute<'a> {
pub name: &'a str,
pub value: &'a str,
Expand Down Expand Up @@ -138,7 +139,7 @@ pub struct SystemDescription {
pub domains: Domains,
}

pub fn parse(
pub fn parse_xml(
filename: &Path,
xml: &str,
config: &Config,
Expand All @@ -151,14 +152,6 @@ pub fn parse(

let xml_sdf = SystemDescriptionFile { filename };

let mut root_pds = vec![];
let mut mrs = vec![];
let mut iomaps = vec![];
let mut io_address_space_names = HashSet::new();
let mut iommu_domain_ids = HashSet::new();
let mut iommu_device_identifiers = Vec::new();
let mut channels = vec![];
let mut domains = Domains::default();
let system = doc
.root()
.children()
Expand All @@ -170,6 +163,25 @@ pub fn parse(

let system: &dyn SdfNode = &system;

parse(filename, system, config, search_paths)
}

pub fn parse(
filename: &Path,
system: &dyn SdfNode,
config: &Config,
search_paths: &Vec<PathBuf>,
) -> Result<SystemDescription, String> {
let xml_sdf = SystemDescriptionFile { filename };
let mut root_pds = vec![];
let mut mrs = vec![];
let mut iomaps = vec![];
let mut io_address_space_names = HashSet::new();
let mut iommu_domain_ids = HashSet::new();
let mut iommu_device_identifiers = Vec::new();
let mut channels = vec![];
let mut domains = Domains::default();

// Channels cannot be parsed immediately as they refer to a particular protection domain
// via an index in the list of PDs. This means that we have to parse all PDs first and
// then parse the channels.
Expand Down
4 changes: 2 additions & 2 deletions tool/microkit/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn check_success(kernel_config: &sel4::Config, test_name: &str) {
path.push("tests/sdf/");
path.push(test_name);
let sdf = std::fs::read_to_string(path).unwrap();
let parse = sdf::parse(
let parse = sdf::parse_xml(
Path::new(test_name),
&sdf,
kernel_config,
Expand All @@ -131,7 +131,7 @@ fn check_error(kernel_config: &sel4::Config, test_name: &str, expected_err: &str
sdf_path.push("tests/sdf/");
sdf_path.push(test_name);
let sdf = std::fs::read_to_string(sdf_path).unwrap();
let parse_err = sdf::parse(
let parse_err = sdf::parse_xml(
Path::new(test_name),
&sdf,
kernel_config,
Expand Down
Loading