Implemented ACPI table
This commit is contained in:
39
src/acpi/hpet.rs
Normal file
39
src/acpi/hpet.rs
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user