1*db1b7ce2SLawrence Tang /** 2*db1b7ce2SLawrence Tang * Describes functions for converting IOMMU specific DMAr CPER sections from binary and JSON format 3*db1b7ce2SLawrence Tang * into an intermediate format. 4*db1b7ce2SLawrence Tang * 5*db1b7ce2SLawrence Tang * Author: Lawrence.Tang@arm.com 6*db1b7ce2SLawrence Tang **/ 7*db1b7ce2SLawrence Tang #include <stdio.h> 8*db1b7ce2SLawrence Tang #include "json.h" 9*db1b7ce2SLawrence Tang #include "../edk/Cper.h" 10*db1b7ce2SLawrence Tang #include "../cper-utils.h" 11*db1b7ce2SLawrence Tang #include "cper-section-dmar-iommu.h" 12*db1b7ce2SLawrence Tang 13*db1b7ce2SLawrence Tang //Converts a single IOMMU specific DMAr CPER section into JSON IR. 14*db1b7ce2SLawrence Tang json_object* cper_section_dmar_iommu_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor) 15*db1b7ce2SLawrence Tang { 16*db1b7ce2SLawrence Tang EFI_IOMMU_DMAR_ERROR_DATA* iommu_error = (EFI_IOMMU_DMAR_ERROR_DATA*)section; 17*db1b7ce2SLawrence Tang json_object* section_ir = json_object_new_object(); 18*db1b7ce2SLawrence Tang 19*db1b7ce2SLawrence Tang //Revision. 20*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "revision", json_object_new_int(iommu_error->Revision)); 21*db1b7ce2SLawrence Tang 22*db1b7ce2SLawrence Tang //IOMMU registers. 23*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "controlRegister", json_object_new_uint64(iommu_error->Control)); 24*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "statusRegister", json_object_new_uint64(iommu_error->Status)); 25*db1b7ce2SLawrence Tang 26*db1b7ce2SLawrence Tang //IOMMU event log entry. 27*db1b7ce2SLawrence Tang //todo: implement as specified in the IOMMU specification 28*db1b7ce2SLawrence Tang 29*db1b7ce2SLawrence Tang //Device table entry. 30*db1b7ce2SLawrence Tang //todo: dump as b64 31*db1b7ce2SLawrence Tang 32*db1b7ce2SLawrence Tang //Page table entries. 33*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level6", json_object_new_uint64(iommu_error->PteL6)); 34*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level5", json_object_new_uint64(iommu_error->PteL5)); 35*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level4", json_object_new_uint64(iommu_error->PteL4)); 36*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level3", json_object_new_uint64(iommu_error->PteL3)); 37*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level2", json_object_new_uint64(iommu_error->PteL2)); 38*db1b7ce2SLawrence Tang json_object_object_add(section_ir, "pageTableEntry_Level1", json_object_new_uint64(iommu_error->PteL1)); 39*db1b7ce2SLawrence Tang 40*db1b7ce2SLawrence Tang return section_ir; 41*db1b7ce2SLawrence Tang }