Add more detailed ARM error structures.
diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c
index 4dcb6c3..cda8252 100644
--- a/sections/cper-section-arm.c
+++ b/sections/cper-section-arm.c
@@ -11,6 +11,12 @@
#include "../cper-utils.h"
#include "cper-section-arm.h"
+//Private pre-definitions.
+json_object* cper_arm_error_info_to_ir(EFI_ARM_PROCESSOR_ERROR_INFORMATION_ENTRY* error_info, void** cur_pos);
+json_object* cper_arm_cache_error_to_ir(EFI_ARM_PROCESSOR_CACHE_ERROR_STRUCTURE* cache_error);
+json_object* cper_arm_tlb_error_to_ir(EFI_ARM_PROCESSOR_TLB_ERROR_STRUCTURE* tlb_error);
+json_object* cper_arm_bus_error_to_ir(EFI_ARM_PROCESSOR_BUS_ERROR_STRUCTURE* bus_error);
+
//Converts the given processor-generic CPER section into JSON IR.
json_object* cper_section_arm_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
{
@@ -39,10 +45,89 @@
//Whether the processor is running, and the state of it if so.
json_object_object_add(section_ir, "running", json_object_new_boolean(record->RunningState));
- if (record->RunningState)
+ if (record->RunningState >> 31)
{
- //...
+ //Bit 32 of running state is on, so PSCI state information is included.
+ //todo: Look at how to make this human readable from the ARM PSCI document.
+ json_object_object_add(section_ir, "psciState", json_object_new_int(record->PsciState));
}
+ //Processor error structures.
+ json_object* error_info_array = json_object_new_array();
+ EFI_ARM_PROCESSOR_ERROR_INFORMATION_ENTRY* cur_error = (EFI_ARM_PROCESSOR_ERROR_INFORMATION_ENTRY*)(record + 1);
+ for (int i=0; i<record->ErrInfoNum; i++)
+ {
+ json_object_array_add(error_info_array, cper_arm_error_info_to_ir(cur_error, (void*)&cur_error));
+ //Dynamically sized structure, so pointer is controlled within the above function.
+ }
return section_ir;
+}
+
+//Converts a single ARM Process Error Information structure into JSON IR.
+json_object* cper_arm_error_info_to_ir(EFI_ARM_PROCESSOR_ERROR_INFORMATION_ENTRY* error_info, void** cur_pos)
+{
+ json_object* error_info_ir = json_object_new_object();
+
+ //Version, length.
+ json_object_object_add(error_info_ir, "version", json_object_new_int(error_info->Version));
+ json_object_object_add(error_info_ir, "version", json_object_new_int(error_info->Length));
+
+ //Validation bitfield.
+ json_object* validation = bitfield_to_ir(error_info->ValidationBits, 5, ARM_PROCESSOR_ERROR_INFO_ENTRY_VALID_BITFIELD_NAMES);
+ json_object_object_add(error_info_ir, "validationBits", validation);
+
+ //The type of error information in this log.
+ //todo: The UEFI spec is ambiguous, what are the values for these??
+ json_object* error_type = integer_to_readable_pair(error_info->Type, 4,
+ ARM_PROCESSOR_ERROR_INFO_ENTRY_INFO_TYPES_KEYS,
+ ARM_PROCESSOR_ERROR_INFO_ENTRY_INFO_TYPES_VALUES,
+ "Unknown (Reserved)");
+ json_object_object_add(error_info_ir, "errorType", error_type);
+
+ //Multiple error count.
+ json_object* multiple_error = json_object_object_create();
+ json_object_object_add(multiple_error, "value", json_object_new_int(error_info->MultipleError));
+ json_object_object_add(multiple_error, "type",
+ json_object_new_string(error_info->MultipleError < 1 ? "Single Error" : "Multiple Errors"));
+ json_object_object_add(error_info_ir, "multipleError", multiple_error);
+
+ //Flags.
+ json_object* flags = bitfield_to_ir(error_info->Flags, 4, ARM_PROCESSOR_ERROR_INFO_ENTRY_FLAGS_NAMES);
+ json_object_object_add(error_info_ir, "flags", flags);
+
+ //Error information, split by type.
+ json_object* error_subinfo = NULL;
+ switch (error_info->Type)
+ {
+ case 0: //Cache
+ error_subinfo = cper_arm_cache_error_to_ir((EFI_ARM_PROCESSOR_CACHE_ERROR_STRUCTURE*)error_info->ErrorInformation);
+ break;
+ case 1: //TLB
+ error_subinfo = cper_arm_tlb_error_to_ir((EFI_ARM_PROCESSOR_TLB_ERROR_STRUCTURE*)error_info->ErrorInformation);
+ break;
+ case 2: //Bus
+ error_subinfo = cper_arm_bus_error_to_ir((EFI_ARM_PROCESSOR_BUS_ERROR_STRUCTURE*)error_info->ErrorInformation);
+ break;
+ }
+ json_object_object_add(error_info_ir, "errorInformation", error_subinfo);
+
+ return error_info_ir;
+}
+
+//Converts a single ARM cache error information structure into JSON IR format.
+json_object* cper_arm_cache_error_to_ir(EFI_ARM_PROCESSOR_CACHE_ERROR_STRUCTURE* cache_error)
+{
+ //todo
+}
+
+//Converts a single ARM TLB error information structure into JSON IR format.
+json_object* cper_arm_tlb_error_to_ir(EFI_ARM_PROCESSOR_TLB_ERROR_STRUCTURE* tlb_error)
+{
+ //todo
+}
+
+//Converts a single ARM bus error information structure into JSON IR format.
+json_object* cper_arm_bus_error_to_ir(EFI_ARM_PROCESSOR_BUS_ERROR_STRUCTURE* bus_error)
+{
+ //todo
}
\ No newline at end of file