1 #ifndef _ENV_VIRTUAL_SINGLE_CORE_H
2 #define _ENV_VIRTUAL_SINGLE_CORE_H
4 //-----------------------------------------------------------------------
6 //-----------------------------------------------------------------------
12 #define RVTEST_RV64UF \
17 #define RVTEST_VEC_ENABLE \
19 #define RVTEST_CODE_BEGIN \
26 //-----------------------------------------------------------------------
28 //-----------------------------------------------------------------------
30 #define RVTEST_CODE_END \
32 //-----------------------------------------------------------------------
34 //-----------------------------------------------------------------------
36 #define RVTEST_PASS li a0, 1; syscall;
37 #define RVTEST_FAIL sll a0, x28, 1; 1:beqz a0, 1b; or a0, a0, 1; syscall;
39 //-----------------------------------------------------------------------
41 //-----------------------------------------------------------------------
43 #define RVTEST_DATA_BEGIN
44 #define RVTEST_DATA_END
46 //#define RVTEST_DATA_BEGIN .align 4; .global begin_signature; begin_signature:
47 //#define RVTEST_DATA_END .align 4; .global end_signature; end_signature:
49 //-----------------------------------------------------------------------
50 // Supervisor mode definitions and macros
51 //-----------------------------------------------------------------------
55 #define vvcfg(nxregs, nfregs) ({ \
56 asm volatile ("vvcfg %0,%1" : : "r"(nxregs), "r"(nfregs)); })
58 #define vsetvl(vl) ({ long __tmp; \
59 asm volatile ("vsetvl %0,%1" : "=r"(__tmp) : "r"(vl)); })
61 #define vcfg(word) ({ vvcfg((word)>>12, (word)>>18); vsetvl((word)); })
63 #define dword_bit_cmd(dw) ((dw >> 32) & 0x1)
64 #define dword_bit_cnt(dw) (!dword_bit_cmd(dw))
65 #define dword_bit_imm1(dw) ((dw >> 35) & 0x1)
66 #define dword_bit_imm2(dw) ((dw >> 34) & 0x1)
67 #define dword_bit_pf(dw) ((dw >> 36) & 0x1)
69 #define fencevl() ({ \
70 asm volatile ("fence.v.l" ::: "memory"); })
72 #define vxcptkill() ({ \
73 asm volatile ("vxcptkill"); })
75 #define vxcpthold() ({ \
76 asm volatile ("vxcpthold"); })
78 #define venqcmd(bits, pf) ({ \
79 asm volatile ("venqcmd %0,%1" : : "r"(bits), "r"(pf)); })
81 #define venqimm1(bits, pf) ({ \
82 asm volatile ("venqimm1 %0,%1" : : "r"(bits), "r"(pf)); })
84 #define venqimm2(bits, pf) ({ \
85 asm volatile ("venqimm2 %0,%1" : : "r"(bits), "r"(pf)); })
87 #define venqcnt(bits, pf) ({ \
88 asm volatile ("venqcnt %0,%1" :: "r"(bits), "r"(pf)); })
90 #define MAX_TEST_PAGES 63 // this must be the period of the LFSR below
91 #define LFSR_NEXT(x) (((((x)^((x)>>1)) & 1) << 5) | ((x) >> 1))
94 #define PGSIZE (1 << PGSHIFT)
96 #define SIZEOF_TRAPFRAME_T 1336
101 typedef unsigned long pte_t
;
102 #define LEVELS (sizeof(pte_t) == sizeof(uint64_t) ? 3 : 2)
103 #define PTIDXBITS (PGSHIFT - (sizeof(pte_t) == 8 ? 3 : 2))
104 #define VPN_BITS (PTIDXBITS * LEVELS)
105 #define VA_BITS (VPN_BITS + PGSHIFT)
106 #define PTES_PER_PT (PGSIZE/sizeof(pte_t))