Skip to content

Commit

Permalink
parse XSDT and MADT
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyukai0403 committed Jan 11, 2025
1 parent 0eec0d0 commit ac04f77
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions kernel/src/acpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub struct RSDP {
reserved: [u8; 3],
}

#[derive(Debug)]
#[derive(Debug, Copy, Clone)]
#[repr(packed)]
pub struct XSDT {
pub struct ACPI_table_header {
signature: [u8; 4],
length: u32,
revision: u8,
Expand All @@ -28,17 +28,40 @@ pub struct XSDT {
OEMRevision: u32,
creator_id: u32,
creator_revison: u32,
pointers: [* const (); 16], // TODO
}

#[derive(Debug)]
#[repr(packed)]
pub struct XSDT {
header: ACPI_table_header,
pointers: [u64; 16], // TODO
}

#[derive(Debug)]
#[repr(packed)]
pub struct MADT {
header: ACPI_table_header,
local_apic_addr: u32,
flags: u32,
record_marker: (),
}

pub static mut rsdp: * const RSDP = 0 as * const RSDP;
pub static mut xsdt: * const XSDT = 0 as * const XSDT;
pub static mut madt: * const MADT = 0 as * const MADT;

pub fn init(res: &RsdpResponse) {
unsafe {
rsdp = res.address() as * const RSDP;
println!("{:?}", *rsdp);
xsdt = phys_to_virt((*rsdp).xsdt_addr) as * const XSDT;
println!("{:?}", *xsdt);
for i in 0..16 {
let head = phys_to_virt((*xsdt).pointers[i]) as * const ACPI_table_header;
if (*head).signature == [65, 80, 73, 67] {
madt = head as * const MADT;
println!("{:#?}", *madt);
}
}
}
}

0 comments on commit ac04f77

Please sign in to comment.