1 #ifndef CPER_SECTION_ARM_H 2 #define CPER_SECTION_ARM_H 3 4 #include "json.h" 5 #include "../edk/Cper.h" 6 7 #define ARM_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ 8 {"mpidrValid", "errorAffinityLevelValid", "runningStateValid", "vendorSpecificInfoValid"} 9 #define ARM_ERROR_INFO_ENTRY_VALID_BITFIELD_NAMES (const char*[]) \ 10 {"multipleErrorValid", "flagsValid", "errorInformationValid", "virtualFaultAddressValid", "physicalFaultAddressValid"} 11 #define ARM_ERROR_INFO_ENTRY_FLAGS_NAMES (const char*[]) \ 12 {"firstErrorCaptured", "lastErrorCaptured", "propagated", "overflow"} 13 #define ARM_CACHE_TLB_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ 14 {"transactionTypeValid", "operationValid", "levelValid", "processorContextCorruptValid", "correctedValid", \ 15 "precisePCValid", "restartablePCValid"} 16 #define ARM_BUS_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ 17 {"transactionTypeValid", "operationValid", "levelValid", "processorContextCorruptValid", "correctedValid", \ 18 "precisePCValid", "restartablePCValid", "participationTypeValid", "timedOutValid", "addressSpaceValid", \ 19 "memoryAttributesValid", "accessModeValid"} 20 #define ARM_ERROR_TRANSACTION_TYPES_KEYS (int []){0, 1, 2} 21 #define ARM_ERROR_TRANSACTION_TYPES_VALUES (const char*[]){"Instruction", "Data Access", "Generic"} 22 #define ARM_ERROR_INFO_ENTRY_INFO_TYPES_KEYS (int []){0, 1, 2, 3} 23 #define ARM_ERROR_INFO_ENTRY_INFO_TYPES_VALUES (const char*[]){"Cache Error", "TLB Error", \ 24 "Bus Error", "Micro-Architectural Error"} 25 #define ARM_CACHE_BUS_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 26 #define ARM_CACHE_BUS_OPERATION_TYPES_VALUES (const char*[]){"Generic Error", "Generic Read", "Generic Write", \ 27 "Data Read", "Data Write", "Instruction Fetch", "Prefetch", "Eviction", "Snooping", "Snooped", "Management"} 28 #define ARM_TLB_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8} 29 #define ARM_TLB_OPERATION_TYPES_VALUES (const char*[]){"Generic Error", "Generic Read", "Generic Write", \ 30 "Data Read", "Data Write", "Instruction Fetch", "Prefetch", "Local Management Operation", \ 31 "External Management Operation"} 32 #define ARM_BUS_PARTICIPATION_TYPES_KEYS (int []){0, 1, 2, 3} 33 #define ARM_BUS_PARTICIPATION_TYPES_VALUES (const char*[]){"Local Processor Originated Request", \ 34 "Local Processor Responded to Request", "Local Processor Observed", "Generic"} 35 #define ARM_BUS_ADDRESS_SPACE_TYPES_KEYS (int []){0, 1, 3} 36 #define ARM_BUS_ADDRESS_SPACE_TYPES_VALUES (const char*[]){"External Memory Access", "Internal Memory Access", \ 37 "Device Memory Access"} 38 #define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8} 39 #define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_VALUES (const char*[]){"AArch32 General Purpose Registers", \ 40 "AArch32 EL1 Context Registers", "AArch32 EL2 Context Registers", "AArch32 Secure Context Registers" \ 41 "AArch64 General Purpose Registers", "AArch64 EL1 Context Registers", "AArch64 EL2 Context Registers" \ 42 "AArch64 EL3 Context Registers", "Miscellaneous System Register Structure"} 43 #define ARM_AARCH32_GPR_NAMES (const char*[]){"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \ 44 "r10", "r11", "r12", "r13_sp", "r14_lr", "r15_pc"} 45 #define ARM_AARCH32_EL1_REGISTER_NAMES (const char*[]){"dfar", "dfsr", "ifar", "isr", "mair0", "mair1", "midr", \ 46 "mpidr", "nmrr", "prrr", "sctlr_ns", "spsr", "spsr_abt", "spsr_fiq", "spsr_irq", "spsr_svc", "spsr_und", \ 47 "tpidrprw", "tpidruro", "tpidrurw", "ttbcr", "ttbr0", "ttbr1", "dacr"} 48 #define ARM_AARCH32_EL2_REGISTER_NAMES (const char*[]){"elr_hyp", "hamair0", "hamair1", "hcr", "hcr2", "hdfar", \ 49 "hifar", "hpfar", "hsr", "htcr", "htpidr", "httbr", "spsr_hyp", "vtcr", "vttbr", "dacr32_el2"} 50 #define ARM_AARCH32_SECURE_REGISTER_NAMES (const char*[]){"sctlr_s", "spsr_mon"} 51 #define ARM_AARCH64_GPR_NAMES (const char*[]){"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10" \ 52 "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26" \ 53 "x27", "x28", "x29", "x30", "sp"} 54 #define ARM_AARCH64_EL1_REGISTER_NAMES (const char*[]){"elr_el1", "esr_el1", "far_el1", "isr_el1", "mair_el1", \ 55 "midr_el1", "mpidr_el1", "sctlr_el1", "sp_el0", "sp_el1", "spsr_el1", "tcr_el1", "tpidr_el0", "tpidr_el1", \ 56 "tpidrro_el0", "ttbr0_el1", "ttbr1_el1"} 57 #define ARM_AARCH64_EL2_REGISTER_NAMES (const char*[]){"elr_el2", "esr_el2", "far_el2", "hacr_el2", "hcr_el2", \ 58 "hpfar_el2", "mair_el2", "sctlr_el2", "sp_el2", "spsr_el2", "tcr_el2", "tpidr_el2", "ttbr0_el2", "vtcr_el2", \ 59 "vttbr_el2"} 60 #define ARM_AARCH64_EL3_REGISTER_NAMES (const char*[]){"elr_el3", "esr_el3", "far_el3", "mair_el3", "sctlr_el3", \ 61 "sp_el3", "spsr_el3", "tcr_el3", "tpidr_el3", "ttbr0_el3"} 62 63 /// 64 /// ARM Processor Error Record 65 /// 66 typedef struct { 67 UINT32 ValidFields; 68 UINT16 ErrInfoNum; 69 UINT16 ContextInfoNum; 70 UINT32 SectionLength; 71 UINT32 ErrorAffinityLevel; 72 UINT64 MPIDR_EL1; 73 UINT64 MIDR_EL1; 74 UINT32 RunningState; 75 UINT32 PsciState; 76 } EFI_ARM_ERROR_RECORD; 77 78 /// 79 /// ARM Processor Error Information Structure 80 /// 81 typedef struct { 82 UINT64 ValidationBits : 16; 83 UINT64 TransactionType : 2; 84 UINT64 Operation : 4; 85 UINT64 Level : 3; 86 UINT64 ProcessorContextCorrupt : 1; 87 UINT64 Corrected : 1; 88 UINT64 PrecisePC : 1; 89 UINT64 RestartablePC : 1; 90 UINT64 Reserved : 34; 91 } EFI_ARM_CACHE_ERROR_STRUCTURE; 92 93 typedef struct { 94 UINT64 ValidationBits : 16; 95 UINT64 TransactionType : 2; 96 UINT64 Operation : 4; 97 UINT64 Level : 3; 98 UINT64 ProcessorContextCorrupt : 1; 99 UINT64 Corrected : 1; 100 UINT64 PrecisePC : 1; 101 UINT64 RestartablePC : 1; 102 UINT64 Reserved : 34; 103 } EFI_ARM_TLB_ERROR_STRUCTURE; 104 105 typedef struct { 106 UINT64 ValidationBits : 16; 107 UINT64 TransactionType : 2; 108 UINT64 Operation : 4; 109 UINT64 Level : 3; 110 UINT64 ProcessorContextCorrupt : 1; 111 UINT64 Corrected : 1; 112 UINT64 PrecisePC : 1; 113 UINT64 RestartablePC : 1; 114 UINT64 ParticipationType : 2; 115 UINT64 TimeOut : 1; 116 UINT64 AddressSpace : 2; 117 UINT64 MemoryAddressAttributes : 8; 118 UINT64 AccessMode : 1; 119 UINT64 Reserved : 19; 120 } EFI_ARM_BUS_ERROR_STRUCTURE; 121 122 typedef union { 123 EFI_ARM_CACHE_ERROR_STRUCTURE CacheError; 124 EFI_ARM_TLB_ERROR_STRUCTURE TlbError; 125 EFI_ARM_BUS_ERROR_STRUCTURE BusError; 126 } EFI_ARM_ERROR_INFORMATION_STRUCTURE; 127 128 typedef struct { 129 UINT8 Version; 130 UINT8 Length; 131 UINT16 ValidationBits; 132 UINT8 Type; 133 UINT16 MultipleError; 134 UINT8 Flags; 135 EFI_ARM_ERROR_INFORMATION_STRUCTURE ErrorInformation; 136 UINT64 VirtualFaultAddress; 137 UINT64 PhysicalFaultAddress; 138 } EFI_ARM_ERROR_INFORMATION_ENTRY; 139 140 /// 141 /// ARM Processor Context Information Structure 142 /// 143 typedef struct { 144 UINT16 Version; 145 UINT16 RegisterContextType; 146 UINT32 RegisterArraySize; 147 } EFI_ARM_CONTEXT_INFORMATION_HEADER; 148 149 /// 150 /// ARM Processor Context Register Types 151 /// 152 #define EFI_ARM_CONTEXT_TYPE_AARCH32_GPR 0 153 #define EFI_ARM_CONTEXT_TYPE_AARCH32_EL1 1 154 #define EFI_ARM_CONTEXT_TYPE_AARCH32_EL2 2 155 #define EFI_ARM_CONTEXT_TYPE_AARCH32_SECURE 3 156 #define EFI_ARM_CONTEXT_TYPE_AARCH64_GPR 4 157 #define EFI_ARM_CONTEXT_TYPE_AARCH64_EL1 5 158 #define EFI_ARM_CONTEXT_TYPE_AARCH64_EL2 6 159 #define EFI_ARM_CONTEXT_TYPE_AARCH64_EL3 7 160 #define EFI_ARM_CONTEXT_TYPE_MISC 8 161 162 typedef struct { 163 UINT32 R0; 164 UINT32 R1; 165 UINT32 R2; 166 UINT32 R3; 167 UINT32 R4; 168 UINT32 R5; 169 UINT32 R6; 170 UINT32 R7; 171 UINT32 R8; 172 UINT32 R9; 173 UINT32 R10; 174 UINT32 R11; 175 UINT32 R12; 176 UINT32 R13_sp; 177 UINT32 R14_lr; 178 UINT32 R15_pc; 179 } EFI_ARM_V8_AARCH32_GPR; 180 181 typedef struct { 182 UINT32 Dfar; 183 UINT32 Dfsr; 184 UINT32 Ifar; 185 UINT32 Isr; 186 UINT32 Mair0; 187 UINT32 Mair1; 188 UINT32 Midr; 189 UINT32 Mpidr; 190 UINT32 Nmrr; 191 UINT32 Prrr; 192 UINT32 Sctlr_Ns; 193 UINT32 Spsr; 194 UINT32 Spsr_Abt; 195 UINT32 Spsr_Fiq; 196 UINT32 Spsr_Irq; 197 UINT32 Spsr_Svc; 198 UINT32 Spsr_Und; 199 UINT32 Tpidrprw; 200 UINT32 Tpidruro; 201 UINT32 Tpidrurw; 202 UINT32 Ttbcr; 203 UINT32 Ttbr0; 204 UINT32 Ttbr1; 205 UINT32 Dacr; 206 } EFI_ARM_AARCH32_EL1_CONTEXT_REGISTERS; 207 208 typedef struct { 209 UINT32 Elr_Hyp; 210 UINT32 Hamair0; 211 UINT32 Hamair1; 212 UINT32 Hcr; 213 UINT32 Hcr2; 214 UINT32 Hdfar; 215 UINT32 Hifar; 216 UINT32 Hpfar; 217 UINT32 Hsr; 218 UINT32 Htcr; 219 UINT32 Htpidr; 220 UINT32 Httbr; 221 UINT32 Spsr_Hyp; 222 UINT32 Vtcr; 223 UINT32 Vttbr; 224 UINT32 Dacr32_El2; 225 } EFI_ARM_AARCH32_EL2_CONTEXT_REGISTERS; 226 227 typedef struct { 228 UINT32 Sctlr_S; 229 UINT32 Spsr_Mon; 230 } EFI_ARM_AARCH32_SECURE_CONTEXT_REGISTERS; 231 232 typedef struct { 233 UINT64 X0; 234 UINT64 X1; 235 UINT64 X2; 236 UINT64 X3; 237 UINT64 X4; 238 UINT64 X5; 239 UINT64 X6; 240 UINT64 X7; 241 UINT64 X8; 242 UINT64 X9; 243 UINT64 X10; 244 UINT64 X11; 245 UINT64 X12; 246 UINT64 X13; 247 UINT64 X14; 248 UINT64 X15; 249 UINT64 X16; 250 UINT64 X17; 251 UINT64 X18; 252 UINT64 X19; 253 UINT64 X20; 254 UINT64 X21; 255 UINT64 X22; 256 UINT64 X23; 257 UINT64 X24; 258 UINT64 X25; 259 UINT64 X26; 260 UINT64 X27; 261 UINT64 X28; 262 UINT64 X29; 263 UINT64 X30; 264 UINT64 Sp; 265 } EFI_ARM_V8_AARCH64_GPR; 266 267 typedef struct { 268 UINT64 Elr_El1; 269 UINT64 Esr_El1; 270 UINT64 Far_El1; 271 UINT64 Isr_El1; 272 UINT64 Mair_El1; 273 UINT64 Midr_El1; 274 UINT64 Mpidr_El1; 275 UINT64 Sctlr_El1; 276 UINT64 Sp_El0; 277 UINT64 Sp_El1; 278 UINT64 Spsr_El1; 279 UINT64 Tcr_El1; 280 UINT64 Tpidr_El0; 281 UINT64 Tpidr_El1; 282 UINT64 Tpidrro_El0; 283 UINT64 Ttbr0_El1; 284 UINT64 Ttbr1_El1; 285 } EFI_ARM_AARCH64_EL1_CONTEXT_REGISTERS; 286 287 typedef struct { 288 UINT64 Elr_El2; 289 UINT64 Esr_El2; 290 UINT64 Far_El2; 291 UINT64 Hacr_El2; 292 UINT64 Hcr_El2; 293 UINT64 Hpfar_El2; 294 UINT64 Mair_El2; 295 UINT64 Sctlr_El2; 296 UINT64 Sp_El2; 297 UINT64 Spsr_El2; 298 UINT64 Tcr_El2; 299 UINT64 Tpidr_El2; 300 UINT64 Ttbr0_El2; 301 UINT64 Vtcr_El2; 302 UINT64 Vttbr_El2; 303 } EFI_ARM_AARCH64_EL2_CONTEXT_REGISTERS; 304 305 typedef struct { 306 UINT64 Elr_El3; 307 UINT64 Esr_El3; 308 UINT64 Far_El3; 309 UINT64 Mair_El3; 310 UINT64 Sctlr_El3; 311 UINT64 Sp_El3; 312 UINT64 Spsr_El3; 313 UINT64 Tcr_El3; 314 UINT64 Tpidr_El3; 315 UINT64 Ttbr0_El3; 316 } EFI_ARM_AARCH64_EL3_CONTEXT_REGISTERS; 317 318 typedef struct { 319 UINT64 MrsOp2 : 3; 320 UINT64 MrsCrm : 4; 321 UINT64 MrsCrn : 4; 322 UINT64 MrsOp1 : 3; 323 UINT64 MrsO0 : 1; 324 UINT64 Value : 64; 325 } EFI_ARM_MISC_CONTEXT_REGISTER; 326 327 json_object* cper_section_arm_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor); 328 329 #endif