dev-arm: Carve out a portion of VExpress_GEM5 for the bootloader

This patch is carving out a portion of VExpress_GEM5 memory for the
bootloader. Prior to this patch this was only happening
conditionally/dynamically via the setupBootLoader call.  With this patch
the region is always present and the setupBootLoader doesn't instantiate
memory, it is only setting up some bootloader parameters.

Change-Id: Iaa5cdf471b14e8faa37353a25631bf7c6fc64afc
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21604
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/dev/arm/RealView.py b/src/dev/arm/RealView.py
index 3586f20..1ff098e 100644
--- a/src/dev/arm/RealView.py
+++ b/src/dev/arm/RealView.py
@@ -551,6 +551,8 @@
     _off_chip_ranges = []
 
     def _attach_device(self, device, bus, dma_ports=None):
+        if hasattr(device, "port"):
+            device.port = bus.master
         if hasattr(device, "pio"):
             device.pio = bus.master
         if hasattr(device, "dma"):
@@ -589,11 +591,6 @@
         self._attach_io(self._off_chip_devices(), *args, **kwargs)
 
     def setupBootLoader(self, mem_bus, cur_sys, loc):
-        cur_sys.bootmem = SimpleMemory(
-            range = AddrRange('2GB', size = '64MB'),
-            conf_table_reported = False)
-        if mem_bus is not None:
-            cur_sys.bootmem.port = mem_bus.master
         cur_sys.boot_loader = loc('boot.arm')
         cur_sys.atags_addr = 0x100
         cur_sys.load_offset = 0
@@ -646,6 +643,7 @@
     def _on_chip_devices(self):
         devices = [
             self.gic, self.vgic,
+            self.bootmem,
             self.local_cpu_timer
         ]
         if hasattr(self, "gicv2m"):
@@ -675,6 +673,8 @@
                             BAR1 = 0x1C1A0100, BAR1Size = '4096B',
                             BAR0LegacyIO = True, BAR1LegacyIO = True)
 
+    bootmem        = SimpleMemory(range = AddrRange('64MB'),
+                                  conf_table_reported = False)
     vram           = SimpleMemory(range = AddrRange(0x18000000, size='32MB'),
                                   conf_table_reported = False)
     rtc            = PL031(pio_addr=0x1C170000, int_num=36)
@@ -737,10 +737,6 @@
         self.gicv2m.frames = [Gicv2mFrame(spi_base=256, spi_len=64, addr=0x2C1C0000)]
 
     def setupBootLoader(self, mem_bus, cur_sys, loc):
-        cur_sys.bootmem = SimpleMemory(range = AddrRange('64MB'),
-                                       conf_table_reported = False)
-        if mem_bus is not None:
-            cur_sys.bootmem.port = mem_bus.master
         if not cur_sys.boot_loader:
             cur_sys.boot_loader = loc('boot_emm.arm')
         cur_sys.atags_addr = 0x8000000
@@ -756,10 +752,6 @@
         pci_pio_base=0x2f000000)
 
     def setupBootLoader(self, mem_bus, cur_sys, loc):
-        cur_sys.bootmem = SimpleMemory(range=AddrRange(0, size='64MB'),
-                                       conf_table_reported=False)
-        if mem_bus is not None:
-            cur_sys.bootmem.port = mem_bus.master
         if not cur_sys.boot_loader:
             cur_sys.boot_loader = loc('boot_emm.arm64')
         cur_sys.atags_addr = 0x8000000
@@ -872,6 +864,9 @@
         AddrRange(0x2f000000, 0x7fffffff),
     ]
 
+    bootmem = SimpleMemory(range=AddrRange(0, size='64MB'),
+                           conf_table_reported=False)
+
     # Platform control device (off-chip)
     realview_io = RealViewCtrl(proc_id0=0x14000000, proc_id1=0x14000000,
                                idreg=0x02250000, pio_addr=0x1c010000)
@@ -887,6 +882,7 @@
     def _on_chip_devices(self):
         return [
             self.generic_timer,
+            self.bootmem,
         ]
 
     ### Off-chip devices ###
@@ -936,10 +932,6 @@
         self._attach_device(device, *args, **kwargs)
 
     def setupBootLoader(self, mem_bus, cur_sys, loc):
-        cur_sys.bootmem = SimpleMemory(range=AddrRange(0, size='64MB'),
-                                       conf_table_reported=False)
-        if mem_bus is not None:
-            cur_sys.bootmem.port = mem_bus.master
         if not cur_sys.boot_loader:
             cur_sys.boot_loader = [ loc('boot_emm.arm64'), loc('boot_emm.arm') ]
         cur_sys.atags_addr = 0x8000000