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 typedef struct AcpiRsdpData
{
44 char *oem_id
; /* OEM identification */
45 uint8_t revision
; /* Must be 0 for 1.0, 2 for 2.0 */
47 unsigned *rsdt_tbl_offset
;
48 unsigned *xsdt_tbl_offset
;
51 /* Table structure from Linux kernel (the ACPI tables are under the
55 #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \
56 uint32_t signature; /* ACPI signature (4 ASCII characters) */ \
57 uint32_t length; /* Length of table, in bytes, including header */ \
58 uint8_t revision; /* ACPI Specification minor version # */ \
59 uint8_t checksum; /* To make sum of entire table == 0 */ \
61 QEMU_NONSTRING; /* OEM identification */ \
62 uint8_t oem_table_id[8] \
63 QEMU_NONSTRING; /* OEM table identification */ \
64 uint32_t oem_revision; /* OEM revision number */ \
65 uint8_t asl_compiler_id[4] \
66 QEMU_NONSTRING; /* ASL compiler vendor ID */ \
67 uint32_t asl_compiler_revision; /* ASL compiler revision number */
70 /* ACPI common table header */
71 struct AcpiTableHeader
{
74 typedef struct AcpiTableHeader AcpiTableHeader
;
76 struct AcpiGenericAddress
{
77 uint8_t space_id
; /* Address space where struct or register exists */
78 uint8_t bit_width
; /* Size in bits of given register */
79 uint8_t bit_offset
; /* Bit offset within the register */
80 uint8_t access_width
; /* ACPI 3.0: Minimum Access size (ACPI 3.0),
81 ACPI 2.0: Reserved, Table 5-1 */
82 uint64_t address
; /* 64-bit address of struct or register */
85 typedef struct AcpiFadtData
{
86 struct AcpiGenericAddress pm1a_cnt
; /* PM1a_CNT_BLK */
87 struct AcpiGenericAddress pm1a_evt
; /* PM1a_EVT_BLK */
88 struct AcpiGenericAddress pm_tmr
; /* PM_TMR_BLK */
89 struct AcpiGenericAddress gpe0_blk
; /* GPE0_BLK */
90 struct AcpiGenericAddress reset_reg
; /* RESET_REG */
91 struct AcpiGenericAddress sleep_ctl
; /* SLEEP_CONTROL_REG */
92 struct AcpiGenericAddress sleep_sts
; /* SLEEP_STATUS_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 Firmware ACPI Control Structure (FACS)
155 struct AcpiFacsDescriptorRev1
{
156 uint32_t signature
; /* ACPI Signature */
157 uint32_t length
; /* Length of structure, in bytes */
158 uint32_t hardware_signature
; /* Hardware configuration signature */
159 uint32_t firmware_waking_vector
; /* ACPI OS waking vector */
160 uint32_t global_lock
; /* Global Lock */
162 uint8_t resverved3
[40]; /* Reserved - must be zero */
164 typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1
;
166 /* Values for Type in APIC sub-headers */
168 #define ACPI_APIC_GENERIC_CPU_INTERFACE 11
169 #define ACPI_APIC_GENERIC_DISTRIBUTOR 12
170 #define ACPI_APIC_GENERIC_MSI_FRAME 13
171 #define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
172 #define ACPI_APIC_GENERIC_TRANSLATOR 15
173 #define ACPI_APIC_RESERVED 16 /* 16 and greater are reserved */
176 * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
178 #define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */\
182 /* Sub-structures for MADT */
184 struct AcpiMadtGenericCpuInterface
{
187 uint32_t cpu_interface_number
;
190 uint32_t parking_version
;
191 uint32_t performance_interrupt
;
192 uint64_t parked_address
;
193 uint64_t base_address
;
194 uint64_t gicv_base_address
;
195 uint64_t gich_base_address
;
196 uint32_t vgic_interrupt
;
197 uint64_t gicr_base_address
;
201 typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface
;
203 /* GICC CPU Interface Flags */
204 #define ACPI_MADT_GICC_ENABLED 1
206 struct AcpiMadtGenericDistributor
{
210 uint64_t base_address
;
211 uint32_t global_irq_base
;
212 /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */
214 uint8_t reserved2
[3];
217 typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor
;
219 struct AcpiMadtGenericMsiFrame
{
222 uint32_t gic_msi_frame_id
;
223 uint64_t base_address
;
229 typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame
;
231 struct AcpiMadtGenericRedistributor
{
234 uint64_t base_address
;
235 uint32_t range_length
;
238 typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor
;
240 struct AcpiMadtGenericTranslator
{
243 uint32_t translation_id
;
244 uint64_t base_address
;
248 typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator
;
251 * Generic Timer Description Table (GTDT)
253 #define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0)
254 #define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0)
255 #define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2)
257 struct AcpiGenericTimerTable
{
258 ACPI_TABLE_HEADER_DEF
259 uint64_t counter_block_addresss
;
261 uint32_t secure_el1_interrupt
;
262 uint32_t secure_el1_flags
;
263 uint32_t non_secure_el1_interrupt
;
264 uint32_t non_secure_el1_flags
;
265 uint32_t virtual_timer_interrupt
;
266 uint32_t virtual_timer_flags
;
267 uint32_t non_secure_el2_interrupt
;
268 uint32_t non_secure_el2_flags
;
269 uint64_t counter_read_block_address
;
270 uint32_t platform_timer_count
;
271 uint32_t platform_timer_offset
;
273 typedef struct AcpiGenericTimerTable AcpiGenericTimerTable
;
276 * Input Output Remapping Table (IORT)
277 * Conforms to "IO Remapping Table System Software on ARM Platforms",
278 * Document number: ARM DEN 0049B, October 2015
281 struct AcpiIortTable
{
282 ACPI_TABLE_HEADER_DEF
/* ACPI common table header */
284 uint32_t node_offset
;
287 typedef struct AcpiIortTable AcpiIortTable
;
293 #define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \
298 uint32_t mapping_count; \
299 uint32_t mapping_offset;
301 /* Values for node Type above */
303 ACPI_IORT_NODE_ITS_GROUP
= 0x00,
304 ACPI_IORT_NODE_NAMED_COMPONENT
= 0x01,
305 ACPI_IORT_NODE_PCI_ROOT_COMPLEX
= 0x02,
306 ACPI_IORT_NODE_SMMU
= 0x03,
307 ACPI_IORT_NODE_SMMU_V3
= 0x04
310 struct AcpiIortIdMapping
{
313 uint32_t output_base
;
314 uint32_t output_reference
;
317 typedef struct AcpiIortIdMapping AcpiIortIdMapping
;
319 struct AcpiIortMemoryAccess
{
320 uint32_t cache_coherency
;
323 uint8_t memory_flags
;
325 typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess
;
327 struct AcpiIortItsGroup
{
328 ACPI_IORT_NODE_HEADER_DEF
330 uint32_t identifiers
[];
332 typedef struct AcpiIortItsGroup AcpiIortItsGroup
;
334 #define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1
336 struct AcpiIortSmmu3
{
337 ACPI_IORT_NODE_HEADER_DEF
338 uint64_t base_address
;
341 uint64_t vatos_address
;
347 AcpiIortIdMapping id_mapping_array
[];
349 typedef struct AcpiIortSmmu3 AcpiIortSmmu3
;
352 ACPI_IORT_NODE_HEADER_DEF
353 AcpiIortMemoryAccess memory_properties
;
354 uint32_t ats_attribute
;
355 uint32_t pci_segment_number
;
356 AcpiIortIdMapping id_mapping_array
[];
358 typedef struct AcpiIortRC AcpiIortRC
;