blob: 9fba6536f505089df5663adb303ba496857f5316 [file] [log] [blame]
Simon Glass858fed12020-04-08 16:57:36 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Helpers for ACPI table generation
4 *
5 * Based on acpi.c from coreboot
6 *
7 * Copyright 2019 Google LLC
8 *
9 * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com>
10 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
11 */
12
13#ifndef __ACPI_TABLE_H__
14#define __ACPI_TABLE_H__
15
Simon Glass4dcacfc2020-05-10 11:40:13 -060016#include <linux/bitops.h>
17
Simon Glass858fed12020-04-08 16:57:36 -060018#define RSDP_SIG "RSD PTR " /* RSDP pointer signature */
19#define OEM_ID "U-BOOT" /* U-Boot */
20#define OEM_TABLE_ID "U-BOOTBL" /* U-Boot Table */
21#define ASLC_ID "INTL" /* Intel ASL Compiler */
22
Simon Glass4ffe8b02020-09-22 12:45:09 -060023/* TODO(sjg@chromium.org): Figure out how to get compiler revision */
24#define ASL_REVISION 0
25
Simon Glass858fed12020-04-08 16:57:36 -060026#define ACPI_RSDP_REV_ACPI_1_0 0
27#define ACPI_RSDP_REV_ACPI_2_0 2
28
Simon Glass4969d212020-04-08 16:57:37 -060029#if !defined(__ACPI__)
30
Simon Glass0e113842020-04-26 09:19:47 -060031struct acpi_ctx;
32
Simon Glass858fed12020-04-08 16:57:36 -060033/*
34 * RSDP (Root System Description Pointer)
35 * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
36 */
37struct acpi_rsdp {
38 char signature[8]; /* RSDP signature */
39 u8 checksum; /* Checksum of the first 20 bytes */
40 char oem_id[6]; /* OEM ID */
41 u8 revision; /* 0 for ACPI 1.0, others 2 */
42 u32 rsdt_address; /* Physical address of RSDT (32 bits) */
43 u32 length; /* Total RSDP length (incl. extended part) */
44 u64 xsdt_address; /* Physical address of XSDT (64 bits) */
45 u8 ext_checksum; /* Checksum of the whole table */
46 u8 reserved[3];
47};
48
49/* Generic ACPI header, provided by (almost) all tables */
50struct __packed acpi_table_header {
51 char signature[4]; /* ACPI signature (4 ASCII characters) */
52 u32 length; /* Table length in bytes (incl. header) */
53 u8 revision; /* Table version (not ACPI version!) */
54 volatile u8 checksum; /* To make sum of entire table == 0 */
55 char oem_id[6]; /* OEM identification */
56 char oem_table_id[8]; /* OEM table identification */
57 u32 oem_revision; /* OEM revision number */
58 char aslc_id[4]; /* ASL compiler vendor ID */
59 u32 aslc_revision; /* ASL compiler revision number */
60};
61
Simon Glass4ffe8b02020-09-22 12:45:09 -060062struct acpi_gen_regaddr {
63 u8 space_id; /* Address space ID */
64 u8 bit_width; /* Register size in bits */
65 u8 bit_offset; /* Register bit offset */
66 u8 access_size; /* Access size */
67 u32 addrl; /* Register address, low 32 bits */
68 u32 addrh; /* Register address, high 32 bits */
69};
70
Simon Glass858fed12020-04-08 16:57:36 -060071/* A maximum number of 32 ACPI tables ought to be enough for now */
72#define MAX_ACPI_TABLES 32
73
74/* RSDT (Root System Description Table) */
75struct acpi_rsdt {
76 struct acpi_table_header header;
77 u32 entry[MAX_ACPI_TABLES];
78};
79
80/* XSDT (Extended System Description Table) */
81struct acpi_xsdt {
82 struct acpi_table_header header;
83 u64 entry[MAX_ACPI_TABLES];
84};
85
Simon Glass4ffe8b02020-09-22 12:45:09 -060086/* HPET timers */
87struct __packed acpi_hpet {
88 struct acpi_table_header header;
89 u32 id;
90 struct acpi_gen_regaddr addr;
91 u8 number;
92 u16 min_tick;
93 u8 attributes;
94};
95
Simon Glass272a7032020-09-22 12:45:32 -060096struct __packed acpi_tpm2 {
97 struct acpi_table_header header;
98 u16 platform_class;
99 u8 reserved[2];
100 u64 control_area;
101 u32 start_method;
102 u8 msp[12];
103 u32 laml;
104 u64 lasa;
105};
106
Simon Glass28026282020-09-22 12:45:33 -0600107struct __packed acpi_tcpa {
108 struct acpi_table_header header;
109 u16 platform_class;
110 u32 laml;
111 u64 lasa;
112};
113
Simon Glass858fed12020-04-08 16:57:36 -0600114/* FADT Preferred Power Management Profile */
115enum acpi_pm_profile {
116 ACPI_PM_UNSPECIFIED = 0,
117 ACPI_PM_DESKTOP,
118 ACPI_PM_MOBILE,
119 ACPI_PM_WORKSTATION,
120 ACPI_PM_ENTERPRISE_SERVER,
121 ACPI_PM_SOHO_SERVER,
122 ACPI_PM_APPLIANCE_PC,
123 ACPI_PM_PERFORMANCE_SERVER,
124 ACPI_PM_TABLET
125};
126
127/* FADT flags for p_lvl2_lat and p_lvl3_lat */
128#define ACPI_FADT_C2_NOT_SUPPORTED 101
129#define ACPI_FADT_C3_NOT_SUPPORTED 1001
130
131/* FADT Boot Architecture Flags */
132#define ACPI_FADT_LEGACY_FREE 0x00
133#define ACPI_FADT_LEGACY_DEVICES BIT(0)
134#define ACPI_FADT_8042 BIT(1)
135#define ACPI_FADT_VGA_NOT_PRESENT BIT(2)
136#define ACPI_FADT_MSI_NOT_SUPPORTED BIT(3)
137#define ACPI_FADT_NO_PCIE_ASPM_CONTROL BIT(4)
138
139/* FADT Feature Flags */
140#define ACPI_FADT_WBINVD BIT(0)
141#define ACPI_FADT_WBINVD_FLUSH BIT(1)
142#define ACPI_FADT_C1_SUPPORTED BIT(2)
143#define ACPI_FADT_C2_MP_SUPPORTED BIT(3)
144#define ACPI_FADT_POWER_BUTTON BIT(4)
145#define ACPI_FADT_SLEEP_BUTTON BIT(5)
146#define ACPI_FADT_FIXED_RTC BIT(6)
147#define ACPI_FADT_S4_RTC_WAKE BIT(7)
148#define ACPI_FADT_32BIT_TIMER BIT(8)
149#define ACPI_FADT_DOCKING_SUPPORTED BIT(9)
150#define ACPI_FADT_RESET_REGISTER BIT(10)
151#define ACPI_FADT_SEALED_CASE BIT(11)
152#define ACPI_FADT_HEADLESS BIT(12)
153#define ACPI_FADT_SLEEP_TYPE BIT(13)
154#define ACPI_FADT_PCI_EXPRESS_WAKE BIT(14)
155#define ACPI_FADT_PLATFORM_CLOCK BIT(15)
156#define ACPI_FADT_S4_RTC_VALID BIT(16)
157#define ACPI_FADT_REMOTE_POWER_ON BIT(17)
158#define ACPI_FADT_APIC_CLUSTER BIT(18)
159#define ACPI_FADT_APIC_PHYSICAL BIT(19)
160#define ACPI_FADT_HW_REDUCED_ACPI BIT(20)
161#define ACPI_FADT_LOW_PWR_IDLE_S0 BIT(21)
162
163enum acpi_address_space_type {
164 ACPI_ADDRESS_SPACE_MEMORY = 0, /* System memory */
165 ACPI_ADDRESS_SPACE_IO, /* System I/O */
166 ACPI_ADDRESS_SPACE_PCI, /* PCI config space */
167 ACPI_ADDRESS_SPACE_EC, /* Embedded controller */
168 ACPI_ADDRESS_SPACE_SMBUS, /* SMBus */
169 ACPI_ADDRESS_SPACE_PCC = 0x0a, /* Platform Comm. Channel */
170 ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */
171};
172
173enum acpi_address_space_size {
174 ACPI_ACCESS_SIZE_UNDEFINED = 0,
175 ACPI_ACCESS_SIZE_BYTE_ACCESS,
176 ACPI_ACCESS_SIZE_WORD_ACCESS,
177 ACPI_ACCESS_SIZE_DWORD_ACCESS,
178 ACPI_ACCESS_SIZE_QWORD_ACCESS
179};
180
Simon Glass858fed12020-04-08 16:57:36 -0600181/* FADT (Fixed ACPI Description Table) */
182struct __packed acpi_fadt {
183 struct acpi_table_header header;
184 u32 firmware_ctrl;
185 u32 dsdt;
186 u8 res1;
187 u8 preferred_pm_profile;
188 u16 sci_int;
189 u32 smi_cmd;
190 u8 acpi_enable;
191 u8 acpi_disable;
192 u8 s4bios_req;
193 u8 pstate_cnt;
194 u32 pm1a_evt_blk;
195 u32 pm1b_evt_blk;
196 u32 pm1a_cnt_blk;
197 u32 pm1b_cnt_blk;
198 u32 pm2_cnt_blk;
199 u32 pm_tmr_blk;
200 u32 gpe0_blk;
201 u32 gpe1_blk;
202 u8 pm1_evt_len;
203 u8 pm1_cnt_len;
204 u8 pm2_cnt_len;
205 u8 pm_tmr_len;
206 u8 gpe0_blk_len;
207 u8 gpe1_blk_len;
208 u8 gpe1_base;
209 u8 cst_cnt;
210 u16 p_lvl2_lat;
211 u16 p_lvl3_lat;
212 u16 flush_size;
213 u16 flush_stride;
214 u8 duty_offset;
215 u8 duty_width;
216 u8 day_alrm;
217 u8 mon_alrm;
218 u8 century;
219 u16 iapc_boot_arch;
220 u8 res2;
221 u32 flags;
222 struct acpi_gen_regaddr reset_reg;
223 u8 reset_value;
224 u16 arm_boot_arch;
225 u8 minor_revision;
226 u32 x_firmware_ctl_l;
227 u32 x_firmware_ctl_h;
228 u32 x_dsdt_l;
229 u32 x_dsdt_h;
230 struct acpi_gen_regaddr x_pm1a_evt_blk;
231 struct acpi_gen_regaddr x_pm1b_evt_blk;
232 struct acpi_gen_regaddr x_pm1a_cnt_blk;
233 struct acpi_gen_regaddr x_pm1b_cnt_blk;
234 struct acpi_gen_regaddr x_pm2_cnt_blk;
235 struct acpi_gen_regaddr x_pm_tmr_blk;
236 struct acpi_gen_regaddr x_gpe0_blk;
237 struct acpi_gen_regaddr x_gpe1_blk;
238};
239
Simon Glassb2672ea2020-04-08 16:57:38 -0600240/* FADT TABLE Revision values - note these do not match the ACPI revision */
241#define ACPI_FADT_REV_ACPI_1_0 1
242#define ACPI_FADT_REV_ACPI_2_0 3
243#define ACPI_FADT_REV_ACPI_3_0 4
244#define ACPI_FADT_REV_ACPI_4_0 4
245#define ACPI_FADT_REV_ACPI_5_0 5
246#define ACPI_FADT_REV_ACPI_6_0 6
247
248/* MADT TABLE Revision values - note these do not match the ACPI revision */
249#define ACPI_MADT_REV_ACPI_3_0 2
250#define ACPI_MADT_REV_ACPI_4_0 3
251#define ACPI_MADT_REV_ACPI_5_0 3
252#define ACPI_MADT_REV_ACPI_6_0 5
253
254#define ACPI_MCFG_REV_ACPI_3_0 1
255
256/* IVRS Revision Field */
257#define IVRS_FORMAT_FIXED 0x01 /* Type 10h & 11h only */
258#define IVRS_FORMAT_MIXED 0x02 /* Type 10h, 11h, & 40h */
259
Simon Glass858fed12020-04-08 16:57:36 -0600260/* FACS flags */
261#define ACPI_FACS_S4BIOS_F BIT(0)
262#define ACPI_FACS_64BIT_WAKE_F BIT(1)
263
264/* FACS (Firmware ACPI Control Structure) */
265struct acpi_facs {
266 char signature[4]; /* "FACS" */
267 u32 length; /* Length in bytes (>= 64) */
268 u32 hardware_signature; /* Hardware signature */
269 u32 firmware_waking_vector; /* Firmware waking vector */
270 u32 global_lock; /* Global lock */
271 u32 flags; /* FACS flags */
272 u32 x_firmware_waking_vector_l; /* X FW waking vector, low */
273 u32 x_firmware_waking_vector_h; /* X FW waking vector, high */
274 u8 version; /* Version 2 */
275 u8 res1[3];
276 u32 ospm_flags; /* OSPM enabled flags */
277 u8 res2[24];
278};
279
280/* MADT flags */
281#define ACPI_MADT_PCAT_COMPAT BIT(0)
282
283/* MADT (Multiple APIC Description Table) */
284struct acpi_madt {
285 struct acpi_table_header header;
286 u32 lapic_addr; /* Local APIC address */
287 u32 flags; /* Multiple APIC flags */
288};
289
290/* MADT: APIC Structure Type*/
291enum acpi_apic_types {
292 ACPI_APIC_LAPIC = 0, /* Processor local APIC */
293 ACPI_APIC_IOAPIC, /* I/O APIC */
294 ACPI_APIC_IRQ_SRC_OVERRIDE, /* Interrupt source override */
295 ACPI_APIC_NMI_SRC, /* NMI source */
296 ACPI_APIC_LAPIC_NMI, /* Local APIC NMI */
297 ACPI_APIC_LAPIC_ADDR_OVERRIDE, /* Local APIC address override */
298 ACPI_APIC_IOSAPIC, /* I/O SAPIC */
299 ACPI_APIC_LSAPIC, /* Local SAPIC */
300 ACPI_APIC_PLATFORM_IRQ_SRC, /* Platform interrupt sources */
301 ACPI_APIC_LX2APIC, /* Processor local x2APIC */
302 ACPI_APIC_LX2APIC_NMI, /* Local x2APIC NMI */
303};
304
305/* MADT: Processor Local APIC Structure */
306
307#define LOCAL_APIC_FLAG_ENABLED BIT(0)
308
309struct acpi_madt_lapic {
310 u8 type; /* Type (0) */
311 u8 length; /* Length in bytes (8) */
312 u8 processor_id; /* ACPI processor ID */
313 u8 apic_id; /* Local APIC ID */
314 u32 flags; /* Local APIC flags */
315};
316
317/* MADT: I/O APIC Structure */
318struct acpi_madt_ioapic {
319 u8 type; /* Type (1) */
320 u8 length; /* Length in bytes (12) */
321 u8 ioapic_id; /* I/O APIC ID */
322 u8 reserved;
323 u32 ioapic_addr; /* I/O APIC address */
324 u32 gsi_base; /* Global system interrupt base */
325};
326
327/* MADT: Interrupt Source Override Structure */
328struct __packed acpi_madt_irqoverride {
329 u8 type; /* Type (2) */
330 u8 length; /* Length in bytes (10) */
331 u8 bus; /* ISA (0) */
332 u8 source; /* Bus-relative int. source (IRQ) */
333 u32 gsirq; /* Global system interrupt */
334 u16 flags; /* MPS INTI flags */
335};
336
337/* MADT: Local APIC NMI Structure */
338struct __packed acpi_madt_lapic_nmi {
339 u8 type; /* Type (4) */
340 u8 length; /* Length in bytes (6) */
341 u8 processor_id; /* ACPI processor ID */
342 u16 flags; /* MPS INTI flags */
343 u8 lint; /* Local APIC LINT# */
344};
345
346/* MCFG (PCI Express MMIO config space BAR description table) */
347struct acpi_mcfg {
348 struct acpi_table_header header;
349 u8 reserved[8];
350};
351
352struct acpi_mcfg_mmconfig {
353 u32 base_address_l;
354 u32 base_address_h;
355 u16 pci_segment_group_number;
356 u8 start_bus_number;
357 u8 end_bus_number;
358 u8 reserved[4];
359};
360
361/* PM1_CNT bit defines */
362#define PM1_CNT_SCI_EN BIT(0)
363
364/* ACPI global NVS structure */
365struct acpi_global_nvs;
366
367/* CSRT (Core System Resource Table) */
368struct acpi_csrt {
369 struct acpi_table_header header;
370};
371
372struct acpi_csrt_group {
373 u32 length;
374 u32 vendor_id;
375 u32 subvendor_id;
376 u16 device_id;
377 u16 subdevice_id;
378 u16 revision;
379 u16 reserved;
380 u32 shared_info_length;
381};
382
383struct acpi_csrt_shared_info {
384 u16 major_version;
385 u16 minor_version;
386 u32 mmio_base_low;
387 u32 mmio_base_high;
388 u32 gsi_interrupt;
389 u8 interrupt_polarity;
390 u8 interrupt_mode;
391 u8 num_channels;
392 u8 dma_address_width;
393 u16 base_request_line;
394 u16 num_handshake_signals;
395 u32 max_block_size;
396};
397
Simon Glass87cf8d22020-09-22 12:45:16 -0600398/* Port types for ACPI _UPC object */
399enum acpi_upc_type {
400 UPC_TYPE_A,
401 UPC_TYPE_MINI_AB,
402 UPC_TYPE_EXPRESSCARD,
403 UPC_TYPE_USB3_A,
404 UPC_TYPE_USB3_B,
405 UPC_TYPE_USB3_MICRO_B,
406 UPC_TYPE_USB3_MICRO_AB,
407 UPC_TYPE_USB3_POWER_B,
408 UPC_TYPE_C_USB2_ONLY,
409 UPC_TYPE_C_USB2_SS_SWITCH,
410 UPC_TYPE_C_USB2_SS,
411 UPC_TYPE_PROPRIETARY = 0xff,
412 /*
413 * The following types are not directly defined in the ACPI
414 * spec but are used by coreboot to identify a USB device type.
415 */
416 UPC_TYPE_INTERNAL = 0xff,
417 UPC_TYPE_UNUSED,
418 UPC_TYPE_HUB
419};
420
421enum dev_scope_type {
422 SCOPE_PCI_ENDPOINT = 1,
423 SCOPE_PCI_SUB = 2,
424 SCOPE_IOAPIC = 3,
425 SCOPE_MSI_HPET = 4,
426 SCOPE_ACPI_NAMESPACE_DEVICE = 5
427};
428
429struct __packed dev_scope {
430 u8 type;
431 u8 length;
432 u8 reserved[2];
433 u8 enumeration;
434 u8 start_bus;
435 struct {
436 u8 dev;
437 u8 fn;
438 } __packed path[0];
439};
440
Simon Glasse9629892020-04-08 16:57:39 -0600441enum dmar_type {
442 DMAR_DRHD = 0,
443 DMAR_RMRR = 1,
444 DMAR_ATSR = 2,
445 DMAR_RHSA = 3,
446 DMAR_ANDD = 4
447};
448
449enum {
450 DRHD_INCLUDE_PCI_ALL = BIT(0)
451};
452
453enum dmar_flags {
454 DMAR_INTR_REMAP = BIT(0),
455 DMAR_X2APIC_OPT_OUT = BIT(1),
456 DMAR_CTRL_PLATFORM_OPT_IN_FLAG = BIT(2),
457};
458
459struct dmar_entry {
460 u16 type;
461 u16 length;
462 u8 flags;
463 u8 reserved;
464 u16 segment;
465 u64 bar;
466};
467
468struct dmar_rmrr_entry {
469 u16 type;
470 u16 length;
471 u16 reserved;
472 u16 segment;
473 u64 bar;
474 u64 limit;
475};
476
477/* DMAR (DMA Remapping Reporting Structure) */
478struct __packed acpi_dmar {
479 struct acpi_table_header header;
480 u8 host_address_width;
481 u8 flags;
482 u8 reserved[10];
483 struct dmar_entry structure[0];
484};
485
Simon Glass858fed12020-04-08 16:57:36 -0600486/* DBG2 definitions are partially used for SPCR interface_type */
487
488/* Types for port_type field */
489
490#define ACPI_DBG2_SERIAL_PORT 0x8000
491#define ACPI_DBG2_1394_PORT 0x8001
492#define ACPI_DBG2_USB_PORT 0x8002
493#define ACPI_DBG2_NET_PORT 0x8003
494
495/* Subtypes for port_subtype field */
496
497#define ACPI_DBG2_16550_COMPATIBLE 0x0000
498#define ACPI_DBG2_16550_SUBSET 0x0001
499#define ACPI_DBG2_ARM_PL011 0x0003
500#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D
501#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E
502#define ACPI_DBG2_ARM_DCC 0x000F
503#define ACPI_DBG2_BCM2835 0x0010
504
505#define ACPI_DBG2_1394_STANDARD 0x0000
506
507#define ACPI_DBG2_USB_XHCI 0x0000
508#define ACPI_DBG2_USB_EHCI 0x0001
509
510#define ACPI_DBG2_UNKNOWN 0x00FF
511
Simon Glass95971892020-09-22 12:45:10 -0600512/* DBG2: Microsoft Debug Port Table 2 header */
513struct __packed acpi_dbg2_header {
514 struct acpi_table_header header;
515 u32 devices_offset;
516 u32 devices_count;
517};
518
519/* DBG2: Microsoft Debug Port Table 2 device entry */
520struct __packed acpi_dbg2_device {
521 u8 revision;
522 u16 length;
523 u8 address_count;
524 u16 namespace_string_length;
525 u16 namespace_string_offset;
526 u16 oem_data_length;
527 u16 oem_data_offset;
528 u16 port_type;
529 u16 port_subtype;
530 u8 reserved[2];
531 u16 base_address_offset;
532 u16 address_size_offset;
533};
534
Simon Glass858fed12020-04-08 16:57:36 -0600535/* SPCR (Serial Port Console Redirection table) */
536struct __packed acpi_spcr {
537 struct acpi_table_header header;
538 u8 interface_type;
539 u8 reserved[3];
540 struct acpi_gen_regaddr serial_port;
541 u8 interrupt_type;
542 u8 pc_interrupt;
543 u32 interrupt; /* Global system interrupt */
544 u8 baud_rate;
545 u8 parity;
546 u8 stop_bits;
547 u8 flow_control;
548 u8 terminal_type;
549 u8 reserved1;
550 u16 pci_device_id; /* Must be 0xffff if not PCI device */
551 u16 pci_vendor_id; /* Must be 0xffff if not PCI device */
552 u8 pci_bus;
553 u8 pci_device;
554 u8 pci_function;
555 u32 pci_flags;
556 u8 pci_segment;
557 u32 reserved2;
558};
559
Simon Glassb2672ea2020-04-08 16:57:38 -0600560/* Tables defined/reserved by ACPI and generated by U-Boot */
561enum acpi_tables {
562 ACPITAB_BERT,
563 ACPITAB_DBG2,
564 ACPITAB_DMAR,
565 ACPITAB_DSDT,
566 ACPITAB_ECDT,
567 ACPITAB_FACS,
568 ACPITAB_FADT,
569 ACPITAB_HEST,
570 ACPITAB_HPET,
571 ACPITAB_IVRS,
572 ACPITAB_MADT,
573 ACPITAB_MCFG,
574 ACPITAB_NHLT,
575 ACPITAB_RSDP,
576 ACPITAB_RSDT,
577 ACPITAB_SLIT,
578 ACPITAB_SPCR,
579 ACPITAB_SPMI,
580 ACPITAB_SRAT,
581 ACPITAB_SSDT,
582 ACPITAB_TCPA,
583 ACPITAB_TPM2,
584 ACPITAB_VFCT,
585 ACPITAB_XSDT,
586
587 ACPITAB_COUNT,
588};
589
590/**
591 * acpi_get_table_revision() - Get the revision number generated for a table
592 *
593 * This keeps the version-number information in one place
594 *
595 * @table: ACPI table to check
596 * @return version number that U-Boot generates
597 */
598int acpi_get_table_revision(enum acpi_tables table);
599
Simon Glasse9629892020-04-08 16:57:39 -0600600/**
601 * acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table
602 *
603 * @dmar: Place to put the table
604 * @flags: DMAR flags to use
605 * @return 0 if OK, -ve on error
606 */
607int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags);
608
Simon Glass17968c32020-04-26 09:19:46 -0600609/**
Simon Glass95971892020-09-22 12:45:10 -0600610 * acpi_create_dbg2() - Create a DBG2 table
611 *
612 * This table describes how to access the debug UART
613 *
614 * @dbg2: Place to put information
615 * @port_type: Serial port type (see ACPI_DBG2_...)
616 * @port_subtype: Serial port sub-type (see ACPI_DBG2_...)
617 * @address: ACPI address of port
618 * @address_size: Size of address space
619 * @device_path: Path of device (created using acpi_device_path())
620 */
621void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
622 int port_type, int port_subtype,
623 struct acpi_gen_regaddr *address, uint32_t address_size,
624 const char *device_path);
625
626/**
Simon Glass17968c32020-04-26 09:19:46 -0600627 * acpi_fill_header() - Set up a new table header
628 *
629 * This sets all fields except length, revision, checksum and aslc_revision
630 *
631 * @header: ACPI header to update
632 * @signature: Table signature to use (4 characters)
633 */
634void acpi_fill_header(struct acpi_table_header *header, char *signature);
635
Simon Glass0e113842020-04-26 09:19:47 -0600636/**
637 * acpi_align() - Align the ACPI output pointer to a 16-byte boundary
638 *
639 * @ctx: ACPI context
640 */
641void acpi_align(struct acpi_ctx *ctx);
642
643/**
644 * acpi_align64() - Align the ACPI output pointer to a 64-byte boundary
645 *
646 * @ctx: ACPI context
647 */
648void acpi_align64(struct acpi_ctx *ctx);
649
650/**
651 * acpi_inc() - Increment the ACPI output pointer by a bit
652 *
653 * The pointer is NOT aligned afterwards.
654 *
655 * @ctx: ACPI context
656 * @amount: Amount to increment by
657 */
658void acpi_inc(struct acpi_ctx *ctx, uint amount);
659
660/**
661 * acpi_inc_align() - Increment the ACPI output pointer by a bit and align
662 *
663 * The pointer is aligned afterwards to a 16-byte boundary
664 *
665 * @ctx: ACPI context
666 * @amount: Amount to increment by
667 */
668void acpi_inc_align(struct acpi_ctx *ctx, uint amount);
669
Simon Glass575a5472020-04-26 09:19:50 -0600670/**
671 * acpi_add_table() - Add a new table to the RSDP and XSDT
672 *
673 * @ctx: ACPI context
674 * @table: Table to add
675 * @return 0 if OK, -E2BIG if too many tables
676 */
677int acpi_add_table(struct acpi_ctx *ctx, void *table);
678
Simon Glass9c442a62020-04-26 09:19:51 -0600679/**
680 * acpi_setup_base_tables() - Set up context along with RSDP, RSDT and XSDT
681 *
682 * Set up the context with the given start position. Some basic tables are
683 * always needed, so set them up as well.
684 *
685 * @ctx: Context to set up
686 */
687void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start);
688
Simon Glass4969d212020-04-08 16:57:37 -0600689#endif /* !__ACPI__*/
690
Simon Glass858fed12020-04-08 16:57:36 -0600691#include <asm/acpi_table.h>
692
693#endif /* __ACPI_TABLE_H__ */