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