Fix the bug in RxsdtIter that caused u32 pointers to be used regardless of ACPI table kind

This commit is contained in:
R Aadarsh
2026-06-30 16:12:45 +00:00
committed by Jeremy Soller
parent a03c545f3c
commit aa7e7d2f44
3 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ use alloc::boxed::Box;
use core::convert::TryFrom;
use rmm::PhysicalAddress;
use crate::acpi::rxsdt::RxsdtIter;
use crate::acpi::{RxsdtEnum, rxsdt::RxsdtIter};
use super::{rxsdt::Rxsdt, sdt::Sdt};
@@ -27,6 +27,6 @@ impl Rsdt {
impl Rxsdt for Rsdt {
fn iter(&self) -> RxsdtIter {
RxsdtIter { sdt: self.0, i: 0 }
RxsdtIter { sdt: self.0, i: 0 , rxsdt_enum: RxsdtEnum::Rsdt(Rsdt(self.0))}
}
}
+7 -3
View File
@@ -1,7 +1,7 @@
use alloc::boxed::Box;
use rmm::PhysicalAddress;
use crate::acpi::sdt::Sdt;
use crate::acpi::{RxsdtEnum, sdt::Sdt};
pub trait Rxsdt {
fn iter(&self) -> RxsdtIter;
@@ -10,6 +10,7 @@ pub trait Rxsdt {
pub struct RxsdtIter {
pub sdt: &'static Sdt,
pub i: usize,
pub rxsdt_enum: RxsdtEnum,
}
impl Iterator for RxsdtIter {
@@ -17,10 +18,13 @@ impl Iterator for RxsdtIter {
fn next(&mut self) -> Option<Self::Item> {
if self.i < self.sdt.data_len() / size_of::<u64>() {
let item = unsafe {
core::ptr::read_unaligned((self.sdt.data_address() as *const u64).add(self.i))
match self.rxsdt_enum{
RxsdtEnum::Rsdt(_) => PhysicalAddress::new(core::ptr::read_unaligned((self.sdt.data_address() as *const u32).add(self.i)) as usize),
RxsdtEnum::Xsdt(_) => PhysicalAddress::new(core::ptr::read_unaligned((self.sdt.data_address() as *const u64).add(self.i)) as usize),
}
};
self.i += 1;
Some(PhysicalAddress::new(item as usize))
Some(item)
} else {
None
}
+2 -2
View File
@@ -2,7 +2,7 @@ use alloc::boxed::Box;
use core::convert::TryFrom;
use rmm::PhysicalAddress;
use crate::acpi::rxsdt::RxsdtIter;
use crate::acpi::{RxsdtEnum, rxsdt::RxsdtIter};
use super::{rxsdt::Rxsdt, sdt::Sdt};
@@ -27,6 +27,6 @@ impl Xsdt {
impl Rxsdt for Xsdt {
fn iter(&self) -> RxsdtIter {
RxsdtIter { sdt: self.0, i: 0 }
RxsdtIter { sdt: self.0, i: 0, rxsdt_enum: RxsdtEnum::Xsdt(Xsdt(self.0)) }
}
}