1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00
serenity/Kernel/VM/AnonymousVMObject.cpp
Andreas Kling 6bdb81ad87 Kernel: Split VMObject into two classes: Anonymous- and InodeVMObject
InodeVMObject is a VMObject with an underlying Inode in the filesystem.
AnonymousVMObject has no Inode.

I'm happy that InodeVMObject::inode() can now return Inode& instead of
VMObject::inode() return Inode*. :^)
2019-08-07 18:09:32 +02:00

41 lines
1.1 KiB
C++

#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/PhysicalPage.h>
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size)
{
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
return adopt(*new AnonymousVMObject(size));
}
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
{
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
return adopt(*new AnonymousVMObject(paddr, size));
}
AnonymousVMObject::AnonymousVMObject(size_t size)
: VMObject(size, ShouldFillPhysicalPages::Yes)
{
}
AnonymousVMObject::AnonymousVMObject(PhysicalAddress paddr, size_t size)
: VMObject(size, ShouldFillPhysicalPages::No)
{
for (size_t i = 0; i < size; i += PAGE_SIZE)
m_physical_pages.append(PhysicalPage::create(paddr.offset(i), false, false));
ASSERT(m_physical_pages.size() == page_count());
}
AnonymousVMObject::AnonymousVMObject(const AnonymousVMObject& other)
: VMObject(other)
{
}
AnonymousVMObject::~AnonymousVMObject()
{
}
NonnullRefPtr<VMObject> AnonymousVMObject::clone()
{
return adopt(*new AnonymousVMObject(*this));
}