/**
 * Describes functions for converting generic DMAr CPER sections from binary and JSON format
 * into an intermediate format.
 *
 * Author: Lawrence.Tang@arm.com
 **/
#include <stdio.h>
#include <json.h>
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-dmar-generic.h>

//Converts a single generic DMAr CPER section into JSON IR.
json_object *cper_section_dmar_generic_to_ir(void *section)
{
	EFI_DMAR_GENERIC_ERROR_DATA *firmware_error =
		(EFI_DMAR_GENERIC_ERROR_DATA *)section;
	json_object *section_ir = json_object_new_object();

	//Requester ID, segment.
	json_object_object_add(
		section_ir, "requesterID",
		json_object_new_int(firmware_error->RequesterId));
	json_object_object_add(
		section_ir, "segmentNumber",
		json_object_new_int(firmware_error->SegmentNumber));

	//Fault reason.
	json_object *fault_reason = integer_to_readable_pair_with_desc(
		firmware_error->FaultReason, 11,
		DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS,
		DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_VALUES,
		DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_DESCRIPTIONS,
		"Unknown (Reserved)");
	json_object_object_add(section_ir, "faultReason", fault_reason);

	//Access type.
	json_object *access_type = integer_to_readable_pair(
		firmware_error->AccessType, 2,
		DMAR_GENERIC_ERROR_ACCESS_TYPES_KEYS,
		DMAR_GENERIC_ERROR_ACCESS_TYPES_VALUES, "Unknown (Reserved)");
	json_object_object_add(section_ir, "accessType", access_type);

	//Address type.
	json_object *address_type = integer_to_readable_pair(
		firmware_error->AddressType, 2,
		DMAR_GENERIC_ERROR_ADDRESS_TYPES_KEYS,
		DMAR_GENERIC_ERROR_ADDRESS_TYPES_VALUES, "Unknown (Reserved)");
	json_object_object_add(section_ir, "addressType", address_type);

	//Architecture type.
	json_object *arch_type = integer_to_readable_pair(
		firmware_error->ArchType, 2, DMAR_GENERIC_ERROR_ARCH_TYPES_KEYS,
		DMAR_GENERIC_ERROR_ARCH_TYPES_VALUES, "Unknown (Reserved)");
	json_object_object_add(section_ir, "architectureType", arch_type);

	//Device address.
	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, "architectureType"));
	section_cper->DeviceAddr = json_object_get_uint64(
		json_object_object_get(section, "deviceAddress"));

	//Write to stream, free resources.
	fwrite(section_cper, sizeof(EFI_DMAR_GENERIC_ERROR_DATA), 1, out);
	fflush(out);
	free(section_cper);
}
