1// See LICENSE for license details. 2 3#ifndef _ENV_VIRTUAL_SINGLE_CORE_H 4#define _ENV_VIRTUAL_SINGLE_CORE_H 5 6#include "../p/riscv_test.h" 7 8//----------------------------------------------------------------------- 9// Begin Macro 10//----------------------------------------------------------------------- 11 12#undef RVTEST_FP_ENABLE 13#define RVTEST_FP_ENABLE fssr x0 14 15#undef RVTEST_CODE_BEGIN 16#define RVTEST_CODE_BEGIN \ 17 .text; \ 18 .global userstart; \ 19userstart: \ 20 init 21 22//----------------------------------------------------------------------- 23// Pass/Fail Macro 24//----------------------------------------------------------------------- 25 26#undef RVTEST_PASS 27#define RVTEST_PASS li a0, 1; scall 28 29#undef RVTEST_FAIL 30#define RVTEST_FAIL sll a0, TESTNUM, 1; 1:beqz a0, 1b; or a0, a0, 1; scall; 31 32//----------------------------------------------------------------------- 33// Data Section Macro 34//----------------------------------------------------------------------- 35 36#undef RVTEST_DATA_END 37#define RVTEST_DATA_END 38 39//----------------------------------------------------------------------- 40// Supervisor mode definitions and macros 41//----------------------------------------------------------------------- 42 43#define MAX_TEST_PAGES 63 // this must be the period of the LFSR below 44#define LFSR_NEXT(x) (((((x)^((x)>>1)) & 1) << 5) | ((x) >> 1)) 45 46#define PGSHIFT 12 47#define PGSIZE (1UL << PGSHIFT) 48 49#define SIZEOF_TRAPFRAME_T ((__riscv_xlen / 8) * 36) 50 51#ifndef __ASSEMBLER__ 52 53typedef unsigned long pte_t; 54#define LEVELS (sizeof(pte_t) == sizeof(uint64_t) ? 3 : 2) 55#define PTIDXBITS (PGSHIFT - (sizeof(pte_t) == 8 ? 3 : 2)) 56#define VPN_BITS (PTIDXBITS * LEVELS) 57#define VA_BITS (VPN_BITS + PGSHIFT) 58#define PTES_PER_PT (1UL << RISCV_PGLEVEL_BITS) 59#define MEGAPAGE_SIZE (PTES_PER_PT * PGSIZE) 60 61typedef struct 62{ 63 long gpr[32]; 64 long sr; 65 long epc; 66 long badvaddr; 67 long cause; 68} trapframe_t; 69#endif 70 71#endif 72