Add firmware error record support.
diff --git a/cper-parse.c b/cper-parse.c
index 7772131..6ad7d2d 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -17,6 +17,7 @@
#include "sections/cper-section-pcie.h"
#include "sections/cper-section-pci-bus.h"
#include "sections/cper-section-pci-dev.h"
+#include "sections/cper-section-firmware.h"
//Private pre-definitions.
json_object* cper_header_to_ir(EFI_COMMON_ERROR_RECORD_HEADER* header);
@@ -316,8 +317,8 @@
result = cper_section_platform_memory2_to_ir(section, descriptor);
else if (guid_equal(&descriptor->SectionType, &gEfiPcieErrorSectionGuid))
result = cper_section_pcie_to_ir(section, descriptor);
- // if (guid_equal(&descriptor->SectionType, &gEfiFirmwareErrorSectionGuid))
- // result = cper_section_firmware_error_to_ir(section);
+ else if (guid_equal(&descriptor->SectionType, &gEfiFirmwareErrorSectionGuid))
+ result = cper_section_firmware_to_ir(section, descriptor);
else if (guid_equal(&descriptor->SectionType, &gEfiPciBusErrorSectionGuid))
result = cper_section_pci_bus_to_ir(section, descriptor);
else if (guid_equal(&descriptor->SectionType, &gEfiPciDevErrorSectionGuid))
diff --git a/sections/cper-section-firmware.c b/sections/cper-section-firmware.c
new file mode 100644
index 0000000..03ce456
--- /dev/null
+++ b/sections/cper-section-firmware.c
@@ -0,0 +1,36 @@
+/**
+ * Describes functions for converting firmware 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-firmware.h"
+
+//Converts a single firmware CPER section into JSON IR.
+json_object* cper_section_firmware_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
+{
+ EFI_FIRMWARE_ERROR_DATA* firmware_error = (EFI_FIRMWARE_ERROR_DATA*)section;
+ json_object* section_ir = json_object_new_object();
+
+ //Record type.
+ json_object* record_type = integer_to_readable_pair(firmware_error->ErrorType, 3,
+ FIRMWARE_ERROR_RECORD_TYPES_KEYS,
+ FIRMWARE_ERROR_RECORD_TYPES_VALUES,
+ "Unknown (Reserved)");
+ json_object_object_add(section_ir, "errorRecordType", record_type);
+
+ //Revision, record identifier.
+ json_object_object_add(section_ir, "revision", json_object_new_int(firmware_error->Revision));
+ json_object_object_add(section_ir, "recordID", json_object_new_uint64(firmware_error->RecordId));
+
+ //Record GUID.
+ char record_id_guid[GUID_STRING_LENGTH];
+ guid_to_string(record_id_guid, &firmware_error->RecordIdGuid);
+ json_object_object_add(section_ir, "recordIDGUID", json_object_new_string(record_id_guid));
+
+ return section_ir;
+}
\ No newline at end of file
diff --git a/sections/cper-section-firmware.h b/sections/cper-section-firmware.h
new file mode 100644
index 0000000..a879c12
--- /dev/null
+++ b/sections/cper-section-firmware.h
@@ -0,0 +1,13 @@
+#ifndef CPER_SECTION_FIRMWARE_H
+#define CPER_SECTION_FIRMWARE_H
+
+#include "json.h"
+#include "../edk/Cper.h"
+
+#define FIRMWARE_ERROR_RECORD_TYPES_KEYS (int []){0, 1, 2}
+#define FIRMWARE_ERROR_RECORD_TYPES_VALUES (const char*[]){"IPF SAL Error Record", \
+ "SOC Firmware Error Record (Type1 Legacy)", "SOC Firmware Error Record (Type2)"}
+
+json_object* cper_section_firmware_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
+
+#endif
\ No newline at end of file