mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 22:27:44 +00:00
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.
This commit is contained in:
parent
d65114afd7
commit
bcc6ddfb6b
6 changed files with 16 additions and 16 deletions
|
@ -20,7 +20,6 @@ MemoryManager& MM
|
|||
}
|
||||
|
||||
MemoryManager::MemoryManager()
|
||||
: m_range_allocator(LinearAddress(0xc0000000), 0x3f000000)
|
||||
{
|
||||
// FIXME: This is not the best way to do memory map detection.
|
||||
// Rewrite to use BIOS int 15,e820 once we have VM86 support.
|
||||
|
@ -402,7 +401,7 @@ RetainPtr<Region> MemoryManager::allocate_kernel_region(size_t size, String&& na
|
|||
InterruptDisabler disabler;
|
||||
|
||||
ASSERT(!(size % PAGE_SIZE));
|
||||
auto range = m_range_allocator.allocate_anywhere(size);
|
||||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||
ASSERT(range.is_valid());
|
||||
auto region = adopt(*new Region(range, move(name), true, true, false));
|
||||
MM.map_region_at_address(*m_kernel_page_directory, *region, range.base(), false);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <AK/Weakable.h>
|
||||
#include <Kernel/LinearAddress.h>
|
||||
#include <Kernel/VM/PhysicalPage.h>
|
||||
#include <Kernel/VM/RangeAllocator.h>
|
||||
#include <Kernel/VM/Region.h>
|
||||
#include <Kernel/VM/VMObject.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
|
@ -217,8 +216,6 @@ private:
|
|||
HashTable<Region*> m_user_regions;
|
||||
HashTable<Region*> m_kernel_regions;
|
||||
|
||||
RangeAllocator m_range_allocator;
|
||||
|
||||
size_t m_ram_size { 0 };
|
||||
bool m_quickmap_in_use { false };
|
||||
};
|
||||
|
|
|
@ -3,12 +3,17 @@
|
|||
#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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/VM/PhysicalPage.h>
|
||||
#include <Kernel/VM/RangeAllocator.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Retainable.h>
|
||||
#include <AK/RetainPtr.h>
|
||||
|
@ -8,7 +9,7 @@
|
|||
class PageDirectory : public Retainable<PageDirectory> {
|
||||
friend class MemoryManager;
|
||||
public:
|
||||
static Retained<PageDirectory> create() { return adopt(*new PageDirectory); }
|
||||
static Retained<PageDirectory> create_for_userspace() { return adopt(*new PageDirectory); }
|
||||
static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
||||
~PageDirectory();
|
||||
|
||||
|
@ -17,10 +18,13 @@ public:
|
|||
|
||||
void flush(LinearAddress);
|
||||
|
||||
RangeAllocator& range_allocator() { return m_range_allocator; }
|
||||
|
||||
private:
|
||||
PageDirectory();
|
||||
explicit PageDirectory(PhysicalAddress);
|
||||
|
||||
RangeAllocator m_range_allocator;
|
||||
RetainPtr<PhysicalPage> m_directory_page;
|
||||
HashMap<unsigned, RetainPtr<PhysicalPage>> m_physical_pages;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue