mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:02:46 +00:00 
			
		
		
		
	 27f699ef0c
			
		
	
	
		27f699ef0c
		
	
	
	
	
		
			
			These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <AK/HashMap.h>
 | |
| #include <AK/RefPtr.h>
 | |
| #include <AK/RefCounted.h>
 | |
| #include <Kernel/VM/PhysicalPage.h>
 | |
| #include <Kernel/VM/RangeAllocator.h>
 | |
| 
 | |
| class PageDirectory : public RefCounted<PageDirectory> {
 | |
|     friend class MemoryManager;
 | |
| 
 | |
| public:
 | |
|     static NonnullRefPtr<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); }
 | |
|     static NonnullRefPtr<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
 | |
|     ~PageDirectory();
 | |
| 
 | |
|     u32 cr3() const { return m_directory_page->paddr().get(); }
 | |
|     PageDirectoryEntry* entries() { return reinterpret_cast<PageDirectoryEntry*>(cr3()); }
 | |
| 
 | |
|     void flush(VirtualAddress);
 | |
| 
 | |
|     RangeAllocator& range_allocator() { return m_range_allocator; }
 | |
| 
 | |
| private:
 | |
|     explicit PageDirectory(const RangeAllocator* parent_range_allocator);
 | |
|     explicit PageDirectory(PhysicalAddress);
 | |
| 
 | |
|     RangeAllocator m_range_allocator;
 | |
|     RefPtr<PhysicalPage> m_directory_page;
 | |
|     HashMap<unsigned, RefPtr<PhysicalPage>> m_physical_pages;
 | |
| };
 |