diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-22 17:46:11 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-22 17:46:11 +0200 |
| commit | 8719b4570a2d10dd49a0d3a47e24f5c55bdda85e (patch) | |
| tree | ba095740888f3768e08b2ea058b0ea6da2d0403d /dev/zka/src/CodeMgr.cxx | |
| parent | 45944b3d2dab04b763fcc6d10164fe8069e60b08 (diff) | |
:boom: A big refactor on the filesystem structure.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/zka/src/CodeMgr.cxx')
| -rw-r--r-- | dev/zka/src/CodeMgr.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/dev/zka/src/CodeMgr.cxx b/dev/zka/src/CodeMgr.cxx new file mode 100644 index 00000000..13bcd640 --- /dev/null +++ b/dev/zka/src/CodeMgr.cxx @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + 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* process_name) noexcept + { + if (!main) + return No; + + UserProcess proc; + proc.SetImageStart(reinterpret_cast<VoidPtr>(main)); + + proc.Kind = UserProcess::kExeKind; + 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 |
