Merge pull request #289 from buncram/expose-satp

Expose satp
This commit is contained in:
Dolu1990 2023-01-16 12:45:02 +01:00 committed by GitHub
commit 94f2ea6dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -82,6 +82,7 @@ case class CsrPluginConfig(
deterministicInteruptionEntry : Boolean = false, //Only used for simulatation purposes
wfiOutput : Boolean = false,
withPrivilegedDebug : Boolean = false, //For the official RISC-V debug spec implementation
exportPrivilege : Boolean = false,
var debugTriggers : Int = 2
){
assert(!ucycleAccess.canWrite)
@ -612,6 +613,7 @@ class CsrPlugin(val config: CsrPluginConfig) extends Plugin[VexRiscv] with Excep
contextSwitching = Bool().setName("contextSwitching")
privilege = UInt(2 bits).setName("CsrPlugin_privilege")
if (exportPrivilege) out(privilege)
forceMachineWire = False
if(catchIllegalAccess || ecallGen || withEbreak)

View File

@ -41,7 +41,9 @@ case class MmuPortConfig(portTlbSize : Int, latency : Int = 0, earlyRequireMmuLo
class MmuPlugin(ioRange : UInt => Bool,
virtualRange : UInt => Bool = address => True,
// allowUserIo : Boolean = false,
enableMmuInMachineMode : Boolean = false) extends Plugin[VexRiscv] with MemoryTranslator {
enableMmuInMachineMode : Boolean = false,
exportSatp: Boolean = false
) extends Plugin[VexRiscv] with MemoryTranslator {
var dBusAccess : DBusAccess = null
val portsInfo = ArrayBuffer[MmuPort]()
@ -94,8 +96,10 @@ class MmuPlugin(ioRange : UInt => Bool,
val satp = new Area {
val mode = RegInit(False)
val asid = Reg(Bits(9 bits))
// Bottom 20 bits are used in implementation, but top 2 bits are still stored for OS use.
val ppn = Reg(UInt(22 bits))
val ppn = Reg(UInt(22 bits)) // Bottom 20 bits are used in implementation, but top 2 bits are still stored for OS use.
if(exportSatp) {
out(mode, asid, ppn)
}
}
for(offset <- List(CSR.MSTATUS, CSR.SSTATUS)) csrService.rw(offset, 19 -> status.mxr, 18 -> status.sum, 17 -> status.mprv)