1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00
serenity/Kernel/VM/PageDirectory.cpp
Andreas Kling bcc6ddfb6b Kernel: Let PageDirectory own the associated RangeAllocator.
Since we transition to a new PageDirectory on exec(), we need a matching
RangeAllocator to go with the new directory. Instead of juggling this in
Process and MemoryManager, simply attach the RangeAllocator to the
PageDirectory instead.

Fixes #61.
2019-05-20 04:46:29 +02:00

37 lines
962 B
C++

#include <Kernel/VM/PageDirectory.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
static const dword userspace_range_base = 0x01000000;
static const dword kernelspace_range_base = 0xc0000000;
PageDirectory::PageDirectory(PhysicalAddress paddr)
: m_range_allocator(LinearAddress(0xc0000000), 0x3f000000)
{
m_directory_page = PhysicalPage::create_eternal(paddr, true);
}
PageDirectory::PageDirectory()
: m_range_allocator(LinearAddress(userspace_range_base), kernelspace_range_base - userspace_range_base)
{
MM.populate_page_directory(*this);
}
PageDirectory::~PageDirectory()
{
#ifdef MM_DEBUG
dbgprintf("MM: ~PageDirectory K%x\n", this);
#endif
}
void PageDirectory::flush(LinearAddress laddr)
{
#ifdef MM_DEBUG
dbgprintf("MM: Flush page L%x\n", laddr.get());
#endif
if (!current)
return;
if (&current->process().page_directory() == this)
MM.flush_tlb(laddr);
}