1 #ifndef _ENV_VIRTUAL_SINGLE_CORE_H
2 #define _ENV_VIRTUAL_SINGLE_CORE_H
4 //-----------------------------------------------------------------------
6 //-----------------------------------------------------------------------
10 #define RVTEST_RV64S \
12 #define RVTEST_FP_ENABLE \
18 #define RVTEST_VEC_ENABLE \
25 #define RVTEST_CODE_BEGIN \
31 //-----------------------------------------------------------------------
33 //-----------------------------------------------------------------------
35 #define RVTEST_CODE_END \
37 //-----------------------------------------------------------------------
39 //-----------------------------------------------------------------------
41 #define RVTEST_PASS li a0, 1; syscall;
42 #define RVTEST_FAIL sll a0, x28, 1; 1:beqz a0, 1b; or a0, a0, 1; syscall;
44 //-----------------------------------------------------------------------
46 //-----------------------------------------------------------------------
48 #define RVTEST_DATA_BEGIN
49 #define RVTEST_DATA_END
51 //#define RVTEST_DATA_BEGIN .align 4; .global begin_signature; begin_signature:
52 //#define RVTEST_DATA_END .align 4; .global end_signature; end_signature:
54 //-----------------------------------------------------------------------
55 // Supervisor mode definitions and macros
56 //-----------------------------------------------------------------------
60 #define vvcfg(nxregs, nfregs) ({ \
61 asm volatile ("vvcfg %0,%1" : : "r"(nxregs), "r"(nfregs)); })
63 #define vsetvl(vl) ({ long __tmp; \
64 asm volatile ("vsetvl %0,%1" : "=r"(__tmp) : "r"(vl)); })
66 #define vcfg(word) ({ vvcfg((word)>>12, (word)>>18); vsetvl((word)); })
68 #define dword_bit_cmd(dw) ((dw >> 32) & 0x1)
69 #define dword_bit_cnt(dw) (!dword_bit_cmd(dw))
70 #define dword_bit_imm1(dw) ((dw >> 35) & 0x1)
71 #define dword_bit_imm2(dw) ((dw >> 34) & 0x1)
72 #define dword_bit_pf(dw) ((dw >> 36) & 0x1)
74 #define fencevl() ({ \
75 asm volatile ("fence.v.l" ::: "memory"); })
77 #define vxcptkill() ({ \
78 asm volatile ("vxcptkill"); })
80 #define vxcpthold() ({ \
81 asm volatile ("vxcpthold"); })
83 #define venqcmd(bits, pf) ({ \
84 asm volatile ("venqcmd %0,%1" : : "r"(bits), "r"(pf)); })
86 #define venqimm1(bits, pf) ({ \
87 asm volatile ("venqimm1 %0,%1" : : "r"(bits), "r"(pf)); })
89 #define venqimm2(bits, pf) ({ \
90 asm volatile ("venqimm2 %0,%1" : : "r"(bits), "r"(pf)); })
92 #define venqcnt(bits, pf) ({ \
93 asm volatile ("venqcnt %0,%1" :: "r"(bits), "r"(pf)); })
95 #define MAX_TEST_PAGES 63 // this must be the period of the LFSR below
96 #define LFSR_NEXT(x) (((((x)^((x)>>1)) & 1) << 5) | ((x) >> 1))
99 #define PGSIZE (1 << PGSHIFT)
101 #define SIZEOF_TRAPFRAME_T 1336
103 #ifndef __ASSEMBLER__
106 typedef unsigned long pte_t
;
107 #define LEVELS (sizeof(pte_t) == sizeof(uint64_t) ? 3 : 2)
108 #define PTIDXBITS (PGSHIFT - (sizeof(pte_t) == 8 ? 3 : 2))
109 #define VPN_BITS (PTIDXBITS * LEVELS)
110 #define VA_BITS (VPN_BITS + PGSHIFT)
111 #define PTES_PER_PT (PGSIZE/sizeof(pte_t))