Add support for platform memory 1 records.
diff --git a/cper-parse.c b/cper-parse.c
index bf34c67..eaef4a1 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -13,6 +13,7 @@
#include "sections/cper-section-generic.h"
#include "sections/cper-section-ia32x64.h"
#include "sections/cper-section-arm.h"
+#include "sections/cper-section-memory.h"
//Private pre-definitions.
json_object* cper_header_to_ir(EFI_COMMON_ERROR_RECORD_HEADER* header);
@@ -306,8 +307,8 @@
// // if (guid_equal(&descriptor->SectionType, &gEfiIpfProcessorErrorSectionGuid))
else if (guid_equal(&descriptor->SectionType, &gEfiArmProcessorErrorSectionGuid))
result = cper_section_arm_to_ir(section, descriptor);
- // if (guid_equal(&descriptor->SectionType, &gEfiPlatformMemoryErrorSectionGuid))
- // result = cper_section_platform_memory_to_ir(section);
+ else if (guid_equal(&descriptor->SectionType, &gEfiPlatformMemoryErrorSectionGuid))
+ result = cper_section_platform_memory_to_ir(section, descriptor);
// if (guid_equal(&descriptor->SectionType, &gEfiPcieErrorSectionGuid))
// result = cper_section_pcie_to_ir(section);
// if (guid_equal(&descriptor->SectionType, &gEfiFirmwareErrorSectionGuid))
diff --git a/cper-utils.c b/cper-utils.c
index ff28b50..c29b9df 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -12,6 +12,30 @@
//The available severity types for CPER.
const char* CPER_SEVERITY_TYPES[4] = {"Recoverable", "Fatal", "Corrected", "Informational"};
+//Converts the given generic CPER error status to JSON IR.
+json_object* cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS* error_status)
+{
+ json_object* error_status_ir = json_object_new_object();
+
+ //Error type.
+ json_object_object_add(error_status_ir, "errorType", integer_to_readable_pair_with_desc(error_status->Type, 18,
+ CPER_GENERIC_ERROR_TYPES_KEYS,
+ CPER_GENERIC_ERROR_TYPES_VALUES,
+ CPER_GENERIC_ERROR_TYPES_DESCRIPTIONS,
+ "Unknown (Reserved)"));
+
+ //Boolean bit fields.
+ json_object_object_add(error_status_ir, "addressSignal", json_object_new_boolean(error_status->AddressSignal));
+ json_object_object_add(error_status_ir, "controlSignal", json_object_new_boolean(error_status->ControlSignal));
+ json_object_object_add(error_status_ir, "dataSignal", json_object_new_boolean(error_status->DataSignal));
+ json_object_object_add(error_status_ir, "detectedByResponder", json_object_new_boolean(error_status->DetectedByResponder));
+ json_object_object_add(error_status_ir, "detectedByRequester", json_object_new_boolean(error_status->DetectedByRequester));
+ json_object_object_add(error_status_ir, "firstError", json_object_new_boolean(error_status->FirstError));
+ json_object_object_add(error_status_ir, "overflowNotLogged", json_object_new_boolean(error_status->OverflowNotLogged));
+
+ return error_status_ir;
+}
+
//Converts a single uniform struct of UINT64s into intermediate JSON IR format, given names for each field in byte order.
json_object* uniform_struct64_to_ir(UINT64* start, int len, const char* names[])
{
diff --git a/cper-utils.h b/cper-utils.h
index 635bcd6..f7878d4 100644
--- a/cper-utils.h
+++ b/cper-utils.h
@@ -4,6 +4,7 @@
#define GUID_STRING_LENGTH 30
#define TIMESTAMP_LENGTH 24
+json_object* cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS* error_status);
json_object* uniform_struct_to_ir(UINT32* start, int len, const char* names[]);
json_object* uniform_struct64_to_ir(UINT64* start, int len, const char* names[]);
json_object* integer_to_readable_pair(int value, int len, int keys[], const char* values[], const char* default_value);
diff --git a/edk/Cper.c b/edk/Cper.c
index 6f557d8..d11dfdd 100644
--- a/edk/Cper.c
+++ b/edk/Cper.c
@@ -27,6 +27,7 @@
//EFI_GUID gEfiIpfProcessorErrorSectionGuid = { 0xe429faf1, 0x3cb7, 0x11d4, { 0xb, 0xca, 0x7, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 }};
EFI_GUID gEfiArmProcessorErrorSectionGuid = { 0xe19e3d16, 0xbc11, 0x11e4, { 0x9c, 0xaa, 0xc2, 0x05, 0x1d, 0x5d, 0x46, 0xb0 }};
EFI_GUID gEfiPlatformMemoryErrorSectionGuid = { 0xa5bc1114, 0x6f64, 0x4ede, { 0xb8, 0x63, 0x3e, 0x83, 0xed, 0x7c, 0x83, 0xb1 }};
+EFI_GUID gEfiPlatformMemoryError2SectionGuid = { 0x61EC04FC, 0x48E6, 0xD813, { 0x25, 0xC9, 0x8D, 0xAA, 0x44, 0x75, 0x0B, 0x12 }};
EFI_GUID gEfiPcieErrorSectionGuid = { 0xd995e954, 0xbbc1, 0x430f, { 0xad, 0x91, 0xb4, 0x4d, 0xcb, 0x3c, 0x6f, 0x35 }};
EFI_GUID gEfiFirmwareErrorSectionGuid = { 0x81212a96, 0x09ed, 0x4996, { 0x94, 0x71, 0x8d, 0x72, 0x9c, 0x8e, 0x69, 0xed }};
EFI_GUID gEfiPciBusErrorSectionGuid = { 0xc5753963, 0x3b84, 0x4095, { 0xbf, 0x78, 0xed, 0xda, 0xd3, 0xf9, 0xc9, 0xdd }};
diff --git a/edk/Cper.h b/edk/Cper.h
index 6c0014c..a73c6eb 100644
--- a/edk/Cper.h
+++ b/edk/Cper.h
@@ -1021,6 +1021,33 @@
} EFI_GENERIC_ERROR_STATUS;
///
+/// CPER Generic Error Codes
+///
+#define CPER_GENERIC_ERROR_TYPES_KEYS (int []){1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}
+#define CPER_GENERIC_ERROR_TYPES_VALUES (const char*[]){"ERR_INTERNAL", "ERR_BUS", "ERR_MEM", "ERR_TLB", \
+ "ERR_CACHE", "ERR_FUNCTION", "ERR_SELFTEST", "ERR_FLOW", "ERR_MAP", "ERR_IMPROPER", "ERR_UNIMPL", \
+ "ERR_LOL", "ERR_RESPONSE", "ERR_PARITY", "ERR_PROTOCOL", "ERR_ERROR", "ERR_TIMEOUT", "ERR_POISONED"}
+#define CPER_GENERIC_ERROR_TYPES_DESCRIPTIONS (const char*[]){\
+ "Error detected internal to the component.", \
+ "Error detected in the bus.", \
+ "Storage error in memory (DRAM).", \
+ "Storage error in TLB.", \
+ "Storage error in cache.", \
+ "Error in one or more functional units.", \
+ "Component failed self test.", \
+ "Overflow or underflow of internal queue.", \
+ "Virtual address not found on IO-TLB or IO-PDIR.", \
+ "Improper access error.", \
+ "Access to a memory address which is not mapped to any component.", \
+ "Loss of Lockstep error.", \
+ "Response not associated with a request.", \
+ "Bus parity error (must also set the A, C, or D bits).", \
+ "Detection of a protocol error.", \
+ "Detection of a PATH_ERROR.", \
+ "Bus operation timeout.", \
+ "A read was issued to data that has been poisoned."}
+
+///
/// Error Type
///
typedef enum {
@@ -1495,6 +1522,7 @@
//extern EFI_GUID gEfiIpfProcessorErrorSectionGuid;
extern EFI_GUID gEfiArmProcessorErrorSectionGuid;
extern EFI_GUID gEfiPlatformMemoryErrorSectionGuid;
+extern EFI_GUID gEfiPlatformMemoryError2SectionGuid;
extern EFI_GUID gEfiPcieErrorSectionGuid;
extern EFI_GUID gEfiFirmwareErrorSectionGuid;
extern EFI_GUID gEfiPciBusErrorSectionGuid;
diff --git a/sections/cper-section-memory.c b/sections/cper-section-memory.c
index d7c8d5c..13f97c2 100644
--- a/sections/cper-section-memory.c
+++ b/sections/cper-section-memory.c
@@ -11,7 +11,7 @@
#include "cper-section-memory.h"
//Converts a single memory error CPER section into JSON IR.
-json_object* cper_section_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
+json_object* cper_section_platform_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
{
EFI_PLATFORM_MEMORY_ERROR_DATA* memory_error = (EFI_PLATFORM_MEMORY_ERROR_DATA*)section;
json_object* section_ir = json_object_new_object();
@@ -21,10 +21,56 @@
json_object_object_add(section_ir, "validationBits", validation);
//Error status.
- json_object* error_status = json_object_new_object();
- json_object_object_add(error_status, "errorType", integer_to_readable_pair_with_desc(memory_error->ErrorStatus.Type, 18,
- MEMORY_ERROR_ERROR_TYPES_KEYS,
- MEMORY_ERROR_ERROR_TYPES_VALUES,
- MEMORY_ERROR_ERROR_TYPES_DESCRIPTIONS,
- "Unknown (Reserved)"));
+ json_object* error_status = cper_generic_error_status_to_ir(&memory_error->ErrorStatus);
+ json_object_object_add(section_ir, "errorStatus", error_status);
+
+ //Miscellaneous numeric fields.
+ json_object_object_add(section_ir, "physicalAddress", json_object_new_uint64(memory_error->PhysicalAddress));
+ json_object_object_add(section_ir, "physicalAddressMask", json_object_new_uint64(memory_error->PhysicalAddressMask));
+ json_object_object_add(section_ir, "node", json_object_new_uint64(memory_error->Node));
+ json_object_object_add(section_ir, "card", json_object_new_uint64(memory_error->Card));
+ json_object_object_add(section_ir, "moduleRank", json_object_new_uint64(memory_error->ModuleRank));
+ json_object_object_add(section_ir, "device", json_object_new_uint64(memory_error->Device));
+ json_object_object_add(section_ir, "row", json_object_new_uint64(memory_error->Row));
+ json_object_object_add(section_ir, "column", json_object_new_uint64(memory_error->Column));
+ json_object_object_add(section_ir, "bitPosition", json_object_new_uint64(memory_error->BitPosition));
+ json_object_object_add(section_ir, "requestorID", json_object_new_uint64(memory_error->RequestorId));
+ json_object_object_add(section_ir, "responderID", json_object_new_uint64(memory_error->ResponderId));
+ json_object_object_add(section_ir, "targetID", json_object_new_uint64(memory_error->TargetId));
+ json_object_object_add(section_ir, "rankNumber", json_object_new_uint64(memory_error->RankNum));
+ json_object_object_add(section_ir, "cardSmbiosHandle", json_object_new_uint64(memory_error->CardHandle));
+ json_object_object_add(section_ir, "moduleSmbiosHandle", json_object_new_uint64(memory_error->ModuleHandle));
+
+ //Bank.
+ json_object* bank = json_object_new_object();
+ json_object_object_add(bank, "address", json_object_new_uint64(memory_error->Bank & 0xFF));
+ json_object_object_add(bank, "group", json_object_new_uint64(memory_error->Bank >> 8));
+ json_object_object_add(section_ir, "bank", bank);
+
+ //Memory error type.
+ json_object* memory_error_type = integer_to_readable_pair(memory_error->ErrorType, 16,
+ MEMORY_ERROR_TYPES_KEYS,
+ MEMORY_ERROR_TYPES_VALUES,
+ "Unknown (Reserved)");
+ json_object_object_add(section_ir, "memoryErrorType", memory_error_type);
+
+ //"Extended" row/column indication field + misc.
+ json_object* extended = json_object_new_object();
+ json_object_object_add(extended, "rowBit16", json_object_new_boolean(memory_error->Extended & 0b1));
+ json_object_object_add(extended, "rowBit17", json_object_new_boolean((memory_error->Extended >> 1) & 0b1));
+ json_object_object_add(extended, "chipIdentification", json_object_new_int(memory_error->Extended >> 5));
+ json_object_object_add(section_ir, "extended", extended);
+
+ return section_ir;
+}
+
+//Converts a single memory error 2 CPER section into JSON IR.
+json_object* cper_section_platform_memory2_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
+{
+ EFI_PLATFORM_MEMORY2_ERROR_DATA* memory_error = (EFI_PLATFORM_MEMORY2_ERROR_DATA*)section;
+ json_object* section_ir = json_object_new_object();
+
+ //... todo
+
+ return section_ir;
}
\ No newline at end of file
diff --git a/sections/cper-section-memory.h b/sections/cper-section-memory.h
index 929ee7f..bed02c9 100644
--- a/sections/cper-section-memory.h
+++ b/sections/cper-section-memory.h
@@ -10,30 +10,13 @@
"platformResponderIDValid", "memoryPlatformTargetValid", "memoryErrorTypeValid", "rankNumberValid", \
"cardHandleValid", "moduleHandleValid", "extendedRowBitsValid", "bankGroupValid", "bankAddressValid", \
"chipIdentificationValid"}
-#define MEMORY_ERROR_ERROR_TYPES_KEYS (int []){1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}
-#define MEMORY_ERROR_ERROR_TYPES_VALUES (const char*[]){"ERR_INTERNAL", "ERR_BUS", "ERR_MEM", "ERR_TLB", \
- "ERR_CACHE", "ERR_FUNCTION", "ERR_SELFTEST", "ERR_FLOW", "ERR_MAP", "ERR_IMPROPER", "ERR_UNIMPL", \
- "ERR_LOL", "ERR_RESPONSE", "ERR_PARITY", "ERR_PROTOCOL", "ERR_ERROR", "ERR_TIMEOUT", "ERR_POISONED"}
-#define MEMORY_ERROR_ERROR_TYPES_DESCRIPTIONS (const char*[]){\
- "Error detected internal to the component.", \
- "Error detected in the bus.", \
- "Storage error in memory (DRAM).", \
- "Storage error in TLB.", \
- "Storage error in cache.", \
- "Error in one or more functional units.", \
- "Component failed self test.", \
- "Overflow or underflow of internal queue.", \
- "Virtual address not found on IO-TLB or IO-PDIR.", \
- "Improper access error.", \
- "Access to a memory address which is not mapped to any component.", \
- "Loss of Lockstep error.", \
- "Response not associated with a request.", \
- "Bus parity error (must also set the A, C, or D bits).", \
- "Detection of a protocol error.", \
- "Detection of a PATH_ERROR.", \
- "Bus operation timeout.", \
- "A read was issued to data that has been poisoned."}
+#define MEMORY_ERROR_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
+#define MEMORY_ERROR_TYPES_VALUES (const char*[]){"Unknown", "No Error", "Single-bit ECC", \
+ "Multi-bit ECC", "Single-symbol ChipKill ECC", "Multi-symbol ChipKill ECC", "Master Abort", \
+ "Target Abort", "Parity Error", "Watchdog Timeout", "Invalid Address", "Mirror Broken", \
+ "Memory Sparing", "Scrub Corrected Error", "Scrub Uncorrected Error", "Physical Memory Map-out Event"}
-json_object* cper_section_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
+json_object* cper_section_platform_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
+json_object* cper_section_platform_memory2_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
#endif
\ No newline at end of file