aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-03-10 01:07:03 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-03-10 01:08:31 -0800
commitd5278834830bdd2cb8586f25fe05ae917b0eb949 (patch)
treebef4b4c1405dc56cb0a3e37711a7e858d2f2a95b
parent469c5f16a7ce5a913248367a420d43dc3518eb88 (diff)
downloadriscv-pk-d5278834830bdd2cb8586f25fe05ae917b0eb949.zip
riscv-pk-d5278834830bdd2cb8586f25fe05ae917b0eb949.tar.gz
riscv-pk-d5278834830bdd2cb8586f25fe05ae917b0eb949.tar.bz2
Misc improvements
-rw-r--r--machine/emulation.c4
-rw-r--r--machine/minit.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/machine/emulation.c b/machine/emulation.c
index 5e3ca2e..dad86f9 100644
--- a/machine/emulation.c
+++ b/machine/emulation.c
@@ -61,7 +61,7 @@ void illegal_insn_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc)
" .word truly_illegal_insn\n"
" .word truly_illegal_insn\n"
" .word truly_illegal_insn\n"
- " .word emulate_system\n"
+ " .word emulate_system_opcode\n"
" .word truly_illegal_insn\n"
" .word truly_illegal_insn\n"
" .word truly_illegal_insn\n"
@@ -153,7 +153,7 @@ static inline int emulate_write_csr(int num, uintptr_t value, uintptr_t mstatus)
return -1;
}
-DECLARE_EMULATION_FUNC(emulate_system)
+DECLARE_EMULATION_FUNC(emulate_system_opcode)
{
int rs1_num = (insn >> 15) & 0x1f;
uintptr_t rs1_val = GET_RS1(insn, regs);
diff --git a/machine/minit.c b/machine/minit.c
index 4bc0f27..055fdb3 100644
--- a/machine/minit.c
+++ b/machine/minit.c
@@ -11,21 +11,23 @@ uintptr_t num_harts;
static void mstatus_init()
{
+ // Enable FPU and set VM mode
uintptr_t ms = 0;
ms = INSERT_FIELD(ms, MSTATUS_VM, VM_CHOICE);
ms = INSERT_FIELD(ms, MSTATUS_FS, 1);
write_csr(mstatus, ms);
+ // Make sure the hart actually supports the VM mode we want
ms = read_csr(mstatus);
assert(EXTRACT_FIELD(ms, MSTATUS_VM) == VM_CHOICE);
- write_csr(mtimecmp, 0);
- clear_csr(mip, MIP_MSIP);
- write_csr(mie, -1);
+ // Enable user/supervisor use of perf counters
write_csr(mucounteren, -1);
write_csr(mscounteren, -1);
+ write_csr(mie, ~MIP_MTIP); // disable timer; enable other interrupts
}
+// send S-mode interrupts and most exceptions straight to S-mode
static void delegate_traps()
{
uintptr_t interrupts = MIP_SSIP | MIP_STIP;
@@ -89,7 +91,7 @@ static void hart_init()
void init_first_hart()
{
hart_init();
- memset(HLS(), 0, sizeof(*HLS()));
+ hls_init(0, NULL); // this might get called again from parse_config_string
parse_config_string();
memory_init();
boot_loader();