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