acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table
[qemu.git] / include / hw / acpi / acpi-defs.h
blob3f174ba2080ca822b4adf546d32931673add4779
1 /*
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
18 enum {
19 ACPI_FADT_F_WBINVD,
20 ACPI_FADT_F_WBINVD_FLUSH,
21 ACPI_FADT_F_PROC_C1,
22 ACPI_FADT_F_P_LVL2_UP,
23 ACPI_FADT_F_PWR_BUTTON,
24 ACPI_FADT_F_SLP_BUTTON,
25 ACPI_FADT_F_FIX_RTC,
26 ACPI_FADT_F_RTC_S4,
27 ACPI_FADT_F_TMR_VAL_EXT,
28 ACPI_FADT_F_DCK_CAP,
29 ACPI_FADT_F_RESET_REG_SUP,
30 ACPI_FADT_F_SEALED_CASE,
31 ACPI_FADT_F_HEADLESS,
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;
49 } AcpiRsdpData;
51 /* Table structure from Linux kernel (the ACPI tables are under the
52 BSD license) */
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 */ \
60 uint8_t oem_id[6] \
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 {
72 ACPI_TABLE_HEADER_DEF
73 } QEMU_PACKED;
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 */
83 } QEMU_PACKED;
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;
115 } AcpiFadtData;
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;
132 uint8_t irq;
133 uint32_t gsi;
134 uint8_t baud;
135 uint8_t parity;
136 uint8_t stopbits;
137 uint8_t flowctrl;
138 uint8_t term_type;
139 uint8_t reserved2;
140 uint16_t pci_device_id;
141 uint16_t pci_vendor_id;
142 uint8_t pci_bus;
143 uint8_t pci_slot;
144 uint8_t pci_func;
145 uint32_t pci_flags;
146 uint8_t pci_seg;
147 uint32_t reserved3;
148 } QEMU_PACKED;
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 */
161 uint32_t flags;
162 uint8_t resverved3 [40]; /* Reserved - must be zero */
163 } QEMU_PACKED;
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 */\
179 uint8_t type; \
180 uint8_t length;
182 /* Sub-structures for MADT */
184 struct AcpiMadtGenericCpuInterface {
185 ACPI_SUB_HEADER_DEF
186 uint16_t reserved;
187 uint32_t cpu_interface_number;
188 uint32_t uid;
189 uint32_t flags;
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;
198 uint64_t arm_mpidr;
199 } QEMU_PACKED;
201 typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface;
203 /* GICC CPU Interface Flags */
204 #define ACPI_MADT_GICC_ENABLED 1
206 struct AcpiMadtGenericDistributor {
207 ACPI_SUB_HEADER_DEF
208 uint16_t reserved;
209 uint32_t gic_id;
210 uint64_t base_address;
211 uint32_t global_irq_base;
212 /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */
213 uint8_t version;
214 uint8_t reserved2[3];
215 } QEMU_PACKED;
217 typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor;
219 struct AcpiMadtGenericMsiFrame {
220 ACPI_SUB_HEADER_DEF
221 uint16_t reserved;
222 uint32_t gic_msi_frame_id;
223 uint64_t base_address;
224 uint32_t flags;
225 uint16_t spi_count;
226 uint16_t spi_base;
227 } QEMU_PACKED;
229 typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame;
231 struct AcpiMadtGenericRedistributor {
232 ACPI_SUB_HEADER_DEF
233 uint16_t reserved;
234 uint64_t base_address;
235 uint32_t range_length;
236 } QEMU_PACKED;
238 typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor;
240 struct AcpiMadtGenericTranslator {
241 ACPI_SUB_HEADER_DEF
242 uint16_t reserved;
243 uint32_t translation_id;
244 uint64_t base_address;
245 uint32_t reserved2;
246 } QEMU_PACKED;
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;
260 uint32_t reserved;
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;
272 } QEMU_PACKED;
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 */
283 uint32_t node_count;
284 uint32_t node_offset;
285 uint32_t reserved;
286 } QEMU_PACKED;
287 typedef struct AcpiIortTable AcpiIortTable;
290 * IORT node types
293 #define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \
294 uint8_t type; \
295 uint16_t length; \
296 uint8_t revision; \
297 uint32_t reserved; \
298 uint32_t mapping_count; \
299 uint32_t mapping_offset;
301 /* Values for node Type above */
302 enum {
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 {
311 uint32_t input_base;
312 uint32_t id_count;
313 uint32_t output_base;
314 uint32_t output_reference;
315 uint32_t flags;
316 } QEMU_PACKED;
317 typedef struct AcpiIortIdMapping AcpiIortIdMapping;
319 struct AcpiIortMemoryAccess {
320 uint32_t cache_coherency;
321 uint8_t hints;
322 uint16_t reserved;
323 uint8_t memory_flags;
324 } QEMU_PACKED;
325 typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess;
327 struct AcpiIortItsGroup {
328 ACPI_IORT_NODE_HEADER_DEF
329 uint32_t its_count;
330 uint32_t identifiers[];
331 } QEMU_PACKED;
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;
339 uint32_t flags;
340 uint32_t reserved2;
341 uint64_t vatos_address;
342 uint32_t model;
343 uint32_t event_gsiv;
344 uint32_t pri_gsiv;
345 uint32_t gerr_gsiv;
346 uint32_t sync_gsiv;
347 AcpiIortIdMapping id_mapping_array[];
348 } QEMU_PACKED;
349 typedef struct AcpiIortSmmu3 AcpiIortSmmu3;
351 struct AcpiIortRC {
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[];
357 } QEMU_PACKED;
358 typedef struct AcpiIortRC AcpiIortRC;
360 #endif