25#include "vendor/riscv_csr.h"
34#define CPU_CSR_MCAUSE_CAUSE_MSK (0x0fffu)
36extern volatile int riscv_in_isr;
41static inline __attribute__((always_inline))
unsigned int irq_enable(
void)
47 "csrrs %[dest], mstatus, %[mask]"
49 :[mask]
"i" (MSTATUS_MIE)
58static inline __attribute__((always_inline))
unsigned int irq_disable(
void)
64 "csrrc %[dest], mstatus, %[mask]"
66 :[mask]
"i" (MSTATUS_MIE)
81 "csrw mstatus, %[state]"
91static inline __attribute__((always_inline))
bool irq_is_in(
void)
96static inline __attribute__((always_inline))
bool irq_is_enabled(
void)
101 "csrr %[dest], mstatus"
106 return (state & MSTATUS_MIE);
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.