Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
| 3 | |
| 4 | /* |
| 5 | * coreboot ACPI support - headers and defines. |
| 6 | */ |
| 7 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame^] | 8 | #ifndef __ACPI_ACPI_H__ |
| 9 | #define __ACPI_ACPI_H__ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * The type and enable fields are common in ACPI, but the |
| 13 | * values themselves are hardware implementation defined. |
| 14 | */ |
| 15 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) |
| 16 | #define SLP_EN (1 << 13) |
| 17 | #define SLP_TYP_SHIFT 10 |
| 18 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 19 | #define SLP_TYP_S0 0 |
| 20 | #define SLP_TYP_S1 1 |
| 21 | #define SLP_TYP_S3 5 |
| 22 | #define SLP_TYP_S4 6 |
| 23 | #define SLP_TYP_S5 7 |
| 24 | #elif CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 25 | #define SLP_EN (1 << 13) |
| 26 | #define SLP_TYP_SHIFT 10 |
| 27 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 28 | #define SLP_TYP_S0 0 |
| 29 | #define SLP_TYP_S1 1 |
| 30 | #define SLP_TYP_S3 3 |
| 31 | #define SLP_TYP_S4 4 |
| 32 | #define SLP_TYP_S5 5 |
| 33 | #endif |
| 34 | |
| 35 | #define ACPI_TABLE_CREATOR "COREBOOT" /* Must be exactly 8 bytes long! */ |
| 36 | #define OEM_ID "COREv4" /* Must be exactly 6 bytes long! */ |
| 37 | |
| 38 | #if !defined(__ASSEMBLER__) && !defined(__ACPI__) |
| 39 | #include <commonlib/helpers.h> |
| 40 | #include <device/device.h> |
| 41 | #include <uuid.h> |
| 42 | #include <cper.h> |
| 43 | #include <types.h> |
| 44 | |
| 45 | #define RSDP_SIG "RSD PTR " /* RSDT pointer signature */ |
| 46 | #define ASLC "CORE" /* Must be exactly 4 bytes long! */ |
| 47 | |
| 48 | /* |
| 49 | * The assigned ACPI ID for the coreboot project is 'BOOT' |
| 50 | * http://www.uefi.org/acpi_id_list |
| 51 | */ |
| 52 | #define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */ |
| 53 | |
| 54 | /* List of ACPI HID that use the coreboot ACPI ID */ |
| 55 | enum coreboot_acpi_ids { |
| 56 | COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */ |
| 57 | COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */ |
| 58 | }; |
| 59 | |
| 60 | enum acpi_tables { |
| 61 | /* Tables defined by ACPI and used by coreboot */ |
| 62 | BERT, DBG2, DMAR, DSDT, FACS, FADT, HEST, HPET, IVRS, MADT, MCFG, |
| 63 | RSDP, RSDT, SLIT, SRAT, SSDT, TCPA, TPM2, XSDT, ECDT, |
| 64 | /* Additional proprietary tables used by coreboot */ |
| 65 | VFCT, NHLT, SPMI |
| 66 | }; |
| 67 | |
| 68 | /* RSDP (Root System Description Pointer) */ |
| 69 | typedef struct acpi_rsdp { |
| 70 | char signature[8]; /* RSDP signature */ |
| 71 | u8 checksum; /* Checksum of the first 20 bytes */ |
| 72 | char oem_id[6]; /* OEM ID */ |
| 73 | u8 revision; /* RSDP revision */ |
| 74 | u32 rsdt_address; /* Physical address of RSDT (32 bits) */ |
| 75 | u32 length; /* Total RSDP length (incl. extended part) */ |
| 76 | u64 xsdt_address; /* Physical address of XSDT (64 bits) */ |
| 77 | u8 ext_checksum; /* Checksum of the whole table */ |
| 78 | u8 reserved[3]; |
| 79 | } __packed acpi_rsdp_t; |
| 80 | |
| 81 | /* GAS (Generic Address Structure) */ |
| 82 | typedef struct acpi_gen_regaddr { |
| 83 | u8 space_id; /* Address space ID */ |
| 84 | u8 bit_width; /* Register size in bits */ |
| 85 | u8 bit_offset; /* Register bit offset */ |
| 86 | u8 access_size; /* Access size since ACPI 2.0c */ |
| 87 | u32 addrl; /* Register address, low 32 bits */ |
| 88 | u32 addrh; /* Register address, high 32 bits */ |
| 89 | } __packed acpi_addr_t; |
| 90 | |
| 91 | #define ACPI_ADDRESS_SPACE_MEMORY 0 /* System memory */ |
| 92 | #define ACPI_ADDRESS_SPACE_IO 1 /* System I/O */ |
| 93 | #define ACPI_ADDRESS_SPACE_PCI 2 /* PCI config space */ |
| 94 | #define ACPI_ADDRESS_SPACE_EC 3 /* Embedded controller */ |
| 95 | #define ACPI_ADDRESS_SPACE_SMBUS 4 /* SMBus */ |
| 96 | #define ACPI_ADDRESS_SPACE_PCC 0x0A /* Platform Comm. Channel */ |
| 97 | #define ACPI_ADDRESS_SPACE_FIXED 0x7f /* Functional fixed hardware */ |
| 98 | #define ACPI_FFIXEDHW_VENDOR_INTEL 1 /* Intel */ |
| 99 | #define ACPI_FFIXEDHW_CLASS_HLT 0 /* C1 Halt */ |
| 100 | #define ACPI_FFIXEDHW_CLASS_IO_HLT 1 /* C1 I/O then Halt */ |
| 101 | #define ACPI_FFIXEDHW_CLASS_MWAIT 2 /* MWAIT Native C-state */ |
| 102 | #define ACPI_FFIXEDHW_FLAG_HW_COORD 1 /* Hardware Coordination bit */ |
| 103 | #define ACPI_FFIXEDHW_FLAG_BM_STS 2 /* BM_STS avoidance bit */ |
| 104 | /* 0x80-0xbf: Reserved */ |
| 105 | /* 0xc0-0xff: OEM defined */ |
| 106 | |
| 107 | /* Access size definitions for Generic address structure */ |
| 108 | #define ACPI_ACCESS_SIZE_UNDEFINED 0 /* Undefined (legacy reasons) */ |
| 109 | #define ACPI_ACCESS_SIZE_BYTE_ACCESS 1 |
| 110 | #define ACPI_ACCESS_SIZE_WORD_ACCESS 2 |
| 111 | #define ACPI_ACCESS_SIZE_DWORD_ACCESS 3 |
| 112 | #define ACPI_ACCESS_SIZE_QWORD_ACCESS 4 |
| 113 | |
| 114 | /* Common ACPI HIDs */ |
| 115 | #define ACPI_HID_FDC "PNP0700" |
| 116 | #define ACPI_HID_KEYBOARD "PNP0303" |
| 117 | #define ACPI_HID_MOUSE "PNP0F03" |
| 118 | #define ACPI_HID_COM "PNP0501" |
| 119 | #define ACPI_HID_LPT "PNP0400" |
| 120 | #define ACPI_HID_PNP "PNP0C02" |
| 121 | #define ACPI_HID_CONTAINER "PNP0A05" |
| 122 | |
| 123 | /* Generic ACPI header, provided by (almost) all tables */ |
| 124 | typedef struct acpi_table_header { |
| 125 | char signature[4]; /* ACPI signature (4 ASCII characters) */ |
| 126 | u32 length; /* Table length in bytes (incl. header) */ |
| 127 | u8 revision; /* Table version (not ACPI version!) */ |
| 128 | u8 checksum; /* To make sum of entire table == 0 */ |
| 129 | char oem_id[6]; /* OEM identification */ |
| 130 | char oem_table_id[8]; /* OEM table identification */ |
| 131 | u32 oem_revision; /* OEM revision number */ |
| 132 | char asl_compiler_id[4]; /* ASL compiler vendor ID */ |
| 133 | u32 asl_compiler_revision; /* ASL compiler revision number */ |
| 134 | } __packed acpi_header_t; |
| 135 | |
| 136 | /* A maximum number of 32 ACPI tables ought to be enough for now. */ |
| 137 | #define MAX_ACPI_TABLES 32 |
| 138 | |
| 139 | /* RSDT (Root System Description Table) */ |
| 140 | typedef struct acpi_rsdt { |
| 141 | acpi_header_t header; |
| 142 | u32 entry[MAX_ACPI_TABLES]; |
| 143 | } __packed acpi_rsdt_t; |
| 144 | |
| 145 | /* XSDT (Extended System Description Table) */ |
| 146 | typedef struct acpi_xsdt { |
| 147 | acpi_header_t header; |
| 148 | u64 entry[MAX_ACPI_TABLES]; |
| 149 | } __packed acpi_xsdt_t; |
| 150 | |
| 151 | /* HPET timers */ |
| 152 | typedef struct acpi_hpet { |
| 153 | acpi_header_t header; |
| 154 | u32 id; |
| 155 | acpi_addr_t addr; |
| 156 | u8 number; |
| 157 | u16 min_tick; |
| 158 | u8 attributes; |
| 159 | } __packed acpi_hpet_t; |
| 160 | |
| 161 | /* MCFG (PCI Express MMIO config space BAR description table) */ |
| 162 | typedef struct acpi_mcfg { |
| 163 | acpi_header_t header; |
| 164 | u8 reserved[8]; |
| 165 | } __packed acpi_mcfg_t; |
| 166 | |
| 167 | typedef struct acpi_tcpa { |
| 168 | acpi_header_t header; |
| 169 | u16 platform_class; |
| 170 | u32 laml; |
| 171 | u64 lasa; |
| 172 | } __packed acpi_tcpa_t; |
| 173 | |
| 174 | typedef struct acpi_tpm2 { |
| 175 | acpi_header_t header; |
| 176 | u16 platform_class; |
| 177 | u8 reserved[2]; |
| 178 | u64 control_area; |
| 179 | u32 start_method; |
| 180 | u8 msp[12]; |
| 181 | u32 laml; |
| 182 | u64 lasa; |
| 183 | } __packed acpi_tpm2_t; |
| 184 | |
| 185 | typedef struct acpi_mcfg_mmconfig { |
| 186 | u32 base_address; |
| 187 | u32 base_reserved; |
| 188 | u16 pci_segment_group_number; |
| 189 | u8 start_bus_number; |
| 190 | u8 end_bus_number; |
| 191 | u8 reserved[4]; |
| 192 | } __packed acpi_mcfg_mmconfig_t; |
| 193 | |
| 194 | /* SRAT (System Resource Affinity Table) */ |
| 195 | typedef struct acpi_srat { |
| 196 | acpi_header_t header; |
| 197 | u32 resv; |
| 198 | u64 resv1; |
| 199 | /* Followed by static resource allocation structure[n] */ |
| 200 | } __packed acpi_srat_t; |
| 201 | |
| 202 | /* SRAT: Processor Local APIC/SAPIC Affinity Structure */ |
| 203 | typedef struct acpi_srat_lapic { |
| 204 | u8 type; /* Type (0) */ |
| 205 | u8 length; /* Length in bytes (16) */ |
| 206 | u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */ |
| 207 | u8 apic_id; /* Local APIC ID */ |
| 208 | u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */ |
| 209 | u8 local_sapic_eid; /* Local SAPIC EID */ |
| 210 | u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */ |
| 211 | u32 clock_domain; /* _CDM Clock Domain */ |
| 212 | } __packed acpi_srat_lapic_t; |
| 213 | |
| 214 | /* SRAT: Memory Affinity Structure */ |
| 215 | typedef struct acpi_srat_mem { |
| 216 | u8 type; /* Type (1) */ |
| 217 | u8 length; /* Length in bytes (40) */ |
| 218 | u32 proximity_domain; /* Proximity domain */ |
| 219 | u16 resv; |
| 220 | u32 base_address_low; /* Mem range base address, low */ |
| 221 | u32 base_address_high; /* Mem range base address, high */ |
| 222 | u32 length_low; /* Mem range length, low */ |
| 223 | u32 length_high; /* Mem range length, high */ |
| 224 | u32 resv1; |
| 225 | u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2, |
| 226 | * other bits reserved to 0 |
| 227 | */ |
| 228 | u32 resv2[2]; |
| 229 | } __packed acpi_srat_mem_t; |
| 230 | |
| 231 | /* SLIT (System Locality Distance Information Table) */ |
| 232 | typedef struct acpi_slit { |
| 233 | acpi_header_t header; |
| 234 | /* Followed by static resource allocation 8+byte[num*num] */ |
| 235 | } __packed acpi_slit_t; |
| 236 | |
| 237 | /* MADT (Multiple APIC Description Table) */ |
| 238 | typedef struct acpi_madt { |
| 239 | acpi_header_t header; |
| 240 | u32 lapic_addr; /* Local APIC address */ |
| 241 | u32 flags; /* Multiple APIC flags */ |
| 242 | } __packed acpi_madt_t; |
| 243 | |
| 244 | /* VFCT image header */ |
| 245 | typedef struct acpi_vfct_image_hdr { |
| 246 | u32 PCIBus; |
| 247 | u32 PCIDevice; |
| 248 | u32 PCIFunction; |
| 249 | u16 VendorID; |
| 250 | u16 DeviceID; |
| 251 | u16 SSVID; |
| 252 | u16 SSID; |
| 253 | u32 Revision; |
| 254 | u32 ImageLength; |
| 255 | u8 VbiosContent; // dummy - copy VBIOS here |
| 256 | } __packed acpi_vfct_image_hdr_t; |
| 257 | |
| 258 | /* VFCT (VBIOS Fetch Table) */ |
| 259 | typedef struct acpi_vfct { |
| 260 | acpi_header_t header; |
| 261 | u8 TableUUID[16]; |
| 262 | u32 VBIOSImageOffset; |
| 263 | u32 Lib1ImageOffset; |
| 264 | u32 Reserved[4]; |
| 265 | acpi_vfct_image_hdr_t image_hdr; |
| 266 | } __packed acpi_vfct_t; |
| 267 | |
| 268 | typedef struct acpi_ivrs_info { |
| 269 | } __packed acpi_ivrs_info_t; |
| 270 | |
| 271 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */ |
| 272 | typedef struct acpi_ivrs_ivhd { |
| 273 | uint8_t type; |
| 274 | uint8_t flags; |
| 275 | uint16_t length; |
| 276 | uint16_t device_id; |
| 277 | uint16_t capability_offset; |
| 278 | uint32_t iommu_base_low; |
| 279 | uint32_t iommu_base_high; |
| 280 | uint16_t pci_segment_group; |
| 281 | uint16_t iommu_info; |
| 282 | uint32_t iommu_feature_info; |
| 283 | uint8_t entry[0]; |
| 284 | } __packed acpi_ivrs_ivhd_t; |
| 285 | |
| 286 | /* IVRS (I/O Virtualization Reporting Structure) Type 10h */ |
| 287 | typedef struct acpi_ivrs { |
| 288 | acpi_header_t header; |
| 289 | uint32_t iv_info; |
| 290 | uint32_t reserved[2]; |
| 291 | struct acpi_ivrs_ivhd ivhd; |
| 292 | } __packed acpi_ivrs_t; |
| 293 | |
| 294 | /* IVHD Type 11h IOMMU Attributes */ |
| 295 | typedef struct ivhd11_iommu_attr { |
| 296 | uint32_t reserved1 : 13; |
| 297 | uint32_t perf_counters : 4; |
| 298 | uint32_t perf_counter_banks : 6; |
| 299 | uint32_t msi_num_ppr : 5; |
| 300 | uint32_t reserved2 : 4; |
| 301 | } __packed ivhd11_iommu_attr_t; |
| 302 | |
| 303 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 11h */ |
| 304 | typedef struct acpi_ivrs_ivhd_11 { |
| 305 | uint8_t type; |
| 306 | uint8_t flags; |
| 307 | uint16_t length; |
| 308 | uint16_t device_id; |
| 309 | uint16_t capability_offset; |
| 310 | uint32_t iommu_base_low; |
| 311 | uint32_t iommu_base_high; |
| 312 | uint16_t pci_segment_group; |
| 313 | uint16_t iommu_info; |
| 314 | struct ivhd11_iommu_attr iommu_attributes; |
| 315 | uint32_t efr_reg_image_low; |
| 316 | uint32_t efr_reg_image_high; |
| 317 | uint32_t reserved[2]; |
| 318 | uint8_t entry[0]; |
| 319 | } __packed acpi_ivrs_ivhd11_t; |
| 320 | |
| 321 | enum dev_scope_type { |
| 322 | SCOPE_PCI_ENDPOINT = 1, |
| 323 | SCOPE_PCI_SUB = 2, |
| 324 | SCOPE_IOAPIC = 3, |
| 325 | SCOPE_MSI_HPET = 4, |
| 326 | SCOPE_ACPI_NAMESPACE_DEVICE = 5 |
| 327 | }; |
| 328 | |
| 329 | typedef struct dev_scope { |
| 330 | u8 type; |
| 331 | u8 length; |
| 332 | u8 reserved[2]; |
| 333 | u8 enumeration; |
| 334 | u8 start_bus; |
| 335 | struct { |
| 336 | u8 dev; |
| 337 | u8 fn; |
| 338 | } __packed path[0]; |
| 339 | } __packed dev_scope_t; |
| 340 | |
| 341 | enum dmar_type { |
| 342 | DMAR_DRHD = 0, |
| 343 | DMAR_RMRR = 1, |
| 344 | DMAR_ATSR = 2, |
| 345 | DMAR_RHSA = 3, |
| 346 | DMAR_ANDD = 4 |
| 347 | }; |
| 348 | |
| 349 | enum { |
| 350 | DRHD_INCLUDE_PCI_ALL = 1 |
| 351 | }; |
| 352 | |
| 353 | enum dmar_flags { |
| 354 | DMAR_INTR_REMAP = 1 << 0, |
| 355 | DMAR_X2APIC_OPT_OUT = 1 << 1, |
| 356 | DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2, |
| 357 | }; |
| 358 | |
| 359 | typedef struct dmar_entry { |
| 360 | u16 type; |
| 361 | u16 length; |
| 362 | u8 flags; |
| 363 | u8 reserved; |
| 364 | u16 segment; |
| 365 | u64 bar; |
| 366 | } __packed dmar_entry_t; |
| 367 | |
| 368 | typedef struct dmar_rmrr_entry { |
| 369 | u16 type; |
| 370 | u16 length; |
| 371 | u16 reserved; |
| 372 | u16 segment; |
| 373 | u64 bar; |
| 374 | u64 limit; |
| 375 | } __packed dmar_rmrr_entry_t; |
| 376 | |
| 377 | typedef struct dmar_atsr_entry { |
| 378 | u16 type; |
| 379 | u16 length; |
| 380 | u8 flags; |
| 381 | u8 reserved; |
| 382 | u16 segment; |
| 383 | } __packed dmar_atsr_entry_t; |
| 384 | |
| 385 | typedef struct dmar_rhsa_entry { |
| 386 | u16 type; |
| 387 | u16 length; |
| 388 | u32 reserved; |
| 389 | u64 base_address; |
| 390 | u32 proximity_domain; |
| 391 | } __packed dmar_rhsa_entry_t; |
| 392 | |
| 393 | typedef struct dmar_andd_entry { |
| 394 | u16 type; |
| 395 | u16 length; |
| 396 | u8 reserved[3]; |
| 397 | u8 device_number; |
| 398 | u8 device_name[]; |
| 399 | } __packed dmar_andd_entry_t; |
| 400 | |
| 401 | /* DMAR (DMA Remapping Reporting Structure) */ |
| 402 | typedef struct acpi_dmar { |
| 403 | acpi_header_t header; |
| 404 | u8 host_address_width; |
| 405 | u8 flags; |
| 406 | u8 reserved[10]; |
| 407 | dmar_entry_t structure[0]; |
| 408 | } __packed acpi_dmar_t; |
| 409 | |
| 410 | /* MADT: APIC Structure Types */ |
| 411 | enum acpi_apic_types { |
| 412 | LOCAL_APIC, /* Processor local APIC */ |
| 413 | IO_APIC, /* I/O APIC */ |
| 414 | IRQ_SOURCE_OVERRIDE, /* Interrupt source override */ |
| 415 | NMI_TYPE, /* NMI source */ |
| 416 | LOCAL_APIC_NMI, /* Local APIC NMI */ |
| 417 | LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */ |
| 418 | IO_SAPIC, /* I/O SAPIC */ |
| 419 | LOCAL_SAPIC, /* Local SAPIC */ |
| 420 | PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */ |
| 421 | LOCAL_X2APIC, /* Processor local x2APIC */ |
| 422 | LOCAL_X2APIC_NMI, /* Local x2APIC NMI */ |
| 423 | GICC, /* GIC CPU Interface */ |
| 424 | GICD, /* GIC Distributor */ |
| 425 | GIC_MSI_FRAME, /* GIC MSI Frame */ |
| 426 | GICR, /* GIC Redistributor */ |
| 427 | GIC_ITS, /* Interrupt Translation Service */ |
| 428 | /* 0x10-0x7f: Reserved */ |
| 429 | /* 0x80-0xff: Reserved for OEM use */ |
| 430 | }; |
| 431 | |
| 432 | /* MADT: Processor Local APIC Structure */ |
| 433 | typedef struct acpi_madt_lapic { |
| 434 | u8 type; /* Type (0) */ |
| 435 | u8 length; /* Length in bytes (8) */ |
| 436 | u8 processor_id; /* ACPI processor ID */ |
| 437 | u8 apic_id; /* Local APIC ID */ |
| 438 | u32 flags; /* Local APIC flags */ |
| 439 | } __packed acpi_madt_lapic_t; |
| 440 | |
| 441 | /* MADT: Local APIC NMI Structure */ |
| 442 | typedef struct acpi_madt_lapic_nmi { |
| 443 | u8 type; /* Type (4) */ |
| 444 | u8 length; /* Length in bytes (6) */ |
| 445 | u8 processor_id; /* ACPI processor ID */ |
| 446 | u16 flags; /* MPS INTI flags */ |
| 447 | u8 lint; /* Local APIC LINT# */ |
| 448 | } __packed acpi_madt_lapic_nmi_t; |
| 449 | |
| 450 | /* MADT: I/O APIC Structure */ |
| 451 | typedef struct acpi_madt_ioapic { |
| 452 | u8 type; /* Type (1) */ |
| 453 | u8 length; /* Length in bytes (12) */ |
| 454 | u8 ioapic_id; /* I/O APIC ID */ |
| 455 | u8 reserved; |
| 456 | u32 ioapic_addr; /* I/O APIC address */ |
| 457 | u32 gsi_base; /* Global system interrupt base */ |
| 458 | } __packed acpi_madt_ioapic_t; |
| 459 | |
| 460 | /* MADT: Interrupt Source Override Structure */ |
| 461 | typedef struct acpi_madt_irqoverride { |
| 462 | u8 type; /* Type (2) */ |
| 463 | u8 length; /* Length in bytes (10) */ |
| 464 | u8 bus; /* ISA (0) */ |
| 465 | u8 source; /* Bus-relative int. source (IRQ) */ |
| 466 | u32 gsirq; /* Global system interrupt */ |
| 467 | u16 flags; /* MPS INTI flags */ |
| 468 | } __packed acpi_madt_irqoverride_t; |
| 469 | |
| 470 | /* MADT: Processor Local x2APIC Structure */ |
| 471 | typedef struct acpi_madt_lx2apic { |
| 472 | u8 type; /* Type (9) */ |
| 473 | u8 length; /* Length in bytes (16) */ |
| 474 | u16 reserved; |
| 475 | u32 x2apic_id; /* Local x2APIC ID */ |
| 476 | u32 flags; /* Same as Local APIC flags */ |
| 477 | u32 processor_id; /* ACPI processor ID */ |
| 478 | } __packed acpi_madt_lx2apic_t; |
| 479 | |
| 480 | /* MADT: Processor Local x2APIC NMI Structure */ |
| 481 | typedef struct acpi_madt_lx2apic_nmi { |
| 482 | u8 type; /* Type (10) */ |
| 483 | u8 length; /* Length in bytes (12) */ |
| 484 | u16 flags; /* Same as MPS INTI flags */ |
| 485 | u32 processor_id; /* ACPI processor ID */ |
| 486 | u8 lint; /* Local APIC LINT# */ |
| 487 | u8 reserved[3]; |
| 488 | } __packed acpi_madt_lx2apic_nmi_t; |
| 489 | |
| 490 | #define ACPI_DBG2_PORT_SERIAL 0x8000 |
| 491 | #define ACPI_DBG2_PORT_SERIAL_16550 0x0000 |
| 492 | #define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001 |
| 493 | #define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003 |
| 494 | #define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e |
| 495 | #define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f |
| 496 | #define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010 |
| 497 | #define ACPI_DBG2_PORT_IEEE1394 0x8001 |
| 498 | #define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000 |
| 499 | #define ACPI_DBG2_PORT_USB 0x8002 |
| 500 | #define ACPI_DBG2_PORT_USB_XHCI 0x0000 |
| 501 | #define ACPI_DBG2_PORT_USB_EHCI 0x0001 |
| 502 | #define ACPI_DBG2_PORT_NET 0x8003 |
| 503 | |
| 504 | /* DBG2: Microsoft Debug Port Table 2 header */ |
| 505 | typedef struct acpi_dbg2_header { |
| 506 | acpi_header_t header; |
| 507 | uint32_t devices_offset; |
| 508 | uint32_t devices_count; |
| 509 | } __attribute__((packed)) acpi_dbg2_header_t; |
| 510 | |
| 511 | /* DBG2: Microsoft Debug Port Table 2 device entry */ |
| 512 | typedef struct acpi_dbg2_device { |
| 513 | uint8_t revision; |
| 514 | uint16_t length; |
| 515 | uint8_t address_count; |
| 516 | uint16_t namespace_string_length; |
| 517 | uint16_t namespace_string_offset; |
| 518 | uint16_t oem_data_length; |
| 519 | uint16_t oem_data_offset; |
| 520 | uint16_t port_type; |
| 521 | uint16_t port_subtype; |
| 522 | uint8_t reserved[2]; |
| 523 | uint16_t base_address_offset; |
| 524 | uint16_t address_size_offset; |
| 525 | } __attribute__((packed)) acpi_dbg2_device_t; |
| 526 | |
| 527 | /* FADT (Fixed ACPI Description Table) */ |
| 528 | typedef struct acpi_fadt { |
| 529 | acpi_header_t header; |
| 530 | u32 firmware_ctrl; |
| 531 | u32 dsdt; |
| 532 | u8 reserved; /* Should be 0 */ |
| 533 | u8 preferred_pm_profile; |
| 534 | u16 sci_int; |
| 535 | u32 smi_cmd; |
| 536 | u8 acpi_enable; |
| 537 | u8 acpi_disable; |
| 538 | u8 s4bios_req; |
| 539 | u8 pstate_cnt; |
| 540 | u32 pm1a_evt_blk; |
| 541 | u32 pm1b_evt_blk; |
| 542 | u32 pm1a_cnt_blk; |
| 543 | u32 pm1b_cnt_blk; |
| 544 | u32 pm2_cnt_blk; |
| 545 | u32 pm_tmr_blk; |
| 546 | u32 gpe0_blk; |
| 547 | u32 gpe1_blk; |
| 548 | u8 pm1_evt_len; |
| 549 | u8 pm1_cnt_len; |
| 550 | u8 pm2_cnt_len; |
| 551 | u8 pm_tmr_len; |
| 552 | u8 gpe0_blk_len; |
| 553 | u8 gpe1_blk_len; |
| 554 | u8 gpe1_base; |
| 555 | u8 cst_cnt; |
| 556 | u16 p_lvl2_lat; |
| 557 | u16 p_lvl3_lat; |
| 558 | u16 flush_size; |
| 559 | u16 flush_stride; |
| 560 | u8 duty_offset; |
| 561 | u8 duty_width; |
| 562 | u8 day_alrm; |
| 563 | u8 mon_alrm; |
| 564 | u8 century; |
| 565 | u16 iapc_boot_arch; |
| 566 | u8 res2; |
| 567 | u32 flags; |
| 568 | acpi_addr_t reset_reg; |
| 569 | u8 reset_value; |
| 570 | u16 ARM_boot_arch; /* Revision 6 only, Revision 5: Must be zero */ |
| 571 | u8 FADT_MinorVersion; /* Revision 6 only, Revision 5: Must be zero */ |
| 572 | u32 x_firmware_ctl_l; |
| 573 | u32 x_firmware_ctl_h; |
| 574 | u32 x_dsdt_l; |
| 575 | u32 x_dsdt_h; |
| 576 | acpi_addr_t x_pm1a_evt_blk; |
| 577 | acpi_addr_t x_pm1b_evt_blk; |
| 578 | acpi_addr_t x_pm1a_cnt_blk; |
| 579 | acpi_addr_t x_pm1b_cnt_blk; |
| 580 | acpi_addr_t x_pm2_cnt_blk; |
| 581 | acpi_addr_t x_pm_tmr_blk; |
| 582 | acpi_addr_t x_gpe0_blk; |
| 583 | acpi_addr_t x_gpe1_blk; |
| 584 | /* Revision 5 */ |
| 585 | acpi_addr_t sleep_control_reg; |
| 586 | acpi_addr_t sleep_status_reg; |
| 587 | /* Revision 6 */ |
| 588 | u64 hypervisor_vendor_identity; |
| 589 | } __packed acpi_fadt_t; |
| 590 | |
| 591 | /* FADT TABLE Revision values */ |
| 592 | #define ACPI_FADT_REV_ACPI_1_0 1 |
| 593 | #define ACPI_FADT_REV_ACPI_2_0 3 |
| 594 | #define ACPI_FADT_REV_ACPI_3_0 4 |
| 595 | #define ACPI_FADT_REV_ACPI_4_0 4 |
| 596 | #define ACPI_FADT_REV_ACPI_5_0 5 |
| 597 | #define ACPI_FADT_REV_ACPI_6_0 6 |
| 598 | |
| 599 | /* Flags for p_lvl2_lat and p_lvl3_lat */ |
| 600 | #define ACPI_FADT_C2_NOT_SUPPORTED 101 |
| 601 | #define ACPI_FADT_C3_NOT_SUPPORTED 1001 |
| 602 | |
| 603 | /* FADT Feature Flags */ |
| 604 | #define ACPI_FADT_WBINVD (1 << 0) |
| 605 | #define ACPI_FADT_WBINVD_FLUSH (1 << 1) |
| 606 | #define ACPI_FADT_C1_SUPPORTED (1 << 2) |
| 607 | #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3) |
| 608 | #define ACPI_FADT_POWER_BUTTON (1 << 4) |
| 609 | #define ACPI_FADT_SLEEP_BUTTON (1 << 5) |
| 610 | #define ACPI_FADT_FIXED_RTC (1 << 6) |
| 611 | #define ACPI_FADT_S4_RTC_WAKE (1 << 7) |
| 612 | #define ACPI_FADT_32BIT_TIMER (1 << 8) |
| 613 | #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9) |
| 614 | #define ACPI_FADT_RESET_REGISTER (1 << 10) |
| 615 | #define ACPI_FADT_SEALED_CASE (1 << 11) |
| 616 | #define ACPI_FADT_HEADLESS (1 << 12) |
| 617 | #define ACPI_FADT_SLEEP_TYPE (1 << 13) |
| 618 | #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14) |
| 619 | #define ACPI_FADT_PLATFORM_CLOCK (1 << 15) |
| 620 | #define ACPI_FADT_S4_RTC_VALID (1 << 16) |
| 621 | #define ACPI_FADT_REMOTE_POWER_ON (1 << 17) |
| 622 | #define ACPI_FADT_APIC_CLUSTER (1 << 18) |
| 623 | #define ACPI_FADT_APIC_PHYSICAL (1 << 19) |
| 624 | /* Bits 20-31: reserved ACPI 3.0 & 4.0 */ |
| 625 | #define ACPI_FADT_HW_REDUCED_ACPI (1 << 20) |
| 626 | #define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21) |
| 627 | /* bits 22-31: reserved since ACPI 5.0 */ |
| 628 | |
| 629 | /* FADT Boot Architecture Flags */ |
| 630 | #define ACPI_FADT_LEGACY_DEVICES (1 << 0) |
| 631 | #define ACPI_FADT_8042 (1 << 1) |
| 632 | #define ACPI_FADT_VGA_NOT_PRESENT (1 << 2) |
| 633 | #define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3) |
| 634 | #define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4) |
| 635 | #define ACPI_FADT_NO_CMOS_RTC (1 << 5) |
| 636 | #define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */ |
| 637 | |
| 638 | /* FADT ARM Boot Architecture Flags */ |
| 639 | #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) |
| 640 | #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) |
| 641 | /* bits 2-16: reserved since ACPI 5.1 */ |
| 642 | |
| 643 | /* FADT Preferred Power Management Profile */ |
| 644 | enum acpi_preferred_pm_profiles { |
| 645 | PM_UNSPECIFIED = 0, |
| 646 | PM_DESKTOP = 1, |
| 647 | PM_MOBILE = 2, |
| 648 | PM_WORKSTATION = 3, |
| 649 | PM_ENTERPRISE_SERVER = 4, |
| 650 | PM_SOHO_SERVER = 5, |
| 651 | PM_APPLIANCE_PC = 6, |
| 652 | PM_PERFORMANCE_SERVER = 7, |
| 653 | PM_TABLET = 8, /* ACPI 5.0 & greater */ |
| 654 | }; |
| 655 | |
| 656 | /* FACS (Firmware ACPI Control Structure) */ |
| 657 | typedef struct acpi_facs { |
| 658 | char signature[4]; /* "FACS" */ |
| 659 | u32 length; /* Length in bytes (>= 64) */ |
| 660 | u32 hardware_signature; /* Hardware signature */ |
| 661 | u32 firmware_waking_vector; /* Firmware waking vector */ |
| 662 | u32 global_lock; /* Global lock */ |
| 663 | u32 flags; /* FACS flags */ |
| 664 | u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ |
| 665 | u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ |
| 666 | u8 version; /* FACS version */ |
| 667 | u8 resv1[3]; /* This value is 0 */ |
| 668 | u32 ospm_flags; /* 64BIT_WAKE_F */ |
| 669 | u8 resv2[24]; /* This value is 0 */ |
| 670 | } __packed acpi_facs_t; |
| 671 | |
| 672 | /* FACS flags */ |
| 673 | #define ACPI_FACS_S4BIOS_F (1 << 0) |
| 674 | #define ACPI_FACS_64BIT_WAKE_F (1 << 1) |
| 675 | /* Bits 31..2: reserved */ |
| 676 | |
| 677 | /* ECDT (Embedded Controller Boot Resources Table) */ |
| 678 | typedef struct acpi_ecdt { |
| 679 | acpi_header_t header; |
| 680 | acpi_addr_t ec_control; /* EC control register */ |
| 681 | acpi_addr_t ec_data; /* EC data register */ |
| 682 | u32 uid; /* UID */ |
| 683 | u8 gpe_bit; /* GPE bit */ |
| 684 | u8 ec_id[]; /* EC ID */ |
| 685 | } __packed acpi_ecdt_t; |
| 686 | |
| 687 | /* HEST (Hardware Error Source Table) */ |
| 688 | typedef struct acpi_hest { |
| 689 | acpi_header_t header; |
| 690 | u32 error_source_count; |
| 691 | /* error_source_struct(s) */ |
| 692 | } __packed acpi_hest_t; |
| 693 | |
| 694 | /* Error Source Descriptors */ |
| 695 | typedef struct acpi_hest_esd { |
| 696 | u16 type; |
| 697 | u16 source_id; |
| 698 | u16 resv; |
| 699 | u8 flags; |
| 700 | u8 enabled; |
| 701 | u32 prealloc_erecords; /* The number of error records to |
| 702 | * pre-allocate for this error source. |
| 703 | */ |
| 704 | u32 max_section_per_record; |
| 705 | } __packed acpi_hest_esd_t; |
| 706 | |
| 707 | /* Hardware Error Notification */ |
| 708 | typedef struct acpi_hest_hen { |
| 709 | u8 type; |
| 710 | u8 length; |
| 711 | u16 conf_we; /* Configuration Write Enable */ |
| 712 | u32 poll_interval; |
| 713 | u32 vector; |
| 714 | u32 sw2poll_threshold_val; |
| 715 | u32 sw2poll_threshold_win; |
| 716 | u32 error_threshold_val; |
| 717 | u32 error_threshold_win; |
| 718 | } __packed acpi_hest_hen_t; |
| 719 | |
| 720 | /* BERT (Boot Error Record Table) */ |
| 721 | typedef struct acpi_bert { |
| 722 | acpi_header_t header; |
| 723 | u32 region_length; |
| 724 | u64 error_region; |
| 725 | } __packed acpi_bert_t; |
| 726 | |
| 727 | /* Generic Error Data Entry */ |
| 728 | typedef struct acpi_hest_generic_data { |
| 729 | guid_t section_type; |
| 730 | u32 error_severity; |
| 731 | u16 revision; |
| 732 | u8 validation_bits; |
| 733 | u8 flags; |
| 734 | u32 data_length; |
| 735 | guid_t fru_id; |
| 736 | u8 fru_text[20]; |
| 737 | /* error data */ |
| 738 | } __packed acpi_hest_generic_data_t; |
| 739 | |
| 740 | /* Generic Error Data Entry v300 */ |
| 741 | typedef struct acpi_hest_generic_data_v300 { |
| 742 | guid_t section_type; |
| 743 | u32 error_severity; |
| 744 | u16 revision; |
| 745 | u8 validation_bits; |
| 746 | u8 flags; /* see CPER Section Descriptor, Flags field */ |
| 747 | u32 data_length; |
| 748 | guid_t fru_id; |
| 749 | u8 fru_text[20]; |
| 750 | cper_timestamp_t timestamp; |
| 751 | /* error data */ |
| 752 | } __packed acpi_hest_generic_data_v300_t; |
| 753 | #define HEST_GENERIC_ENTRY_V300 0x300 |
| 754 | |
| 755 | /* Both Generic Error Status & Generic Error Data Entry, Error Severity field */ |
| 756 | #define ACPI_GENERROR_SEV_RECOVERABLE 0 |
| 757 | #define ACPI_GENERROR_SEV_FATAL 1 |
| 758 | #define ACPI_GENERROR_SEV_CORRECTED 2 |
| 759 | #define ACPI_GENERROR_SEV_NONE 3 |
| 760 | |
| 761 | /* Generic Error Data Entry, Validation Bits field */ |
| 762 | #define ACPI_GENERROR_VALID_FRUID BIT(0) |
| 763 | #define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1) |
| 764 | #define ACPI_GENERROR_VALID_TIMESTAMP BIT(2) |
| 765 | |
| 766 | /* Generic Error Status Block */ |
| 767 | typedef struct acpi_generic_error_status { |
| 768 | u32 block_status; |
| 769 | u32 raw_data_offset; /* must follow any generic entries */ |
| 770 | u32 raw_data_length; |
| 771 | u32 data_length; /* generic data */ |
| 772 | u32 error_severity; |
| 773 | /* Generic Error Data structures, zero or more entries */ |
| 774 | } __packed acpi_generic_error_status_t; |
| 775 | |
| 776 | /* Generic Status Block, Block Status values */ |
| 777 | #define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0) |
| 778 | #define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1) |
| 779 | #define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2) |
| 780 | #define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3) |
| 781 | #define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4 |
| 782 | #define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff |
| 783 | #define GENERIC_ERR_STS_ENTRY_COUNT_MASK \ |
| 784 | (GENERIC_ERR_STS_ENTRY_COUNT_MAX \ |
| 785 | << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT) |
| 786 | |
| 787 | typedef struct acpi_cstate { |
| 788 | u8 ctype; |
| 789 | u16 latency; |
| 790 | u32 power; |
| 791 | acpi_addr_t resource; |
| 792 | } __packed acpi_cstate_t; |
| 793 | |
| 794 | typedef struct acpi_tstate { |
| 795 | u32 percent; |
| 796 | u32 power; |
| 797 | u32 latency; |
| 798 | u32 control; |
| 799 | u32 status; |
| 800 | } __packed acpi_tstate_t; |
| 801 | |
| 802 | /* Port types for ACPI _UPC object */ |
| 803 | enum acpi_upc_type { |
| 804 | UPC_TYPE_A, |
| 805 | UPC_TYPE_MINI_AB, |
| 806 | UPC_TYPE_EXPRESSCARD, |
| 807 | UPC_TYPE_USB3_A, |
| 808 | UPC_TYPE_USB3_B, |
| 809 | UPC_TYPE_USB3_MICRO_B, |
| 810 | UPC_TYPE_USB3_MICRO_AB, |
| 811 | UPC_TYPE_USB3_POWER_B, |
| 812 | UPC_TYPE_C_USB2_ONLY, |
| 813 | UPC_TYPE_C_USB2_SS_SWITCH, |
| 814 | UPC_TYPE_C_USB2_SS, |
| 815 | UPC_TYPE_PROPRIETARY = 0xff, |
| 816 | /* |
| 817 | * The following types are not directly defined in the ACPI |
| 818 | * spec but are used by coreboot to identify a USB device type. |
| 819 | */ |
| 820 | UPC_TYPE_INTERNAL = 0xff, |
| 821 | UPC_TYPE_UNUSED, |
| 822 | UPC_TYPE_HUB |
| 823 | }; |
| 824 | |
| 825 | enum acpi_ipmi_interface_type { |
| 826 | IPMI_INTERFACE_RESERVED = 0, |
| 827 | IPMI_INTERFACE_KCS, |
| 828 | IPMI_INTERFACE_SMIC, |
| 829 | IPMI_INTERFACE_BT, |
| 830 | IPMI_INTERFACE_SSIF, |
| 831 | }; |
| 832 | |
| 833 | #define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0) |
| 834 | #define ACPI_IPMI_INT_TYPE_SCI (1 << 0) |
| 835 | #define ACPI_IPMI_INT_TYPE_APIC (1 << 1) |
| 836 | |
| 837 | /* ACPI IPMI 2.0 */ |
| 838 | struct acpi_spmi { |
| 839 | acpi_header_t header; |
| 840 | u8 interface_type; |
| 841 | u8 reserved; |
| 842 | u16 specification_revision; |
| 843 | u8 interrupt_type; |
| 844 | u8 gpe; |
| 845 | u8 reserved2; |
| 846 | u8 pci_device_flag; |
| 847 | |
| 848 | u32 global_system_interrupt; |
| 849 | acpi_addr_t base_address; |
| 850 | union { |
| 851 | struct { |
| 852 | u8 pci_segment_group; |
| 853 | u8 pci_bus; |
| 854 | u8 pci_device; |
| 855 | u8 pci_function; |
| 856 | }; |
| 857 | u8 uid[4]; |
| 858 | }; |
| 859 | u8 reserved3; |
| 860 | } __packed; |
| 861 | |
| 862 | unsigned long fw_cfg_acpi_tables(unsigned long start); |
| 863 | |
| 864 | /* These are implemented by the target port or north/southbridge. */ |
| 865 | unsigned long write_acpi_tables(unsigned long addr); |
| 866 | unsigned long acpi_fill_madt(unsigned long current); |
| 867 | unsigned long acpi_fill_mcfg(unsigned long current); |
| 868 | unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current); |
| 869 | void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id); |
| 870 | void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length); |
| 871 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt); |
| 872 | #if CONFIG(COMMON_FADT) |
| 873 | void acpi_fill_fadt(acpi_fadt_t *fadt); |
| 874 | #endif |
| 875 | |
| 876 | void update_ssdt(void *ssdt); |
| 877 | void update_ssdtx(void *ssdtx, int i); |
| 878 | |
| 879 | /* These can be used by the target port. */ |
| 880 | u8 acpi_checksum(u8 *table, u32 length); |
| 881 | |
| 882 | void acpi_add_table(acpi_rsdp_t *rsdp, void *table); |
| 883 | |
| 884 | int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic); |
| 885 | int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, |
| 886 | u32 gsi_base); |
| 887 | int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, |
| 888 | u8 bus, u8 source, u32 gsirq, u16 flags); |
| 889 | int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu, |
| 890 | u16 flags, u8 lint); |
| 891 | void acpi_create_madt(acpi_madt_t *madt); |
| 892 | unsigned long acpi_create_madt_lapics(unsigned long current); |
| 893 | unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, |
| 894 | u8 lint); |
| 895 | int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic); |
| 896 | int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu, |
| 897 | u16 flags, u8 lint); |
| 898 | int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic); |
| 899 | int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, |
| 900 | u32 flags); |
| 901 | int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, |
| 902 | u16 seg_nr, u8 start, u8 end); |
| 903 | unsigned long acpi_create_srat_lapics(unsigned long current); |
| 904 | void acpi_create_srat(acpi_srat_t *srat, |
| 905 | unsigned long (*acpi_fill_srat)(unsigned long current)); |
| 906 | |
| 907 | void acpi_create_slit(acpi_slit_t *slit, |
| 908 | unsigned long (*acpi_fill_slit)(unsigned long current)); |
| 909 | |
| 910 | void acpi_create_vfct(const struct device *device, |
| 911 | acpi_vfct_t *vfct, |
| 912 | unsigned long (*acpi_fill_vfct)(const struct device *device, |
| 913 | acpi_vfct_t *vfct_struct, |
| 914 | unsigned long current)); |
| 915 | |
| 916 | void acpi_create_ipmi(const struct device *device, |
| 917 | struct acpi_spmi *spmi, |
| 918 | const u16 ipmi_revision, |
| 919 | const acpi_addr_t *addr, |
| 920 | const enum acpi_ipmi_interface_type type, |
| 921 | const s8 gpe_interrupt, |
| 922 | const u32 apic_interrupt, |
| 923 | const u32 uid); |
| 924 | |
| 925 | void acpi_create_ivrs(acpi_ivrs_t *ivrs, |
| 926 | unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, |
| 927 | unsigned long current)); |
| 928 | |
| 929 | void acpi_create_hpet(acpi_hpet_t *hpet); |
| 930 | unsigned long acpi_write_hpet(const struct device *device, unsigned long start, |
| 931 | acpi_rsdp_t *rsdp); |
| 932 | |
| 933 | /* cpu/intel/speedstep/acpi.c */ |
| 934 | void generate_cpu_entries(const struct device *device); |
| 935 | |
| 936 | void acpi_create_mcfg(acpi_mcfg_t *mcfg); |
| 937 | |
| 938 | void acpi_create_facs(acpi_facs_t *facs); |
| 939 | |
| 940 | void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header, |
| 941 | int port_type, int port_subtype, |
| 942 | acpi_addr_t *address, uint32_t address_size, |
| 943 | const char *device_path); |
| 944 | |
| 945 | unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current, |
| 946 | const struct device *dev, uint8_t access_size); |
| 947 | void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, |
| 948 | unsigned long (*acpi_fill_dmar)(unsigned long)); |
| 949 | unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, |
| 950 | u16 segment, u64 bar); |
| 951 | unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, |
| 952 | u64 bar, u64 limit); |
| 953 | unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, |
| 954 | u16 segment); |
| 955 | unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, |
| 956 | u32 proximity_domain); |
| 957 | unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, |
| 958 | const char *device_name); |
| 959 | void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current); |
| 960 | void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current); |
| 961 | void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current); |
| 962 | unsigned long acpi_create_dmar_ds_pci_br(unsigned long current, |
| 963 | u8 bus, u8 dev, u8 fn); |
| 964 | unsigned long acpi_create_dmar_ds_pci(unsigned long current, |
| 965 | u8 bus, u8 dev, u8 fn); |
| 966 | unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, |
| 967 | u8 enumeration_id, |
| 968 | u8 bus, u8 dev, u8 fn); |
| 969 | unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, |
| 970 | u8 enumeration_id, |
| 971 | u8 bus, u8 dev, u8 fn); |
| 972 | void acpi_write_hest(acpi_hest_t *hest, |
| 973 | unsigned long (*acpi_fill_hest)(acpi_hest_t *hest)); |
| 974 | |
| 975 | unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, |
| 976 | acpi_hest_esd_t *esd, u16 type, void *data, u16 len); |
| 977 | |
| 978 | /* For ACPI S3 support. */ |
| 979 | void acpi_resume(void *wake_vec); |
| 980 | void mainboard_suspend_resume(void); |
| 981 | void *acpi_find_wakeup_vector(void); |
| 982 | |
| 983 | /* ACPI_Sn assignments are defined to always equal the sleep state numbers */ |
| 984 | enum { |
| 985 | ACPI_S0 = 0, |
| 986 | ACPI_S1 = 1, |
| 987 | ACPI_S2 = 2, |
| 988 | ACPI_S3 = 3, |
| 989 | ACPI_S4 = 4, |
| 990 | ACPI_S5 = 5, |
| 991 | }; |
| 992 | |
| 993 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \ |
| 994 | || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 995 | /* Given the provided PM1 control register return the ACPI sleep type. */ |
| 996 | static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt) |
| 997 | { |
| 998 | switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) { |
| 999 | case SLP_TYP_S0: return ACPI_S0; |
| 1000 | case SLP_TYP_S1: return ACPI_S1; |
| 1001 | case SLP_TYP_S3: return ACPI_S3; |
| 1002 | case SLP_TYP_S4: return ACPI_S4; |
| 1003 | case SLP_TYP_S5: return ACPI_S5; |
| 1004 | } |
| 1005 | return -1; |
| 1006 | } |
| 1007 | #endif |
| 1008 | |
| 1009 | /* Returns ACPI_Sx values. */ |
| 1010 | int acpi_get_sleep_type(void); |
| 1011 | |
| 1012 | /* Read and clear GPE status */ |
| 1013 | int acpi_get_gpe(int gpe); |
| 1014 | |
| 1015 | static inline int acpi_s3_resume_allowed(void) |
| 1016 | { |
| 1017 | return CONFIG(HAVE_ACPI_RESUME); |
| 1018 | } |
| 1019 | |
| 1020 | #if CONFIG(HAVE_ACPI_RESUME) |
| 1021 | |
| 1022 | #if ENV_ROMSTAGE_OR_BEFORE |
| 1023 | static inline int acpi_is_wakeup_s3(void) |
| 1024 | { |
| 1025 | return (acpi_get_sleep_type() == ACPI_S3); |
| 1026 | } |
| 1027 | #else |
| 1028 | int acpi_is_wakeup(void); |
| 1029 | int acpi_is_wakeup_s3(void); |
| 1030 | int acpi_is_wakeup_s4(void); |
| 1031 | #endif |
| 1032 | |
| 1033 | #else |
| 1034 | static inline int acpi_is_wakeup(void) { return 0; } |
| 1035 | static inline int acpi_is_wakeup_s3(void) { return 0; } |
| 1036 | static inline int acpi_is_wakeup_s4(void) { return 0; } |
| 1037 | #endif |
| 1038 | |
| 1039 | static inline uintptr_t acpi_align_current(uintptr_t current) |
| 1040 | { |
| 1041 | return ALIGN_UP(current, 16); |
| 1042 | } |
| 1043 | |
| 1044 | /* ACPI table revisions should match the revision of the ACPI spec |
| 1045 | * supported. This function keeps the table versions synced. This could |
| 1046 | * be made into a weak function if there is ever a need to override the |
| 1047 | * coreboot default ACPI spec version supported. */ |
| 1048 | int get_acpi_table_revision(enum acpi_tables table); |
| 1049 | |
| 1050 | #endif // !defined(__ASSEMBLER__) && !defined(__ACPI__) && !defined(__ROMC__) |
| 1051 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame^] | 1052 | #endif /* __ACPI_ACPI_H__ */ |