Skip to content

Commit ad1b570

Browse files
committed
fix: fix IORT node pointer calculation and add SMMU V3 base address iterator
1 parent b315e95 commit ad1b570

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

acpi/src/iort.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,19 @@ impl fmt::Display for Iort {
4242

4343
impl Iort {
4444
pub fn nodes(&self) -> IortNodeIter {
45-
let pointer = unsafe { (self as *const Iort).add(1) as *const u8 };
46-
let remaining_length = self.header.length as u32 - core::mem::size_of::<Iort>() as u32;
45+
let node_offset = self.node_array_offset as usize;
46+
let pointer = unsafe { (self as *const Iort as *const u8).add(node_offset)};
47+
let remaining_length = self.header.length as u32 - node_offset as u32;
4748

4849
IortNodeIter { pointer, remaining_length, _phantom: PhantomData }
4950
}
51+
52+
pub fn smmuv3_bases(&self) -> impl Iterator<Item = u64> + '_ {
53+
self.nodes().filter_map(|node| match node {
54+
IortNode::SmmuV3(smmu_v3) => Some(smmu_v3.base_address),
55+
_ => None,
56+
})
57+
}
5058
}
5159

5260
#[derive(Debug, Clone, Copy)]

0 commit comments

Comments
 (0)