diff options
Diffstat (limited to 'machine')
-rw-r--r-- | machine/bits.h | 2 | ||||
-rw-r--r-- | machine/emulation.c | 4 | ||||
-rw-r--r-- | machine/encoding.h | 2 | ||||
-rw-r--r-- | machine/fp_asm.S | 2 | ||||
-rw-r--r-- | machine/fp_emulation.c | 6 | ||||
-rw-r--r-- | machine/fp_ldst.c | 4 | ||||
-rw-r--r-- | machine/htif.h | 2 | ||||
-rw-r--r-- | machine/misaligned_ldst.c | 4 | ||||
-rw-r--r-- | machine/mtrap.c | 2 | ||||
-rw-r--r-- | machine/muldiv_emulation.c | 4 | ||||
-rw-r--r-- | machine/unprivileged_memory.h | 2 | ||||
-rw-r--r-- | machine/vm.h | 2 |
12 files changed, 18 insertions, 18 deletions
diff --git a/machine/bits.h b/machine/bits.h index e550f80..e578903 100644 --- a/machine/bits.h +++ b/machine/bits.h @@ -17,7 +17,7 @@ #define STR(x) XSTR(x) #define XSTR(x) #x -#ifdef __riscv64 +#if __riscv_xlen == 64 # define SLL32 sllw # define STORE sd # define LOAD ld diff --git a/machine/emulation.c b/machine/emulation.c index d8e0f1e..882daa1 100644 --- a/machine/emulation.c +++ b/machine/emulation.c @@ -35,7 +35,7 @@ void illegal_insn_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) " .word truly_illegal_insn\n" #endif " .word truly_illegal_insn\n" -#if !defined(__riscv_muldiv) && defined(__riscv64) +#if !defined(__riscv_muldiv) && __riscv_xlen >= 64 " .word emulate_mul_div32\n" #else " .word truly_illegal_insn\n" @@ -99,7 +99,7 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* result return -1; *result = *mtime; return 0; -#ifdef __riscv32 +#if __riscv_xlen == 32 case CSR_TIMEH: if (!((counteren >> (CSR_TIME - CSR_CYCLE)) & 1)) return -1; diff --git a/machine/encoding.h b/machine/encoding.h index 35e0f9f..8aeac4c 100644 --- a/machine/encoding.h +++ b/machine/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/machine/fp_asm.S b/machine/fp_asm.S index a3e5ef4..cdbb151 100644 --- a/machine/fp_asm.S +++ b/machine/fp_asm.S @@ -8,7 +8,7 @@ #define get_f32(which) fmv.x.s a0, which; jr t0 #define put_f32(which) fmv.s.x which, a0; jr t0 -#ifdef __riscv64 +#if __riscv_xlen == 64 # define get_f64(which) fmv.x.d a0, which; jr t0 # define put_f64(which) fmv.d.x which, a0; jr t0 #else diff --git a/machine/fp_emulation.c b/machine/fp_emulation.c index be9c067..182567a 100644 --- a/machine/fp_emulation.c +++ b/machine/fp_emulation.c @@ -206,7 +206,7 @@ DECLARE_EMULATION_FUNC(emulate_fcvt_fi) case 1: // uint32 uint_val = (uint32_t)uint_val; break; -#ifdef __riscv64 +#if __riscv_xlen == 64 case 2: // int64 negative = (int64_t)uint_val < 0; uint_val = negative ? -uint_val : uint_val; @@ -230,7 +230,7 @@ DECLARE_EMULATION_FUNC(emulate_fcvt_fi) DECLARE_EMULATION_FUNC(emulate_fcvt_if) { int rs2_num = (insn >> 20) & 0x1f; -#ifdef __riscv64 +#if __riscv_xlen == 64 if (rs2_num >= 4) return truly_illegal_insn(regs, mcause, mepc, mstatus, insn); #else @@ -367,7 +367,7 @@ DECLARE_EMULATION_FUNC(emulate_fmv_fi) if ((insn & MASK_FMV_S_X) == MATCH_FMV_S_X) SET_F32_RD(insn, regs, rs1); -#ifdef __riscv64 +#if __riscv_xlen == 64 else if ((insn & MASK_FMV_D_X) == MATCH_FMV_D_X) SET_F64_RD(insn, regs, rs1); #endif diff --git a/machine/fp_ldst.c b/machine/fp_ldst.c index b3d57e5..93a4844 100644 --- a/machine/fp_ldst.c +++ b/machine/fp_ldst.c @@ -19,7 +19,7 @@ DECLARE_EMULATION_FUNC(emulate_float_load) if (addr % sizeof(uintptr_t) != 0) return misaligned_load_trap(regs, mcause, mepc); -#ifdef __riscv64 +#if __riscv_xlen == 64 val = load_uint64_t((void *)addr, mepc); #else val = load_uint32_t((void *)addr, mepc); @@ -52,7 +52,7 @@ DECLARE_EMULATION_FUNC(emulate_float_store) return misaligned_store_trap(regs, mcause, mepc); val = GET_F64_RS2(insn, regs); -#ifdef __riscv64 +#if __riscv_xlen == 64 store_uint64_t((void *)addr, val, mepc); #else store_uint32_t((void *)addr, val, mepc); diff --git a/machine/htif.h b/machine/htif.h index e66ad06..7107ddb 100644 --- a/machine/htif.h +++ b/machine/htif.h @@ -3,7 +3,7 @@ #include <stdint.h> -#ifdef __riscv64 +#if __riscv_xlen == 64 # define TOHOST_CMD(dev, cmd, payload) \ (((uint64_t)(dev) << 56) | ((uint64_t)(cmd) << 48) | (uint64_t)(payload)) #else diff --git a/machine/misaligned_ldst.c b/machine/misaligned_ldst.c index dd56f7f..980aeba 100644 --- a/machine/misaligned_ldst.c +++ b/machine/misaligned_ldst.c @@ -19,7 +19,7 @@ void misaligned_load_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) int shift = 0, fp = 0, len; if ((insn & MASK_LW) == MATCH_LW) len = 4, shift = 8*(sizeof(uintptr_t) - len); -#ifdef __riscv64 +#if __riscv_xlen == 64 else if ((insn & MASK_LD) == MATCH_LD) len = 8, shift = 8*(sizeof(uintptr_t) - len); else if ((insn & MASK_LWU) == MATCH_LWU) @@ -62,7 +62,7 @@ void misaligned_store_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) val.intx = GET_RS2(insn, regs); if ((insn & MASK_SW) == MATCH_SW) len = 4; -#ifdef __riscv64 +#if __riscv_xlen == 64 else if ((insn & MASK_SD) == MATCH_SD) len = 8; #endif diff --git a/machine/mtrap.c b/machine/mtrap.c index d2cbcd2..07f7d10 100644 --- a/machine/mtrap.c +++ b/machine/mtrap.c @@ -250,7 +250,7 @@ void mcall_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) retval = mcall_shutdown(); break; case MCALL_SET_TIMER: -#ifdef __riscv32 +#if __riscv_xlen == 32 retval = mcall_set_timer(arg0 + ((uint64_t)arg1 << 32)); #else retval = mcall_set_timer(arg0); diff --git a/machine/muldiv_emulation.c b/machine/muldiv_emulation.c index d0583c5..1fde345 100644 --- a/machine/muldiv_emulation.c +++ b/machine/muldiv_emulation.c @@ -2,7 +2,7 @@ #ifndef __riscv_muldiv -#ifdef __riscv64 +#if __riscv_xlen == 64 typedef __int128 double_int; #else typedef int64_t double_int; @@ -37,7 +37,7 @@ DECLARE_EMULATION_FUNC(emulate_mul_div) SET_RD(insn, regs, val); } -#ifdef __riscv64 +#if __riscv_xlen == 64 DECLARE_EMULATION_FUNC(emulate_mul_div32) { diff --git a/machine/unprivileged_memory.h b/machine/unprivileged_memory.h index 7ed9e7c..03f1e27 100644 --- a/machine/unprivileged_memory.h +++ b/machine/unprivileged_memory.h @@ -39,7 +39,7 @@ DECLARE_UNPRIVILEGED_LOAD_FUNCTION(int32_t, lw) DECLARE_UNPRIVILEGED_STORE_FUNCTION(uint8_t, sb) DECLARE_UNPRIVILEGED_STORE_FUNCTION(uint16_t, sh) DECLARE_UNPRIVILEGED_STORE_FUNCTION(uint32_t, sw) -#ifdef __riscv64 +#if __riscv_xlen == 64 DECLARE_UNPRIVILEGED_LOAD_FUNCTION(uint32_t, lwu) DECLARE_UNPRIVILEGED_LOAD_FUNCTION(uint64_t, ld) DECLARE_UNPRIVILEGED_STORE_FUNCTION(uint64_t, sd) diff --git a/machine/vm.h b/machine/vm.h index dd9bf59..4e6bcc1 100644 --- a/machine/vm.h +++ b/machine/vm.h @@ -5,7 +5,7 @@ #include <stdint.h> #define MEGAPAGE_SIZE ((uintptr_t)(RISCV_PGSIZE << RISCV_PGLEVEL_BITS)) -#ifdef __riscv64 +#if __riscv_xlen == 64 # define VM_CHOICE VM_SV39 # define VA_BITS 39 # define GIGAPAGE_SIZE (MEGAPAGE_SIZE << RISCV_PGLEVEL_BITS) |