summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/src/CodeMgr.cc
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2025-01-24 10:38:36 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2025-01-24 10:38:36 +0100
commit7b4bd3577a31d0f0adc7371840642791ae1567f4 (patch)
tree1a8afc973aaa739d0d763315cad2fd376d1cea9c /dev/Kernel/src/CodeMgr.cc
ADD: Open version, with important changes kept out.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/src/CodeMgr.cc')
-rw-r--r--dev/Kernel/src/CodeMgr.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/dev/Kernel/src/CodeMgr.cc b/dev/Kernel/src/CodeMgr.cc
new file mode 100644
index 00000000..de35f846
--- /dev/null
+++ b/dev/Kernel/src/CodeMgr.cc
@@ -0,0 +1,28 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <KernelKit/CodeMgr.h>
+#include <NewKit/Utils.h>
+#include <KernelKit/UserProcessScheduler.h>
+
+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 if the process was started or not.
+ /***********************************************************************************/
+
+ ProcessID rtl_create_process(rtl_main_kind main, const Char* process_name) noexcept
+ {
+ if (!process_name ||
+ *process_name == 0)
+ return kProcessInvalidID;
+
+ return UserProcessScheduler::The().Spawn(process_name, reinterpret_cast<VoidPtr>(main), nullptr);
+ }
+} // namespace Kernel