summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources/CodeMgr.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dev/ZKA/Sources/CodeMgr.cxx')
-rw-r--r--dev/ZKA/Sources/CodeMgr.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/dev/ZKA/Sources/CodeMgr.cxx b/dev/ZKA/Sources/CodeMgr.cxx
new file mode 100644
index 00000000..df5b0917
--- /dev/null
+++ b/dev/ZKA/Sources/CodeMgr.cxx
@@ -0,0 +1,32 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <NewKit/Utils.hxx>
+#include <KernelKit/CodeMgr.hxx>
+#include <KernelKit/UserProcessScheduler.hxx>
+
+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.
+ bool sched_execute_thread(MainKind main, const Char* processName) noexcept
+ {
+ if (!main)
+ return false;
+
+ UserProcess proc;
+ proc.SetImageStart(reinterpret_cast<VoidPtr>(main));
+
+ proc.Kind = UserProcess::kExeKind;
+ proc.StackSize = kib_cast(8);
+
+ rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(processName));
+
+ return UserProcessScheduler::The().Add(proc) == kErrorSuccess;
+ }
+} // namespace Kernel