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:
Bananymous
2023-04-20 00:45:41 +03:00
parent ea0c9b639f
commit b1c7af38d0
8 changed files with 134 additions and 33 deletions

View File

@@ -17,7 +17,7 @@ public:
using paddr_t = uintptr_t;
public:
static void intialize();
static void initialize();
static MMU& get();
MMU();
@@ -31,6 +31,11 @@ public:
void map_page_at(paddr_t, vaddr_t, uint8_t);
void load();
private:
void initialize_kernel();
private:
uint64_t* m_highest_paging_struct;
};

View File

@@ -4,6 +4,7 @@
#include <BAN/StringView.h>
#include <BAN/Vector.h>
#include <kernel/FS/Inode.h>
#include <kernel/Memory/MMU.h>
#include <kernel/SpinLock.h>
#include <kernel/Terminal/TTY.h>
#include <kernel/Thread.h>
@@ -54,6 +55,8 @@ namespace Kernel
static Process& current() { return Thread::current().process(); }
MMU& mmu() { return m_mmu ? *m_mmu : MMU::get(); }
private:
Process(pid_t);
static Process* create_process();
@@ -81,6 +84,7 @@ namespace Kernel
BAN::String m_working_directory;
BAN::Vector<Thread*> m_threads;
MMU* m_mmu { nullptr };
TTY* m_tty { nullptr };
};

View File

@@ -47,6 +47,7 @@ namespace Kernel
static Thread& current() ;
Process& process();
bool has_process() const { return m_process; }
private:
Thread(pid_t tid, Process*);