Kernel: Add Utilities::get_rflags(), and thus Interrupts::are_enabled()

This commit is contained in:
apio 2022-10-12 12:56:55 +02:00
parent e90b90c556
commit b3e16068ef
5 changed files with 22 additions and 0 deletions

View File

@ -8,4 +8,6 @@ namespace Interrupts
bool is_in_handler();
void return_from_handler(Context* context);
bool are_enabled();
}

View File

@ -5,4 +5,6 @@ namespace Utilities
{
uint64_t get_blocks_from_size(uint64_t blocksize,
uint64_t size); // Returns how many blocks of size blocksize does size occupy.
uint64_t get_rflags();
}

View File

@ -1,4 +1,5 @@
#include "interrupts/Interrupts.h"
#include "misc/utils.h"
#include "trace/StackTracer.h"
void Interrupts::disable()
@ -25,3 +26,8 @@ void Interrupts::return_from_handler(Context* context)
:
: "r"(context));
}
bool Interrupts::are_enabled()
{
return (Utilities::get_rflags() & 0x200) > 0;
}

View File

@ -26,3 +26,9 @@ asm_enable_sse:
or ax, 3 << 9
mov cr4, rax
ret
global asm_get_rflags
asm_get_rflags:
pushfq
pop rax
ret

View File

@ -4,3 +4,9 @@ uint64_t Utilities::get_blocks_from_size(uint64_t blocksize, uint64_t size)
{
return (size + (blocksize - 1)) / blocksize;
}
extern "C" uint64_t asm_get_rflags();
uint64_t Utilities::get_rflags()
{
return asm_get_rflags();
}