Kernel/aarch64: Store a pointer to the current Thread on Processor

And also implemented and update the related functions.
This commit is contained in:
Timon Kruiper 2022-10-20 13:01:26 +02:00 committed by Gunnar Beutner
parent 8fe3c50b30
commit a998bba73b
Notes: sideshowbarker 2024-07-17 07:25:39 +09:00

View file

@ -111,11 +111,9 @@ public:
m_idle_thread = &idle_thread; m_idle_thread = &idle_thread;
} }
// FIXME: Actually return the current thread once aarch64 supports threading.
ALWAYS_INLINE static Thread* current_thread() ALWAYS_INLINE static Thread* current_thread()
{ {
static Thread* current_thread { nullptr }; return current().m_current_thread;
return current_thread;
} }
ALWAYS_INLINE bool has_nx() const ALWAYS_INLINE bool has_nx() const
@ -204,14 +202,12 @@ public:
ALWAYS_INLINE static void set_current_thread(Thread& current_thread) ALWAYS_INLINE static void set_current_thread(Thread& current_thread)
{ {
(void)current_thread; current().m_current_thread = &current_thread;
TODO_AARCH64();
} }
// FIXME: Actually return the idle thread once aarch64 supports threading.
ALWAYS_INLINE static Thread* idle_thread() ALWAYS_INLINE static Thread* idle_thread()
{ {
return nullptr; return current().m_idle_thread;
} }
ALWAYS_INLINE static Processor& current() ALWAYS_INLINE static Processor& current()
@ -241,6 +237,7 @@ public:
static ErrorOr<Vector<FlatPtr, 32>> capture_stack_trace(Thread& thread, size_t max_frames = 0); static ErrorOr<Vector<FlatPtr, 32>> capture_stack_trace(Thread& thread, size_t max_frames = 0);
private: private:
Thread* m_current_thread;
Thread* m_idle_thread; Thread* m_idle_thread;
u32 m_in_critical { 0 }; u32 m_in_critical { 0 };