From 83d870e58457a1d335a1d9b9966a6a1887cc297b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Nov 2025 03:02:43 +0100 Subject: feat! breaking changes on kernel sources. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/HardwareThreadScheduler.cc | 184 ------------------------------ 1 file changed, 184 deletions(-) delete mode 100644 dev/kernel/src/HardwareThreadScheduler.cc (limited to 'dev/kernel/src/HardwareThreadScheduler.cc') diff --git a/dev/kernel/src/HardwareThreadScheduler.cc b/dev/kernel/src/HardwareThreadScheduler.cc deleted file mode 100644 index 41d927f6..00000000 --- a/dev/kernel/src/HardwareThreadScheduler.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#include -#include -#include -#include - -/***********************************************************************************/ -///! @file HardwareThreadScheduler.cc -///! @brief This file handles multi processing in the Kernel. -///! @brief Multi processing is needed for multi-tasking operations. -/***********************************************************************************/ - -namespace Kernel { -/***********************************************************************************/ -/// @note Those symbols are needed in order to switch and validate the stack. -/***********************************************************************************/ - -EXTERN_C Bool hal_check_task(HAL::StackFramePtr frame); -EXTERN_C Bool mp_register_task(HAL::StackFramePtr frame, ProcessID pid); - -STATIC HardwareThreadScheduler kHardwareThreadScheduler; - -///! A HardwareThread class takes care of it's owned hardware thread. -///! It has a stack for it's core. - -/***********************************************************************************/ -///! @brief C++ constructor. -/***********************************************************************************/ -HardwareThread::HardwareThread() = default; - -/***********************************************************************************/ -///! @brief C++ destructor. -/***********************************************************************************/ -HardwareThread::~HardwareThread() = default; - -/***********************************************************************************/ -//! @brief returns the id of the thread. -/***********************************************************************************/ -ThreadID& HardwareThread::ID() noexcept { - return fID; -} - -/***********************************************************************************/ -//! @brief returns the kind of thread we have. -/***********************************************************************************/ -ThreadKind& HardwareThread::Kind() noexcept { - return fKind; -} - -/***********************************************************************************/ -//! @brief is the thread busy? -//! @return whether the thread is busy or not. -/***********************************************************************************/ -Bool HardwareThread::IsBusy() noexcept { - return fBusy; -} - -/***********************************************************************************/ -/// @brief Get processor stack frame. -/***********************************************************************************/ - -HAL::StackFramePtr HardwareThread::StackFrame() noexcept { - MUST_PASS(this->fStack); - return this->fStack; -} - -Void HardwareThread::Busy(Bool busy) noexcept { - this->fBusy = busy; -} - -HardwareThread::operator bool() { - return this->fStack && !this->fBusy; -} - -/***********************************************************************************/ -/// @brief Wakeup the processor. -/***********************************************************************************/ - -Void HardwareThread::Wake(const bool wakeup) noexcept { - this->fWakeup = wakeup; -} - -/***********************************************************************************/ -/// @brief Switch to hardware thread. -/// @param stack the new hardware thread. -/// @retval true stack was changed, code is running. -/// @retval false stack is invalid, previous code is running. -/***********************************************************************************/ -Bool HardwareThread::Switch(HAL::StackFramePtr frame) { - if (!frame) { - return NO; - } - - if (!hal_check_task(frame)) { - return NO; - } - - this->fStack = frame; - return mp_register_task(fStack, this->fID); -} - -/***********************************************************************************/ -///! @brief Tells if processor is waked up. -/***********************************************************************************/ -bool HardwareThread::IsWakeup() noexcept { - return this->fWakeup; -} - -/***********************************************************************************/ -///! @brief Constructor and destructors. -///! @brief Default constructor. -/***********************************************************************************/ - -HardwareThreadScheduler::HardwareThreadScheduler() = default; - -/***********************************************************************************/ -///! @brief Default destructor. -/***********************************************************************************/ -HardwareThreadScheduler::~HardwareThreadScheduler() = default; - -/***********************************************************************************/ -/// @brief Shared singleton function -/***********************************************************************************/ -HardwareThreadScheduler& HardwareThreadScheduler::The() { - return kHardwareThreadScheduler; -} - -/***********************************************************************************/ -/// @brief Get Stack Frame of AP. -/***********************************************************************************/ -HAL::StackFramePtr HardwareThreadScheduler::Leak() noexcept { - return fThreadList[fCurrentThreadIdx].fStack; -} - -/***********************************************************************************/ -/** - * Get Hardware thread at index. - * @param idx the index - * @return the reference to the hardware thread. - */ -/***********************************************************************************/ -Ref HardwareThreadScheduler::operator[](SizeT idx) { - if (idx > kMaxAPInsideSched) { - HardwareThread* kFakeThread = nullptr; - return {kFakeThread}; - } - - fCurrentThreadIdx = idx; - return &fThreadList[idx]; -} - -/***********************************************************************************/ -/** - * Check if thread pool isn't empty. - * @return - */ -/***********************************************************************************/ -HardwareThreadScheduler::operator bool() noexcept { - return !fThreadList.Empty(); -} - -/***********************************************************************************/ -/** - * Reverse operator bool - * @return - */ -/***********************************************************************************/ -bool HardwareThreadScheduler::operator!() noexcept { - return fThreadList.Empty(); -} - -/***********************************************************************************/ -/// @brief Returns the amount of core present. -/// @return the number of APs. -/***********************************************************************************/ -SizeT HardwareThreadScheduler::Capacity() noexcept { - return fThreadList.Count(); -} -} // namespace Kernel -- cgit v1.2.3