Skip to content

Commit bd58246

Browse files
committed
Fix: Handle changes for MADT in acpi crate (#223)
- Adapted to the changes introduced in the acpi crate PR #223, specifically for the MADT structure. - Updated handling of MADT entries to align with the new API. - Used Pin<&Madt> to ensure immovable references when accessing MADT entries, in response to changes in the MADT structure. - Adjusted usage of MADT pointers to accommodate the new access pattern introduced by the acpi crate update. See: rust-osdev/acpi#223
1 parent 55e2928 commit bd58246

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/src/acpi.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use core::{marker::PhantomData, ptr::read_unaligned};
1+
use core::{
2+
marker::PhantomData,
3+
pin::{Pin, pin},
4+
ptr::read_unaligned,
5+
};
26

37
use acpi::{
48
AcpiError,
@@ -102,7 +106,7 @@ pub struct ApicInfo {
102106
}
103107

104108
impl ApicInfo {
105-
fn from_madt(madt: &Madt) -> Self {
109+
fn from_madt(madt: Pin<&Madt>) -> Self {
106110
// Find the entry about I/O APIC from the MADT.
107111
let io_apic_entry = madt
108112
.entries()
@@ -199,11 +203,13 @@ pub unsafe fn init(rsdp_addr: PhysPtr) {
199203
panic!();
200204
}
201205

206+
let madt = unsafe { Pin::new_unchecked(&*madt_ptr) };
207+
202208
kprintln!("FADT is found: 0x{:X}", fadt_ptr as u64);
203209
FADT.call_once(|| *fadt_ptr);
204210

205211
kprintln!("MADT is found: 0x{:X}", madt_ptr as u64);
206-
APIC_INFO.call_once(|| ApicInfo::from_madt(&*madt_ptr));
212+
APIC_INFO.call_once(|| ApicInfo::from_madt(madt));
207213
}
208214

209215
pub fn get_fadt() -> &'static Fadt {

0 commit comments

Comments
 (0)