Add all DMAR, CCIX, PCI, firmware conversions.
diff --git a/sections/cper-section-dmar-generic.c b/sections/cper-section-dmar-generic.c
index 26934f8..6d2460d 100644
--- a/sections/cper-section-dmar-generic.c
+++ b/sections/cper-section-dmar-generic.c
@@ -53,4 +53,25 @@
json_object_object_add(section_ir, "deviceAddress", json_object_new_uint64(firmware_error->DeviceAddr));
return section_ir;
+}
+
+//Converts a single generic DMAR CPER-JSON section into CPER binary, outputting to the given stream.
+void ir_section_dmar_generic_to_cper(json_object* section, FILE* out)
+{
+ EFI_DMAR_GENERIC_ERROR_DATA* section_cper =
+ (EFI_DMAR_GENERIC_ERROR_DATA*)calloc(1, sizeof(EFI_DMAR_GENERIC_ERROR_DATA));
+
+ //Record fields.
+ section_cper->RequesterId = (UINT16)json_object_get_int(json_object_object_get(section, "requesterID"));
+ section_cper->SegmentNumber = (UINT16)json_object_get_int(json_object_object_get(section, "segmentNumber"));
+ section_cper->FaultReason = (UINT8)readable_pair_to_integer(json_object_object_get(section, "faultReason"));
+ section_cper->AccessType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "accessType"));
+ section_cper->AddressType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "addressType"));
+ section_cper->ArchType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "archType"));
+ section_cper->DeviceAddr = json_object_get_uint64(json_object_object_get(section, "deviceAddress"));
+
+ //Write to stream, free resources.
+ fwrite(§ion_cper, sizeof(section_cper), 1, out);
+ fflush(out);
+ free(section_cper);
}
\ No newline at end of file