Skip to content

Commit

Permalink
Make rv64mi-p-ecall work when U-mode is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
aswaterman committed Nov 10, 2017
1 parent 652ec8c commit d9b4071
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion isa/rv64si/scall.S
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ RVTEST_CODE_BEGIN

li TESTNUM, 2

# This is the expected trap code.
li t1, CAUSE_USER_ECALL

#ifdef __MACHINE_MODE
# If running in M mode, use mstatus.MPP to check existence of U mode.
# Otherwise, if in S mode, then U mode must exist and we don't need to check.
li t0, MSTATUS_MPP
csrc mstatus, t0
csrr t1, mstatus
and t0, t0, t1
beqz t0, 1f

# If U mode doesn't exist, mcause should indicate ECALL from M mode.
li t1, CAUSE_MACHINE_ECALL
#endif

1:
li t0, SSTATUS_SPP
csrc sstatus, t0
la t0, 1f
Expand All @@ -42,7 +59,6 @@ RVTEST_CODE_BEGIN
.align 2
.global stvec_handler
stvec_handler:
li t1, CAUSE_USER_ECALL
csrr t0, scause
bne t0, t1, fail
j pass
Expand Down

0 comments on commit d9b4071

Please sign in to comment.