From c9118de5a6360d69919ca157f55d10ee4eafe6d4 Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Tue, 23 Aug 2022 22:00:50 +0200 Subject: [PATCH] Kernel/aarch64: Implement critical section related functions --- Kernel/Arch/aarch64/Processor.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h index aa0b04ea8a..4dd878e15a 100644 --- a/Kernel/Arch/aarch64/Processor.h +++ b/Kernel/Arch/aarch64/Processor.h @@ -136,12 +136,22 @@ public: Aarch64::DAIF::set_I(); } - ALWAYS_INLINE static void enter_critical() { VERIFY_NOT_REACHED(); } - ALWAYS_INLINE static void leave_critical() { VERIFY_NOT_REACHED(); } + // FIXME: Share the critical functions with x86/Processor.h + ALWAYS_INLINE static void enter_critical() + { + auto current_processor = current(); + current_processor.m_in_critical = current_processor.in_critical() + 1; + } + + ALWAYS_INLINE static void leave_critical() + { + auto current_processor = current(); + current_processor.m_in_critical = current_processor.in_critical() - 1; + } + ALWAYS_INLINE static u32 in_critical() { - VERIFY_NOT_REACHED(); - return 0; + return current().m_in_critical; } // FIXME: Actually return the idle thread once aarch64 supports threading. @@ -161,6 +171,9 @@ public: } [[noreturn]] static void halt(); + +private: + u32 m_in_critical { 0 }; }; }