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