Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * coreboot ACPI support - headers and defines. |
| 5 | */ |
| 6 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 7 | #ifndef __ACPI_ACPI_H__ |
| 8 | #define __ACPI_ACPI_H__ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * The type and enable fields are common in ACPI, but the |
| 12 | * values themselves are hardware implementation defined. |
| 13 | */ |
| 14 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) |
| 15 | #define SLP_EN (1 << 13) |
| 16 | #define SLP_TYP_SHIFT 10 |
| 17 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 18 | #define SLP_TYP_S0 0 |
| 19 | #define SLP_TYP_S1 1 |
| 20 | #define SLP_TYP_S3 5 |
| 21 | #define SLP_TYP_S4 6 |
| 22 | #define SLP_TYP_S5 7 |
| 23 | #elif CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 24 | #define SLP_EN (1 << 13) |
| 25 | #define SLP_TYP_SHIFT 10 |
| 26 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 27 | #define SLP_TYP_S0 0 |
| 28 | #define SLP_TYP_S1 1 |
| 29 | #define SLP_TYP_S3 3 |
| 30 | #define SLP_TYP_S4 4 |
| 31 | #define SLP_TYP_S5 5 |
| 32 | #endif |
| 33 | |
| 34 | #define ACPI_TABLE_CREATOR "COREBOOT" /* Must be exactly 8 bytes long! */ |
| 35 | #define OEM_ID "COREv4" /* Must be exactly 6 bytes long! */ |
Elyes HAOUAS | 288426d | 2020-10-01 16:52:26 +0200 | [diff] [blame] | 36 | #define ACPI_DSDT_REV_1 0x01 /* DSDT revision: ACPI v1 */ |
Elyes HAOUAS | 7f53ec6 | 2020-10-05 16:33:52 +0200 | [diff] [blame] | 37 | #define ACPI_DSDT_REV_2 0x02 /* DSDT revision: ACPI v2.0 and greater */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 38 | |
| 39 | #if !defined(__ASSEMBLER__) && !defined(__ACPI__) |
| 40 | #include <commonlib/helpers.h> |
| 41 | #include <device/device.h> |
| 42 | #include <uuid.h> |
| 43 | #include <cper.h> |
Kyösti Mälkki | ac0dc4a | 2020-11-18 07:40:21 +0200 | [diff] [blame] | 44 | #include <romstage_handoff.h> |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 45 | #include <types.h> |
| 46 | |
Tim Wawrzynczak | 05a6d5c | 2021-11-24 09:54:59 -0700 | [diff] [blame] | 47 | enum acpi_device_sleep_states { |
| 48 | ACPI_DEVICE_SLEEP_D0 = 0, |
| 49 | ACPI_DEVICE_SLEEP_D1 = 1, |
| 50 | ACPI_DEVICE_SLEEP_D2 = 2, |
| 51 | ACPI_DEVICE_SLEEP_D3 = 3, |
| 52 | ACPI_DEVICE_SLEEP_D3_HOT = ACPI_DEVICE_SLEEP_D3, |
| 53 | ACPI_DEVICE_SLEEP_D3_COLD = 4, |
| 54 | }; |
| 55 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 56 | #define RSDP_SIG "RSD PTR " /* RSDT pointer signature */ |
| 57 | #define ASLC "CORE" /* Must be exactly 4 bytes long! */ |
| 58 | |
Raul E Rangel | 1c0b9f2 | 2020-07-09 11:58:38 -0600 | [diff] [blame] | 59 | #define ACPI_NAME_BUFFER_SIZE 5 /* 4 chars + 1 NUL */ |
| 60 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 61 | /* |
| 62 | * The assigned ACPI ID for the coreboot project is 'BOOT' |
| 63 | * http://www.uefi.org/acpi_id_list |
| 64 | */ |
| 65 | #define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */ |
| 66 | |
| 67 | /* List of ACPI HID that use the coreboot ACPI ID */ |
| 68 | enum coreboot_acpi_ids { |
| 69 | COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */ |
| 70 | COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */ |
| 71 | }; |
| 72 | |
| 73 | enum acpi_tables { |
| 74 | /* Tables defined by ACPI and used by coreboot */ |
Jonathan Zhang | 3dcafa8 | 2022-05-11 13:11:20 -0700 | [diff] [blame] | 75 | BERT, CEDT, DBG2, DMAR, DSDT, EINJ, FACS, FADT, HEST, HMAT, HPET, IVRS, |
| 76 | MADT, MCFG, RSDP, RSDT, SLIT, SRAT, SSDT, TCPA, TPM2, XSDT, ECDT, LPIT, |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 77 | /* Additional proprietary tables used by coreboot */ |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 78 | VFCT, NHLT, SPMI, CRAT |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /* RSDP (Root System Description Pointer) */ |
| 82 | typedef struct acpi_rsdp { |
| 83 | char signature[8]; /* RSDP signature */ |
| 84 | u8 checksum; /* Checksum of the first 20 bytes */ |
| 85 | char oem_id[6]; /* OEM ID */ |
| 86 | u8 revision; /* RSDP revision */ |
| 87 | u32 rsdt_address; /* Physical address of RSDT (32 bits) */ |
| 88 | u32 length; /* Total RSDP length (incl. extended part) */ |
| 89 | u64 xsdt_address; /* Physical address of XSDT (64 bits) */ |
| 90 | u8 ext_checksum; /* Checksum of the whole table */ |
| 91 | u8 reserved[3]; |
| 92 | } __packed acpi_rsdp_t; |
| 93 | |
| 94 | /* GAS (Generic Address Structure) */ |
| 95 | typedef struct acpi_gen_regaddr { |
| 96 | u8 space_id; /* Address space ID */ |
| 97 | u8 bit_width; /* Register size in bits */ |
| 98 | u8 bit_offset; /* Register bit offset */ |
| 99 | u8 access_size; /* Access size since ACPI 2.0c */ |
| 100 | u32 addrl; /* Register address, low 32 bits */ |
| 101 | u32 addrh; /* Register address, high 32 bits */ |
| 102 | } __packed acpi_addr_t; |
| 103 | |
Elyes HAOUAS | 5f5fd85 | 2020-10-15 12:24:00 +0200 | [diff] [blame] | 104 | #define ACPI_ADDRESS_SPACE_MEMORY 0 /* System memory */ |
| 105 | #define ACPI_ADDRESS_SPACE_IO 1 /* System I/O */ |
| 106 | #define ACPI_ADDRESS_SPACE_PCI 2 /* PCI config space */ |
| 107 | #define ACPI_ADDRESS_SPACE_EC 3 /* Embedded controller */ |
| 108 | #define ACPI_ADDRESS_SPACE_SMBUS 4 /* SMBus */ |
| 109 | #define ACPI_ADDRESS_SPACE_CMOS 5 /* SystemCMOS */ |
| 110 | #define ACPI_ADDRESS_SPACE_PCI_BAR_TARGET 6 /* PciBarTarget */ |
| 111 | #define ACPI_ADDRESS_SPACE_IPMI 7 /* IPMI */ |
| 112 | #define ACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO 8 /* GeneralPurposeIO */ |
| 113 | #define ACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS 9 /* GenericSerialBus */ |
| 114 | #define ACPI_ADDRESS_SPACE_PCC 0x0A /* Platform Comm. Channel */ |
| 115 | #define ACPI_ADDRESS_SPACE_FIXED 0x7f /* Functional fixed hardware */ |
| 116 | #define ACPI_FFIXEDHW_VENDOR_INTEL 1 /* Intel */ |
| 117 | #define ACPI_FFIXEDHW_CLASS_HLT 0 /* C1 Halt */ |
| 118 | #define ACPI_FFIXEDHW_CLASS_IO_HLT 1 /* C1 I/O then Halt */ |
| 119 | #define ACPI_FFIXEDHW_CLASS_MWAIT 2 /* MWAIT Native C-state */ |
| 120 | #define ACPI_FFIXEDHW_FLAG_HW_COORD 1 /* Hardware Coordination bit */ |
| 121 | #define ACPI_FFIXEDHW_FLAG_BM_STS 2 /* BM_STS avoidance bit */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 122 | /* 0x80-0xbf: Reserved */ |
| 123 | /* 0xc0-0xff: OEM defined */ |
| 124 | |
| 125 | /* Access size definitions for Generic address structure */ |
| 126 | #define ACPI_ACCESS_SIZE_UNDEFINED 0 /* Undefined (legacy reasons) */ |
| 127 | #define ACPI_ACCESS_SIZE_BYTE_ACCESS 1 |
| 128 | #define ACPI_ACCESS_SIZE_WORD_ACCESS 2 |
| 129 | #define ACPI_ACCESS_SIZE_DWORD_ACCESS 3 |
| 130 | #define ACPI_ACCESS_SIZE_QWORD_ACCESS 4 |
| 131 | |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 132 | /* Macros for common resource types */ |
| 133 | #define ACPI_REG_MSR(address, offset, width) \ |
Michael Niewöhner | f72c7b1 | 2021-10-05 21:42:57 +0200 | [diff] [blame] | 134 | (acpi_addr_t){ \ |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 135 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 136 | .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \ |
| 137 | .addrl = address, \ |
| 138 | .bit_offset = offset, \ |
| 139 | .bit_width = width, \ |
| 140 | } |
| 141 | |
Michael Niewöhner | f72c7b1 | 2021-10-05 21:42:57 +0200 | [diff] [blame] | 142 | #define ACPI_REG_UNSUPPORTED (acpi_addr_t){0} |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 143 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 144 | /* Common ACPI HIDs */ |
| 145 | #define ACPI_HID_FDC "PNP0700" |
| 146 | #define ACPI_HID_KEYBOARD "PNP0303" |
| 147 | #define ACPI_HID_MOUSE "PNP0F03" |
| 148 | #define ACPI_HID_COM "PNP0501" |
| 149 | #define ACPI_HID_LPT "PNP0400" |
| 150 | #define ACPI_HID_PNP "PNP0C02" |
| 151 | #define ACPI_HID_CONTAINER "PNP0A05" |
| 152 | |
| 153 | /* Generic ACPI header, provided by (almost) all tables */ |
| 154 | typedef struct acpi_table_header { |
| 155 | char signature[4]; /* ACPI signature (4 ASCII characters) */ |
| 156 | u32 length; /* Table length in bytes (incl. header) */ |
| 157 | u8 revision; /* Table version (not ACPI version!) */ |
| 158 | u8 checksum; /* To make sum of entire table == 0 */ |
| 159 | char oem_id[6]; /* OEM identification */ |
| 160 | char oem_table_id[8]; /* OEM table identification */ |
| 161 | u32 oem_revision; /* OEM revision number */ |
| 162 | char asl_compiler_id[4]; /* ASL compiler vendor ID */ |
| 163 | u32 asl_compiler_revision; /* ASL compiler revision number */ |
| 164 | } __packed acpi_header_t; |
| 165 | |
| 166 | /* A maximum number of 32 ACPI tables ought to be enough for now. */ |
| 167 | #define MAX_ACPI_TABLES 32 |
| 168 | |
| 169 | /* RSDT (Root System Description Table) */ |
| 170 | typedef struct acpi_rsdt { |
| 171 | acpi_header_t header; |
| 172 | u32 entry[MAX_ACPI_TABLES]; |
| 173 | } __packed acpi_rsdt_t; |
| 174 | |
| 175 | /* XSDT (Extended System Description Table) */ |
| 176 | typedef struct acpi_xsdt { |
| 177 | acpi_header_t header; |
| 178 | u64 entry[MAX_ACPI_TABLES]; |
| 179 | } __packed acpi_xsdt_t; |
| 180 | |
| 181 | /* HPET timers */ |
| 182 | typedef struct acpi_hpet { |
| 183 | acpi_header_t header; |
| 184 | u32 id; |
| 185 | acpi_addr_t addr; |
| 186 | u8 number; |
| 187 | u16 min_tick; |
| 188 | u8 attributes; |
| 189 | } __packed acpi_hpet_t; |
| 190 | |
| 191 | /* MCFG (PCI Express MMIO config space BAR description table) */ |
| 192 | typedef struct acpi_mcfg { |
| 193 | acpi_header_t header; |
| 194 | u8 reserved[8]; |
| 195 | } __packed acpi_mcfg_t; |
| 196 | |
| 197 | typedef struct acpi_tcpa { |
| 198 | acpi_header_t header; |
| 199 | u16 platform_class; |
| 200 | u32 laml; |
| 201 | u64 lasa; |
| 202 | } __packed acpi_tcpa_t; |
| 203 | |
| 204 | typedef struct acpi_tpm2 { |
| 205 | acpi_header_t header; |
| 206 | u16 platform_class; |
| 207 | u8 reserved[2]; |
| 208 | u64 control_area; |
| 209 | u32 start_method; |
| 210 | u8 msp[12]; |
| 211 | u32 laml; |
| 212 | u64 lasa; |
| 213 | } __packed acpi_tpm2_t; |
| 214 | |
| 215 | typedef struct acpi_mcfg_mmconfig { |
| 216 | u32 base_address; |
| 217 | u32 base_reserved; |
| 218 | u16 pci_segment_group_number; |
| 219 | u8 start_bus_number; |
| 220 | u8 end_bus_number; |
| 221 | u8 reserved[4]; |
| 222 | } __packed acpi_mcfg_mmconfig_t; |
| 223 | |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 224 | /* |
Jonathan Zhang | 3dcafa8 | 2022-05-11 13:11:20 -0700 | [diff] [blame] | 225 | * CEDT (CXL Early Discovery Table) |
| 226 | * CXL spec 2.0 section 9.14.1 |
| 227 | */ |
| 228 | typedef struct acpi_cedt { |
| 229 | acpi_header_t header; |
| 230 | /* Followed by CEDT structures[n] */ |
| 231 | } __packed acpi_cedt_t; |
| 232 | |
| 233 | #define ACPI_CEDT_STRUCTURE_CHBS 0 |
| 234 | #define ACPI_CEDT_STRUCTURE_CFMWS 1 |
| 235 | |
| 236 | #define ACPI_CEDT_CHBS_CXL_VER_1_1 0x00 |
| 237 | #define ACPI_CEDT_CHBS_CXL_VER_2_0 0x01 |
| 238 | |
| 239 | /* CHBS: CXL Host Bridge Structure */ |
| 240 | typedef struct acpi_cedt_chbs { |
| 241 | u8 type; /* Always 0, other values reserved */ |
| 242 | u8 resv1; |
| 243 | u16 length; /* Length in bytes (32) */ |
| 244 | u32 uid; /* CXL Host Bridge Unique ID */ |
| 245 | u32 cxl_ver; |
| 246 | u32 resv2; |
| 247 | /* |
| 248 | * For CXL 1.1, the base is Downstream Port Root Complex Resource Block; |
| 249 | * For CXL 2.0, the base is CXL Host Bridge Component Registers. |
| 250 | */ |
| 251 | u64 base; |
| 252 | u64 len; |
| 253 | } __packed acpi_cedt_chbs_t; |
| 254 | |
| 255 | #define ACPI_CEDT_CFMWS_RESTRICTION_TYPE_2_MEM (1 << 0) |
| 256 | #define ACPI_CEDT_CFMWS_RESTRICTION_TYPE_3_MEM (1 << 1) |
| 257 | #define ACPI_CEDT_CFMWS_RESTRICTION_VOLATIL (1 << 2) |
| 258 | #define ACPI_CEDT_CFMWS_RESTRICTION_PERSISTENT (1 << 3) |
| 259 | #define ACPI_CEDT_CFMWS_RESTRICTION_FIXED (1 << 4) |
| 260 | |
| 261 | /* CFMWS: CXL Fixed Memory Window Structure */ |
| 262 | typedef struct acpi_cedt_cfmws { |
| 263 | u8 type; /* Type (0) */ |
| 264 | u8 resv1; |
| 265 | u16 length; /* Length in bytes (32) */ |
| 266 | u32 resv2; |
| 267 | u64 base_hpa; /* Base of the HPA range, 256MB aligned */ |
| 268 | u64 window_size; /* Number of bytes this window represents */ |
| 269 | u8 eniw; /* Encoded Number of Interleave Ways */ |
| 270 | u8 interleave_arithmetic; /* Standard Modulo arithmetic (0) */ |
| 271 | u16 resv3; |
| 272 | u32 hbig; /* Host Bridge Interleave Granularity */ |
| 273 | u16 restriction; |
| 274 | u16 qtg_id; |
| 275 | u32 interleave_target[]; /* Interleave Target List */ |
| 276 | } __packed acpi_cedt_cfmws_t; |
| 277 | |
| 278 | /* |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 279 | * HMAT (Heterogeneous Memory Attribute Table) |
| 280 | * ACPI spec 6.4 section 5.2.27 |
| 281 | */ |
| 282 | typedef struct acpi_hmat { |
| 283 | acpi_header_t header; |
| 284 | u32 resv; |
| 285 | /* Followed by HMAT table structure[n] */ |
| 286 | } __packed acpi_hmat_t; |
| 287 | |
| 288 | /* HMAT: Memory Proximity Domain Attributes structure */ |
| 289 | typedef struct acpi_hmat_mpda { |
| 290 | u16 type; /* Type (0) */ |
| 291 | u16 resv; |
| 292 | u32 length; /* Length in bytes (40) */ |
| 293 | u16 flags; |
| 294 | u16 resv1; |
| 295 | u32 proximity_domain_initiator; |
| 296 | u32 proximity_domain_memory; |
| 297 | u32 resv2; |
| 298 | u64 resv3; |
| 299 | u64 resv4; |
| 300 | } __packed acpi_hmat_mpda_t; |
| 301 | |
| 302 | /* HMAT: System Locality Latency and Bandwidth Information structure */ |
| 303 | typedef struct acpi_hmat_sllbi { |
| 304 | u16 type; /* Type (1) */ |
| 305 | u16 resv; |
| 306 | u32 length; /* Length in bytes */ |
| 307 | u8 flags; |
| 308 | u8 data_type; |
| 309 | /* |
| 310 | * Transfer size defined as a 5-biased power of 2 exponent, |
| 311 | * when the bandwidth/latency value is achieved. |
| 312 | */ |
| 313 | u8 min_transfer_size; |
| 314 | u8 resv1; |
| 315 | u32 num_initiator_domains; |
| 316 | u32 num_target_domains; |
| 317 | u32 resv2; |
| 318 | u64 entry_base_unit; |
| 319 | /* Followed by initiator proximity domain list */ |
| 320 | /* Followed by target proximity domain list */ |
| 321 | /* Followed by latency / bandwidth values */ |
| 322 | } __packed acpi_hmat_sllbi_t; |
| 323 | |
| 324 | /* HMAT: Memory Side Cache Information structure */ |
| 325 | typedef struct acpi_hmat_msci { |
| 326 | u16 type; /* Type (2) */ |
| 327 | u16 resv; |
| 328 | u32 length; /* Length in bytes */ |
| 329 | u32 domain; /* Proximity domain for the memory */ |
| 330 | u32 resv1; |
| 331 | u64 cache_size; |
| 332 | /* Describes level, associativity, write policy, cache line size */ |
| 333 | u32 cache_attributes; |
| 334 | u16 resv2; |
| 335 | /* |
| 336 | * Number of SMBIOS handlers that contribute to the |
| 337 | * memory side cache physical devices |
| 338 | */ |
| 339 | u16 num_handlers; |
| 340 | /* Followed by SMBIOS handlers*/ |
| 341 | } __packed acpi_hmat_msci_t; |
| 342 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 343 | /* SRAT (System Resource Affinity Table) */ |
| 344 | typedef struct acpi_srat { |
| 345 | acpi_header_t header; |
| 346 | u32 resv; |
| 347 | u64 resv1; |
| 348 | /* Followed by static resource allocation structure[n] */ |
| 349 | } __packed acpi_srat_t; |
| 350 | |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 351 | #define ACPI_SRAT_STRUCTURE_LAPIC 0 |
| 352 | #define ACPI_SRAT_STRUCTURE_MEM 1 |
| 353 | #define ACPI_SRAT_STRUCTURE_GIA 5 |
| 354 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 355 | /* SRAT: Processor Local APIC/SAPIC Affinity Structure */ |
| 356 | typedef struct acpi_srat_lapic { |
| 357 | u8 type; /* Type (0) */ |
| 358 | u8 length; /* Length in bytes (16) */ |
| 359 | u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */ |
| 360 | u8 apic_id; /* Local APIC ID */ |
| 361 | u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */ |
| 362 | u8 local_sapic_eid; /* Local SAPIC EID */ |
| 363 | u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */ |
| 364 | u32 clock_domain; /* _CDM Clock Domain */ |
| 365 | } __packed acpi_srat_lapic_t; |
| 366 | |
| 367 | /* SRAT: Memory Affinity Structure */ |
| 368 | typedef struct acpi_srat_mem { |
| 369 | u8 type; /* Type (1) */ |
| 370 | u8 length; /* Length in bytes (40) */ |
| 371 | u32 proximity_domain; /* Proximity domain */ |
| 372 | u16 resv; |
| 373 | u32 base_address_low; /* Mem range base address, low */ |
| 374 | u32 base_address_high; /* Mem range base address, high */ |
| 375 | u32 length_low; /* Mem range length, low */ |
| 376 | u32 length_high; /* Mem range length, high */ |
| 377 | u32 resv1; |
| 378 | u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2, |
| 379 | * other bits reserved to 0 |
| 380 | */ |
| 381 | u32 resv2[2]; |
| 382 | } __packed acpi_srat_mem_t; |
| 383 | |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 384 | /* SRAT: Generic Initiator Affinity Structure (ACPI spec 6.4 section 5.2.16.6) */ |
| 385 | typedef struct acpi_srat_gia { |
| 386 | u8 type; /* Type (5) */ |
| 387 | u8 length; /* Length in bytes (32) */ |
| 388 | u8 resv; |
| 389 | u8 dev_handle_type; /* Device handle type */ |
| 390 | u32 proximity_domain; /*Proximity domain */ |
| 391 | u8 dev_handle[16]; /* Device handle */ |
| 392 | u32 flags; |
| 393 | u32 resv1; |
| 394 | } __packed acpi_srat_gia_t; |
| 395 | |
| 396 | #define ACPI_SRAT_GIA_DEV_HANDLE_ACPI 0 |
| 397 | #define ACPI_SRAT_GIA_DEV_HANDLE_PCI 1 |
| 398 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 399 | /* SLIT (System Locality Distance Information Table) */ |
| 400 | typedef struct acpi_slit { |
| 401 | acpi_header_t header; |
| 402 | /* Followed by static resource allocation 8+byte[num*num] */ |
| 403 | } __packed acpi_slit_t; |
| 404 | |
| 405 | /* MADT (Multiple APIC Description Table) */ |
| 406 | typedef struct acpi_madt { |
| 407 | acpi_header_t header; |
| 408 | u32 lapic_addr; /* Local APIC address */ |
| 409 | u32 flags; /* Multiple APIC flags */ |
| 410 | } __packed acpi_madt_t; |
| 411 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 412 | /* |
| 413 | * LPIT (Low Power Idle Table) |
| 414 | * Conforms to "Intel Low Power S0 Idle" specification, rev 002 from July 2017. |
| 415 | */ |
| 416 | typedef struct acpi_lpit { |
| 417 | acpi_header_t header; |
| 418 | } __packed acpi_lpit_t; |
| 419 | |
| 420 | /* LPIT: LPI descriptor flags */ |
| 421 | typedef struct acpi_lpi_flags { |
| 422 | uint32_t disabled : 1; |
| 423 | uint32_t counter_not_available : 1; |
| 424 | uint32_t reserved : 30; |
| 425 | } __packed acpi_lpi_desc_flags_t; |
| 426 | |
| 427 | /* LPIT: LPI descriptor types */ |
| 428 | enum acpi_lpi_desc_type { |
| 429 | ACPI_LPI_DESC_TYPE_NATIVE_CSTATE = 0x00, |
| 430 | /* type >= 1 reserved */ |
| 431 | }; |
| 432 | |
| 433 | /* LPIT: LPI descriptor header */ |
| 434 | typedef struct acpi_lpi_desc_hdr { |
| 435 | uint32_t type; |
| 436 | uint32_t length; |
| 437 | uint16_t uid; |
| 438 | uint16_t reserved; |
| 439 | } __packed acpi_lpi_desc_hdr_t; |
| 440 | |
| 441 | #define ACPI_LPIT_CTR_FREQ_TSC 0 |
| 442 | |
| 443 | /* LPIT: Native C-state instruction based LPI structure */ |
| 444 | typedef struct acpi_lpi_desc_ncst { |
| 445 | acpi_lpi_desc_hdr_t header; |
| 446 | acpi_lpi_desc_flags_t flags; |
| 447 | acpi_addr_t entry_trigger; /* Entry trigger C-state */ |
| 448 | uint32_t min_residency; /* Minimum residency or "break-even" in microseconds */ |
| 449 | uint32_t max_latency; /* Worst case exit latency in microseconds */ |
| 450 | acpi_addr_t residency_counter; |
| 451 | uint64_t counter_frequency; /* Frequency in cycles per second - 0 means TSC freq */ |
| 452 | } __packed acpi_lpi_desc_ncst_t; |
| 453 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 454 | /* VFCT image header */ |
| 455 | typedef struct acpi_vfct_image_hdr { |
| 456 | u32 PCIBus; |
| 457 | u32 PCIDevice; |
| 458 | u32 PCIFunction; |
| 459 | u16 VendorID; |
| 460 | u16 DeviceID; |
| 461 | u16 SSVID; |
| 462 | u16 SSID; |
| 463 | u32 Revision; |
| 464 | u32 ImageLength; |
| 465 | u8 VbiosContent; // dummy - copy VBIOS here |
| 466 | } __packed acpi_vfct_image_hdr_t; |
| 467 | |
| 468 | /* VFCT (VBIOS Fetch Table) */ |
| 469 | typedef struct acpi_vfct { |
| 470 | acpi_header_t header; |
| 471 | u8 TableUUID[16]; |
| 472 | u32 VBIOSImageOffset; |
| 473 | u32 Lib1ImageOffset; |
| 474 | u32 Reserved[4]; |
| 475 | acpi_vfct_image_hdr_t image_hdr; |
| 476 | } __packed acpi_vfct_t; |
| 477 | |
| 478 | typedef struct acpi_ivrs_info { |
| 479 | } __packed acpi_ivrs_info_t; |
| 480 | |
| 481 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */ |
| 482 | typedef struct acpi_ivrs_ivhd { |
| 483 | uint8_t type; |
| 484 | uint8_t flags; |
| 485 | uint16_t length; |
| 486 | uint16_t device_id; |
| 487 | uint16_t capability_offset; |
| 488 | uint32_t iommu_base_low; |
| 489 | uint32_t iommu_base_high; |
| 490 | uint16_t pci_segment_group; |
| 491 | uint16_t iommu_info; |
| 492 | uint32_t iommu_feature_info; |
| 493 | uint8_t entry[0]; |
| 494 | } __packed acpi_ivrs_ivhd_t; |
| 495 | |
| 496 | /* IVRS (I/O Virtualization Reporting Structure) Type 10h */ |
| 497 | typedef struct acpi_ivrs { |
| 498 | acpi_header_t header; |
| 499 | uint32_t iv_info; |
| 500 | uint32_t reserved[2]; |
| 501 | struct acpi_ivrs_ivhd ivhd; |
| 502 | } __packed acpi_ivrs_t; |
| 503 | |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 504 | /* CRAT (Component Resource Affinity Table Structure) */ |
| 505 | struct acpi_crat_header { |
| 506 | acpi_header_t header; |
| 507 | uint32_t total_entries; |
| 508 | uint16_t num_nodes; |
| 509 | uint8_t reserved[6]; |
| 510 | } __packed; |
| 511 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 512 | /* IVHD Type 11h IOMMU Attributes */ |
| 513 | typedef struct ivhd11_iommu_attr { |
| 514 | uint32_t reserved1 : 13; |
| 515 | uint32_t perf_counters : 4; |
| 516 | uint32_t perf_counter_banks : 6; |
| 517 | uint32_t msi_num_ppr : 5; |
| 518 | uint32_t reserved2 : 4; |
| 519 | } __packed ivhd11_iommu_attr_t; |
| 520 | |
| 521 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 11h */ |
| 522 | typedef struct acpi_ivrs_ivhd_11 { |
| 523 | uint8_t type; |
| 524 | uint8_t flags; |
| 525 | uint16_t length; |
| 526 | uint16_t device_id; |
| 527 | uint16_t capability_offset; |
| 528 | uint32_t iommu_base_low; |
| 529 | uint32_t iommu_base_high; |
| 530 | uint16_t pci_segment_group; |
| 531 | uint16_t iommu_info; |
| 532 | struct ivhd11_iommu_attr iommu_attributes; |
| 533 | uint32_t efr_reg_image_low; |
| 534 | uint32_t efr_reg_image_high; |
| 535 | uint32_t reserved[2]; |
| 536 | uint8_t entry[0]; |
| 537 | } __packed acpi_ivrs_ivhd11_t; |
| 538 | |
| 539 | enum dev_scope_type { |
| 540 | SCOPE_PCI_ENDPOINT = 1, |
| 541 | SCOPE_PCI_SUB = 2, |
| 542 | SCOPE_IOAPIC = 3, |
| 543 | SCOPE_MSI_HPET = 4, |
| 544 | SCOPE_ACPI_NAMESPACE_DEVICE = 5 |
| 545 | }; |
| 546 | |
| 547 | typedef struct dev_scope { |
| 548 | u8 type; |
| 549 | u8 length; |
| 550 | u8 reserved[2]; |
| 551 | u8 enumeration; |
| 552 | u8 start_bus; |
| 553 | struct { |
| 554 | u8 dev; |
| 555 | u8 fn; |
| 556 | } __packed path[0]; |
| 557 | } __packed dev_scope_t; |
| 558 | |
| 559 | enum dmar_type { |
| 560 | DMAR_DRHD = 0, |
| 561 | DMAR_RMRR = 1, |
| 562 | DMAR_ATSR = 2, |
| 563 | DMAR_RHSA = 3, |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 564 | DMAR_ANDD = 4, |
| 565 | DMAR_SATC = 5 |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 566 | }; |
| 567 | |
| 568 | enum { |
| 569 | DRHD_INCLUDE_PCI_ALL = 1 |
| 570 | }; |
| 571 | |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 572 | enum { |
| 573 | ATC_REQUIRED = 1 |
| 574 | }; |
| 575 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 576 | enum dmar_flags { |
| 577 | DMAR_INTR_REMAP = 1 << 0, |
| 578 | DMAR_X2APIC_OPT_OUT = 1 << 1, |
| 579 | DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2, |
| 580 | }; |
| 581 | |
| 582 | typedef struct dmar_entry { |
| 583 | u16 type; |
| 584 | u16 length; |
| 585 | u8 flags; |
| 586 | u8 reserved; |
| 587 | u16 segment; |
| 588 | u64 bar; |
| 589 | } __packed dmar_entry_t; |
| 590 | |
| 591 | typedef struct dmar_rmrr_entry { |
| 592 | u16 type; |
| 593 | u16 length; |
| 594 | u16 reserved; |
| 595 | u16 segment; |
| 596 | u64 bar; |
| 597 | u64 limit; |
| 598 | } __packed dmar_rmrr_entry_t; |
| 599 | |
| 600 | typedef struct dmar_atsr_entry { |
| 601 | u16 type; |
| 602 | u16 length; |
| 603 | u8 flags; |
| 604 | u8 reserved; |
| 605 | u16 segment; |
| 606 | } __packed dmar_atsr_entry_t; |
| 607 | |
| 608 | typedef struct dmar_rhsa_entry { |
| 609 | u16 type; |
| 610 | u16 length; |
| 611 | u32 reserved; |
| 612 | u64 base_address; |
| 613 | u32 proximity_domain; |
| 614 | } __packed dmar_rhsa_entry_t; |
| 615 | |
| 616 | typedef struct dmar_andd_entry { |
| 617 | u16 type; |
| 618 | u16 length; |
| 619 | u8 reserved[3]; |
| 620 | u8 device_number; |
| 621 | u8 device_name[]; |
| 622 | } __packed dmar_andd_entry_t; |
| 623 | |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 624 | typedef struct dmar_satc_entry { |
| 625 | u16 type; |
| 626 | u16 length; |
| 627 | u8 flags; |
| 628 | u8 reserved; |
| 629 | u16 segment_number; |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 630 | } __packed dmar_satc_entry_t; |
| 631 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 632 | /* DMAR (DMA Remapping Reporting Structure) */ |
| 633 | typedef struct acpi_dmar { |
| 634 | acpi_header_t header; |
| 635 | u8 host_address_width; |
| 636 | u8 flags; |
| 637 | u8 reserved[10]; |
| 638 | dmar_entry_t structure[0]; |
| 639 | } __packed acpi_dmar_t; |
| 640 | |
| 641 | /* MADT: APIC Structure Types */ |
| 642 | enum acpi_apic_types { |
| 643 | LOCAL_APIC, /* Processor local APIC */ |
| 644 | IO_APIC, /* I/O APIC */ |
| 645 | IRQ_SOURCE_OVERRIDE, /* Interrupt source override */ |
| 646 | NMI_TYPE, /* NMI source */ |
| 647 | LOCAL_APIC_NMI, /* Local APIC NMI */ |
| 648 | LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */ |
| 649 | IO_SAPIC, /* I/O SAPIC */ |
| 650 | LOCAL_SAPIC, /* Local SAPIC */ |
| 651 | PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */ |
| 652 | LOCAL_X2APIC, /* Processor local x2APIC */ |
| 653 | LOCAL_X2APIC_NMI, /* Local x2APIC NMI */ |
| 654 | GICC, /* GIC CPU Interface */ |
| 655 | GICD, /* GIC Distributor */ |
| 656 | GIC_MSI_FRAME, /* GIC MSI Frame */ |
| 657 | GICR, /* GIC Redistributor */ |
| 658 | GIC_ITS, /* Interrupt Translation Service */ |
| 659 | /* 0x10-0x7f: Reserved */ |
| 660 | /* 0x80-0xff: Reserved for OEM use */ |
| 661 | }; |
| 662 | |
| 663 | /* MADT: Processor Local APIC Structure */ |
| 664 | typedef struct acpi_madt_lapic { |
| 665 | u8 type; /* Type (0) */ |
| 666 | u8 length; /* Length in bytes (8) */ |
| 667 | u8 processor_id; /* ACPI processor ID */ |
| 668 | u8 apic_id; /* Local APIC ID */ |
| 669 | u32 flags; /* Local APIC flags */ |
| 670 | } __packed acpi_madt_lapic_t; |
| 671 | |
| 672 | /* MADT: Local APIC NMI Structure */ |
| 673 | typedef struct acpi_madt_lapic_nmi { |
| 674 | u8 type; /* Type (4) */ |
| 675 | u8 length; /* Length in bytes (6) */ |
| 676 | u8 processor_id; /* ACPI processor ID */ |
| 677 | u16 flags; /* MPS INTI flags */ |
| 678 | u8 lint; /* Local APIC LINT# */ |
| 679 | } __packed acpi_madt_lapic_nmi_t; |
| 680 | |
Kyösti Mälkki | 66b5e1b | 2022-11-12 21:13:45 +0200 | [diff] [blame] | 681 | #define ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS 0xff |
| 682 | #define ACPI_MADT_LX2APIC_NMI_ALL_PROCESSORS ((u32)-1) |
Raul E Rangel | f5552ce | 2021-02-11 11:27:56 -0700 | [diff] [blame] | 683 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 684 | /* MADT: I/O APIC Structure */ |
| 685 | typedef struct acpi_madt_ioapic { |
| 686 | u8 type; /* Type (1) */ |
| 687 | u8 length; /* Length in bytes (12) */ |
| 688 | u8 ioapic_id; /* I/O APIC ID */ |
| 689 | u8 reserved; |
| 690 | u32 ioapic_addr; /* I/O APIC address */ |
| 691 | u32 gsi_base; /* Global system interrupt base */ |
| 692 | } __packed acpi_madt_ioapic_t; |
| 693 | |
Raul E Rangel | 169302a | 2022-04-25 14:59:05 -0600 | [diff] [blame] | 694 | #define MP_IRQ_POLARITY_DEFAULT 0x0 |
| 695 | #define MP_IRQ_POLARITY_HIGH 0x1 |
| 696 | #define MP_IRQ_POLARITY_LOW 0x3 |
| 697 | #define MP_IRQ_POLARITY_MASK 0x3 |
| 698 | #define MP_IRQ_TRIGGER_DEFAULT 0x0 |
| 699 | #define MP_IRQ_TRIGGER_EDGE 0x4 |
| 700 | #define MP_IRQ_TRIGGER_LEVEL 0xc |
| 701 | #define MP_IRQ_TRIGGER_MASK 0xc |
| 702 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 703 | /* MADT: Interrupt Source Override Structure */ |
| 704 | typedef struct acpi_madt_irqoverride { |
| 705 | u8 type; /* Type (2) */ |
| 706 | u8 length; /* Length in bytes (10) */ |
| 707 | u8 bus; /* ISA (0) */ |
| 708 | u8 source; /* Bus-relative int. source (IRQ) */ |
| 709 | u32 gsirq; /* Global system interrupt */ |
| 710 | u16 flags; /* MPS INTI flags */ |
| 711 | } __packed acpi_madt_irqoverride_t; |
| 712 | |
| 713 | /* MADT: Processor Local x2APIC Structure */ |
| 714 | typedef struct acpi_madt_lx2apic { |
| 715 | u8 type; /* Type (9) */ |
| 716 | u8 length; /* Length in bytes (16) */ |
| 717 | u16 reserved; |
| 718 | u32 x2apic_id; /* Local x2APIC ID */ |
| 719 | u32 flags; /* Same as Local APIC flags */ |
| 720 | u32 processor_id; /* ACPI processor ID */ |
| 721 | } __packed acpi_madt_lx2apic_t; |
| 722 | |
| 723 | /* MADT: Processor Local x2APIC NMI Structure */ |
| 724 | typedef struct acpi_madt_lx2apic_nmi { |
| 725 | u8 type; /* Type (10) */ |
| 726 | u8 length; /* Length in bytes (12) */ |
| 727 | u16 flags; /* Same as MPS INTI flags */ |
| 728 | u32 processor_id; /* ACPI processor ID */ |
| 729 | u8 lint; /* Local APIC LINT# */ |
| 730 | u8 reserved[3]; |
| 731 | } __packed acpi_madt_lx2apic_nmi_t; |
| 732 | |
| 733 | #define ACPI_DBG2_PORT_SERIAL 0x8000 |
| 734 | #define ACPI_DBG2_PORT_SERIAL_16550 0x0000 |
| 735 | #define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001 |
| 736 | #define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003 |
| 737 | #define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e |
| 738 | #define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f |
| 739 | #define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010 |
| 740 | #define ACPI_DBG2_PORT_IEEE1394 0x8001 |
| 741 | #define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000 |
| 742 | #define ACPI_DBG2_PORT_USB 0x8002 |
| 743 | #define ACPI_DBG2_PORT_USB_XHCI 0x0000 |
| 744 | #define ACPI_DBG2_PORT_USB_EHCI 0x0001 |
| 745 | #define ACPI_DBG2_PORT_NET 0x8003 |
| 746 | |
| 747 | /* DBG2: Microsoft Debug Port Table 2 header */ |
| 748 | typedef struct acpi_dbg2_header { |
| 749 | acpi_header_t header; |
| 750 | uint32_t devices_offset; |
| 751 | uint32_t devices_count; |
| 752 | } __attribute__((packed)) acpi_dbg2_header_t; |
| 753 | |
| 754 | /* DBG2: Microsoft Debug Port Table 2 device entry */ |
| 755 | typedef struct acpi_dbg2_device { |
| 756 | uint8_t revision; |
| 757 | uint16_t length; |
| 758 | uint8_t address_count; |
| 759 | uint16_t namespace_string_length; |
| 760 | uint16_t namespace_string_offset; |
| 761 | uint16_t oem_data_length; |
| 762 | uint16_t oem_data_offset; |
| 763 | uint16_t port_type; |
| 764 | uint16_t port_subtype; |
| 765 | uint8_t reserved[2]; |
| 766 | uint16_t base_address_offset; |
| 767 | uint16_t address_size_offset; |
| 768 | } __attribute__((packed)) acpi_dbg2_device_t; |
| 769 | |
| 770 | /* FADT (Fixed ACPI Description Table) */ |
| 771 | typedef struct acpi_fadt { |
| 772 | acpi_header_t header; |
| 773 | u32 firmware_ctrl; |
| 774 | u32 dsdt; |
| 775 | u8 reserved; /* Should be 0 */ |
| 776 | u8 preferred_pm_profile; |
| 777 | u16 sci_int; |
| 778 | u32 smi_cmd; |
| 779 | u8 acpi_enable; |
| 780 | u8 acpi_disable; |
| 781 | u8 s4bios_req; |
| 782 | u8 pstate_cnt; |
| 783 | u32 pm1a_evt_blk; |
| 784 | u32 pm1b_evt_blk; |
| 785 | u32 pm1a_cnt_blk; |
| 786 | u32 pm1b_cnt_blk; |
| 787 | u32 pm2_cnt_blk; |
| 788 | u32 pm_tmr_blk; |
| 789 | u32 gpe0_blk; |
| 790 | u32 gpe1_blk; |
| 791 | u8 pm1_evt_len; |
| 792 | u8 pm1_cnt_len; |
| 793 | u8 pm2_cnt_len; |
| 794 | u8 pm_tmr_len; |
| 795 | u8 gpe0_blk_len; |
| 796 | u8 gpe1_blk_len; |
| 797 | u8 gpe1_base; |
| 798 | u8 cst_cnt; |
| 799 | u16 p_lvl2_lat; |
| 800 | u16 p_lvl3_lat; |
| 801 | u16 flush_size; |
| 802 | u16 flush_stride; |
| 803 | u8 duty_offset; |
| 804 | u8 duty_width; |
| 805 | u8 day_alrm; |
| 806 | u8 mon_alrm; |
| 807 | u8 century; |
| 808 | u16 iapc_boot_arch; |
| 809 | u8 res2; |
| 810 | u32 flags; |
| 811 | acpi_addr_t reset_reg; |
| 812 | u8 reset_value; |
Elyes Haouas | b55ac09 | 2022-02-16 14:42:19 +0100 | [diff] [blame] | 813 | u16 ARM_boot_arch; /* Must be zero if ACPI Revision <= 5.0 */ |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 814 | u8 FADT_MinorVersion; /* Must be zero if ACPI Revision <= 5.0 */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 815 | u32 x_firmware_ctl_l; |
| 816 | u32 x_firmware_ctl_h; |
| 817 | u32 x_dsdt_l; |
| 818 | u32 x_dsdt_h; |
| 819 | acpi_addr_t x_pm1a_evt_blk; |
| 820 | acpi_addr_t x_pm1b_evt_blk; |
| 821 | acpi_addr_t x_pm1a_cnt_blk; |
| 822 | acpi_addr_t x_pm1b_cnt_blk; |
| 823 | acpi_addr_t x_pm2_cnt_blk; |
| 824 | acpi_addr_t x_pm_tmr_blk; |
| 825 | acpi_addr_t x_gpe0_blk; |
| 826 | acpi_addr_t x_gpe1_blk; |
| 827 | /* Revision 5 */ |
| 828 | acpi_addr_t sleep_control_reg; |
| 829 | acpi_addr_t sleep_status_reg; |
| 830 | /* Revision 6 */ |
| 831 | u64 hypervisor_vendor_identity; |
| 832 | } __packed acpi_fadt_t; |
| 833 | |
| 834 | /* FADT TABLE Revision values */ |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 835 | #define ACPI_FADT_REV_ACPI_1 1 |
| 836 | #define ACPI_FADT_REV_ACPI_2 3 |
| 837 | #define ACPI_FADT_REV_ACPI_3 4 |
| 838 | #define ACPI_FADT_REV_ACPI_4 4 |
| 839 | #define ACPI_FADT_REV_ACPI_5 5 |
| 840 | #define ACPI_FADT_REV_ACPI_6 6 |
| 841 | |
| 842 | /* FADT Minor Version value: |
| 843 | * Bits 0-3: minor version |
| 844 | * Bits 4-7: Errata |
| 845 | * value of 1 means this is compatible with Errata A, |
| 846 | * value of 2 would be compatible with Errata B, and so on |
| 847 | * Version 6.3 Errata A would be: (1 << 4) | 3 |
| 848 | */ |
| 849 | #define ACPI_FADT_MINOR_VERSION_0 0 /* coreboot currently use this version */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 850 | |
| 851 | /* Flags for p_lvl2_lat and p_lvl3_lat */ |
| 852 | #define ACPI_FADT_C2_NOT_SUPPORTED 101 |
| 853 | #define ACPI_FADT_C3_NOT_SUPPORTED 1001 |
| 854 | |
| 855 | /* FADT Feature Flags */ |
| 856 | #define ACPI_FADT_WBINVD (1 << 0) |
| 857 | #define ACPI_FADT_WBINVD_FLUSH (1 << 1) |
| 858 | #define ACPI_FADT_C1_SUPPORTED (1 << 2) |
| 859 | #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3) |
| 860 | #define ACPI_FADT_POWER_BUTTON (1 << 4) |
| 861 | #define ACPI_FADT_SLEEP_BUTTON (1 << 5) |
| 862 | #define ACPI_FADT_FIXED_RTC (1 << 6) |
| 863 | #define ACPI_FADT_S4_RTC_WAKE (1 << 7) |
| 864 | #define ACPI_FADT_32BIT_TIMER (1 << 8) |
| 865 | #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9) |
| 866 | #define ACPI_FADT_RESET_REGISTER (1 << 10) |
| 867 | #define ACPI_FADT_SEALED_CASE (1 << 11) |
| 868 | #define ACPI_FADT_HEADLESS (1 << 12) |
| 869 | #define ACPI_FADT_SLEEP_TYPE (1 << 13) |
| 870 | #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14) |
| 871 | #define ACPI_FADT_PLATFORM_CLOCK (1 << 15) |
| 872 | #define ACPI_FADT_S4_RTC_VALID (1 << 16) |
| 873 | #define ACPI_FADT_REMOTE_POWER_ON (1 << 17) |
| 874 | #define ACPI_FADT_APIC_CLUSTER (1 << 18) |
| 875 | #define ACPI_FADT_APIC_PHYSICAL (1 << 19) |
| 876 | /* Bits 20-31: reserved ACPI 3.0 & 4.0 */ |
| 877 | #define ACPI_FADT_HW_REDUCED_ACPI (1 << 20) |
| 878 | #define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21) |
| 879 | /* bits 22-31: reserved since ACPI 5.0 */ |
| 880 | |
| 881 | /* FADT Boot Architecture Flags */ |
| 882 | #define ACPI_FADT_LEGACY_DEVICES (1 << 0) |
| 883 | #define ACPI_FADT_8042 (1 << 1) |
| 884 | #define ACPI_FADT_VGA_NOT_PRESENT (1 << 2) |
| 885 | #define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3) |
| 886 | #define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4) |
| 887 | #define ACPI_FADT_NO_CMOS_RTC (1 << 5) |
| 888 | #define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */ |
| 889 | |
| 890 | /* FADT ARM Boot Architecture Flags */ |
| 891 | #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) |
| 892 | #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) |
| 893 | /* bits 2-16: reserved since ACPI 5.1 */ |
| 894 | |
| 895 | /* FADT Preferred Power Management Profile */ |
| 896 | enum acpi_preferred_pm_profiles { |
| 897 | PM_UNSPECIFIED = 0, |
| 898 | PM_DESKTOP = 1, |
| 899 | PM_MOBILE = 2, |
| 900 | PM_WORKSTATION = 3, |
| 901 | PM_ENTERPRISE_SERVER = 4, |
| 902 | PM_SOHO_SERVER = 5, |
| 903 | PM_APPLIANCE_PC = 6, |
| 904 | PM_PERFORMANCE_SERVER = 7, |
| 905 | PM_TABLET = 8, /* ACPI 5.0 & greater */ |
| 906 | }; |
| 907 | |
| 908 | /* FACS (Firmware ACPI Control Structure) */ |
| 909 | typedef struct acpi_facs { |
| 910 | char signature[4]; /* "FACS" */ |
| 911 | u32 length; /* Length in bytes (>= 64) */ |
| 912 | u32 hardware_signature; /* Hardware signature */ |
| 913 | u32 firmware_waking_vector; /* Firmware waking vector */ |
| 914 | u32 global_lock; /* Global lock */ |
| 915 | u32 flags; /* FACS flags */ |
| 916 | u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ |
| 917 | u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ |
| 918 | u8 version; /* FACS version */ |
| 919 | u8 resv1[3]; /* This value is 0 */ |
| 920 | u32 ospm_flags; /* 64BIT_WAKE_F */ |
| 921 | u8 resv2[24]; /* This value is 0 */ |
| 922 | } __packed acpi_facs_t; |
| 923 | |
| 924 | /* FACS flags */ |
| 925 | #define ACPI_FACS_S4BIOS_F (1 << 0) |
| 926 | #define ACPI_FACS_64BIT_WAKE_F (1 << 1) |
| 927 | /* Bits 31..2: reserved */ |
| 928 | |
| 929 | /* ECDT (Embedded Controller Boot Resources Table) */ |
| 930 | typedef struct acpi_ecdt { |
| 931 | acpi_header_t header; |
| 932 | acpi_addr_t ec_control; /* EC control register */ |
| 933 | acpi_addr_t ec_data; /* EC data register */ |
| 934 | u32 uid; /* UID */ |
| 935 | u8 gpe_bit; /* GPE bit */ |
| 936 | u8 ec_id[]; /* EC ID */ |
| 937 | } __packed acpi_ecdt_t; |
| 938 | |
| 939 | /* HEST (Hardware Error Source Table) */ |
| 940 | typedef struct acpi_hest { |
| 941 | acpi_header_t header; |
| 942 | u32 error_source_count; |
| 943 | /* error_source_struct(s) */ |
| 944 | } __packed acpi_hest_t; |
| 945 | |
| 946 | /* Error Source Descriptors */ |
| 947 | typedef struct acpi_hest_esd { |
| 948 | u16 type; |
| 949 | u16 source_id; |
| 950 | u16 resv; |
| 951 | u8 flags; |
| 952 | u8 enabled; |
| 953 | u32 prealloc_erecords; /* The number of error records to |
| 954 | * pre-allocate for this error source. |
| 955 | */ |
| 956 | u32 max_section_per_record; |
| 957 | } __packed acpi_hest_esd_t; |
| 958 | |
| 959 | /* Hardware Error Notification */ |
| 960 | typedef struct acpi_hest_hen { |
| 961 | u8 type; |
| 962 | u8 length; |
| 963 | u16 conf_we; /* Configuration Write Enable */ |
| 964 | u32 poll_interval; |
| 965 | u32 vector; |
| 966 | u32 sw2poll_threshold_val; |
| 967 | u32 sw2poll_threshold_win; |
| 968 | u32 error_threshold_val; |
| 969 | u32 error_threshold_win; |
| 970 | } __packed acpi_hest_hen_t; |
| 971 | |
| 972 | /* BERT (Boot Error Record Table) */ |
| 973 | typedef struct acpi_bert { |
| 974 | acpi_header_t header; |
| 975 | u32 region_length; |
| 976 | u64 error_region; |
| 977 | } __packed acpi_bert_t; |
| 978 | |
| 979 | /* Generic Error Data Entry */ |
| 980 | typedef struct acpi_hest_generic_data { |
| 981 | guid_t section_type; |
| 982 | u32 error_severity; |
| 983 | u16 revision; |
| 984 | u8 validation_bits; |
| 985 | u8 flags; |
| 986 | u32 data_length; |
| 987 | guid_t fru_id; |
| 988 | u8 fru_text[20]; |
| 989 | /* error data */ |
| 990 | } __packed acpi_hest_generic_data_t; |
| 991 | |
| 992 | /* Generic Error Data Entry v300 */ |
| 993 | typedef struct acpi_hest_generic_data_v300 { |
| 994 | guid_t section_type; |
| 995 | u32 error_severity; |
| 996 | u16 revision; |
| 997 | u8 validation_bits; |
| 998 | u8 flags; /* see CPER Section Descriptor, Flags field */ |
| 999 | u32 data_length; |
| 1000 | guid_t fru_id; |
| 1001 | u8 fru_text[20]; |
| 1002 | cper_timestamp_t timestamp; |
| 1003 | /* error data */ |
| 1004 | } __packed acpi_hest_generic_data_v300_t; |
| 1005 | #define HEST_GENERIC_ENTRY_V300 0x300 |
| 1006 | |
| 1007 | /* Both Generic Error Status & Generic Error Data Entry, Error Severity field */ |
| 1008 | #define ACPI_GENERROR_SEV_RECOVERABLE 0 |
| 1009 | #define ACPI_GENERROR_SEV_FATAL 1 |
| 1010 | #define ACPI_GENERROR_SEV_CORRECTED 2 |
| 1011 | #define ACPI_GENERROR_SEV_NONE 3 |
| 1012 | |
| 1013 | /* Generic Error Data Entry, Validation Bits field */ |
| 1014 | #define ACPI_GENERROR_VALID_FRUID BIT(0) |
| 1015 | #define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1) |
| 1016 | #define ACPI_GENERROR_VALID_TIMESTAMP BIT(2) |
| 1017 | |
Felix Held | 403fa86 | 2021-07-26 22:43:00 +0200 | [diff] [blame] | 1018 | /* |
| 1019 | * Generic Error Status Block |
| 1020 | * |
| 1021 | * If there is a raw data section at the end of the generic error status block after the |
| 1022 | * zero or more generic error data entries, raw_data_length indicates the length of the raw |
| 1023 | * section and raw_data_offset is the offset of the beginning of the raw data section from |
| 1024 | * the start of the acpi_generic_error_status block it is contained in. So if raw_data_length |
| 1025 | * is non-zero, raw_data_offset must be at least sizeof(acpi_generic_error_status_t). |
| 1026 | */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1027 | typedef struct acpi_generic_error_status { |
| 1028 | u32 block_status; |
| 1029 | u32 raw_data_offset; /* must follow any generic entries */ |
| 1030 | u32 raw_data_length; |
| 1031 | u32 data_length; /* generic data */ |
| 1032 | u32 error_severity; |
| 1033 | /* Generic Error Data structures, zero or more entries */ |
| 1034 | } __packed acpi_generic_error_status_t; |
| 1035 | |
| 1036 | /* Generic Status Block, Block Status values */ |
| 1037 | #define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0) |
| 1038 | #define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1) |
| 1039 | #define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2) |
| 1040 | #define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3) |
| 1041 | #define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4 |
| 1042 | #define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff |
| 1043 | #define GENERIC_ERR_STS_ENTRY_COUNT_MASK \ |
| 1044 | (GENERIC_ERR_STS_ENTRY_COUNT_MAX \ |
| 1045 | << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT) |
| 1046 | |
| 1047 | typedef struct acpi_cstate { |
| 1048 | u8 ctype; |
| 1049 | u16 latency; |
| 1050 | u32 power; |
| 1051 | acpi_addr_t resource; |
| 1052 | } __packed acpi_cstate_t; |
| 1053 | |
Jason Glenesk | ca36aed | 2020-09-15 21:01:57 -0700 | [diff] [blame] | 1054 | struct acpi_sw_pstate { |
| 1055 | u32 core_freq; |
| 1056 | u32 power; |
| 1057 | u32 transition_latency; |
| 1058 | u32 bus_master_latency; |
| 1059 | u32 control_value; |
| 1060 | u32 status_value; |
| 1061 | } __packed; |
| 1062 | |
| 1063 | struct acpi_xpss_sw_pstate { |
| 1064 | u64 core_freq; |
| 1065 | u64 power; |
| 1066 | u64 transition_latency; |
| 1067 | u64 bus_master_latency; |
| 1068 | u64 control_value; |
| 1069 | u64 status_value; |
| 1070 | u64 control_mask; |
| 1071 | u64 status_mask; |
| 1072 | } __packed; |
| 1073 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1074 | typedef struct acpi_tstate { |
| 1075 | u32 percent; |
| 1076 | u32 power; |
| 1077 | u32 latency; |
| 1078 | u32 control; |
| 1079 | u32 status; |
| 1080 | } __packed acpi_tstate_t; |
| 1081 | |
Raul E Rangel | c704832 | 2021-04-19 15:58:25 -0600 | [diff] [blame] | 1082 | enum acpi_lpi_state_flags { |
| 1083 | ACPI_LPI_STATE_DISABLED = 0, |
| 1084 | ACPI_LPI_STATE_ENABLED |
| 1085 | }; |
| 1086 | |
| 1087 | /* Low Power Idle State */ |
| 1088 | struct acpi_lpi_state { |
| 1089 | u32 min_residency_us; |
| 1090 | u32 worst_case_wakeup_latency_us; |
| 1091 | u32 flags; |
| 1092 | u32 arch_context_lost_flags; |
| 1093 | u32 residency_counter_frequency_hz; |
| 1094 | u32 enabled_parent_state; |
| 1095 | acpi_addr_t entry_method; |
| 1096 | acpi_addr_t residency_counter_register; |
| 1097 | acpi_addr_t usage_counter_register; |
| 1098 | const char *state_name; |
| 1099 | }; |
| 1100 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1101 | /* Port types for ACPI _UPC object */ |
| 1102 | enum acpi_upc_type { |
| 1103 | UPC_TYPE_A, |
| 1104 | UPC_TYPE_MINI_AB, |
| 1105 | UPC_TYPE_EXPRESSCARD, |
| 1106 | UPC_TYPE_USB3_A, |
| 1107 | UPC_TYPE_USB3_B, |
| 1108 | UPC_TYPE_USB3_MICRO_B, |
| 1109 | UPC_TYPE_USB3_MICRO_AB, |
| 1110 | UPC_TYPE_USB3_POWER_B, |
| 1111 | UPC_TYPE_C_USB2_ONLY, |
| 1112 | UPC_TYPE_C_USB2_SS_SWITCH, |
| 1113 | UPC_TYPE_C_USB2_SS, |
| 1114 | UPC_TYPE_PROPRIETARY = 0xff, |
| 1115 | /* |
| 1116 | * The following types are not directly defined in the ACPI |
| 1117 | * spec but are used by coreboot to identify a USB device type. |
| 1118 | */ |
| 1119 | UPC_TYPE_INTERNAL = 0xff, |
| 1120 | UPC_TYPE_UNUSED, |
| 1121 | UPC_TYPE_HUB |
| 1122 | }; |
| 1123 | |
| 1124 | enum acpi_ipmi_interface_type { |
| 1125 | IPMI_INTERFACE_RESERVED = 0, |
| 1126 | IPMI_INTERFACE_KCS, |
| 1127 | IPMI_INTERFACE_SMIC, |
| 1128 | IPMI_INTERFACE_BT, |
| 1129 | IPMI_INTERFACE_SSIF, |
| 1130 | }; |
| 1131 | |
| 1132 | #define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0) |
| 1133 | #define ACPI_IPMI_INT_TYPE_SCI (1 << 0) |
| 1134 | #define ACPI_IPMI_INT_TYPE_APIC (1 << 1) |
| 1135 | |
| 1136 | /* ACPI IPMI 2.0 */ |
| 1137 | struct acpi_spmi { |
| 1138 | acpi_header_t header; |
| 1139 | u8 interface_type; |
| 1140 | u8 reserved; |
| 1141 | u16 specification_revision; |
| 1142 | u8 interrupt_type; |
| 1143 | u8 gpe; |
| 1144 | u8 reserved2; |
| 1145 | u8 pci_device_flag; |
| 1146 | |
| 1147 | u32 global_system_interrupt; |
| 1148 | acpi_addr_t base_address; |
| 1149 | union { |
| 1150 | struct { |
| 1151 | u8 pci_segment_group; |
| 1152 | u8 pci_bus; |
| 1153 | u8 pci_device; |
| 1154 | u8 pci_function; |
| 1155 | }; |
| 1156 | u8 uid[4]; |
| 1157 | }; |
| 1158 | u8 reserved3; |
| 1159 | } __packed; |
| 1160 | |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1161 | /* EINJ APEI Standard Definitions */ |
| 1162 | /* EINJ Error Types |
| 1163 | Refer to the ACPI spec, EINJ section, for more info on bit definitions |
| 1164 | */ |
| 1165 | #define ACPI_EINJ_CPU_CE (1 << 0) |
| 1166 | #define ACPI_EINJ_CPU_UCE (1 << 1) |
| 1167 | #define ACPI_EINJ_CPU_UCE_FATAL (1 << 2) |
| 1168 | #define ACPI_EINJ_MEM_CE (1 << 3) |
| 1169 | #define ACPI_EINJ_MEM_UCE (1 << 4) |
| 1170 | #define ACPI_EINJ_MEM_UCE_FATAL (1 << 5) |
| 1171 | #define ACPI_EINJ_PCIE_CE (1 << 6) |
| 1172 | #define ACPI_EINJ_PCIE_UCE_NON_FATAL (1 << 7) |
| 1173 | #define ACPI_EINJ_PCIE_UCE_FATAL (1 << 8) |
| 1174 | #define ACPI_EINJ_PLATFORM_CE (1 << 9) |
| 1175 | #define ACPI_EINJ_PLATFORM_UCE (1 << 10) |
| 1176 | #define ACPI_EINJ_PLATFORM_UCE_FATAL (1 << 11) |
| 1177 | #define ACPI_EINJ_VENDOR_DEFINED (1 << 31) |
| 1178 | #define ACPI_EINJ_DEFAULT_CAP (ACPI_EINJ_MEM_CE | ACPI_EINJ_MEM_UCE | \ |
| 1179 | ACPI_EINJ_PCIE_CE | ACPI_EINJ_PCIE_UCE_FATAL) |
| 1180 | |
| 1181 | /* EINJ actions */ |
| 1182 | #define ACTION_COUNT 9 |
| 1183 | #define BEGIN_INJECT_OP 0x00 |
| 1184 | #define GET_TRIGGER_ACTION_TABLE 0x01 |
| 1185 | #define SET_ERROR_TYPE 0x02 |
| 1186 | #define GET_ERROR_TYPE 0x03 |
| 1187 | #define END_INJECT_OP 0x04 |
| 1188 | #define EXECUTE_INJECT_OP 0x05 |
| 1189 | #define CHECK_BUSY_STATUS 0x06 |
| 1190 | #define GET_CMD_STATUS 0x07 |
| 1191 | #define SET_ERROR_TYPE_WITH_ADDRESS 0x08 |
| 1192 | #define TRIGGER_ERROR 0xFF |
| 1193 | |
| 1194 | /* EINJ Instructions */ |
| 1195 | #define READ_REGISTER 0x00 |
| 1196 | #define READ_REGISTER_VALUE 0x01 |
| 1197 | #define WRITE_REGISTER 0x02 |
| 1198 | #define WRITE_REGISTER_VALUE 0x03 |
| 1199 | #define NO_OP 0x04 |
| 1200 | |
| 1201 | /* EINJ (Error Injection Table) */ |
| 1202 | typedef struct acpi_gen_regaddr1 { |
| 1203 | u8 space_id; /* Address space ID */ |
| 1204 | u8 bit_width; /* Register size in bits */ |
| 1205 | u8 bit_offset; /* Register bit offset */ |
| 1206 | u8 access_size; /* Access size since ACPI 2.0c */ |
| 1207 | u64 addr; /* Register address */ |
| 1208 | } __packed acpi_addr64_t; |
| 1209 | |
| 1210 | /* Instruction entry */ |
| 1211 | typedef struct acpi_einj_action_table { |
| 1212 | u8 action; |
| 1213 | u8 instruction; |
| 1214 | u16 flags; |
| 1215 | acpi_addr64_t reg; |
| 1216 | u64 value; |
| 1217 | u64 mask; |
| 1218 | } __packed acpi_einj_action_table_t; |
| 1219 | |
| 1220 | typedef struct acpi_injection_header { |
| 1221 | u32 einj_header_size; |
| 1222 | u32 flags; |
| 1223 | u32 entry_count; |
| 1224 | } __packed acpi_injection_header_t; |
| 1225 | |
| 1226 | typedef struct acpi_einj_trigger_table { |
| 1227 | u32 header_size; |
| 1228 | u32 revision; |
| 1229 | u32 table_size; |
| 1230 | u32 entry_count; |
| 1231 | acpi_einj_action_table_t trigger_action[1]; |
| 1232 | } __packed acpi_einj_trigger_table_t; |
| 1233 | |
| 1234 | typedef struct set_error_type { |
| 1235 | u32 errtype; |
| 1236 | u32 vendorerrortype; |
| 1237 | u32 flags; |
| 1238 | u32 apicid; |
| 1239 | u64 memaddr; |
| 1240 | u64 memrange; |
| 1241 | u32 pciesbdf; |
| 1242 | } __packed set_error_type_t; |
| 1243 | |
| 1244 | #define EINJ_PARAM_NUM 6 |
| 1245 | typedef struct acpi_einj_smi { |
| 1246 | u64 op_state; |
| 1247 | u64 err_inject[EINJ_PARAM_NUM]; |
| 1248 | u64 trigger_action_table; |
| 1249 | u64 err_inj_cap; |
| 1250 | u64 op_status; |
| 1251 | u64 cmd_sts; |
| 1252 | u64 einj_addr; |
| 1253 | u64 einj_addr_msk; |
| 1254 | set_error_type_t setaddrtable; |
| 1255 | u64 reserved[50]; |
| 1256 | } __packed acpi_einj_smi_t; |
| 1257 | |
| 1258 | /* EINJ Flags */ |
| 1259 | #define EINJ_DEF_TRIGGER_PORT 0xb2 |
| 1260 | #define FLAG_PRESERVE 0x01 |
| 1261 | #define FLAG_IGNORE 0x00 |
| 1262 | |
| 1263 | /* EINJ Registers */ |
| 1264 | #define EINJ_REG_MEMORY(address) \ |
| 1265 | { \ |
| 1266 | .space_id = ACPI_ADDRESS_SPACE_MEMORY, \ |
| 1267 | .bit_width = 64, \ |
| 1268 | .bit_offset = 0, \ |
| 1269 | .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \ |
| 1270 | .addr = address} |
| 1271 | |
| 1272 | #define EINJ_REG_IO() \ |
| 1273 | { \ |
| 1274 | .space_id = ACPI_ADDRESS_SPACE_IO, \ |
| 1275 | .bit_width = 0x10, \ |
| 1276 | .bit_offset = 0, \ |
| 1277 | .access_size = ACPI_ACCESS_SIZE_WORD_ACCESS, \ |
| 1278 | .addr = EINJ_DEF_TRIGGER_PORT} /* HW dependent code can override this also */ |
| 1279 | |
| 1280 | typedef struct acpi_einj { |
| 1281 | acpi_header_t header; |
| 1282 | acpi_injection_header_t inj_header; |
| 1283 | acpi_einj_action_table_t action_table[ACTION_COUNT]; |
| 1284 | } __packed acpi_einj_t; |
| 1285 | |
| 1286 | |
Arthur Heymans | 2e7e2d9 | 2022-03-03 22:28:27 +0100 | [diff] [blame] | 1287 | uintptr_t get_coreboot_rsdp(void); |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1288 | void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions); |
| 1289 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1290 | unsigned long fw_cfg_acpi_tables(unsigned long start); |
| 1291 | |
| 1292 | /* These are implemented by the target port or north/southbridge. */ |
Raul E Rangel | 6b446b9 | 2021-11-19 11:38:35 -0700 | [diff] [blame] | 1293 | void preload_acpi_dsdt(void); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1294 | unsigned long write_acpi_tables(unsigned long addr); |
| 1295 | unsigned long acpi_fill_madt(unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1296 | unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current); |
| 1297 | void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id); |
| 1298 | void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length); |
| 1299 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt); |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1300 | |
Tarun Tuli | c66ea98 | 2022-05-03 20:35:47 +0000 | [diff] [blame] | 1301 | void soc_lpi_get_constraints(void *unused); |
| 1302 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1303 | void acpi_fill_fadt(acpi_fadt_t *fadt); |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 1304 | void arch_fill_fadt(acpi_fadt_t *fadt); |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1305 | void soc_fill_fadt(acpi_fadt_t *fadt); |
Kyösti Mälkki | 02fd15d | 2020-06-02 03:34:43 +0300 | [diff] [blame] | 1306 | void mainboard_fill_fadt(acpi_fadt_t *fadt); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1307 | |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1308 | void acpi_fill_gnvs(void); |
Kyösti Mälkki | 3dc1792 | 2021-03-16 19:01:48 +0200 | [diff] [blame] | 1309 | void acpi_fill_cnvs(void); |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1310 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1311 | unsigned long acpi_fill_lpit(unsigned long current); |
| 1312 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1313 | /* These can be used by the target port. */ |
| 1314 | u8 acpi_checksum(u8 *table, u32 length); |
| 1315 | |
| 1316 | void acpi_add_table(acpi_rsdp_t *rsdp, void *table); |
| 1317 | |
Jonathan Zhang | 3dcafa8 | 2022-05-11 13:11:20 -0700 | [diff] [blame] | 1318 | /* Create CXL Early Discovery Table */ |
| 1319 | void acpi_create_cedt(acpi_cedt_t *cedt, |
| 1320 | unsigned long (*acpi_fill_cedt)(unsigned long current)); |
| 1321 | /* Create a CXL Host Bridge Structure for CEDT */ |
| 1322 | int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base); |
| 1323 | /* Create a CXL Fixed Memory Window Structure for CEDT */ |
| 1324 | int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size, |
| 1325 | u8 eniw, u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target); |
| 1326 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1327 | int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic); |
| 1328 | int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, |
| 1329 | u32 gsi_base); |
Kyösti Mälkki | c7da027 | 2021-06-08 11:37:08 +0300 | [diff] [blame] | 1330 | int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1331 | int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, |
| 1332 | u8 bus, u8 source, u32 gsirq, u16 flags); |
| 1333 | int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu, |
| 1334 | u16 flags, u8 lint); |
| 1335 | void acpi_create_madt(acpi_madt_t *madt); |
| 1336 | unsigned long acpi_create_madt_lapics(unsigned long current); |
Kyösti Mälkki | 66b5e1b | 2022-11-12 21:13:45 +0200 | [diff] [blame] | 1337 | unsigned long acpi_create_madt_lapics_with_nmis(unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1338 | int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic); |
| 1339 | int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu, |
| 1340 | u16 flags, u8 lint); |
| 1341 | int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic); |
| 1342 | int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, |
| 1343 | u32 flags); |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 1344 | /* |
| 1345 | * Given the Generic Initiator device's BDF, the proximity domain's ID |
| 1346 | * and flag, create Generic Initiator Affinity structure in SRAT. |
| 1347 | */ |
| 1348 | int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain, |
| 1349 | u16 seg, u8 bus, u8 dev, u8 func, u32 flags); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1350 | int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, |
| 1351 | u16 seg_nr, u8 start, u8 end); |
| 1352 | unsigned long acpi_create_srat_lapics(unsigned long current); |
| 1353 | void acpi_create_srat(acpi_srat_t *srat, |
| 1354 | unsigned long (*acpi_fill_srat)(unsigned long current)); |
| 1355 | |
| 1356 | void acpi_create_slit(acpi_slit_t *slit, |
| 1357 | unsigned long (*acpi_fill_slit)(unsigned long current)); |
| 1358 | |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 1359 | /* |
| 1360 | * Create a Memory Proximity Domain Attributes structure for HMAT, |
| 1361 | * given proximity domain for the attached initiaor, and |
| 1362 | * proximimity domain for the memory. |
| 1363 | */ |
| 1364 | int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory); |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 1365 | /* Create Heterogeneous Memory Attribute Table */ |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 1366 | void acpi_create_hmat(acpi_hmat_t *hmat, |
| 1367 | unsigned long (*acpi_fill_hmat)(unsigned long current)); |
| 1368 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1369 | void acpi_create_vfct(const struct device *device, |
| 1370 | acpi_vfct_t *vfct, |
| 1371 | unsigned long (*acpi_fill_vfct)(const struct device *device, |
| 1372 | acpi_vfct_t *vfct_struct, |
| 1373 | unsigned long current)); |
| 1374 | |
| 1375 | void acpi_create_ipmi(const struct device *device, |
| 1376 | struct acpi_spmi *spmi, |
| 1377 | const u16 ipmi_revision, |
| 1378 | const acpi_addr_t *addr, |
| 1379 | const enum acpi_ipmi_interface_type type, |
| 1380 | const s8 gpe_interrupt, |
| 1381 | const u32 apic_interrupt, |
| 1382 | const u32 uid); |
| 1383 | |
| 1384 | void acpi_create_ivrs(acpi_ivrs_t *ivrs, |
| 1385 | unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, |
| 1386 | unsigned long current)); |
| 1387 | |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 1388 | void acpi_create_crat(struct acpi_crat_header *crat, |
| 1389 | unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct, |
| 1390 | unsigned long current)); |
| 1391 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1392 | void acpi_create_hpet(acpi_hpet_t *hpet); |
| 1393 | unsigned long acpi_write_hpet(const struct device *device, unsigned long start, |
| 1394 | acpi_rsdp_t *rsdp); |
| 1395 | |
| 1396 | /* cpu/intel/speedstep/acpi.c */ |
| 1397 | void generate_cpu_entries(const struct device *device); |
| 1398 | |
| 1399 | void acpi_create_mcfg(acpi_mcfg_t *mcfg); |
| 1400 | |
| 1401 | void acpi_create_facs(acpi_facs_t *facs); |
| 1402 | |
| 1403 | void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header, |
| 1404 | int port_type, int port_subtype, |
| 1405 | acpi_addr_t *address, uint32_t address_size, |
| 1406 | const char *device_path); |
| 1407 | |
| 1408 | unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current, |
| 1409 | const struct device *dev, uint8_t access_size); |
| 1410 | void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, |
| 1411 | unsigned long (*acpi_fill_dmar)(unsigned long)); |
| 1412 | unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, |
| 1413 | u16 segment, u64 bar); |
| 1414 | unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, |
| 1415 | u64 bar, u64 limit); |
| 1416 | unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, |
| 1417 | u16 segment); |
| 1418 | unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, |
| 1419 | u32 proximity_domain); |
| 1420 | unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, |
| 1421 | const char *device_name); |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 1422 | unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags, |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 1423 | u16 segment); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1424 | void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current); |
| 1425 | void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current); |
| 1426 | void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current); |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 1427 | void acpi_dmar_satc_fixup(unsigned long base, unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1428 | unsigned long acpi_create_dmar_ds_pci_br(unsigned long current, |
| 1429 | u8 bus, u8 dev, u8 fn); |
| 1430 | unsigned long acpi_create_dmar_ds_pci(unsigned long current, |
| 1431 | u8 bus, u8 dev, u8 fn); |
| 1432 | unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, |
| 1433 | u8 enumeration_id, |
| 1434 | u8 bus, u8 dev, u8 fn); |
| 1435 | unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, |
| 1436 | u8 enumeration_id, |
| 1437 | u8 bus, u8 dev, u8 fn); |
| 1438 | void acpi_write_hest(acpi_hest_t *hest, |
| 1439 | unsigned long (*acpi_fill_hest)(acpi_hest_t *hest)); |
| 1440 | |
| 1441 | unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, |
| 1442 | acpi_hest_esd_t *esd, u16 type, void *data, u16 len); |
| 1443 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1444 | void acpi_create_lpit(acpi_lpit_t *lpit); |
| 1445 | unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid); |
| 1446 | |
Felix Held | f7dbf4a | 2021-06-07 16:56:04 +0200 | [diff] [blame] | 1447 | /* chipsets that select ACPI_BERT must implement this function */ |
Felix Held | 2940548 | 2021-05-28 16:01:57 +0200 | [diff] [blame] | 1448 | enum cb_err acpi_soc_get_bert_region(void **region, size_t *length); |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 1449 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1450 | /* For ACPI S3 support. */ |
Kyösti Mälkki | a4c0e1a | 2020-06-18 08:28:12 +0300 | [diff] [blame] | 1451 | void __noreturn acpi_resume(void *wake_vec); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1452 | void mainboard_suspend_resume(void); |
| 1453 | void *acpi_find_wakeup_vector(void); |
| 1454 | |
| 1455 | /* ACPI_Sn assignments are defined to always equal the sleep state numbers */ |
| 1456 | enum { |
| 1457 | ACPI_S0 = 0, |
| 1458 | ACPI_S1 = 1, |
| 1459 | ACPI_S2 = 2, |
| 1460 | ACPI_S3 = 3, |
| 1461 | ACPI_S4 = 4, |
| 1462 | ACPI_S5 = 5, |
| 1463 | }; |
| 1464 | |
| 1465 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \ |
| 1466 | || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 1467 | /* Given the provided PM1 control register return the ACPI sleep type. */ |
| 1468 | static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt) |
| 1469 | { |
| 1470 | switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) { |
| 1471 | case SLP_TYP_S0: return ACPI_S0; |
| 1472 | case SLP_TYP_S1: return ACPI_S1; |
| 1473 | case SLP_TYP_S3: return ACPI_S3; |
| 1474 | case SLP_TYP_S4: return ACPI_S4; |
| 1475 | case SLP_TYP_S5: return ACPI_S5; |
| 1476 | } |
| 1477 | return -1; |
| 1478 | } |
| 1479 | #endif |
| 1480 | |
Kyösti Mälkki | e0d3868 | 2020-06-07 12:01:58 +0300 | [diff] [blame] | 1481 | uint8_t acpi_get_preferred_pm_profile(void); |
| 1482 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1483 | /* Returns ACPI_Sx values. */ |
| 1484 | int acpi_get_sleep_type(void); |
| 1485 | |
| 1486 | /* Read and clear GPE status */ |
| 1487 | int acpi_get_gpe(int gpe); |
| 1488 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 1489 | /* Once we enter payload, is SMI handler installed and capable of |
| 1490 | responding to APM_CNT Advanced Power Management Control commands. */ |
| 1491 | static inline int permanent_smi_handler(void) |
| 1492 | { |
| 1493 | return CONFIG(HAVE_SMI_HANDLER); |
| 1494 | } |
| 1495 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1496 | static inline int acpi_s3_resume_allowed(void) |
| 1497 | { |
| 1498 | return CONFIG(HAVE_ACPI_RESUME); |
| 1499 | } |
| 1500 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1501 | static inline int acpi_is_wakeup_s3(void) |
| 1502 | { |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1503 | if (!acpi_s3_resume_allowed()) |
| 1504 | return 0; |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1505 | |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1506 | if (ENV_ROMSTAGE_OR_BEFORE) |
| 1507 | return (acpi_get_sleep_type() == ACPI_S3); |
| 1508 | |
Kyösti Mälkki | ac0dc4a | 2020-11-18 07:40:21 +0200 | [diff] [blame] | 1509 | return romstage_handoff_is_resume(); |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1510 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1511 | |
| 1512 | static inline uintptr_t acpi_align_current(uintptr_t current) |
| 1513 | { |
| 1514 | return ALIGN_UP(current, 16); |
| 1515 | } |
| 1516 | |
| 1517 | /* ACPI table revisions should match the revision of the ACPI spec |
| 1518 | * supported. This function keeps the table versions synced. This could |
| 1519 | * be made into a weak function if there is ever a need to override the |
| 1520 | * coreboot default ACPI spec version supported. */ |
| 1521 | int get_acpi_table_revision(enum acpi_tables table); |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 1522 | u8 get_acpi_fadt_minor_version(void); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1523 | |
Kyösti Mälkki | 94e0465 | 2020-06-01 13:26:22 +0300 | [diff] [blame] | 1524 | #endif // !defined(__ASSEMBLER__) && !defined(__ACPI__) |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1525 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 1526 | #endif /* __ACPI_ACPI_H__ */ |