1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +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:
Andreas Kling 2019-04-03 15:13:07 +02:00
parent 39fd81174e
commit b9738fa8ac
21 changed files with 630 additions and 575 deletions

46
Kernel/VM/PhysicalPage.h Normal file
View file

@ -0,0 +1,46 @@
#pragma once
#include <Kernel/Assertions.h>
#include <Kernel/types.h>
#include <AK/Retained.h>
class PhysicalPage {
friend class MemoryManager;
friend class PageDirectory;
friend class VMObject;
public:
PhysicalAddress paddr() const { return m_paddr; }
void retain()
{
ASSERT(m_retain_count);
++m_retain_count;
}
void release()
{
ASSERT(m_retain_count);
if (!--m_retain_count) {
if (m_may_return_to_freelist)
return_to_freelist();
else
delete this;
}
}
static Retained<PhysicalPage> create_eternal(PhysicalAddress, bool supervisor);
static Retained<PhysicalPage> create(PhysicalAddress, bool supervisor);
word retain_count() const { return m_retain_count; }
private:
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
~PhysicalPage() { }
void return_to_freelist();
word m_retain_count { 1 };
bool m_may_return_to_freelist { true };
bool m_supervisor { false };
PhysicalAddress m_paddr;
};