blob: b92c77e5d532ebcb348ef918dc22743bc0a2e45f [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
Furquan Shaikhe0844632020-05-02 10:23:37 -0700356/* SRAT: Processor Local APIC/SAPIC Affinity Structure */
357typedef struct acpi_srat_lapic {
358 u8 type; /* Type (0) */
359 u8 length; /* Length in bytes (16) */
360 u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */
361 u8 apic_id; /* Local APIC ID */
362 u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */
363 u8 local_sapic_eid; /* Local SAPIC EID */
364 u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */
365 u32 clock_domain; /* _CDM Clock Domain */
366} __packed acpi_srat_lapic_t;
367
368/* SRAT: Memory Affinity Structure */
369typedef struct acpi_srat_mem {
370 u8 type; /* Type (1) */
371 u8 length; /* Length in bytes (40) */
372 u32 proximity_domain; /* Proximity domain */
373 u16 resv;
374 u32 base_address_low; /* Mem range base address, low */
375 u32 base_address_high; /* Mem range base address, high */
376 u32 length_low; /* Mem range length, low */
377 u32 length_high; /* Mem range length, high */
378 u32 resv1;
379 u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2,
380 * other bits reserved to 0
381 */
382 u32 resv2[2];
383} __packed acpi_srat_mem_t;
384
Jonathan Zhang3164b642021-04-21 17:51:31 -0700385/* SRAT: Generic Initiator Affinity Structure (ACPI spec 6.4 section 5.2.16.6) */
386typedef struct acpi_srat_gia {
387 u8 type; /* Type (5) */
388 u8 length; /* Length in bytes (32) */
389 u8 resv;
390 u8 dev_handle_type; /* Device handle type */
391 u32 proximity_domain; /*Proximity domain */
392 u8 dev_handle[16]; /* Device handle */
393 u32 flags;
394 u32 resv1;
395} __packed acpi_srat_gia_t;
396
397#define ACPI_SRAT_GIA_DEV_HANDLE_ACPI 0
398#define ACPI_SRAT_GIA_DEV_HANDLE_PCI 1
399
Furquan Shaikhe0844632020-05-02 10:23:37 -0700400/* SLIT (System Locality Distance Information Table) */
401typedef struct acpi_slit {
402 acpi_header_t header;
403 /* Followed by static resource allocation 8+byte[num*num] */
404} __packed acpi_slit_t;
405
406/* MADT (Multiple APIC Description Table) */
407typedef struct acpi_madt {
408 acpi_header_t header;
409 u32 lapic_addr; /* Local APIC address */
410 u32 flags; /* Multiple APIC flags */
411} __packed acpi_madt_t;
412
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +0100413/*
414 * LPIT (Low Power Idle Table)
415 * Conforms to "Intel Low Power S0 Idle" specification, rev 002 from July 2017.
416 */
417typedef struct acpi_lpit {
418 acpi_header_t header;
419} __packed acpi_lpit_t;
420
421/* LPIT: LPI descriptor flags */
422typedef struct acpi_lpi_flags {
423 uint32_t disabled : 1;
424 uint32_t counter_not_available : 1;
425 uint32_t reserved : 30;
426} __packed acpi_lpi_desc_flags_t;
427
428/* LPIT: LPI descriptor types */
429enum acpi_lpi_desc_type {
430 ACPI_LPI_DESC_TYPE_NATIVE_CSTATE = 0x00,
431 /* type >= 1 reserved */
432};
433
434/* LPIT: LPI descriptor header */
435typedef struct acpi_lpi_desc_hdr {
436 uint32_t type;
437 uint32_t length;
438 uint16_t uid;
439 uint16_t reserved;
440} __packed acpi_lpi_desc_hdr_t;
441
442#define ACPI_LPIT_CTR_FREQ_TSC 0
443
444/* LPIT: Native C-state instruction based LPI structure */
445typedef struct acpi_lpi_desc_ncst {
446 acpi_lpi_desc_hdr_t header;
447 acpi_lpi_desc_flags_t flags;
448 acpi_addr_t entry_trigger; /* Entry trigger C-state */
449 uint32_t min_residency; /* Minimum residency or "break-even" in microseconds */
450 uint32_t max_latency; /* Worst case exit latency in microseconds */
451 acpi_addr_t residency_counter;
452 uint64_t counter_frequency; /* Frequency in cycles per second - 0 means TSC freq */
453} __packed acpi_lpi_desc_ncst_t;
454
Furquan Shaikhe0844632020-05-02 10:23:37 -0700455/* VFCT image header */
456typedef struct acpi_vfct_image_hdr {
457 u32 PCIBus;
458 u32 PCIDevice;
459 u32 PCIFunction;
460 u16 VendorID;
461 u16 DeviceID;
462 u16 SSVID;
463 u16 SSID;
464 u32 Revision;
465 u32 ImageLength;
466 u8 VbiosContent; // dummy - copy VBIOS here
467} __packed acpi_vfct_image_hdr_t;
468
469/* VFCT (VBIOS Fetch Table) */
470typedef struct acpi_vfct {
471 acpi_header_t header;
472 u8 TableUUID[16];
473 u32 VBIOSImageOffset;
474 u32 Lib1ImageOffset;
475 u32 Reserved[4];
476 acpi_vfct_image_hdr_t image_hdr;
477} __packed acpi_vfct_t;
478
479typedef struct acpi_ivrs_info {
480} __packed acpi_ivrs_info_t;
481
482/* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */
483typedef struct acpi_ivrs_ivhd {
484 uint8_t type;
485 uint8_t flags;
486 uint16_t length;
487 uint16_t device_id;
488 uint16_t capability_offset;
489 uint32_t iommu_base_low;
490 uint32_t iommu_base_high;
491 uint16_t pci_segment_group;
492 uint16_t iommu_info;
493 uint32_t iommu_feature_info;
494 uint8_t entry[0];
495} __packed acpi_ivrs_ivhd_t;
496
497/* IVRS (I/O Virtualization Reporting Structure) Type 10h */
498typedef struct acpi_ivrs {
499 acpi_header_t header;
500 uint32_t iv_info;
501 uint32_t reserved[2];
502 struct acpi_ivrs_ivhd ivhd;
503} __packed acpi_ivrs_t;
504
Jason Glenesk61624b22020-11-02 20:06:23 -0800505/* CRAT (Component Resource Affinity Table Structure) */
506struct acpi_crat_header {
507 acpi_header_t header;
508 uint32_t total_entries;
509 uint16_t num_nodes;
510 uint8_t reserved[6];
511} __packed;
512
Furquan Shaikhe0844632020-05-02 10:23:37 -0700513/* IVHD Type 11h IOMMU Attributes */
514typedef struct ivhd11_iommu_attr {
515 uint32_t reserved1 : 13;
516 uint32_t perf_counters : 4;
517 uint32_t perf_counter_banks : 6;
518 uint32_t msi_num_ppr : 5;
519 uint32_t reserved2 : 4;
520} __packed ivhd11_iommu_attr_t;
521
522/* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 11h */
523typedef struct acpi_ivrs_ivhd_11 {
524 uint8_t type;
525 uint8_t flags;
526 uint16_t length;
527 uint16_t device_id;
528 uint16_t capability_offset;
529 uint32_t iommu_base_low;
530 uint32_t iommu_base_high;
531 uint16_t pci_segment_group;
532 uint16_t iommu_info;
533 struct ivhd11_iommu_attr iommu_attributes;
534 uint32_t efr_reg_image_low;
535 uint32_t efr_reg_image_high;
536 uint32_t reserved[2];
537 uint8_t entry[0];
538} __packed acpi_ivrs_ivhd11_t;
539
540enum dev_scope_type {
541 SCOPE_PCI_ENDPOINT = 1,
542 SCOPE_PCI_SUB = 2,
543 SCOPE_IOAPIC = 3,
544 SCOPE_MSI_HPET = 4,
545 SCOPE_ACPI_NAMESPACE_DEVICE = 5
546};
547
548typedef struct dev_scope {
549 u8 type;
550 u8 length;
551 u8 reserved[2];
552 u8 enumeration;
553 u8 start_bus;
554 struct {
555 u8 dev;
556 u8 fn;
557 } __packed path[0];
558} __packed dev_scope_t;
559
560enum dmar_type {
561 DMAR_DRHD = 0,
562 DMAR_RMRR = 1,
563 DMAR_ATSR = 2,
564 DMAR_RHSA = 3,
John Zhao6edbb182021-03-24 11:55:09 -0700565 DMAR_ANDD = 4,
566 DMAR_SATC = 5
Furquan Shaikhe0844632020-05-02 10:23:37 -0700567};
568
569enum {
570 DRHD_INCLUDE_PCI_ALL = 1
571};
572
John Zhao091532d2021-04-17 16:03:21 -0700573enum {
574 ATC_REQUIRED = 1
575};
576
Furquan Shaikhe0844632020-05-02 10:23:37 -0700577enum dmar_flags {
578 DMAR_INTR_REMAP = 1 << 0,
579 DMAR_X2APIC_OPT_OUT = 1 << 1,
580 DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2,
581};
582
583typedef struct dmar_entry {
584 u16 type;
585 u16 length;
586 u8 flags;
587 u8 reserved;
588 u16 segment;
589 u64 bar;
590} __packed dmar_entry_t;
591
592typedef struct dmar_rmrr_entry {
593 u16 type;
594 u16 length;
595 u16 reserved;
596 u16 segment;
597 u64 bar;
598 u64 limit;
599} __packed dmar_rmrr_entry_t;
600
601typedef struct dmar_atsr_entry {
602 u16 type;
603 u16 length;
604 u8 flags;
605 u8 reserved;
606 u16 segment;
607} __packed dmar_atsr_entry_t;
608
609typedef struct dmar_rhsa_entry {
610 u16 type;
611 u16 length;
612 u32 reserved;
613 u64 base_address;
614 u32 proximity_domain;
615} __packed dmar_rhsa_entry_t;
616
617typedef struct dmar_andd_entry {
618 u16 type;
619 u16 length;
620 u8 reserved[3];
621 u8 device_number;
622 u8 device_name[];
623} __packed dmar_andd_entry_t;
624
John Zhao6edbb182021-03-24 11:55:09 -0700625typedef struct dmar_satc_entry {
626 u16 type;
627 u16 length;
628 u8 flags;
629 u8 reserved;
630 u16 segment_number;
John Zhao6edbb182021-03-24 11:55:09 -0700631} __packed dmar_satc_entry_t;
632
Furquan Shaikhe0844632020-05-02 10:23:37 -0700633/* DMAR (DMA Remapping Reporting Structure) */
634typedef struct acpi_dmar {
635 acpi_header_t header;
636 u8 host_address_width;
637 u8 flags;
638 u8 reserved[10];
639 dmar_entry_t structure[0];
640} __packed acpi_dmar_t;
641
642/* MADT: APIC Structure Types */
643enum acpi_apic_types {
644 LOCAL_APIC, /* Processor local APIC */
645 IO_APIC, /* I/O APIC */
646 IRQ_SOURCE_OVERRIDE, /* Interrupt source override */
647 NMI_TYPE, /* NMI source */
648 LOCAL_APIC_NMI, /* Local APIC NMI */
649 LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */
650 IO_SAPIC, /* I/O SAPIC */
651 LOCAL_SAPIC, /* Local SAPIC */
652 PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */
653 LOCAL_X2APIC, /* Processor local x2APIC */
654 LOCAL_X2APIC_NMI, /* Local x2APIC NMI */
655 GICC, /* GIC CPU Interface */
656 GICD, /* GIC Distributor */
657 GIC_MSI_FRAME, /* GIC MSI Frame */
658 GICR, /* GIC Redistributor */
659 GIC_ITS, /* Interrupt Translation Service */
660 /* 0x10-0x7f: Reserved */
661 /* 0x80-0xff: Reserved for OEM use */
662};
663
664/* MADT: Processor Local APIC Structure */
665typedef struct acpi_madt_lapic {
666 u8 type; /* Type (0) */
667 u8 length; /* Length in bytes (8) */
668 u8 processor_id; /* ACPI processor ID */
669 u8 apic_id; /* Local APIC ID */
670 u32 flags; /* Local APIC flags */
671} __packed acpi_madt_lapic_t;
672
673/* MADT: Local APIC NMI Structure */
674typedef struct acpi_madt_lapic_nmi {
675 u8 type; /* Type (4) */
676 u8 length; /* Length in bytes (6) */
677 u8 processor_id; /* ACPI processor ID */
678 u16 flags; /* MPS INTI flags */
679 u8 lint; /* Local APIC LINT# */
680} __packed acpi_madt_lapic_nmi_t;
681
Kyösti Mälkki66b5e1b2022-11-12 21:13:45 +0200682#define ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS 0xff
683#define ACPI_MADT_LX2APIC_NMI_ALL_PROCESSORS ((u32)-1)
Raul E Rangelf5552ce2021-02-11 11:27:56 -0700684
Furquan Shaikhe0844632020-05-02 10:23:37 -0700685/* MADT: I/O APIC Structure */
686typedef struct acpi_madt_ioapic {
687 u8 type; /* Type (1) */
688 u8 length; /* Length in bytes (12) */
689 u8 ioapic_id; /* I/O APIC ID */
690 u8 reserved;
691 u32 ioapic_addr; /* I/O APIC address */
692 u32 gsi_base; /* Global system interrupt base */
693} __packed acpi_madt_ioapic_t;
694
Raul E Rangel169302a2022-04-25 14:59:05 -0600695#define MP_IRQ_POLARITY_DEFAULT 0x0
696#define MP_IRQ_POLARITY_HIGH 0x1
697#define MP_IRQ_POLARITY_LOW 0x3
698#define MP_IRQ_POLARITY_MASK 0x3
699#define MP_IRQ_TRIGGER_DEFAULT 0x0
700#define MP_IRQ_TRIGGER_EDGE 0x4
701#define MP_IRQ_TRIGGER_LEVEL 0xc
702#define MP_IRQ_TRIGGER_MASK 0xc
703
Furquan Shaikhe0844632020-05-02 10:23:37 -0700704/* MADT: Interrupt Source Override Structure */
705typedef struct acpi_madt_irqoverride {
706 u8 type; /* Type (2) */
707 u8 length; /* Length in bytes (10) */
708 u8 bus; /* ISA (0) */
709 u8 source; /* Bus-relative int. source (IRQ) */
710 u32 gsirq; /* Global system interrupt */
711 u16 flags; /* MPS INTI flags */
712} __packed acpi_madt_irqoverride_t;
713
714/* MADT: Processor Local x2APIC Structure */
715typedef struct acpi_madt_lx2apic {
716 u8 type; /* Type (9) */
717 u8 length; /* Length in bytes (16) */
718 u16 reserved;
719 u32 x2apic_id; /* Local x2APIC ID */
720 u32 flags; /* Same as Local APIC flags */
721 u32 processor_id; /* ACPI processor ID */
722} __packed acpi_madt_lx2apic_t;
723
724/* MADT: Processor Local x2APIC NMI Structure */
725typedef struct acpi_madt_lx2apic_nmi {
726 u8 type; /* Type (10) */
727 u8 length; /* Length in bytes (12) */
728 u16 flags; /* Same as MPS INTI flags */
729 u32 processor_id; /* ACPI processor ID */
730 u8 lint; /* Local APIC LINT# */
731 u8 reserved[3];
732} __packed acpi_madt_lx2apic_nmi_t;
733
734#define ACPI_DBG2_PORT_SERIAL 0x8000
735#define ACPI_DBG2_PORT_SERIAL_16550 0x0000
736#define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001
737#define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003
738#define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e
739#define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f
740#define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010
741#define ACPI_DBG2_PORT_IEEE1394 0x8001
742#define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000
743#define ACPI_DBG2_PORT_USB 0x8002
744#define ACPI_DBG2_PORT_USB_XHCI 0x0000
745#define ACPI_DBG2_PORT_USB_EHCI 0x0001
746#define ACPI_DBG2_PORT_NET 0x8003
747
748/* DBG2: Microsoft Debug Port Table 2 header */
749typedef struct acpi_dbg2_header {
750 acpi_header_t header;
751 uint32_t devices_offset;
752 uint32_t devices_count;
753} __attribute__((packed)) acpi_dbg2_header_t;
754
755/* DBG2: Microsoft Debug Port Table 2 device entry */
756typedef struct acpi_dbg2_device {
757 uint8_t revision;
758 uint16_t length;
759 uint8_t address_count;
760 uint16_t namespace_string_length;
761 uint16_t namespace_string_offset;
762 uint16_t oem_data_length;
763 uint16_t oem_data_offset;
764 uint16_t port_type;
765 uint16_t port_subtype;
766 uint8_t reserved[2];
767 uint16_t base_address_offset;
768 uint16_t address_size_offset;
769} __attribute__((packed)) acpi_dbg2_device_t;
770
771/* FADT (Fixed ACPI Description Table) */
772typedef struct acpi_fadt {
773 acpi_header_t header;
774 u32 firmware_ctrl;
775 u32 dsdt;
776 u8 reserved; /* Should be 0 */
777 u8 preferred_pm_profile;
778 u16 sci_int;
779 u32 smi_cmd;
780 u8 acpi_enable;
781 u8 acpi_disable;
782 u8 s4bios_req;
783 u8 pstate_cnt;
784 u32 pm1a_evt_blk;
785 u32 pm1b_evt_blk;
786 u32 pm1a_cnt_blk;
787 u32 pm1b_cnt_blk;
788 u32 pm2_cnt_blk;
789 u32 pm_tmr_blk;
790 u32 gpe0_blk;
791 u32 gpe1_blk;
792 u8 pm1_evt_len;
793 u8 pm1_cnt_len;
794 u8 pm2_cnt_len;
795 u8 pm_tmr_len;
796 u8 gpe0_blk_len;
797 u8 gpe1_blk_len;
798 u8 gpe1_base;
799 u8 cst_cnt;
800 u16 p_lvl2_lat;
801 u16 p_lvl3_lat;
802 u16 flush_size;
803 u16 flush_stride;
804 u8 duty_offset;
805 u8 duty_width;
806 u8 day_alrm;
807 u8 mon_alrm;
808 u8 century;
809 u16 iapc_boot_arch;
810 u8 res2;
811 u32 flags;
812 acpi_addr_t reset_reg;
813 u8 reset_value;
Elyes Haouasb55ac092022-02-16 14:42:19 +0100814 u16 ARM_boot_arch; /* Must be zero if ACPI Revision <= 5.0 */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100815 u8 FADT_MinorVersion; /* Must be zero if ACPI Revision <= 5.0 */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700816 u32 x_firmware_ctl_l;
817 u32 x_firmware_ctl_h;
818 u32 x_dsdt_l;
819 u32 x_dsdt_h;
820 acpi_addr_t x_pm1a_evt_blk;
821 acpi_addr_t x_pm1b_evt_blk;
822 acpi_addr_t x_pm1a_cnt_blk;
823 acpi_addr_t x_pm1b_cnt_blk;
824 acpi_addr_t x_pm2_cnt_blk;
825 acpi_addr_t x_pm_tmr_blk;
826 acpi_addr_t x_gpe0_blk;
827 acpi_addr_t x_gpe1_blk;
828 /* Revision 5 */
829 acpi_addr_t sleep_control_reg;
830 acpi_addr_t sleep_status_reg;
831 /* Revision 6 */
832 u64 hypervisor_vendor_identity;
833} __packed acpi_fadt_t;
834
835/* FADT TABLE Revision values */
Elyes Haouas8b950f42022-02-16 12:08:16 +0100836#define ACPI_FADT_REV_ACPI_1 1
837#define ACPI_FADT_REV_ACPI_2 3
838#define ACPI_FADT_REV_ACPI_3 4
839#define ACPI_FADT_REV_ACPI_4 4
840#define ACPI_FADT_REV_ACPI_5 5
841#define ACPI_FADT_REV_ACPI_6 6
842
843/* FADT Minor Version value:
844 * Bits 0-3: minor version
845 * Bits 4-7: Errata
846 * value of 1 means this is compatible with Errata A,
847 * value of 2 would be compatible with Errata B, and so on
848 * Version 6.3 Errata A would be: (1 << 4) | 3
849 */
850#define ACPI_FADT_MINOR_VERSION_0 0 /* coreboot currently use this version */
Furquan Shaikhe0844632020-05-02 10:23:37 -0700851
852/* Flags for p_lvl2_lat and p_lvl3_lat */
853#define ACPI_FADT_C2_NOT_SUPPORTED 101
854#define ACPI_FADT_C3_NOT_SUPPORTED 1001
855
856/* FADT Feature Flags */
857#define ACPI_FADT_WBINVD (1 << 0)
858#define ACPI_FADT_WBINVD_FLUSH (1 << 1)
859#define ACPI_FADT_C1_SUPPORTED (1 << 2)
860#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
861#define ACPI_FADT_POWER_BUTTON (1 << 4)
862#define ACPI_FADT_SLEEP_BUTTON (1 << 5)
863#define ACPI_FADT_FIXED_RTC (1 << 6)
864#define ACPI_FADT_S4_RTC_WAKE (1 << 7)
865#define ACPI_FADT_32BIT_TIMER (1 << 8)
866#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
867#define ACPI_FADT_RESET_REGISTER (1 << 10)
868#define ACPI_FADT_SEALED_CASE (1 << 11)
869#define ACPI_FADT_HEADLESS (1 << 12)
870#define ACPI_FADT_SLEEP_TYPE (1 << 13)
871#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
872#define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
873#define ACPI_FADT_S4_RTC_VALID (1 << 16)
874#define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
875#define ACPI_FADT_APIC_CLUSTER (1 << 18)
876#define ACPI_FADT_APIC_PHYSICAL (1 << 19)
877/* Bits 20-31: reserved ACPI 3.0 & 4.0 */
878#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20)
879#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21)
880/* bits 22-31: reserved since ACPI 5.0 */
881
882/* FADT Boot Architecture Flags */
883#define ACPI_FADT_LEGACY_DEVICES (1 << 0)
884#define ACPI_FADT_8042 (1 << 1)
885#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
886#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
887#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
888#define ACPI_FADT_NO_CMOS_RTC (1 << 5)
889#define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */
890
891/* FADT ARM Boot Architecture Flags */
892#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
893#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
894/* bits 2-16: reserved since ACPI 5.1 */
895
896/* FADT Preferred Power Management Profile */
897enum acpi_preferred_pm_profiles {
898 PM_UNSPECIFIED = 0,
899 PM_DESKTOP = 1,
900 PM_MOBILE = 2,
901 PM_WORKSTATION = 3,
902 PM_ENTERPRISE_SERVER = 4,
903 PM_SOHO_SERVER = 5,
904 PM_APPLIANCE_PC = 6,
905 PM_PERFORMANCE_SERVER = 7,
906 PM_TABLET = 8, /* ACPI 5.0 & greater */
907};
908
909/* FACS (Firmware ACPI Control Structure) */
910typedef struct acpi_facs {
911 char signature[4]; /* "FACS" */
912 u32 length; /* Length in bytes (>= 64) */
913 u32 hardware_signature; /* Hardware signature */
914 u32 firmware_waking_vector; /* Firmware waking vector */
915 u32 global_lock; /* Global lock */
916 u32 flags; /* FACS flags */
917 u32 x_firmware_waking_vector_l; /* X FW waking vector, low */
918 u32 x_firmware_waking_vector_h; /* X FW waking vector, high */
919 u8 version; /* FACS version */
920 u8 resv1[3]; /* This value is 0 */
921 u32 ospm_flags; /* 64BIT_WAKE_F */
922 u8 resv2[24]; /* This value is 0 */
923} __packed acpi_facs_t;
924
925/* FACS flags */
926#define ACPI_FACS_S4BIOS_F (1 << 0)
927#define ACPI_FACS_64BIT_WAKE_F (1 << 1)
928/* Bits 31..2: reserved */
929
930/* ECDT (Embedded Controller Boot Resources Table) */
931typedef struct acpi_ecdt {
932 acpi_header_t header;
933 acpi_addr_t ec_control; /* EC control register */
934 acpi_addr_t ec_data; /* EC data register */
935 u32 uid; /* UID */
936 u8 gpe_bit; /* GPE bit */
937 u8 ec_id[]; /* EC ID */
938} __packed acpi_ecdt_t;
939
940/* HEST (Hardware Error Source Table) */
941typedef struct acpi_hest {
942 acpi_header_t header;
943 u32 error_source_count;
944 /* error_source_struct(s) */
945} __packed acpi_hest_t;
946
947/* Error Source Descriptors */
948typedef struct acpi_hest_esd {
949 u16 type;
950 u16 source_id;
951 u16 resv;
952 u8 flags;
953 u8 enabled;
954 u32 prealloc_erecords; /* The number of error records to
955 * pre-allocate for this error source.
956 */
957 u32 max_section_per_record;
958} __packed acpi_hest_esd_t;
959
960/* Hardware Error Notification */
961typedef struct acpi_hest_hen {
962 u8 type;
963 u8 length;
964 u16 conf_we; /* Configuration Write Enable */
965 u32 poll_interval;
966 u32 vector;
967 u32 sw2poll_threshold_val;
968 u32 sw2poll_threshold_win;
969 u32 error_threshold_val;
970 u32 error_threshold_win;
971} __packed acpi_hest_hen_t;
972
973/* BERT (Boot Error Record Table) */
974typedef struct acpi_bert {
975 acpi_header_t header;
976 u32 region_length;
977 u64 error_region;
978} __packed acpi_bert_t;
979
980/* Generic Error Data Entry */
981typedef struct acpi_hest_generic_data {
982 guid_t section_type;
983 u32 error_severity;
984 u16 revision;
985 u8 validation_bits;
986 u8 flags;
987 u32 data_length;
988 guid_t fru_id;
989 u8 fru_text[20];
990 /* error data */
991} __packed acpi_hest_generic_data_t;
992
993/* Generic Error Data Entry v300 */
994typedef struct acpi_hest_generic_data_v300 {
995 guid_t section_type;
996 u32 error_severity;
997 u16 revision;
998 u8 validation_bits;
999 u8 flags; /* see CPER Section Descriptor, Flags field */
1000 u32 data_length;
1001 guid_t fru_id;
1002 u8 fru_text[20];
1003 cper_timestamp_t timestamp;
1004 /* error data */
1005} __packed acpi_hest_generic_data_v300_t;
1006#define HEST_GENERIC_ENTRY_V300 0x300
1007
1008/* Both Generic Error Status & Generic Error Data Entry, Error Severity field */
1009#define ACPI_GENERROR_SEV_RECOVERABLE 0
1010#define ACPI_GENERROR_SEV_FATAL 1
1011#define ACPI_GENERROR_SEV_CORRECTED 2
1012#define ACPI_GENERROR_SEV_NONE 3
1013
1014/* Generic Error Data Entry, Validation Bits field */
1015#define ACPI_GENERROR_VALID_FRUID BIT(0)
1016#define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1)
1017#define ACPI_GENERROR_VALID_TIMESTAMP BIT(2)
1018
Felix Held403fa862021-07-26 22:43:00 +02001019/*
1020 * Generic Error Status Block
1021 *
1022 * If there is a raw data section at the end of the generic error status block after the
1023 * zero or more generic error data entries, raw_data_length indicates the length of the raw
1024 * section and raw_data_offset is the offset of the beginning of the raw data section from
1025 * the start of the acpi_generic_error_status block it is contained in. So if raw_data_length
1026 * is non-zero, raw_data_offset must be at least sizeof(acpi_generic_error_status_t).
1027 */
Furquan Shaikhe0844632020-05-02 10:23:37 -07001028typedef struct acpi_generic_error_status {
1029 u32 block_status;
1030 u32 raw_data_offset; /* must follow any generic entries */
1031 u32 raw_data_length;
1032 u32 data_length; /* generic data */
1033 u32 error_severity;
1034 /* Generic Error Data structures, zero or more entries */
1035} __packed acpi_generic_error_status_t;
1036
1037/* Generic Status Block, Block Status values */
1038#define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0)
1039#define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1)
1040#define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2)
1041#define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3)
1042#define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4
1043#define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff
1044#define GENERIC_ERR_STS_ENTRY_COUNT_MASK \
1045 (GENERIC_ERR_STS_ENTRY_COUNT_MAX \
1046 << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT)
1047
1048typedef struct acpi_cstate {
1049 u8 ctype;
1050 u16 latency;
1051 u32 power;
1052 acpi_addr_t resource;
1053} __packed acpi_cstate_t;
1054
Jason Gleneskca36aed2020-09-15 21:01:57 -07001055struct acpi_sw_pstate {
1056 u32 core_freq;
1057 u32 power;
1058 u32 transition_latency;
1059 u32 bus_master_latency;
1060 u32 control_value;
1061 u32 status_value;
1062} __packed;
1063
1064struct acpi_xpss_sw_pstate {
1065 u64 core_freq;
1066 u64 power;
1067 u64 transition_latency;
1068 u64 bus_master_latency;
1069 u64 control_value;
1070 u64 status_value;
1071 u64 control_mask;
1072 u64 status_mask;
1073} __packed;
1074
Furquan Shaikhe0844632020-05-02 10:23:37 -07001075typedef struct acpi_tstate {
1076 u32 percent;
1077 u32 power;
1078 u32 latency;
1079 u32 control;
1080 u32 status;
1081} __packed acpi_tstate_t;
1082
Raul E Rangelc7048322021-04-19 15:58:25 -06001083enum acpi_lpi_state_flags {
1084 ACPI_LPI_STATE_DISABLED = 0,
1085 ACPI_LPI_STATE_ENABLED
1086};
1087
1088/* Low Power Idle State */
1089struct acpi_lpi_state {
1090 u32 min_residency_us;
1091 u32 worst_case_wakeup_latency_us;
1092 u32 flags;
1093 u32 arch_context_lost_flags;
1094 u32 residency_counter_frequency_hz;
1095 u32 enabled_parent_state;
1096 acpi_addr_t entry_method;
1097 acpi_addr_t residency_counter_register;
1098 acpi_addr_t usage_counter_register;
1099 const char *state_name;
1100};
1101
Furquan Shaikhe0844632020-05-02 10:23:37 -07001102/* Port types for ACPI _UPC object */
1103enum acpi_upc_type {
1104 UPC_TYPE_A,
1105 UPC_TYPE_MINI_AB,
1106 UPC_TYPE_EXPRESSCARD,
1107 UPC_TYPE_USB3_A,
1108 UPC_TYPE_USB3_B,
1109 UPC_TYPE_USB3_MICRO_B,
1110 UPC_TYPE_USB3_MICRO_AB,
1111 UPC_TYPE_USB3_POWER_B,
1112 UPC_TYPE_C_USB2_ONLY,
1113 UPC_TYPE_C_USB2_SS_SWITCH,
1114 UPC_TYPE_C_USB2_SS,
1115 UPC_TYPE_PROPRIETARY = 0xff,
1116 /*
1117 * The following types are not directly defined in the ACPI
1118 * spec but are used by coreboot to identify a USB device type.
1119 */
1120 UPC_TYPE_INTERNAL = 0xff,
1121 UPC_TYPE_UNUSED,
1122 UPC_TYPE_HUB
1123};
1124
1125enum acpi_ipmi_interface_type {
1126 IPMI_INTERFACE_RESERVED = 0,
1127 IPMI_INTERFACE_KCS,
1128 IPMI_INTERFACE_SMIC,
1129 IPMI_INTERFACE_BT,
1130 IPMI_INTERFACE_SSIF,
1131};
1132
1133#define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0)
1134#define ACPI_IPMI_INT_TYPE_SCI (1 << 0)
1135#define ACPI_IPMI_INT_TYPE_APIC (1 << 1)
1136
1137/* ACPI IPMI 2.0 */
1138struct acpi_spmi {
1139 acpi_header_t header;
1140 u8 interface_type;
1141 u8 reserved;
1142 u16 specification_revision;
1143 u8 interrupt_type;
1144 u8 gpe;
1145 u8 reserved2;
1146 u8 pci_device_flag;
1147
1148 u32 global_system_interrupt;
1149 acpi_addr_t base_address;
1150 union {
1151 struct {
1152 u8 pci_segment_group;
1153 u8 pci_bus;
1154 u8 pci_device;
1155 u8 pci_function;
1156 };
1157 u8 uid[4];
1158 };
1159 u8 reserved3;
1160} __packed;
1161
Rocky Phaguraeff07132021-01-10 15:42:50 -08001162/* EINJ APEI Standard Definitions */
1163/* EINJ Error Types
1164 Refer to the ACPI spec, EINJ section, for more info on bit definitions
1165*/
1166#define ACPI_EINJ_CPU_CE (1 << 0)
1167#define ACPI_EINJ_CPU_UCE (1 << 1)
1168#define ACPI_EINJ_CPU_UCE_FATAL (1 << 2)
1169#define ACPI_EINJ_MEM_CE (1 << 3)
1170#define ACPI_EINJ_MEM_UCE (1 << 4)
1171#define ACPI_EINJ_MEM_UCE_FATAL (1 << 5)
1172#define ACPI_EINJ_PCIE_CE (1 << 6)
1173#define ACPI_EINJ_PCIE_UCE_NON_FATAL (1 << 7)
1174#define ACPI_EINJ_PCIE_UCE_FATAL (1 << 8)
1175#define ACPI_EINJ_PLATFORM_CE (1 << 9)
1176#define ACPI_EINJ_PLATFORM_UCE (1 << 10)
1177#define ACPI_EINJ_PLATFORM_UCE_FATAL (1 << 11)
1178#define ACPI_EINJ_VENDOR_DEFINED (1 << 31)
1179#define ACPI_EINJ_DEFAULT_CAP (ACPI_EINJ_MEM_CE | ACPI_EINJ_MEM_UCE | \
1180 ACPI_EINJ_PCIE_CE | ACPI_EINJ_PCIE_UCE_FATAL)
1181
1182/* EINJ actions */
1183#define ACTION_COUNT 9
1184#define BEGIN_INJECT_OP 0x00
1185#define GET_TRIGGER_ACTION_TABLE 0x01
1186#define SET_ERROR_TYPE 0x02
1187#define GET_ERROR_TYPE 0x03
1188#define END_INJECT_OP 0x04
1189#define EXECUTE_INJECT_OP 0x05
1190#define CHECK_BUSY_STATUS 0x06
1191#define GET_CMD_STATUS 0x07
1192#define SET_ERROR_TYPE_WITH_ADDRESS 0x08
1193#define TRIGGER_ERROR 0xFF
1194
1195/* EINJ Instructions */
1196#define READ_REGISTER 0x00
1197#define READ_REGISTER_VALUE 0x01
1198#define WRITE_REGISTER 0x02
1199#define WRITE_REGISTER_VALUE 0x03
1200#define NO_OP 0x04
1201
1202/* EINJ (Error Injection Table) */
1203typedef struct acpi_gen_regaddr1 {
1204 u8 space_id; /* Address space ID */
1205 u8 bit_width; /* Register size in bits */
1206 u8 bit_offset; /* Register bit offset */
1207 u8 access_size; /* Access size since ACPI 2.0c */
1208 u64 addr; /* Register address */
1209} __packed acpi_addr64_t;
1210
1211/* Instruction entry */
1212typedef struct acpi_einj_action_table {
1213 u8 action;
1214 u8 instruction;
1215 u16 flags;
1216 acpi_addr64_t reg;
1217 u64 value;
1218 u64 mask;
1219} __packed acpi_einj_action_table_t;
1220
1221typedef struct acpi_injection_header {
1222 u32 einj_header_size;
1223 u32 flags;
1224 u32 entry_count;
1225} __packed acpi_injection_header_t;
1226
1227typedef struct acpi_einj_trigger_table {
1228 u32 header_size;
1229 u32 revision;
1230 u32 table_size;
1231 u32 entry_count;
1232 acpi_einj_action_table_t trigger_action[1];
1233} __packed acpi_einj_trigger_table_t;
1234
1235typedef struct set_error_type {
1236 u32 errtype;
1237 u32 vendorerrortype;
1238 u32 flags;
1239 u32 apicid;
1240 u64 memaddr;
1241 u64 memrange;
1242 u32 pciesbdf;
1243} __packed set_error_type_t;
1244
1245#define EINJ_PARAM_NUM 6
1246typedef struct acpi_einj_smi {
1247 u64 op_state;
1248 u64 err_inject[EINJ_PARAM_NUM];
1249 u64 trigger_action_table;
1250 u64 err_inj_cap;
1251 u64 op_status;
1252 u64 cmd_sts;
1253 u64 einj_addr;
1254 u64 einj_addr_msk;
1255 set_error_type_t setaddrtable;
1256 u64 reserved[50];
1257} __packed acpi_einj_smi_t;
1258
1259/* EINJ Flags */
1260#define EINJ_DEF_TRIGGER_PORT 0xb2
1261#define FLAG_PRESERVE 0x01
1262#define FLAG_IGNORE 0x00
1263
1264/* EINJ Registers */
1265#define EINJ_REG_MEMORY(address) \
1266 { \
1267 .space_id = ACPI_ADDRESS_SPACE_MEMORY, \
1268 .bit_width = 64, \
1269 .bit_offset = 0, \
1270 .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \
1271 .addr = address}
1272
1273#define EINJ_REG_IO() \
1274 { \
1275 .space_id = ACPI_ADDRESS_SPACE_IO, \
1276 .bit_width = 0x10, \
1277 .bit_offset = 0, \
1278 .access_size = ACPI_ACCESS_SIZE_WORD_ACCESS, \
1279 .addr = EINJ_DEF_TRIGGER_PORT} /* HW dependent code can override this also */
1280
1281typedef struct acpi_einj {
1282 acpi_header_t header;
1283 acpi_injection_header_t inj_header;
1284 acpi_einj_action_table_t action_table[ACTION_COUNT];
1285} __packed acpi_einj_t;
1286
Arthur Heymans2e7e2d92022-03-03 22:28:27 +01001287uintptr_t get_coreboot_rsdp(void);
Rocky Phaguraeff07132021-01-10 15:42:50 -08001288void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions);
1289
Furquan Shaikhe0844632020-05-02 10:23:37 -07001290unsigned long fw_cfg_acpi_tables(unsigned long start);
1291
1292/* These are implemented by the target port or north/southbridge. */
Raul E Rangel6b446b92021-11-19 11:38:35 -07001293void preload_acpi_dsdt(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001294unsigned long write_acpi_tables(unsigned long addr);
1295unsigned long acpi_fill_madt(unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001296unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current);
1297void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
1298void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length);
1299void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001300
Furquan Shaikhe0844632020-05-02 10:23:37 -07001301void acpi_fill_fadt(acpi_fadt_t *fadt);
Angel Pons79572e42020-07-13 00:17:43 +02001302void arch_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkkif9aac922020-05-30 16:16:28 +03001303void soc_fill_fadt(acpi_fadt_t *fadt);
Kyösti Mälkki02fd15d2020-06-02 03:34:43 +03001304void mainboard_fill_fadt(acpi_fadt_t *fadt);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001305
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001306void acpi_fill_gnvs(void);
Kyösti Mälkki3dc17922021-03-16 19:01:48 +02001307void acpi_fill_cnvs(void);
Kyösti Mälkki2ab4a962020-06-30 11:41:47 +03001308
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001309unsigned long acpi_fill_lpit(unsigned long current);
1310
Furquan Shaikhe0844632020-05-02 10:23:37 -07001311/* These can be used by the target port. */
1312u8 acpi_checksum(u8 *table, u32 length);
1313
1314void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
1315
Jonathan Zhang3dcafa82022-05-11 13:11:20 -07001316/* Create CXL Early Discovery Table */
1317void acpi_create_cedt(acpi_cedt_t *cedt,
1318 unsigned long (*acpi_fill_cedt)(unsigned long current));
1319/* Create a CXL Host Bridge Structure for CEDT */
1320int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base);
1321/* Create a CXL Fixed Memory Window Structure for CEDT */
1322int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size,
1323 u8 eniw, u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target);
1324
Furquan Shaikhe0844632020-05-02 10:23:37 -07001325int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
1326int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
1327 u32 gsi_base);
Kyösti Mälkkic7da0272021-06-08 11:37:08 +03001328int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001329int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
1330 u8 bus, u8 source, u32 gsirq, u16 flags);
1331int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
1332 u16 flags, u8 lint);
1333void acpi_create_madt(acpi_madt_t *madt);
1334unsigned long acpi_create_madt_lapics(unsigned long current);
Kyösti Mälkki66b5e1b2022-11-12 21:13:45 +02001335unsigned long acpi_create_madt_lapics_with_nmis(unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001336int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic);
1337int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu,
1338 u16 flags, u8 lint);
1339int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
1340int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek,
1341 u32 flags);
Jonathan Zhang3164b642021-04-21 17:51:31 -07001342/*
1343 * Given the Generic Initiator device's BDF, the proximity domain's ID
1344 * and flag, create Generic Initiator Affinity structure in SRAT.
1345 */
1346int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain,
1347 u16 seg, u8 bus, u8 dev, u8 func, u32 flags);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001348int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
1349 u16 seg_nr, u8 start, u8 end);
1350unsigned long acpi_create_srat_lapics(unsigned long current);
1351void acpi_create_srat(acpi_srat_t *srat,
1352 unsigned long (*acpi_fill_srat)(unsigned long current));
1353
1354void acpi_create_slit(acpi_slit_t *slit,
1355 unsigned long (*acpi_fill_slit)(unsigned long current));
1356
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001357/*
1358 * Create a Memory Proximity Domain Attributes structure for HMAT,
1359 * given proximity domain for the attached initiaor, and
1360 * proximimity domain for the memory.
1361 */
1362int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory);
Martin Roth0949e732021-10-01 14:28:22 -06001363/* Create Heterogeneous Memory Attribute Table */
Jonathan Zhang2a4e1f42021-04-01 11:43:37 -07001364void acpi_create_hmat(acpi_hmat_t *hmat,
1365 unsigned long (*acpi_fill_hmat)(unsigned long current));
1366
Furquan Shaikhe0844632020-05-02 10:23:37 -07001367void acpi_create_vfct(const struct device *device,
1368 acpi_vfct_t *vfct,
1369 unsigned long (*acpi_fill_vfct)(const struct device *device,
1370 acpi_vfct_t *vfct_struct,
1371 unsigned long current));
1372
1373void acpi_create_ipmi(const struct device *device,
1374 struct acpi_spmi *spmi,
1375 const u16 ipmi_revision,
1376 const acpi_addr_t *addr,
1377 const enum acpi_ipmi_interface_type type,
1378 const s8 gpe_interrupt,
1379 const u32 apic_interrupt,
1380 const u32 uid);
1381
1382void acpi_create_ivrs(acpi_ivrs_t *ivrs,
1383 unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct,
1384 unsigned long current));
1385
Jason Glenesk61624b22020-11-02 20:06:23 -08001386void acpi_create_crat(struct acpi_crat_header *crat,
1387 unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct,
1388 unsigned long current));
1389
Furquan Shaikhe0844632020-05-02 10:23:37 -07001390void acpi_create_hpet(acpi_hpet_t *hpet);
1391unsigned long acpi_write_hpet(const struct device *device, unsigned long start,
1392 acpi_rsdp_t *rsdp);
1393
1394/* cpu/intel/speedstep/acpi.c */
1395void generate_cpu_entries(const struct device *device);
1396
1397void acpi_create_mcfg(acpi_mcfg_t *mcfg);
1398
1399void acpi_create_facs(acpi_facs_t *facs);
1400
1401void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header,
1402 int port_type, int port_subtype,
1403 acpi_addr_t *address, uint32_t address_size,
1404 const char *device_path);
1405
1406unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
1407 const struct device *dev, uint8_t access_size);
1408void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
1409 unsigned long (*acpi_fill_dmar)(unsigned long));
1410unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
1411 u16 segment, u64 bar);
1412unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment,
1413 u64 bar, u64 limit);
1414unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags,
1415 u16 segment);
1416unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr,
1417 u32 proximity_domain);
1418unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number,
1419 const char *device_name);
John Zhao6edbb182021-03-24 11:55:09 -07001420unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags,
John Zhao091532d2021-04-17 16:03:21 -07001421 u16 segment);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001422void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current);
1423void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current);
1424void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current);
John Zhao6edbb182021-03-24 11:55:09 -07001425void acpi_dmar_satc_fixup(unsigned long base, unsigned long current);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001426unsigned long acpi_create_dmar_ds_pci_br(unsigned long current,
1427 u8 bus, u8 dev, u8 fn);
1428unsigned long acpi_create_dmar_ds_pci(unsigned long current,
1429 u8 bus, u8 dev, u8 fn);
1430unsigned long acpi_create_dmar_ds_ioapic(unsigned long current,
1431 u8 enumeration_id,
1432 u8 bus, u8 dev, u8 fn);
Arthur Heymansbc8f8592022-12-02 13:17:39 +01001433unsigned long acpi_create_dmar_ds_ioapic_from_hw(unsigned long current,
1434 u32 addr, u8 bus, u8 dev, u8 fn);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001435unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current,
1436 u8 enumeration_id,
1437 u8 bus, u8 dev, u8 fn);
1438void acpi_write_hest(acpi_hest_t *hest,
1439 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest));
1440
1441unsigned long acpi_create_hest_error_source(acpi_hest_t *hest,
1442 acpi_hest_esd_t *esd, u16 type, void *data, u16 len);
1443
Michael Niewöhnerf0a44ae2021-01-01 21:04:09 +01001444void acpi_create_lpit(acpi_lpit_t *lpit);
1445unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid);
1446
Felix Heldf7dbf4a2021-06-07 16:56:04 +02001447/* chipsets that select ACPI_BERT must implement this function */
Felix Held29405482021-05-28 16:01:57 +02001448enum cb_err acpi_soc_get_bert_region(void **region, size_t *length);
Francois Toguo522e0db2021-01-21 09:55:19 -08001449
Furquan Shaikhe0844632020-05-02 10:23:37 -07001450/* For ACPI S3 support. */
Kyösti Mälkkia4c0e1a2020-06-18 08:28:12 +03001451void __noreturn acpi_resume(void *wake_vec);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001452void mainboard_suspend_resume(void);
1453void *acpi_find_wakeup_vector(void);
1454
1455/* ACPI_Sn assignments are defined to always equal the sleep state numbers */
1456enum {
1457 ACPI_S0 = 0,
1458 ACPI_S1 = 1,
1459 ACPI_S2 = 2,
1460 ACPI_S3 = 3,
1461 ACPI_S4 = 4,
1462 ACPI_S5 = 5,
1463};
1464
1465#if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \
1466 || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES)
1467/* Given the provided PM1 control register return the ACPI sleep type. */
1468static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt)
1469{
1470 switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) {
1471 case SLP_TYP_S0: return ACPI_S0;
1472 case SLP_TYP_S1: return ACPI_S1;
1473 case SLP_TYP_S3: return ACPI_S3;
1474 case SLP_TYP_S4: return ACPI_S4;
1475 case SLP_TYP_S5: return ACPI_S5;
1476 }
1477 return -1;
1478}
1479#endif
1480
Kyösti Mälkkie0d38682020-06-07 12:01:58 +03001481uint8_t acpi_get_preferred_pm_profile(void);
1482
Furquan Shaikhe0844632020-05-02 10:23:37 -07001483/* Returns ACPI_Sx values. */
1484int acpi_get_sleep_type(void);
1485
1486/* Read and clear GPE status */
1487int acpi_get_gpe(int gpe);
1488
Kyösti Mälkki0a9e72e2019-08-11 01:22:28 +03001489/* Once we enter payload, is SMI handler installed and capable of
1490 responding to APM_CNT Advanced Power Management Control commands. */
1491static inline int permanent_smi_handler(void)
1492{
1493 return CONFIG(HAVE_SMI_HANDLER);
1494}
1495
Furquan Shaikhe0844632020-05-02 10:23:37 -07001496static inline int acpi_s3_resume_allowed(void)
1497{
1498 return CONFIG(HAVE_ACPI_RESUME);
1499}
1500
Furquan Shaikhe0844632020-05-02 10:23:37 -07001501static inline int acpi_is_wakeup_s3(void)
1502{
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001503 if (!acpi_s3_resume_allowed())
1504 return 0;
Furquan Shaikhe0844632020-05-02 10:23:37 -07001505
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001506 if (ENV_ROMSTAGE_OR_BEFORE)
1507 return (acpi_get_sleep_type() == ACPI_S3);
1508
Kyösti Mälkkiac0dc4a2020-11-18 07:40:21 +02001509 return romstage_handoff_is_resume();
Kyösti Mälkki4a3f67a2020-06-18 13:44:29 +03001510}
Furquan Shaikhe0844632020-05-02 10:23:37 -07001511
1512static inline uintptr_t acpi_align_current(uintptr_t current)
1513{
1514 return ALIGN_UP(current, 16);
1515}
1516
1517/* ACPI table revisions should match the revision of the ACPI spec
1518 * supported. This function keeps the table versions synced. This could
1519 * be made into a weak function if there is ever a need to override the
1520 * coreboot default ACPI spec version supported. */
1521int get_acpi_table_revision(enum acpi_tables table);
Elyes Haouas8b950f42022-02-16 12:08:16 +01001522u8 get_acpi_fadt_minor_version(void);
Furquan Shaikhe0844632020-05-02 10:23:37 -07001523
Kyösti Mälkki94e04652020-06-01 13:26:22 +03001524#endif // !defined(__ASSEMBLER__) && !defined(__ACPI__)
Furquan Shaikhe0844632020-05-02 10:23:37 -07001525
Furquan Shaikh56eafbb2020-04-30 18:38:55 -07001526#endif /* __ACPI_ACPI_H__ */