Skip to content

Commit

Permalink
tool: run clippy and fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Aug 5, 2024
1 parent cd05c86 commit 432c27b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
3 changes: 2 additions & 1 deletion tool/microkit/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ impl ElfFile {
}

let mut segment_data = vec![0; phent.memsz as usize];
segment_data[..phent.filesz as usize].copy_from_slice(&bytes[segment_start..segment_end]);
segment_data[..phent.filesz as usize]
.copy_from_slice(&bytes[segment_start..segment_end]);

let segment = ElfSegment {
data: segment_data,
Expand Down
38 changes: 25 additions & 13 deletions tool/microkit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,14 @@ impl<'a> InitSystem<'a> {
if space_left < alloc_size {
for ut in &self.device_untyped {
let space_left = ut.ut.region.end - ut.watermark;
println!("ut [0x{:x}..0x{:x}], space left: 0x{:x}", ut.ut.region.base, ut.ut.region.end, space_left);
println!(
"ut [0x{:x}..0x{:x}], space left: 0x{:x}",
ut.ut.region.base, ut.ut.region.end, space_left
);
}
panic!(
"Error: allocation for physical address {:x} is too large ({:x}) for untyped",
phys_address,
alloc_size
phys_address, alloc_size
);
}

Expand Down Expand Up @@ -456,7 +458,11 @@ struct BuiltSystem {
initial_task_phys_region: MemoryRegion,
}

pub fn pd_write_symbols(pds: &Vec<ProtectionDomain>, pd_elf_files: &mut Vec<ElfFile>, pd_setvar_values: &Vec<Vec<u64>>) -> Result<(), String> {
pub fn pd_write_symbols(
pds: &[ProtectionDomain],
pd_elf_files: &mut [ElfFile],
pd_setvar_values: &[Vec<u64>],
) -> Result<(), String> {
for (i, pd) in pds.iter().enumerate() {
let elf = &mut pd_elf_files[i];
let name = pd.name.as_bytes();
Expand Down Expand Up @@ -1396,8 +1402,7 @@ fn build_system(
let (page_size_human, page_size_label) = util::human_size_strict(PageSize::Small as u64);
let ipc_buffer_str = format!(
"Page({} {}): IPC Buffer PD={}",
page_size_human, page_size_label,
pd.name
page_size_human, page_size_label, pd.name
);
small_page_names.push(ipc_buffer_str);
}
Expand All @@ -1409,7 +1414,10 @@ fn build_system(

let (page_size_human, page_size_label) = util::human_size_strict(mr.page_size as u64);
for idx in 0..mr.page_count {
let page_str = format!("Page({} {}): MR={} #{}", page_size_human, page_size_label, mr.name, idx);
let page_str = format!(
"Page({} {}): MR={} #{}",
page_size_human, page_size_label, mr.name, idx
);
match mr.page_size as PageSize {
PageSize::Small => small_page_names.push(page_str),
PageSize::Large => large_page_names.push(page_str),
Expand Down Expand Up @@ -1443,10 +1451,7 @@ fn build_system(
PageSize::Small => small_page_objs[idx..idx + mr.page_count as usize].to_vec(),
PageSize::Large => large_page_objs[idx..idx + mr.page_count as usize].to_vec(),
};
mr_pages.insert(
mr,
objs
);
mr_pages.insert(mr, objs);
match mr.page_size {
PageSize::Small => page_small_idx += mr.page_count as usize,
PageSize::Large => page_large_idx += mr.page_count as usize,
Expand Down Expand Up @@ -1478,7 +1483,10 @@ fn build_system(
};

let (page_size_human, page_size_label) = util::human_size_strict(mr.page_size as u64);
let name = format!("Page({} {}): MR={} @ {:x}", page_size_human, page_size_label, mr.name, phys_addr);
let name = format!(
"Page({} {}): MR={} @ {:x}",
page_size_human, page_size_label, mr.name, phys_addr
);
let page = init_system.allocate_fixed_object(phys_addr, obj_type, 1, name);
mr_pages.get_mut(mr).unwrap().push(page);
}
Expand Down Expand Up @@ -3485,7 +3493,11 @@ fn main() -> Result<(), String> {
monitor_elf.write_symbol("pd_names", &pd_names_bytes)?;

// Write out all the symbols for each PD
pd_write_symbols(&system.protection_domains, &mut pd_elf_files, &built_system.pd_setvar_values)?;
pd_write_symbols(
&system.protection_domains,
&mut pd_elf_files,
&built_system.pd_setvar_values,
)?;

// Generate the report
let report = match std::fs::File::create(args.report) {
Expand Down

0 comments on commit 432c27b

Please sign in to comment.