22 #define RISCV_XLEN __riscv_xlen
24 #warning "__riscv_xlen not defined, defaulting to 64"
37 #error "Unsupported RISCV_XLEN"
42#define READ_CSR(REG) ({ \
43 unsigned long __tmp; \
44 asm volatile ("csrr %0, " REG : "=r"(__tmp)); \
47#define WRITE_CSR(REG, VAL) ({ \
48 asm volatile ("csrw " REG ", %0" :: "rK"(VAL)); })
50#define SWAP_CSR(REG, VAL) ({ \
51 unsigned long __tmp; \
52 asm volatile ("csrrw %0, " REG ", %1" : "=r"(__tmp) : "rK"(VAL)); \
55#define SET_CSR_BITS(REG, BIT) ({ \
56 unsigned long __tmp; \
57 asm volatile ("csrrs %0, " REG ", %1" : "=r"(__tmp) : "rK"(BIT)); \
60#define CLEAR_CSR_BITS(REG, BIT) ({ \
61 unsigned long __tmp; \
62 asm volatile ("csrrc %0, " REG ", %1" : "=r"(__tmp) : "rK"(BIT)); \