#define IRQ_COP 8
#define IRQ_HOST 9
-#define IMPL_ROCKET 1
-
#define DEFAULT_RSTVEC 0x0
#define DEFAULT_NMIVEC 0x4
#define DEFAULT_MTVEC 0x8
#define CSR_UARCH14 0xcce
#define CSR_UARCH15 0xccf
#define CSR_SSTATUS 0x100
-#define CSR_STVEC 0x101
#define CSR_SIE 0x104
+#define CSR_STVEC 0x105
#define CSR_SSCRATCH 0x140
#define CSR_SEPC 0x141
#define CSR_SCAUSE 0x142
#define CSR_STIME 0xd01
#define CSR_STIMEW 0xa01
#define CSR_MSTATUS 0x300
-#define CSR_MTVEC 0x301
#define CSR_MEDELEG 0x302
#define CSR_MIDELEG 0x303
#define CSR_MIE 0x304
+#define CSR_MTVEC 0x305
#define CSR_MTIMECMP 0x321
#define CSR_MSCRATCH 0x340
#define CSR_MEPC 0x341
#define CSR_MIP 0x344
#define CSR_MIPI 0x345
#define CSR_MTIME 0x701
-#define CSR_MCPUID 0xf00
-#define CSR_MIMPID 0xf01
+#define CSR_MISA 0xf00
+#define CSR_MVENDORID 0xf01
+#define CSR_MARCHID 0xf02
+#define CSR_MIMPID 0xf03
+#define CSR_MCFGADDR 0xf04
#define CSR_MHARTID 0xf10
#define CSR_MTOHOST 0x7c0
#define CSR_MFROMHOST 0x7c1
#define CSR_MRESET 0x7c2
-#define CSR_MIOBASE 0x7c4
#define CSR_CYCLEH 0xc80
#define CSR_TIMEH 0xc81
#define CSR_INSTRETH 0xc82
DECLARE_CSR(uarch14, CSR_UARCH14)
DECLARE_CSR(uarch15, CSR_UARCH15)
DECLARE_CSR(sstatus, CSR_SSTATUS)
-DECLARE_CSR(stvec, CSR_STVEC)
DECLARE_CSR(sie, CSR_SIE)
+DECLARE_CSR(stvec, CSR_STVEC)
DECLARE_CSR(sscratch, CSR_SSCRATCH)
DECLARE_CSR(sepc, CSR_SEPC)
DECLARE_CSR(scause, CSR_SCAUSE)
DECLARE_CSR(stime, CSR_STIME)
DECLARE_CSR(stimew, CSR_STIMEW)
DECLARE_CSR(mstatus, CSR_MSTATUS)
-DECLARE_CSR(mtvec, CSR_MTVEC)
DECLARE_CSR(medeleg, CSR_MEDELEG)
DECLARE_CSR(mideleg, CSR_MIDELEG)
DECLARE_CSR(mie, CSR_MIE)
+DECLARE_CSR(mtvec, CSR_MTVEC)
DECLARE_CSR(mtimecmp, CSR_MTIMECMP)
DECLARE_CSR(mscratch, CSR_MSCRATCH)
DECLARE_CSR(mepc, CSR_MEPC)
DECLARE_CSR(mip, CSR_MIP)
DECLARE_CSR(mipi, CSR_MIPI)
DECLARE_CSR(mtime, CSR_MTIME)
-DECLARE_CSR(mcpuid, CSR_MCPUID)
+DECLARE_CSR(misa, CSR_MISA)
+DECLARE_CSR(mvendorid, CSR_MVENDORID)
+DECLARE_CSR(marchid, CSR_MARCHID)
DECLARE_CSR(mimpid, CSR_MIMPID)
+DECLARE_CSR(mcfgaddr, CSR_MCFGADDR)
DECLARE_CSR(mhartid, CSR_MHARTID)
DECLARE_CSR(mtohost, CSR_MTOHOST)
DECLARE_CSR(mfromhost, CSR_MFROMHOST)
DECLARE_CSR(mreset, CSR_MRESET)
-DECLARE_CSR(miobase, CSR_MIOBASE)
DECLARE_CSR(cycleh, CSR_CYCLEH)
DECLARE_CSR(timeh, CSR_TIMEH)
DECLARE_CSR(instreth, CSR_INSTRETH)
const char* all_subsets = "imafdc";
max_xlen = 64;
- cpuid = reg_t(2) << 62;
+ isa = reg_t(2) << 62;
if (strncmp(p, "rv32", 4) == 0)
- max_xlen = 32, cpuid = 0, p += 4;
+ max_xlen = 32, isa = 0, p += 4;
else if (strncmp(p, "rv64", 4) == 0)
p += 4;
else if (strncmp(p, "rv", 2) == 0)
bad_isa_string(str);
}
- isa = "rv" + std::to_string(max_xlen) + p;
- cpuid |= 1L << ('s' - 'a'); // advertise support for supervisor mode
+ isa_string = "rv" + std::to_string(max_xlen) + p;
+ isa |= 1L << ('s' - 'a'); // advertise support for supervisor mode
while (*p) {
- cpuid |= 1L << (*p - 'a');
+ isa |= 1L << (*p - 'a');
if (auto next = strchr(all_subsets, *p)) {
all_subsets = next + 1;
if (supports_extension('D') && !supports_extension('F'))
bad_isa_string(str);
+
+ // if we have IMAFD, advertise G, too
+ if (supports_extension('I') && supports_extension('M') &&
+ supports_extension('A') && supports_extension('D'))
+ isa |= 1L << ('g' - 'a');
+
+ // advertise support for supervisor and user modes
+ isa |= 1L << ('s' - 'a');
+ isa |= 1L << ('u' - 'a');
}
void state_t::reset()
case CSR_MCAUSE: return state.mcause;
case CSR_MBADADDR: return state.mbadaddr;
case CSR_MTIMECMP: return state.mtimecmp;
- case CSR_MCPUID: return cpuid;
- case CSR_MIMPID: return IMPL_ROCKET;
+ case CSR_MISA: return isa;
+ case CSR_MARCHID: return 0;
+ case CSR_MIMPID: return 0;
+ case CSR_MVENDORID: return 0;
case CSR_MHARTID: return id;
case CSR_MTVEC: return DEFAULT_MTVEC;
case CSR_MEDELEG: return state.medeleg;
case CSR_MFROMHOST:
sim->get_htif()->tick(); // not necessary, but faster
return state.fromhost;
- case CSR_MIOBASE: return sim->memsz;
+ case CSR_MCFGADDR: return sim->memsz;
case CSR_UARCH0:
case CSR_UARCH1:
case CSR_UARCH2: