#include "config.h"
#include "sim.h"
#include "mmu.h"
-#include "htif.h"
#include "disasm.h"
#include "gdbserver.h"
#include <cinttypes>
processor_t::processor_t(const char* isa, sim_t* sim, uint32_t id,
bool halt_on_reset)
: debug(false), sim(sim), ext(NULL), disassembler(new disassembler_t),
- id(id), run(false), halt_on_reset(halt_on_reset)
+ id(id), halt_on_reset(halt_on_reset)
{
parse_isa_string(isa);
mmu = new mmu_t(sim, this);
- reset(true);
+ reset();
register_base_instructions();
}
#endif
}
-void processor_t::reset(bool value)
+void processor_t::reset()
{
- if (run == !value)
- return;
- run = !value;
-
state.reset();
state.dcsr.halt = halt_on_reset;
halt_on_reset = false;
return vm == VM_MBARE;
}
-static int paddr_bits(reg_t vm)
+int processor_t::paddr_bits()
{
- switch (vm) {
- case VM_SV32: return 34;
- case VM_SV39: return 50;
- case VM_SV48: return 50;
- default: abort();
- }
+ assert(xlen == max_xlen);
+ return max_xlen == 64 ? 50 : 34;
}
void processor_t::set_csr(int which, reg_t val)
(state.mie & ~state.mideleg) | (val & state.mideleg));
case CSR_SPTBR: {
// upper bits of sptbr are the ASID; we only support ASID = 0
- reg_t vm = get_field(state.mstatus, MSTATUS_VM);
- state.sptbr = val & (((reg_t)1 << (paddr_bits(vm) - PGSHIFT)) - 1);
+ state.sptbr = val & (((reg_t)1 << (paddr_bits() - PGSHIFT)) - 1);
break;
}
case CSR_SEPC: state.sepc = val; break;