Userspace process creation stub

This commit is contained in:
Alex 2022-11-02 17:16:11 +02:00
parent efea5e7aaf
commit bb92e820fc
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
4 changed files with 59 additions and 1 deletions

6
Execute/Parse.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <exec.hpp>
namespace Execute
{
}

9
Execute/Spawn.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <exec.hpp>
namespace Execute
{
ExStatus Spawn(char *Path, uint64_t Arg0, uint64_t Arg1)
{
return ExStatus::Unknown;
}
}

View File

@ -1,9 +1,11 @@
#include "kernel.h" #include "kernel.h"
#include <filesystem/ustar.hpp> #include <filesystem/ustar.hpp>
#include <vector.hpp>
#include <power.hpp> #include <power.hpp>
#include <lock.hpp> #include <lock.hpp>
#include <printf.h> #include <printf.h>
#include <exec.hpp>
#include <cwalk.h> #include <cwalk.h>
#include "DAPI.hpp" #include "DAPI.hpp"
@ -65,7 +67,25 @@ void KernelMainThread()
TaskManager->WaitForThread(CurrentWorker); TaskManager->WaitForThread(CurrentWorker);
KPrint("Waiting for userspace process to start..."); KPrint("Waiting for userspace process to start...");
/* Load init file */
Vector<char *> 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); CPU::Halt(true);
} }

23
include/exec.hpp Normal file
View File

@ -0,0 +1,23 @@
#ifndef __FENNIX_KERNEL_FILE_EXECUTE_H__
#define __FENNIX_KERNEL_FILE_EXECUTE_H__
#include <types.h>
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__