Add support for platform memory 1 records.
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