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