From 849af3db3b0d0c1edd3d32359be21785e3465bf2 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 19 Aug 2024 11:08:35 +0200 Subject: [IMP] + Add the thread header block, which contains informations about a list of threads inside a process. + Add WINDOW structure to keep track of Windows as well. Signed-off-by: Amlal El Mahrouss --- dev/ZKA/KernelKit/ProcessScheduler.hxx | 4 ++-- dev/ZKA/Sources/MP.cxx | 18 +++++++++--------- dev/ZKA/Sources/ProcessScheduler.cxx | 4 ++-- dev/ZKA/Sources/ThreadScheduler.cxx | 29 ++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/dev/ZKA/KernelKit/ProcessScheduler.hxx b/dev/ZKA/KernelKit/ProcessScheduler.hxx index 277334cc..c74dee6a 100644 --- a/dev/ZKA/KernelKit/ProcessScheduler.hxx +++ b/dev/ZKA/KernelKit/ProcessScheduler.hxx @@ -28,7 +28,7 @@ namespace Kernel { //! @brief Forward declarations. struct PROCESS_HEADER_BLOCK; - + class PEFSharedObjectInterface; class ProcessTeam; class ProcessScheduler; @@ -143,7 +143,7 @@ namespace Kernel const Int32& GetExitCode() noexcept; public: - Char Name[kProcessLen] = {"PROCESS"}; + Char Name[kProcessLen] = {"PROCESS #0 (TEAM 0)"}; ProcessSubsystem SubSystem{ProcessSubsystem::eProcessSubsystemInvalid}; ProcessLevelRing Selector{ProcessLevelRing::kRingStdUser}; HAL::StackFramePtr StackFrame{nullptr}; diff --git a/dev/ZKA/Sources/MP.cxx b/dev/ZKA/Sources/MP.cxx index bf35f51e..da92a8c6 100644 --- a/dev/ZKA/Sources/MP.cxx +++ b/dev/ZKA/Sources/MP.cxx @@ -84,17 +84,17 @@ namespace Kernel /// @retval false stack is invalid, previous code is running. Bool HardwareThread::Switch(HAL::StackFramePtr stack) { - if (!rt_check_stack(stack)) + /// provide 'nullptr' to free the stack frame. + if (stack == nullptr) { - /// provide 'nullptr' to free the stack frame. - if (stack == nullptr) - { - delete fStack; - fStack = nullptr; + delete fStack; + fStack = nullptr; - return true; - } + return true; + } + if (!rt_check_stack(stack)) + { return false; } @@ -125,7 +125,7 @@ namespace Kernel StringView strCoreName(512); strCoreName += "\\Class\\Smp\\MPClass"; - cSMPCoreName.GetKey() = strCoreName; + cSMPCoreName.GetKey() = strCoreName; cSMPCoreName.GetValue() = (UIntPtr)this; kcout << "newoskrnl: initializing " << strCoreName.CData() << endl; diff --git a/dev/ZKA/Sources/ProcessScheduler.cxx b/dev/ZKA/Sources/ProcessScheduler.cxx index a979c413..0066d70b 100644 --- a/dev/ZKA/Sources/ProcessScheduler.cxx +++ b/dev/ZKA/Sources/ProcessScheduler.cxx @@ -210,8 +210,8 @@ namespace Kernel } /// @brief Add process to list. - /// @param process - /// @return + /// @param process the process *Ref* class. + /// @return the process index inside the team. SizeT ProcessScheduler::Add(Ref& process) { if (!process.Leak().Image) diff --git a/dev/ZKA/Sources/ThreadScheduler.cxx b/dev/ZKA/Sources/ThreadScheduler.cxx index fb822a68..a6dfd2b9 100644 --- a/dev/ZKA/Sources/ThreadScheduler.cxx +++ b/dev/ZKA/Sources/ThreadScheduler.cxx @@ -5,4 +5,31 @@ ------------------------------------------- */ #include -#include \ No newline at end of file +#include + +namespace Kernel::Detail +{ + /// \brief Process thread information. + struct THREAD_HEADER_BLOCK final + { + STATIC constexpr SizeT cMaxLen = 256; + + // Status + Char fName[cMaxLen] = { "THREAD #0 (PROCESS 0)" }; + + ProcessStatus fThreadStatus; + + // Information + Int64 fThreadID; + + // Code buffers. + UIntPtr fCode; + UIntPtr fStack; + UIntPtr fBSS; + UIntPtr fProcessheader; + + // GX buffers. + UIntPtr fTGB; + UIntPtr fTGBSize; + }; +} -- cgit v1.2.3