dev-arm: Automatically assign PCI device ids in attachPciDevice
authorCiro Santilli <ciro.santilli@arm.com>
Thu, 24 Oct 2019 16:35:13 +0000 (17:35 +0100)
committerCiro Santilli <ciro.santilli@arm.com>
Thu, 28 Nov 2019 11:13:43 +0000 (11:13 +0000)
Simulation scripts currently need to assign PCI device addresses when
adding new devices. This change moves this responsibility to the
VExpress_GEM5_BASE::attachPciDevice method.

Change-Id: I6d62af8a8f9176d964cc011dd8fb9744154bbb87
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22830
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>

configs/common/FSConfig.py
configs/example/arm/devices.py
src/dev/arm/RealView.py

index b34db4e2656bac9ba99349451f75a5a8aab8118e..55a6e91189e5f809c89b6a474cf1b24c035cbd92 100644 (file)
@@ -365,8 +365,7 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None,
         # Attach off-chip devices
         self.realview.attachIO(self.iobus)
 
-    for dev_id, dev in enumerate(pci_devices):
-        dev.pci_bus, dev.pci_dev, dev.pci_func = (0, dev_id + 1, 0)
+    for dev in pci_devices:
         self.realview.attachPciDevice(
             dev, self.iobus,
             dma_ports=self._dma_ports if ruby else None)
index 16312eb729a1d24154b8d10a47e7e779c73dab27..4615daac2012f09bd2d97a769b02b83f8afa3cfe 100644 (file)
@@ -303,14 +303,10 @@ def simpleSystem(BaseSystem, caches, mem_size, platform=None, **kwargs):
                 self.dmabridge = Bridge(delay='50ns',
                                         ranges=[self.mem_ranges[0]])
 
-            self._pci_devices = 0
             self._clusters = []
             self._num_cpus = 0
 
         def attach_pci(self, dev):
-            dev.pci_bus, dev.pci_dev, dev.pci_func = \
-                (0, self._pci_devices + 1, 0)
-            self._pci_devices += 1
             self.realview.attachPciDevice(dev, self.iobus)
 
         def connect(self):
index 10d3abb2707551d83682685659139198beeb2fb6..6e8630a963a570e950769c14c43e2afbffe16969 100644 (file)
@@ -542,6 +542,7 @@ class RealView(Platform):
     cxx_header = "dev/arm/realview.hh"
     system = Param.System(Parent.any, "system")
     _mem_regions = [ AddrRange(0, size='256MB') ]
+    _num_pci_dev = 0
 
     def _on_chip_devices(self):
         return []
@@ -952,6 +953,10 @@ Interrupts:
 
     def attachPciDevice(self, device, *args, **kwargs):
         device.host = self.pci_host
+        self._num_pci_dev += 1
+        device.pci_bus = 0
+        device.pci_dev = self._num_pci_dev
+        device.pci_func = 0
         self._attach_device(device, *args, **kwargs)
 
     def attachSmmu(self, devices, bus):