cb97635bab7a70b8d26472bd72661858801a8768
[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 .align 2
43 .global stvec_handler
44 stvec_handler:
45 li t1, CAUSE_USER_ECALL
46 csrr t0, scause
47 bne t0, t1, fail
48 j pass
49
50 RVTEST_CODE_END
51
52 .data
53 RVTEST_DATA_BEGIN
54
55 TEST_DATA
56
57 RVTEST_DATA_END