strat9_kernel/acpi/
dmar.rs1use super::sdt::Sdt;
5use zerocopy::FromBytes;
6
7pub const DMAR_SIGNATURE: &[u8; 4] = b"DMAR";
8
9#[derive(Clone, Copy, Debug, FromBytes)]
10#[repr(C, packed)]
11struct DmarReporting {
12 header: Sdt,
13 host_address_width: u8,
14 flags: u8,
15 _reserved: [u8; 10],
16}
17
18pub struct Dmar {
19 table: &'static DmarReporting,
20}
21
22impl Dmar {
23 pub fn get() -> Option<Self> {
25 unsafe {
26 super::find_table(DMAR_SIGNATURE).map(|ptr| Dmar {
27 table: &*(ptr as *const DmarReporting),
28 })
29 }
30 }
31
32 pub fn host_address_width(&self) -> u8 {
34 self.table.host_address_width + 1
35 }
36
37 pub fn flags(&self) -> u8 {
39 self.table.flags
40 }
41}