blob: 09e12115ba884c58b5be47407b81b6d2646e6a31 [file] [log] [blame]
Furquan Shaikhe0844632020-05-02 10:23:37 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Furquan Shaikhe0844632020-05-02 10:23:37 -07002
3/*
4 * coreboot ACPI support - headers and defines.
5 */
6
Furquan Shaikh56eafbb2020-04-30 18:38:55 -07007#ifndef __ACPI_ACPI_H__
8#define __ACPI_ACPI_H__
Furquan Shaikhe0844632020-05-02 10:23:37 -07009
10/*
11 * The type and enable fields are common in ACPI, but the
12 * values themselves are hardware implementation defined.
13 */
14#if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES)
15 #define SLP_EN (1 << 13)
16 #define SLP_TYP_SHIFT 10
17 #define SLP_TYP (7 << SLP_TYP_SHIFT)
18 #define SLP_TYP_S0 0
19 #define SLP_TYP_S1 1
20 #define SLP_TYP_S3 5
21 #define SLP_TYP_S4 6
22 #define SLP_TYP_S5 7
23#elif CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES)
24 #define SLP_EN (1 << 13)
25 #define SLP_TYP_SHIFT 10
26 #define SLP_TYP (7 << SLP_TYP_SHIFT)
27 #define SLP_TYP_S0 0
28 #define SLP_TYP_S1 1
29 #define SLP_TYP_S3 3
30 #define SLP_TYP_S4 4
31 #define SLP_TYP_S5 5
32#endif
33
34#define ACPI_TABLE_CREATOR "COREBOOT" /* Must be exactly 8 bytes long! */
35#define OEM_ID "COREv4" /* Must be exactly 6 bytes long! */
Elyes HAOUAS288426d2020-10-01 16:52:26 +020036#define ACPI_DSDT_REV_1 0x01 /* DSDT revision: ACPI v1 */
Elyes HAOUAS7f53ec62020-10-05 16:33:52 +020037#define ACPI_DSDT_REV_2 0x02 /* DSDT revision: ACPI v2.0 and greater */
Furquan Shaikhe0844632020-05-02 10:23:37 -070038
39#if !defined(__ASSEMBLER__) && !defined(__ACPI__)
40#include <commonlib/helpers.h>
41#include <device/device.h>
42#include <uuid.h>
43#include <cper.h>
Kyösti Mälkkiac0dc4a2020-11-18 07:40:21 +020044#include <romstage_handoff.h>
Furquan Shaikhe0844632020-05-02 10:23:37 -070045#include <types.h>
46
Tim Wawrzynczak05a6d5c2021-11-24 09:54:59 -070047enum acpi_device_sleep_states {
48 ACPI_DEVICE_SLEEP_D0 = 0,
49 ACPI_DEVICE_SLEEP_D1 = 1,
50 ACPI_DEVICE_SLEEP_D2 = 2,
51 ACPI_DEVICE_SLEEP_D3 = 3,
52 ACPI_DEVICE_SLEEP_D3_HOT = ACPI_DEVICE_SLEEP_D3,
53 ACPI_DEVICE_SLEEP_D3_COLD = 4,
Eran Mitrani4c9440c2022-11-29 17:46:38 -080054 ACPI_DEVICE_SLEEP_NONE = 5,
Tim Wawrzynczak05a6d5c2021-11-24 09:54:59 -070055};
56
Furquan Shaikhe0844632020-05-02 10:23:37 -070057#define RSDP_SIG "RSD PTR " /* RSDT pointer signature */
58#define ASLC "CORE" /* Must be exactly 4 bytes long! */
59
Raul E Rangel1c0b9f22020-07-09 11:58:38 -060060#define ACPI_NAME_BUFFER_SIZE 5 /* 4 chars + 1 NUL */
61
Furquan Shaikhe0844632020-05-02 10:23:37 -070062/*
63 * The assigned ACPI ID for the coreboot project is 'BOOT'
64 * http://www.uefi.org/acpi_id_list
65 */
66#define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */
67
68/* List of ACPI HID that use the coreboot ACPI ID */
69enum coreboot_acpi_ids {
70 COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */
71 COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */
72};
73
74enum acpi_tables {
75 /* Tables defined by ACPI and used by coreboot */
Jonathan Zhang3dcafa82022-05-11 13:11:20 -070076 BERT, CEDT, DBG2, DMAR, DSDT, EINJ, FACS, FADT, HEST, HMAT, HPET, IVRS,
77 MADT, MCFG, RSDP, RSDT, SLIT, SRAT, SSDT, TCPA, TPM2, XSDT, ECDT, LPIT,
Furquan Shaikhe0844632020-05-02 10:23:37 -070078 /* Additional proprietary tables used by coreboot */
Jason Glenesk61624b22020-11-02 20:06:23 -080079 VFCT, NHLT, SPMI, CRAT
Furquan Shaikhe0844632020-05-02 10:23:37 -070080};
81
82/* RSDP (Root System Description Pointer) */
83typedef struct acpi_rsdp {
84 char signature[8]; /* RSDP signature */
85 u8 checksum; /* Checksum of the first 20 bytes */
86 char oem_id[6]; /* OEM ID */
87 u8 revision; /* RSDP revision */
88 u32 rsdt_address; /* Physical address of RSDT (32 bits) */
89 u32 length; /* Total RSDP length (incl. extended part) */
90 u64 xsdt_address; /* Physical address of XSDT (64 bits) */
91 u8 ext_checksum; /* Checksum of the whole table */
92 u8 reserved[3];
93} __packed acpi_rsdp_t;
94
95/* GAS (Generic Address Structure) */
96typedef struct acpi_gen_regaddr {
97 u8 space_id; /* Address space ID */
98 u8 bit_width; /* Register size in bits */
99 u8 bit_offset; /* Register bit offset */
100 u8 access_size; /* Access size since ACPI 2.0c */
101 u32 addrl; /* Register address, low 32 bits */
102 u32 addrh; /* Register address, high 32 bits */
103} __packed acpi_addr_t;
104
Elyes HAOUAS5f5fd852020-10-15 12:24:00 +0200105#define ACPI_ADDRESS_SPACE_MEMORY 0 /* System memory */
106#define ACPI_ADDRESS_SPACE_IO 1 /* System I/O */
107#define ACPI_ADDRESS_SPACE_PCI 2 /* PCI config space */
108#define ACPI_ADDRESS_SPACE_EC 3 /* Embedded controller */
109#define ACPI_ADDRESS_SPACE_SMBUS 4 /* SMBus */
110#define ACPI_ADDRESS_SPACE_CMOS 5 /* SystemCMOS */
111#define ACPI_ADDRESS_SPACE_PCI_BAR_TARGET 6 /* PciBarTarget */
112#define ACPI_ADDRESS_SPACE_IPMI 7 /* IPMI */
113#define ACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO 8 /* GeneralPurposeIO */
114#define ACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS 9 /* GenericSerialBus */
115#define ACPI_ADDRESS_SPACE_PCC 0x0A /* Platform Comm. Channel */
116#define ACPI_ADDRESS_SPACE_FIXED 0x7f /* Functional fixed hardware */
117#define ACPI_FFIXEDHW_VENDOR_INTEL 1 /* Intel */
118#define ACPI_FFIXEDHW_CLASS_HLT 0 /* C1 Halt */
119#define ACPI_FFIXEDHW_CLASS_IO_HLT 1 /* C1 I/O then Halt */
120#define ACPI_FFIXEDHW_CLASS_MWAIT 2 /* MWAIT Native C-state */
121#define ACPI_FFIXEDHW_FLAG_HW_COORD 1 /* Hardware Coordination bit */
122#define ACPI_FFIXEDHW_FLAG_BM_STS 2 /* BM_STS avoidance bit */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700123/* 0x80-0xbf: Reserved */
124/* 0xc0-0xff: OEM defined */
125
126/* Access size definitions for Generic address structure */
127#define ACPI_ACCESS_SIZE_UNDEFINED 0 /* Undefined (legacy reasons) */
128#define ACPI_ACCESS_SIZE_BYTE_ACCESS 1
129#define ACPI_ACCESS_SIZE_WORD_ACCESS 2
130#define ACPI_ACCESS_SIZE_DWORD_ACCESS 3
131#define ACPI_ACCESS_SIZE_QWORD_ACCESS 4
132
Michael Niewöhnerab088c92021-09-23 17:04:35 +0200133/* Macros for common resource types */
134#define ACPI_REG_MSR(address, offset, width) \
Michael Niewöhnerf72c7b12021-10-05 21:42:57 +0200135 (acpi_addr_t){ \
Michael Niewöhnerab088c92021-09-23 17:04:35 +0200136 .space_id = ACPI_ADDRESS_SPACE_FIXED, \
137 .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \
138 .addrl = address, \
139 .bit_offset = offset, \
140 .bit_width = width, \
141 }
142
Michael Niewöhnerf72c7b12021-10-05 21:42:57 +0200143#define ACPI_REG_UNSUPPORTED (acpi_addr_t){0}
Michael Niewöhnerab088c92021-09-23 17:04:35 +0200144
Furquan Shaikhe0844632020-05-02 10:23:37 -0700145/* Common ACPI HIDs */
146#define ACPI_HID_FDC "PNP0700"
147#define ACPI_HID_KEYBOARD "PNP0303"
148#define ACPI_HID_MOUSE "PNP0F03"
149#define ACPI_HID_COM "PNP0501"
150#define ACPI_HID_LPT "PNP0400"
151#define ACPI_HID_PNP "PNP0C02"
152#define ACPI_HID_CONTAINER "PNP0A05"
153
154/* Generic ACPI header, provided by (almost) all tables */
155typedef struct acpi_table_header {
156 char signature[4]; /* ACPI signature (4 ASCII characters) */
157 u32 length; /* Table length in bytes (incl. header) */
158 u8 revision; /* Table version (not ACPI version!) */
159 u8 checksum; /* To make sum of entire table == 0 */
160 char oem_id[6]; /* OEM identification */
161 char oem_table_id[8]; /* OEM table identification */
162 u32 oem_revision; /* OEM revision number */
163 char asl_compiler_id[4]; /* ASL compiler vendor ID */
164 u32 asl_compiler_revision; /* ASL compiler revision number */
165} __packed acpi_header_t;
166
167/* A maximum number of 32 ACPI tables ought to be enough for now. */
168#define MAX_ACPI_TABLES 32
169
170/* RSDT (Root System Description Table) */
171typedef struct acpi_rsdt {
172 acpi_header_t header;
173 u32 entry[MAX_ACPI_TABLES];
174} __packed acpi_rsdt_t;
175
176/* XSDT (Extended System Description Table) */
177typedef struct acpi_xsdt {
178 acpi_header_t header;
179 u64 entry[MAX_ACPI_TABLES];
180} __packed acpi_xsdt_t;
181
182/* HPET timers */
183typedef struct acpi_hpet {
184 acpi_header_t header;
185 u32 id;
186 acpi_addr_t addr;
187 u8 number;
188 u16 min_tick;
189 u8 attributes;
190} __packed acpi_hpet_t;
191
192/* MCFG (PCI Express MMIO config space BAR description table) */
193typedef struct acpi_mcfg {
194 acpi_header_t header;
195 u8 reserved[8];
196} __packed acpi_mcfg_t;
197
198typedef struct acpi_tcpa {
199 acpi_header_t header;
200 u16 platform_class;
201 u32 laml;
202 u64 lasa;
203} __packed acpi_tcpa_t;
204
205typedef struct acpi_tpm2 {
206 acpi_header_t header;
207 u16 platform_class;
208 u8 reserved[2];
209 u64 control_area;
210 u32 start_method;
211 u8 msp[12];
212 u32 laml;
213 u64 lasa;
214} __packed acpi_tpm2_t;
215
216typedef struct acpi_mcfg_mmconfig {
217 u32 base_address;
218 u32 base_reserved;
219 u16 pci_segment_group_number;
220 u8 start_bus_number;
221 u8 end_bus_number;
222 u8 reserved[4];
223} __packed acpi_mcfg_mmconfig_t;
224
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -0700225/*
Jonathan Zhang3dcafa82022-05-11 13:11:20 -0700226 * CEDT (CXL Early Discovery Table)
227 * CXL spec 2.0 section 9.14.1
228 */
229typedef struct acpi_cedt {
230 acpi_header_t header;
231 /* Followed by CEDT structures[n] */
232} __packed acpi_cedt_t;
233
234#define ACPI_CEDT_STRUCTURE_CHBS 0
235#define ACPI_CEDT_STRUCTURE_CFMWS 1
236
237#define ACPI_CEDT_CHBS_CXL_VER_1_1 0x00
238#define ACPI_CEDT_CHBS_CXL_VER_2_0 0x01
239
240/* CHBS: CXL Host Bridge Structure */
241typedef struct acpi_cedt_chbs {
242 u8 type; /* Always 0, other values reserved */
243 u8 resv1;
244 u16 length; /* Length in bytes (32) */
245 u32 uid; /* CXL Host Bridge Unique ID */
246 u32 cxl_ver;
247 u32 resv2;
248 /*
249 * For CXL 1.1, the base is Downstream Port Root Complex Resource Block;
250 * For CXL 2.0, the base is CXL Host Bridge Component Registers.
251 */
252 u64 base;
253 u64 len;
254} __packed acpi_cedt_chbs_t;
255
256#define ACPI_CEDT_CFMWS_RESTRICTION_TYPE_2_MEM (1 << 0)
257#define ACPI_CEDT_CFMWS_RESTRICTION_TYPE_3_MEM (1 << 1)
258#define ACPI_CEDT_CFMWS_RESTRICTION_VOLATIL (1 << 2)
259#define ACPI_CEDT_CFMWS_RESTRICTION_PERSISTENT (1 << 3)
260#define ACPI_CEDT_CFMWS_RESTRICTION_FIXED (1 << 4)
261
262/* CFMWS: CXL Fixed Memory Window Structure */
263typedef struct acpi_cedt_cfmws {
264 u8 type; /* Type (0) */
265 u8 resv1;
266 u16 length; /* Length in bytes (32) */
267 u32 resv2;
268 u64 base_hpa; /* Base of the HPA range, 256MB aligned */
269 u64 window_size; /* Number of bytes this window represents */
270 u8 eniw; /* Encoded Number of Interleave Ways */
271 u8 interleave_arithmetic; /* Standard Modulo arithmetic (0) */
272 u16 resv3;
273 u32 hbig; /* Host Bridge Interleave Granularity */
274 u16 restriction;
275 u16 qtg_id;
276 u32 interleave_target[]; /* Interleave Target List */
277} __packed acpi_cedt_cfmws_t;
278
279/*
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -0700280 * HMAT (Heterogeneous Memory Attribute Table)
281 * ACPI spec 6.4 section 5.2.27
282 */
283typedef struct acpi_hmat {
284 acpi_header_t header;
285 u32 resv;
286 /* Followed by HMAT table structure[n] */
287} __packed acpi_hmat_t;
288
289/* HMAT: Memory Proximity Domain Attributes structure */
290typedef struct acpi_hmat_mpda {
291 u16 type; /* Type (0) */
292 u16 resv;
293 u32 length; /* Length in bytes (40) */
294 u16 flags;
295 u16 resv1;
296 u32 proximity_domain_initiator;
297 u32 proximity_domain_memory;
298 u32 resv2;
299 u64 resv3;
300 u64 resv4;
301} __packed acpi_hmat_mpda_t;
302
303/* HMAT: System Locality Latency and Bandwidth Information structure */
304typedef struct acpi_hmat_sllbi {
305 u16 type; /* Type (1) */
306 u16 resv;
307 u32 length; /* Length in bytes */
308 u8 flags;
309 u8 data_type;
310 /*
311 * Transfer size defined as a 5-biased power of 2 exponent,
312 * when the bandwidth/latency value is achieved.
313 */
314 u8 min_transfer_size;
315 u8 resv1;
316 u32 num_initiator_domains;
317 u32 num_target_domains;
318 u32 resv2;
319 u64 entry_base_unit;
320 /* Followed by initiator proximity domain list */
321 /* Followed by target proximity domain list */
322 /* Followed by latency / bandwidth values */
323} __packed acpi_hmat_sllbi_t;
324
325/* HMAT: Memory Side Cache Information structure */
326typedef struct acpi_hmat_msci {
327 u16 type; /* Type (2) */
328 u16 resv;
329 u32 length; /* Length in bytes */
330 u32 domain; /* Proximity domain for the memory */
331 u32 resv1;
332 u64 cache_size;
333 /* Describes level, associativity, write policy, cache line size */
334 u32 cache_attributes;
335 u16 resv2;
336 /*
337 * Number of SMBIOS handlers that contribute to the
338 * memory side cache physical devices
339 */
340 u16 num_handlers;
341 /* Followed by SMBIOS handlers*/
342} __packed acpi_hmat_msci_t;
343
Furquan Shaikhe0844632020-05-02 10:23:37 -0700344/* SRAT (System Resource Affinity Table) */
345typedef struct acpi_srat {
346 acpi_header_t header;
347 u32 resv;
348 u64 resv1;
349 /* Followed by static resource allocation structure[n] */
350} __packed acpi_srat_t;
351
Jonathan Zhang3164b642021-04-21 17:51:31 -0700352#define ACPI_SRAT_STRUCTURE_LAPIC 0
353#define ACPI_SRAT_STRUCTURE_MEM 1
354#define ACPI_SRAT_STRUCTURE_GIA 5
355
Naresh Solanki76835cc2023-01-20 19:13:02 +0100356/* SRAT: Processor x2APIC Structure */
357typedef struct acpi_srat_x2apic {
358 u8 type; /* Type (0) */
359 u8 length; /* Length in bytes (16) */
360 u16 reserved; /* Reserved - Must be zero */
361 u32 proximity_domain; /* Proximity domain */
362 u32 x2apic_id; /* x2APIC ID */
363 u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */
364 u32 clock_domain; /* _CDM Clock Domain */
365 u32 reserved1; /* Reserved */
366} __packed acpi_srat_x2apic_t;
367
Furquan Shaikhe0844632020-05-02 10:23:37 -0700368/* SRAT: Processor Local APIC/SAPIC Affinity Structure */
369typedef struct acpi_srat_lapic {
370 u8 type; /* Type (0) */
371 u8 length; /* Length in bytes (16) */
372 u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */
373 u8 apic_id; /* Local APIC ID */
374 u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */
375 u8 local_sapic_eid; /* Local SAPIC EID */
376 u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */
377 u32 clock_domain; /* _CDM Clock Domain */
378} __packed acpi_srat_lapic_t;
379
380/* SRAT: Memory Affinity Structure */
381typedef struct acpi_srat_mem {
382 u8 type; /* Type (1) */
383 u8 length; /* Length in bytes (40) */
384 u32 proximity_domain; /* Proximity domain */
385 u16 resv;
386 u32 base_address_low; /* Mem range base address, low */
387 u32 base_address_high; /* Mem range base address, high */
388 u32 length_low; /* Mem range length, low */
389 u32 length_high; /* Mem range length, high */
390 u32 resv1;
391 u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2,
392 * other bits reserved to 0
393 */
394 u32 resv2[2];
395} __packed acpi_srat_mem_t;
396
Jonathan Zhang3164b642021-04-21 17:51:31 -0700397/* SRAT: Generic Initiator Affinity Structure (ACPI spec 6.4 section 5.2.16.6) */
398typedef struct acpi_srat_gia {
399 u8 type; /* Type (5) */
400 u8 length; /* Length in bytes (32) */
401 u8 resv;
402 u8 dev_handle_type; /* Device handle type */
403 u32 proximity_domain; /*Proximity domain */
404 u8 dev_handle[16]; /* Device handle */
405 u32 flags;
406 u32 resv1;
407} __packed acpi_srat_gia_t;
408
409#define ACPI_SRAT_GIA_DEV_HANDLE_ACPI 0
410#define ACPI_SRAT_GIA_DEV_HANDLE_PCI 1
411
Furquan Shaikhe0844632020-05-02 10:23:37 -0700412/* SLIT (System Locality Distance Information Table) */
413typedef struct acpi_slit {
414 acpi_header_t header;
415 /* Followed by static resource allocation 8+byte[num*num] */
416} __packed acpi_slit_t;
417
418/* MADT (Multiple APIC Description Table) */
419typedef struct acpi_madt {
420 acpi_header_t header;
421 u32 lapic_addr; /* Local APIC address */
422 u32 flags; /* Multiple APIC flags */
423} __packed acpi_madt_t;
424
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +0100425/*
426 * LPIT (Low Power Idle Table)
427 * Conforms to "Intel Low Power S0 Idle" specification, rev 002 from July 2017.
428 */
429typedef struct acpi_lpit {
430 acpi_header_t header;
431} __packed acpi_lpit_t;
432
433/* LPIT: LPI descriptor flags */
434typedef struct acpi_lpi_flags {
435 uint32_t disabled : 1;
436 uint32_t counter_not_available : 1;
437 uint32_t reserved : 30;
438} __packed acpi_lpi_desc_flags_t;
439
440/* LPIT: LPI descriptor types */
441enum acpi_lpi_desc_type {
442 ACPI_LPI_DESC_TYPE_NATIVE_CSTATE = 0x00,
443 /* type >= 1 reserved */
444};
445
446/* LPIT: LPI descriptor header */
447typedef struct acpi_lpi_desc_hdr {
448 uint32_t type;
449 uint32_t length;
450 uint16_t uid;
451 uint16_t reserved;
452} __packed acpi_lpi_desc_hdr_t;
453
454#define ACPI_LPIT_CTR_FREQ_TSC 0
455
456/* LPIT: Native C-state instruction based LPI structure */
457typedef struct acpi_lpi_desc_ncst {
458 acpi_lpi_desc_hdr_t header;
459 acpi_lpi_desc_flags_t flags;
460 acpi_addr_t entry_trigger; /* Entry trigger C-state */
461 uint32_t min_residency; /* Minimum residency or "break-even" in microseconds */
462 uint32_t max_latency; /* Worst case exit latency in microseconds */
463 acpi_addr_t residency_counter;
464 uint64_t counter_frequency; /* Frequency in cycles per second - 0 means TSC freq */
465} __packed acpi_lpi_desc_ncst_t;
466
Furquan Shaikhe0844632020-05-02 10:23:37 -0700467/* VFCT image header */
468typedef struct acpi_vfct_image_hdr {
469 u32 PCIBus;
470 u32 PCIDevice;
471 u32 PCIFunction;
472 u16 VendorID;
473 u16 DeviceID;
474 u16 SSVID;
475 u16 SSID;
476 u32 Revision;
477 u32 ImageLength;
478 u8 VbiosContent; // dummy - copy VBIOS here
479} __packed acpi_vfct_image_hdr_t;
480
481/* VFCT (VBIOS Fetch Table) */
482typedef struct acpi_vfct {
483 acpi_header_t header;
484 u8 TableUUID[16];
485 u32 VBIOSImageOffset;
486 u32 Lib1ImageOffset;
487 u32 Reserved[4];
488 acpi_vfct_image_hdr_t image_hdr;
489} __packed acpi_vfct_t;
490
491typedef struct acpi_ivrs_info {
492} __packed acpi_ivrs_info_t;
493
494/* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */
495typedef struct acpi_ivrs_ivhd {
496 uint8_t type;
497 uint8_t flags;
498 uint16_t length;
499 uint16_t device_id;
500 uint16_t capability_offset;
501 uint32_t iommu_base_low;
502 uint32_t iommu_base_high;
503 uint16_t pci_segment_group;
504 uint16_t iommu_info;
505 uint32_t iommu_feature_info;
506 uint8_t entry[0];
507} __packed acpi_ivrs_ivhd_t;
508
509/* IVRS (I/O Virtualization Reporting Structure) Type 10h */
510typedef struct acpi_ivrs {
511 acpi_header_t header;
512 uint32_t iv_info;
513 uint32_t reserved[2];
514 struct acpi_ivrs_ivhd ivhd;
515} __packed acpi_ivrs_t;
516
Jason Glenesk61624b22020-11-02 20:06:23 -0800517/* CRAT (Component Resource Affinity Table Structure) */
518struct acpi_crat_header {
519 acpi_header_t header;
520 uint32_t total_entries;
521 uint16_t num_nodes;
522 uint8_t reserved[6];
523} __packed;
524
Furquan Shaikhe0844632020-05-02 10:23:37 -0700525/* IVHD Type 11h IOMMU Attributes */
526typedef struct ivhd11_iommu_attr {
527 uint32_t reserved1 : 13;
528 uint32_t perf_counters : 4;
529 uint32_t perf_counter_banks : 6;
530 uint32_t msi_num_ppr : 5;
531 uint32_t reserved2 : 4;
532} __packed ivhd11_iommu_attr_t;
533
534/* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 11h */
535typedef struct acpi_ivrs_ivhd_11 {
536 uint8_t type;
537 uint8_t flags;
538 uint16_t length;
539 uint16_t device_id;
540 uint16_t capability_offset;
541 uint32_t iommu_base_low;
542 uint32_t iommu_base_high;
543 uint16_t pci_segment_group;
544 uint16_t iommu_info;
545 struct ivhd11_iommu_attr iommu_attributes;
546 uint32_t efr_reg_image_low;
547 uint32_t efr_reg_image_high;
548 uint32_t reserved[2];
549 uint8_t entry[0];
550} __packed acpi_ivrs_ivhd11_t;
551
552enum dev_scope_type {
553 SCOPE_PCI_ENDPOINT = 1,
554 SCOPE_PCI_SUB = 2,
555 SCOPE_IOAPIC = 3,
556 SCOPE_MSI_HPET = 4,
557 SCOPE_ACPI_NAMESPACE_DEVICE = 5
558};
559
560typedef struct dev_scope {
561 u8 type;
562 u8 length;
563 u8 reserved[2];
564 u8 enumeration;
565 u8 start_bus;
566 struct {
567 u8 dev;
568 u8 fn;
569 } __packed path[0];
570} __packed dev_scope_t;
571
572enum dmar_type {
573 DMAR_DRHD = 0,
574 DMAR_RMRR = 1,
575 DMAR_ATSR = 2,
576 DMAR_RHSA = 3,
John Zhao6edbb182021-03-24 11:55:09 -0700577 DMAR_ANDD = 4,
578 DMAR_SATC = 5
Furquan Shaikhe0844632020-05-02 10:23:37 -0700579};
580
581enum {
582 DRHD_INCLUDE_PCI_ALL = 1
583};
584
John Zhao091532d2021-04-17 16:03:21 -0700585enum {
586 ATC_REQUIRED = 1
587};
588
Furquan Shaikhe0844632020-05-02 10:23:37 -0700589enum dmar_flags {
590 DMAR_INTR_REMAP = 1 << 0,
591 DMAR_X2APIC_OPT_OUT = 1 << 1,
592 DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2,
593};
594
595typedef struct dmar_entry {
596 u16 type;
597 u16 length;
598 u8 flags;
599 u8 reserved;
600 u16 segment;
601 u64 bar;
602} __packed dmar_entry_t;
603
604typedef struct dmar_rmrr_entry {
605 u16 type;
606 u16 length;
607 u16 reserved;
608 u16 segment;
609 u64 bar;
610 u64 limit;
611} __packed dmar_rmrr_entry_t;
612
613typedef struct dmar_atsr_entry {
614 u16 type;
615 u16 length;
616 u8 flags;
617 u8 reserved;
618 u16 segment;
619} __packed dmar_atsr_entry_t;
620
621typedef struct dmar_rhsa_entry {
622 u16 type;
623 u16 length;
624 u32 reserved;
625 u64 base_address;
626 u32 proximity_domain;
627} __packed dmar_rhsa_entry_t;
628
629typedef struct dmar_andd_entry {
630 u16 type;
631 u16 length;
632 u8 reserved[3];
633 u8 device_number;
634 u8 device_name[];
635} __packed dmar_andd_entry_t;
636
John Zhao6edbb182021-03-24 11:55:09 -0700637typedef struct dmar_satc_entry {
638 u16 type;
639 u16 length;
640 u8 flags;
641 u8 reserved;
642 u16 segment_number;
John Zhao6edbb182021-03-24 11:55:09 -0700643} __packed dmar_satc_entry_t;
644
Furquan Shaikhe0844632020-05-02 10:23:37 -0700645/* DMAR (DMA Remapping Reporting Structure) */
646typedef struct acpi_dmar {
647 acpi_header_t header;
648 u8 host_address_width;
649 u8 flags;
650 u8 reserved[10];
651 dmar_entry_t structure[0];
652} __packed acpi_dmar_t;
653
654/* MADT: APIC Structure Types */
655enum acpi_apic_types {
656 LOCAL_APIC, /* Processor local APIC */
657 IO_APIC, /* I/O APIC */
658 IRQ_SOURCE_OVERRIDE, /* Interrupt source override */
659 NMI_TYPE, /* NMI source */
660 LOCAL_APIC_NMI, /* Local APIC NMI */
661 LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */
662 IO_SAPIC, /* I/O SAPIC */
663 LOCAL_SAPIC, /* Local SAPIC */
664 PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */
665 LOCAL_X2APIC, /* Processor local x2APIC */
666 LOCAL_X2APIC_NMI, /* Local x2APIC NMI */
667 GICC, /* GIC CPU Interface */
668 GICD, /* GIC Distributor */
669 GIC_MSI_FRAME, /* GIC MSI Frame */
670 GICR, /* GIC Redistributor */
671 GIC_ITS, /* Interrupt Translation Service */
672 /* 0x10-0x7f: Reserved */
673 /* 0x80-0xff: Reserved for OEM use */
674};
675
676/* MADT: Processor Local APIC Structure */
677typedef struct acpi_madt_lapic {
678 u8 type; /* Type (0) */
679 u8 length; /* Length in bytes (8) */
680 u8 processor_id; /* ACPI processor ID */
681 u8 apic_id; /* Local APIC ID */
682 u32 flags; /* Local APIC flags */
683} __packed acpi_madt_lapic_t;
684
Kyösti Mälkki2e9f0d32023-04-07 23:05:46 +0300685#define ACPI_MADT_MAX_LAPIC_ID 0xfe
686
Furquan Shaikhe0844632020-05-02 10:23:37 -0700687/* MADT: Local APIC NMI Structure */
688typedef struct acpi_madt_lapic_nmi {
689 u8 type; /* Type (4) */
690 u8 length; /* Length in bytes (6) */
691 u8 processor_id; /* ACPI processor ID */
692 u16 flags; /* MPS INTI flags */
693 u8 lint; /* Local APIC LINT# */
694} __packed acpi_madt_lapic_nmi_t;
695
Kyösti Mälkki66b5e1b2022-11-12 21:13:45 +0200696#define ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS 0xff
697#define ACPI_MADT_LX2APIC_NMI_ALL_PROCESSORS ((u32)-1)
Raul E Rangelf5552ce2021-02-11 11:27:56 -0700698
Furquan Shaikhe0844632020-05-02 10:23:37 -0700699/* MADT: I/O APIC Structure */
700typedef struct acpi_madt_ioapic {
701 u8 type; /* Type (1) */
702 u8 length; /* Length in bytes (12) */
703 u8 ioapic_id; /* I/O APIC ID */
704 u8 reserved;
705 u32 ioapic_addr; /* I/O APIC address */
706 u32 gsi_base; /* Global system interrupt base */
707} __packed acpi_madt_ioapic_t;
708
Raul E Rangel169302a2022-04-25 14:59:05 -0600709#define MP_IRQ_POLARITY_DEFAULT 0x0
710#define MP_IRQ_POLARITY_HIGH 0x1
711#define MP_IRQ_POLARITY_LOW 0x3
712#define MP_IRQ_POLARITY_MASK 0x3
713#define MP_IRQ_TRIGGER_DEFAULT 0x0
714#define MP_IRQ_TRIGGER_EDGE 0x4
715#define MP_IRQ_TRIGGER_LEVEL 0xc
716#define MP_IRQ_TRIGGER_MASK 0xc
717
Furquan Shaikhe0844632020-05-02 10:23:37 -0700718/* MADT: Interrupt Source Override Structure */
719typedef struct acpi_madt_irqoverride {
720 u8 type; /* Type (2) */
721 u8 length; /* Length in bytes (10) */
722 u8 bus; /* ISA (0) */
723 u8 source; /* Bus-relative int. source (IRQ) */
724 u32 gsirq; /* Global system interrupt */
725 u16 flags; /* MPS INTI flags */
726} __packed acpi_madt_irqoverride_t;
727
728/* MADT: Processor Local x2APIC Structure */
729typedef struct acpi_madt_lx2apic {
730 u8 type; /* Type (9) */
731 u8 length; /* Length in bytes (16) */
732 u16 reserved;
733 u32 x2apic_id; /* Local x2APIC ID */
734 u32 flags; /* Same as Local APIC flags */
735 u32 processor_id; /* ACPI processor ID */
736} __packed acpi_madt_lx2apic_t;
737
738/* MADT: Processor Local x2APIC NMI Structure */
739typedef struct acpi_madt_lx2apic_nmi {
740 u8 type; /* Type (10) */
741 u8 length; /* Length in bytes (12) */
742 u16 flags; /* Same as MPS INTI flags */
743 u32 processor_id; /* ACPI processor ID */
744 u8 lint; /* Local APIC LINT# */
745 u8 reserved[3];
746} __packed acpi_madt_lx2apic_nmi_t;
747
748#define ACPI_DBG2_PORT_SERIAL 0x8000
749#define ACPI_DBG2_PORT_SERIAL_16550 0x0000
750#define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001
751#define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003
752#define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e
753#define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f
754#define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010
755#define ACPI_DBG2_PORT_IEEE1394 0x8001
756#define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000
757#define ACPI_DBG2_PORT_USB 0x8002
758#define ACPI_DBG2_PORT_USB_XHCI 0x0000
759#define ACPI_DBG2_PORT_USB_EHCI 0x0001
760#define ACPI_DBG2_PORT_NET 0x8003
761
762/* DBG2: Microsoft Debug Port Table 2 header */
763typedef struct acpi_dbg2_header {
764 acpi_header_t header;
765 uint32_t devices_offset;
766 uint32_t devices_count;
767} __attribute__((packed)) acpi_dbg2_header_t;
768
769/* DBG2: Microsoft Debug Port Table 2 device entry */
770typedef struct acpi_dbg2_device {
771 uint8_t revision;
772 uint16_t length;
773 uint8_t address_count;
774 uint16_t namespace_string_length;
775 uint16_t namespace_string_offset;
776 uint16_t oem_data_length;
777 uint16_t oem_data_offset;
778 uint16_t port_type;
779 uint16_t port_subtype;
780 uint8_t reserved[2];
781 uint16_t base_address_offset;
782 uint16_t address_size_offset;
783} __attribute__((packed)) acpi_dbg2_device_t;
784
785/* FADT (Fixed ACPI Description Table) */
786typedef struct acpi_fadt {
787 acpi_header_t header;
788 u32 firmware_ctrl;
789 u32 dsdt;
790 u8 reserved; /* Should be 0 */
791 u8 preferred_pm_profile;
792 u16 sci_int;
793 u32 smi_cmd;
794 u8 acpi_enable;
795 u8 acpi_disable;
796 u8 s4bios_req;
797 u8 pstate_cnt;
798 u32 pm1a_evt_blk;
799 u32 pm1b_evt_blk;
800 u32 pm1a_cnt_blk;
801 u32 pm1b_cnt_blk;
802 u32 pm2_cnt_blk;
803 u32 pm_tmr_blk;
804 u32 gpe0_blk;
805 u32 gpe1_blk;
806 u8 pm1_evt_len;
807 u8 pm1_cnt_len;
808 u8 pm2_cnt_len;
809 u8 pm_tmr_len;
810 u8 gpe0_blk_len;
811 u8 gpe1_blk_len;
812 u8 gpe1_base;
813 u8 cst_cnt;
814 u16 p_lvl2_lat;
815 u16 p_lvl3_lat;
816 u16 flush_size;
817 u16 flush_stride;
818 u8 duty_offset;
819 u8 duty_width;
820 u8 day_alrm;
821 u8 mon_alrm;
822 u8 century;
823 u16 iapc_boot_arch;
824 u8 res2;
825 u32 flags;
826 acpi_addr_t reset_reg;
827 u8 reset_value;
Elyes Haouasb55ac092022-02-16 14:42:19 +0100828 u16 ARM_boot_arch; /* Must be zero if ACPI Revision <= 5.0 */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100829 u8 FADT_MinorVersion; /* Must be zero if ACPI Revision <= 5.0 */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700830 u32 x_firmware_ctl_l;
831 u32 x_firmware_ctl_h;
832 u32 x_dsdt_l;
833 u32 x_dsdt_h;
834 acpi_addr_t x_pm1a_evt_blk;
835 acpi_addr_t x_pm1b_evt_blk;
836 acpi_addr_t x_pm1a_cnt_blk;
837 acpi_addr_t x_pm1b_cnt_blk;
838 acpi_addr_t x_pm2_cnt_blk;
839 acpi_addr_t x_pm_tmr_blk;
840 acpi_addr_t x_gpe0_blk;
841 acpi_addr_t x_gpe1_blk;
842 /* Revision 5 */
843 acpi_addr_t sleep_control_reg;
844 acpi_addr_t sleep_status_reg;
845 /* Revision 6 */
846 u64 hypervisor_vendor_identity;
847} __packed acpi_fadt_t;
848
849/* FADT TABLE Revision values */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100850#define ACPI_FADT_REV_ACPI_1 1
851#define ACPI_FADT_REV_ACPI_2 3
852#define ACPI_FADT_REV_ACPI_3 4
853#define ACPI_FADT_REV_ACPI_4 4
854#define ACPI_FADT_REV_ACPI_5 5
855#define ACPI_FADT_REV_ACPI_6 6
856
857/* FADT Minor Version value:
858 * Bits 0-3: minor version
859 * Bits 4-7: Errata
860 * value of 1 means this is compatible with Errata A,
861 * value of 2 would be compatible with Errata B, and so on
862 * Version 6.3 Errata A would be: (1 << 4) | 3
863 */
864#define ACPI_FADT_MINOR_VERSION_0 0 /* coreboot currently use this version */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700865
866/* Flags for p_lvl2_lat and p_lvl3_lat */
867#define ACPI_FADT_C2_NOT_SUPPORTED 101
868#define ACPI_FADT_C3_NOT_SUPPORTED 1001
869
870/* FADT Feature Flags */
871#define ACPI_FADT_WBINVD (1 << 0)
872#define ACPI_FADT_WBINVD_FLUSH (1 << 1)
873#define ACPI_FADT_C1_SUPPORTED (1 << 2)
874#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
875#define ACPI_FADT_POWER_BUTTON (1 << 4)
876#define ACPI_FADT_SLEEP_BUTTON (1 << 5)
877#define ACPI_FADT_FIXED_RTC (1 << 6)
878#define ACPI_FADT_S4_RTC_WAKE (1 << 7)
879#define ACPI_FADT_32BIT_TIMER (1 << 8)
880#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
881#define ACPI_FADT_RESET_REGISTER (1 << 10)
882#define ACPI_FADT_SEALED_CASE (1 << 11)
883#define ACPI_FADT_HEADLESS (1 << 12)
884#define ACPI_FADT_SLEEP_TYPE (1 << 13)
885#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
886#define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
887#define ACPI_FADT_S4_RTC_VALID (1 << 16)
888#define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
889#define ACPI_FADT_APIC_CLUSTER (1 << 18)
890#define ACPI_FADT_APIC_PHYSICAL (1 << 19)
891/* Bits 20-31: reserved ACPI 3.0 & 4.0 */
892#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20)
893#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21)
894/* bits 22-31: reserved since ACPI 5.0 */
895
896/* FADT Boot Architecture Flags */
897#define ACPI_FADT_LEGACY_DEVICES (1 << 0)
898#define ACPI_FADT_8042 (1 << 1)
899#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
900#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
901#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
902#define ACPI_FADT_NO_CMOS_RTC (1 << 5)
903#define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */
904
905/* FADT ARM Boot Architecture Flags */
906#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
907#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
908/* bits 2-16: reserved since ACPI 5.1 */
909
910/* FADT Preferred Power Management Profile */
911enum acpi_preferred_pm_profiles {
912 PM_UNSPECIFIED = 0,
913 PM_DESKTOP = 1,
914 PM_MOBILE = 2,
915 PM_WORKSTATION = 3,
916 PM_ENTERPRISE_SERVER = 4,
917 PM_SOHO_SERVER = 5,
918 PM_APPLIANCE_PC = 6,
919 PM_PERFORMANCE_SERVER = 7,
920 PM_TABLET = 8, /* ACPI 5.0 & greater */
921};
922
923/* FACS (Firmware ACPI Control Structure) */
924typedef struct acpi_facs {
925 char signature[4]; /* "FACS" */
926 u32 length; /* Length in bytes (>= 64) */
927 u32 hardware_signature; /* Hardware signature */
928 u32 firmware_waking_vector; /* Firmware waking vector */
929 u32 global_lock; /* Global lock */
930 u32 flags; /* FACS flags */
931 u32 x_firmware_waking_vector_l; /* X FW waking vector, low */
932 u32 x_firmware_waking_vector_h; /* X FW waking vector, high */
933 u8 version; /* FACS version */
934 u8 resv1[3]; /* This value is 0 */
935 u32 ospm_flags; /* 64BIT_WAKE_F */
936 u8 resv2[24]; /* This value is 0 */
937} __packed acpi_facs_t;
938
939/* FACS flags */
940#define ACPI_FACS_S4BIOS_F (1 << 0)
941#define ACPI_FACS_64BIT_WAKE_F (1 << 1)
942/* Bits 31..2: reserved */
943
944/* ECDT (Embedded Controller Boot Resources Table) */
945typedef struct acpi_ecdt {
946 acpi_header_t header;
947 acpi_addr_t ec_control; /* EC control register */
948 acpi_addr_t ec_data; /* EC data register */
949 u32 uid; /* UID */
950 u8 gpe_bit; /* GPE bit */
951 u8 ec_id[]; /* EC ID */
952} __packed acpi_ecdt_t;
953
954/* HEST (Hardware Error Source Table) */
955typedef struct acpi_hest {
956 acpi_header_t header;
957 u32 error_source_count;
958 /* error_source_struct(s) */
959} __packed acpi_hest_t;
960
961/* Error Source Descriptors */
962typedef struct acpi_hest_esd {
963 u16 type;
964 u16 source_id;
965 u16 resv;
966 u8 flags;
967 u8 enabled;
968 u32 prealloc_erecords; /* The number of error records to
969 * pre-allocate for this error source.
970 */
971 u32 max_section_per_record;
972} __packed acpi_hest_esd_t;
973
974/* Hardware Error Notification */
975typedef struct acpi_hest_hen {
976 u8 type;
977 u8 length;
978 u16 conf_we; /* Configuration Write Enable */
979 u32 poll_interval;
980 u32 vector;
981 u32 sw2poll_threshold_val;
982 u32 sw2poll_threshold_win;
983 u32 error_threshold_val;
984 u32 error_threshold_win;
985} __packed acpi_hest_hen_t;
986
987/* BERT (Boot Error Record Table) */
988typedef struct acpi_bert {
989 acpi_header_t header;
990 u32 region_length;
991 u64 error_region;
992} __packed acpi_bert_t;
993
994/* Generic Error Data Entry */
995typedef struct acpi_hest_generic_data {
996 guid_t section_type;
997 u32 error_severity;
998 u16 revision;
999 u8 validation_bits;
1000 u8 flags;
1001 u32 data_length;
1002 guid_t fru_id;
1003 u8 fru_text[20];
1004 /* error data */
1005} __packed acpi_hest_generic_data_t;
1006
1007/* Generic Error Data Entry v300 */
1008typedef struct acpi_hest_generic_data_v300 {
1009 guid_t section_type;
1010 u32 error_severity;
1011 u16 revision;
1012 u8 validation_bits;
1013 u8 flags; /* see CPER Section Descriptor, Flags field */
1014 u32 data_length;
1015 guid_t fru_id;
1016 u8 fru_text[20];
1017 cper_timestamp_t timestamp;
1018 /* error data */
1019} __packed acpi_hest_generic_data_v300_t;
1020#define HEST_GENERIC_ENTRY_V300 0x300
1021
1022/* Both Generic Error Status & Generic Error Data Entry, Error Severity field */
1023#define ACPI_GENERROR_SEV_RECOVERABLE 0
1024#define ACPI_GENERROR_SEV_FATAL 1
1025#define ACPI_GENERROR_SEV_CORRECTED 2
1026#define ACPI_GENERROR_SEV_NONE 3
1027
1028/* Generic Error Data Entry, Validation Bits field */
1029#define ACPI_GENERROR_VALID_FRUID BIT(0)
1030#define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1)
1031#define ACPI_GENERROR_VALID_TIMESTAMP BIT(2)
1032
Felix Held403fa862021-07-26 22:43:00 +02001033/*
1034 * Generic Error Status Block
1035 *
1036 * If there is a raw data section at the end of the generic error status block after the
1037 * zero or more generic error data entries, raw_data_length indicates the length of the raw
1038 * section and raw_data_offset is the offset of the beginning of the raw data section from
1039 * the start of the acpi_generic_error_status block it is contained in. So if raw_data_length
1040 * is non-zero, raw_data_offset must be at least sizeof(acpi_generic_error_status_t).
1041 */
Furquan Shaikhe0844632020-05-02 10:23:37 -07001042typedef struct acpi_generic_error_status {
1043 u32 block_status;
1044 u32 raw_data_offset; /* must follow any generic entries */
1045 u32 raw_data_length;
1046 u32 data_length; /* generic data */
1047 u32 error_severity;
1048 /* Generic Error Data structures, zero or more entries */
1049} __packed acpi_generic_error_status_t;
1050
1051/* Generic Status Block, Block Status values */
1052#define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0)
1053#define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1)
1054#define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2)
1055#define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3)
1056#define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4
1057#define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff
1058#define GENERIC_ERR_STS_ENTRY_COUNT_MASK \
1059 (GENERIC_ERR_STS_ENTRY_COUNT_MAX \
1060 << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT)
1061
1062typedef struct acpi_cstate {
1063 u8 ctype;
1064 u16 latency;
1065 u32 power;
1066 acpi_addr_t resource;
1067} __packed acpi_cstate_t;
1068
Jason Gleneskca36aed2020-09-15 21:01:57 -07001069struct acpi_sw_pstate {
1070 u32 core_freq;
1071 u32 power;
1072 u32 transition_latency;
1073 u32 bus_master_latency;
1074 u32 control_value;
1075 u32 status_value;
1076} __packed;
1077
1078struct acpi_xpss_sw_pstate {
1079 u64 core_freq;
1080 u64 power;
1081 u64 transition_latency;
1082 u64 bus_master_latency;
1083 u64 control_value;
1084 u64 status_value;
1085 u64 control_mask;
1086 u64 status_mask;
1087} __packed;
1088
Furquan Shaikhe0844632020-05-02 10:23:37 -07001089typedef struct acpi_tstate {
1090 u32 percent;
1091 u32 power;
1092 u32 latency;
1093 u32 control;
1094 u32 status;
1095} __packed acpi_tstate_t;
1096
Raul E Rangelc7048322021-04-19 15:58:25 -06001097enum acpi_lpi_state_flags {
1098 ACPI_LPI_STATE_DISABLED = 0,
1099 ACPI_LPI_STATE_ENABLED
1100};
1101
1102/* Low Power Idle State */
1103struct acpi_lpi_state {
1104 u32 min_residency_us;
1105 u32 worst_case_wakeup_latency_us;
1106 u32 flags;
1107 u32 arch_context_lost_flags;
1108 u32 residency_counter_frequency_hz;
1109 u32 enabled_parent_state;
1110 acpi_addr_t entry_method;
1111 acpi_addr_t residency_counter_register;
1112 acpi_addr_t usage_counter_register;
1113 const char *state_name;
1114};
1115
Furquan Shaikhe0844632020-05-02 10:23:37 -07001116/* Port types for ACPI _UPC object */
1117enum acpi_upc_type {
1118 UPC_TYPE_A,
1119 UPC_TYPE_MINI_AB,
1120 UPC_TYPE_EXPRESSCARD,
1121 UPC_TYPE_USB3_A,
1122 UPC_TYPE_USB3_B,
1123 UPC_TYPE_USB3_MICRO_B,
1124 UPC_TYPE_USB3_MICRO_AB,
1125 UPC_TYPE_USB3_POWER_B,
1126 UPC_TYPE_C_USB2_ONLY,
1127 UPC_TYPE_C_USB2_SS_SWITCH,
1128 UPC_TYPE_C_USB2_SS,
1129 UPC_TYPE_PROPRIETARY = 0xff,
1130 /*
1131 * The following types are not directly defined in the ACPI
1132 * spec but are used by coreboot to identify a USB device type.
1133 */
1134 UPC_TYPE_INTERNAL = 0xff,
1135 UPC_TYPE_UNUSED,
1136 UPC_TYPE_HUB
1137};
1138
1139enum acpi_ipmi_interface_type {
1140 IPMI_INTERFACE_RESERVED = 0,
1141 IPMI_INTERFACE_KCS,
1142 IPMI_INTERFACE_SMIC,
1143 IPMI_INTERFACE_BT,
1144 IPMI_INTERFACE_SSIF,
1145};
1146
1147#define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0)
1148#define ACPI_IPMI_INT_TYPE_SCI (1 << 0)
1149#define ACPI_IPMI_INT_TYPE_APIC (1 << 1)
1150
1151/* ACPI IPMI 2.0 */
1152struct acpi_spmi {
1153 acpi_header_t header;
1154 u8 interface_type;
1155 u8 reserved;
1156 u16 specification_revision;
1157 u8 interrupt_type;
1158 u8 gpe;
1159 u8 reserved2;
1160 u8 pci_device_flag;
1161
1162 u32 global_system_interrupt;
1163 acpi_addr_t base_address;
1164 union {
1165 struct {
1166 u8 pci_segment_group;
1167 u8 pci_bus;
1168 u8 pci_device;
1169 u8 pci_function;
1170 };
1171 u8 uid[4];
1172 };
1173 u8 reserved3;
1174} __packed;
1175
Rocky Phaguraeff07132021-01-10 15:42:50 -08001176/* EINJ APEI Standard Definitions */
1177/* EINJ Error Types
1178 Refer to the ACPI spec, EINJ section, for more info on bit definitions
1179*/
1180#define ACPI_EINJ_CPU_CE (1 << 0)
1181#define ACPI_EINJ_CPU_UCE (1 << 1)
1182#define ACPI_EINJ_CPU_UCE_FATAL (1 << 2)
1183#define ACPI_EINJ_MEM_CE (1 << 3)
1184#define ACPI_EINJ_MEM_UCE (1 << 4)
1185#define ACPI_EINJ_MEM_UCE_FATAL (1 << 5)
1186#define ACPI_EINJ_PCIE_CE (1 << 6)
1187#define ACPI_EINJ_PCIE_UCE_NON_FATAL (1 << 7)
1188#define ACPI_EINJ_PCIE_UCE_FATAL (1 << 8)
1189#define ACPI_EINJ_PLATFORM_CE (1 << 9)
1190#define ACPI_EINJ_PLATFORM_UCE (1 << 10)
1191#define ACPI_EINJ_PLATFORM_UCE_FATAL (1 << 11)
1192#define ACPI_EINJ_VENDOR_DEFINED (1 << 31)
1193#define ACPI_EINJ_DEFAULT_CAP (ACPI_EINJ_MEM_CE | ACPI_EINJ_MEM_UCE | \
1194 ACPI_EINJ_PCIE_CE | ACPI_EINJ_PCIE_UCE_FATAL)
1195
1196/* EINJ actions */
1197#define ACTION_COUNT 9
1198#define BEGIN_INJECT_OP 0x00
1199#define GET_TRIGGER_ACTION_TABLE 0x01
1200#define SET_ERROR_TYPE 0x02
1201#define GET_ERROR_TYPE 0x03
1202#define END_INJECT_OP 0x04
1203#define EXECUTE_INJECT_OP 0x05
1204#define CHECK_BUSY_STATUS 0x06
1205#define GET_CMD_STATUS 0x07
1206#define SET_ERROR_TYPE_WITH_ADDRESS 0x08
1207#define TRIGGER_ERROR 0xFF
1208
1209/* EINJ Instructions */
1210#define READ_REGISTER 0x00
1211#define READ_REGISTER_VALUE 0x01
1212#define WRITE_REGISTER 0x02
1213#define WRITE_REGISTER_VALUE 0x03
1214#define NO_OP 0x04
1215
1216/* EINJ (Error Injection Table) */
1217typedef struct acpi_gen_regaddr1 {
1218 u8 space_id; /* Address space ID */
1219 u8 bit_width; /* Register size in bits */
1220 u8 bit_offset; /* Register bit offset */
1221 u8 access_size; /* Access size since ACPI 2.0c */
1222 u64 addr; /* Register address */
1223} __packed acpi_addr64_t;
1224
1225/* Instruction entry */
1226typedef struct acpi_einj_action_table {
1227 u8 action;
1228 u8 instruction;
1229 u16 flags;
1230 acpi_addr64_t reg;
1231 u64 value;
1232 u64 mask;
1233} __packed acpi_einj_action_table_t;
1234
1235typedef struct acpi_injection_header {
1236 u32 einj_header_size;
1237 u32 flags;
1238 u32 entry_count;
1239} __packed acpi_injection_header_t;
1240
1241typedef struct acpi_einj_trigger_table {
1242 u32 header_size;
1243 u32 revision;
1244 u32 table_size;
1245 u32 entry_count;
1246 acpi_einj_action_table_t trigger_action[1];
1247} __packed acpi_einj_trigger_table_t;
1248
1249typedef struct set_error_type {
1250 u32 errtype;
1251 u32 vendorerrortype;
1252 u32 flags;
1253 u32 apicid;
1254 u64 memaddr;
1255 u64 memrange;
1256 u32 pciesbdf;
1257} __packed set_error_type_t;
1258
1259#define EINJ_PARAM_NUM 6
1260typedef struct acpi_einj_smi {
1261 u64 op_state;
1262 u64 err_inject[EINJ_PARAM_NUM];
1263 u64 trigger_action_table;
1264 u64 err_inj_cap;
1265 u64 op_status;
1266 u64 cmd_sts;
1267 u64 einj_addr;
1268 u64 einj_addr_msk;
1269 set_error_type_t setaddrtable;
1270 u64 reserved[50];
1271} __packed acpi_einj_smi_t;
1272
1273/* EINJ Flags */
1274#define EINJ_DEF_TRIGGER_PORT 0xb2
1275#define FLAG_PRESERVE 0x01
1276#define FLAG_IGNORE 0x00
1277
1278/* EINJ Registers */
1279#define EINJ_REG_MEMORY(address) \
1280 { \
1281 .space_id = ACPI_ADDRESS_SPACE_MEMORY, \
1282 .bit_width = 64, \
1283 .bit_offset = 0, \
1284 .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \
1285 .addr = address}
1286
1287#define EINJ_REG_IO() \
1288 { \
1289 .space_id = ACPI_ADDRESS_SPACE_IO, \
1290 .bit_width = 0x10, \
1291 .bit_offset = 0, \
1292 .access_size = ACPI_ACCESS_SIZE_WORD_ACCESS, \
1293 .addr = EINJ_DEF_TRIGGER_PORT} /* HW dependent code can override this also */
1294
1295typedef struct acpi_einj {
1296 acpi_header_t header;
1297 acpi_injection_header_t inj_header;
1298 acpi_einj_action_table_t action_table[ACTION_COUNT];
1299} __packed acpi_einj_t;
1300
Arthur Heymanse7aaf042023-06-07 12:12:45 +02001301/* SPCR (Serial Port Console Redirection Table) */
1302typedef struct acpi_spcr {
1303 acpi_header_t header;
1304 uint8_t interface_type;
1305 uint8_t reserved[3];
1306 acpi_addr_t base_address;
1307 uint8_t interrupt_type;
1308 uint8_t irq;
1309 uint32_t global_system_interrupt;
1310 uint8_t configured_baudrate;
1311 uint8_t parity;
1312 uint8_t stop_bits;
1313 uint8_t flow_control;
1314 uint8_t terminal_type;
1315 uint8_t language;
1316 uint16_t pci_did;
1317 uint16_t pci_vid;
1318 uint8_t pci_bus;
1319 uint8_t pci_dev;
1320 uint8_t pci_fun;
1321 uint32_t pci_flags;
1322 uint8_t pci_segment;
1323 uint32_t uart_clock;
1324 uint32_t precise_baud_rate;
1325 uint16_t namespace_string_length;
1326 uint16_t namespace_string_offset;
1327 char namespacestring[];
1328} __packed acpi_spcr_t;
1329_Static_assert(sizeof(acpi_spcr_t) == 88, "acpi_spcr_t must have an 88 byte size\n");
1330
Arthur Heymans2e7e2d92022-03-03 22:28:27 +01001331uintptr_t get_coreboot_rsdp(void);
Rocky Phaguraeff07132021-01-10 15:42:50 -08001332void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions);
1333
Furquan Shaikhe0844632020-05-02 10:23:37 -07001334unsigned long fw_cfg_acpi_tables(unsigned long start);
1335
1336/* These are implemented by the target port or north/southbridge. */
Raul E Rangel6b446b92021-11-19 11:38:35 -07001337void preload_acpi_dsdt(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001338unsigned long write_acpi_tables(unsigned long addr);
1339unsigned long acpi_fill_madt(unsigned long current);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001340
Furquan Shaikhe0844632020-05-02 10:23:37 -07001341void acpi_fill_fadt(acpi_fadt_t *fadt);
Angel Pons79572e42020-07-13 00:17:43 +02001342void arch_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001343void soc_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkki02fd15d2020-06-02 03:34:43 +03001344void mainboard_fill_fadt(acpi_fadt_t *fadt);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001345
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001346void acpi_fill_gnvs(void);
Kyösti Mälkki3dc17922021-03-16 19:01:48 +02001347void acpi_fill_cnvs(void);
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001348
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001349unsigned long acpi_fill_lpit(unsigned long current);
1350
Furquan Shaikhe0844632020-05-02 10:23:37 -07001351/* These can be used by the target port. */
1352u8 acpi_checksum(u8 *table, u32 length);
1353
1354void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
1355
Jonathan Zhang3dcafa82022-05-11 13:11:20 -07001356/* Create CXL Early Discovery Table */
1357void acpi_create_cedt(acpi_cedt_t *cedt,
1358 unsigned long (*acpi_fill_cedt)(unsigned long current));
1359/* Create a CXL Host Bridge Structure for CEDT */
1360int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base);
1361/* Create a CXL Fixed Memory Window Structure for CEDT */
1362int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size,
1363 u8 eniw, u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target);
1364
Kyösti Mälkkic7da0272021-06-08 11:37:08 +03001365int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr);
Kyösti Mälkki9ac1fb72023-04-07 22:39:53 +03001366
Kyösti Mälkki2e9f0d32023-04-07 23:05:46 +03001367unsigned long acpi_create_madt_one_lapic(unsigned long current, u32 cpu, u32 apic);
Kyösti Mälkki9ac1fb72023-04-07 22:39:53 +03001368
1369unsigned long acpi_create_madt_lapic_nmis(unsigned long current);
1370
Furquan Shaikhe0844632020-05-02 10:23:37 -07001371int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
Naresh Solanki76835cc2023-01-20 19:13:02 +01001372int acpi_create_srat_x2apic(acpi_srat_x2apic_t *x2apic, u32 node, u32 apic);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001373int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek,
1374 u32 flags);
Jonathan Zhang3164b642021-04-21 17:51:31 -07001375/*
1376 * Given the Generic Initiator device's BDF, the proximity domain's ID
1377 * and flag, create Generic Initiator Affinity structure in SRAT.
1378 */
1379int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain,
1380 u16 seg, u8 bus, u8 dev, u8 func, u32 flags);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001381unsigned long acpi_create_srat_lapics(unsigned long current);
1382void acpi_create_srat(acpi_srat_t *srat,
1383 unsigned long (*acpi_fill_srat)(unsigned long current));
1384
1385void acpi_create_slit(acpi_slit_t *slit,
1386 unsigned long (*acpi_fill_slit)(unsigned long current));
1387
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001388/*
1389 * Create a Memory Proximity Domain Attributes structure for HMAT,
1390 * given proximity domain for the attached initiaor, and
1391 * proximimity domain for the memory.
1392 */
1393int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory);
Martin Roth0949e732021-10-01 14:28:22 -06001394/* Create Heterogeneous Memory Attribute Table */
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001395void acpi_create_hmat(acpi_hmat_t *hmat,
1396 unsigned long (*acpi_fill_hmat)(unsigned long current));
1397
Furquan Shaikhe0844632020-05-02 10:23:37 -07001398void acpi_create_vfct(const struct device *device,
1399 acpi_vfct_t *vfct,
1400 unsigned long (*acpi_fill_vfct)(const struct device *device,
1401 acpi_vfct_t *vfct_struct,
1402 unsigned long current));
1403
1404void acpi_create_ipmi(const struct device *device,
1405 struct acpi_spmi *spmi,
1406 const u16 ipmi_revision,
1407 const acpi_addr_t *addr,
1408 const enum acpi_ipmi_interface_type type,
1409 const s8 gpe_interrupt,
1410 const u32 apic_interrupt,
1411 const u32 uid);
1412
1413void acpi_create_ivrs(acpi_ivrs_t *ivrs,
1414 unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct,
1415 unsigned long current));
1416
Jason Glenesk61624b22020-11-02 20:06:23 -08001417void acpi_create_crat(struct acpi_crat_header *crat,
1418 unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct,
1419 unsigned long current));
1420
Furquan Shaikhe0844632020-05-02 10:23:37 -07001421unsigned long acpi_write_hpet(const struct device *device, unsigned long start,
1422 acpi_rsdp_t *rsdp);
1423
1424/* cpu/intel/speedstep/acpi.c */
1425void generate_cpu_entries(const struct device *device);
1426
Furquan Shaikhe0844632020-05-02 10:23:37 -07001427unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
1428 const struct device *dev, uint8_t access_size);
1429void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
1430 unsigned long (*acpi_fill_dmar)(unsigned long));
1431unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
1432 u16 segment, u64 bar);
1433unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment,
1434 u64 bar, u64 limit);
1435unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags,
1436 u16 segment);
1437unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr,
1438 u32 proximity_domain);
1439unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number,
1440 const char *device_name);
John Zhao6edbb182021-03-24 11:55:09 -07001441unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags,
John Zhao091532d2021-04-17 16:03:21 -07001442 u16 segment);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001443void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current);
1444void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current);
1445void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current);
John Zhao6edbb182021-03-24 11:55:09 -07001446void acpi_dmar_satc_fixup(unsigned long base, unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001447unsigned long acpi_create_dmar_ds_pci_br(unsigned long current,
1448 u8 bus, u8 dev, u8 fn);
1449unsigned long acpi_create_dmar_ds_pci(unsigned long current,
1450 u8 bus, u8 dev, u8 fn);
1451unsigned long acpi_create_dmar_ds_ioapic(unsigned long current,
1452 u8 enumeration_id,
1453 u8 bus, u8 dev, u8 fn);
Arthur Heymansbc8f8592022-12-02 13:17:39 +01001454unsigned long acpi_create_dmar_ds_ioapic_from_hw(unsigned long current,
1455 u32 addr, u8 bus, u8 dev, u8 fn);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001456unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current,
1457 u8 enumeration_id,
1458 u8 bus, u8 dev, u8 fn);
1459void acpi_write_hest(acpi_hest_t *hest,
1460 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest));
1461
1462unsigned long acpi_create_hest_error_source(acpi_hest_t *hest,
1463 acpi_hest_esd_t *esd, u16 type, void *data, u16 len);
1464
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001465unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid);
1466
Felix Heldf7dbf4a2021-06-07 16:56:04 +02001467/* chipsets that select ACPI_BERT must implement this function */
Felix Held29405482021-05-28 16:01:57 +02001468enum cb_err acpi_soc_get_bert_region(void **region, size_t *length);
Francois Toguo522e0db2021-01-21 09:55:19 -08001469
Furquan Shaikhe0844632020-05-02 10:23:37 -07001470/* For ACPI S3 support. */
Kyösti Mälkkia4c0e1a2020-06-18 08:28:12 +03001471void __noreturn acpi_resume(void *wake_vec);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001472void mainboard_suspend_resume(void);
1473void *acpi_find_wakeup_vector(void);
1474
1475/* ACPI_Sn assignments are defined to always equal the sleep state numbers */
1476enum {
1477 ACPI_S0 = 0,
1478 ACPI_S1 = 1,
1479 ACPI_S2 = 2,
1480 ACPI_S3 = 3,
1481 ACPI_S4 = 4,
1482 ACPI_S5 = 5,
1483};
1484
1485#if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \
1486 || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES)
1487/* Given the provided PM1 control register return the ACPI sleep type. */
1488static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt)
1489{
1490 switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) {
1491 case SLP_TYP_S0: return ACPI_S0;
1492 case SLP_TYP_S1: return ACPI_S1;
1493 case SLP_TYP_S3: return ACPI_S3;
1494 case SLP_TYP_S4: return ACPI_S4;
1495 case SLP_TYP_S5: return ACPI_S5;
1496 }
1497 return -1;
1498}
1499#endif
1500
Kyösti Mälkkie0d38682020-06-07 12:01:58 +03001501uint8_t acpi_get_preferred_pm_profile(void);
1502
Furquan Shaikhe0844632020-05-02 10:23:37 -07001503/* Returns ACPI_Sx values. */
1504int acpi_get_sleep_type(void);
1505
1506/* Read and clear GPE status */
1507int acpi_get_gpe(int gpe);
1508
Kyösti Mälkki0a9e72e2019-08-11 01:22:28 +03001509/* Once we enter payload, is SMI handler installed and capable of
1510 responding to APM_CNT Advanced Power Management Control commands. */
1511static inline int permanent_smi_handler(void)
1512{
1513 return CONFIG(HAVE_SMI_HANDLER);
1514}
1515
Furquan Shaikhe0844632020-05-02 10:23:37 -07001516static inline int acpi_s3_resume_allowed(void)
1517{
1518 return CONFIG(HAVE_ACPI_RESUME);
1519}
1520
Furquan Shaikhe0844632020-05-02 10:23:37 -07001521static inline int acpi_is_wakeup_s3(void)
1522{
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001523 if (!acpi_s3_resume_allowed())
1524 return 0;
Furquan Shaikhe0844632020-05-02 10:23:37 -07001525
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001526 if (ENV_ROMSTAGE_OR_BEFORE)
1527 return (acpi_get_sleep_type() == ACPI_S3);
1528
Kyösti Mälkkiac0dc4a2020-11-18 07:40:21 +02001529 return romstage_handoff_is_resume();
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001530}
Furquan Shaikhe0844632020-05-02 10:23:37 -07001531
1532static inline uintptr_t acpi_align_current(uintptr_t current)
1533{
1534 return ALIGN_UP(current, 16);
1535}
1536
1537/* ACPI table revisions should match the revision of the ACPI spec
1538 * supported. This function keeps the table versions synced. This could
1539 * be made into a weak function if there is ever a need to override the
1540 * coreboot default ACPI spec version supported. */
1541int get_acpi_table_revision(enum acpi_tables table);
Elyes Haouas8b950f42022-02-16 12:08:16 +01001542u8 get_acpi_fadt_minor_version(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001543
Kyösti Mälkki94e04652020-06-01 13:26:22 +03001544#endif // !defined(__ASSEMBLER__) && !defined(__ACPI__)
Furquan Shaikhe0844632020-05-02 10:23:37 -07001545
Furquan Shaikh56eafbb2020-04-30 18:38:55 -07001546#endif /* __ACPI_ACPI_H__ */