2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License along
13 * with this program; if not, see <http://www.gnu.org/licenses/>.
15 #ifndef QEMU_ACPI_DEFS_H
16 #define QEMU_ACPI_DEFS_H
20 ACPI_FADT_F_WBINVD_FLUSH
,
22 ACPI_FADT_F_P_LVL2_UP
,
23 ACPI_FADT_F_PWR_BUTTON
,
24 ACPI_FADT_F_SLP_BUTTON
,
27 ACPI_FADT_F_TMR_VAL_EXT
,
29 ACPI_FADT_F_RESET_REG_SUP
,
30 ACPI_FADT_F_SEALED_CASE
,
32 ACPI_FADT_F_CPU_SW_SLP
,
33 ACPI_FADT_F_PCI_EXP_WAK
,
34 ACPI_FADT_F_USE_PLATFORM_CLOCK
,
35 ACPI_FADT_F_S4_RTC_STS_VALID
,
36 ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE
,
37 ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL
,
38 ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE
,
39 ACPI_FADT_F_HW_REDUCED_ACPI
,
40 ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE
,
43 struct AcpiRsdpDescriptor
{ /* Root System Descriptor Pointer */
44 uint64_t signature
; /* ACPI signature, contains "RSD PTR " */
45 uint8_t checksum
; /* To make sum of struct == 0 */
46 uint8_t oem_id
[6]; /* OEM identification */
47 uint8_t revision
; /* Must be 0 for 1.0, 2 for 2.0 */
48 uint32_t rsdt_physical_address
; /* 32-bit physical address of RSDT */
49 uint32_t length
; /* XSDT Length in bytes including hdr */
50 uint64_t xsdt_physical_address
; /* 64-bit physical address of XSDT */
51 uint8_t extended_checksum
; /* Checksum of entire table */
52 uint8_t reserved
[3]; /* Reserved field must be 0 */
54 typedef struct AcpiRsdpDescriptor AcpiRsdpDescriptor
;
56 /* Table structure from Linux kernel (the ACPI tables are under the
60 #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \
61 uint32_t signature; /* ACPI signature (4 ASCII characters) */ \
62 uint32_t length; /* Length of table, in bytes, including header */ \
63 uint8_t revision; /* ACPI Specification minor version # */ \
64 uint8_t checksum; /* To make sum of entire table == 0 */ \
65 uint8_t oem_id [6]; /* OEM identification */ \
66 uint8_t oem_table_id [8]; /* OEM table identification */ \
67 uint32_t oem_revision; /* OEM revision number */ \
68 uint8_t asl_compiler_id [4]; /* ASL compiler vendor ID */ \
69 uint32_t asl_compiler_revision; /* ASL compiler revision number */
72 /* ACPI common table header */
73 struct AcpiTableHeader
{
76 typedef struct AcpiTableHeader AcpiTableHeader
;
78 struct AcpiGenericAddress
{
79 uint8_t space_id
; /* Address space where struct or register exists */
80 uint8_t bit_width
; /* Size in bits of given register */
81 uint8_t bit_offset
; /* Bit offset within the register */
82 uint8_t access_width
; /* ACPI 3.0: Minimum Access size (ACPI 3.0),
83 ACPI 2.0: Reserved, Table 5-1 */
84 uint64_t address
; /* 64-bit address of struct or register */
87 typedef struct AcpiFadtData
{
88 struct AcpiGenericAddress pm1a_cnt
; /* PM1a_CNT_BLK */
89 struct AcpiGenericAddress pm1a_evt
; /* PM1a_EVT_BLK */
90 struct AcpiGenericAddress pm_tmr
; /* PM_TMR_BLK */
91 struct AcpiGenericAddress gpe0_blk
; /* GPE0_BLK */
92 struct AcpiGenericAddress reset_reg
; /* RESET_REG */
93 uint8_t reset_val
; /* RESET_VALUE */
94 uint8_t rev
; /* Revision */
95 uint32_t flags
; /* Flags */
96 uint32_t smi_cmd
; /* SMI_CMD */
97 uint16_t sci_int
; /* SCI_INT */
98 uint8_t int_model
; /* INT_MODEL */
99 uint8_t acpi_enable_cmd
; /* ACPI_ENABLE */
100 uint8_t acpi_disable_cmd
; /* ACPI_DISABLE */
101 uint8_t rtc_century
; /* CENTURY */
102 uint16_t plvl2_lat
; /* P_LVL2_LAT */
103 uint16_t plvl3_lat
; /* P_LVL3_LAT */
104 uint16_t arm_boot_arch
; /* ARM_BOOT_ARCH */
105 uint8_t minor_ver
; /* FADT Minor Version */
108 * respective tables offsets within ACPI_BUILD_TABLE_FILE,
109 * NULL if table doesn't exist (in that case field's value
110 * won't be patched by linker and will be kept set to 0)
112 unsigned *facs_tbl_offset
; /* FACS offset in */
113 unsigned *dsdt_tbl_offset
;
114 unsigned *xdsdt_tbl_offset
;
117 #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
118 #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
121 * Serial Port Console Redirection Table (SPCR), Rev. 1.02
123 * For .interface_type see Debug Port Table 2 (DBG2) serial port
124 * subtypes in Table 3, Rev. May 22, 2012
126 struct AcpiSerialPortConsoleRedirection
{
127 ACPI_TABLE_HEADER_DEF
128 uint8_t interface_type
;
129 uint8_t reserved1
[3];
130 struct AcpiGenericAddress base_address
;
131 uint8_t interrupt_types
;
140 uint16_t pci_device_id
;
141 uint16_t pci_vendor_id
;
149 typedef struct AcpiSerialPortConsoleRedirection
150 AcpiSerialPortConsoleRedirection
;
153 * ACPI 1.0 Root System Description Table (RSDT)
155 struct AcpiRsdtDescriptorRev1
{
156 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
157 uint32_t table_offset_entry
[0]; /* Array of pointers to other */
160 typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1
;
163 * ACPI 2.0 eXtended System Description Table (XSDT)
165 struct AcpiXsdtDescriptorRev2
{
166 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
167 uint64_t table_offset_entry
[0]; /* Array of pointers to other */
170 typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2
;
173 * ACPI 1.0 Firmware ACPI Control Structure (FACS)
175 struct AcpiFacsDescriptorRev1
{
176 uint32_t signature
; /* ACPI Signature */
177 uint32_t length
; /* Length of structure, in bytes */
178 uint32_t hardware_signature
; /* Hardware configuration signature */
179 uint32_t firmware_waking_vector
; /* ACPI OS waking vector */
180 uint32_t global_lock
; /* Global Lock */
182 uint8_t resverved3
[40]; /* Reserved - must be zero */
184 typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1
;
187 * Differentiated System Description Table (DSDT)
191 * MADT values and structures
194 /* Values for MADT PCATCompat */
196 #define ACPI_DUAL_PIC 0
197 #define ACPI_MULTIPLE_APIC 1
201 struct AcpiMultipleApicTable
{
202 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
203 uint32_t local_apic_address
; /* Physical address of local APIC */
206 typedef struct AcpiMultipleApicTable AcpiMultipleApicTable
;
208 /* Values for Type in APIC sub-headers */
210 #define ACPI_APIC_PROCESSOR 0
211 #define ACPI_APIC_IO 1
212 #define ACPI_APIC_XRUPT_OVERRIDE 2
213 #define ACPI_APIC_NMI 3
214 #define ACPI_APIC_LOCAL_NMI 4
215 #define ACPI_APIC_ADDRESS_OVERRIDE 5
216 #define ACPI_APIC_IO_SAPIC 6
217 #define ACPI_APIC_LOCAL_SAPIC 7
218 #define ACPI_APIC_XRUPT_SOURCE 8
219 #define ACPI_APIC_LOCAL_X2APIC 9
220 #define ACPI_APIC_LOCAL_X2APIC_NMI 10
221 #define ACPI_APIC_GENERIC_CPU_INTERFACE 11
222 #define ACPI_APIC_GENERIC_DISTRIBUTOR 12
223 #define ACPI_APIC_GENERIC_MSI_FRAME 13
224 #define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
225 #define ACPI_APIC_GENERIC_TRANSLATOR 15
226 #define ACPI_APIC_RESERVED 16 /* 16 and greater are reserved */
229 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
231 #define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */\
235 /* Sub-structures for MADT */
237 struct AcpiMadtProcessorApic
{
239 uint8_t processor_id
; /* ACPI processor id */
240 uint8_t local_apic_id
; /* Processor's local APIC id */
243 typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic
;
245 struct AcpiMadtIoApic
{
247 uint8_t io_apic_id
; /* I/O APIC ID */
248 uint8_t reserved
; /* Reserved - must be zero */
249 uint32_t address
; /* APIC physical address */
250 uint32_t interrupt
; /* Global system interrupt where INTI
253 typedef struct AcpiMadtIoApic AcpiMadtIoApic
;
255 struct AcpiMadtIntsrcovr
{
262 typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr
;
264 struct AcpiMadtLocalNmi
{
266 uint8_t processor_id
; /* ACPI processor id */
267 uint16_t flags
; /* MPS INTI flags */
268 uint8_t lint
; /* Local APIC LINT# */
270 typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi
;
272 struct AcpiMadtProcessorX2Apic
{
275 uint32_t x2apic_id
; /* Processor's local x2APIC ID */
277 uint32_t uid
; /* Processor object _UID */
279 typedef struct AcpiMadtProcessorX2Apic AcpiMadtProcessorX2Apic
;
281 struct AcpiMadtLocalX2ApicNmi
{
283 uint16_t flags
; /* MPS INTI flags */
284 uint32_t uid
; /* Processor object _UID */
285 uint8_t lint
; /* Local APIC LINT# */
286 uint8_t reserved
[3]; /* Local APIC LINT# */
288 typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi
;
290 struct AcpiMadtGenericCpuInterface
{
293 uint32_t cpu_interface_number
;
296 uint32_t parking_version
;
297 uint32_t performance_interrupt
;
298 uint64_t parked_address
;
299 uint64_t base_address
;
300 uint64_t gicv_base_address
;
301 uint64_t gich_base_address
;
302 uint32_t vgic_interrupt
;
303 uint64_t gicr_base_address
;
307 typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface
;
309 /* GICC CPU Interface Flags */
310 #define ACPI_MADT_GICC_ENABLED 1
312 struct AcpiMadtGenericDistributor
{
316 uint64_t base_address
;
317 uint32_t global_irq_base
;
318 /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */
320 uint8_t reserved2
[3];
323 typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor
;
325 struct AcpiMadtGenericMsiFrame
{
328 uint32_t gic_msi_frame_id
;
329 uint64_t base_address
;
335 typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame
;
337 struct AcpiMadtGenericRedistributor
{
340 uint64_t base_address
;
341 uint32_t range_length
;
344 typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor
;
346 struct AcpiMadtGenericTranslator
{
349 uint32_t translation_id
;
350 uint64_t base_address
;
354 typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator
;
357 * Generic Timer Description Table (GTDT)
359 #define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0)
360 #define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0)
361 #define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2)
363 struct AcpiGenericTimerTable
{
364 ACPI_TABLE_HEADER_DEF
365 uint64_t counter_block_addresss
;
367 uint32_t secure_el1_interrupt
;
368 uint32_t secure_el1_flags
;
369 uint32_t non_secure_el1_interrupt
;
370 uint32_t non_secure_el1_flags
;
371 uint32_t virtual_timer_interrupt
;
372 uint32_t virtual_timer_flags
;
373 uint32_t non_secure_el2_interrupt
;
374 uint32_t non_secure_el2_flags
;
375 uint64_t counter_read_block_address
;
376 uint32_t platform_timer_count
;
377 uint32_t platform_timer_offset
;
379 typedef struct AcpiGenericTimerTable AcpiGenericTimerTable
;
382 * HPET Description Table
385 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
386 uint32_t timer_block_id
;
387 struct AcpiGenericAddress addr
;
390 uint8_t page_protect
;
392 typedef struct Acpi20Hpet Acpi20Hpet
;
395 * SRAT (NUMA topology description) table
398 struct AcpiSystemResourceAffinityTable
{
399 ACPI_TABLE_HEADER_DEF
401 uint32_t reserved2
[2];
403 typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable
;
405 #define ACPI_SRAT_PROCESSOR_APIC 0
406 #define ACPI_SRAT_MEMORY 1
407 #define ACPI_SRAT_PROCESSOR_x2APIC 2
408 #define ACPI_SRAT_PROCESSOR_GICC 3
410 struct AcpiSratProcessorAffinity
{
412 uint8_t proximity_lo
;
413 uint8_t local_apic_id
;
415 uint8_t local_sapic_eid
;
416 uint8_t proximity_hi
[3];
419 typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity
;
421 struct AcpiSratProcessorX2ApicAffinity
{
424 uint32_t proximity_domain
;
430 typedef struct AcpiSratProcessorX2ApicAffinity AcpiSratProcessorX2ApicAffinity
;
432 struct AcpiSratMemoryAffinity
{
437 uint64_t range_length
;
440 uint32_t reserved3
[2];
442 typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity
;
444 struct AcpiSratProcessorGiccAffinity
{
447 uint32_t acpi_processor_uid
;
449 uint32_t clock_domain
;
452 typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity
;
454 /* PCI fw r3.0 MCFG table. */
456 struct AcpiMcfgAllocation
{
457 uint64_t address
; /* Base address, processor-relative */
458 uint16_t pci_segment
; /* PCI segment group number */
459 uint8_t start_bus_number
; /* Starting PCI Bus number */
460 uint8_t end_bus_number
; /* Final PCI Bus number */
463 typedef struct AcpiMcfgAllocation AcpiMcfgAllocation
;
465 struct AcpiTableMcfg
{
466 ACPI_TABLE_HEADER_DEF
;
468 AcpiMcfgAllocation allocation
[0];
470 typedef struct AcpiTableMcfg AcpiTableMcfg
;
473 * TCPA Description Table
475 * Following Level 00, Rev 00.37 of specs:
476 * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification
479 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
480 uint16_t platform_class
;
481 uint32_t log_area_minimum_length
;
482 uint64_t log_area_start_address
;
484 typedef struct Acpi20Tcpa Acpi20Tcpa
;
489 * Following Version 1.2, Revision 8 of specs:
490 * https://trustedcomputinggroup.org/tcg-acpi-specification/
493 ACPI_TABLE_HEADER_DEF
494 uint16_t platform_class
;
496 uint64_t control_area_address
;
497 uint32_t start_method
;
498 uint8_t start_method_params
[12];
499 uint32_t log_area_minimum_length
;
500 uint64_t log_area_start_address
;
502 typedef struct Acpi20TPM2 Acpi20TPM2
;
504 /* DMAR - DMA Remapping table r2.2 */
505 struct AcpiTableDmar
{
506 ACPI_TABLE_HEADER_DEF
507 uint8_t host_address_width
; /* Maximum DMA physical addressability */
509 uint8_t reserved
[10];
511 typedef struct AcpiTableDmar AcpiTableDmar
;
513 /* Masks for Flags field above */
514 #define ACPI_DMAR_INTR_REMAP 1
515 #define ACPI_DMAR_X2APIC_OPT_OUT (1 << 1)
517 /* Values for sub-structure type for DMAR */
519 ACPI_DMAR_TYPE_HARDWARE_UNIT
= 0, /* DRHD */
520 ACPI_DMAR_TYPE_RESERVED_MEMORY
= 1, /* RMRR */
521 ACPI_DMAR_TYPE_ATSR
= 2, /* ATSR */
522 ACPI_DMAR_TYPE_HARDWARE_AFFINITY
= 3, /* RHSR */
523 ACPI_DMAR_TYPE_ANDD
= 4, /* ANDD */
524 ACPI_DMAR_TYPE_RESERVED
= 5 /* Reserved for furture use */
528 * Sub-structures for DMAR
531 /* Device scope structure for DRHD. */
532 struct AcpiDmarDeviceScope
{
536 uint8_t enumeration_id
;
543 typedef struct AcpiDmarDeviceScope AcpiDmarDeviceScope
;
545 /* Type 0: Hardware Unit Definition */
546 struct AcpiDmarHardwareUnit
{
551 uint16_t pci_segment
; /* The PCI Segment associated with this unit */
552 uint64_t address
; /* Base address of remapping hardware register-set */
553 AcpiDmarDeviceScope scope
[0];
555 typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit
;
557 /* Type 2: Root Port ATS Capability Reporting Structure */
558 struct AcpiDmarRootPortATS
{
563 uint16_t pci_segment
;
564 AcpiDmarDeviceScope scope
[0];
566 typedef struct AcpiDmarRootPortATS AcpiDmarRootPortATS
;
568 /* Masks for Flags field above */
569 #define ACPI_DMAR_INCLUDE_PCI_ALL 1
570 #define ACPI_DMAR_ATSR_ALL_PORTS 1
573 * Input Output Remapping Table (IORT)
574 * Conforms to "IO Remapping Table System Software on ARM Platforms",
575 * Document number: ARM DEN 0049B, October 2015
578 struct AcpiIortTable
{
579 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
581 uint32_t node_offset
;
584 typedef struct AcpiIortTable AcpiIortTable
;
590 #define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \
595 uint32_t mapping_count; \
596 uint32_t mapping_offset;
598 /* Values for node Type above */
600 ACPI_IORT_NODE_ITS_GROUP
= 0x00,
601 ACPI_IORT_NODE_NAMED_COMPONENT
= 0x01,
602 ACPI_IORT_NODE_PCI_ROOT_COMPLEX
= 0x02,
603 ACPI_IORT_NODE_SMMU
= 0x03,
604 ACPI_IORT_NODE_SMMU_V3
= 0x04
607 struct AcpiIortIdMapping
{
610 uint32_t output_base
;
611 uint32_t output_reference
;
614 typedef struct AcpiIortIdMapping AcpiIortIdMapping
;
616 struct AcpiIortMemoryAccess
{
617 uint32_t cache_coherency
;
620 uint8_t memory_flags
;
622 typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess
;
624 struct AcpiIortItsGroup
{
625 ACPI_IORT_NODE_HEADER_DEF
627 uint32_t identifiers
[0];
629 typedef struct AcpiIortItsGroup AcpiIortItsGroup
;
631 struct AcpiIortSmmu3
{
632 ACPI_IORT_NODE_HEADER_DEF
633 uint64_t base_address
;
636 uint64_t vatos_address
;
642 AcpiIortIdMapping id_mapping_array
[0];
644 typedef struct AcpiIortSmmu3 AcpiIortSmmu3
;
647 ACPI_IORT_NODE_HEADER_DEF
648 AcpiIortMemoryAccess memory_properties
;
649 uint32_t ats_attribute
;
650 uint32_t pci_segment_number
;
651 AcpiIortIdMapping id_mapping_array
[0];
653 typedef struct AcpiIortRC AcpiIortRC
;