#pragma once #include #include #include #include #include class PageDirectory : public Retainable { friend class MemoryManager; public: static Retained create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); } static Retained 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(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 m_directory_page; HashMap> m_physical_pages; };