diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-10-21 20:23:36 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-10-21 20:23:36 +0200 |
| commit | d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e (patch) | |
| tree | 89cbd6b7e23802f92bf3158868f4dc33c088e516 /dev/zka/src/CodeMgr.cc | |
| parent | 21b3da78f806d6765f9dffa6a84c21346f171cee (diff) | |
IMP: Major refactor of header and source files extensions.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/zka/src/CodeMgr.cc')
| -rw-r--r-- | dev/zka/src/CodeMgr.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/dev/zka/src/CodeMgr.cc b/dev/zka/src/CodeMgr.cc new file mode 100644 index 00000000..130f8cfe --- /dev/null +++ b/dev/zka/src/CodeMgr.cc @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include <NewKit/Utils.h> +#include <KernelKit/CodeMgr.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. + Bool sched_execute_thread(MainKind main, const Char* process_name) noexcept + { + if (!main) + return No; + + UserProcess proc; + proc.SetImageStart(reinterpret_cast<VoidPtr>(main)); + + proc.Kind = UserProcess::kExectuableKind; + proc.StackSize = kib_cast(32); + + rt_set_memory(proc.Name, 0, kProcessLen); + rt_copy_memory((VoidPtr)process_name, proc.Name, rt_string_len(process_name)); + + return UserProcessScheduler::The().Add(proc) > 0; + } +} // namespace Kernel |
