From 9e219c9ca70459bfda9067d637bb8bf52c5f0326 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 6 Dec 2016 17:02:41 -0800 Subject: [PATCH] avoid non-standard predefined macros --- encoding.h | 2 +- p/riscv_test.h | 2 +- v/entry.S | 2 +- v/riscv_test.h | 6 +----- v/vm.c | 4 ++-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/encoding.h b/encoding.h index 35e0f9f..8aeac4c 100644 --- a/encoding.h +++ b/encoding.h @@ -150,7 +150,7 @@ #ifdef __riscv -#ifdef __riscv64 +#if __riscv_xlen == 64 # define MSTATUS_SD MSTATUS64_SD # define SSTATUS_SD SSTATUS64_SD # define RISCV_PGLEVEL_BITS 9 diff --git a/p/riscv_test.h b/p/riscv_test.h index 9cc8754..0a5bf51 100644 --- a/p/riscv_test.h +++ b/p/riscv_test.h @@ -52,7 +52,7 @@ RVTEST_ENABLE_SUPERVISOR; \ .endm -#ifdef __riscv64 +#if __riscv_xlen == 64 # define CHECK_XLEN csrr a0, misa; bltz a0, 1f; RVTEST_PASS; 1: #else # define CHECK_XLEN csrr a0, misa; bgez a0, 1f; RVTEST_PASS; 1: diff --git a/v/entry.S b/v/entry.S index ae4e57c..8234fc3 100644 --- a/v/entry.S +++ b/v/entry.S @@ -1,6 +1,6 @@ #include "riscv_test.h" -#ifdef __riscv64 +#if __riscv_xlen == 64 # define STORE sd # define LOAD ld # define REGBYTES 8 diff --git a/v/riscv_test.h b/v/riscv_test.h index 0dd3a1f..8ca9ffd 100644 --- a/v/riscv_test.h +++ b/v/riscv_test.h @@ -46,11 +46,7 @@ userstart: \ #define PGSHIFT 12 #define PGSIZE (1UL << PGSHIFT) -#ifdef __riscv64 -# define SIZEOF_TRAPFRAME_T 288 -#else -# define SIZEOF_TRAPFRAME_T 144 -#endif +#define SIZEOF_TRAPFRAME_T ((__riscv_xlen / 8) * 36) #ifndef __ASSEMBLER__ diff --git a/v/vm.c b/v/vm.c index 2530785..1aa068a 100644 --- a/v/vm.c +++ b/v/vm.c @@ -62,7 +62,7 @@ void wtf() #define l1pt pt[0] #define user_l2pt pt[1] #define kernel_l2pt pt[2] -#ifdef __riscv64 +#if __riscv_xlen == 64 # define NPT 5 # define user_l3pt pt[3] # define kernel_l3pt pt[4] @@ -204,7 +204,7 @@ void vm_boot(uintptr_t test_addr) l1pt[PTES_PER_PT-1] = ((pte_t)kernel_l2pt >> PGSHIFT << PTE_PPN_SHIFT) | PTE_V; // map user to lowermost megapage l1pt[0] = ((pte_t)user_l2pt >> PGSHIFT << PTE_PPN_SHIFT) | PTE_V; -#ifdef __riscv64 +#if __riscv_xlen == 64 kernel_l2pt[PTES_PER_PT-1] = ((pte_t)kernel_l3pt >> PGSHIFT << PTE_PPN_SHIFT) | PTE_V; user_l2pt[0] = ((pte_t)user_l3pt >> PGSHIFT << PTE_PPN_SHIFT) | PTE_V; #endif