Add extra definitions for existing sections.
diff --git a/cper-parse.c b/cper-parse.c
index 2bfb3cf..fa2d796 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -281,11 +281,6 @@
else if (guid_equal(§ion_descriptor->SectionType, &gEfiCxlMldPortErrorSectionGuid))
section_type_readable = "CXL MLD Port Component Error";
- //todo: How do you determine if this is a CXL component event?
- //perhaps refer to CXL Specification, Rev 2.0
- // if (guid_equal(§ion_descriptor->SectionType, &gEfiProcessorGenericErrorSectionGuid))
- // section_type_readable = "CXL Component Event";
-
json_object_object_add(section_type, "type", json_object_new_string(section_type_readable));
json_object_object_add(section_descriptor_ir, "sectionType", section_type);
diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c
index 58e97bf..8590414 100644
--- a/sections/cper-section-arm.c
+++ b/sections/cper-section-arm.c
@@ -50,7 +50,8 @@
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.
+ //This can't be made human readable, as it is unknown whether this will be the pre-PSCI 1.0 format
+ //or the newer Extended StateID format.
json_object_object_add(section_ir, "psciState", json_object_new_int(record->PsciState));
}
diff --git a/sections/cper-section-ccix-per.c b/sections/cper-section-ccix-per.c
index ae8a797..afba8d4 100644
--- a/sections/cper-section-ccix-per.c
+++ b/sections/cper-section-ccix-per.c
@@ -6,6 +6,7 @@
**/
#include <stdio.h>
#include "json.h"
+#include "b64.h"
#include "../edk/Cper.h"
#include "../cper-utils.h"
#include "cper-section-ccix-per.h"
@@ -28,8 +29,15 @@
json_object_object_add(section_ir, "ccixPortID", json_object_new_int(ccix_error->CcixPortId));
//CCIX PER Log.
- //todo: implement as described in Section 7.3.2 of CCIX Base Specification (Rev 1.0)
- //the PER Log structure notes the number of DWORDs in the record.
+ //This is formatted as described in Section 7.3.2 of CCIX Base Specification (Rev 1.0).
+ unsigned char* cur_pos = (unsigned char*)(ccix_error + 1);
+ int remaining_length = section - (void*)cur_pos + ccix_error->Length;
+ if (remaining_length > 0)
+ {
+ char* encoded = b64_encode(cur_pos, remaining_length);
+ json_object_object_add(section_ir, "ccixPERLog", json_object_new_string(encoded));
+ free(encoded);
+ }
return section_ir;
}
\ No newline at end of file
diff --git a/sections/cper-section-cxl-component.c b/sections/cper-section-cxl-component.c
index ab3b34f..cb950b7 100644
--- a/sections/cper-section-cxl-component.c
+++ b/sections/cper-section-cxl-component.c
@@ -6,6 +6,7 @@
**/
#include <stdio.h>
#include "json.h"
+#include "b64.h"
#include "../edk/Cper.h"
#include "../cper-utils.h"
#include "cper-section-cxl-component.h"
@@ -13,11 +14,41 @@
//Converts a single CXL component error CPER section into JSON IR.
json_object* cper_section_cxl_component_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
{
- //The length of the structure (bytes).
EFI_CXL_COMPONENT_EVENT_HEADER* cxl_error = (EFI_CXL_COMPONENT_EVENT_HEADER*)section;
json_object* section_ir = json_object_new_object();
+
+ //Length (bytes) for the entire structure.
+ json_object_object_add(section_ir, "length", json_object_new_uint64(cxl_error->Length));
- //todo: Figure out structure for CXL Component Event log (UEFI spec is a bit vague)
+ //Validation bits.
+ json_object* validation = bitfield_to_ir(cxl_error->ValidBits, 3, CXL_COMPONENT_ERROR_VALID_BITFIELD_NAMES);
+ json_object_object_add(section_ir, "validationBits", validation);
+
+ //Device ID.
+ json_object* device_id = json_object_new_object();
+ json_object_object_add(device_id, "vendorID", json_object_new_int(cxl_error->DeviceId.VendorId));
+ json_object_object_add(device_id, "deviceID", json_object_new_int(cxl_error->DeviceId.DeviceId));
+ json_object_object_add(device_id, "functionNumber", json_object_new_int(cxl_error->DeviceId.FunctionNumber));
+ json_object_object_add(device_id, "deviceNumber", json_object_new_int(cxl_error->DeviceId.DeviceNumber));
+ json_object_object_add(device_id, "busNumber", json_object_new_int(cxl_error->DeviceId.BusNumber));
+ json_object_object_add(device_id, "segmentNumber", json_object_new_int(cxl_error->DeviceId.SegmentNumber));
+ json_object_object_add(device_id, "slotNumber", json_object_new_int(cxl_error->DeviceId.SlotNumber));
+ json_object_object_add(section_ir, "deviceID", device_id);
+
+ //Device serial.
+ json_object_object_add(section_ir, "deviceSerial", json_object_new_uint64(cxl_error->DeviceSerial));
+
+ //The specification for this is defined within the CXL Specification Section 8.2.9.1.
+ unsigned char* cur_pos = (unsigned char*)(cxl_error + 1);
+ int remaining_len = section - (void*)cur_pos + cxl_error->Length;
+ if (remaining_len > 0)
+ {
+ json_object* event_log = json_object_new_object();
+ char* encoded = b64_encode(cur_pos, remaining_len);
+ json_object_object_add(event_log, "data", json_object_new_string(encoded));
+ free(encoded);
+ json_object_object_add(section_ir, "cxlComponentEventLog", event_log);
+ }
return section_ir;
}
\ No newline at end of file
diff --git a/sections/cper-section-cxl-component.h b/sections/cper-section-cxl-component.h
index 17dcedf..fa93950 100644
--- a/sections/cper-section-cxl-component.h
+++ b/sections/cper-section-cxl-component.h
@@ -4,6 +4,9 @@
#include "json.h"
#include "../edk/Cper.h"
+#define CXL_COMPONENT_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"deviceIDValid", "deviceSerialValid", \
+ "cxlComponentEventLogValid"}
+
///
/// CXL Generic Component Error Section
///
@@ -26,10 +29,6 @@
UINT64 DeviceSerial;
} EFI_CXL_COMPONENT_EVENT_HEADER;
-typedef struct {
- //todo: What is the structure for this? The UEFI spec is a bit vague.
-} EFI_CXL_COMPONENT_COMMON_RECORD_HEAD;
-
json_object* cper_section_cxl_component_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
#endif
\ No newline at end of file