Add a process spawn syscall and use it to start a proc.
Also add a skeleton VirtualMemory manager to be used per process.
This commit is contained in:
parent
5bcf1f4e4a
commit
3c3341a90f
7 changed files with 125 additions and 6 deletions
|
|
@ -3,27 +3,42 @@
|
|||
#include "boot/boot_info.h"
|
||||
#include "debug/debug.h"
|
||||
#include "loader/elf_loader.h"
|
||||
#include "memory/paging_util.h"
|
||||
#include "scheduler/process.h"
|
||||
#include "scheduler/process_manager.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const limine_file& GetInitProgram() {
|
||||
bool streq(const char* a, const char* b) {
|
||||
while (true) {
|
||||
if (*a == '\0' && *b == '\0') return true;
|
||||
if (*a == '\0' || *b == '\0') {
|
||||
return false;
|
||||
}
|
||||
if (*a != *b) {
|
||||
return false;
|
||||
}
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
const limine_file& GetInitProgram(const char* path) {
|
||||
const limine_module_response& resp = boot::GetModules();
|
||||
dbgln("Dumping modules");
|
||||
for (uint64_t i = 0; i < resp.module_count; i++) {
|
||||
const limine_file& file = *resp.modules[i];
|
||||
dbgln("%s,%m,%x", file.path, file.address, file.size);
|
||||
// TODO eventually compare this file path.
|
||||
return file;
|
||||
if (streq(file.path, path)) return file;
|
||||
}
|
||||
panic("No init program found");
|
||||
panic("Program not found: %s", path);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void LoadInitProgram() {
|
||||
const limine_file& init_prog = GetInitProgram();
|
||||
const limine_file& init_prog = GetInitProgram("/sys/test");
|
||||
const limine_file& prog2 = GetInitProgram("/sys/test2");
|
||||
|
||||
SharedPtr<Process> proc = MakeShared<Process>();
|
||||
gProcMan->InsertProcess(proc);
|
||||
|
|
@ -31,5 +46,10 @@ void LoadInitProgram() {
|
|||
uint64_t entry =
|
||||
LoadElfProgram(proc->cr3(), reinterpret_cast<uint64_t>(init_prog.address),
|
||||
init_prog.size);
|
||||
|
||||
CopyIntoNonResidentProcess(reinterpret_cast<uint64_t>(prog2.address),
|
||||
prog2.size, proc->cr3(),
|
||||
proc->vmm().GetNextMemMapAddr(prog2.size));
|
||||
|
||||
proc->CreateThread(entry);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue