blob: e99f5b9c72434476736a22904dfc8ae66accc002 [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
685/* MADT: Local APIC NMI Structure */
686typedef struct acpi_madt_lapic_nmi {
687 u8 type; /* Type (4) */
688 u8 length; /* Length in bytes (6) */
689 u8 processor_id; /* ACPI processor ID */
690 u16 flags; /* MPS INTI flags */
691 u8 lint; /* Local APIC LINT# */
692} __packed acpi_madt_lapic_nmi_t;
693
Kyösti Mälkki66b5e1b2022-11-12 21:13:45 +0200694#define ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS 0xff
695#define ACPI_MADT_LX2APIC_NMI_ALL_PROCESSORS ((u32)-1)
Raul E Rangelf5552ce2021-02-11 11:27:56 -0700696
Furquan Shaikhe0844632020-05-02 10:23:37 -0700697/* MADT: I/O APIC Structure */
698typedef struct acpi_madt_ioapic {
699 u8 type; /* Type (1) */
700 u8 length; /* Length in bytes (12) */
701 u8 ioapic_id; /* I/O APIC ID */
702 u8 reserved;
703 u32 ioapic_addr; /* I/O APIC address */
704 u32 gsi_base; /* Global system interrupt base */
705} __packed acpi_madt_ioapic_t;
706
Raul E Rangel169302a2022-04-25 14:59:05 -0600707#define MP_IRQ_POLARITY_DEFAULT 0x0
708#define MP_IRQ_POLARITY_HIGH 0x1
709#define MP_IRQ_POLARITY_LOW 0x3
710#define MP_IRQ_POLARITY_MASK 0x3
711#define MP_IRQ_TRIGGER_DEFAULT 0x0
712#define MP_IRQ_TRIGGER_EDGE 0x4
713#define MP_IRQ_TRIGGER_LEVEL 0xc
714#define MP_IRQ_TRIGGER_MASK 0xc
715
Furquan Shaikhe0844632020-05-02 10:23:37 -0700716/* MADT: Interrupt Source Override Structure */
717typedef struct acpi_madt_irqoverride {
718 u8 type; /* Type (2) */
719 u8 length; /* Length in bytes (10) */
720 u8 bus; /* ISA (0) */
721 u8 source; /* Bus-relative int. source (IRQ) */
722 u32 gsirq; /* Global system interrupt */
723 u16 flags; /* MPS INTI flags */
724} __packed acpi_madt_irqoverride_t;
725
726/* MADT: Processor Local x2APIC Structure */
727typedef struct acpi_madt_lx2apic {
728 u8 type; /* Type (9) */
729 u8 length; /* Length in bytes (16) */
730 u16 reserved;
731 u32 x2apic_id; /* Local x2APIC ID */
732 u32 flags; /* Same as Local APIC flags */
733 u32 processor_id; /* ACPI processor ID */
734} __packed acpi_madt_lx2apic_t;
735
736/* MADT: Processor Local x2APIC NMI Structure */
737typedef struct acpi_madt_lx2apic_nmi {
738 u8 type; /* Type (10) */
739 u8 length; /* Length in bytes (12) */
740 u16 flags; /* Same as MPS INTI flags */
741 u32 processor_id; /* ACPI processor ID */
742 u8 lint; /* Local APIC LINT# */
743 u8 reserved[3];
744} __packed acpi_madt_lx2apic_nmi_t;
745
746#define ACPI_DBG2_PORT_SERIAL 0x8000
747#define ACPI_DBG2_PORT_SERIAL_16550 0x0000
748#define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001
749#define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003
750#define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e
751#define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f
752#define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010
753#define ACPI_DBG2_PORT_IEEE1394 0x8001
754#define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000
755#define ACPI_DBG2_PORT_USB 0x8002
756#define ACPI_DBG2_PORT_USB_XHCI 0x0000
757#define ACPI_DBG2_PORT_USB_EHCI 0x0001
758#define ACPI_DBG2_PORT_NET 0x8003
759
760/* DBG2: Microsoft Debug Port Table 2 header */
761typedef struct acpi_dbg2_header {
762 acpi_header_t header;
763 uint32_t devices_offset;
764 uint32_t devices_count;
765} __attribute__((packed)) acpi_dbg2_header_t;
766
767/* DBG2: Microsoft Debug Port Table 2 device entry */
768typedef struct acpi_dbg2_device {
769 uint8_t revision;
770 uint16_t length;
771 uint8_t address_count;
772 uint16_t namespace_string_length;
773 uint16_t namespace_string_offset;
774 uint16_t oem_data_length;
775 uint16_t oem_data_offset;
776 uint16_t port_type;
777 uint16_t port_subtype;
778 uint8_t reserved[2];
779 uint16_t base_address_offset;
780 uint16_t address_size_offset;
781} __attribute__((packed)) acpi_dbg2_device_t;
782
783/* FADT (Fixed ACPI Description Table) */
784typedef struct acpi_fadt {
785 acpi_header_t header;
786 u32 firmware_ctrl;
787 u32 dsdt;
788 u8 reserved; /* Should be 0 */
789 u8 preferred_pm_profile;
790 u16 sci_int;
791 u32 smi_cmd;
792 u8 acpi_enable;
793 u8 acpi_disable;
794 u8 s4bios_req;
795 u8 pstate_cnt;
796 u32 pm1a_evt_blk;
797 u32 pm1b_evt_blk;
798 u32 pm1a_cnt_blk;
799 u32 pm1b_cnt_blk;
800 u32 pm2_cnt_blk;
801 u32 pm_tmr_blk;
802 u32 gpe0_blk;
803 u32 gpe1_blk;
804 u8 pm1_evt_len;
805 u8 pm1_cnt_len;
806 u8 pm2_cnt_len;
807 u8 pm_tmr_len;
808 u8 gpe0_blk_len;
809 u8 gpe1_blk_len;
810 u8 gpe1_base;
811 u8 cst_cnt;
812 u16 p_lvl2_lat;
813 u16 p_lvl3_lat;
814 u16 flush_size;
815 u16 flush_stride;
816 u8 duty_offset;
817 u8 duty_width;
818 u8 day_alrm;
819 u8 mon_alrm;
820 u8 century;
821 u16 iapc_boot_arch;
822 u8 res2;
823 u32 flags;
824 acpi_addr_t reset_reg;
825 u8 reset_value;
Elyes Haouasb55ac092022-02-16 14:42:19 +0100826 u16 ARM_boot_arch; /* Must be zero if ACPI Revision <= 5.0 */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100827 u8 FADT_MinorVersion; /* Must be zero if ACPI Revision <= 5.0 */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700828 u32 x_firmware_ctl_l;
829 u32 x_firmware_ctl_h;
830 u32 x_dsdt_l;
831 u32 x_dsdt_h;
832 acpi_addr_t x_pm1a_evt_blk;
833 acpi_addr_t x_pm1b_evt_blk;
834 acpi_addr_t x_pm1a_cnt_blk;
835 acpi_addr_t x_pm1b_cnt_blk;
836 acpi_addr_t x_pm2_cnt_blk;
837 acpi_addr_t x_pm_tmr_blk;
838 acpi_addr_t x_gpe0_blk;
839 acpi_addr_t x_gpe1_blk;
840 /* Revision 5 */
841 acpi_addr_t sleep_control_reg;
842 acpi_addr_t sleep_status_reg;
843 /* Revision 6 */
844 u64 hypervisor_vendor_identity;
845} __packed acpi_fadt_t;
846
847/* FADT TABLE Revision values */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100848#define ACPI_FADT_REV_ACPI_1 1
849#define ACPI_FADT_REV_ACPI_2 3
850#define ACPI_FADT_REV_ACPI_3 4
851#define ACPI_FADT_REV_ACPI_4 4
852#define ACPI_FADT_REV_ACPI_5 5
853#define ACPI_FADT_REV_ACPI_6 6
854
855/* FADT Minor Version value:
856 * Bits 0-3: minor version
857 * Bits 4-7: Errata
858 * value of 1 means this is compatible with Errata A,
859 * value of 2 would be compatible with Errata B, and so on
860 * Version 6.3 Errata A would be: (1 << 4) | 3
861 */
862#define ACPI_FADT_MINOR_VERSION_0 0 /* coreboot currently use this version */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700863
864/* Flags for p_lvl2_lat and p_lvl3_lat */
865#define ACPI_FADT_C2_NOT_SUPPORTED 101
866#define ACPI_FADT_C3_NOT_SUPPORTED 1001
867
868/* FADT Feature Flags */
869#define ACPI_FADT_WBINVD (1 << 0)
870#define ACPI_FADT_WBINVD_FLUSH (1 << 1)
871#define ACPI_FADT_C1_SUPPORTED (1 << 2)
872#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
873#define ACPI_FADT_POWER_BUTTON (1 << 4)
874#define ACPI_FADT_SLEEP_BUTTON (1 << 5)
875#define ACPI_FADT_FIXED_RTC (1 << 6)
876#define ACPI_FADT_S4_RTC_WAKE (1 << 7)
877#define ACPI_FADT_32BIT_TIMER (1 << 8)
878#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
879#define ACPI_FADT_RESET_REGISTER (1 << 10)
880#define ACPI_FADT_SEALED_CASE (1 << 11)
881#define ACPI_FADT_HEADLESS (1 << 12)
882#define ACPI_FADT_SLEEP_TYPE (1 << 13)
883#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
884#define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
885#define ACPI_FADT_S4_RTC_VALID (1 << 16)
886#define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
887#define ACPI_FADT_APIC_CLUSTER (1 << 18)
888#define ACPI_FADT_APIC_PHYSICAL (1 << 19)
889/* Bits 20-31: reserved ACPI 3.0 & 4.0 */
890#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20)
891#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21)
892/* bits 22-31: reserved since ACPI 5.0 */
893
894/* FADT Boot Architecture Flags */
895#define ACPI_FADT_LEGACY_DEVICES (1 << 0)
896#define ACPI_FADT_8042 (1 << 1)
897#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
898#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
899#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
900#define ACPI_FADT_NO_CMOS_RTC (1 << 5)
901#define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */
902
903/* FADT ARM Boot Architecture Flags */
904#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
905#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
906/* bits 2-16: reserved since ACPI 5.1 */
907
908/* FADT Preferred Power Management Profile */
909enum acpi_preferred_pm_profiles {
910 PM_UNSPECIFIED = 0,
911 PM_DESKTOP = 1,
912 PM_MOBILE = 2,
913 PM_WORKSTATION = 3,
914 PM_ENTERPRISE_SERVER = 4,
915 PM_SOHO_SERVER = 5,
916 PM_APPLIANCE_PC = 6,
917 PM_PERFORMANCE_SERVER = 7,
918 PM_TABLET = 8, /* ACPI 5.0 & greater */
919};
920
921/* FACS (Firmware ACPI Control Structure) */
922typedef struct acpi_facs {
923 char signature[4]; /* "FACS" */
924 u32 length; /* Length in bytes (>= 64) */
925 u32 hardware_signature; /* Hardware signature */
926 u32 firmware_waking_vector; /* Firmware waking vector */
927 u32 global_lock; /* Global lock */
928 u32 flags; /* FACS flags */
929 u32 x_firmware_waking_vector_l; /* X FW waking vector, low */
930 u32 x_firmware_waking_vector_h; /* X FW waking vector, high */
931 u8 version; /* FACS version */
932 u8 resv1[3]; /* This value is 0 */
933 u32 ospm_flags; /* 64BIT_WAKE_F */
934 u8 resv2[24]; /* This value is 0 */
935} __packed acpi_facs_t;
936
937/* FACS flags */
938#define ACPI_FACS_S4BIOS_F (1 << 0)
939#define ACPI_FACS_64BIT_WAKE_F (1 << 1)
940/* Bits 31..2: reserved */
941
942/* ECDT (Embedded Controller Boot Resources Table) */
943typedef struct acpi_ecdt {
944 acpi_header_t header;
945 acpi_addr_t ec_control; /* EC control register */
946 acpi_addr_t ec_data; /* EC data register */
947 u32 uid; /* UID */
948 u8 gpe_bit; /* GPE bit */
949 u8 ec_id[]; /* EC ID */
950} __packed acpi_ecdt_t;
951
952/* HEST (Hardware Error Source Table) */
953typedef struct acpi_hest {
954 acpi_header_t header;
955 u32 error_source_count;
956 /* error_source_struct(s) */
957} __packed acpi_hest_t;
958
959/* Error Source Descriptors */
960typedef struct acpi_hest_esd {
961 u16 type;
962 u16 source_id;
963 u16 resv;
964 u8 flags;
965 u8 enabled;
966 u32 prealloc_erecords; /* The number of error records to
967 * pre-allocate for this error source.
968 */
969 u32 max_section_per_record;
970} __packed acpi_hest_esd_t;
971
972/* Hardware Error Notification */
973typedef struct acpi_hest_hen {
974 u8 type;
975 u8 length;
976 u16 conf_we; /* Configuration Write Enable */
977 u32 poll_interval;
978 u32 vector;
979 u32 sw2poll_threshold_val;
980 u32 sw2poll_threshold_win;
981 u32 error_threshold_val;
982 u32 error_threshold_win;
983} __packed acpi_hest_hen_t;
984
985/* BERT (Boot Error Record Table) */
986typedef struct acpi_bert {
987 acpi_header_t header;
988 u32 region_length;
989 u64 error_region;
990} __packed acpi_bert_t;
991
992/* Generic Error Data Entry */
993typedef struct acpi_hest_generic_data {
994 guid_t section_type;
995 u32 error_severity;
996 u16 revision;
997 u8 validation_bits;
998 u8 flags;
999 u32 data_length;
1000 guid_t fru_id;
1001 u8 fru_text[20];
1002 /* error data */
1003} __packed acpi_hest_generic_data_t;
1004
1005/* Generic Error Data Entry v300 */
1006typedef struct acpi_hest_generic_data_v300 {
1007 guid_t section_type;
1008 u32 error_severity;
1009 u16 revision;
1010 u8 validation_bits;
1011 u8 flags; /* see CPER Section Descriptor, Flags field */
1012 u32 data_length;
1013 guid_t fru_id;
1014 u8 fru_text[20];
1015 cper_timestamp_t timestamp;
1016 /* error data */
1017} __packed acpi_hest_generic_data_v300_t;
1018#define HEST_GENERIC_ENTRY_V300 0x300
1019
1020/* Both Generic Error Status & Generic Error Data Entry, Error Severity field */
1021#define ACPI_GENERROR_SEV_RECOVERABLE 0
1022#define ACPI_GENERROR_SEV_FATAL 1
1023#define ACPI_GENERROR_SEV_CORRECTED 2
1024#define ACPI_GENERROR_SEV_NONE 3
1025
1026/* Generic Error Data Entry, Validation Bits field */
1027#define ACPI_GENERROR_VALID_FRUID BIT(0)
1028#define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1)
1029#define ACPI_GENERROR_VALID_TIMESTAMP BIT(2)
1030
Felix Held403fa862021-07-26 22:43:00 +02001031/*
1032 * Generic Error Status Block
1033 *
1034 * If there is a raw data section at the end of the generic error status block after the
1035 * zero or more generic error data entries, raw_data_length indicates the length of the raw
1036 * section and raw_data_offset is the offset of the beginning of the raw data section from
1037 * the start of the acpi_generic_error_status block it is contained in. So if raw_data_length
1038 * is non-zero, raw_data_offset must be at least sizeof(acpi_generic_error_status_t).
1039 */
Furquan Shaikhe0844632020-05-02 10:23:37 -07001040typedef struct acpi_generic_error_status {
1041 u32 block_status;
1042 u32 raw_data_offset; /* must follow any generic entries */
1043 u32 raw_data_length;
1044 u32 data_length; /* generic data */
1045 u32 error_severity;
1046 /* Generic Error Data structures, zero or more entries */
1047} __packed acpi_generic_error_status_t;
1048
1049/* Generic Status Block, Block Status values */
1050#define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0)
1051#define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1)
1052#define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2)
1053#define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3)
1054#define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4
1055#define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff
1056#define GENERIC_ERR_STS_ENTRY_COUNT_MASK \
1057 (GENERIC_ERR_STS_ENTRY_COUNT_MAX \
1058 << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT)
1059
1060typedef struct acpi_cstate {
1061 u8 ctype;
1062 u16 latency;
1063 u32 power;
1064 acpi_addr_t resource;
1065} __packed acpi_cstate_t;
1066
Jason Gleneskca36aed2020-09-15 21:01:57 -07001067struct acpi_sw_pstate {
1068 u32 core_freq;
1069 u32 power;
1070 u32 transition_latency;
1071 u32 bus_master_latency;
1072 u32 control_value;
1073 u32 status_value;
1074} __packed;
1075
1076struct acpi_xpss_sw_pstate {
1077 u64 core_freq;
1078 u64 power;
1079 u64 transition_latency;
1080 u64 bus_master_latency;
1081 u64 control_value;
1082 u64 status_value;
1083 u64 control_mask;
1084 u64 status_mask;
1085} __packed;
1086
Furquan Shaikhe0844632020-05-02 10:23:37 -07001087typedef struct acpi_tstate {
1088 u32 percent;
1089 u32 power;
1090 u32 latency;
1091 u32 control;
1092 u32 status;
1093} __packed acpi_tstate_t;
1094
Raul E Rangelc7048322021-04-19 15:58:25 -06001095enum acpi_lpi_state_flags {
1096 ACPI_LPI_STATE_DISABLED = 0,
1097 ACPI_LPI_STATE_ENABLED
1098};
1099
1100/* Low Power Idle State */
1101struct acpi_lpi_state {
1102 u32 min_residency_us;
1103 u32 worst_case_wakeup_latency_us;
1104 u32 flags;
1105 u32 arch_context_lost_flags;
1106 u32 residency_counter_frequency_hz;
1107 u32 enabled_parent_state;
1108 acpi_addr_t entry_method;
1109 acpi_addr_t residency_counter_register;
1110 acpi_addr_t usage_counter_register;
1111 const char *state_name;
1112};
1113
Furquan Shaikhe0844632020-05-02 10:23:37 -07001114/* Port types for ACPI _UPC object */
1115enum acpi_upc_type {
1116 UPC_TYPE_A,
1117 UPC_TYPE_MINI_AB,
1118 UPC_TYPE_EXPRESSCARD,
1119 UPC_TYPE_USB3_A,
1120 UPC_TYPE_USB3_B,
1121 UPC_TYPE_USB3_MICRO_B,
1122 UPC_TYPE_USB3_MICRO_AB,
1123 UPC_TYPE_USB3_POWER_B,
1124 UPC_TYPE_C_USB2_ONLY,
1125 UPC_TYPE_C_USB2_SS_SWITCH,
1126 UPC_TYPE_C_USB2_SS,
1127 UPC_TYPE_PROPRIETARY = 0xff,
1128 /*
1129 * The following types are not directly defined in the ACPI
1130 * spec but are used by coreboot to identify a USB device type.
1131 */
1132 UPC_TYPE_INTERNAL = 0xff,
1133 UPC_TYPE_UNUSED,
1134 UPC_TYPE_HUB
1135};
1136
1137enum acpi_ipmi_interface_type {
1138 IPMI_INTERFACE_RESERVED = 0,
1139 IPMI_INTERFACE_KCS,
1140 IPMI_INTERFACE_SMIC,
1141 IPMI_INTERFACE_BT,
1142 IPMI_INTERFACE_SSIF,
1143};
1144
1145#define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0)
1146#define ACPI_IPMI_INT_TYPE_SCI (1 << 0)
1147#define ACPI_IPMI_INT_TYPE_APIC (1 << 1)
1148
1149/* ACPI IPMI 2.0 */
1150struct acpi_spmi {
1151 acpi_header_t header;
1152 u8 interface_type;
1153 u8 reserved;
1154 u16 specification_revision;
1155 u8 interrupt_type;
1156 u8 gpe;
1157 u8 reserved2;
1158 u8 pci_device_flag;
1159
1160 u32 global_system_interrupt;
1161 acpi_addr_t base_address;
1162 union {
1163 struct {
1164 u8 pci_segment_group;
1165 u8 pci_bus;
1166 u8 pci_device;
1167 u8 pci_function;
1168 };
1169 u8 uid[4];
1170 };
1171 u8 reserved3;
1172} __packed;
1173
Rocky Phaguraeff07132021-01-10 15:42:50 -08001174/* EINJ APEI Standard Definitions */
1175/* EINJ Error Types
1176 Refer to the ACPI spec, EINJ section, for more info on bit definitions
1177*/
1178#define ACPI_EINJ_CPU_CE (1 << 0)
1179#define ACPI_EINJ_CPU_UCE (1 << 1)
1180#define ACPI_EINJ_CPU_UCE_FATAL (1 << 2)
1181#define ACPI_EINJ_MEM_CE (1 << 3)
1182#define ACPI_EINJ_MEM_UCE (1 << 4)
1183#define ACPI_EINJ_MEM_UCE_FATAL (1 << 5)
1184#define ACPI_EINJ_PCIE_CE (1 << 6)
1185#define ACPI_EINJ_PCIE_UCE_NON_FATAL (1 << 7)
1186#define ACPI_EINJ_PCIE_UCE_FATAL (1 << 8)
1187#define ACPI_EINJ_PLATFORM_CE (1 << 9)
1188#define ACPI_EINJ_PLATFORM_UCE (1 << 10)
1189#define ACPI_EINJ_PLATFORM_UCE_FATAL (1 << 11)
1190#define ACPI_EINJ_VENDOR_DEFINED (1 << 31)
1191#define ACPI_EINJ_DEFAULT_CAP (ACPI_EINJ_MEM_CE | ACPI_EINJ_MEM_UCE | \
1192 ACPI_EINJ_PCIE_CE | ACPI_EINJ_PCIE_UCE_FATAL)
1193
1194/* EINJ actions */
1195#define ACTION_COUNT 9
1196#define BEGIN_INJECT_OP 0x00
1197#define GET_TRIGGER_ACTION_TABLE 0x01
1198#define SET_ERROR_TYPE 0x02
1199#define GET_ERROR_TYPE 0x03
1200#define END_INJECT_OP 0x04
1201#define EXECUTE_INJECT_OP 0x05
1202#define CHECK_BUSY_STATUS 0x06
1203#define GET_CMD_STATUS 0x07
1204#define SET_ERROR_TYPE_WITH_ADDRESS 0x08
1205#define TRIGGER_ERROR 0xFF
1206
1207/* EINJ Instructions */
1208#define READ_REGISTER 0x00
1209#define READ_REGISTER_VALUE 0x01
1210#define WRITE_REGISTER 0x02
1211#define WRITE_REGISTER_VALUE 0x03
1212#define NO_OP 0x04
1213
1214/* EINJ (Error Injection Table) */
1215typedef struct acpi_gen_regaddr1 {
1216 u8 space_id; /* Address space ID */
1217 u8 bit_width; /* Register size in bits */
1218 u8 bit_offset; /* Register bit offset */
1219 u8 access_size; /* Access size since ACPI 2.0c */
1220 u64 addr; /* Register address */
1221} __packed acpi_addr64_t;
1222
1223/* Instruction entry */
1224typedef struct acpi_einj_action_table {
1225 u8 action;
1226 u8 instruction;
1227 u16 flags;
1228 acpi_addr64_t reg;
1229 u64 value;
1230 u64 mask;
1231} __packed acpi_einj_action_table_t;
1232
1233typedef struct acpi_injection_header {
1234 u32 einj_header_size;
1235 u32 flags;
1236 u32 entry_count;
1237} __packed acpi_injection_header_t;
1238
1239typedef struct acpi_einj_trigger_table {
1240 u32 header_size;
1241 u32 revision;
1242 u32 table_size;
1243 u32 entry_count;
1244 acpi_einj_action_table_t trigger_action[1];
1245} __packed acpi_einj_trigger_table_t;
1246
1247typedef struct set_error_type {
1248 u32 errtype;
1249 u32 vendorerrortype;
1250 u32 flags;
1251 u32 apicid;
1252 u64 memaddr;
1253 u64 memrange;
1254 u32 pciesbdf;
1255} __packed set_error_type_t;
1256
1257#define EINJ_PARAM_NUM 6
1258typedef struct acpi_einj_smi {
1259 u64 op_state;
1260 u64 err_inject[EINJ_PARAM_NUM];
1261 u64 trigger_action_table;
1262 u64 err_inj_cap;
1263 u64 op_status;
1264 u64 cmd_sts;
1265 u64 einj_addr;
1266 u64 einj_addr_msk;
1267 set_error_type_t setaddrtable;
1268 u64 reserved[50];
1269} __packed acpi_einj_smi_t;
1270
1271/* EINJ Flags */
1272#define EINJ_DEF_TRIGGER_PORT 0xb2
1273#define FLAG_PRESERVE 0x01
1274#define FLAG_IGNORE 0x00
1275
1276/* EINJ Registers */
1277#define EINJ_REG_MEMORY(address) \
1278 { \
1279 .space_id = ACPI_ADDRESS_SPACE_MEMORY, \
1280 .bit_width = 64, \
1281 .bit_offset = 0, \
1282 .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \
1283 .addr = address}
1284
1285#define EINJ_REG_IO() \
1286 { \
1287 .space_id = ACPI_ADDRESS_SPACE_IO, \
1288 .bit_width = 0x10, \
1289 .bit_offset = 0, \
1290 .access_size = ACPI_ACCESS_SIZE_WORD_ACCESS, \
1291 .addr = EINJ_DEF_TRIGGER_PORT} /* HW dependent code can override this also */
1292
1293typedef struct acpi_einj {
1294 acpi_header_t header;
1295 acpi_injection_header_t inj_header;
1296 acpi_einj_action_table_t action_table[ACTION_COUNT];
1297} __packed acpi_einj_t;
1298
Arthur Heymans2e7e2d92022-03-03 22:28:27 +01001299uintptr_t get_coreboot_rsdp(void);
Rocky Phaguraeff07132021-01-10 15:42:50 -08001300void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions);
1301
Furquan Shaikhe0844632020-05-02 10:23:37 -07001302unsigned long fw_cfg_acpi_tables(unsigned long start);
1303
1304/* These are implemented by the target port or north/southbridge. */
Raul E Rangel6b446b92021-11-19 11:38:35 -07001305void preload_acpi_dsdt(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001306unsigned long write_acpi_tables(unsigned long addr);
1307unsigned long acpi_fill_madt(unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001308unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current);
1309void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
1310void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length);
1311void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001312
Furquan Shaikhe0844632020-05-02 10:23:37 -07001313void acpi_fill_fadt(acpi_fadt_t *fadt);
Angel Pons79572e42020-07-13 00:17:43 +02001314void arch_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001315void soc_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkki02fd15d2020-06-02 03:34:43 +03001316void mainboard_fill_fadt(acpi_fadt_t *fadt);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001317
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001318void acpi_fill_gnvs(void);
Kyösti Mälkki3dc17922021-03-16 19:01:48 +02001319void acpi_fill_cnvs(void);
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001320
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001321unsigned long acpi_fill_lpit(unsigned long current);
1322
Furquan Shaikhe0844632020-05-02 10:23:37 -07001323/* These can be used by the target port. */
1324u8 acpi_checksum(u8 *table, u32 length);
1325
1326void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
1327
Jonathan Zhang3dcafa82022-05-11 13:11:20 -07001328/* Create CXL Early Discovery Table */
1329void acpi_create_cedt(acpi_cedt_t *cedt,
1330 unsigned long (*acpi_fill_cedt)(unsigned long current));
1331/* Create a CXL Host Bridge Structure for CEDT */
1332int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base);
1333/* Create a CXL Fixed Memory Window Structure for CEDT */
1334int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size,
1335 u8 eniw, u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target);
1336
Furquan Shaikhe0844632020-05-02 10:23:37 -07001337int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
1338int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
1339 u32 gsi_base);
Kyösti Mälkkic7da0272021-06-08 11:37:08 +03001340int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001341int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
1342 u8 bus, u8 source, u32 gsirq, u16 flags);
1343int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
1344 u16 flags, u8 lint);
1345void acpi_create_madt(acpi_madt_t *madt);
Kyösti Mälkki899c7132021-06-16 11:06:26 +03001346
Kyösti Mälkki66b5e1b2022-11-12 21:13:45 +02001347unsigned long acpi_create_madt_lapics_with_nmis(unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001348int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic);
1349int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu,
1350 u16 flags, u8 lint);
1351int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
Naresh Solanki76835cc2023-01-20 19:13:02 +01001352int acpi_create_srat_x2apic(acpi_srat_x2apic_t *x2apic, u32 node, u32 apic);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001353int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek,
1354 u32 flags);
Jonathan Zhang3164b642021-04-21 17:51:31 -07001355/*
1356 * Given the Generic Initiator device's BDF, the proximity domain's ID
1357 * and flag, create Generic Initiator Affinity structure in SRAT.
1358 */
1359int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain,
1360 u16 seg, u8 bus, u8 dev, u8 func, u32 flags);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001361int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
1362 u16 seg_nr, u8 start, u8 end);
1363unsigned long acpi_create_srat_lapics(unsigned long current);
1364void acpi_create_srat(acpi_srat_t *srat,
1365 unsigned long (*acpi_fill_srat)(unsigned long current));
1366
1367void acpi_create_slit(acpi_slit_t *slit,
1368 unsigned long (*acpi_fill_slit)(unsigned long current));
1369
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001370/*
1371 * Create a Memory Proximity Domain Attributes structure for HMAT,
1372 * given proximity domain for the attached initiaor, and
1373 * proximimity domain for the memory.
1374 */
1375int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory);
Martin Roth0949e732021-10-01 14:28:22 -06001376/* Create Heterogeneous Memory Attribute Table */
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001377void acpi_create_hmat(acpi_hmat_t *hmat,
1378 unsigned long (*acpi_fill_hmat)(unsigned long current));
1379
Furquan Shaikhe0844632020-05-02 10:23:37 -07001380void acpi_create_vfct(const struct device *device,
1381 acpi_vfct_t *vfct,
1382 unsigned long (*acpi_fill_vfct)(const struct device *device,
1383 acpi_vfct_t *vfct_struct,
1384 unsigned long current));
1385
1386void acpi_create_ipmi(const struct device *device,
1387 struct acpi_spmi *spmi,
1388 const u16 ipmi_revision,
1389 const acpi_addr_t *addr,
1390 const enum acpi_ipmi_interface_type type,
1391 const s8 gpe_interrupt,
1392 const u32 apic_interrupt,
1393 const u32 uid);
1394
1395void acpi_create_ivrs(acpi_ivrs_t *ivrs,
1396 unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct,
1397 unsigned long current));
1398
Jason Glenesk61624b22020-11-02 20:06:23 -08001399void acpi_create_crat(struct acpi_crat_header *crat,
1400 unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct,
1401 unsigned long current));
1402
Furquan Shaikhe0844632020-05-02 10:23:37 -07001403void acpi_create_hpet(acpi_hpet_t *hpet);
1404unsigned long acpi_write_hpet(const struct device *device, unsigned long start,
1405 acpi_rsdp_t *rsdp);
1406
1407/* cpu/intel/speedstep/acpi.c */
1408void generate_cpu_entries(const struct device *device);
1409
1410void acpi_create_mcfg(acpi_mcfg_t *mcfg);
1411
1412void acpi_create_facs(acpi_facs_t *facs);
1413
1414void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header,
1415 int port_type, int port_subtype,
1416 acpi_addr_t *address, uint32_t address_size,
1417 const char *device_path);
1418
1419unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
1420 const struct device *dev, uint8_t access_size);
1421void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
1422 unsigned long (*acpi_fill_dmar)(unsigned long));
1423unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
1424 u16 segment, u64 bar);
1425unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment,
1426 u64 bar, u64 limit);
1427unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags,
1428 u16 segment);
1429unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr,
1430 u32 proximity_domain);
1431unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number,
1432 const char *device_name);
John Zhao6edbb182021-03-24 11:55:09 -07001433unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags,
John Zhao091532d2021-04-17 16:03:21 -07001434 u16 segment);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001435void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current);
1436void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current);
1437void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current);
John Zhao6edbb182021-03-24 11:55:09 -07001438void acpi_dmar_satc_fixup(unsigned long base, unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001439unsigned long acpi_create_dmar_ds_pci_br(unsigned long current,
1440 u8 bus, u8 dev, u8 fn);
1441unsigned long acpi_create_dmar_ds_pci(unsigned long current,
1442 u8 bus, u8 dev, u8 fn);
1443unsigned long acpi_create_dmar_ds_ioapic(unsigned long current,
1444 u8 enumeration_id,
1445 u8 bus, u8 dev, u8 fn);
Arthur Heymansbc8f8592022-12-02 13:17:39 +01001446unsigned long acpi_create_dmar_ds_ioapic_from_hw(unsigned long current,
1447 u32 addr, u8 bus, u8 dev, u8 fn);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001448unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current,
1449 u8 enumeration_id,
1450 u8 bus, u8 dev, u8 fn);
1451void acpi_write_hest(acpi_hest_t *hest,
1452 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest));
1453
1454unsigned long acpi_create_hest_error_source(acpi_hest_t *hest,
1455 acpi_hest_esd_t *esd, u16 type, void *data, u16 len);
1456
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001457void acpi_create_lpit(acpi_lpit_t *lpit);
1458unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid);
1459
Felix Heldf7dbf4a2021-06-07 16:56:04 +02001460/* chipsets that select ACPI_BERT must implement this function */
Felix Held29405482021-05-28 16:01:57 +02001461enum cb_err acpi_soc_get_bert_region(void **region, size_t *length);
Francois Toguo522e0db2021-01-21 09:55:19 -08001462
Furquan Shaikhe0844632020-05-02 10:23:37 -07001463/* For ACPI S3 support. */
Kyösti Mälkkia4c0e1a2020-06-18 08:28:12 +03001464void __noreturn acpi_resume(void *wake_vec);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001465void mainboard_suspend_resume(void);
1466void *acpi_find_wakeup_vector(void);
1467
1468/* ACPI_Sn assignments are defined to always equal the sleep state numbers */
1469enum {
1470 ACPI_S0 = 0,
1471 ACPI_S1 = 1,
1472 ACPI_S2 = 2,
1473 ACPI_S3 = 3,
1474 ACPI_S4 = 4,
1475 ACPI_S5 = 5,
1476};
1477
1478#if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \
1479 || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES)
1480/* Given the provided PM1 control register return the ACPI sleep type. */
1481static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt)
1482{
1483 switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) {
1484 case SLP_TYP_S0: return ACPI_S0;
1485 case SLP_TYP_S1: return ACPI_S1;
1486 case SLP_TYP_S3: return ACPI_S3;
1487 case SLP_TYP_S4: return ACPI_S4;
1488 case SLP_TYP_S5: return ACPI_S5;
1489 }
1490 return -1;
1491}
1492#endif
1493
Kyösti Mälkkie0d38682020-06-07 12:01:58 +03001494uint8_t acpi_get_preferred_pm_profile(void);
1495
Furquan Shaikhe0844632020-05-02 10:23:37 -07001496/* Returns ACPI_Sx values. */
1497int acpi_get_sleep_type(void);
1498
1499/* Read and clear GPE status */
1500int acpi_get_gpe(int gpe);
1501
Kyösti Mälkki0a9e72e2019-08-11 01:22:28 +03001502/* Once we enter payload, is SMI handler installed and capable of
1503 responding to APM_CNT Advanced Power Management Control commands. */
1504static inline int permanent_smi_handler(void)
1505{
1506 return CONFIG(HAVE_SMI_HANDLER);
1507}
1508
Furquan Shaikhe0844632020-05-02 10:23:37 -07001509static inline int acpi_s3_resume_allowed(void)
1510{
1511 return CONFIG(HAVE_ACPI_RESUME);
1512}
1513
Furquan Shaikhe0844632020-05-02 10:23:37 -07001514static inline int acpi_is_wakeup_s3(void)
1515{
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001516 if (!acpi_s3_resume_allowed())
1517 return 0;
Furquan Shaikhe0844632020-05-02 10:23:37 -07001518
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001519 if (ENV_ROMSTAGE_OR_BEFORE)
1520 return (acpi_get_sleep_type() == ACPI_S3);
1521
Kyösti Mälkkiac0dc4a2020-11-18 07:40:21 +02001522 return romstage_handoff_is_resume();
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001523}
Furquan Shaikhe0844632020-05-02 10:23:37 -07001524
1525static inline uintptr_t acpi_align_current(uintptr_t current)
1526{
1527 return ALIGN_UP(current, 16);
1528}
1529
1530/* ACPI table revisions should match the revision of the ACPI spec
1531 * supported. This function keeps the table versions synced. This could
1532 * be made into a weak function if there is ever a need to override the
1533 * coreboot default ACPI spec version supported. */
1534int get_acpi_table_revision(enum acpi_tables table);
Elyes Haouas8b950f42022-02-16 12:08:16 +01001535u8 get_acpi_fadt_minor_version(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001536
Kyösti Mälkki94e04652020-06-01 13:26:22 +03001537#endif // !defined(__ASSEMBLER__) && !defined(__ACPI__)
Furquan Shaikhe0844632020-05-02 10:23:37 -07001538
Furquan Shaikh56eafbb2020-04-30 18:38:55 -07001539#endif /* __ACPI_ACPI_H__ */