23 lines
460 B
C
23 lines
460 B
C
#include <arch/irq.h>
|
|
#include <stdint.h>
|
|
#include <x86_64/defs.h>
|
|
|
|
bool arch_irq_get_state() {
|
|
uint64_t flags;
|
|
asm volatile("pushf; pop %0" : "=r"(flags)::"memory");
|
|
return flags & RFLAGS_IF;
|
|
}
|
|
|
|
bool arch_irq_set_state(bool state) {
|
|
bool old = arch_irq_get_state();
|
|
if (state)
|
|
asm volatile("sti" ::: "memory");
|
|
else
|
|
asm volatile("cli" ::: "memory");
|
|
return old;
|
|
}
|
|
|
|
void arch_irq_wait() {
|
|
asm volatile("hlt");
|
|
}
|