mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +00:00
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*. :^)
This commit is contained in:
parent
cb2d572a14
commit
6bdb81ad87
16 changed files with 286 additions and 200 deletions
41
Kernel/VM/AnonymousVMObject.cpp
Normal file
41
Kernel/VM/AnonymousVMObject.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#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));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue