diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-12-06 15:53:20 +0100 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-12-06 15:57:01 +0100 |
| commit | 46a885ad913aa24543efb154886919ad30182229 (patch) | |
| tree | 3f9d6887763d8e1ea66fc89ec9aadb22f4cb9abc /dev/ZKAKit/src | |
| parent | 8723d3401c15cad5797697aea4735b8972aabafb (diff) | |
META: Friday bump.
Signed-off-by: Amlal <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKAKit/src')
| -rw-r--r-- | dev/ZKAKit/src/FS/HPFS.cc | 2 | ||||
| -rw-r--r-- | dev/ZKAKit/src/HardwareThreadScheduler.cc | 71 | ||||
| -rw-r--r-- | dev/ZKAKit/src/ThreadLocalStorage.cc | 4 | ||||
| -rw-r--r-- | dev/ZKAKit/src/UserProcessScheduler.cc | 9 |
4 files changed, 64 insertions, 22 deletions
diff --git a/dev/ZKAKit/src/FS/HPFS.cc b/dev/ZKAKit/src/FS/HPFS.cc index e08ee5a7..58478dea 100644 --- a/dev/ZKAKit/src/FS/HPFS.cc +++ b/dev/ZKAKit/src/FS/HPFS.cc @@ -13,7 +13,7 @@ #include <KernelKit/LPC.h> #include <NewKit/Crc32.h> #include <NewKit/Stop.h> -#include <NewKit/String.h> +#include <NewKit/KString.h> #include <NewKit/Utils.h> #include <FirmwareKit/EPM.h> #include <KernelKit/UserProcessScheduler.h> diff --git a/dev/ZKAKit/src/HardwareThreadScheduler.cc b/dev/ZKAKit/src/HardwareThreadScheduler.cc index e06942d9..036fa898 100644 --- a/dev/ZKAKit/src/HardwareThreadScheduler.cc +++ b/dev/ZKAKit/src/HardwareThreadScheduler.cc @@ -9,39 +9,56 @@ #include <KernelKit/HardwareThreadScheduler.h> #include <CFKit/Property.h> -///! BUGS: 0 - -///! @file MP.cc +/***********************************************************************************/ +///! @file HardwareThreadScheduler.cc ///! @brief This file handles multi processing in the Kernel. ///! @brief Multi processing is needed for multi-tasking operations. +/***********************************************************************************/ namespace Kernel { - HardwareThreadScheduler kHardwareThreadScheduler; + /***********************************************************************************/ + /// @note Those symbols are needed in order to switch and validate the stack. + /***********************************************************************************/ + + EXTERN Bool hal_check_stack(HAL::StackFramePtr frame_ptr); + EXTERN_C Bool mp_register_process(VoidPtr image, Ptr8 stack_ptr, 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. + /***********************************************************************************/ const ThreadID& HardwareThread::ID() noexcept { return fID; } + /***********************************************************************************/ //! @brief returns the kind of thread we have. + /***********************************************************************************/ const ThreadKind& HardwareThread::Kind() noexcept { return fKind; } + /***********************************************************************************/ //! @brief is the thread busy? //! @return whether the thread is busy or not. + /***********************************************************************************/ Bool HardwareThread::IsBusy() noexcept { STATIC Int64 busy_timer = 0U; @@ -57,7 +74,9 @@ namespace Kernel return fBusy; } + /***********************************************************************************/ /// @brief Get processor stack frame. + /***********************************************************************************/ HAL::StackFramePtr HardwareThread::StackFrame() noexcept { @@ -72,10 +91,12 @@ namespace Kernel HardwareThread::operator bool() { - return fStack; + return this->fStack && !this->fBusy; } + /***********************************************************************************/ /// @brief Wakeup the processor. + /***********************************************************************************/ Void HardwareThread::Wake(const bool wakeup) noexcept { @@ -87,15 +108,12 @@ namespace Kernel mp_wakeup_thread(fStack); } - /// @note Those symbols are needed in order to switch and validate the stack. - - EXTERN Bool hal_check_stack(HAL::StackFramePtr frame_ptr); - EXTERN_C Bool mp_register_process(VoidPtr image, Ptr8 stack_ptr, HAL::StackFramePtr frame, ProcessID pid); - + /***********************************************************************************/ /// @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(VoidPtr image, Ptr8 stack_ptr, HAL::StackFramePtr frame, const ProcessID& pid) { if (!frame || @@ -123,47 +141,59 @@ namespace Kernel return ret; } + /***********************************************************************************/ ///! @brief Tells if processor is waked up. + /***********************************************************************************/ bool HardwareThread::IsWakeup() noexcept { return 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 Core + /***********************************************************************************/ + /// @brief Get Stack Frame of AP. + /***********************************************************************************/ HAL::StackFramePtr HardwareThreadScheduler::Leak() noexcept { return fThreadList[fCurrentThread].fStack; } + /***********************************************************************************/ /** * Get Hardware thread at index. * @param idx the index * @return the reference to the hardware thread. */ + /***********************************************************************************/ Ref<HardwareThread*> HardwareThreadScheduler::operator[](const SizeT& idx) { if (idx == 0) { - if (fThreadList[idx].Kind() != kHartSystemReserved) + if (fThreadList[idx].Kind() != kAPSystemReserved) { - fThreadList[idx].fKind = kHartBoot; + fThreadList[idx].fKind = kAPBoot; } } - else if (idx >= kMaxHartInsideSched) + else if (idx >= kMaxAPInsideSched) { static HardwareThread* fakeThread = nullptr; return {fakeThread}; @@ -172,28 +202,37 @@ namespace Kernel 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 cores. + /// @return the number of APs. + /***********************************************************************************/ SizeT HardwareThreadScheduler::Capacity() noexcept { + if (fThreadList.Empty()) + return 0UL; + return fThreadList.Capacity(); } } // namespace Kernel diff --git a/dev/ZKAKit/src/ThreadLocalStorage.cc b/dev/ZKAKit/src/ThreadLocalStorage.cc index c6089824..5fdf56aa 100644 --- a/dev/ZKAKit/src/ThreadLocalStorage.cc +++ b/dev/ZKAKit/src/ThreadLocalStorage.cc @@ -32,8 +32,8 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* tib_ptr) !tib_ptr->Record) return false; - IEncoderObject encoder; - const char* tib_as_bytes = encoder.AsBytes(tib_ptr); + ICodec encoder; + const Char* tib_as_bytes = encoder.AsBytes(tib_ptr); kcout << "Checking for a valid cookie inside the TIB...\r"; diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc index 3c7e8879..4b24d98a 100644 --- a/dev/ZKAKit/src/UserProcessScheduler.cc +++ b/dev/ZKAKit/src/UserProcessScheduler.cc @@ -515,13 +515,16 @@ namespace Kernel for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) { - if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidHart) + if (!HardwareThreadScheduler::The()[index].Leak()) + continue; + + if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidAP) continue; if (HardwareThreadScheduler::The()[index].Leak()->Kind() != - ThreadKind::kHartBoot && + ThreadKind::kAPBoot && HardwareThreadScheduler::The()[index].Leak()->Kind() != - ThreadKind::kHartSystemReserved) + ThreadKind::kAPSystemReserved) { PID prev_pid = UserProcessHelper::TheCurrentPID(); UserProcessHelper::TheCurrentPID().Leak().Leak() = new_pid; |
