From 5fc386102380e6c15c81df4fd750f54641535eaa Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Tue, 15 Feb 2022 15:00:53 +0000 Subject: beginning to things out into cpu-dependent and cpu-independent code --- kc/core/cpu/irq.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 kc/core/cpu/irq.c (limited to 'kc/core/cpu/irq.c') 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 + +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;"); + } +} + -- cgit v1.3.1-1-g115d