/**
 * Describes functions for converting memory error 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-memory.h"

//Converts a single memory error CPER section into JSON IR.
json_object* cper_section_platform_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
{
    EFI_PLATFORM_MEMORY_ERROR_DATA* memory_error = (EFI_PLATFORM_MEMORY_ERROR_DATA*)section;
    json_object* section_ir = json_object_new_object();

    //Validation bitfield.
    json_object* validation = bitfield_to_ir(memory_error->ValidFields, 22, MEMORY_ERROR_VALID_BITFIELD_NAMES);
    json_object_object_add(section_ir, "validationBits", validation);

    //Error status.
    json_object* error_status = cper_generic_error_status_to_ir(&memory_error->ErrorStatus);
    json_object_object_add(section_ir, "errorStatus", error_status);

    //Bank.
    json_object* bank = json_object_new_object();
    if ((memory_error->ValidFields >> 5) & 0x1)
    {
        //Entire bank address mode.
        json_object_object_add(bank, "value", json_object_new_uint64(memory_error->Bank));
    }
    else 
    {
        //Address/group address mode.
        json_object_object_add(bank, "address", json_object_new_uint64(memory_error->Bank & 0xFF));
        json_object_object_add(bank, "group", json_object_new_uint64(memory_error->Bank >> 8));
    }
    json_object_object_add(section_ir, "bank", bank);

    //Memory error type.
    json_object* memory_error_type = integer_to_readable_pair(memory_error->ErrorType, 16,
        MEMORY_ERROR_TYPES_KEYS,
        MEMORY_ERROR_TYPES_VALUES,
        "Unknown (Reserved)");
    json_object_object_add(section_ir, "memoryErrorType", memory_error_type);

    //"Extended" row/column indication field + misc.
    json_object* extended = json_object_new_object();
    json_object_object_add(extended, "rowBit16", json_object_new_boolean(memory_error->Extended & 0b1));
    json_object_object_add(extended, "rowBit17", json_object_new_boolean((memory_error->Extended >> 1) & 0b1));
    json_object_object_add(extended, "chipIdentification", json_object_new_int(memory_error->Extended >> 5));
    json_object_object_add(section_ir, "extended", extended);

    //Miscellaneous numeric fields.
    json_object_object_add(section_ir, "physicalAddress", json_object_new_uint64(memory_error->PhysicalAddress));
    json_object_object_add(section_ir, "physicalAddressMask", json_object_new_uint64(memory_error->PhysicalAddressMask));
    json_object_object_add(section_ir, "node", json_object_new_uint64(memory_error->Node));
    json_object_object_add(section_ir, "card", json_object_new_uint64(memory_error->Card));
    json_object_object_add(section_ir, "moduleRank", json_object_new_uint64(memory_error->ModuleRank));
    json_object_object_add(section_ir, "device", json_object_new_uint64(memory_error->Device));
    json_object_object_add(section_ir, "row", json_object_new_uint64(memory_error->Row));
    json_object_object_add(section_ir, "column", json_object_new_uint64(memory_error->Column));
    json_object_object_add(section_ir, "bitPosition", json_object_new_uint64(memory_error->BitPosition));
    json_object_object_add(section_ir, "requestorID", json_object_new_uint64(memory_error->RequestorId));
    json_object_object_add(section_ir, "responderID", json_object_new_uint64(memory_error->ResponderId));
    json_object_object_add(section_ir, "targetID", json_object_new_uint64(memory_error->TargetId));
    json_object_object_add(section_ir, "rankNumber", json_object_new_uint64(memory_error->RankNum));
    json_object_object_add(section_ir, "cardSmbiosHandle", json_object_new_uint64(memory_error->CardHandle));
    json_object_object_add(section_ir, "moduleSmbiosHandle", json_object_new_uint64(memory_error->ModuleHandle));

    return section_ir;
}

//Converts a single memory error 2 CPER section into JSON IR.
json_object* cper_section_platform_memory2_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
{
    EFI_PLATFORM_MEMORY2_ERROR_DATA* memory_error = (EFI_PLATFORM_MEMORY2_ERROR_DATA*)section;
    json_object* section_ir = json_object_new_object();

    //Validation bits.
    json_object* validation = bitfield_to_ir(memory_error->ValidFields, 22, MEMORY_ERROR_2_VALID_BITFIELD_NAMES);
    json_object_object_add(section_ir, "validationBits", validation);

    //Error status.
    json_object* error_status = cper_generic_error_status_to_ir(&memory_error->ErrorStatus);
    json_object_object_add(section_ir, "errorStatus", error_status);

    //Bank.
    json_object* bank = json_object_new_object();
    if ((memory_error->ValidFields >> 5) & 0x1)
    {
        //Entire bank address mode.
        json_object_object_add(bank, "value", json_object_new_uint64(memory_error->Bank));
    }
    else 
    {
        //Address/group address mode.
        json_object_object_add(bank, "address", json_object_new_uint64(memory_error->Bank & 0xFF));
        json_object_object_add(bank, "group", json_object_new_uint64(memory_error->Bank >> 8));
    }
    json_object_object_add(section_ir, "bank", bank);

    //Memory error type.
    json_object* memory_error_type = integer_to_readable_pair(memory_error->MemErrorType, 16,
        MEMORY_ERROR_TYPES_KEYS,
        MEMORY_ERROR_TYPES_VALUES,
        "Unknown (Reserved)");
    json_object_object_add(section_ir, "memoryErrorType", memory_error_type);

    //Status.
    json_object* status = json_object_new_object();
    json_object_object_add(status, "value", json_object_new_int(memory_error->Status));
    json_object_object_add(status, "state", json_object_new_string(memory_error->Status & 0b1 == 0 ? "Corrected" : "Uncorrected"));
    json_object_object_add(section_ir, "status", status);

    //Miscellaneous numeric fields.
    json_object_object_add(section_ir, "physicalAddress", json_object_new_uint64(memory_error->PhysicalAddress));
    json_object_object_add(section_ir, "physicalAddressMask", json_object_new_uint64(memory_error->PhysicalAddressMask));
    json_object_object_add(section_ir, "node", json_object_new_uint64(memory_error->Node));
    json_object_object_add(section_ir, "card", json_object_new_uint64(memory_error->Card));
    json_object_object_add(section_ir, "module", json_object_new_uint64(memory_error->Module));
    json_object_object_add(section_ir, "device", json_object_new_uint64(memory_error->Device));
    json_object_object_add(section_ir, "row", json_object_new_uint64(memory_error->Row));
    json_object_object_add(section_ir, "column", json_object_new_uint64(memory_error->Column));
    json_object_object_add(section_ir, "rank", json_object_new_uint64(memory_error->Rank));
    json_object_object_add(section_ir, "bitPosition", json_object_new_uint64(memory_error->BitPosition));
    json_object_object_add(section_ir, "chipID", json_object_new_uint64(memory_error->ChipId));
    json_object_object_add(section_ir, "requestorID", json_object_new_uint64(memory_error->RequestorId));
    json_object_object_add(section_ir, "responderID", json_object_new_uint64(memory_error->ResponderId));
    json_object_object_add(section_ir, "targetID", json_object_new_uint64(memory_error->TargetId));
    json_object_object_add(section_ir, "cardSmbiosHandle", json_object_new_uint64(memory_error->CardHandle));
    json_object_object_add(section_ir, "moduleSmbiosHandle", json_object_new_uint64(memory_error->ModuleHandle));
    
    return section_ir;
}

//Converts a single Memory Error IR section into CPER binary, outputting to the provided stream.
void ir_section_memory_to_cper(json_object* section, FILE* out)
{
    EFI_PLATFORM_MEMORY_ERROR_DATA* section_cper = 
        (EFI_PLATFORM_MEMORY_ERROR_DATA*)calloc(1, sizeof(EFI_PLATFORM_MEMORY_ERROR_DATA));

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

    //Error status.
    ir_generic_error_status_to_cper(json_object_object_get(section, "errorStatus"), &section_cper->ErrorStatus);

    //Bank.
    json_object* bank = json_object_object_get(section, "bank");
    if ((section_cper->ValidFields >> 5) & 0x1)
    {
        //Bank just uses simple address.
        section_cper->Bank = (UINT16)json_object_get_uint64(json_object_object_get(bank, "value"));
    }
    else
    {
        //Bank uses address/group style address.
        UINT16 address = (UINT8)json_object_get_uint64(json_object_object_get(bank, "address"));
        UINT16 group = (UINT8)json_object_get_uint64(json_object_object_get(bank, "group"));
        section_cper->Bank = address + (group << 8);
    }

    //"Extended" field.
    json_object* extended = json_object_object_get(section, "extended");
    section_cper->Extended = 0;
    section_cper->Extended |= json_object_get_boolean(json_object_object_get(extended, "rowBit16"));
    section_cper->Extended |= json_object_get_boolean(json_object_object_get(extended, "rowBit17")) << 1;
    section_cper->Extended |= json_object_get_int(json_object_object_get(extended, "chipIdentification")) << 5;

    //Miscellaneous value fields.
    section_cper->ErrorType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "memoryErrorType"));
    section_cper->PhysicalAddress = json_object_get_uint64(json_object_object_get(section, "physicalAddress"));
    section_cper->PhysicalAddressMask = json_object_get_uint64(json_object_object_get(section, "physicalAddressMask"));
    section_cper->Node = (UINT16)json_object_get_uint64(json_object_object_get(section, "node"));
    section_cper->Card = (UINT16)json_object_get_uint64(json_object_object_get(section, "card"));
    section_cper->ModuleRank = (UINT16)json_object_get_uint64(json_object_object_get(section, "moduleRank"));
    section_cper->Device = (UINT16)json_object_get_uint64(json_object_object_get(section, "device"));
    section_cper->Row = (UINT16)json_object_get_uint64(json_object_object_get(section, "row"));
    section_cper->Column = (UINT16)json_object_get_uint64(json_object_object_get(section, "column"));
    section_cper->BitPosition = (UINT16)json_object_get_uint64(json_object_object_get(section, "bitPosition"));
    section_cper->RequestorId = json_object_get_uint64(json_object_object_get(section, "requestorID"));
    section_cper->ResponderId = json_object_get_uint64(json_object_object_get(section, "responderID"));
    section_cper->TargetId = json_object_get_uint64(json_object_object_get(section, "targetID"));
    section_cper->RankNum = (UINT16)json_object_get_uint64(json_object_object_get(section, "rankNumber"));
    section_cper->CardHandle = (UINT16)json_object_get_uint64(json_object_object_get(section, "cardSmbiosHandle"));
    section_cper->ModuleHandle = (UINT16)json_object_get_uint64(json_object_object_get(section, "moduleSmbiosHandle"));

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

//Converts a single Memory Error 2 IR section into CPER binary, outputting to the provided stream.
void ir_section_memory2_to_cper(json_object* section, FILE* out)
{
    EFI_PLATFORM_MEMORY2_ERROR_DATA* section_cper = 
        (EFI_PLATFORM_MEMORY2_ERROR_DATA*)calloc(1, sizeof(EFI_PLATFORM_MEMORY2_ERROR_DATA));

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

    //Error status.
    ir_generic_error_status_to_cper(json_object_object_get(section, "errorStatus"), &section_cper->ErrorStatus);

    //Bank.
    json_object* bank = json_object_object_get(section, "bank");
    if ((section_cper->ValidFields >> 5) & 0x1)
    {
        //Bank just uses simple address.
        section_cper->Bank = (UINT16)json_object_get_uint64(json_object_object_get(bank, "value"));
    }
    else
    {
        //Bank uses address/group style address.
        UINT16 address = (UINT8)json_object_get_uint64(json_object_object_get(bank, "address"));
        UINT16 group = (UINT8)json_object_get_uint64(json_object_object_get(bank, "group"));
        section_cper->Bank = address + (group << 8);
    }

    //Miscellaneous value fields.
    section_cper->MemErrorType = readable_pair_to_integer(json_object_object_get(section, "memoryErrorType"));
    section_cper->Status = (UINT8)readable_pair_to_integer(json_object_object_get(section, "status"));
    section_cper->PhysicalAddress = json_object_get_uint64(json_object_object_get(section, "physicalAddress"));
    section_cper->PhysicalAddressMask = json_object_get_uint64(json_object_object_get(section, "physicalAddressMask"));
    section_cper->Node = (UINT16)json_object_get_uint64(json_object_object_get(section, "node"));
    section_cper->Card = (UINT16)json_object_get_uint64(json_object_object_get(section, "card"));
    section_cper->Module = (UINT32)json_object_get_uint64(json_object_object_get(section, "module"));
    section_cper->Device = (UINT32)json_object_get_uint64(json_object_object_get(section, "device"));
    section_cper->Row = (UINT32)json_object_get_uint64(json_object_object_get(section, "row"));
    section_cper->Column = (UINT32)json_object_get_uint64(json_object_object_get(section, "column"));
    section_cper->Rank = (UINT32)json_object_get_uint64(json_object_object_get(section, "rank"));
    section_cper->BitPosition = (UINT32)json_object_get_uint64(json_object_object_get(section, "bitPosition"));
    section_cper->ChipId = (UINT8)json_object_get_uint64(json_object_object_get(section, "chipID"));
    section_cper->RequestorId = json_object_get_uint64(json_object_object_get(section, "requestorID"));
    section_cper->ResponderId = json_object_get_uint64(json_object_object_get(section, "responderID"));
    section_cper->TargetId = json_object_get_uint64(json_object_object_get(section, "targetID"));
    section_cper->CardHandle = (UINT32)json_object_get_uint64(json_object_object_get(section, "cardSmbiosHandle"));
    section_cper->ModuleHandle = (UINT32)json_object_get_uint64(json_object_object_get(section, "moduleSmbiosHandle"));

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