-
Connor Wood authoredConnor Wood authored
hpet.rs 822 B
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,
pub 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
}
}
}