def test_ivrs_parser_ivrs_full(self): # finally the big daddy... load it up! IvrsParserTest.ivhd_10h.addDTEEntry(IvrsParserTest.dte_01h) IvrsParserTest.ivhd_10h.addDTEEntry(IvrsParserTest.dte_02h) IvrsParserTest.ivhd_10h.addDTEEntry(IvrsParserTest.dte_03h) IvrsParserTest.ivhd_10h.addDTEEntry(IvrsParserTest.dte_00h) IvrsParserTest.ivhd_11h.addDTEEntry(IvrsParserTest.dte_42h) IvrsParserTest.ivhd_11h.addDTEEntry(IvrsParserTest.dte_43h) IvrsParserTest.ivhd_11h.addDTEEntry(IvrsParserTest.dte_46h) IvrsParserTest.ivhd_11h.addDTEEntry(IvrsParserTest.dte_47h) IvrsParserTest.ivhd_11h.addDTEEntry(IvrsParserTest.dte_48h) IvrsParserTest.ivhd_40h.addDTEEntry(IvrsParserTest.dte_f0h_0) IvrsParserTest.ivhd_40h.addDTEEntry(IvrsParserTest.dte_f0h_1) IvrsParserTest.ivhd_40h.addDTEEntry(IvrsParserTest.dte_f0h_2) IvrsParserTest.ivrs.addIVHDEntry(IvrsParserTest.ivhd_10h) IvrsParserTest.ivrs.addIVMDEntry(IvrsParserTest.ivmd_20h) IvrsParserTest.ivrs.addIVHDEntry(IvrsParserTest.ivhd_11h) IvrsParserTest.ivrs.addIVMDEntry(IvrsParserTest.ivmd_21h) IvrsParserTest.ivrs.addIVHDEntry(IvrsParserTest.ivhd_40h) IvrsParserTest.ivrs.addIVMDEntry(IvrsParserTest.ivmd_22h) IvrsParserTest.ivrs.DumpInfo() IvrsParserTest.ivrs.ToXmlElementTree() ivrs_byte = IvrsParserTest.ivrs.Encode() ivrs2 = IVRS_TABLE(ivrs_byte) self.assertEqual(ivrs2.Encode(), ivrs_byte)
def test_ivrs_parser_ivhd_40h(self): # I/O Virtualization Hardware Definition (IVHD) Type 40h header ivhd_t_40h = bytes([ 0x40, # Type 0x90, # Flags 0x28, 0x00, # Length 0x02, 0x00, # DeviceID 0x40, 0x00, # Capability offset 0xEF, 0xBE, 0xAD, 0xDE, 0x0D, 0xF0, 0xED, 0xFE, # IOMMU base address 0x00, 0x00, # PCI Segment Group 0x00, 0x00, # IOMMU info 0xBE, 0xBA, 0xAD, 0xAB, # IOMMU Attributes 0xDA, 0x4A, 0x29, 0x22, 0xEF, 0x77, 0x4F, 0x00, # EFR Register Image 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]) # Reserved IvrsParserTest.ivhd_40h = IVRS_TABLE.IVHD_STRUCT(ivhd_t_40h) self.assertNotEqual(IvrsParserTest.ivhd_40h.Encode(), None) self.assertEqual(IvrsParserTest.ivhd_40h.Type, IVRS_TABLE.IVHD_STRUCT.IVHD_TYPE.TYPE_40H) self.assertEqual(IvrsParserTest.ivhd_40h.Flags, 0x90) self.assertEqual(IvrsParserTest.ivhd_40h.Length, 0x28) self.assertEqual(IvrsParserTest.ivhd_40h.DeviceID, 0x02) self.assertEqual(IvrsParserTest.ivhd_40h.CapabilityOffset, 0x40) self.assertEqual(IvrsParserTest.ivhd_40h.IOMMUBaseAddress, 0xFEEDF00DDEADBEEF) self.assertEqual(IvrsParserTest.ivhd_40h.SegmentGroup, 0) self.assertEqual(IvrsParserTest.ivhd_40h.IOMMUInfo, 0) self.assertEqual(IvrsParserTest.ivhd_40h.IOMMUFeatureInfo, 0xABADBABE) self.assertEqual(IvrsParserTest.ivhd_40h.IOMMUEFRImage, 0x4F77EF22294ADA)
def test_ivrs_parser_ivmd_22h(self): # IVMD Types 22h Format ivmd_t_22h = bytes([ 0x22, # Type 0x08, # Flags 0x20, 0x00, # Length 0x00, 0x00, # DeviceID 0x00, 0x00, # Auxiliary data 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Reserved 0xEF, 0xBE, 0xAD, 0xDE, 0x0D, 0xF0, 0xED, 0xFE, # IVMD start address 0x00, 0xAD, 0xBB, 0xDA, 0xDE, 0xC0, 0x05, 0xB1 ]) # IVMD memory block length IvrsParserTest.ivmd_22h = IVRS_TABLE.IVMD_STRUCT(ivmd_t_22h) self.assertNotEqual(IvrsParserTest.ivmd_22h.Encode(), None) self.assertEqual(IvrsParserTest.ivmd_22h.Type, IVRS_TABLE.IVMD_STRUCT.IVMD_TYPE.TYPE_22H) self.assertEqual(IvrsParserTest.ivmd_22h.Flags, 0x08) self.assertEqual(IvrsParserTest.ivmd_22h.Length, 0x20) self.assertEqual(IvrsParserTest.ivmd_22h.DeviceID, 0) self.assertEqual(IvrsParserTest.ivmd_22h.AuxiliaryData, 0) self.assertEqual(IvrsParserTest.ivmd_22h.Reserved, 0) self.assertEqual(IvrsParserTest.ivmd_22h.IVMDStartAddress, 0xFEEDF00DDEADBEEF) self.assertEqual(IvrsParserTest.ivmd_22h.IVMDMemoryBlockLength, 0xB105C0DEDABBAD00)
def test_ivrs_parser_ivhd_10h(self): # I/O Virtualization Hardware Definition (IVHD) Type 10h header ivhd_t_10h = bytes([ 0x10, # Type 0x90, # Flags 0x18, 0x00, # Length 0x02, 0x00, # DeviceID 0x40, 0x00, # Capability offset 0xEF, 0xBE, 0xAD, 0xDE, 0x0D, 0xF0, 0xED, 0xFE, # IOMMU base address 0x00, 0x00, # PCI Segment Group 0x00, 0x00, # IOMMU info 0xBE, 0xBA, 0xAD, 0xAB ]) # IOMMU Feature Reporting IvrsParserTest.ivhd_10h = IVRS_TABLE.IVHD_STRUCT(ivhd_t_10h) self.assertNotEqual(IvrsParserTest.ivhd_10h.Encode(), None) self.assertEqual(IvrsParserTest.ivhd_10h.Type, IVRS_TABLE.IVHD_STRUCT.IVHD_TYPE.TYPE_10H) self.assertEqual(IvrsParserTest.ivhd_10h.Flags, 0x90) self.assertEqual(IvrsParserTest.ivhd_10h.Length, 0x18) self.assertEqual(IvrsParserTest.ivhd_10h.DeviceID, 0x02) self.assertEqual(IvrsParserTest.ivhd_10h.CapabilityOffset, 0x40) self.assertEqual(IvrsParserTest.ivhd_10h.IOMMUBaseAddress, 0xFEEDF00DDEADBEEF) self.assertEqual(IvrsParserTest.ivhd_10h.SegmentGroup, 0) self.assertEqual(IvrsParserTest.ivhd_10h.IOMMUInfo, 0) self.assertEqual(IvrsParserTest.ivhd_10h.IOMMUFeatureInfo, 0xABADBABE)
def test_ivrs_parser_ivrs_empty(self): ivrs_header = bytes([ 0x49, 0x56, 0x52, 0x53, # Signature: IVRS 0x30, 0x00, 0x00, 0x00, # Length 0x02, # Revision 0x9C, # Checksum 0x41, 0x4D, 0x44, 0x20, 0x20, 0x20, # OEM ID: 'AMD ' 0x41, 0x4D, 0x44, 0x20, 0x49, 0x56, 0x52, 0x53, # OEM Table ID: 'AMD IVRS' 0x01, 0x00, 0x00, 0x00, # OEM Revision 0x41, 0x4D, 0x44, 0x20, # CreatorID: 'AMD ' 0x00, 0x00, 0x00, 0x00, # Creator revision 0x43, 0x30, 0x20, 0x00, # IVinfo 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]) # Reserved: 0 IvrsParserTest.ivrs = IVRS_TABLE(ivrs_header) self.assertNotEqual(IvrsParserTest.ivrs.Encode(), None) self.assertEqual(IvrsParserTest.ivrs.acpi_header.Signature, b'IVRS') self.assertEqual(IvrsParserTest.ivrs.acpi_header.Length, 0x30) self.assertEqual(IvrsParserTest.ivrs.acpi_header.Revision, 0x02) self.assertEqual(IvrsParserTest.ivrs.acpi_header.Checksum, 0x9C) self.assertEqual(IvrsParserTest.ivrs.acpi_header.OEMID, b'AMD ') self.assertEqual(IvrsParserTest.ivrs.acpi_header.OEMTableID, b'AMD IVRS') self.assertEqual(IvrsParserTest.ivrs.acpi_header.OEMRevision, 1) self.assertEqual(IvrsParserTest.ivrs.acpi_header.CreatorID, b'AMD ') self.assertEqual(IvrsParserTest.ivrs.acpi_header.CreatorRevision, 0) self.assertEqual(IvrsParserTest.ivrs.acpi_header.IVinfo, 0x00203043) self.assertEqual(IvrsParserTest.ivrs.acpi_header.Reserved, 0)