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