diff options
| author | Ada Christine <adachristine18@gmail.com> | 2023-02-14 15:14:35 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2023-02-14 15:14:35 +0000 |
| commit | 9fd358e9395aae73622bdcf58ebe43f12671c990 (patch) | |
| tree | b9bd20fba6ee4a7da84d54d2208e17a49c0305d5 /kc/core/cpu/irq.c | |
| parent | f59e168c504f50de7b2ff77af0c1b1cfe0483e7b (diff) | |
refactors
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) + ); } } |
