Implement get_mmconf creator function
authorReto Buerki <reet@codelabs.ch>
Mon, 11 Sep 2017 10:02:02 +0000 (12:02 +0200)
committerReto Buerki <reet@codelabs.ch>
Fri, 15 Sep 2017 11:16:20 +0000 (13:16 +0200)
The function returns an mmconf XML memory region specified by base, bus,
device and function.

src/creator.py
test/test_creator.py

index 39bdc05..d26d356 100644 (file)
@@ -637,6 +637,15 @@ class PciDevicesCreator():
 
         return irqs
 
+    def get_mmconf(self, base, bus, devno, fn):
+        "Return mmconf region for given device"
+        addr = base + (bus * 2 ** 20 + devno * 2 ** 15 + fn * 2 ** 12)
+        return schemadata.schema.deviceMemoryType(
+            name="mmconf",
+            physicalAddress=util.toWord64(str(hex(addr))),
+            size="16#1000#",
+            caching="UC")
+
     def createDeviceFromPath(self, devicepath, devicecapmgr, devicespec,
                              iommugrp):
         device = schemadata.schema.deviceType(name=devicespec.name)
index 4d8f14a..baea7f0 100644 (file)
@@ -614,6 +614,14 @@ class TestPciDevicesCreator:
         assert_xbl(dev3_irqs, dev3_testirqs, "irq")
         assert not dev_emptyresource_irqs
 
+        def test_get_mmconf(self):
+            mem = schemadata.schema.deviceMemoryType(
+                name="mmconf",
+                physicalAddress="16#f928_3000#",
+                size="16#1000#",
+                caching="UC")
+            assert_xb(mem, self.pcicreator.get_mmconf(0xf9000000, 2, 16, 3))
+
     def test_createDeviceFromPath(self):
         testloc = os.path.join(self.testdir, "devices_test")
         devpath = os.path.join(testloc, "0000:00:1f.3")