Add all DMAR, CCIX, PCI, firmware conversions.
diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c
index a219674..db034d1 100644
--- a/sections/cper-section-pci-bus.c
+++ b/sections/cper-section-pci-bus.c
@@ -46,4 +46,39 @@
json_object_object_add(section_ir, "targetID", json_object_new_uint64(bus_error->TargetId));
return section_ir;
+}
+
+//Converts a single provided PCI/PCI-X bus CPER-JSON section into CPER binary, outputting to the
+//provided stream.
+void ir_section_pci_bus_to_cper(json_object* section, FILE* out)
+{
+ EFI_PCI_PCIX_BUS_ERROR_DATA* section_cper =
+ (EFI_PCI_PCIX_BUS_ERROR_DATA*)calloc(1, sizeof(EFI_PCI_PCIX_BUS_ERROR_DATA));
+
+ //Validation bits.
+ section_cper->ValidFields = ir_to_bitfield(json_object_object_get(section, "validationBits"),
+ 9, PCI_BUS_ERROR_VALID_BITFIELD_NAMES);
+
+ //Error status.
+ ir_generic_error_status_to_cper(json_object_object_get(section, "errorStatus"), §ion_cper->ErrorStatus);
+
+ //Bus ID.
+ json_object* bus_id = json_object_object_get(section, "busID");
+ UINT16 bus_number = (UINT8)json_object_get_int(json_object_object_get(bus_id, "busNumber"));
+ UINT16 segment_number = (UINT8)json_object_get_int(json_object_object_get(bus_id, "segmentNumber"));
+ section_cper->BusId = bus_number + (segment_number << 8);
+
+ //Remaining fields.
+ section_cper->Type = (UINT16)readable_pair_to_integer(json_object_object_get(section, "errorType"));
+ section_cper->BusAddress = json_object_get_uint64(json_object_object_get(section, "busAddress"));
+ section_cper->BusData = json_object_get_uint64(json_object_object_get(section, "busData"));
+ section_cper->BusCommand = json_object_get_string(json_object_object_get(section, "busCommand")) == "PCI" ? 0 : 1;
+ section_cper->RequestorId = json_object_get_uint64(json_object_object_get(section, "requestorID"));
+ section_cper->ResponderId = json_object_get_uint64(json_object_object_get(section, "responderID"));
+ section_cper->TargetId = json_object_get_uint64(json_object_object_get(section, "targetID"));
+
+ //Write to stream, free resources.
+ fwrite(§ion_cper, sizeof(section_cper), 1, out);
+ fflush(out);
+ free(section_cper);
}
\ No newline at end of file