acpi_spec/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! ACPI types.
5
6#![expect(missing_docs)]
7#![forbid(unsafe_code)]
8#![no_std]
9
10#[cfg(feature = "alloc")]
11extern crate alloc;
12
13pub mod aspt;
14pub mod fadt;
15pub mod gtdt;
16pub mod madt;
17pub mod mcfg;
18pub mod pptt;
19pub mod srat;
20
21#[expect(non_camel_case_types)]
22mod packed_nums {
23    pub type u16_ne = zerocopy::U16<zerocopy::NativeEndian>;
24    pub type u32_ne = zerocopy::U32<zerocopy::NativeEndian>;
25    pub type u64_ne = zerocopy::U64<zerocopy::NativeEndian>;
26}
27
28use self::packed_nums::*;
29use core::mem::size_of;
30use static_assertions::const_assert_eq;
31use zerocopy::FromBytes;
32use zerocopy::Immutable;
33use zerocopy::IntoBytes;
34use zerocopy::KnownLayout;
35use zerocopy::Unaligned;
36
37#[repr(C, packed)]
38#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout, FromBytes, Unaligned)]
39pub struct Rsdp {
40    pub signature: [u8; 8], // "RSD PTR "
41    pub checksum: u8,       // first 20 bytes
42    pub oem_id: [u8; 6],
43    pub revision: u8, // 2
44    pub rsdt: u32,
45    pub length: u32,
46    pub xsdt: u64,
47    pub xchecksum: u8, // full checksum
48    pub rsvd: [u8; 3],
49}
50
51const_assert_eq!(size_of::<Rsdp>(), 36);
52
53#[repr(C)]
54#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout, FromBytes, Unaligned)]
55pub struct Header {
56    pub signature: [u8; 4],
57    pub length: u32_ne,
58    pub revision: u8,
59    pub checksum: u8,
60    pub oem_id: [u8; 6],
61    pub oem_tableid: [u8; 8],
62    pub oem_revision: u32_ne,
63    pub creator_id: u32_ne,
64    pub creator_revision: u32_ne,
65}
66
67const_assert_eq!(size_of::<Header>(), 36);
68
69/// Marker trait for ACPI Table structs that encodes the table's signature
70pub trait Table: IntoBytes + Unaligned + Immutable + KnownLayout {
71    const SIGNATURE: [u8; 4];
72}