diff --git a/Execute/Parse.cpp b/Execute/Parse.cpp new file mode 100644 index 0000000..1c91b31 --- /dev/null +++ b/Execute/Parse.cpp @@ -0,0 +1,6 @@ +#include + +namespace Execute +{ + +} diff --git a/Execute/Spawn.cpp b/Execute/Spawn.cpp new file mode 100644 index 0000000..4baf062 --- /dev/null +++ b/Execute/Spawn.cpp @@ -0,0 +1,9 @@ +#include + +namespace Execute +{ + ExStatus Spawn(char *Path, uint64_t Arg0, uint64_t Arg1) + { + return ExStatus::Unknown; + } +} diff --git a/KThread.cpp b/KThread.cpp index b9d0dc4..3d918ae 100644 --- a/KThread.cpp +++ b/KThread.cpp @@ -1,9 +1,11 @@ #include "kernel.h" #include +#include #include #include #include +#include #include #include "DAPI.hpp" @@ -65,7 +67,25 @@ void KernelMainThread() TaskManager->WaitForThread(CurrentWorker); KPrint("Waiting for userspace process to start..."); - /* Load init file */ + + Vector argv; + int argc = 0; + + /* ... */ + argv.push_back((char *)"--start"); + /* ... */ + + argv.push_back(nullptr); + argc = argv.size() - 1; + + // TODO: Untested! + Execute::ExStatus ret = Execute::Spawn(Config.InitPath, argc, (uint64_t)argv.data()); + if (ret != Execute::ExStatus::OK) + { + KPrint("\eE85230Failed to start %s! Code: %d", Config.InitPath, ret); + CPU::Halt(true); + } + TaskManager->GetCurrentThread()->SetPriority(1); CPU::Halt(true); } diff --git a/include/exec.hpp b/include/exec.hpp new file mode 100644 index 0000000..b7a7d90 --- /dev/null +++ b/include/exec.hpp @@ -0,0 +1,23 @@ +#ifndef __FENNIX_KERNEL_FILE_EXECUTE_H__ +#define __FENNIX_KERNEL_FILE_EXECUTE_H__ + +#include + +namespace Execute +{ + enum ExStatus + { + OK, + Unknown, + InvalidFile, + InvalidFileFormat, + InvalidFileHeader, + InvalidFileData, + InvalidFileEntryPoint, + InvalidFilePath + }; + + ExStatus Spawn(char *Path, uint64_t Arg0, uint64_t Arg1); +} + +#endif // !__FENNIX_KERNEL_FILE_EXECUTE_H__