diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-05-23 07:53:50 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-05-23 07:53:50 +0000 |
| commit | f5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (patch) | |
| tree | c9305701aa2d4ee0235c85c67cd6633e5763ec21 /Kernel/Sources/CodeManager.cxx | |
| parent | ca675beb41dba8d7d16c5793b55d1672f38be3b4 (diff) | |
| parent | 06b1a4bb12b4043b606d8bb0d55942d636c6833e (diff) | |
Merged in MHR-23 (pull request #13)
MHR-23
Diffstat (limited to 'Kernel/Sources/CodeManager.cxx')
| -rw-r--r-- | Kernel/Sources/CodeManager.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Kernel/Sources/CodeManager.cxx b/Kernel/Sources/CodeManager.cxx new file mode 100644 index 00000000..358481f6 --- /dev/null +++ b/Kernel/Sources/CodeManager.cxx @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include <NewKit/Utils.hpp> +#include <KernelKit/CodeManager.hpp> +#include <KernelKit/ProcessScheduler.hpp> + +namespace NewOS +{ + /// @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 execute_from_image(MainKind main, const char* processName) noexcept + { + if (!main) + return false; + + ProcessHeader proc((VoidPtr)main); + proc.Kind = ProcessHeader::kDriverKind; + rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(proc.Name)); + + Ref<ProcessHeader> refProc = proc; + + return ProcessScheduler::Shared().Leak().Add(refProc); + } +} // namespace NewOS
\ No newline at end of file |
