Added Interrupt::IsEnabled().

This commit is contained in:
Jonas 'Sortie' Termansen 2012-04-11 15:46:32 +02:00
parent 36ff6c7f96
commit 8cbf9ff8f0
3 changed files with 18 additions and 2 deletions

View File

@ -47,6 +47,9 @@ const unsigned IRQ13 = 45;
const unsigned IRQ14 = 46;
const unsigned IRQ15 = 47;
extern "C" unsigned long asm_interrupts_are_enabled();
inline bool IsEnabled() { return asm_interrupts_are_enabled(); }
inline void Enable() { asm volatile("sti"); }
inline void Disable() { asm volatile("cli"); }

View File

@ -443,3 +443,11 @@ interrupt_handler_prepare:
interrupt_handler_null:
iretq
.global asm_interrupts_are_enabled
.type asm_interrupts_are_enabled, @function
asm_interrupts_are_enabled:
pushfq
popq %rax
andq $0x000200, %rax # FLAGS_INTERRUPT
retq

View File

@ -153,9 +153,14 @@ irq_common_stub:
;sti
iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP
global
global interrupt_handler_null
interrupt_handler_null:
iret
global asm_interrupts_are_enabled
asm_interrupts_are_enabled:
pushf
pop eax
and eax, 0x000200 ; FLAGS_INTERRUPT
ret