diff options
Diffstat (limited to 'kc/core/cpu/irq.c')
| -rw-r--r-- | kc/core/cpu/irq.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kc/core/cpu/irq.c b/kc/core/cpu/irq.c new file mode 100644 index 0000000..639aca3 --- /dev/null +++ b/kc/core/cpu/irq.c @@ -0,0 +1,24 @@ +#include "irq.h" + +#include <stdatomic.h> + +static atomic_uint_fast64_t irq_lock_count = 0; + +void irq_lock(void) +{ + __asm__ volatile ("cli;"); +} + +void irq_unlock(void) +{ + if (irq_lock_count >= 1) + { + irq_lock_count--; + } + + if (irq_lock_count == 0) + { + __asm__ volatile ("sti;"); + } +} + |
