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