GenerateBootROM: use compiled DTB
This commit is contained in:
parent
17b1ee3037
commit
9a2f0d01a1
@ -25,6 +25,7 @@ trait CoreplexRISCVPlatform extends CoreplexNetwork {
|
|||||||
plic.intnode := intBar.intnode
|
plic.intnode := intBar.intnode
|
||||||
|
|
||||||
lazy val dts = DTS(bindingTree)
|
lazy val dts = DTS(bindingTree)
|
||||||
|
lazy val dtb = DTB(dts)
|
||||||
lazy val json = JSON(bindingTree)
|
lazy val json = JSON(bindingTree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ package diplomacy
|
|||||||
|
|
||||||
import Chisel._
|
import Chisel._
|
||||||
import config._
|
import config._
|
||||||
|
import sys.process._
|
||||||
|
import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
|
||||||
|
|
||||||
case object DTSModel extends Field[String]
|
case object DTSModel extends Field[String]
|
||||||
case object DTSCompat extends Field[Seq[String]] // -dev, -soc
|
case object DTSCompat extends Field[Seq[String]] // -dev, -soc
|
||||||
@ -115,3 +117,17 @@ object DTS
|
|||||||
case x: ResourceMap => fmtMap(x, indent, cells)
|
case x: ResourceMap => fmtMap(x, indent, cells)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class DTB(contents: Seq[Byte])
|
||||||
|
object DTB
|
||||||
|
{
|
||||||
|
def apply(dts: String): DTB = {
|
||||||
|
val instream = new ByteArrayInputStream(dts.getBytes("UTF-8"))
|
||||||
|
val outstream = new ByteArrayOutputStream
|
||||||
|
val proc = "dtc -O dtb" #< instream #> outstream
|
||||||
|
require (proc.! == 0, "Failed to run dtc; is it in your path?")
|
||||||
|
instream.close
|
||||||
|
outstream.close
|
||||||
|
DTB(outstream.toByteArray)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -307,7 +307,7 @@ trait PeripheryBootROM {
|
|||||||
|
|
||||||
private val bootrom_address = 0x1000
|
private val bootrom_address = 0x1000
|
||||||
private val bootrom_size = 0x1000
|
private val bootrom_size = 0x1000
|
||||||
private lazy val bootrom_contents = GenerateBootROM(p, bootrom_address, coreplex.dts)
|
private lazy val bootrom_contents = GenerateBootROM(p, bootrom_address, coreplex.dtb)
|
||||||
val bootrom = LazyModule(new TLROM(bootrom_address, bootrom_size, bootrom_contents, true, peripheryBusConfig.beatBytes))
|
val bootrom = LazyModule(new TLROM(bootrom_address, bootrom_size, bootrom_contents, true, peripheryBusConfig.beatBytes))
|
||||||
bootrom.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
|
bootrom.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
|
||||||
}
|
}
|
||||||
|
@ -53,17 +53,17 @@ class GlobalVariable[T] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object GenerateBootROM {
|
object GenerateBootROM {
|
||||||
def apply(p: Parameters, address: BigInt, dts: String) = {
|
def apply(p: Parameters, address: BigInt, dtb: DTB) = {
|
||||||
val romdata = Files.readAllBytes(Paths.get(p(BootROMFile)))
|
val romdata = Files.readAllBytes(Paths.get(p(BootROMFile)))
|
||||||
val rom = ByteBuffer.wrap(romdata)
|
val rom = ByteBuffer.wrap(romdata)
|
||||||
|
|
||||||
rom.order(ByteOrder.LITTLE_ENDIAN)
|
rom.order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
|
||||||
require(address == address.toInt)
|
require(address == address.toInt)
|
||||||
val dtsAddr = address.toInt + rom.capacity
|
val dtbAddr = address.toInt + rom.capacity
|
||||||
require(rom.getInt(12) == 0,
|
require(rom.getInt(12) == 0,
|
||||||
"DTS address position should not be occupied by code")
|
"DTS address position should not be occupied by code")
|
||||||
rom.putInt(12, dtsAddr)
|
rom.putInt(12, dtbAddr)
|
||||||
rom.array() ++ (dts.getBytes.toSeq)
|
rom.array() ++ dtb.contents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user