/**
 * Describes high level functions for converting an entire CPER log, and functions for parsing 
 * CPER headers and section descriptions into an intermediate JSON format.
 * 
 * Author: Lawrence.Tang@arm.com
 **/

#include <stdio.h>
#include "json.h"
#include "b64.h"
#include "edk/Cper.h"
#include "cper-parse.h"
#include "cper-utils.h"
#include "sections/cper-section-generic.h"
#include "sections/cper-section-ia32x64.h"
#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"
#include "sections/cper-section-pci-dev.h"
#include "sections/cper-section-firmware.h"
#include "sections/cper-section-dmar-generic.h"
#include "sections/cper-section-dmar-vtd.h"
#include "sections/cper-section-dmar-iommu.h"
#include "sections/cper-section-ccix-per.h"
#include "sections/cper-section-cxl-protocol.h"
#include "sections/cper-section-ipf.h"
#include "sections/cper-section-cxl-component.h"

//Private pre-definitions.
json_object *cper_header_to_ir(EFI_COMMON_ERROR_RECORD_HEADER *header);
json_object *
cper_section_descriptor_to_ir(EFI_ERROR_SECTION_DESCRIPTOR *section_descriptor);
json_object *cper_section_to_ir(FILE *handle,
				EFI_ERROR_SECTION_DESCRIPTOR *descriptor);

//Reads a CPER log file at the given file location, and returns an intermediate
//JSON representation of this CPER record.
json_object *cper_to_ir(FILE *cper_file)
{
	//Ensure this is really a CPER log.
	EFI_COMMON_ERROR_RECORD_HEADER header;
	fseek(cper_file, 0, SEEK_SET);
	if (fread(&header, sizeof(EFI_COMMON_ERROR_RECORD_HEADER), 1,
		  cper_file) != 1) {
		printf("Invalid CPER file: Invalid length (log too short).\n");
		return NULL;
	}

	//Check if the header contains the magic bytes ("CPER").
	if (header.SignatureStart != EFI_ERROR_RECORD_SIGNATURE_START) {
		printf("Invalid CPER file: Invalid header (incorrect signature).\n");
		return NULL;
	}

	//Create the header JSON object from the read bytes.
	json_object *header_ir = cper_header_to_ir(&header);

	//Read the appropriate number of section descriptors & sections, and convert them into IR format.
	json_object *section_descriptors_ir = json_object_new_array();
	json_object *sections_ir = json_object_new_array();
	for (int i = 0; i < header.SectionCount; i++) {
		//Create the section descriptor.
		EFI_ERROR_SECTION_DESCRIPTOR section_descriptor;
		if (fread(&section_descriptor,
			  sizeof(EFI_ERROR_SECTION_DESCRIPTOR), 1,
			  cper_file) != 1) {
			printf("Invalid number of section headers: Header states %d sections, could not read section %d.\n",
			       header.SectionCount, i + 1);
			return NULL;
		}
		json_object_array_add(
			section_descriptors_ir,
			cper_section_descriptor_to_ir(&section_descriptor));

		//Read the section itself.
		json_object_array_add(sections_ir,
				      cper_section_to_ir(cper_file,
							 &section_descriptor));
	}

	//Add the header, section descriptors, and sections to a parent object.
	json_object *parent = json_object_new_object();
	json_object_object_add(parent, "header", header_ir);
	json_object_object_add(parent, "sectionDescriptors",
			       section_descriptors_ir);
	json_object_object_add(parent, "sections", sections_ir);

	return parent;
}

//Converts a parsed CPER record header into intermediate JSON object format.
json_object *cper_header_to_ir(EFI_COMMON_ERROR_RECORD_HEADER *header)
{
	json_object *header_ir = json_object_new_object();

	//Revision/version information.
	json_object_object_add(header_ir, "revision",
			       revision_to_ir(header->Revision));

	//Section count.
	json_object_object_add(header_ir, "sectionCount",
			       json_object_new_int(header->SectionCount));

	//Error severity (with interpreted string version).
	json_object *error_severity = json_object_new_object();
	json_object_object_add(error_severity, "code",
			       json_object_new_uint64(header->ErrorSeverity));
	json_object_object_add(error_severity, "name",
			       json_object_new_string(severity_to_string(
				       header->ErrorSeverity)));
	json_object_object_add(header_ir, "severity", error_severity);

	//The validation bits for each section.
	json_object *validation_bits = bitfield_to_ir(
		header->ValidationBits, 3, CPER_HEADER_VALID_BITFIELD_NAMES);
	json_object_object_add(header_ir, "validationBits", validation_bits);

	//Total length of the record (including headers) in bytes.
	json_object_object_add(header_ir, "recordLength",
			       json_object_new_uint64(header->RecordLength));

	//If a timestamp exists according to validation bits, then add it.
	if (header->ValidationBits & 0b10) {
		char timestamp_string[TIMESTAMP_LENGTH];
		timestamp_to_string(timestamp_string, &header->TimeStamp);

		json_object_object_add(
			header_ir, "timestamp",
			json_object_new_string(timestamp_string));
		json_object_object_add(
			header_ir, "timestampIsPrecise",
			json_object_new_boolean(header->TimeStamp.Flag));
	}

	//If a platform ID exists according to the validation bits, then add it.
	if (header->ValidationBits & 0b1) {
		char platform_string[GUID_STRING_LENGTH];
		guid_to_string(platform_string, &header->PlatformID);
		json_object_object_add(header_ir, "platformID",
				       json_object_new_string(platform_string));
	}

	//If a partition ID exists according to the validation bits, then add it.
	if (header->ValidationBits & 0b100) {
		char partition_string[GUID_STRING_LENGTH];
		guid_to_string(partition_string, &header->PartitionID);
		json_object_object_add(
			header_ir, "partitionID",
			json_object_new_string(partition_string));
	}

	//Creator ID of the header.
	char creator_string[GUID_STRING_LENGTH];
	guid_to_string(creator_string, &header->CreatorID);
	json_object_object_add(header_ir, "creatorID",
			       json_object_new_string(creator_string));

	//Notification type for the header. Some defined types are available.
	json_object *notification_type = json_object_new_object();
	char notification_type_string[GUID_STRING_LENGTH];
	guid_to_string(notification_type_string, &header->NotificationType);
	json_object_object_add(
		notification_type, "guid",
		json_object_new_string(notification_type_string));

	//Add the human readable notification type if possible.
	char *notification_type_readable = "Unknown";
	if (guid_equal(&header->NotificationType,
		       &gEfiEventNotificationTypeCmcGuid))
		notification_type_readable = "CMC";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeCpeGuid))
		notification_type_readable = "CPE";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeMceGuid))
		notification_type_readable = "MCE";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypePcieGuid))
		notification_type_readable = "PCIe";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeInitGuid))
		notification_type_readable = "INIT";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeNmiGuid))
		notification_type_readable = "NMI";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeBootGuid))
		notification_type_readable = "Boot";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeDmarGuid))
		notification_type_readable = "DMAr";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeSeaGuid))
		notification_type_readable = "SEA";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeSeiGuid))
		notification_type_readable = "SEI";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypePeiGuid))
		notification_type_readable = "PEI";
	else if (guid_equal(&header->NotificationType,
			    &gEfiEventNotificationTypeCxlGuid))
		notification_type_readable = "CXL Component";
	json_object_object_add(
		notification_type, "type",
		json_object_new_string(notification_type_readable));
	json_object_object_add(header_ir, "notificationType",
			       notification_type);

	//The record ID for this record, unique on a given system.
	json_object_object_add(header_ir, "recordID",
			       json_object_new_uint64(header->RecordID));

	//Flag for the record, and a human readable form.
	json_object *flags = integer_to_readable_pair(
		header->Flags,
		sizeof(CPER_HEADER_FLAG_TYPES_KEYS) / sizeof(int),
		CPER_HEADER_FLAG_TYPES_KEYS, CPER_HEADER_FLAG_TYPES_VALUES,
		"Unknown");
	json_object_object_add(header_ir, "flags", flags);

	//Persistence information. Outside the scope of specification, so just a uint32 here.
	json_object_object_add(header_ir, "persistenceInfo",
			       json_object_new_uint64(header->PersistenceInfo));
	return header_ir;
}

//Converts the given EFI section descriptor into JSON IR format.
json_object *
cper_section_descriptor_to_ir(EFI_ERROR_SECTION_DESCRIPTOR *section_descriptor)
{
	json_object *section_descriptor_ir = json_object_new_object();

	//The offset of the section from the base of the record header, length.
	json_object_object_add(
		section_descriptor_ir, "sectionOffset",
		json_object_new_uint64(section_descriptor->SectionOffset));
	json_object_object_add(
		section_descriptor_ir, "sectionLength",
		json_object_new_uint64(section_descriptor->SectionLength));

	//Revision.
	json_object_object_add(section_descriptor_ir, "revision",
			       revision_to_ir(section_descriptor->Revision));

	//Validation bits.
	json_object *validation_bits =
		bitfield_to_ir(section_descriptor->SecValidMask, 2,
			       CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES);
	json_object_object_add(section_descriptor_ir, "validationBits",
			       validation_bits);

	//Flag bits.
	json_object *flags =
		bitfield_to_ir(section_descriptor->SectionFlags, 8,
			       CPER_SECTION_DESCRIPTOR_FLAGS_BITFIELD_NAMES);
	json_object_object_add(section_descriptor_ir, "flags", flags);

	//Section type (GUID).
	json_object *section_type = json_object_new_object();
	char section_type_string[GUID_STRING_LENGTH];
	guid_to_string(section_type_string, &section_descriptor->SectionType);
	json_object_object_add(section_type, "data",
			       json_object_new_string(section_type_string));

	//Readable section type, if possible.
	char *section_type_readable = "Unknown";
	if (guid_equal(&section_descriptor->SectionType,
		       &gEfiProcessorGenericErrorSectionGuid))
		section_type_readable = "Processor Generic";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiIa32X64ProcessorErrorSectionGuid))
		section_type_readable = "IA32/X64";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiIpfProcessorErrorSectionGuid))
		section_type_readable = "IPF";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiArmProcessorErrorSectionGuid))
		section_type_readable = "ARM";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiPlatformMemoryErrorSectionGuid) ||
		 guid_equal(&section_descriptor->SectionType,
			    &gEfiPlatformMemoryError2SectionGuid))
		section_type_readable = "Platform Memory";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiPcieErrorSectionGuid))
		section_type_readable = "PCIe";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiFirmwareErrorSectionGuid))
		section_type_readable = "Firmware Error Record Reference";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiPciBusErrorSectionGuid))
		section_type_readable = "PCI/PCI-X Bus";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiPciDevErrorSectionGuid))
		section_type_readable = "PCI Component/Device";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiDMArGenericErrorSectionGuid))
		section_type_readable = "DMAr Generic";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiDirectedIoDMArErrorSectionGuid))
		section_type_readable =
			"Intel VT for Directed I/O specific DMAr section";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiIommuDMArErrorSectionGuid))
		section_type_readable = "IOMMU specific DMAr section";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCcixPerLogErrorSectionGuid))
		section_type_readable = "CCIX PER Log Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlProtocolErrorSectionGuid))
		section_type_readable = "CXL Protocol Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlGeneralMediaErrorSectionGuid))
		section_type_readable = "CXL General Media Component Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlDramEventErrorSectionGuid))
		section_type_readable = "CXL DRAM Component Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlPhysicalSwitchErrorSectionGuid))
		section_type_readable = "CXL Physical Switch Component Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlVirtualSwitchErrorSectionGuid))
		section_type_readable = "CXL Virtual Switch Component Error";
	else if (guid_equal(&section_descriptor->SectionType,
			    &gEfiCxlMldPortErrorSectionGuid))
		section_type_readable = "CXL MLD Port Component Error";

	json_object_object_add(section_type, "type",
			       json_object_new_string(section_type_readable));
	json_object_object_add(section_descriptor_ir, "sectionType",
			       section_type);

	//If validation bits indicate it exists, add FRU ID.
	if (section_descriptor->SecValidMask & 0b1) {
		char fru_id_string[GUID_STRING_LENGTH];
		guid_to_string(fru_id_string, &section_descriptor->FruId);
		json_object_object_add(section_descriptor_ir, "fruID",
				       json_object_new_string(fru_id_string));
	}

	//If validation bits indicate it exists, add FRU text.
	if ((section_descriptor->SecValidMask & 0b10) >> 1)
		json_object_object_add(
			section_descriptor_ir, "fruText",
			json_object_new_string(section_descriptor->FruString));

	//Section severity.
	json_object *section_severity = json_object_new_object();
	json_object_object_add(
		section_severity, "code",
		json_object_new_uint64(section_descriptor->Severity));
	json_object_object_add(section_severity, "name",
			       json_object_new_string(severity_to_string(
				       section_descriptor->Severity)));
	json_object_object_add(section_descriptor_ir, "severity",
			       section_severity);

	return section_descriptor_ir;
}

//Converts the section described by a single given section descriptor.
json_object *cper_section_to_ir(FILE *handle,
				EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
{
	//Save our current position in the stream.
	long position = ftell(handle);

	//Read section as described by the section descriptor.
	fseek(handle, descriptor->SectionOffset, SEEK_SET);
	void *section = malloc(descriptor->SectionLength);
	if (fread(section, descriptor->SectionLength, 1, handle) != 1) {
		printf("Section read failed: Could not read %d bytes from global offset %d.\n",
		       descriptor->SectionLength, descriptor->SectionOffset);
		free(section);
		return NULL;
	}

	//Seek back to our original position.
	fseek(handle, position, SEEK_SET);

	//Parse section to IR based on GUID.
	json_object *result = NULL;
	if (guid_equal(&descriptor->SectionType,
		       &gEfiProcessorGenericErrorSectionGuid))
		result = cper_section_generic_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiIa32X64ProcessorErrorSectionGuid))
		result = cper_section_ia32x64_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiIpfProcessorErrorSectionGuid))
		result = cper_section_ipf_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiArmProcessorErrorSectionGuid))
		result = cper_section_arm_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiPlatformMemoryErrorSectionGuid))
		result =
			cper_section_platform_memory_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiPlatformMemoryError2SectionGuid))
		result = cper_section_platform_memory2_to_ir(section,
							     descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiPcieErrorSectionGuid))
		result = cper_section_pcie_to_ir(section, descriptor);
	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))
		result = cper_section_pci_dev_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiDMArGenericErrorSectionGuid))
		result = cper_section_dmar_generic_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiDirectedIoDMArErrorSectionGuid))
		result = cper_section_dmar_vtd_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiIommuDMArErrorSectionGuid))
		result = cper_section_dmar_iommu_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiCcixPerLogErrorSectionGuid))
		result = cper_section_ccix_per_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiCxlProtocolErrorSectionGuid))
		result = cper_section_cxl_protocol_to_ir(section, descriptor);
	else if (guid_equal(&descriptor->SectionType,
			    &gEfiCxlGeneralMediaErrorSectionGuid) ||
		 guid_equal(&descriptor->SectionType,
			    &gEfiCxlDramEventErrorSectionGuid) ||
		 guid_equal(&descriptor->SectionType,
			    &gEfiCxlPhysicalSwitchErrorSectionGuid) ||
		 guid_equal(&descriptor->SectionType,
			    &gEfiCxlVirtualSwitchErrorSectionGuid) ||
		 guid_equal(&descriptor->SectionType,
			    &gEfiCxlMldPortErrorSectionGuid)) {
		result = cper_section_cxl_component_to_ir(section, descriptor);
	} else {
		//Failed read, unknown GUID.
		//Output the data as formatted base64.
		result = json_object_new_object();
		char *encoded = b64_encode((unsigned char *)section,
					   descriptor->SectionLength);
		json_object_object_add(result, "data",
				       json_object_new_string(encoded));
		free(encoded);
	}

	//Free section memory, return result.
	free(section);
	return result;
}