mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
7afc0fb9c8
Otherwise we'll start handing out addresses that are very likely already in use by existing ranges.
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <Kernel/VM/PhysicalPage.h>
|
|
#include <Kernel/VM/RangeAllocator.h>
|
|
#include <AK/HashMap.h>
|
|
#include <AK/Retainable.h>
|
|
#include <AK/RetainPtr.h>
|
|
|
|
class PageDirectory : public Retainable<PageDirectory> {
|
|
friend class MemoryManager;
|
|
public:
|
|
static Retained<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); }
|
|
static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
|
~PageDirectory();
|
|
|
|
dword cr3() const { return m_directory_page->paddr().get(); }
|
|
dword* entries() { return reinterpret_cast<dword*>(cr3()); }
|
|
|
|
void flush(LinearAddress);
|
|
|
|
RangeAllocator& range_allocator() { return m_range_allocator; }
|
|
|
|
private:
|
|
explicit PageDirectory(const RangeAllocator* parent_range_allocator);
|
|
explicit PageDirectory(PhysicalAddress);
|
|
|
|
RangeAllocator m_range_allocator;
|
|
RetainPtr<PhysicalPage> m_directory_page;
|
|
HashMap<unsigned, RetainPtr<PhysicalPage>> m_physical_pages;
|
|
};
|