diff options
Diffstat (limited to 'kc/core/cpu/irq.c')
| -rw-r--r-- | kc/core/cpu/irq.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/kc/core/cpu/irq.c b/kc/core/cpu/irq.c index e4dd29f..f42db4c 100644 --- a/kc/core/cpu/irq.c +++ b/kc/core/cpu/irq.c @@ -4,13 +4,25 @@ static volatile atomic_uint_fast64_t irq_lock_count = 0; -void irq_lock(void) +uint64_t irq_lock(void) { + uint64_t flags; + + __asm__ volatile + ( + "pushf\n" + "pop %0\n" + "cli\n" + : + "=r"(flags) + ); + irq_lock_count++; - __asm__ volatile ("cli;"); + + return flags; } -void irq_unlock(void) +void irq_unlock(uint64_t flags) { if (atomic_load(&irq_lock_count) >= 1) { @@ -19,7 +31,14 @@ void irq_unlock(void) if (atomic_load(&irq_lock_count) == 0) { - __asm__ volatile ("sti;"); + __asm__ volatile + ( + "push %q0\n" + "popf" + : + : + "r"(flags) + ); } } |
