Skip to main content

strat9_kernel/acpi/
sdt.rs

1//! ACPI table definitions and basic SDT structures.
2//! Inspired by Theseus OS.
3
4use zerocopy::FromBytes;
5
6/// The size in bytes of the ACPI SDT Header (`Sdt` struct).
7pub const SDT_SIZE_IN_BYTES: usize = core::mem::size_of::<Sdt>();
8
9/// An ACPI System Descriptor Table.
10/// This is the header (the first part) of every ACPI table.
11#[derive(Copy, Clone, Debug, FromBytes)]
12#[repr(C, packed)]
13pub struct Sdt {
14    pub signature: [u8; 4],
15    pub length: u32,
16    pub revision: u8,
17    pub checksum: u8,
18    pub oem_id: [u8; 6],
19    pub oem_table_id: [u8; 8],
20    pub oem_revision: u32,
21    pub creator_id: u32,
22    pub creator_revision: u32,
23}
24
25/// A struct used to describe the position and layout of registers
26/// related to ACPI tables.
27#[derive(Clone, Copy, Debug, FromBytes)]
28#[repr(C, packed)]
29pub struct GenericAddressStructure {
30    pub address_space: u8,
31    pub bit_width: u8,
32    pub bit_offset: u8,
33    pub access_size: u8,
34    pub phys_addr: u64,
35}