Move PML4 initialization into the VirtualMemory class.
This commit is contained in:
parent
f22dd66c8d
commit
1db93e5b12
11 changed files with 39 additions and 25 deletions
|
|
@ -48,7 +48,7 @@ typedef struct {
|
|||
|
||||
} // namespace
|
||||
|
||||
uint64_t LoadElfProgram(uint64_t cr3, uint64_t base, uint64_t offset) {
|
||||
uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t offset) {
|
||||
Elf64Header* header = reinterpret_cast<Elf64Header*>(base);
|
||||
dbgln("phoff: %u phnum: %u", header->phoff, header->phnum);
|
||||
Elf64ProgramHeader* programs =
|
||||
|
|
@ -60,7 +60,7 @@ uint64_t LoadElfProgram(uint64_t cr3, uint64_t base, uint64_t offset) {
|
|||
"filesz: %u, memsz: %u, align: %u",
|
||||
program.type, program.flags, program.offset, program.vaddr,
|
||||
program.paddr, program.filesz, program.memsz, program.align);
|
||||
CopyIntoNonResidentProcess(base + program.offset, program.filesz, cr3,
|
||||
CopyIntoNonResidentProcess(base + program.offset, program.filesz, dest_proc,
|
||||
program.vaddr);
|
||||
}
|
||||
return header->entry;
|
||||
|
|
|
|||
|
|
@ -2,5 +2,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "scheduler/process.h"
|
||||
|
||||
// Loads the elf program and returns its entry point.
|
||||
uint64_t LoadElfProgram(uint64_t cr3, uint64_t base, uint64_t length);
|
||||
uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t length);
|
||||
|
|
|
|||
|
|
@ -43,12 +43,11 @@ void LoadInitProgram() {
|
|||
SharedPtr<Process> proc = MakeShared<Process>();
|
||||
gProcMan->InsertProcess(proc);
|
||||
|
||||
uint64_t entry =
|
||||
LoadElfProgram(proc->cr3(), reinterpret_cast<uint64_t>(init_prog.address),
|
||||
init_prog.size);
|
||||
uint64_t entry = LoadElfProgram(
|
||||
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
|
||||
|
||||
CopyIntoNonResidentProcess(reinterpret_cast<uint64_t>(prog2.address),
|
||||
prog2.size, proc->cr3(),
|
||||
prog2.size, *proc,
|
||||
proc->vmm().GetNextMemMapAddr(prog2.size));
|
||||
|
||||
proc->CreateThread(entry);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue