summaryrefslogtreecommitdiff
path: root/Kernel/MemoryManager.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-17 13:12:59 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-17 13:12:59 +0100
commit0730b3c15fdc537e365fde0c307bea3fb615a43e (patch)
tree56203bfc1d81590b8f4d36775224def37dadefe3 /Kernel/MemoryManager.h
parent8321908abe7a3cfef4b90f80f40e6fa004cc8927 (diff)
downloadserenity-0730b3c15fdc537e365fde0c307bea3fb615a43e.zip
Add ability to switch video modes from the system menu.
I had to change PhysicalPage around a bit for this. Physical pages can now be instantiated for any arbitrary physical address without worrying that such pages end up in the kernel page allocator when released. Most of the pieces were already in place, I just glued everything together.
Diffstat (limited to 'Kernel/MemoryManager.h')
-rw-r--r--Kernel/MemoryManager.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/Kernel/MemoryManager.h b/Kernel/MemoryManager.h
index 289baf0675..ccdcf0b6ad 100644
--- a/Kernel/MemoryManager.h
+++ b/Kernel/MemoryManager.h
@@ -25,7 +25,6 @@ enum class PageFaultResponse {
};
class PhysicalPage {
- AK_MAKE_ETERNAL
friend class MemoryManager;
friend class PageDirectory;
friend class VMObject;
@@ -41,19 +40,27 @@ public:
void release()
{
ASSERT(m_retain_count);
- if (!--m_retain_count)
- return_to_freelist();
+ if (!--m_retain_count) {
+ if (m_may_return_to_freelist)
+ return_to_freelist();
+ else
+ delete this;
+ }
}
+ static RetainPtr<PhysicalPage> create_eternal(PhysicalAddress, bool supervisor);
+ static RetainPtr<PhysicalPage> create(PhysicalAddress, bool supervisor);
+
unsigned short retain_count() const { return m_retain_count; }
private:
- PhysicalPage(PhysicalAddress paddr, bool supervisor);
- ~PhysicalPage() = delete;
+ PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
+ ~PhysicalPage() { }
void return_to_freelist();
unsigned short m_retain_count { 1 };
+ bool m_may_return_to_freelist { true };
bool m_supervisor { false };
PhysicalAddress m_paddr;
};