Skip to main content

raw_acpi/
dsdt.rs

1use crate::SDTHeader;
2
3#[derive(Copy, Clone)]
4#[repr(C, packed)]
5/// ## Differentiated System Description Table
6///
7/// The Differentiated System Description Table (DSDT) is part of the system fixed description.
8/// The DSDT is comprised of a system description table header followed by data in Definition Block format. See Section 5.2.11 for a description of Definition Blocks.
9/// During initialization, OSPM finds the pointer to the DSDT in the Fixed ACPI Description Table (using the FADT's `dsdt` or `x_dsdt` fields) and then loads the DSDT to create the ACPI Namespace.
10pub struct DifferentiatedSystemDescriptionTable {
11    /// - **Signature** - "DSDT"
12    /// - **Revision** - This field also sets the global integer width for the AML interpreter.
13    /// Values less than two will cause the interpreter to use 32-bit integers and math. Values of two and greater will cause the interpreter to use full 64-bit integers and math.
14    pub header: SDTHeader,
15    /// The bytes of AML code.
16    pub def_block: [u8; 0],
17}
18impl DifferentiatedSystemDescriptionTable {
19    pub const fn def_block(&self) -> &[u8] {
20        // SAFETY: I sure hope the OEM doesn't frick things up...
21        unsafe {
22            core::slice::from_raw_parts(
23                (self as *const _ as *const u8).add(crate::SDT_HEADER_SIZE),
24                self.header.length as usize - crate::SDT_HEADER_SIZE,
25            )
26        }
27    }
28}