Implemented ACPI table

This commit is contained in:
Connor Wood
2017-07-14 10:36:27 +01:00
parent 687f991ab4
commit 387cd41e5e
2 changed files with 43 additions and 0 deletions

39
src/acpi/hpet.rs Normal file
View File

@@ -0,0 +1,39 @@
use core::{mem, ptr};
use super::sdt::Sdt;
#[repr(packed)]
#[derive(Clone, Copy, Debug, Default)]
pub struct GenericAddressStructure {
address_space: u8,
bit_width: u8,
bit_offset: u8,
access_size: u8,
address: u64,
}
#[repr(packed)]
#[derive(Debug)]
pub struct Hpet {
pub header: Sdt,
pub hw_rev_id: u8,
pub comparator_descriptor: u8,
pub pci_vendor_id: u16,
pub base_address: GenericAddressStructure,
pub hpet_number: u8,
pub min_periodic_clk_tick: u16,
pub oem_attribute: u8
}
impl Hpet {
pub fn new(sdt: &'static Sdt) -> Option<Hpet> {
if &sdt.signature == b"HPET" && sdt.length as usize >= mem::size_of::<Hpet>() {
Some(unsafe { ptr::read((sdt as *const Sdt) as *const Hpet) })
} else {
None
}
}
}

View File

@@ -18,9 +18,11 @@ use self::madt::{Madt, MadtEntry};
use self::rsdt::Rsdt;
use self::sdt::Sdt;
use self::xsdt::Xsdt;
use self::hpet::Hpet;
use self::aml::{is_aml_table, parse_aml_table, AmlNamespace, AmlError};
mod hpet;
mod dmar;
mod fadt;
mod madt;
@@ -195,6 +197,8 @@ fn parse_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
_ => ()
}
}
} else if let Some(hpet) = Hpet::new(sdt) {
println!(": {:#?}", hpet);
} else if is_aml_table(sdt) {
ACPI_TABLE.lock().namespace = match parse_aml_table(sdt) {
Ok(res) => {