dev: Separate generateDeviceTree into a RiscvUart8250 SimObject.

The only difference between the RiscvUart8250 and the regular Uart8250
is that the Riscv version knows how to generate a device tree node
appropriate for use in a Riscv system. This lets us drop the TARGET_ISA
check from that method, since that should be called iff the target
system is Riscv.

Also update the HiFive platform to use the RiscvUart8250 so that it can
continue to generate device trees successfully.

Change-Id: I306596efffed5e5eed337d3db492d2782ebfaa8d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52144
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:
Gabe Black
2021-10-27 03:16:28 -07:00
parent 3eae203423
commit 996f0ce168
2 changed files with 15 additions and 15 deletions

View File

@@ -38,7 +38,7 @@ from m5.objects.PMAChecker import PMAChecker
from m5.objects.Clint import Clint
from m5.objects.Plic import Plic
from m5.objects.RTC import RiscvRTC
from m5.objects.Uart import Uart8250
from m5.objects.Uart import RiscvUart8250
from m5.objects.Terminal import Terminal
from m5.params import *
from m5.proxy import *
@@ -106,7 +106,7 @@ class HiFive(Platform):
plic = Param.Plic(Plic(pio_addr=0xc000000), "PLIC")
# Uart
uart = Uart8250(pio_addr=0x10000000)
uart = RiscvUart8250(pio_addr=0x10000000)
# Int source ID to redirect console interrupts to
# Set to 0 if using a pci interrupt for Uart instead
uart_int_id = Param.Int(0xa, "PLIC Uart interrupt ID")

View File

@@ -67,17 +67,17 @@ class Uart8250(Uart):
cxx_class = 'gem5::Uart8250'
pio_size = Param.Addr(0x8, "Size of address range")
class RiscvUart8250(Uart8250):
def generateDeviceTree(self, state):
if buildEnv['TARGET_ISA'] == "riscv":
node = self.generateBasicPioDeviceNode(
state, "uart", self.pio_addr, self.pio_size)
platform = self.platform.unproxy(self)
plic = platform.plic
node.append(
FdtPropertyWords("interrupts", [platform.uart_int_id]))
node.append(
FdtPropertyWords("clock-frequency", [0x384000]))
node.append(
FdtPropertyWords("interrupt-parent", state.phandle(plic)))
node.appendCompatible(["ns8250"])
yield node
node = self.generateBasicPioDeviceNode(
state, "uart", self.pio_addr, self.pio_size)
platform = self.platform.unproxy(self)
plic = platform.plic
node.append(
FdtPropertyWords("interrupts", [platform.uart_int_id]))
node.append(
FdtPropertyWords("clock-frequency", [0x384000]))
node.append(
FdtPropertyWords("interrupt-parent", state.phandle(plic)))
node.appendCompatible(["ns8250"])
yield node