2019-04-03 16:13:07 +03:00
|
|
|
#include <Kernel/VM/MemoryManager.h>
|
2019-06-07 12:43:58 +03:00
|
|
|
#include <Kernel/VM/PhysicalPage.h>
|
2019-09-16 10:01:44 +03:00
|
|
|
#include <Kernel/Heap/kmalloc.h>
|
2019-04-03 16:13:07 +03:00
|
|
|
|
2019-06-21 19:37:47 +03:00
|
|
|
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
|
2019-04-03 16:13:07 +03:00
|
|
|
{
|
2019-07-24 07:29:47 +03:00
|
|
|
return adopt(*new PhysicalPage(paddr, supervisor, may_return_to_freelist));
|
2019-04-03 16:13:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-14 14:56:21 +03:00
|
|
|
void PhysicalPage::return_to_freelist() &&
|
2019-04-03 16:13:07 +03:00
|
|
|
{
|
|
|
|
ASSERT((paddr().get() & ~PAGE_MASK) == 0);
|
2019-06-11 14:13:02 +03:00
|
|
|
|
2019-04-03 16:13:07 +03:00
|
|
|
InterruptDisabler disabler;
|
2019-06-11 14:13:02 +03:00
|
|
|
|
2019-04-03 16:13:07 +03:00
|
|
|
m_retain_count = 1;
|
2019-06-11 14:13:02 +03:00
|
|
|
|
2019-04-03 16:13:07 +03:00
|
|
|
if (m_supervisor)
|
2019-06-14 14:56:21 +03:00
|
|
|
MM.deallocate_supervisor_physical_page(move(*this));
|
2019-04-03 16:13:07 +03:00
|
|
|
else
|
2019-06-14 14:56:21 +03:00
|
|
|
MM.deallocate_user_physical_page(move(*this));
|
2019-06-11 14:13:02 +03:00
|
|
|
|
2019-04-03 16:13:07 +03:00
|
|
|
#ifdef MM_DEBUG
|
|
|
|
dbgprintf("MM: P%x released to freelist\n", m_paddr.get());
|
|
|
|
#endif
|
|
|
|
}
|