diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-09-05 19:13:02 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-09-05 19:13:02 +0000 |
| commit | 621e814da6d5005ade8a1fe3f378a363db559cf7 (patch) | |
| tree | 438f1337c0eb2ae83cf3d409c29848d396be08b2 /dev/ZKA/Sources/CodeMgr.cxx | |
| parent | cc9ce57cac59bd443e2319e3b8f427172b93f7da (diff) | |
| parent | 3b60a1e87ab02a1b72d8bb9f7392780899d5a0d7 (diff) | |
Merged in major-refactor (pull request #19)
Major refactor
Diffstat (limited to 'dev/ZKA/Sources/CodeMgr.cxx')
| -rw-r--r-- | dev/ZKA/Sources/CodeMgr.cxx | 32 |
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..1d4f4a6e --- /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 = mib_cast(4); + + rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(processName)); + + return UserProcessScheduler::The().Add(proc) == kErrorSuccess; + } +} // namespace Kernel |
