1 1.5 riastrad /* $NetBSD: apei_cper.h,v 1.5 2024/10/27 12:59:08 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /*- 4 1.1 riastrad * Copyright (c) 2024 The NetBSD Foundation, Inc. 5 1.1 riastrad * All rights reserved. 6 1.1 riastrad * 7 1.1 riastrad * Redistribution and use in source and binary forms, with or without 8 1.1 riastrad * modification, are permitted provided that the following conditions 9 1.1 riastrad * are met: 10 1.1 riastrad * 1. Redistributions of source code must retain the above copyright 11 1.1 riastrad * notice, this list of conditions and the following disclaimer. 12 1.1 riastrad * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 riastrad * notice, this list of conditions and the following disclaimer in the 14 1.1 riastrad * documentation and/or other materials provided with the distribution. 15 1.1 riastrad * 16 1.1 riastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 riastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 1.1 riastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 1.1 riastrad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 1.1 riastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 1.1 riastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 1.1 riastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 1.1 riastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 1.1 riastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 1.1 riastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 riastrad * POSSIBILITY OF SUCH DAMAGE. 27 1.1 riastrad */ 28 1.1 riastrad 29 1.1 riastrad /* 30 1.1 riastrad * UEFI Common Platform Error Record 31 1.1 riastrad * 32 1.1 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html 33 1.1 riastrad */ 34 1.1 riastrad 35 1.1 riastrad #ifndef _SYS_DEV_ACPI_APEI_CPER_H_ 36 1.1 riastrad #define _SYS_DEV_ACPI_APEI_CPER_H_ 37 1.1 riastrad 38 1.1 riastrad #include <sys/types.h> 39 1.1 riastrad 40 1.1 riastrad #include <sys/cdefs.h> 41 1.1 riastrad 42 1.1 riastrad /* 43 1.1 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#record-header 44 1.1 riastrad */ 45 1.1 riastrad struct cper_header { 46 1.2 rillig char SignatureStart[4]; /* `CPER' */ 47 1.1 riastrad uint16_t Revision; 48 1.2 rillig uint32_t SignatureEnd; /* 0xffffffff */ 49 1.1 riastrad uint16_t SectionCount; 50 1.1 riastrad uint32_t ErrorSeverity; 51 1.1 riastrad uint32_t ValidationBits; 52 1.1 riastrad uint32_t RecordLength; 53 1.1 riastrad uint64_t Timestamp; 54 1.1 riastrad uint8_t PlatformId[16]; 55 1.1 riastrad uint8_t PartitionId[16]; 56 1.1 riastrad uint8_t CreatorId[16]; 57 1.1 riastrad uint8_t NotificationType[16]; 58 1.1 riastrad uint64_t RecordId; 59 1.1 riastrad uint32_t Flags; 60 1.1 riastrad uint64_t PersistenceInfo; 61 1.1 riastrad uint8_t Reserved[12]; 62 1.1 riastrad } __packed; 63 1.1 riastrad __CTASSERT(sizeof(struct cper_header) == 128); 64 1.1 riastrad 65 1.3 riastrad enum { /* struct cper_header::ErrorSeverity */ 66 1.1 riastrad CPER_ERROR_SEVERITY_RECOVERABLE = 0, 67 1.1 riastrad CPER_ERROR_SEVERITY_FATAL = 1, 68 1.1 riastrad CPER_ERROR_SEVERITY_CORRECTED = 2, 69 1.1 riastrad CPER_ERROR_SEVERITY_INFORMATIONAL = 3, 70 1.1 riastrad }; 71 1.1 riastrad 72 1.3 riastrad enum { /* struct cper_header::ValidationBits */ 73 1.1 riastrad CPER_VALID_PLATFORM_ID = __BIT(0), 74 1.1 riastrad CPER_VALID_TIMESTAMP = __BIT(1), 75 1.1 riastrad CPER_VALID_PARTITION_ID = __BIT(2), 76 1.1 riastrad }; 77 1.1 riastrad 78 1.1 riastrad /* 79 1.1 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#error-record-header-flags 80 1.1 riastrad */ 81 1.3 riastrad enum { /* struct cper_header::Flags */ 82 1.1 riastrad CPER_HW_ERROR_FLAG_RECOVERED = __BIT(0), 83 1.1 riastrad CPER_HW_ERROR_FLAG_PREVERR = __BIT(1), 84 1.1 riastrad CPER_HW_ERROR_FLAG_SIMULATED = __BIT(2), 85 1.1 riastrad }; 86 1.1 riastrad 87 1.1 riastrad /* 88 1.1 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#section-descriptor-format 89 1.1 riastrad */ 90 1.1 riastrad enum { 91 1.1 riastrad CPER_SECTION_FLAG_PRIMARY = __BIT(0), 92 1.1 riastrad CPER_SECTION_FLAG_CONTAINMENT_WARNING = __BIT(1), 93 1.1 riastrad CPER_SECTION_FLAG_RESET = __BIT(2), 94 1.1 riastrad CPER_SECTION_FLAG_ERROR_THRESHOLD_EXCEEDED = __BIT(3), 95 1.1 riastrad CPER_SECTION_FLAG_RESOURCE_NOT_ACCESSIBLE = __BIT(4), 96 1.1 riastrad CPER_SECTION_FLAG_LATENT_ERROR = __BIT(5), 97 1.1 riastrad CPER_SECTION_FLAG_PROPAGATED = __BIT(6), 98 1.1 riastrad CPER_SECTION_FLAG_OVERFLOW = __BIT(7), 99 1.1 riastrad }; 100 1.1 riastrad 101 1.1 riastrad #define CPER_SECTION_FLAGS_FMT "\177\020" \ 102 1.1 riastrad "b\000" "PRIMARY\0" \ 103 1.1 riastrad "b\001" "CONTAINMENT_WARNING\0" \ 104 1.1 riastrad "b\002" "RESET\0" \ 105 1.1 riastrad "b\003" "ERROR_THRESHOLD_EXCEEDED\0" \ 106 1.1 riastrad "b\004" "RESOURCE_NOT_ACCESSIBLE\0" \ 107 1.1 riastrad "b\005" "LATENT_ERROR\0" \ 108 1.1 riastrad "b\006" "PROPAGATED\0" \ 109 1.1 riastrad "b\007" "OVERFLOW\0" \ 110 1.1 riastrad "\0" 111 1.1 riastrad 112 1.1 riastrad /* 113 1.4 riastrad * N.2.5. Memory Error Section 114 1.4 riastrad * 115 1.1 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#memory-error-section 116 1.1 riastrad * 117 1.1 riastrad * Type: {0xa5bc1114,0x6f64,0x4ede,{0xb8,0x63,0x3e,0x83,0xed,0x7c,0x83,0xb1}} 118 1.1 riastrad */ 119 1.1 riastrad 120 1.1 riastrad struct cper_memory_error { 121 1.1 riastrad uint64_t ValidationBits; 122 1.1 riastrad uint64_t ErrorStatus; 123 1.1 riastrad uint64_t PhysicalAddress; 124 1.1 riastrad uint64_t PhysicalAddressMask; 125 1.1 riastrad uint16_t Node; 126 1.1 riastrad uint16_t Card; 127 1.1 riastrad uint16_t Module; 128 1.1 riastrad uint16_t Bank; 129 1.1 riastrad uint16_t Device; 130 1.1 riastrad uint16_t Row; 131 1.1 riastrad uint16_t Column; 132 1.1 riastrad uint16_t BitPosition; 133 1.1 riastrad uint64_t RequestorId; 134 1.1 riastrad uint64_t ResponderId; 135 1.1 riastrad uint64_t TargetId; 136 1.1 riastrad uint8_t MemoryErrorType; 137 1.1 riastrad } __packed; 138 1.1 riastrad __CTASSERT(sizeof(struct cper_memory_error) == 73); 139 1.1 riastrad 140 1.1 riastrad struct cper_memory_error_ext { 141 1.1 riastrad struct cper_memory_error Base; 142 1.1 riastrad uint8_t Extended; 143 1.1 riastrad uint16_t RankNumber; 144 1.1 riastrad uint16_t CardHandle; 145 1.1 riastrad uint16_t ModuleHandle; 146 1.1 riastrad } __packed; 147 1.1 riastrad __CTASSERT(sizeof(struct cper_memory_error_ext) == 80); 148 1.1 riastrad 149 1.3 riastrad enum { /* struct cper_memory_error::ValidationBits */ 150 1.1 riastrad CPER_MEMORY_ERROR_VALID_ERROR_STATUS = __BIT(0), 151 1.1 riastrad CPER_MEMORY_ERROR_VALID_PHYSICAL_ADDRESS = __BIT(1), 152 1.1 riastrad CPER_MEMORY_ERROR_VALID_PHYSICAL_ADDRESS_MASK = __BIT(2), 153 1.1 riastrad CPER_MEMORY_ERROR_VALID_NODE = __BIT(3), 154 1.1 riastrad CPER_MEMORY_ERROR_VALID_CARD = __BIT(4), 155 1.1 riastrad CPER_MEMORY_ERROR_VALID_MODULE = __BIT(5), 156 1.1 riastrad CPER_MEMORY_ERROR_VALID_BANK = __BIT(6), 157 1.1 riastrad CPER_MEMORY_ERROR_VALID_DEVICE = __BIT(7), 158 1.1 riastrad CPER_MEMORY_ERROR_VALID_ROW = __BIT(8), 159 1.1 riastrad CPER_MEMORY_ERROR_VALID_COLUMN = __BIT(9), 160 1.1 riastrad CPER_MEMORY_ERROR_VALID_BIT_POSITION = __BIT(10), 161 1.1 riastrad CPER_MEMORY_ERROR_VALID_REQUESTOR_ID = __BIT(11), 162 1.1 riastrad CPER_MEMORY_ERROR_VALID_RESPONDER_ID = __BIT(12), 163 1.1 riastrad CPER_MEMORY_ERROR_VALID_TARGET_ID = __BIT(13), 164 1.1 riastrad CPER_MEMORY_ERROR_VALID_MEMORY_ERROR_TYPE = __BIT(14), 165 1.1 riastrad CPER_MEMORY_ERROR_VALID_RANK_NUMBER = __BIT(15), 166 1.1 riastrad CPER_MEMORY_ERROR_VALID_CARD_HANDLE = __BIT(16), 167 1.1 riastrad CPER_MEMORY_ERROR_VALID_MODULE_HANDLE = __BIT(17), 168 1.1 riastrad CPER_MEMORY_ERROR_VALID_EXTENDED_ROW = __BIT(18), 169 1.1 riastrad CPER_MEMORY_ERROR_VALID_BANK_GROUP = __BIT(19), 170 1.1 riastrad CPER_MEMORY_ERROR_VALID_BANK_ADDRESS = __BIT(20), 171 1.1 riastrad CPER_MEMORY_ERROR_VALID_CHIP_ID = __BIT(21), 172 1.1 riastrad }; 173 1.1 riastrad 174 1.1 riastrad #define CPER_MEMORY_ERROR_VALIDATION_BITS_FMT "\177\020" \ 175 1.1 riastrad "b\000" "ERROR_STATUS\0" \ 176 1.1 riastrad "b\001" "PHYSICAL_ADDRESS\0" \ 177 1.1 riastrad "b\002" "PHYSICAL_ADDRESS_MASK\0" \ 178 1.1 riastrad "b\003" "NODE\0" \ 179 1.1 riastrad "b\004" "CARD\0" \ 180 1.1 riastrad "b\005" "MODULE\0" \ 181 1.1 riastrad "b\006" "BANK\0" \ 182 1.1 riastrad "b\007" "DEVICE\0" \ 183 1.1 riastrad "b\010" "ROW\0" \ 184 1.2 rillig "b\011" "COLUMN\0" \ 185 1.1 riastrad "b\012" "BIT_POSITION\0" \ 186 1.1 riastrad "b\013" "REQUESTOR_ID\0" \ 187 1.1 riastrad "b\014" "RESPONDER_ID\0" \ 188 1.1 riastrad "b\015" "TARGET_ID\0" \ 189 1.1 riastrad "b\016" "MEMORY_ERROR_TYPE\0" \ 190 1.1 riastrad "b\017" "RANK_NUMBER\0" \ 191 1.1 riastrad "b\020" "CARD_HANDLE\0" \ 192 1.1 riastrad "b\021" "MODULE_HANDLE\0" \ 193 1.1 riastrad "b\022" "EXTENDED_ROW\0" \ 194 1.1 riastrad "b\023" "BANK_GROUP\0" \ 195 1.1 riastrad "b\024" "BANK_ADDRESS\0" \ 196 1.1 riastrad "b\025" "CHIP_ID\0" \ 197 1.1 riastrad "\0" 198 1.1 riastrad 199 1.3 riastrad enum { /* struct cper_memory_error::Bank */ 200 1.1 riastrad CPER_MEMORY_ERROR_BANK_ADDRESS = __BITS(7,0), 201 1.1 riastrad CPER_MEMORY_ERROR_BANK_GROUP = __BITS(15,8), 202 1.1 riastrad }; 203 1.1 riastrad 204 1.1 riastrad #define CPER_MEMORY_ERROR_TYPES(F) \ 205 1.1 riastrad F(CPER_MEMORY_ERROR_UNKNOWN, UNKNOWN, 0) \ 206 1.1 riastrad F(CPER_MEMORY_ERROR_NO_ERROR, NO_ERROR, 1) \ 207 1.1 riastrad F(CPER_MEMORY_ERROR_SINGLEBIT_ECC, SINGLEBIT_ECC, 2) \ 208 1.1 riastrad F(CPER_MEMORY_ERROR_MULTIBIT_ECC, MULTIBIT_ECC, 3) \ 209 1.1 riastrad F(CPER_MEMORY_ERROR_SINGLESYM_CHIPKILL_ECC, SINGLESYM_CHIPKILL_ECC, 4)\ 210 1.1 riastrad F(CPER_MEMORY_ERROR_MULTISYM_CHIPKILL_ECC, MULTISYM_CHIPKILL_ECC, 5) \ 211 1.1 riastrad F(CPER_MEMORY_ERROR_MASTER_ABORT, MASTER_ABORT, 6) \ 212 1.1 riastrad F(CPER_MEMORY_ERROR_TARGET_ABORT, TARGET_ABORT, 7) \ 213 1.1 riastrad F(CPER_MEMORY_ERROR_PARITY_ERROR, PARITY_ERROR, 8) \ 214 1.1 riastrad F(CPER_MEMORY_ERROR_WATCHDOG_TIMEOUT, WATCHDOG_TIMEOUT, 9) \ 215 1.1 riastrad F(CPER_MEMORY_ERROR_INVALID_ADDRESS, INVALID_ADDRESS, 10) \ 216 1.1 riastrad F(CPER_MEMORY_ERROR_MIRROR_BROKEN, MIRROR_BROKEN, 11) \ 217 1.1 riastrad F(CPER_MEMORY_ERROR_MEMORY_SPARING, MEMORY_SPARING, 12) \ 218 1.1 riastrad F(CPER_MEMORY_ERROR_SCRUB_CORRECTED_ERROR, SCRUB_CORRECTED_ERROR, 13) \ 219 1.1 riastrad F(CPER_MEMORY_ERROR_SCRUB_UNCORRECTED_ERROR, SCRUB_UNCORRECTED_ERROR, \ 220 1.1 riastrad 14) \ 221 1.1 riastrad F(CPER_MEMORY_ERROR_PHYSMEM_MAPOUT_EVENT, PHYSMEM_MAPOUT_EVENT, 15) \ 222 1.1 riastrad /* end of CPER_MEMORY_ERROR_TYPES */ 223 1.1 riastrad 224 1.3 riastrad enum cper_memory_error_type { /* struct cper_memory_error::MemoryErrorType */ 225 1.1 riastrad #define CPER_MEMORY_ERROR_TYPE_DEF(LN, SN, V) LN = V, 226 1.1 riastrad CPER_MEMORY_ERROR_TYPES(CPER_MEMORY_ERROR_TYPE_DEF) 227 1.1 riastrad #undef CPER_MEMORY_ERROR_TYPE_DEF 228 1.1 riastrad }; 229 1.1 riastrad 230 1.3 riastrad enum { /* struct cper_memory_error_ext::Extended */ 231 1.1 riastrad CPER_MEMORY_ERROR_EXTENDED_ROWBIT16 = __BIT(0), 232 1.1 riastrad CPER_MEMORY_ERROR_EXTENDED_ROWBIT17 = __BIT(1), 233 1.1 riastrad CPER_MEMORY_ERROR_EXTENDED_CHIPID = __BITS(7,5), 234 1.1 riastrad }; 235 1.1 riastrad 236 1.5 riastrad /* 237 1.5 riastrad * N.2.7. PCI Express Error Section 238 1.5 riastrad * 239 1.5 riastrad * https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#pci-express-error-section 240 1.5 riastrad * 241 1.5 riastrad * Type: {0xd995e954,0xbbc1,0x430f,{0xad,0x91,0xb4,0x4d,0xcb,0x3c,0x6f,0x35}} 242 1.5 riastrad */ 243 1.5 riastrad 244 1.5 riastrad struct cper_pcie_error { 245 1.5 riastrad uint64_t ValidationBits; 246 1.5 riastrad uint32_t PortType; 247 1.5 riastrad uint32_t Version; 248 1.5 riastrad uint32_t CommandStatus; 249 1.5 riastrad uint32_t Reserved0; 250 1.5 riastrad struct { 251 1.5 riastrad uint8_t VendorID[2]; 252 1.5 riastrad uint8_t DeviceID[2]; /* product */ 253 1.5 riastrad uint8_t ClassCode[3]; 254 1.5 riastrad uint8_t Function; 255 1.5 riastrad uint8_t Device; 256 1.5 riastrad uint8_t Segment[2]; 257 1.5 riastrad uint8_t Bus; 258 1.5 riastrad uint8_t SecondaryBus; 259 1.5 riastrad uint8_t Slot[2]; /* bits 0:2 resv, bits 3:15 slot */ 260 1.5 riastrad uint8_t Reserved0; 261 1.5 riastrad } DeviceID; 262 1.5 riastrad uint64_t DeviceSerial; 263 1.5 riastrad uint32_t BridgeControlStatus; 264 1.5 riastrad uint8_t CapabilityStructure[60]; 265 1.5 riastrad uint8_t AERInfo[96]; 266 1.5 riastrad } __packed; 267 1.5 riastrad __CTASSERT(sizeof(struct cper_pcie_error) == 208); 268 1.5 riastrad 269 1.5 riastrad enum { /* struct cper_pcie_error::ValidationBits */ 270 1.5 riastrad CPER_PCIE_ERROR_VALID_PORT_TYPE = __BIT(0), 271 1.5 riastrad CPER_PCIE_ERROR_VALID_VERSION = __BIT(1), 272 1.5 riastrad CPER_PCIE_ERROR_VALID_COMMAND_STATUS = __BIT(2), 273 1.5 riastrad CPER_PCIE_ERROR_VALID_DEVICE_ID = __BIT(3), 274 1.5 riastrad CPER_PCIE_ERROR_VALID_DEVICE_SERIAL = __BIT(4), 275 1.5 riastrad CPER_PCIE_ERROR_VALID_BRIDGE_CONTROL_STATUS = __BIT(5), 276 1.5 riastrad CPER_PCIE_ERROR_VALID_CAPABILITY_STRUCTURE = __BIT(6), 277 1.5 riastrad CPER_PCIE_ERROR_VALID_AER_INFO = __BIT(7), 278 1.5 riastrad }; 279 1.5 riastrad 280 1.5 riastrad #define CPER_PCIE_ERROR_VALIDATION_BITS_FMT "\177\020" \ 281 1.5 riastrad "b\000" "PORT_TYPE\0" \ 282 1.5 riastrad "b\001" "VERSION\0" \ 283 1.5 riastrad "b\002" "COMMAND_STATUS\0" \ 284 1.5 riastrad "b\003" "DEVICE_ID\0" \ 285 1.5 riastrad "b\004" "DEVICE_SERIAL\0" \ 286 1.5 riastrad "b\005" "BRIDGE_CONTROL_STATUS\0" \ 287 1.5 riastrad "b\006" "CAPABILITY_STRUCTURE\0" \ 288 1.5 riastrad "b\007" "AER_INFO\0" \ 289 1.5 riastrad "\0" 290 1.5 riastrad 291 1.5 riastrad #define CPER_PCIE_ERROR_PORT_TYPES(F) \ 292 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_PCIE_ENDPOINT, PCIE_ENDPOINT, 0) \ 293 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_LEGACY_PCI_ENDPOINT, LEGACY_PCI_ENDPOINT, \ 294 1.5 riastrad 1) \ 295 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_ROOTPORT5_UPSTREAMSWITCH, \ 296 1.5 riastrad ROOTPORT5_UPSTREAMSWITCH, 4) \ 297 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_DOWNSTREAMSWITCH, DOWNSTREAMSWITCH, 6) \ 298 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_PCIE_PCI_BRIDGE, PCIE_PCI_BRIDGE, 7) \ 299 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_PCI_PCIE_BRIDGE, PCI_PCIE_BRIDGE, 8) \ 300 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_RCIEP_DEV, RCIEP_DEV, 9) \ 301 1.5 riastrad /* Root Complex Integrated Endpoint Device */ \ 302 1.5 riastrad F(CPER_PCIE_ERROR_PORT_TYPE_RCEC, RCEC, 10) \ 303 1.5 riastrad /* Root Complex Event Collector */ \ 304 1.5 riastrad /* end of CPER_PCIE_ERROR_PORT_TYPES */ 305 1.5 riastrad 306 1.5 riastrad enum cper_pcie_error_port_type { /* struct cper_pcie_error::PortType */ 307 1.5 riastrad #define CPER_PCIE_ERROR_PORT_TYPE_DEF(LN, SN, V) LN = V, 308 1.5 riastrad CPER_PCIE_ERROR_PORT_TYPES(CPER_PCIE_ERROR_PORT_TYPE_DEF) 309 1.5 riastrad #undef CPER_PCIE_ERROR_PORT_TYPE_DEF 310 1.5 riastrad }; 311 1.5 riastrad 312 1.1 riastrad #endif /* _SYS_DEV_ACPI_APEI_CPER_H_ */ 313