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

//Converts a single PCIe CPER section into JSON IR.
json_object *cper_section_pcie_to_ir(void *section)
{
	EFI_PCIE_ERROR_DATA *pcie_error = (EFI_PCIE_ERROR_DATA *)section;
	json_object *section_ir = json_object_new_object();

	//Validation bits.
	json_object *validation = bitfield_to_ir(
		pcie_error->ValidFields, 8, PCIE_ERROR_VALID_BITFIELD_NAMES);
	json_object_object_add(section_ir, "validationBits", validation);

	//Port type.
	json_object *port_type = integer_to_readable_pair(
		pcie_error->PortType, 9, PCIE_ERROR_PORT_TYPES_KEYS,
		PCIE_ERROR_PORT_TYPES_VALUES, "Unknown");
	json_object_object_add(section_ir, "portType", port_type);

	//Version, provided each half in BCD.
	json_object *version = json_object_new_object();
	json_object_object_add(
		version, "minor",
		json_object_new_int(bcd_to_int(pcie_error->Version & 0xFF)));
	json_object_object_add(
		version, "major",
		json_object_new_int(bcd_to_int(pcie_error->Version >> 8)));
	json_object_object_add(section_ir, "version", version);

	//Command & status.
	json_object *command_status = json_object_new_object();
	json_object_object_add(
		command_status, "commandRegister",
		json_object_new_uint64(pcie_error->CommandStatus & 0xFFFF));
	json_object_object_add(
		command_status, "statusRegister",
		json_object_new_uint64(pcie_error->CommandStatus >> 16));
	json_object_object_add(section_ir, "commandStatus", command_status);

	//PCIe Device ID.
	json_object *device_id = json_object_new_object();
	UINT64 class_id = (pcie_error->DevBridge.ClassCode[0] << 16) +
			  (pcie_error->DevBridge.ClassCode[1] << 8) +
			  pcie_error->DevBridge.ClassCode[2];
	json_object_object_add(
		device_id, "vendorID",
		json_object_new_uint64(pcie_error->DevBridge.VendorId));
	json_object_object_add(
		device_id, "deviceID",
		json_object_new_uint64(pcie_error->DevBridge.DeviceId));
	json_object_object_add(device_id, "classCode",
			       json_object_new_uint64(class_id));
	json_object_object_add(
		device_id, "functionNumber",
		json_object_new_uint64(pcie_error->DevBridge.Function));
	json_object_object_add(
		device_id, "deviceNumber",
		json_object_new_uint64(pcie_error->DevBridge.Device));
	json_object_object_add(
		device_id, "segmentNumber",
		json_object_new_uint64(pcie_error->DevBridge.Segment));
	json_object_object_add(
		device_id, "primaryOrDeviceBusNumber",
		json_object_new_uint64(
			pcie_error->DevBridge.PrimaryOrDeviceBus));
	json_object_object_add(
		device_id, "secondaryBusNumber",
		json_object_new_uint64(pcie_error->DevBridge.SecondaryBus));
	json_object_object_add(
		device_id, "slotNumber",
		json_object_new_uint64(pcie_error->DevBridge.Slot.Number));
	json_object_object_add(section_ir, "deviceID", device_id);

	//Device serial number.
	json_object_object_add(section_ir, "deviceSerialNumber",
			       json_object_new_uint64(pcie_error->SerialNo));

	//Bridge control status.
	json_object *bridge_control_status = json_object_new_object();
	json_object_object_add(
		bridge_control_status, "secondaryStatusRegister",
		json_object_new_uint64(pcie_error->BridgeControlStatus &
				       0xFFFF));
	json_object_object_add(
		bridge_control_status, "controlRegister",
		json_object_new_uint64(pcie_error->BridgeControlStatus >> 16));
	json_object_object_add(section_ir, "bridgeControlStatus",
			       bridge_control_status);

	//Capability structure.
	//The PCIe capability structure provided here could either be PCIe 1.1 Capability Structure
	//(36-byte, padded to 60 bytes) or PCIe 2.0 Capability Structure (60-byte). There does not seem
	//to be a way to differentiate these, so this is left as a b64 dump.
	int32_t encoded_len = 0;

	char *encoded = base64_encode((UINT8 *)pcie_error->Capability.PcieCap,
				      60, &encoded_len);
	if (encoded == NULL) {
		printf("Failed to allocate encode output buffer. \n");
	} else {
		json_object *capability = json_object_new_object();
		json_object_object_add(capability, "data",
				       json_object_new_string_len(encoded,
								  encoded_len));
		free(encoded);

		json_object_object_add(section_ir, "capabilityStructure",
				       capability);
	}

	//AER information.
	json_object *aer_capability_ir = json_object_new_object();
	encoded_len = 0;

	encoded = base64_encode((UINT8 *)pcie_error->AerInfo.PcieAer, 96,
				&encoded_len);
	if (encoded == NULL) {
		printf("Failed to allocate encode output buffer. \n");
	} else {
		json_object_object_add(aer_capability_ir, "data",
				       json_object_new_string_len(encoded,
								  encoded_len));
		free(encoded);
	}
	json_object_object_add(section_ir, "aerInfo", aer_capability_ir);

	return section_ir;
}

//Converts a single CPER-JSON PCIe section into CPER binary, outputting to the given stream.
void ir_section_pcie_to_cper(json_object *section, FILE *out)
{
	EFI_PCIE_ERROR_DATA *section_cper =
		(EFI_PCIE_ERROR_DATA *)calloc(1, sizeof(EFI_PCIE_ERROR_DATA));

	//Validation bits.
	section_cper->ValidFields = ir_to_bitfield(
		json_object_object_get(section, "validationBits"), 8,
		PCIE_ERROR_VALID_BITFIELD_NAMES);

	//Version.
	json_object *version = json_object_object_get(section, "version");
	UINT32 minor = int_to_bcd(
		json_object_get_int(json_object_object_get(version, "minor")));
	UINT32 major = int_to_bcd(
		json_object_get_int(json_object_object_get(version, "major")));
	section_cper->Version = minor + (major << 8);

	//Command/status registers.
	json_object *command_status =
		json_object_object_get(section, "commandStatus");
	UINT32 command = (UINT16)json_object_get_uint64(
		json_object_object_get(command_status, "commandRegister"));
	UINT32 status = (UINT16)json_object_get_uint64(
		json_object_object_get(command_status, "statusRegister"));
	section_cper->CommandStatus = command + (status << 16);

	//Device ID.
	json_object *device_id = json_object_object_get(section, "deviceID");
	UINT64 class_id = json_object_get_uint64(
		json_object_object_get(device_id, "classCode"));
	section_cper->DevBridge.VendorId = (UINT16)json_object_get_uint64(
		json_object_object_get(device_id, "vendorID"));
	section_cper->DevBridge.DeviceId = (UINT16)json_object_get_uint64(
		json_object_object_get(device_id, "deviceID"));
	section_cper->DevBridge.ClassCode[0] = class_id >> 16;
	section_cper->DevBridge.ClassCode[1] = (class_id >> 8) & 0xFF;
	section_cper->DevBridge.ClassCode[2] = class_id & 0xFF;
	section_cper->DevBridge.Function = (UINT8)json_object_get_uint64(
		json_object_object_get(device_id, "functionNumber"));
	section_cper->DevBridge.Device = (UINT8)json_object_get_uint64(
		json_object_object_get(device_id, "deviceNumber"));
	section_cper->DevBridge.Segment = (UINT16)json_object_get_uint64(
		json_object_object_get(device_id, "segmentNumber"));
	section_cper->DevBridge.PrimaryOrDeviceBus =
		(UINT8)json_object_get_uint64(json_object_object_get(
			device_id, "primaryOrDeviceBusNumber"));
	section_cper->DevBridge.SecondaryBus = (UINT8)json_object_get_uint64(
		json_object_object_get(device_id, "secondaryBusNumber"));
	section_cper->DevBridge.Slot.Number = (UINT16)json_object_get_uint64(
		json_object_object_get(device_id, "slotNumber"));

	//Bridge/control status.
	json_object *bridge_control =
		json_object_object_get(section, "bridgeControlStatus");
	UINT32 bridge_status = (UINT16)json_object_get_uint64(
		json_object_object_get(bridge_control,
				       "secondaryStatusRegister"));
	UINT32 control_status = (UINT16)json_object_get_uint64(
		json_object_object_get(bridge_control, "controlRegister"));
	section_cper->BridgeControlStatus =
		bridge_status + (control_status << 16);

	//Capability structure.
	json_object *capability =
		json_object_object_get(section, "capabilityStructure");
	json_object *encoded = json_object_object_get(capability, "data");

	int32_t decoded_len = 0;

	UINT8 *decoded = base64_decode(json_object_get_string(encoded),
				       json_object_get_string_len(encoded),
				       &decoded_len);
	if (decoded == NULL) {
		printf("Failed to allocate decode output buffer. \n");
	} else {
		memcpy(section_cper->Capability.PcieCap, decoded, decoded_len);
		free(decoded);
	}

	//AER capability structure.
	json_object *aer_info = json_object_object_get(section, "aerInfo");
	encoded = json_object_object_get(aer_info, "data");
	decoded_len = 0;

	decoded = base64_decode(json_object_get_string(encoded),
				json_object_get_string_len(encoded),
				&decoded_len);

	if (decoded == NULL) {
		printf("Failed to allocate decode output buffer. \n");
	} else {
		memcpy(section_cper->AerInfo.PcieAer, decoded, decoded_len);
		free(decoded);
	}

	//Miscellaneous value fields.
	section_cper->PortType = (UINT32)readable_pair_to_integer(
		json_object_object_get(section, "portType"));
	section_cper->SerialNo = json_object_get_uint64(
		json_object_object_get(section, "deviceSerialNumber"));

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