From 49ba8e9e7de4a1ca2f23dbcdac40e12b45b94e0d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 17 Nov 2025 16:11:54 +0100 Subject: feat: kernel: implement 'rtl_create_kernel_task' Signed-off-by: Amlal El Mahrouss --- dev/kernel/KernelKit/CodeMgr.h | 2 +- dev/kernel/KernelKit/KernelTaskScheduler.h | 3 ++- dev/kernel/src/CodeMgr.cc | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'dev') diff --git a/dev/kernel/KernelKit/CodeMgr.h b/dev/kernel/KernelKit/CodeMgr.h index 2569b064..70e977e9 100644 --- a/dev/kernel/KernelKit/CodeMgr.h +++ b/dev/kernel/KernelKit/CodeMgr.h @@ -38,7 +38,7 @@ typedef void (*rtl_cxx_dtor_kind)(void); /// accessible. /// @param main the start of the process. /// @return The team's process id. -ProcessID rtl_create_kernel_process(rtl_main_kind main, const Char* task_name) noexcept; +BOOL rtl_create_kernel_task(HAL::StackFramePtr main, const KID kid) noexcept; /// @brief Executes a new process from a function. User code only. /// @note This sets up a new stack, anything on the main function that calls the Kernel will not be diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h index 6fd626b4..e92a91b7 100644 --- a/dev/kernel/KernelKit/KernelTaskScheduler.h +++ b/dev/kernel/KernelKit/KernelTaskScheduler.h @@ -38,7 +38,8 @@ class KERNEL_TASK final { /// @author Amlal class KernelTaskHelper final { public: - STATIC Bool Switch(HAL::StackFramePtr frame_ptr, ProcessID new_kid); + STATIC Bool Add(HAL::StackFramePtr frame_ptr, ProcessID new_kid); + STATIC Bool Remove(const KID kid); STATIC Bool CanBeScheduled(const KERNEL_TASK& process); STATIC ErrorOr TheCurrentKID(); STATIC SizeT StartScheduling(); diff --git a/dev/kernel/src/CodeMgr.cc b/dev/kernel/src/CodeMgr.cc index 7f85d547..02ed4c62 100644 --- a/dev/kernel/src/CodeMgr.cc +++ b/dev/kernel/src/CodeMgr.cc @@ -9,6 +9,17 @@ #include namespace Kernel { + +/// @brief Executes a new process from a function. Kernel code only. +/// @note This sets up a new stack, anything on the main function that calls the Kernel will not be +/// accessible. +/// @param main the start of the process. +/// @return The team's process id. +BOOL rtl_create_kernel_task(HAL::StackFramePtr task, const KID kid) noexcept { + if (!kid || task == nullptr) return FALSE; + return KernelTaskHelper::Add(task, kid); +} + /***********************************************************************************/ /// @brief Executes a new process from a function. Kernel code only. /// @note This sets up a new stack, anything on the main function that calls the Kernel will not be @@ -19,7 +30,6 @@ namespace Kernel { ProcessID rtl_create_user_process(rtl_main_kind main, const Char* process_name) noexcept { if (!process_name || *process_name == 0) return kSchedInvalidPID; - return UserProcessScheduler::The().Spawn(process_name, reinterpret_cast(main), nullptr); } } // namespace Kernel -- cgit v1.2.3