summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2022-05-16 14:05:18 +0200
committerLinus Groh <mail@linusgroh.de>2022-06-02 13:14:12 +0100
commit9413fe9fe5e585a143502dd96236435a3a353c27 (patch)
treeb5641b8b454443bb2cd69e2c1f19d05e4f81bb3d
parent80be5f80448099dbaf1592832f4c649b894f1294 (diff)
downloadserenity-9413fe9fe5e585a143502dd96236435a3a353c27.zip
Kernel: Add interrupt related functions to Processor class
This adds {enable, disable}_interrupts() and are_interrupts_enabled() to the Processor class, and also implements them for x86(_64) and aarch64.
-rw-r--r--Kernel/Arch/aarch64/Processor.h17
-rw-r--r--Kernel/Arch/x86/Processor.h15
2 files changed, 32 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h
index 01a1d5c134..aa0b04ea8a 100644
--- a/Kernel/Arch/aarch64/Processor.h
+++ b/Kernel/Arch/aarch64/Processor.h
@@ -12,6 +12,7 @@
#include <AK/Types.h>
#include <Kernel/Arch/ProcessorSpecificDataID.h>
+#include <Kernel/Arch/aarch64/Registers.h>
class VirtualAddress;
@@ -119,6 +120,22 @@ public:
return 0;
}
+ ALWAYS_INLINE static bool are_interrupts_enabled()
+ {
+ auto daif = Aarch64::DAIF::read();
+ return !daif.I;
+ }
+
+ ALWAYS_INLINE static void enable_interrupts()
+ {
+ Aarch64::DAIF::clear_I();
+ }
+
+ ALWAYS_INLINE static void disable_interrupts()
+ {
+ Aarch64::DAIF::set_I();
+ }
+
ALWAYS_INLINE static void enter_critical() { VERIFY_NOT_REACHED(); }
ALWAYS_INLINE static void leave_critical() { VERIFY_NOT_REACHED(); }
ALWAYS_INLINE static u32 in_critical()
diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h
index 1e0f4cc2dd..86e0c2182c 100644
--- a/Kernel/Arch/x86/Processor.h
+++ b/Kernel/Arch/x86/Processor.h
@@ -422,6 +422,21 @@ public:
return m_features.has_flag(feature);
}
+ ALWAYS_INLINE static bool are_interrupts_enabled()
+ {
+ return Kernel::are_interrupts_enabled();
+ }
+
+ ALWAYS_INLINE static void enable_interrupts()
+ {
+ sti();
+ }
+
+ ALWAYS_INLINE static void disable_interrupts()
+ {
+ cli();
+ }
+
void check_invoke_scheduler();
void invoke_scheduler_async() { m_invoke_scheduler_async = true; }