initial commit
[riscv-tests.git] / env / pm / riscv_test.h
1 #ifndef _ENV_PHYSICAL_MULTI_CORE_H
2 #define _ENV_PHYSICAL_MULTI_CORE_H
3
4 //-----------------------------------------------------------------------
5 // Begin Macro
6 //-----------------------------------------------------------------------
7
8 #define RVTEST_RV64U \
9
10 #define RVTEST_RV64S \
11
12 #define RVTEST_FP_ENABLE \
13 setpcr cr0, 2; \
14 mfpcr a0, cr0; \
15 and a0, a0, 2; \
16 beqz a0, 1f; \
17 mtfsr x0; \
18 1:
19
20 #define RVTEST_PASS_NOFP \
21 RVTEST_FP_ENABLE \
22 bnez a0, 2f; \
23 RVTEST_PASS \
24 2: \
25
26 #define RVTEST_VEC_ENABLE \
27 mfpcr a0, cr0; \
28 ori a0, a0, 4; \
29 mtpcr a0, cr0; \
30 li a0, 0xff; \
31 mtpcr a0, cr18; \
32
33 #define RVTEST_CODE_BEGIN \
34 .text; \
35 .align 4; \
36 .global _start; \
37 _start: \
38 RVTEST_FP_ENABLE \
39 RVTEST_VEC_ENABLE \
40
41 //-----------------------------------------------------------------------
42 // End Macro
43 //-----------------------------------------------------------------------
44
45 #define RVTEST_CODE_END \
46
47 //-----------------------------------------------------------------------
48 // Pass/Fail Macro
49 //-----------------------------------------------------------------------
50
51 #define RVTEST_FAIL \
52 fence; \
53 beqz x28, 1f; \
54 sll x28, x28, 1; \
55 or x28, x28, 1; \
56 mtpcr x28, cr30; \
57 1: b 1b; \
58
59 #define RVTEST_PASS \
60 fence; \
61 li x1, 1; \
62 mtpcr x1, cr30; \
63 1: b 1b; \
64
65 //-----------------------------------------------------------------------
66 // Data Section Macro
67 //-----------------------------------------------------------------------
68
69 #define RVTEST_DATA_BEGIN
70 #define RVTEST_DATA_END
71
72 //#define RVTEST_DATA_BEGIN .align 4; .global begin_signature; begin_signature:
73 //#define RVTEST_DATA_END .align 4; .global end_signature; end_signature:
74
75 #endif