Kernel: Rename vmo => vmobject everywhere

This commit is contained in:
Andreas Kling 2019-12-19 19:13:44 +01:00
parent 8ea4217c01
commit b6ee8a2c8d
Notes: sideshowbarker 2024-07-19 10:48:28 +09:00
15 changed files with 47 additions and 47 deletions

View file

@ -88,11 +88,11 @@ KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, Virtual
{
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
auto vmo = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());
auto* region = process.allocate_region_with_vmo(
auto vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());
auto* region = process.allocate_region_with_vmobject(
preferred_vaddr,
framebuffer_size_in_bytes(),
move(vmo),
move(vmobject),
0,
"BXVGA Framebuffer",
prot);

View file

@ -27,11 +27,11 @@ KResultOr<Region*> MBVGADevice::mmap(Process& process, FileDescription&, Virtual
{
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
auto vmo = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());
auto* region = process.allocate_region_with_vmo(
auto vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());
auto* region = process.allocate_region_with_vmobject(
preferred_vaddr,
framebuffer_size_in_bytes(),
move(vmo),
move(vmobject),
0,
"MBVGA Framebuffer",
prot);

View file

@ -114,9 +114,9 @@ int Inode::decrement_link_count()
return -ENOTIMPL;
}
void Inode::set_vmo(VMObject& vmo)
void Inode::set_vmobject(VMObject& vmobject)
{
m_vmobject = vmo.make_weak_ptr();
m_vmobject = vmobject.make_weak_ptr();
}
bool Inode::bind_socket(LocalSocket& socket)

View file

@ -71,7 +71,7 @@ public:
void will_be_destroyed();
void set_vmo(VMObject&);
void set_vmobject(VMObject&);
InodeVMObject* vmobject() { return m_vmobject.ptr(); }
const InodeVMObject* vmobject() const { return m_vmobject.ptr(); }

View file

@ -74,7 +74,7 @@ enum ProcFileType {
__FI_PID_Start,
FI_PID_vm,
FI_PID_vmo,
FI_PID_vmobjects,
FI_PID_stack,
FI_PID_regs,
FI_PID_fds,
@ -478,7 +478,7 @@ Optional<KBuffer> procfs$net_local(InodeIdentifier)
return builder.build();
}
Optional<KBuffer> procfs$pid_vmo(InodeIdentifier identifier)
Optional<KBuffer> procfs$pid_vmobjects(InodeIdentifier identifier)
{
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
if (!handle)
@ -1374,7 +1374,7 @@ ProcFS::ProcFS()
m_entries[FI_Root_net_local] = { "local", FI_Root_net_local, procfs$net_local };
m_entries[FI_PID_vm] = { "vm", FI_PID_vm, procfs$pid_vm };
m_entries[FI_PID_vmo] = { "vmo", FI_PID_vmo, procfs$pid_vmo };
m_entries[FI_PID_vmobjects] = { "vmobjects", FI_PID_vmobjects, procfs$pid_vmobjects };
m_entries[FI_PID_stack] = { "stack", FI_PID_stack, procfs$pid_stack };
m_entries[FI_PID_regs] = { "regs", FI_PID_regs, procfs$pid_regs };
m_entries[FI_PID_fds] = { "fds", FI_PID_fds, procfs$pid_fds };

View file

@ -93,5 +93,5 @@ KResultOr<Region*> SharedMemory::mmap(Process& process, FileDescription&, Virtua
{
if (!vmobject())
return KResult(-ENODEV);
return process.allocate_region_with_vmo(vaddr, size, *vmobject(), offset, name(), prot);
return process.allocate_region_with_vmobject(vaddr, size, *vmobject(), offset, name(), prot);
}

View file

@ -130,9 +130,9 @@ static unsigned prot_to_region_access_flags(int prot)
return access;
}
Region& Process::allocate_split_region(const Region& source_region, const Range& range, size_t offset_in_vmo)
Region& Process::allocate_split_region(const Region& source_region, const Range& range, size_t offset_in_vmobject)
{
m_regions.append(Region::create_user_accessible(range, source_region.vmobject(), offset_in_vmo, source_region.name(), source_region.access()));
m_regions.append(Region::create_user_accessible(range, source_region.vmobject(), offset_in_vmobject, source_region.name(), source_region.access()));
return m_regions.last();
}
@ -158,13 +158,13 @@ Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size,
return &m_regions.last();
}
Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject> vmo, size_t offset_in_vmo, const String& name, int prot)
Region* Process::allocate_region_with_vmobject(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot)
{
auto range = allocate_range(vaddr, size);
if (!range.is_valid())
return nullptr;
offset_in_vmo &= PAGE_MASK;
m_regions.append(Region::create_user_accessible(range, move(vmo), offset_in_vmo, name, prot_to_region_access_flags(prot)));
offset_in_vmobject &= PAGE_MASK;
m_regions.append(Region::create_user_accessible(range, move(vmobject), offset_in_vmobject, name, prot_to_region_access_flags(prot)));
m_regions.last().map(page_directory());
return &m_regions.last();
}
@ -240,7 +240,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
// FIXME: The rest of this function seems like it could share more code..
if (flags & MAP_PURGEABLE) {
auto vmobject = PurgeableVMObject::create_with_size(size);
auto* region = allocate_region_with_vmo(VirtualAddress((u32)addr), size, vmobject, 0, name ? name : "mmap (purgeable)", prot);
auto* region = allocate_region_with_vmobject(VirtualAddress((u32)addr), size, vmobject, 0, name ? name : "mmap (purgeable)", prot);
if (!region)
return (void*)-ENOMEM;
if (flags & MAP_SHARED)
@ -516,8 +516,8 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
ProcessPagingScope paging_scope(*this);
ASSERT(description->inode());
auto vmo = InodeVMObject::create_with_inode(*description->inode());
auto* region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo, 0, description->absolute_path(), PROT_READ);
auto vmobject = InodeVMObject::create_with_inode(*description->inode());
auto* region = allocate_region_with_vmobject(VirtualAddress(), metadata.size, vmobject, 0, description->absolute_path(), PROT_READ);
ASSERT(region);
// NOTE: We yank this out of 'm_regions' since we're about to manipulate the vector
@ -544,7 +544,7 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
prot |= PROT_WRITE;
if (is_executable)
prot |= PROT_EXEC;
if (!allocate_region_with_vmo(vaddr, size, vmo, offset_in_image, String(name), prot))
if (!allocate_region_with_vmobject(vaddr, size, vmobject, offset_in_image, String(name), prot))
return nullptr;
return vaddr.as_ptr();
};
@ -2838,7 +2838,7 @@ int Process::sys$create_shared_buffer(int size, void** buffer)
*buffer = shared_buffer->ref_for_process_and_get_address(*this);
ASSERT((int)shared_buffer->size() >= size);
#ifdef SHARED_BUFFER_DEBUG
kprintf("%s(%u): Created shared buffer %d @ %p (%u bytes, vmo is %u)\n", name().characters(), pid(), shared_buffer_id, *buffer, size, shared_buffer->size());
kprintf("%s(%u): Created shared buffer %d @ %p (%u bytes, vmobject is %u)\n", name().characters(), pid(), shared_buffer_id, *buffer, size, shared_buffer->size());
#endif
shared_buffers().resource().set(shared_buffer_id, move(shared_buffer));

View file

@ -284,12 +284,12 @@ public:
bool is_superuser() const { return m_euid == 0; }
Region* allocate_region_with_vmo(VirtualAddress, size_t, NonnullRefPtr<VMObject>, size_t offset_in_vmo, const String& name, int prot);
Region* allocate_region_with_vmobject(VirtualAddress, size_t, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const String& name, int prot);
Region* allocate_file_backed_region(VirtualAddress, size_t, NonnullRefPtr<Inode>, const String& name, int prot);
Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true);
bool deallocate_region(Region& region);
Region& allocate_split_region(const Region& source_region, const Range&, size_t offset_in_vmo);
Region& allocate_split_region(const Region& source_region, const Range&, size_t offset_in_vmobject);
void set_being_inspected(bool b) { m_being_inspected = b; }
bool is_being_inspected() const { return m_being_inspected; }

View file

@ -61,7 +61,7 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
ref.count++;
m_total_refs++;
if (ref.region == nullptr) {
ref.region = process.allocate_region_with_vmo(VirtualAddress(), size(), m_vmobject, 0, "SharedBuffer", PROT_READ | (m_writable ? PROT_WRITE : 0));
ref.region = process.allocate_region_with_vmobject(VirtualAddress(), size(), m_vmobject, 0, "SharedBuffer", PROT_READ | (m_writable ? PROT_WRITE : 0));
ref.region->set_shared(true);
}
sanity_check("ref_for_process_and_get_address");

View file

@ -8,9 +8,9 @@ NonnullRefPtr<InodeVMObject> InodeVMObject::create_with_inode(Inode& inode)
InterruptDisabler disabler;
if (inode.vmobject())
return *inode.vmobject();
auto vmo = adopt(*new InodeVMObject(inode));
vmo->inode().set_vmo(*vmo);
return vmo;
auto vmobject = adopt(*new InodeVMObject(inode));
vmobject->inode().set_vmobject(*vmobject);
return vmobject;
}
NonnullRefPtr<VMObject> InodeVMObject::clone()

View file

@ -587,16 +587,16 @@ bool MemoryManager::validate_user_write(const Process& process, VirtualAddress v
return region && region->is_writable();
}
void MemoryManager::register_vmo(VMObject& vmo)
void MemoryManager::register_vmobject(VMObject& vmobject)
{
InterruptDisabler disabler;
m_vmobjects.append(&vmo);
m_vmobjects.append(&vmobject);
}
void MemoryManager::unregister_vmo(VMObject& vmo)
void MemoryManager::unregister_vmobject(VMObject& vmobject)
{
InterruptDisabler disabler;
m_vmobjects.remove(&vmo);
m_vmobjects.remove(&vmobject);
}
void MemoryManager::register_region(Region& region)

View file

@ -87,8 +87,8 @@ private:
MemoryManager(u32 physical_address_for_kernel_page_tables);
~MemoryManager();
void register_vmo(VMObject&);
void unregister_vmo(VMObject&);
void register_vmobject(VMObject&);
void unregister_vmobject(VMObject&);
void register_region(Region&);
void unregister_region(Region&);

View file

@ -27,10 +27,10 @@ Region::Region(const Range& range, NonnullRefPtr<Inode> inode, const String& nam
MM.register_region(*this);
}
Region::Region(const Range& range, NonnullRefPtr<VMObject> vmo, size_t offset_in_vmo, const String& name, u8 access)
Region::Region(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, u8 access)
: m_range(range)
, m_offset_in_vmo(offset_in_vmo)
, m_vmobject(move(vmo))
, m_offset_in_vmobject(offset_in_vmobject)
, m_vmobject(move(vmobject))
, m_name(name)
, m_access(access)
{
@ -65,7 +65,7 @@ NonnullOwnPtr<Region> Region::clone()
vaddr().get());
#endif
// Create a new region backed by the same VMObject.
return Region::create_user_accessible(m_range, m_vmobject, m_offset_in_vmo, m_name, m_access);
return Region::create_user_accessible(m_range, m_vmobject, m_offset_in_vmobject, m_name, m_access);
}
#ifdef MM_DEBUG
@ -78,7 +78,7 @@ NonnullOwnPtr<Region> Region::clone()
// Set up a COW region. The parent (this) region becomes COW as well!
ensure_cow_map().fill(true);
remap();
auto clone_region = Region::create_user_accessible(m_range, m_vmobject->clone(), m_offset_in_vmo, m_name, m_access);
auto clone_region = Region::create_user_accessible(m_range, m_vmobject->clone(), m_offset_in_vmobject, m_name, m_access);
clone_region->ensure_cow_map();
if (m_stack) {
ASSERT(is_readable());

View file

@ -80,7 +80,7 @@ public:
size_t first_page_index() const
{
return m_offset_in_vmo / PAGE_SIZE;
return m_offset_in_vmobject / PAGE_SIZE;
}
size_t last_page_index() const
@ -95,7 +95,7 @@ public:
size_t offset_in_vmobject() const
{
return m_offset_in_vmo;
return m_offset_in_vmobject;
}
bool commit();
@ -141,7 +141,7 @@ public:
// NOTE: These are public so we can make<> them.
Region(const Range&, const String&, u8 access);
Region(const Range&, NonnullRefPtr<VMObject>, size_t offset_in_vmo, const String&, u8 access);
Region(const Range&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const String&, u8 access);
Region(const Range&, NonnullRefPtr<Inode>, const String&, u8 access);
private:
@ -153,7 +153,7 @@ private:
RefPtr<PageDirectory> m_page_directory;
Range m_range;
size_t m_offset_in_vmo { 0 };
size_t m_offset_in_vmobject { 0 };
NonnullRefPtr<VMObject> m_vmobject;
String m_name;
u8 m_access { 0 };

View file

@ -6,16 +6,16 @@
VMObject::VMObject(const VMObject& other)
: m_physical_pages(other.m_physical_pages)
{
MM.register_vmo(*this);
MM.register_vmobject(*this);
}
VMObject::VMObject(size_t size)
: m_physical_pages(ceil_div(size, PAGE_SIZE))
{
MM.register_vmo(*this);
MM.register_vmobject(*this);
}
VMObject::~VMObject()
{
MM.unregister_vmo(*this);
MM.unregister_vmobject(*this);
}