diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
| commit | ca675beb41dba8d7d16c5793b55d1672f38be3b4 (patch) | |
| tree | c995ada42729ac2059a0ed87a4539d1a7e10b14a /Kernel/Source/CodeManager.cxx | |
| parent | 2b4a4792abf51487ab4a16106f9376f43acf381a (diff) | |
| parent | bc57a29a24b98b00ba17710ba84ec2188ab73504 (diff) | |
Merged in MHR-23 (pull request #12)
MHR-23: Merge work.
Diffstat (limited to 'Kernel/Source/CodeManager.cxx')
| -rw-r--r-- | Kernel/Source/CodeManager.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Kernel/Source/CodeManager.cxx b/Kernel/Source/CodeManager.cxx new file mode 100644 index 00000000..001795ce --- /dev/null +++ b/Kernel/Source/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 |
