diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-03-30 21:59:29 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-03-30 21:59:29 -0700 |
commit | b79db7710e027de487986d03729f7e306c3cd94a (patch) | |
tree | f776ea0534f6740daec6b3f1c7aec178cd442763 /p | |
parent | 433e0094a68116503a24a3759b3b0347431ec632 (diff) | |
download | env-b79db7710e027de487986d03729f7e306c3cd94a.zip env-b79db7710e027de487986d03729f7e306c3cd94a.tar.gz env-b79db7710e027de487986d03729f7e306c3cd94a.tar.bz2 |
Don't rely on mstatus.fs to test FPU presence
Diffstat (limited to 'p')
-rw-r--r-- | p/riscv_test.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/p/riscv_test.h b/p/riscv_test.h index 8489bb2..123fde6 100644 --- a/p/riscv_test.h +++ b/p/riscv_test.h @@ -90,11 +90,8 @@ #define RVTEST_FP_ENABLE \ li a0, SSTATUS_FS & (SSTATUS_FS >> 1); \ csrs sstatus, a0; \ - csrr a1, sstatus; \ - and a0, a0, a1; \ - bnez a0, 2f; \ - RVTEST_PASS; \ -2:fssr x0; \ +test_fpu_presence: \ + fssr x0; \ #define RVTEST_VEC_ENABLE \ li a0, SSTATUS_XS & (SSTATUS_XS >> 1); \ @@ -121,6 +118,7 @@ .align 6; \ .weak stvec_handler; \ .weak mtvec_handler; \ + .weak test_fpu_presence; \ tvec_user: \ EXTRA_TVEC_USER; \ /* test whether the test came from pass/fail */ \ @@ -154,10 +152,14 @@ tvec_supervisor: \ .align 6; \ tvec_hypervisor: \ EXTRA_TVEC_HYPERVISOR; \ - RVTEST_FAIL; /* no hypervisor */ \ /* renting some space out here */ \ other_exception: \ - ori TESTNUM, TESTNUM, 1337; /* some other exception occurred */ \ + csrr t6, mepc; \ + la t5, test_fpu_presence; \ + beqz t5, 1f; \ + bne t5, t6, 1f; \ + RVTEST_PASS; \ + 1: ori TESTNUM, TESTNUM, 1337; /* some other exception occurred */ \ write_tohost: \ csrw tohost, TESTNUM; \ j write_tohost; \ @@ -168,8 +170,8 @@ tvec_machine: \ csrr t6, mepc; \ beq t5, t6, write_tohost; \ la t5, mtvec_handler; \ -1: beqz t5, 1b; \ - j mtvec_handler; \ + bnez t5, mtvec_handler; \ + j other_exception; \ .align 6; \ .globl _start; \ _start: \ |