From 8b1114ea205ef6560fb7bf5713577d1ab7deb5be Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 4 Sep 2024 17:29:07 +0200 Subject: [ MR ] BUMP commit. Signed-off-by: Amlal El Mahrouss --- dev/ZKA/Sources/CodeMgr.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dev/ZKA/Sources/CodeMgr.cxx (limited to 'dev/ZKA/Sources/CodeMgr.cxx') 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 +#include +#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 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(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 -- cgit v1.2.3