AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
vm_object.c File Reference

Vm objects: what a mapping's pages come from, such as a file. More...

#include <core/system.h>
#include <core/arch.h>
#include <core/panic.h>
#include <mm/mm.h>
#include <mm/vm.h>
#include <ds/queue.h>
#include <ds/hashmap.h>
#include <fs/vfs.h>

Go to the source code of this file.

Functions

void vm_object_incref (struct vm_object *vm_object)
 Adds a reference to a vm object: one more mapping of it.
void vm_object_decref (struct vm_object *vm_object)
 Drops a reference to a vm object: one mapping of it less.
int vm_object_page_insert (struct vm_object *vm_object, struct vm_page *vm_page)
 Adds a page to a vm object, at the page's offset (vm_page->off).

Detailed Description

Vm objects: what a mapping's pages come from, such as a file.

A file's object is its vnode's, and keeps the file's pages that have been read in (the page cache).

Definition in file vm_object.c.

Function Documentation

◆ vm_object_decref()

void vm_object_decref ( struct vm_object * vm_object)

Drops a reference to a vm object: one mapping of it less.

A file's object lets go of its vnode with the last one. Its pages stay, cached with the vnode, until the vnode is freed (vnode_pages_free()).

Parameters
vm_objectthe object

Definition at line 38 of file vm_object.c.

References vm_object::p, vm_object::ref, vm_object::type, vfs_close(), vm_object_decref(), and VMOBJ_FILE.

Referenced by sys_mmap(), vm_entry_destroy(), and vm_object_decref().

◆ vm_object_incref()

void vm_object_incref ( struct vm_object * vm_object)

Adds a reference to a vm object: one more mapping of it.

A file's object holds its vnode while it's mapped, because the pages are read from it, and the program file it runs may be removed meanwhile.

Parameters
vm_objectthe object

Definition at line 25 of file vm_object.c.

References vm_object::p, vm_object::ref, vnode::ref, vm_object::type, vm_object_incref(), and VMOBJ_FILE.

Referenced by arch_sigcode_map(), binfmt_elf_load_segments(), sys_mmap(), vm_object_incref(), and vm_space_fork().

◆ vm_object_page_insert()

int vm_object_page_insert ( struct vm_object * vm_object,
struct vm_page * vm_page )

Adds a page to a vm object, at the page's offset (vm_page->off).

Parameters
vm_objectthe object
vm_pagethe page
Returns
0, or -ENOMEM if there was no memory to add it (the object doesn't have the page then)

Definition at line 52 of file vm_object.c.

References vm_page::off, vm_object::pages, and vm_object_page_insert().

Referenced by sigcode_in(), vm_object_page_insert(), and vnode_page_in().