stdlib: Move 'connect_things' to AbstractBoard constructor
This patch moves 'connect_things' to the AbstractBoard constructor, thereby meaning it does not need to be called directly in gem5 configuration scripts. This method has been changed to private as a result. As boards that inherit from AbstractBoard require certain things to be setup prior to `connect_things` being called, a new abstract function, `_setup_board` has been created. This is called in the AbstractBoard constructor before `connect_things` and can be overridden by boards to setup board properties as required. Change-Id: I558a4321b850a6b19e20b7d56d0bcae5805114b6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52184 Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -75,10 +75,6 @@ board = SimpleBoard(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
# This method must be called to connect all the components specified during
|
||||
# the board's construction.
|
||||
board.connect_things()
|
||||
|
||||
# Here we set the workload. In this case we want to run a simple "Hello World!"
|
||||
# program compiled to the ARM ISA. The `Resource` class will automatically
|
||||
# download the binary from the gem5 Resources cloud bucket if it's not already
|
||||
|
||||
@@ -78,8 +78,6 @@ board = RiscvBoard(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
board.connect_things()
|
||||
|
||||
# Set the Full System workload.
|
||||
board.set_kernel_disk_workload(
|
||||
kernel=Resource("riscv-bootloader-vmlinux-5.10"),
|
||||
|
||||
@@ -102,8 +102,6 @@ board = X86Board(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
board.connect_things()
|
||||
|
||||
# Here we set the Full System workload.
|
||||
# The `set_kernel_disk_workload` function for the X86Board takes a kernel, a
|
||||
# disk image, and, optionally, a command to run.
|
||||
|
||||
@@ -92,7 +92,12 @@ class AbstractBoard(System):
|
||||
self.memory = memory
|
||||
self.cache_hierarchy = cache_hierarchy
|
||||
|
||||
self.setup_memory_ranges()
|
||||
|
||||
# Setup board properties unique to the board being constructed.
|
||||
self._setup_board()
|
||||
|
||||
# Connect the memory, processor, and cache hierarchy.
|
||||
self._connect_things()
|
||||
|
||||
def get_processor(self) -> "AbstractProcessor":
|
||||
"""Get the processor connected to the board.
|
||||
@@ -135,11 +140,20 @@ class AbstractBoard(System):
|
||||
|
||||
def get_clock_domain(self) -> ClockDomain:
|
||||
"""Get the clock domain.
|
||||
|
||||
:returns: The clock domain.
|
||||
"""
|
||||
return self.clk_domain
|
||||
|
||||
@abstractmethod
|
||||
def _setup_board(self) -> None:
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
# Technically `get_dma_ports` returns a list. This list could be empty to
|
||||
# indicate the presense of dma ports. Though I quite like having this
|
||||
# boolean to quickly check a board.
|
||||
@@ -220,7 +234,7 @@ class AbstractBoard(System):
|
||||
raise NotImplementedError
|
||||
|
||||
@final
|
||||
def connect_things(self) -> None:
|
||||
def _connect_things(self) -> None:
|
||||
"""Connects all the components to the board.
|
||||
|
||||
The order of this board is always:
|
||||
|
||||
@@ -90,9 +90,10 @@ class RiscvBoard(AbstractBoard, KernelDiskWorkload):
|
||||
super().__init__(
|
||||
clk_freq, processor, memory, cache_hierarchy, exit_on_work_items
|
||||
)
|
||||
|
||||
requires(isa_required=ISA.RISCV)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
self.workload = RiscvLinux()
|
||||
|
||||
# Contains a CLINT, PLIC, UART, and some functions for the dtb, etc.
|
||||
|
||||
@@ -72,6 +72,8 @@ class SimpleBoard(AbstractBoard):
|
||||
exit_on_work_items=exit_on_work_items,
|
||||
)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
# Set up the memory ranges
|
||||
self.setup_memory_ranges()
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ class TestBoard(AbstractBoard):
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
self.setup_memory_ranges()
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
|
||||
@@ -90,6 +90,8 @@ class X86Board(AbstractBoard, KernelDiskWorkload):
|
||||
|
||||
requires(isa_required=ISA.X86)
|
||||
|
||||
@overrides(AbstractBoard)
|
||||
def _setup_board(self) -> None:
|
||||
self.pc = Pc()
|
||||
|
||||
self.workload = X86FsLinux()
|
||||
|
||||
@@ -195,8 +195,6 @@ motherboard = X86Board(
|
||||
exit_on_work_items=True,
|
||||
)
|
||||
|
||||
motherboard.connect_things()
|
||||
|
||||
# Set the Full System workload.
|
||||
motherboard.set_kernel_disk_workload(
|
||||
kernel=Resource(
|
||||
|
||||
@@ -178,8 +178,6 @@ motherboard = X86Board(
|
||||
exit_on_work_items=True,
|
||||
)
|
||||
|
||||
motherboard.connect_things()
|
||||
|
||||
kernal_args = motherboard.get_default_kernel_args() + [args.kernel_args]
|
||||
|
||||
# Set the Full System workload.
|
||||
|
||||
@@ -214,8 +214,6 @@ board = X86Board(
|
||||
exit_on_work_items=True,
|
||||
)
|
||||
|
||||
board.connect_things()
|
||||
|
||||
# The command to run.
|
||||
command = (
|
||||
"cd /home/gem5/parsec-benchmark\n"
|
||||
|
||||
@@ -143,8 +143,6 @@ board = RiscvBoard(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
board.connect_things()
|
||||
|
||||
# Set the Full System workload.
|
||||
board.set_kernel_disk_workload(
|
||||
kernel=Resource(
|
||||
|
||||
@@ -93,8 +93,6 @@ motherboard = SimpleBoard(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
motherboard.connect_things()
|
||||
|
||||
# Set the workload
|
||||
binary = Resource(args.resource,
|
||||
resource_directory=args.resource_directory)
|
||||
|
||||
@@ -131,8 +131,6 @@ motherboard = TestBoard(
|
||||
cache_hierarchy=cache_hierarchy,
|
||||
)
|
||||
|
||||
motherboard.connect_things()
|
||||
|
||||
root = Root(full_system=False, system=motherboard)
|
||||
|
||||
m5.instantiate()
|
||||
|
||||
@@ -185,8 +185,6 @@ motherboard = X86Board(
|
||||
exit_on_work_items=True,
|
||||
)
|
||||
|
||||
motherboard.connect_things()
|
||||
|
||||
kernal_args = motherboard.get_default_kernel_args()
|
||||
if args.boot_type == "init":
|
||||
kernal_args.append("init=/root/exit.sh")
|
||||
|
||||
Reference in New Issue
Block a user