Include hex decode for human readable fields
Hexadecimal decode for some fields like deviceAddress
make sense to be represented in hex over decimal to make
scripting and human-usability easier.
Change-Id: I7d0d100162bc681c3c6885ca01ed23020c3b5063
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/include/libcper/Cper.h b/include/libcper/Cper.h
index e2b5b8c..82f68c1 100644
--- a/include/libcper/Cper.h
+++ b/include/libcper/Cper.h
@@ -52,6 +52,12 @@
#define EFI_ERROR_TIME_STAMP_PRECISE BIT0
///
+/// Hexadecimal string representation of a 64bit integer
+/// 16 bits + 2 char + 1 null termination
+///
+#define EFI_UINT64_HEX_STRING_LEN 19
+
+///
/// The timestamp correlates to the time when the error information was collected
/// by the system software and may not necessarily represent the time of the error
/// event. The timestamp contains the local time in BCD format.
diff --git a/sections/cper-section-memory.c b/sections/cper-section-memory.c
index 68e63af..4aeae43 100644
--- a/sections/cper-section-memory.c
+++ b/sections/cper-section-memory.c
@@ -70,6 +70,13 @@
json_object_object_add(
section_ir, "physicalAddress",
json_object_new_uint64(memory_error->PhysicalAddress));
+
+ char hexstring_buf[EFI_UINT64_HEX_STRING_LEN];
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%016llX",
+ memory_error->PhysicalAddress);
+ json_object_object_add(section_ir, "physicalAddressHex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(
section_ir, "physicalAddressMask",
json_object_new_uint64(memory_error->PhysicalAddressMask));
@@ -167,6 +174,13 @@
json_object_object_add(
section_ir, "physicalAddress",
json_object_new_uint64(memory_error->PhysicalAddress));
+
+ char hexstring_buf[EFI_UINT64_HEX_STRING_LEN];
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%016llX",
+ memory_error->PhysicalAddress);
+ json_object_object_add(section_ir, "physicalAddressHex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(
section_ir, "physicalAddressMask",
json_object_new_uint64(memory_error->PhysicalAddressMask));
diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c
index 154c1cf..ab6e921 100644
--- a/sections/cper-section-pci-bus.c
+++ b/sections/cper-section-pci-bus.c
@@ -52,10 +52,23 @@
json_object_object_add(
section_ir, "busCommandType",
json_object_new_string(command_type == 0 ? "PCI" : "PCI-X"));
+
json_object_object_add(section_ir, "busRequestorID",
json_object_new_uint64(bus_error->RequestorId));
+
+ char hexstring_buf[EFI_UINT64_HEX_STRING_LEN];
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%016llX",
+ bus_error->RequestorId);
+ json_object_object_add(section_ir, "busRequestorIDHex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(section_ir, "busCompleterID",
json_object_new_uint64(bus_error->ResponderId));
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%016llX",
+ bus_error->ResponderId);
+ json_object_object_add(section_ir, "busCompleterIDHex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(section_ir, "targetID",
json_object_new_uint64(bus_error->TargetId));
diff --git a/sections/cper-section-pcie.c b/sections/cper-section-pcie.c
index 41cebb3..ae91cc1 100644
--- a/sections/cper-section-pcie.c
+++ b/sections/cper-section-pcie.c
@@ -71,6 +71,13 @@
json_object_object_add(
device_id, "deviceID",
json_object_new_uint64(pcie_error->DevBridge.DeviceId));
+
+ char hexstring_buf[EFI_UINT64_HEX_STRING_LEN];
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%0X",
+ pcie_error->DevBridge.DeviceId);
+ json_object_object_add(device_id, "deviceIDHex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(device_id, "classCode",
json_object_new_uint64(class_id));
json_object_object_add(
@@ -154,6 +161,13 @@
json_object_object_add(
aer_capability_ir, "uncorrectable_error_status",
json_object_new_uint64(aer_decode->uncorrectable_error_status));
+
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%08" PRIX32,
+ aer_decode->uncorrectable_error_status);
+ json_object_object_add(aer_capability_ir,
+ "uncorrectable_error_status_hex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(
aer_capability_ir, "uncorrectable_error_mask",
json_object_new_uint64(aer_decode->uncorrectable_error_mask));
@@ -164,6 +178,13 @@
json_object_object_add(
aer_capability_ir, "correctable_error_status",
json_object_new_uint64(aer_decode->correctable_error_status));
+
+ snprintf(hexstring_buf, EFI_UINT64_HEX_STRING_LEN, "0x%08" PRIX32,
+ aer_decode->correctable_error_status);
+ json_object_object_add(aer_capability_ir,
+ "correctable_error_status_hex",
+ json_object_new_string(hexstring_buf));
+
json_object_object_add(
aer_capability_ir, "correctable_error_mask",
json_object_new_uint64(aer_decode->correctable_error_mask));
diff --git a/specification/json/sections/cper-memory.json b/specification/json/sections/cper-memory.json
index bdb01da..e2bd787 100644
--- a/specification/json/sections/cper-memory.json
+++ b/specification/json/sections/cper-memory.json
@@ -8,6 +8,7 @@
"memoryErrorType",
"extended",
"physicalAddress",
+ "physicalAddressHex",
"physicalAddressMask",
"node",
"card",
@@ -179,6 +180,9 @@
"type": "integer",
"description": "The physical address at which the memory error occurred."
},
+ "physicalAddressHex": {
+ "type": "string"
+ },
"physicalAddressMask": {
"type": "integer",
"description": "Defines the valid address bits in the Physical Address field. The mask specifies the granularity of the physical address."
diff --git a/specification/json/sections/cper-memory2.json b/specification/json/sections/cper-memory2.json
index 0f57f63..edc62ab 100644
--- a/specification/json/sections/cper-memory2.json
+++ b/specification/json/sections/cper-memory2.json
@@ -8,6 +8,7 @@
"memoryErrorType",
"status",
"physicalAddress",
+ "physicalAddressHex",
"physicalAddressMask",
"node",
"card",
@@ -178,6 +179,9 @@
"type": "integer",
"description": "The physical address at which the memory error occurred."
},
+ "physicalAddressHex": {
+ "type": "string"
+ },
"physicalAddressMask": {
"type": "integer",
"description": "Defines the valid address bits in the Physical Address field. The mask specifies the granularity of the physical address which is dependent on the hardware implementation factors such as interleaving."
diff --git a/specification/json/sections/cper-pci-bus.json b/specification/json/sections/cper-pci-bus.json
index 503c065..ba23e72 100644
--- a/specification/json/sections/cper-pci-bus.json
+++ b/specification/json/sections/cper-pci-bus.json
@@ -10,7 +10,9 @@
"busData",
"busCommandType",
"busRequestorID",
+ "busRequestorIDHex",
"busCompleterID",
+ "busCompleterIDHex",
"targetID"
],
"additionalProperties": false,
@@ -99,10 +101,16 @@
"type": "integer",
"description": "PCI Bus Requestor Id."
},
+ "busRequestorIDHex": {
+ "type": "string"
+ },
"busCompleterID": {
"type": "integer",
"description": "PCI Bus Responder Id."
},
+ "busCompleterIDHex": {
+ "type": "string"
+ },
"targetID": {
"type": "integer",
"description": "PCI Bus intended target identifier."
diff --git a/specification/json/sections/cper-pcie.json b/specification/json/sections/cper-pcie.json
index 79bd600..c9970ef 100644
--- a/specification/json/sections/cper-pcie.json
+++ b/specification/json/sections/cper-pcie.json
@@ -93,6 +93,7 @@
"required": [
"vendorID",
"deviceID",
+ "deviceIDHex",
"classCode",
"functionNumber",
"deviceNumber",
@@ -108,6 +109,9 @@
"deviceID": {
"type": "integer"
},
+ "deviceIDHex": {
+ "type": "string"
+ },
"classCode": {
"type": "integer"
},
@@ -173,6 +177,9 @@
"uncorrectable_error_status": {
"type": "integer"
},
+ "uncorrectable_error_status_hex": {
+ "type": "string"
+ },
"uncorrectable_error_mask": {
"type": "integer"
},
@@ -182,6 +189,9 @@
"correctable_error_status": {
"type": "integer"
},
+ "correctable_error_status_hex": {
+ "type": "string"
+ },
"correctable_error_mask": {
"type": "integer"
},