Add PCI bus section support.
diff --git a/cper-parse.c b/cper-parse.c
index ded404c..19316bc 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -15,6 +15,7 @@
#include "sections/cper-section-arm.h"
#include "sections/cper-section-memory.h"
#include "sections/cper-section-pcie.h"
+#include "sections/cper-section-pci-bus.h"
//Private pre-definitions.
json_object* cper_header_to_ir(EFI_COMMON_ERROR_RECORD_HEADER* header);
@@ -316,8 +317,8 @@
result = cper_section_pcie_to_ir(section, descriptor);
// if (guid_equal(&descriptor->SectionType, &gEfiFirmwareErrorSectionGuid))
// result = cper_section_firmware_error_to_ir(section);
- // if (guid_equal(&descriptor->SectionType, &gEfiPciBusErrorSectionGuid))
- // result = cper_section_pci_bus_to_ir(section);
+ else if (guid_equal(&descriptor->SectionType, &gEfiPciBusErrorSectionGuid))
+ result = cper_section_pci_bus_to_ir(section, descriptor);
// if (guid_equal(&descriptor->SectionType, &gEfiPciDevErrorSectionGuid))
// result = cper_section_pci_dev_to_ir(section);
// if (guid_equal(&descriptor->SectionType, &gEfiDMArGenericErrorSectionGuid))
diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c
new file mode 100644
index 0000000..a219674
--- /dev/null
+++ b/sections/cper-section-pci-bus.c
@@ -0,0 +1,49 @@
+/**
+ * Describes functions for converting PCI/PCI-X bus CPER sections from binary and JSON format
+ * into an intermediate format.
+ *
+ * Author: Lawrence.Tang@arm.com
+ **/
+#include <stdio.h>
+#include "json.h"
+#include "../edk/Cper.h"
+#include "../cper-utils.h"
+#include "cper-section-pci-bus.h"
+
+//Converts a single PCI/PCI-X bus CPER section into JSON IR.
+json_object* cper_section_pci_bus_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
+{
+ EFI_PCI_PCIX_BUS_ERROR_DATA* bus_error = (EFI_PCI_PCIX_BUS_ERROR_DATA*)section;
+ json_object* section_ir = json_object_new_object();
+
+ //Validation bits.
+ json_object* validation = bitfield_to_ir(bus_error->ValidFields, 9, PCI_BUS_ERROR_VALID_BITFIELD_NAMES);
+ json_object_object_add(section_ir, "validationBits", validation);
+
+ //Error status.
+ json_object* error_status = cper_generic_error_status_to_ir(&bus_error->ErrorStatus);
+ json_object_object_add(section_ir, "errorStatus", error_status);
+
+ //PCI bus error type.
+ json_object* error_type = integer_to_readable_pair(bus_error->Type, 8,
+ PCI_BUS_ERROR_TYPES_KEYS,
+ PCI_BUS_ERROR_TYPES_VALUES,
+ "Unknown (Reserved)");
+ json_object_object_add(section_ir, "errorType", error_type);
+
+ //Bus ID.
+ json_object* bus_id = json_object_new_object();
+ json_object_object_add(bus_id, "busNumber", json_object_new_int(bus_error->BusId & 0xFF));
+ json_object_object_add(bus_id, "segmentNumber", json_object_new_int(bus_error->BusId >> 8));
+ json_object_object_add(section_ir, "busID", bus_id);
+
+ //Miscellaneous numeric fields.
+ json_object_object_add(section_ir, "busAddress", json_object_new_uint64(bus_error->BusAddress));
+ json_object_object_add(section_ir, "busData", json_object_new_uint64(bus_error->BusData));
+ json_object_object_add(section_ir, "busCommandType", json_object_new_string(bus_error->BusCommand == 0 ? "PCI" : "PCI-X"));
+ json_object_object_add(section_ir, "busRequestorID", json_object_new_uint64(bus_error->RequestorId));
+ json_object_object_add(section_ir, "busCompleterID", json_object_new_uint64(bus_error->ResponderId));
+ json_object_object_add(section_ir, "targetID", json_object_new_uint64(bus_error->TargetId));
+
+ return section_ir;
+}
\ No newline at end of file
diff --git a/sections/cper-section-pci-bus.h b/sections/cper-section-pci-bus.h
new file mode 100644
index 0000000..e0e1bbb
--- /dev/null
+++ b/sections/cper-section-pci-bus.h
@@ -0,0 +1,17 @@
+#ifndef CPER_SECTION_PCI_BUS_H
+#define CPER_SECTION_PCI_BUS_H
+
+#include "json.h"
+#include "../edk/Cper.h"
+
+#define PCI_BUS_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"errorStatusValid", "errorTypeValid", \
+ "busIDValid", "busAddressValid", "busDataValid", "commandValid", "requestorIDValid", "completerIDValid", \
+ "targetIDValid"}
+#define PCI_BUS_ERROR_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7}
+#define PCI_BUS_ERROR_TYPES_VALUES (const char*[]){"Unknown/OEM Specific Error", "Data Parity Error", \
+ "System Error", "Master Abort", "Bus Timeout/No Device Present (No DEVSEL#)", \
+ "Master Data Parity Error", "Address Parity Error", "Command Parity Error"}
+
+json_object* cper_section_pci_bus_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
+
+#endif
\ No newline at end of file