diff options
| author | Ada Christine <adachristine18@gmail.com> | 2022-02-15 15:00:53 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2022-02-15 15:00:53 +0000 |
| commit | 5fc386102380e6c15c81df4fd750f54641535eaa (patch) | |
| tree | c3aed0635aa10a80e1bbbe46a80e4e67f2be2c39 /kc/core/cpu/irq.c | |
| parent | 0c1bc025700656ce17bbd71f7d149744d65b7fb6 (diff) | |
beginning to things out into cpu-dependent and cpu-independent code
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;"); + } +} + |
