mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	Kernel: Move VM-related files into Kernel/VM/.
Also break MemoryManager.{cpp,h} into one file per class.
			
			
This commit is contained in:
		
							parent
							
								
									39fd81174e
								
							
						
					
					
						commit
						b9738fa8ac
					
				
					 21 changed files with 630 additions and 575 deletions
				
			
		
							
								
								
									
										42
									
								
								Kernel/VM/PhysicalPage.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Kernel/VM/PhysicalPage.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | |||
| #include <Kernel/VM/PhysicalPage.h> | ||||
| #include <Kernel/VM/MemoryManager.h> | ||||
| #include <Kernel/kmalloc.h> | ||||
| 
 | ||||
| Retained<PhysicalPage> PhysicalPage::create_eternal(PhysicalAddress paddr, bool supervisor) | ||||
| { | ||||
|     void* slot = kmalloc_eternal(sizeof(PhysicalPage)); | ||||
|     new (slot) PhysicalPage(paddr, supervisor); | ||||
|     return adopt(*(PhysicalPage*)slot); | ||||
| } | ||||
| 
 | ||||
| Retained<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor) | ||||
| { | ||||
|     void* slot = kmalloc(sizeof(PhysicalPage)); | ||||
|     new (slot) PhysicalPage(paddr, supervisor, false); | ||||
|     return adopt(*(PhysicalPage*)slot); | ||||
| } | ||||
| 
 | ||||
| PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist) | ||||
|     : m_may_return_to_freelist(may_return_to_freelist) | ||||
|     , m_supervisor(supervisor) | ||||
|     , m_paddr(paddr) | ||||
| { | ||||
|     if (supervisor) | ||||
|         ++MemoryManager::s_super_physical_pages_in_existence; | ||||
|     else | ||||
|         ++MemoryManager::s_user_physical_pages_in_existence; | ||||
| } | ||||
| 
 | ||||
| void PhysicalPage::return_to_freelist() | ||||
| { | ||||
|     ASSERT((paddr().get() & ~PAGE_MASK) == 0); | ||||
|     InterruptDisabler disabler; | ||||
|     m_retain_count = 1; | ||||
|     if (m_supervisor) | ||||
|         MM.m_free_supervisor_physical_pages.append(adopt(*this)); | ||||
|     else | ||||
|         MM.m_free_physical_pages.append(adopt(*this)); | ||||
| #ifdef MM_DEBUG | ||||
|     dbgprintf("MM: P%x released to freelist\n", m_paddr.get()); | ||||
| #endif | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling