Allow reset vector to be set dynamically
A chip's power-up sequence, or awake-from-sleep sequence, may wish to set the reset PC based upon dynamic properties, e.g., the settings of external pins. Support this by passing the reset vector to the Coreplex. ExampleTop simply hard-wires the reset vector, as was the case before. Additionally, allow MTVEC to *not* be reset. In most cases, including riscv-tests, pk, and bbl, overriding MTVEC is one of the first things that the boot sequence does. So the reset value is superfluous.
This commit is contained in:
@ -311,7 +311,9 @@ trait PeripheryBootROM extends LazyModule {
|
||||
implicit val p: Parameters
|
||||
val peripheryBus: TLXbar
|
||||
|
||||
val rom = LazyModule(new TLROM(0x1000, 0x1000, GenerateBootROM(p)) { override def name = "bootrom" })
|
||||
val address = 0x1000
|
||||
val size = 0x1000
|
||||
val rom = LazyModule(new TLROM(address, size, GenerateBootROM(p, address)) { override def name = "bootrom" })
|
||||
rom.node := TLFragmenter(peripheryBus.node, 4, 256)
|
||||
}
|
||||
|
||||
@ -365,3 +367,10 @@ trait PeripheryTestBusMasterModule {
|
||||
implicit val p: Parameters
|
||||
val outer: PeripheryTestBusMaster
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
trait HardwiredResetVector {
|
||||
val coreplex: Coreplex
|
||||
coreplex.io.resetVector := UInt(0x1000) // boot ROM
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ class ExampleTopBundle(p: Parameters, c: Coreplex) extends BaseTopBundle(p, c)
|
||||
class ExampleTopModule[+L <: ExampleTop, +B <: ExampleTopBundle](p: Parameters, l: L, b: Coreplex => B) extends BaseTopModule(p, l, b)
|
||||
with PeripheryBootROMModule with PeripheryDebugModule with PeripheryExtInterruptsModule with PeripheryCoreplexLocalInterrupterModule
|
||||
with PeripheryMasterMemModule with PeripheryMasterMMIOModule with PeripherySlaveModule
|
||||
with HardwiredResetVector
|
||||
|
||||
/** Example Top with TestRAM */
|
||||
class ExampleTopWithTestRAM(q: Parameters) extends ExampleTop(q)
|
||||
|
@ -168,21 +168,14 @@ object GenerateConfigString {
|
||||
}
|
||||
|
||||
object GenerateBootROM {
|
||||
def apply(p: Parameters) = {
|
||||
def apply(p: Parameters, address: BigInt) = {
|
||||
val romdata = Files.readAllBytes(Paths.get(p(BootROMFile)))
|
||||
val rom = ByteBuffer.wrap(romdata)
|
||||
|
||||
rom.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
// for now, have the reset vector jump straight to memory
|
||||
val memBase = (
|
||||
if (p(GlobalAddrMap) contains "mem") p(GlobalAddrMap)("mem")
|
||||
else p(GlobalAddrMap)("io:int:dmem0")
|
||||
).start
|
||||
val resetToMemDist = memBase - p(ResetVector)
|
||||
require(resetToMemDist == (resetToMemDist.toInt >> 12 << 12))
|
||||
val configStringAddr = p(ResetVector).toInt + rom.capacity
|
||||
|
||||
require(address == address.toInt)
|
||||
val configStringAddr = address.toInt + rom.capacity
|
||||
require(rom.getInt(12) == 0,
|
||||
"Config string address position should not be occupied by code")
|
||||
rom.putInt(12, configStringAddr)
|
||||
|
Reference in New Issue
Block a user