stdlib: Call setup_memory_ranges() from the constructor
`setup_memory_ranges()`, now `_setup_memory_ranges()`, had to be called by subclasses. Since `setup_memory_ranges() was always called at the top of the `_setup_board()` function (or could be), this function is now automatically called within the AbstractBoard's constructor prior to `_setup_board` and `_connect_things`. Change-Id: I6bf3231666b86059ffc484cfca44e45cfde52ea6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52883 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -86,6 +86,8 @@ class AbstractBoard(System):
|
||||
self.memory = memory
|
||||
self.cache_hierarchy = cache_hierarchy
|
||||
|
||||
# Setup the board and memory system's memory ranges.
|
||||
self._setup_memory_ranges()
|
||||
|
||||
# Setup board properties unique to the board being constructed.
|
||||
self._setup_board()
|
||||
@@ -143,8 +145,9 @@ class AbstractBoard(System):
|
||||
"""
|
||||
This function is called in the AbstractBoard constructor, before the
|
||||
memory, processor, and cache hierarchy components are incorporated via
|
||||
`_connect_thing()`. This function should be overridden by boards to
|
||||
specify components, connections unique to that board.
|
||||
`_connect_thing()`, but after the `_setup_memory_ranges()` function.
|
||||
This function should be overridden by boards to specify components,
|
||||
connections unique to that board.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -212,18 +215,24 @@ class AbstractBoard(System):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def setup_memory_ranges(self) -> None:
|
||||
def _setup_memory_ranges(self) -> None:
|
||||
"""
|
||||
Set the memory ranges for this board.
|
||||
Set the memory ranges for this board and memory system.
|
||||
|
||||
This is called by at the end of the constructor. It can query the
|
||||
board's memory to determine the size and the set the memory ranges on
|
||||
the memory if it needs to move the memory devices.
|
||||
This is called in the constructor, prior to `_setup_board` and
|
||||
`_connect_things`. It should query the board's memory to determine the
|
||||
size and the set the memory ranges on the memory system and on the
|
||||
board.
|
||||
|
||||
The simplest implementation just sets the board's memory range to be
|
||||
the size of memory and memory's memory range to be the same as the
|
||||
board. Full system implementations will likely need something more
|
||||
complicated.
|
||||
The simplest implementation sets the board's memory range to the size
|
||||
of memory and memory system's range to be the same as the board. Full
|
||||
system implementations will likely need something more complicated.
|
||||
|
||||
Notes
|
||||
-----
|
||||
* This *must* be called prior to the incorporation of the cache
|
||||
hierarchy (via `_connect_things`) as cache hierarchies depend upon
|
||||
knowing the memory system's ranges.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -121,9 +121,6 @@ class RiscvBoard(AbstractBoard, KernelDiskWorkload):
|
||||
self._on_chip_devices = [self.platform.clint, self.platform.plic]
|
||||
self._off_chip_devices = [self.platform.uart, self.disk]
|
||||
|
||||
# Set up the memory ranges
|
||||
self.setup_memory_ranges()
|
||||
|
||||
def _setup_io_devices(self) -> None:
|
||||
"""Connect the I/O devices to the I/O bus"""
|
||||
|
||||
@@ -189,7 +186,7 @@ class RiscvBoard(AbstractBoard, KernelDiskWorkload):
|
||||
return self.iobus.mem_side_ports
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def setup_memory_ranges(self):
|
||||
def _setup_memory_ranges(self):
|
||||
memory = self.get_memory()
|
||||
mem_size = memory.get_size()
|
||||
self.mem_ranges = [AddrRange(start=0x80000000, size=mem_size)]
|
||||
|
||||
@@ -67,8 +67,7 @@ class SimpleBoard(AbstractBoard, SEBinaryWorkload):
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
# Set up the memory ranges
|
||||
self.setup_memory_ranges()
|
||||
pass
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def has_io_bus(self) -> bool:
|
||||
@@ -104,7 +103,7 @@ class SimpleBoard(AbstractBoard, SEBinaryWorkload):
|
||||
)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def setup_memory_ranges(self) -> None:
|
||||
def _setup_memory_ranges(self) -> None:
|
||||
memory = self.get_memory()
|
||||
|
||||
# The simple board just has one memory range that is the size of the
|
||||
|
||||
@@ -65,7 +65,7 @@ class TestBoard(AbstractBoard):
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
self.setup_memory_ranges()
|
||||
pass
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def has_io_bus(self) -> bool:
|
||||
@@ -101,7 +101,7 @@ class TestBoard(AbstractBoard):
|
||||
)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def setup_memory_ranges(self) -> None:
|
||||
def _setup_memory_ranges(self) -> None:
|
||||
memory = self.get_memory()
|
||||
|
||||
# The simple board just has one memory range that is the size of the
|
||||
|
||||
@@ -96,9 +96,6 @@ class X86Board(AbstractBoard, KernelDiskWorkload):
|
||||
# North Bridge
|
||||
self.iobus = IOXBar()
|
||||
|
||||
# Figure out the memory ranges.
|
||||
self.setup_memory_ranges()
|
||||
|
||||
# Set up all of the I/O.
|
||||
self._setup_io_devices()
|
||||
|
||||
@@ -276,7 +273,7 @@ class X86Board(AbstractBoard, KernelDiskWorkload):
|
||||
return self.iobus.mem_side_ports
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def setup_memory_ranges(self):
|
||||
def _setup_memory_ranges(self):
|
||||
memory = self.get_memory()
|
||||
|
||||
if memory.get_size() > toMemorySize("3GB"):
|
||||
|
||||
Reference in New Issue
Block a user