diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-03 15:13:07 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-03 15:13:07 +0200 |
commit | b9738fa8ac001945d440d2c078d8a3ec2b2a893b (patch) | |
tree | f818bab11b0342c2959335057899401d83d45eda /Kernel/VM/PhysicalPage.h | |
parent | 39fd81174eec44511a95d2db5db52bcabc930653 (diff) | |
download | serenity-b9738fa8ac001945d440d2c078d8a3ec2b2a893b.zip |
Kernel: Move VM-related files into Kernel/VM/.
Also break MemoryManager.{cpp,h} into one file per class.
Diffstat (limited to 'Kernel/VM/PhysicalPage.h')
-rw-r--r-- | Kernel/VM/PhysicalPage.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h new file mode 100644 index 0000000000..f3b15378dc --- /dev/null +++ b/Kernel/VM/PhysicalPage.h @@ -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; +}; |