Kernel: Add Utilities::get_rflags(), and thus Interrupts::are_enabled()
This commit is contained in:
parent
e90b90c556
commit
b3e16068ef
@ -8,4 +8,6 @@ namespace Interrupts
|
|||||||
|
|
||||||
bool is_in_handler();
|
bool is_in_handler();
|
||||||
void return_from_handler(Context* context);
|
void return_from_handler(Context* context);
|
||||||
|
|
||||||
|
bool are_enabled();
|
||||||
}
|
}
|
@ -5,4 +5,6 @@ namespace Utilities
|
|||||||
{
|
{
|
||||||
uint64_t get_blocks_from_size(uint64_t blocksize,
|
uint64_t get_blocks_from_size(uint64_t blocksize,
|
||||||
uint64_t size); // Returns how many blocks of size blocksize does size occupy.
|
uint64_t size); // Returns how many blocks of size blocksize does size occupy.
|
||||||
|
|
||||||
|
uint64_t get_rflags();
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
#include "interrupts/Interrupts.h"
|
#include "interrupts/Interrupts.h"
|
||||||
|
#include "misc/utils.h"
|
||||||
#include "trace/StackTracer.h"
|
#include "trace/StackTracer.h"
|
||||||
|
|
||||||
void Interrupts::disable()
|
void Interrupts::disable()
|
||||||
@ -25,3 +26,8 @@ void Interrupts::return_from_handler(Context* context)
|
|||||||
:
|
:
|
||||||
: "r"(context));
|
: "r"(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Interrupts::are_enabled()
|
||||||
|
{
|
||||||
|
return (Utilities::get_rflags() & 0x200) > 0;
|
||||||
|
}
|
@ -26,3 +26,9 @@ asm_enable_sse:
|
|||||||
or ax, 3 << 9
|
or ax, 3 << 9
|
||||||
mov cr4, rax
|
mov cr4, rax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
global asm_get_rflags
|
||||||
|
asm_get_rflags:
|
||||||
|
pushfq
|
||||||
|
pop rax
|
||||||
|
ret
|
@ -4,3 +4,9 @@ uint64_t Utilities::get_blocks_from_size(uint64_t blocksize, uint64_t size)
|
|||||||
{
|
{
|
||||||
return (size + (blocksize - 1)) / blocksize;
|
return (size + (blocksize - 1)) / blocksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" uint64_t asm_get_rflags();
|
||||||
|
uint64_t Utilities::get_rflags()
|
||||||
|
{
|
||||||
|
return asm_get_rflags();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user