xref: /qemu/include/hw/acpi/acpi-defs.h (revision cb51ac2ffe3649eb8f5c65dccc2012f0ba2c6b12)
172c194f7SMichael S. Tsirkin /*
272c194f7SMichael S. Tsirkin  * This program is free software; you can redistribute it and/or modify
372c194f7SMichael S. Tsirkin  * it under the terms of the GNU General Public License as published by
472c194f7SMichael S. Tsirkin  * the Free Software Foundation; either version 2 of the License, or
572c194f7SMichael S. Tsirkin  * (at your option) any later version.
672c194f7SMichael S. Tsirkin 
772c194f7SMichael S. Tsirkin  * This program is distributed in the hope that it will be useful,
872c194f7SMichael S. Tsirkin  * but WITHOUT ANY WARRANTY; without even the implied warranty of
972c194f7SMichael S. Tsirkin  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1072c194f7SMichael S. Tsirkin  * GNU General Public License for more details.
1172c194f7SMichael S. Tsirkin 
1272c194f7SMichael S. Tsirkin  * You should have received a copy of the GNU General Public License along
1372c194f7SMichael S. Tsirkin  * with this program; if not, see <http://www.gnu.org/licenses/>.
1472c194f7SMichael S. Tsirkin  */
1572c194f7SMichael S. Tsirkin #ifndef QEMU_ACPI_DEFS_H
1672c194f7SMichael S. Tsirkin #define QEMU_ACPI_DEFS_H
1772c194f7SMichael S. Tsirkin 
1872c194f7SMichael S. Tsirkin enum {
1972c194f7SMichael S. Tsirkin     ACPI_FADT_F_WBINVD,
2072c194f7SMichael S. Tsirkin     ACPI_FADT_F_WBINVD_FLUSH,
2172c194f7SMichael S. Tsirkin     ACPI_FADT_F_PROC_C1,
2272c194f7SMichael S. Tsirkin     ACPI_FADT_F_P_LVL2_UP,
2372c194f7SMichael S. Tsirkin     ACPI_FADT_F_PWR_BUTTON,
2472c194f7SMichael S. Tsirkin     ACPI_FADT_F_SLP_BUTTON,
2572c194f7SMichael S. Tsirkin     ACPI_FADT_F_FIX_RTC,
2672c194f7SMichael S. Tsirkin     ACPI_FADT_F_RTC_S4,
2772c194f7SMichael S. Tsirkin     ACPI_FADT_F_TMR_VAL_EXT,
2872c194f7SMichael S. Tsirkin     ACPI_FADT_F_DCK_CAP,
2972c194f7SMichael S. Tsirkin     ACPI_FADT_F_RESET_REG_SUP,
3072c194f7SMichael S. Tsirkin     ACPI_FADT_F_SEALED_CASE,
3172c194f7SMichael S. Tsirkin     ACPI_FADT_F_HEADLESS,
3272c194f7SMichael S. Tsirkin     ACPI_FADT_F_CPU_SW_SLP,
3372c194f7SMichael S. Tsirkin     ACPI_FADT_F_PCI_EXP_WAK,
3472c194f7SMichael S. Tsirkin     ACPI_FADT_F_USE_PLATFORM_CLOCK,
3572c194f7SMichael S. Tsirkin     ACPI_FADT_F_S4_RTC_STS_VALID,
3672c194f7SMichael S. Tsirkin     ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE,
3772c194f7SMichael S. Tsirkin     ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL,
3872c194f7SMichael S. Tsirkin     ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE,
3972c194f7SMichael S. Tsirkin     ACPI_FADT_F_HW_REDUCED_ACPI,
4072c194f7SMichael S. Tsirkin     ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE,
4172c194f7SMichael S. Tsirkin };
4272c194f7SMichael S. Tsirkin 
4372c194f7SMichael S. Tsirkin /*
4472c194f7SMichael S. Tsirkin  * ACPI 2.0 Generic Address Space definition.
4572c194f7SMichael S. Tsirkin  */
4672c194f7SMichael S. Tsirkin struct Acpi20GenericAddress {
4772c194f7SMichael S. Tsirkin     uint8_t  address_space_id;
4872c194f7SMichael S. Tsirkin     uint8_t  register_bit_width;
4972c194f7SMichael S. Tsirkin     uint8_t  register_bit_offset;
5072c194f7SMichael S. Tsirkin     uint8_t  reserved;
5172c194f7SMichael S. Tsirkin     uint64_t address;
5272c194f7SMichael S. Tsirkin } QEMU_PACKED;
5372c194f7SMichael S. Tsirkin typedef struct Acpi20GenericAddress Acpi20GenericAddress;
5472c194f7SMichael S. Tsirkin 
5572c194f7SMichael S. Tsirkin struct AcpiRsdpDescriptor {        /* Root System Descriptor Pointer */
5672c194f7SMichael S. Tsirkin     uint64_t signature;              /* ACPI signature, contains "RSD PTR " */
5772c194f7SMichael S. Tsirkin     uint8_t  checksum;               /* To make sum of struct == 0 */
5872c194f7SMichael S. Tsirkin     uint8_t  oem_id [6];             /* OEM identification */
5972c194f7SMichael S. Tsirkin     uint8_t  revision;               /* Must be 0 for 1.0, 2 for 2.0 */
6072c194f7SMichael S. Tsirkin     uint32_t rsdt_physical_address;  /* 32-bit physical address of RSDT */
6172c194f7SMichael S. Tsirkin     uint32_t length;                 /* XSDT Length in bytes including hdr */
6272c194f7SMichael S. Tsirkin     uint64_t xsdt_physical_address;  /* 64-bit physical address of XSDT */
6372c194f7SMichael S. Tsirkin     uint8_t  extended_checksum;      /* Checksum of entire table */
6472c194f7SMichael S. Tsirkin     uint8_t  reserved [3];           /* Reserved field must be 0 */
6572c194f7SMichael S. Tsirkin } QEMU_PACKED;
6672c194f7SMichael S. Tsirkin typedef struct AcpiRsdpDescriptor AcpiRsdpDescriptor;
6772c194f7SMichael S. Tsirkin 
6872c194f7SMichael S. Tsirkin /* Table structure from Linux kernel (the ACPI tables are under the
6972c194f7SMichael S. Tsirkin    BSD license) */
7072c194f7SMichael S. Tsirkin 
7172c194f7SMichael S. Tsirkin 
7272c194f7SMichael S. Tsirkin #define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
7372c194f7SMichael S. Tsirkin     uint32_t signature;          /* ACPI signature (4 ASCII characters) */ \
7472c194f7SMichael S. Tsirkin     uint32_t length;                 /* Length of table, in bytes, including header */ \
7572c194f7SMichael S. Tsirkin     uint8_t  revision;               /* ACPI Specification minor version # */ \
7672c194f7SMichael S. Tsirkin     uint8_t  checksum;               /* To make sum of entire table == 0 */ \
7772c194f7SMichael S. Tsirkin     uint8_t  oem_id [6];             /* OEM identification */ \
7872c194f7SMichael S. Tsirkin     uint8_t  oem_table_id [8];       /* OEM table identification */ \
7972c194f7SMichael S. Tsirkin     uint32_t oem_revision;           /* OEM revision number */ \
8072c194f7SMichael S. Tsirkin     uint8_t  asl_compiler_id [4];    /* ASL compiler vendor ID */ \
8172c194f7SMichael S. Tsirkin     uint32_t asl_compiler_revision;  /* ASL compiler revision number */
8272c194f7SMichael S. Tsirkin 
8372c194f7SMichael S. Tsirkin 
8472c194f7SMichael S. Tsirkin struct AcpiTableHeader         /* ACPI common table header */
8572c194f7SMichael S. Tsirkin {
8672c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF
8772c194f7SMichael S. Tsirkin } QEMU_PACKED;
8872c194f7SMichael S. Tsirkin typedef struct AcpiTableHeader AcpiTableHeader;
8972c194f7SMichael S. Tsirkin 
9072c194f7SMichael S. Tsirkin /*
91c2f7c0c3SShannon Zhao  * ACPI Fixed ACPI Description Table (FADT)
9272c194f7SMichael S. Tsirkin  */
93c2f7c0c3SShannon Zhao #define ACPI_FADT_COMMON_DEF /* FADT common definition */ \
94c2f7c0c3SShannon Zhao     ACPI_TABLE_HEADER_DEF    /* ACPI common table header */ \
95c2f7c0c3SShannon Zhao     uint32_t firmware_ctrl;  /* Physical address of FACS */ \
96c2f7c0c3SShannon Zhao     uint32_t dsdt;         /* Physical address of DSDT */ \
97c2f7c0c3SShannon Zhao     uint8_t  model;        /* System Interrupt Model */ \
98c2f7c0c3SShannon Zhao     uint8_t  reserved1;    /* Reserved */ \
99c2f7c0c3SShannon Zhao     uint16_t sci_int;      /* System vector of SCI interrupt */ \
100c2f7c0c3SShannon Zhao     uint32_t smi_cmd;      /* Port address of SMI command port */ \
101c2f7c0c3SShannon Zhao     uint8_t  acpi_enable;  /* Value to write to smi_cmd to enable ACPI */ \
102c2f7c0c3SShannon Zhao     uint8_t  acpi_disable; /* Value to write to smi_cmd to disable ACPI */ \
103c2f7c0c3SShannon Zhao     /* Value to write to SMI CMD to enter S4BIOS state */ \
104c2f7c0c3SShannon Zhao     uint8_t  S4bios_req; \
105c2f7c0c3SShannon Zhao     uint8_t  reserved2;    /* Reserved - must be zero */ \
106c2f7c0c3SShannon Zhao     /* Port address of Power Mgt 1a acpi_event Reg Blk */ \
107c2f7c0c3SShannon Zhao     uint32_t pm1a_evt_blk; \
108c2f7c0c3SShannon Zhao     /* Port address of Power Mgt 1b acpi_event Reg Blk */ \
109c2f7c0c3SShannon Zhao     uint32_t pm1b_evt_blk; \
110c2f7c0c3SShannon Zhao     uint32_t pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ \
111c2f7c0c3SShannon Zhao     uint32_t pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ \
112c2f7c0c3SShannon Zhao     uint32_t pm2_cnt_blk;  /* Port address of Power Mgt 2 Control Reg Blk */ \
113c2f7c0c3SShannon Zhao     uint32_t pm_tmr_blk;   /* Port address of Power Mgt Timer Ctrl Reg Blk */ \
114c2f7c0c3SShannon Zhao     /* Port addr of General Purpose acpi_event 0 Reg Blk */ \
115c2f7c0c3SShannon Zhao     uint32_t gpe0_blk; \
116c2f7c0c3SShannon Zhao     /* Port addr of General Purpose acpi_event 1 Reg Blk */ \
117c2f7c0c3SShannon Zhao     uint32_t gpe1_blk; \
118c2f7c0c3SShannon Zhao     uint8_t  pm1_evt_len;  /* Byte length of ports at pm1_x_evt_blk */ \
119c2f7c0c3SShannon Zhao     uint8_t  pm1_cnt_len;  /* Byte length of ports at pm1_x_cnt_blk */ \
120c2f7c0c3SShannon Zhao     uint8_t  pm2_cnt_len;  /* Byte Length of ports at pm2_cnt_blk */ \
121c2f7c0c3SShannon Zhao     uint8_t  pm_tmr_len;   /* Byte Length of ports at pm_tm_blk */ \
122c2f7c0c3SShannon Zhao     uint8_t  gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ \
123c2f7c0c3SShannon Zhao     uint8_t  gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ \
124c2f7c0c3SShannon Zhao     uint8_t  gpe1_base;    /* Offset in gpe model where gpe1 events start */ \
125c2f7c0c3SShannon Zhao     uint8_t  reserved3;    /* Reserved */ \
126c2f7c0c3SShannon Zhao     uint16_t plvl2_lat;    /* Worst case HW latency to enter/exit C2 state */ \
127c2f7c0c3SShannon Zhao     uint16_t plvl3_lat;    /* Worst case HW latency to enter/exit C3 state */ \
128c2f7c0c3SShannon Zhao     uint16_t flush_size;   /* Size of area read to flush caches */ \
129c2f7c0c3SShannon Zhao     uint16_t flush_stride; /* Stride used in flushing caches */ \
130c2f7c0c3SShannon Zhao     uint8_t  duty_offset;  /* Bit location of duty cycle field in p_cnt reg */ \
131c2f7c0c3SShannon Zhao     uint8_t  duty_width;   /* Bit width of duty cycle field in p_cnt reg */ \
132c2f7c0c3SShannon Zhao     uint8_t  day_alrm;     /* Index to day-of-month alarm in RTC CMOS RAM */ \
133c2f7c0c3SShannon Zhao     uint8_t  mon_alrm;     /* Index to month-of-year alarm in RTC CMOS RAM */ \
13477af8a2bSPhil Dennis-Jordan     uint8_t  century;      /* Index to century in RTC CMOS RAM */ \
13577af8a2bSPhil Dennis-Jordan     /* IA-PC Boot Architecture Flags (see below for individual flags) */ \
13677af8a2bSPhil Dennis-Jordan     uint16_t boot_flags; \
13777af8a2bSPhil Dennis-Jordan     uint8_t reserved;    /* Reserved, must be zero */ \
13877af8a2bSPhil Dennis-Jordan     /* Miscellaneous flag bits (see below for individual flags) */ \
13977af8a2bSPhil Dennis-Jordan     uint32_t flags; \
14077af8a2bSPhil Dennis-Jordan     /* 64-bit address of the Reset register */ \
14177af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress reset_register; \
14277af8a2bSPhil Dennis-Jordan     /* Value to write to the reset_register port to reset the system */ \
14377af8a2bSPhil Dennis-Jordan     uint8_t reset_value; \
14477af8a2bSPhil Dennis-Jordan     /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ \
14577af8a2bSPhil Dennis-Jordan     uint16_t arm_boot_flags; \
14677af8a2bSPhil Dennis-Jordan     uint8_t minor_revision;  /* FADT Minor Revision (ACPI 5.1) */ \
1475ee85347SArd Biesheuvel     uint64_t x_facs;          /* 64-bit physical address of FACS */ \
1485ee85347SArd Biesheuvel     uint64_t x_dsdt;          /* 64-bit physical address of DSDT */ \
14977af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ \
15077af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm1a_event_block; \
15177af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ \
15277af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm1b_event_block; \
15377af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ \
15477af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm1a_control_block; \
15577af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ \
15677af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm1b_control_block; \
15777af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ \
15877af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm2_control_block; \
15977af8a2bSPhil Dennis-Jordan     /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ \
16077af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xpm_timer_block; \
16177af8a2bSPhil Dennis-Jordan     /* 64-bit Extended General Purpose Event 0 Reg Blk address */ \
16277af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xgpe0_block; \
16377af8a2bSPhil Dennis-Jordan     /* 64-bit Extended General Purpose Event 1 Reg Blk address */ \
16477af8a2bSPhil Dennis-Jordan     struct AcpiGenericAddress xgpe1_block; \
16572c194f7SMichael S. Tsirkin 
166c2f7c0c3SShannon Zhao struct AcpiGenericAddress {
167c2f7c0c3SShannon Zhao     uint8_t space_id;        /* Address space where struct or register exists */
168c2f7c0c3SShannon Zhao     uint8_t bit_width;       /* Size in bits of given register */
169c2f7c0c3SShannon Zhao     uint8_t bit_offset;      /* Bit offset within the register */
170c2f7c0c3SShannon Zhao     uint8_t access_width;    /* Minimum Access size (ACPI 3.0) */
171c2f7c0c3SShannon Zhao     uint64_t address;        /* 64-bit address of struct or register */
172c2f7c0c3SShannon Zhao } QEMU_PACKED;
173c2f7c0c3SShannon Zhao 
17477af8a2bSPhil Dennis-Jordan struct AcpiFadtDescriptorRev3 {
17577af8a2bSPhil Dennis-Jordan     ACPI_FADT_COMMON_DEF
17677af8a2bSPhil Dennis-Jordan } QEMU_PACKED;
17777af8a2bSPhil Dennis-Jordan typedef struct AcpiFadtDescriptorRev3 AcpiFadtDescriptorRev3;
17877af8a2bSPhil Dennis-Jordan 
179c2f7c0c3SShannon Zhao struct AcpiFadtDescriptorRev5_1 {
180c2f7c0c3SShannon Zhao     ACPI_FADT_COMMON_DEF
181c2f7c0c3SShannon Zhao     /* 64-bit Sleep Control register (ACPI 5.0) */
182c2f7c0c3SShannon Zhao     struct AcpiGenericAddress sleep_control;
183c2f7c0c3SShannon Zhao     /* 64-bit Sleep Status register (ACPI 5.0) */
184c2f7c0c3SShannon Zhao     struct AcpiGenericAddress sleep_status;
185c2f7c0c3SShannon Zhao } QEMU_PACKED;
186c2f7c0c3SShannon Zhao 
187c2f7c0c3SShannon Zhao typedef struct AcpiFadtDescriptorRev5_1 AcpiFadtDescriptorRev5_1;
188c2f7c0c3SShannon Zhao 
1898c92c6a4SAndrew Jones #define ACPI_FADT_ARM_PSCI_COMPLIANT  (1 << 0)
1908c92c6a4SAndrew Jones #define ACPI_FADT_ARM_PSCI_USE_HVC    (1 << 1)
191c2f7c0c3SShannon Zhao 
19272c194f7SMichael S. Tsirkin /*
193b8a0d75eSAndrew Jones  * Serial Port Console Redirection Table (SPCR), Rev. 1.02
194b8a0d75eSAndrew Jones  *
195b8a0d75eSAndrew Jones  * For .interface_type see Debug Port Table 2 (DBG2) serial port
196b8a0d75eSAndrew Jones  * subtypes in Table 3, Rev. May 22, 2012
197b8a0d75eSAndrew Jones  */
198b8a0d75eSAndrew Jones struct AcpiSerialPortConsoleRedirection {
199b8a0d75eSAndrew Jones     ACPI_TABLE_HEADER_DEF
200b8a0d75eSAndrew Jones     uint8_t  interface_type;
201b8a0d75eSAndrew Jones     uint8_t  reserved1[3];
202b8a0d75eSAndrew Jones     struct AcpiGenericAddress base_address;
203b8a0d75eSAndrew Jones     uint8_t  interrupt_types;
204b8a0d75eSAndrew Jones     uint8_t  irq;
205b8a0d75eSAndrew Jones     uint32_t gsi;
206b8a0d75eSAndrew Jones     uint8_t  baud;
207b8a0d75eSAndrew Jones     uint8_t  parity;
208b8a0d75eSAndrew Jones     uint8_t  stopbits;
209b8a0d75eSAndrew Jones     uint8_t  flowctrl;
210b8a0d75eSAndrew Jones     uint8_t  term_type;
211b8a0d75eSAndrew Jones     uint8_t  reserved2;
212b8a0d75eSAndrew Jones     uint16_t pci_device_id;
213b8a0d75eSAndrew Jones     uint16_t pci_vendor_id;
214b8a0d75eSAndrew Jones     uint8_t  pci_bus;
215b8a0d75eSAndrew Jones     uint8_t  pci_slot;
216b8a0d75eSAndrew Jones     uint8_t  pci_func;
217b8a0d75eSAndrew Jones     uint32_t pci_flags;
218b8a0d75eSAndrew Jones     uint8_t  pci_seg;
219b8a0d75eSAndrew Jones     uint32_t reserved3;
220b8a0d75eSAndrew Jones } QEMU_PACKED;
221b8a0d75eSAndrew Jones typedef struct AcpiSerialPortConsoleRedirection
222b8a0d75eSAndrew Jones                AcpiSerialPortConsoleRedirection;
223b8a0d75eSAndrew Jones 
224b8a0d75eSAndrew Jones /*
22572c194f7SMichael S. Tsirkin  * ACPI 1.0 Root System Description Table (RSDT)
22672c194f7SMichael S. Tsirkin  */
22772c194f7SMichael S. Tsirkin struct AcpiRsdtDescriptorRev1
22872c194f7SMichael S. Tsirkin {
22972c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
23072c194f7SMichael S. Tsirkin     uint32_t table_offset_entry[0];  /* Array of pointers to other */
23172c194f7SMichael S. Tsirkin     /* ACPI tables */
23272c194f7SMichael S. Tsirkin } QEMU_PACKED;
23372c194f7SMichael S. Tsirkin typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1;
23472c194f7SMichael S. Tsirkin 
23572c194f7SMichael S. Tsirkin /*
236*cb51ac2fSArd Biesheuvel  * ACPI 2.0 eXtended System Description Table (XSDT)
237*cb51ac2fSArd Biesheuvel  */
238*cb51ac2fSArd Biesheuvel struct AcpiXsdtDescriptorRev2
239*cb51ac2fSArd Biesheuvel {
240*cb51ac2fSArd Biesheuvel     ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
241*cb51ac2fSArd Biesheuvel     uint64_t table_offset_entry[0];  /* Array of pointers to other */
242*cb51ac2fSArd Biesheuvel     /* ACPI tables */
243*cb51ac2fSArd Biesheuvel } QEMU_PACKED;
244*cb51ac2fSArd Biesheuvel typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2;
245*cb51ac2fSArd Biesheuvel 
246*cb51ac2fSArd Biesheuvel /*
24772c194f7SMichael S. Tsirkin  * ACPI 1.0 Firmware ACPI Control Structure (FACS)
24872c194f7SMichael S. Tsirkin  */
24972c194f7SMichael S. Tsirkin struct AcpiFacsDescriptorRev1
25072c194f7SMichael S. Tsirkin {
25172c194f7SMichael S. Tsirkin     uint32_t signature;           /* ACPI Signature */
25272c194f7SMichael S. Tsirkin     uint32_t length;                 /* Length of structure, in bytes */
25372c194f7SMichael S. Tsirkin     uint32_t hardware_signature;     /* Hardware configuration signature */
25472c194f7SMichael S. Tsirkin     uint32_t firmware_waking_vector; /* ACPI OS waking vector */
25572c194f7SMichael S. Tsirkin     uint32_t global_lock;            /* Global Lock */
25672c194f7SMichael S. Tsirkin     uint32_t flags;
25772c194f7SMichael S. Tsirkin     uint8_t  resverved3 [40];        /* Reserved - must be zero */
25872c194f7SMichael S. Tsirkin } QEMU_PACKED;
25972c194f7SMichael S. Tsirkin typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
26072c194f7SMichael S. Tsirkin 
26172c194f7SMichael S. Tsirkin /*
26272c194f7SMichael S. Tsirkin  * Differentiated System Description Table (DSDT)
26372c194f7SMichael S. Tsirkin  */
26472c194f7SMichael S. Tsirkin 
26572c194f7SMichael S. Tsirkin /*
26672c194f7SMichael S. Tsirkin  * MADT values and structures
26772c194f7SMichael S. Tsirkin  */
26872c194f7SMichael S. Tsirkin 
26972c194f7SMichael S. Tsirkin /* Values for MADT PCATCompat */
27072c194f7SMichael S. Tsirkin 
27172c194f7SMichael S. Tsirkin #define ACPI_DUAL_PIC                0
27272c194f7SMichael S. Tsirkin #define ACPI_MULTIPLE_APIC           1
27372c194f7SMichael S. Tsirkin 
27472c194f7SMichael S. Tsirkin /* Master MADT */
27572c194f7SMichael S. Tsirkin 
27672c194f7SMichael S. Tsirkin struct AcpiMultipleApicTable
27772c194f7SMichael S. Tsirkin {
27872c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
27972c194f7SMichael S. Tsirkin     uint32_t local_apic_address;     /* Physical address of local APIC */
28072c194f7SMichael S. Tsirkin     uint32_t flags;
28172c194f7SMichael S. Tsirkin } QEMU_PACKED;
28272c194f7SMichael S. Tsirkin typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;
28372c194f7SMichael S. Tsirkin 
28472c194f7SMichael S. Tsirkin /* Values for Type in APIC sub-headers */
28572c194f7SMichael S. Tsirkin 
28672c194f7SMichael S. Tsirkin #define ACPI_APIC_PROCESSOR          0
28772c194f7SMichael S. Tsirkin #define ACPI_APIC_IO                 1
28872c194f7SMichael S. Tsirkin #define ACPI_APIC_XRUPT_OVERRIDE     2
28972c194f7SMichael S. Tsirkin #define ACPI_APIC_NMI                3
29072c194f7SMichael S. Tsirkin #define ACPI_APIC_LOCAL_NMI          4
29172c194f7SMichael S. Tsirkin #define ACPI_APIC_ADDRESS_OVERRIDE   5
29272c194f7SMichael S. Tsirkin #define ACPI_APIC_IO_SAPIC           6
29372c194f7SMichael S. Tsirkin #define ACPI_APIC_LOCAL_SAPIC        7
29472c194f7SMichael S. Tsirkin #define ACPI_APIC_XRUPT_SOURCE       8
295982d06c5SShannon Zhao #define ACPI_APIC_LOCAL_X2APIC       9
296982d06c5SShannon Zhao #define ACPI_APIC_LOCAL_X2APIC_NMI      10
2976e2ed65fSAndrew Jones #define ACPI_APIC_GENERIC_CPU_INTERFACE 11
298982d06c5SShannon Zhao #define ACPI_APIC_GENERIC_DISTRIBUTOR   12
299982d06c5SShannon Zhao #define ACPI_APIC_GENERIC_MSI_FRAME     13
300982d06c5SShannon Zhao #define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
3011c2e4ea7SShannon Zhao #define ACPI_APIC_GENERIC_TRANSLATOR    15
3021c2e4ea7SShannon Zhao #define ACPI_APIC_RESERVED              16   /* 16 and greater are reserved */
30372c194f7SMichael S. Tsirkin 
30472c194f7SMichael S. Tsirkin /*
30572c194f7SMichael S. Tsirkin  * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
30672c194f7SMichael S. Tsirkin  */
30772c194f7SMichael S. Tsirkin #define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
30872c194f7SMichael S. Tsirkin     uint8_t  type;                               \
30972c194f7SMichael S. Tsirkin     uint8_t  length;
31072c194f7SMichael S. Tsirkin 
31172c194f7SMichael S. Tsirkin /* Sub-structures for MADT */
31272c194f7SMichael S. Tsirkin 
31372c194f7SMichael S. Tsirkin struct AcpiMadtProcessorApic
31472c194f7SMichael S. Tsirkin {
31572c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
31672c194f7SMichael S. Tsirkin     uint8_t  processor_id;           /* ACPI processor id */
31772c194f7SMichael S. Tsirkin     uint8_t  local_apic_id;          /* Processor's local APIC id */
31872c194f7SMichael S. Tsirkin     uint32_t flags;
31972c194f7SMichael S. Tsirkin } QEMU_PACKED;
32072c194f7SMichael S. Tsirkin typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic;
32172c194f7SMichael S. Tsirkin 
32272c194f7SMichael S. Tsirkin struct AcpiMadtIoApic
32372c194f7SMichael S. Tsirkin {
32472c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
32572c194f7SMichael S. Tsirkin     uint8_t  io_apic_id;             /* I/O APIC ID */
32672c194f7SMichael S. Tsirkin     uint8_t  reserved;               /* Reserved - must be zero */
32772c194f7SMichael S. Tsirkin     uint32_t address;                /* APIC physical address */
32872c194f7SMichael S. Tsirkin     uint32_t interrupt;              /* Global system interrupt where INTI
32972c194f7SMichael S. Tsirkin                                  * lines start */
33072c194f7SMichael S. Tsirkin } QEMU_PACKED;
33172c194f7SMichael S. Tsirkin typedef struct AcpiMadtIoApic AcpiMadtIoApic;
33272c194f7SMichael S. Tsirkin 
33372c194f7SMichael S. Tsirkin struct AcpiMadtIntsrcovr {
33472c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
33572c194f7SMichael S. Tsirkin     uint8_t  bus;
33672c194f7SMichael S. Tsirkin     uint8_t  source;
33772c194f7SMichael S. Tsirkin     uint32_t gsi;
33872c194f7SMichael S. Tsirkin     uint16_t flags;
33972c194f7SMichael S. Tsirkin } QEMU_PACKED;
34072c194f7SMichael S. Tsirkin typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr;
34172c194f7SMichael S. Tsirkin 
34272c194f7SMichael S. Tsirkin struct AcpiMadtLocalNmi {
34372c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
34472c194f7SMichael S. Tsirkin     uint8_t  processor_id;           /* ACPI processor id */
34572c194f7SMichael S. Tsirkin     uint16_t flags;                  /* MPS INTI flags */
34672c194f7SMichael S. Tsirkin     uint8_t  lint;                   /* Local APIC LINT# */
34772c194f7SMichael S. Tsirkin } QEMU_PACKED;
34872c194f7SMichael S. Tsirkin typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi;
34972c194f7SMichael S. Tsirkin 
350e2c95939SIgor Mammedov struct AcpiMadtProcessorX2Apic {
351e2c95939SIgor Mammedov     ACPI_SUB_HEADER_DEF
352e2c95939SIgor Mammedov     uint16_t reserved;
353e2c95939SIgor Mammedov     uint32_t x2apic_id;              /* Processor's local x2APIC ID */
354e2c95939SIgor Mammedov     uint32_t flags;
355e2c95939SIgor Mammedov     uint32_t uid;                    /* Processor object _UID */
356e2c95939SIgor Mammedov } QEMU_PACKED;
357e2c95939SIgor Mammedov typedef struct AcpiMadtProcessorX2Apic AcpiMadtProcessorX2Apic;
358e2c95939SIgor Mammedov 
359e2c95939SIgor Mammedov struct AcpiMadtLocalX2ApicNmi {
360e2c95939SIgor Mammedov     ACPI_SUB_HEADER_DEF
361e2c95939SIgor Mammedov     uint16_t flags;                  /* MPS INTI flags */
362e2c95939SIgor Mammedov     uint32_t uid;                    /* Processor object _UID */
363e2c95939SIgor Mammedov     uint8_t  lint;                   /* Local APIC LINT# */
364e2c95939SIgor Mammedov     uint8_t  reserved[3];            /* Local APIC LINT# */
365e2c95939SIgor Mammedov } QEMU_PACKED;
366e2c95939SIgor Mammedov typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi;
367e2c95939SIgor Mammedov 
3686e2ed65fSAndrew Jones struct AcpiMadtGenericCpuInterface {
369982d06c5SShannon Zhao     ACPI_SUB_HEADER_DEF
370982d06c5SShannon Zhao     uint16_t reserved;
371982d06c5SShannon Zhao     uint32_t cpu_interface_number;
372982d06c5SShannon Zhao     uint32_t uid;
373982d06c5SShannon Zhao     uint32_t flags;
374982d06c5SShannon Zhao     uint32_t parking_version;
375982d06c5SShannon Zhao     uint32_t performance_interrupt;
376982d06c5SShannon Zhao     uint64_t parked_address;
377982d06c5SShannon Zhao     uint64_t base_address;
378982d06c5SShannon Zhao     uint64_t gicv_base_address;
379982d06c5SShannon Zhao     uint64_t gich_base_address;
380982d06c5SShannon Zhao     uint32_t vgic_interrupt;
381982d06c5SShannon Zhao     uint64_t gicr_base_address;
382982d06c5SShannon Zhao     uint64_t arm_mpidr;
383982d06c5SShannon Zhao } QEMU_PACKED;
384982d06c5SShannon Zhao 
3856e2ed65fSAndrew Jones typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface;
3866e2ed65fSAndrew Jones 
3876e2ed65fSAndrew Jones /* GICC CPU Interface Flags */
3886e2ed65fSAndrew Jones #define ACPI_MADT_GICC_ENABLED 1
389982d06c5SShannon Zhao 
390982d06c5SShannon Zhao struct AcpiMadtGenericDistributor {
391982d06c5SShannon Zhao     ACPI_SUB_HEADER_DEF
392982d06c5SShannon Zhao     uint16_t reserved;
393982d06c5SShannon Zhao     uint32_t gic_id;
394982d06c5SShannon Zhao     uint64_t base_address;
395982d06c5SShannon Zhao     uint32_t global_irq_base;
396f06765a9SShannon Zhao     /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */
397f06765a9SShannon Zhao     uint8_t version;
398f06765a9SShannon Zhao     uint8_t reserved2[3];
399982d06c5SShannon Zhao } QEMU_PACKED;
400982d06c5SShannon Zhao 
401982d06c5SShannon Zhao typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor;
402982d06c5SShannon Zhao 
403ca793736SShannon Zhao struct AcpiMadtGenericMsiFrame {
404ca793736SShannon Zhao     ACPI_SUB_HEADER_DEF
405ca793736SShannon Zhao     uint16_t reserved;
406ca793736SShannon Zhao     uint32_t gic_msi_frame_id;
407ca793736SShannon Zhao     uint64_t base_address;
408ca793736SShannon Zhao     uint32_t flags;
409ca793736SShannon Zhao     uint16_t spi_count;
410ca793736SShannon Zhao     uint16_t spi_base;
411ca793736SShannon Zhao } QEMU_PACKED;
412ca793736SShannon Zhao 
413ca793736SShannon Zhao typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame;
414ca793736SShannon Zhao 
415b92ad394SPavel Fedin struct AcpiMadtGenericRedistributor {
416b92ad394SPavel Fedin     ACPI_SUB_HEADER_DEF
417b92ad394SPavel Fedin     uint16_t reserved;
418b92ad394SPavel Fedin     uint64_t base_address;
419b92ad394SPavel Fedin     uint32_t range_length;
420b92ad394SPavel Fedin } QEMU_PACKED;
421b92ad394SPavel Fedin 
422b92ad394SPavel Fedin typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor;
423b92ad394SPavel Fedin 
4241c2e4ea7SShannon Zhao struct AcpiMadtGenericTranslator {
4251c2e4ea7SShannon Zhao     ACPI_SUB_HEADER_DEF
4261c2e4ea7SShannon Zhao     uint16_t reserved;
4271c2e4ea7SShannon Zhao     uint32_t translation_id;
4281c2e4ea7SShannon Zhao     uint64_t base_address;
4291c2e4ea7SShannon Zhao     uint32_t reserved2;
4301c2e4ea7SShannon Zhao } QEMU_PACKED;
4311c2e4ea7SShannon Zhao 
4321c2e4ea7SShannon Zhao typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator;
4331c2e4ea7SShannon Zhao 
43472c194f7SMichael S. Tsirkin /*
435ee246400SShannon Zhao  * Generic Timer Description Table (GTDT)
436ee246400SShannon Zhao  */
4378dd845d3SAndrew Jones #define ACPI_GTDT_INTERRUPT_MODE_LEVEL    (0 << 0)
438aca4bbf4SAndrew Jones #define ACPI_GTDT_INTERRUPT_MODE_EDGE     (1 << 0)
439aca4bbf4SAndrew Jones #define ACPI_GTDT_CAP_ALWAYS_ON           (1 << 2)
440ee246400SShannon Zhao 
441ee246400SShannon Zhao struct AcpiGenericTimerTable {
442ee246400SShannon Zhao     ACPI_TABLE_HEADER_DEF
443ee246400SShannon Zhao     uint64_t counter_block_addresss;
444ee246400SShannon Zhao     uint32_t reserved;
445ee246400SShannon Zhao     uint32_t secure_el1_interrupt;
446ee246400SShannon Zhao     uint32_t secure_el1_flags;
447ee246400SShannon Zhao     uint32_t non_secure_el1_interrupt;
448ee246400SShannon Zhao     uint32_t non_secure_el1_flags;
449ee246400SShannon Zhao     uint32_t virtual_timer_interrupt;
450ee246400SShannon Zhao     uint32_t virtual_timer_flags;
451ee246400SShannon Zhao     uint32_t non_secure_el2_interrupt;
452ee246400SShannon Zhao     uint32_t non_secure_el2_flags;
453ee246400SShannon Zhao     uint64_t counter_read_block_address;
454ee246400SShannon Zhao     uint32_t platform_timer_count;
455ee246400SShannon Zhao     uint32_t platform_timer_offset;
456ee246400SShannon Zhao } QEMU_PACKED;
457ee246400SShannon Zhao typedef struct AcpiGenericTimerTable AcpiGenericTimerTable;
458ee246400SShannon Zhao 
459ee246400SShannon Zhao /*
46072c194f7SMichael S. Tsirkin  * HPET Description Table
46172c194f7SMichael S. Tsirkin  */
46272c194f7SMichael S. Tsirkin struct Acpi20Hpet {
46372c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
46472c194f7SMichael S. Tsirkin     uint32_t           timer_block_id;
46572c194f7SMichael S. Tsirkin     Acpi20GenericAddress addr;
46672c194f7SMichael S. Tsirkin     uint8_t            hpet_number;
46772c194f7SMichael S. Tsirkin     uint16_t           min_tick;
46872c194f7SMichael S. Tsirkin     uint8_t            page_protect;
46972c194f7SMichael S. Tsirkin } QEMU_PACKED;
47072c194f7SMichael S. Tsirkin typedef struct Acpi20Hpet Acpi20Hpet;
47172c194f7SMichael S. Tsirkin 
47272c194f7SMichael S. Tsirkin /*
47372c194f7SMichael S. Tsirkin  * SRAT (NUMA topology description) table
47472c194f7SMichael S. Tsirkin  */
47572c194f7SMichael S. Tsirkin 
47672c194f7SMichael S. Tsirkin struct AcpiSystemResourceAffinityTable
47772c194f7SMichael S. Tsirkin {
47872c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF
47972c194f7SMichael S. Tsirkin     uint32_t    reserved1;
48072c194f7SMichael S. Tsirkin     uint32_t    reserved2[2];
48172c194f7SMichael S. Tsirkin } QEMU_PACKED;
48272c194f7SMichael S. Tsirkin typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable;
48372c194f7SMichael S. Tsirkin 
484e6e400d5SShannon Zhao #define ACPI_SRAT_PROCESSOR_APIC     0
48572c194f7SMichael S. Tsirkin #define ACPI_SRAT_MEMORY             1
486e6e400d5SShannon Zhao #define ACPI_SRAT_PROCESSOR_x2APIC   2
487e6e400d5SShannon Zhao #define ACPI_SRAT_PROCESSOR_GICC     3
48872c194f7SMichael S. Tsirkin 
48972c194f7SMichael S. Tsirkin struct AcpiSratProcessorAffinity
49072c194f7SMichael S. Tsirkin {
49172c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
49272c194f7SMichael S. Tsirkin     uint8_t     proximity_lo;
49372c194f7SMichael S. Tsirkin     uint8_t     local_apic_id;
49472c194f7SMichael S. Tsirkin     uint32_t    flags;
49572c194f7SMichael S. Tsirkin     uint8_t     local_sapic_eid;
49672c194f7SMichael S. Tsirkin     uint8_t     proximity_hi[3];
49772c194f7SMichael S. Tsirkin     uint32_t    reserved;
49872c194f7SMichael S. Tsirkin } QEMU_PACKED;
49972c194f7SMichael S. Tsirkin typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity;
50072c194f7SMichael S. Tsirkin 
5015eff33a2SIgor Mammedov struct AcpiSratProcessorX2ApicAffinity {
5025eff33a2SIgor Mammedov     ACPI_SUB_HEADER_DEF
5035eff33a2SIgor Mammedov     uint16_t    reserved;
5045eff33a2SIgor Mammedov     uint32_t    proximity_domain;
5055eff33a2SIgor Mammedov     uint32_t    x2apic_id;
5065eff33a2SIgor Mammedov     uint32_t    flags;
5075eff33a2SIgor Mammedov     uint32_t    clk_domain;
5085eff33a2SIgor Mammedov     uint32_t    reserved2;
5095eff33a2SIgor Mammedov } QEMU_PACKED;
5105eff33a2SIgor Mammedov typedef struct AcpiSratProcessorX2ApicAffinity AcpiSratProcessorX2ApicAffinity;
5115eff33a2SIgor Mammedov 
51272c194f7SMichael S. Tsirkin struct AcpiSratMemoryAffinity
51372c194f7SMichael S. Tsirkin {
51472c194f7SMichael S. Tsirkin     ACPI_SUB_HEADER_DEF
515ea9fcbd7SShannon Zhao     uint32_t    proximity;
51672c194f7SMichael S. Tsirkin     uint16_t    reserved1;
51772c194f7SMichael S. Tsirkin     uint64_t    base_addr;
51872c194f7SMichael S. Tsirkin     uint64_t    range_length;
51972c194f7SMichael S. Tsirkin     uint32_t    reserved2;
52072c194f7SMichael S. Tsirkin     uint32_t    flags;
52172c194f7SMichael S. Tsirkin     uint32_t    reserved3[2];
52272c194f7SMichael S. Tsirkin } QEMU_PACKED;
52372c194f7SMichael S. Tsirkin typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity;
52472c194f7SMichael S. Tsirkin 
525e6e400d5SShannon Zhao struct AcpiSratProcessorGiccAffinity
526e6e400d5SShannon Zhao {
527e6e400d5SShannon Zhao     ACPI_SUB_HEADER_DEF
528e6e400d5SShannon Zhao     uint32_t    proximity;
529e6e400d5SShannon Zhao     uint32_t    acpi_processor_uid;
530e6e400d5SShannon Zhao     uint32_t    flags;
531e6e400d5SShannon Zhao     uint32_t    clock_domain;
532e6e400d5SShannon Zhao } QEMU_PACKED;
533e6e400d5SShannon Zhao 
534e6e400d5SShannon Zhao typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
535e6e400d5SShannon Zhao 
53672c194f7SMichael S. Tsirkin /* PCI fw r3.0 MCFG table. */
53772c194f7SMichael S. Tsirkin /* Subtable */
53872c194f7SMichael S. Tsirkin struct AcpiMcfgAllocation {
53972c194f7SMichael S. Tsirkin     uint64_t address;                /* Base address, processor-relative */
54072c194f7SMichael S. Tsirkin     uint16_t pci_segment;            /* PCI segment group number */
54172c194f7SMichael S. Tsirkin     uint8_t start_bus_number;       /* Starting PCI Bus number */
54272c194f7SMichael S. Tsirkin     uint8_t end_bus_number;         /* Final PCI Bus number */
54372c194f7SMichael S. Tsirkin     uint32_t reserved;
54472c194f7SMichael S. Tsirkin } QEMU_PACKED;
54572c194f7SMichael S. Tsirkin typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
54672c194f7SMichael S. Tsirkin 
54772c194f7SMichael S. Tsirkin struct AcpiTableMcfg {
54872c194f7SMichael S. Tsirkin     ACPI_TABLE_HEADER_DEF;
54972c194f7SMichael S. Tsirkin     uint8_t reserved[8];
55072c194f7SMichael S. Tsirkin     AcpiMcfgAllocation allocation[0];
55172c194f7SMichael S. Tsirkin } QEMU_PACKED;
55272c194f7SMichael S. Tsirkin typedef struct AcpiTableMcfg AcpiTableMcfg;
55372c194f7SMichael S. Tsirkin 
554711b20b4SStefan Berger /*
555711b20b4SStefan Berger  * TCPA Description Table
5565cb18b3dSStefan Berger  *
5575cb18b3dSStefan Berger  * Following Level 00, Rev 00.37 of specs:
5585cb18b3dSStefan Berger  * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification
559711b20b4SStefan Berger  */
560711b20b4SStefan Berger struct Acpi20Tcpa {
561711b20b4SStefan Berger     ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
562711b20b4SStefan Berger     uint16_t platform_class;
563711b20b4SStefan Berger     uint32_t log_area_minimum_length;
564711b20b4SStefan Berger     uint64_t log_area_start_address;
565711b20b4SStefan Berger } QEMU_PACKED;
566711b20b4SStefan Berger typedef struct Acpi20Tcpa Acpi20Tcpa;
567711b20b4SStefan Berger 
5685cb18b3dSStefan Berger /*
5695cb18b3dSStefan Berger  * TPM2
5705cb18b3dSStefan Berger  *
5715cb18b3dSStefan Berger  * Following Level 00, Rev 00.37 of specs:
5725cb18b3dSStefan Berger  * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification
5735cb18b3dSStefan Berger  */
5745cb18b3dSStefan Berger struct Acpi20TPM2 {
5755cb18b3dSStefan Berger     ACPI_TABLE_HEADER_DEF
5765cb18b3dSStefan Berger     uint16_t platform_class;
5775cb18b3dSStefan Berger     uint16_t reserved;
5785cb18b3dSStefan Berger     uint64_t control_area_address;
5795cb18b3dSStefan Berger     uint32_t start_method;
5805cb18b3dSStefan Berger } QEMU_PACKED;
5815cb18b3dSStefan Berger typedef struct Acpi20TPM2 Acpi20TPM2;
5825cb18b3dSStefan Berger 
583d4eb9119SLe Tan /* DMAR - DMA Remapping table r2.2 */
584d4eb9119SLe Tan struct AcpiTableDmar {
585d4eb9119SLe Tan     ACPI_TABLE_HEADER_DEF
586d4eb9119SLe Tan     uint8_t host_address_width; /* Maximum DMA physical addressability */
587d4eb9119SLe Tan     uint8_t flags;
588d4eb9119SLe Tan     uint8_t reserved[10];
589d4eb9119SLe Tan } QEMU_PACKED;
590d4eb9119SLe Tan typedef struct AcpiTableDmar AcpiTableDmar;
591d4eb9119SLe Tan 
592d4eb9119SLe Tan /* Masks for Flags field above */
593d4eb9119SLe Tan #define ACPI_DMAR_INTR_REMAP        1
594d4eb9119SLe Tan #define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
595d4eb9119SLe Tan 
596d4eb9119SLe Tan /* Values for sub-structure type for DMAR */
597d4eb9119SLe Tan enum {
598d4eb9119SLe Tan     ACPI_DMAR_TYPE_HARDWARE_UNIT = 0,       /* DRHD */
599d4eb9119SLe Tan     ACPI_DMAR_TYPE_RESERVED_MEMORY = 1,     /* RMRR */
600d4eb9119SLe Tan     ACPI_DMAR_TYPE_ATSR = 2,                /* ATSR */
601d4eb9119SLe Tan     ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,   /* RHSR */
602d4eb9119SLe Tan     ACPI_DMAR_TYPE_ANDD = 4,                /* ANDD */
603d4eb9119SLe Tan     ACPI_DMAR_TYPE_RESERVED = 5             /* Reserved for furture use */
604d4eb9119SLe Tan };
605d4eb9119SLe Tan 
606d4eb9119SLe Tan /*
607d4eb9119SLe Tan  * Sub-structures for DMAR
608d4eb9119SLe Tan  */
609cfc13df4SPeter Xu 
610cfc13df4SPeter Xu /* Device scope structure for DRHD. */
611cfc13df4SPeter Xu struct AcpiDmarDeviceScope {
612cfc13df4SPeter Xu     uint8_t entry_type;
613cfc13df4SPeter Xu     uint8_t length;
614cfc13df4SPeter Xu     uint16_t reserved;
615cfc13df4SPeter Xu     uint8_t enumeration_id;
616cfc13df4SPeter Xu     uint8_t bus;
6171b39bc1cSPeter Xu     struct {
6181b39bc1cSPeter Xu         uint8_t device;
6191b39bc1cSPeter Xu         uint8_t function;
6201b39bc1cSPeter Xu     } path[0];
621cfc13df4SPeter Xu } QEMU_PACKED;
622cfc13df4SPeter Xu typedef struct AcpiDmarDeviceScope AcpiDmarDeviceScope;
623cfc13df4SPeter Xu 
624d4eb9119SLe Tan /* Type 0: Hardware Unit Definition */
625d4eb9119SLe Tan struct AcpiDmarHardwareUnit {
626d4eb9119SLe Tan     uint16_t type;
627d4eb9119SLe Tan     uint16_t length;
628d4eb9119SLe Tan     uint8_t flags;
629d4eb9119SLe Tan     uint8_t reserved;
630d4eb9119SLe Tan     uint16_t pci_segment;   /* The PCI Segment associated with this unit */
631d4eb9119SLe Tan     uint64_t address;   /* Base address of remapping hardware register-set */
632cfc13df4SPeter Xu     AcpiDmarDeviceScope scope[0];
633d4eb9119SLe Tan } QEMU_PACKED;
634d4eb9119SLe Tan typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit;
635d4eb9119SLe Tan 
636bd2baaccSJason Wang /* Type 2: Root Port ATS Capability Reporting Structure */
637bd2baaccSJason Wang struct AcpiDmarRootPortATS {
638bd2baaccSJason Wang     uint16_t type;
639bd2baaccSJason Wang     uint16_t length;
640bd2baaccSJason Wang     uint8_t flags;
641bd2baaccSJason Wang     uint8_t reserved;
642bd2baaccSJason Wang     uint16_t pci_segment;
643bd2baaccSJason Wang     AcpiDmarDeviceScope scope[0];
644bd2baaccSJason Wang } QEMU_PACKED;
645bd2baaccSJason Wang typedef struct AcpiDmarRootPortATS AcpiDmarRootPortATS;
646bd2baaccSJason Wang 
647d4eb9119SLe Tan /* Masks for Flags field above */
648d4eb9119SLe Tan #define ACPI_DMAR_INCLUDE_PCI_ALL   1
649bd2baaccSJason Wang #define ACPI_DMAR_ATSR_ALL_PORTS    1
650d4eb9119SLe Tan 
65116fc326aSPrem Mallappa /*
65216fc326aSPrem Mallappa  * Input Output Remapping Table (IORT)
65316fc326aSPrem Mallappa  * Conforms to "IO Remapping Table System Software on ARM Platforms",
65416fc326aSPrem Mallappa  * Document number: ARM DEN 0049B, October 2015
65516fc326aSPrem Mallappa  */
65616fc326aSPrem Mallappa 
65716fc326aSPrem Mallappa struct AcpiIortTable {
65816fc326aSPrem Mallappa     ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
65916fc326aSPrem Mallappa     uint32_t node_count;
66016fc326aSPrem Mallappa     uint32_t node_offset;
66116fc326aSPrem Mallappa     uint32_t reserved;
66216fc326aSPrem Mallappa } QEMU_PACKED;
66316fc326aSPrem Mallappa typedef struct AcpiIortTable AcpiIortTable;
66416fc326aSPrem Mallappa 
66516fc326aSPrem Mallappa /*
66616fc326aSPrem Mallappa  * IORT node types
66716fc326aSPrem Mallappa  */
66816fc326aSPrem Mallappa 
66916fc326aSPrem Mallappa #define ACPI_IORT_NODE_HEADER_DEF   /* Node format common fields */ \
67016fc326aSPrem Mallappa     uint8_t  type;          \
67116fc326aSPrem Mallappa     uint16_t length;        \
67216fc326aSPrem Mallappa     uint8_t  revision;      \
67316fc326aSPrem Mallappa     uint32_t reserved;      \
67416fc326aSPrem Mallappa     uint32_t mapping_count; \
67516fc326aSPrem Mallappa     uint32_t mapping_offset;
67616fc326aSPrem Mallappa 
67716fc326aSPrem Mallappa /* Values for node Type above */
67816fc326aSPrem Mallappa enum {
67916fc326aSPrem Mallappa         ACPI_IORT_NODE_ITS_GROUP = 0x00,
68016fc326aSPrem Mallappa         ACPI_IORT_NODE_NAMED_COMPONENT = 0x01,
68116fc326aSPrem Mallappa         ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02,
68216fc326aSPrem Mallappa         ACPI_IORT_NODE_SMMU = 0x03,
68316fc326aSPrem Mallappa         ACPI_IORT_NODE_SMMU_V3 = 0x04
68416fc326aSPrem Mallappa };
68516fc326aSPrem Mallappa 
68616fc326aSPrem Mallappa struct AcpiIortIdMapping {
68716fc326aSPrem Mallappa     uint32_t input_base;
68816fc326aSPrem Mallappa     uint32_t id_count;
68916fc326aSPrem Mallappa     uint32_t output_base;
69016fc326aSPrem Mallappa     uint32_t output_reference;
69116fc326aSPrem Mallappa     uint32_t flags;
69216fc326aSPrem Mallappa } QEMU_PACKED;
69316fc326aSPrem Mallappa typedef struct AcpiIortIdMapping AcpiIortIdMapping;
69416fc326aSPrem Mallappa 
69516fc326aSPrem Mallappa struct AcpiIortMemoryAccess {
69616fc326aSPrem Mallappa     uint32_t cache_coherency;
69716fc326aSPrem Mallappa     uint8_t  hints;
69816fc326aSPrem Mallappa     uint16_t reserved;
69916fc326aSPrem Mallappa     uint8_t  memory_flags;
70016fc326aSPrem Mallappa } QEMU_PACKED;
70116fc326aSPrem Mallappa typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess;
70216fc326aSPrem Mallappa 
70316fc326aSPrem Mallappa struct AcpiIortItsGroup {
70416fc326aSPrem Mallappa     ACPI_IORT_NODE_HEADER_DEF
70516fc326aSPrem Mallappa     uint32_t its_count;
70616fc326aSPrem Mallappa     uint32_t identifiers[0];
70716fc326aSPrem Mallappa } QEMU_PACKED;
70816fc326aSPrem Mallappa typedef struct AcpiIortItsGroup AcpiIortItsGroup;
70916fc326aSPrem Mallappa 
71016fc326aSPrem Mallappa struct AcpiIortRC {
71116fc326aSPrem Mallappa     ACPI_IORT_NODE_HEADER_DEF
71216fc326aSPrem Mallappa     AcpiIortMemoryAccess memory_properties;
71316fc326aSPrem Mallappa     uint32_t ats_attribute;
71416fc326aSPrem Mallappa     uint32_t pci_segment_number;
71516fc326aSPrem Mallappa     AcpiIortIdMapping id_mapping_array[0];
71616fc326aSPrem Mallappa } QEMU_PACKED;
71716fc326aSPrem Mallappa typedef struct AcpiIortRC AcpiIortRC;
71816fc326aSPrem Mallappa 
71972c194f7SMichael S. Tsirkin #endif
720