f4752d15e9dd05027e407bd612baa3d403eed58b
[riscv-tests.git] / isa / rv64si / scall.S
1 # See LICENSE for license details.
2
3 #*****************************************************************************
4 # scall.S
5 #-----------------------------------------------------------------------------
6 #
7 # Test syscall trap.
8 #
9
10 #include "riscv_test.h"
11 #include "test_macros.h"
12
13 RVTEST_RV64S
14 RVTEST_CODE_BEGIN
15
16 #ifdef __MACHINE_MODE
17 #define sscratch mscratch
18 #define sstatus mstatus
19 #define scause mcause
20 #define sepc mepc
21 #define sret mret
22 #define stvec_handler mtvec_handler
23 #undef SSTATUS_SPP
24 #define SSTATUS_SPP MSTATUS_MPP
25 #endif
26
27 li TESTNUM, 2
28
29 li t0, SSTATUS_SPP
30 csrc sstatus, t0
31 la t0, 1f
32 csrw sepc, t0
33 sret
34 1:
35
36 li TESTNUM, 1
37 scall
38 j fail
39
40 TEST_PASSFAIL
41
42 stvec_handler:
43 li t1, CAUSE_USER_ECALL
44 csrr t0, scause
45 bne t0, t1, fail
46 j pass
47
48 RVTEST_CODE_END
49
50 .data
51 RVTEST_DATA_BEGIN
52
53 TEST_DATA
54
55 RVTEST_DATA_END