Kernel: Add barebones per process virtual addresses
We now assign every (userspace) process its own MMU which we load in scheduler. This allows every process to have separate virtual address space. This is very hackish implementations but it works for now
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include <BAN/StringView.h>
|
||||
#include <kernel/FS/VirtualFileSystem.h>
|
||||
#include <kernel/LockGuard.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Process.h>
|
||||
#include <kernel/Scheduler.h>
|
||||
|
||||
@@ -39,12 +38,14 @@ namespace Kernel
|
||||
auto* process = create_process();
|
||||
TRY(process->m_working_directory.push_back('/'));
|
||||
TRY(process->init_stdio());
|
||||
|
||||
process->m_mmu = new MMU();
|
||||
ASSERT(process->m_mmu);
|
||||
|
||||
TRY(process->add_thread(
|
||||
[](void* entry_func)
|
||||
{
|
||||
Thread& current = Thread::current();
|
||||
MMU::get().map_range(current.stack_base(), current.stack_size(), MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
|
||||
Process::current().m_mmu->map_range(current.stack_base(), current.stack_size(), MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
|
||||
current.jump_userspace((uintptr_t)entry_func);
|
||||
ASSERT_NOT_REACHED();
|
||||
}, (void*)entry
|
||||
|
||||
@@ -169,6 +169,11 @@ namespace Kernel
|
||||
|
||||
Thread& current = current_thread();
|
||||
|
||||
if (current.has_process())
|
||||
current.process().mmu().load();
|
||||
else
|
||||
MMU::get().load();
|
||||
|
||||
switch (current.state())
|
||||
{
|
||||
case Thread::State::NotStarted:
|
||||
@@ -245,7 +250,6 @@ namespace Kernel
|
||||
|
||||
void Scheduler::set_current_process_done()
|
||||
{
|
||||
VERIFY_STI();
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
pid_t pid = m_current_thread->thread->process().pid();
|
||||
|
||||
@@ -134,7 +134,7 @@ extern "C" void kernel_main()
|
||||
IDT::initialize();
|
||||
dprintln("IDT initialized");
|
||||
|
||||
MMU::intialize();
|
||||
MMU::initialize();
|
||||
dprintln("MMU initialized");
|
||||
|
||||
TerminalDriver* terminal_driver = VesaTerminalDriver::create();
|
||||
@@ -194,8 +194,8 @@ static void init2(void* tty1)
|
||||
}, nullptr
|
||||
));
|
||||
|
||||
//jump_userspace();
|
||||
//return;
|
||||
jump_userspace();
|
||||
return;
|
||||
|
||||
MUST(Process::create_kernel(
|
||||
[](void*)
|
||||
|
||||
Reference in New Issue
Block a user