Skip to main content

raw_acpi/
lib.rs

1//! # ACPI System Description Tables
2//!
3//! This rust library defines all the ACPI-defined System Description Tables.  Such tables and more information can be found
4//! <a href="https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#acpi-system-description-tables">here</a>.
5
6#![no_std]
7
8pub mod bgrt;
9pub mod cpep;
10pub mod dsdt;
11pub mod ecdt;
12pub mod facs;
13pub mod fadt;
14//pub mod hpet; // JJ here, this is a reserved signature from acpi.
15pub mod madt;
16//pub mod mcfg; // JJ here, this is a reserved signature from acpi.
17pub mod msct;
18pub mod pcct;
19pub mod psdt;
20pub mod rasf;
21pub mod rsdp;
22pub mod rsdt;
23pub mod sbst;
24pub mod slit;
25//pub mod spcr; // JJ here, this is a reserved signature from acpi.
26pub mod srat;
27pub mod ssdt;
28pub mod xsdt;
29
30#[derive(Clone, Copy)]
31#[repr(C, packed)]
32/// The Generic Address Structure (GAS) provides the platform with a robust means to describe register locations.
33pub struct GenericAddressStructure {
34    /// The address space where the data structure or register exists. Defined values are:
35    /// - 0x00 - System Memory space
36    /// - 0x01 - System I/O space
37    /// - 0x02 - PCI Configuration space
38    /// - 0x03 - Embedded Controller
39    /// - 0x04 - SMBus
40    /// - 0x05 - SystemCMOS
41    /// - 0x06 - PciBarTarget
42    /// - 0x07 - IPMI
43    /// - 0x08 - General PurposeIO
44    /// - 0x09 - GenericSerialBus
45    /// - 0x0A - Platform Communications Channel (PCC)
46    /// - 0x0B - Platform Runtime Mechanism (PRM)
47    /// - 0x0C to 0x7E - Reserved
48    /// - 0x7F - Functional Fixed Hardware
49    /// - 0x80 to 0xFF - OEM Defined
50    pub address_space_id: u8,
51    /// The size in bits of the given register. When addressing a data structure, this field must be zero.
52    pub reg_bit_width: u8,
53    /// The bit offset of the given register at the given address. When addressing a data structure, this field must be zero.
54    pub reg_bit_offset: u8,
55    /// Specifies access size. Unless otherwise defined by the Address Space ID:
56    /// - 0 - Undefined (legacy reasons)
57    /// - 1 - Byte access
58    /// - 2 - Word access
59    /// - 3 - Dword access
60    /// - 4 - QWord access
61    pub access_size: u8,
62    /// The 64-bit address of the data structure or register in the given address space (relative to the processor).
63    pub address: u64,
64}
65
66pub const SDT_HEADER_SIZE: usize = core::mem::size_of::<SDTHeader>();
67
68#[derive(Copy, Clone)]
69#[repr(C, packed)]
70/// ## System Description Table Header structure.
71///
72/// All system description tables begin with the structure shown in the SDTHeader Fields.
73/// The signature field in this table determines the content of the system description table.
74pub struct SDTHeader {
75    /// The ASCII string representation of the table identifier. Note that if OSPM finds a signature in a table that is not listed in
76    /// <a href="https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#description-header-signatures-for-tables-defined-by-acpi">this table</a>, then OSPM ignores the entire table (it is not loaded into ACPI namespace);
77    /// OSPM ignores the table even though the values in the Length and Checksum fields are correct.
78    pub signature: [u8; 4],
79    /// The length of the table, in bytes, including the header, starting from offset 0. This field is used to record the size of the entire table.
80    pub length: u32,
81    /// The revision of the structure corresponding to the signature field for this table.<br>
82    /// Larger revision numbers are backward compatible to lower revision numbers with the same signature.
83    pub revision: u8,
84    /// The entire table, including the checksum field, must add to zero to be considered valid.
85    pub checksum: u8,
86    /// An OEM-supplied string that identifies the OEM.
87    pub oemid: [u8; 6],
88    /// An OEM-supplied string that the OEM uses to identify the particular data table.<br>
89    /// This field is particularly useful when defining a definition block to distinguish definition block functions.
90    /// The OEM assigns each dissimilar structure a new OEM Table ID.
91    pub oem_table_id: [u8; 8],
92    /// An OEM-supplied revision number. Larger numbers are assumed to be newer revisions.
93    pub oem_revision: u32,
94    /// Vendor ID of utility that created the table. For tables containing Definition Blocks, this is the ID for the ASL Compiler.
95    pub creator_id: u32,
96    /// Revision of utility that created the table. For tables containing Definition Blocks, this is the revision for the ASL Compiler.
97    pub creator_revision: u32,
98}