acpi_spec/
fadt.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use super::Header;
5use super::Table;
6use core::mem::size_of;
7use static_assertions::const_assert_eq;
8use zerocopy::Immutable;
9use zerocopy::IntoBytes;
10use zerocopy::KnownLayout;
11use zerocopy::Unaligned;
12
13#[repr(C, packed)]
14#[derive(Copy, Clone, Debug, Default, IntoBytes, Immutable, KnownLayout, Unaligned)]
15pub struct Fadt {
16    // 36
17    pub facs: u32,
18    pub dsdt: u32,
19
20    // 44
21    pub rsvd: u8,
22    pub preferred_pm_profile: u8,
23    pub sci_int: u16,
24
25    // 48
26    pub smi_cmd: u32,
27    pub acpi_enable: u8,
28    pub acpi_disable: u8,
29    pub s4bios_req: u8,
30    pub pstate_cnt: u8,
31
32    // 56
33    pub pm1a_evt_blk: u32,
34    pub pm1b_evt_blk: u32,
35    pub pm1a_cnt_blk: u32,
36    pub pm1b_cnt_blk: u32,
37    pub pm2_cnt_blk: u32,
38    pub pm_tmr_blk: u32,
39    pub gpe0_blk: u32,
40    pub gpe1_blk: u32,
41
42    // 88
43    pub pm1_evt_len: u8,
44    pub pm1_cnt_len: u8,
45    pub pm2_cnt_len: u8,
46    pub pm_tmr_len: u8,
47    pub gpe0_blk_len: u8,
48    pub gpe1_blk_len_len: u8,
49    pub gpe1_base: u8,
50    pub cst_cnt: u8,
51
52    // 96
53    pub p_lvl2_lat: u16,
54    pub p_lvl3_lat: u16,
55    pub flush_size: u16,
56    pub flush_stride: u16,
57
58    // 104
59    pub duty_offset: u8,
60    pub duty_width: u8,
61    pub day_alrm: u8,
62    pub mon_alrm: u8,
63    pub century: u8,
64    pub iapc_boot_arch: u16,
65    pub rsvd2: u8,
66
67    // 112
68    pub flags: u32,
69
70    // 116
71    pub reset_reg: GenericAddress,
72    pub reset_value: u8,
73    pub arm_boot_arch: u16,
74    pub minor_version: u8,
75
76    // 132
77    pub x_firmware_ctrl: u64,
78    pub x_dsdt: u64,
79
80    // 148
81    pub x_pm1a_evt_blk: GenericAddress,
82    pub x_pm1b_evt_blk: GenericAddress,
83    pub x_pm1a_cnt_blk: GenericAddress,
84    pub x_pm1b_cnt_blk: GenericAddress,
85    pub x_pm2_cnt_blk: GenericAddress,
86    pub x_pm_tmr_blk: GenericAddress,
87    pub x_gpe0_blk: GenericAddress,
88    pub x_gpe1_blk: GenericAddress,
89
90    pub sleep_control_reg: GenericAddress,
91    pub sleep_status_reg: GenericAddress,
92    pub hypervisor_vendor_identity: u64,
93}
94
95const_assert_eq!(size_of::<Fadt>(), 276 - size_of::<Header>());
96
97impl Table for Fadt {
98    const SIGNATURE: [u8; 4] = *b"FACP";
99}
100
101pub const FADT_WBINVD: u32 = 1 << 0;
102pub const FADT_WBINVD_FLUSH: u32 = 1 << 1;
103pub const FADT_PROC_C1: u32 = 1 << 2;
104pub const FADT_LVL2_UP: u32 = 1 << 3;
105pub const FADT_PWR_BUTTON: u32 = 1 << 4;
106pub const FADT_SLP_BUTTON: u32 = 1 << 5;
107pub const FADT_FIX_RTC: u32 = 1 << 6;
108pub const FADT_RTC_S4: u32 = 1 << 7;
109pub const FADT_TMR_VAL_EXT: u32 = 1 << 8;
110pub const FADT_DCK_CAP: u32 = 1 << 9;
111pub const FADT_RESET_REG_SUP: u32 = 1 << 10;
112pub const FADT_SEALED_CASE: u32 = 1 << 11;
113pub const FADT_HEADLESS: u32 = 1 << 12;
114pub const FADT_CPU_SW_SLP: u32 = 1 << 13;
115pub const FADT_PCI_EXP_WAK: u32 = 1 << 14;
116pub const FADT_USE_PLATFORM_CLOCK: u32 = 1 << 15;
117pub const FADT_S4_RTC_STS_VALID: u32 = 1 << 16;
118pub const FADT_REMOTE_POWER_ON_CAPABLE: u32 = 1 << 17;
119pub const FADT_FORCE_APIC_CLUSTER_MODE: u32 = 1 << 18;
120pub const FADT_FORCE_APIC_PHYSICAL_DESTINATION_MODE: u32 = 1 << 19;
121pub const FADT_HW_REDUCED_ACPI: u32 = 1 << 20;
122pub const FADT_LOW_POWER_S0_IDLE_CAPABLE: u32 = 1 << 21;
123
124#[repr(u8)]
125#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
126pub enum AddressSpaceId {
127    SystemMemory = 0,
128    SystemIo = 1,
129    PciConfigurationSpace = 2,
130    EmbeddedController = 3,
131    Smbus = 4,
132    PlatformCommunicationChannel = 0x0A,
133    FunctionalFixedHardware = 0x7F,
134}
135
136impl Default for AddressSpaceId {
137    fn default() -> Self {
138        Self::SystemMemory
139    }
140}
141
142#[repr(u8)]
143#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
144pub enum AddressWidth {
145    Undefined = 0,
146    Byte = 1,
147    Word = 2,
148    Dword = 3,
149    Qword = 4,
150}
151
152impl Default for AddressWidth {
153    fn default() -> Self {
154        Self::Undefined
155    }
156}
157
158#[repr(C, packed)]
159#[derive(Copy, Clone, Debug, Default, IntoBytes, Immutable, KnownLayout)]
160pub struct GenericAddress {
161    pub addr_space_id: AddressSpaceId,
162    pub register_bit_width: u8,
163    pub register_bit_offset: u8,
164    pub access_size: AddressWidth,
165    pub address: u64,
166}
167
168const_assert_eq!(size_of::<GenericAddress>(), 12);