AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
vm_object.c
Go to the documentation of this file.
1
6
7
#include <
core/system.h
>
8
#include <
core/arch.h
>
9
#include <
core/panic.h
>
10
#include <
mm/mm.h
>
11
#include <
mm/vm.h
>
12
#include <
ds/queue.h
>
13
#include <
ds/hashmap.h
>
14
#include <
fs/vfs.h
>
15
16
MALLOC_DEFINE
(M_VM_OBJECT,
"vm-object"
,
"virtual memory object"
);
17
25
void
vm_object_incref
(
struct
vm_object
*
vm_object
)
26
{
27
if
(!
vm_object
->
ref
++ &&
vm_object
->
type
==
VMOBJ_FILE
)
28
((
struct
vnode
*)
vm_object
->
p
)->
ref
++;
29
}
30
38
void
vm_object_decref
(
struct
vm_object
*
vm_object
)
39
{
40
if
(!--
vm_object
->
ref
&&
vm_object
->
type
==
VMOBJ_FILE
)
41
vfs_close
((
struct
vnode
*)
vm_object
->
p
);
42
}
43
52
int
vm_object_page_insert
(
struct
vm_object
*
vm_object
,
struct
vm_page
*
vm_page
)
53
{
54
size_t
off =
vm_page
->
off
;
55
hash_t
hash = hashmap_digest(&off,
sizeof
(off));
56
return
hashmap_insert(
vm_object
->
pages
, hash,
vm_page
) ? -ENOMEM : 0;
57
}
vfs_close
int vfs_close(struct vnode *vnode)
Drops a reference to a vnode.
Definition
close.c:18
hashmap.h
hash_t
uintptr_t hash_t
Definition
hashmap.h:22
arch.h
panic.h
system.h
mm.h
MALLOC_DEFINE
#define MALLOC_DEFINE(type, _name, _desc)
Definition
kvmem.h:30
queue.h
vm_object
A vm object: what a mapping's pages come from (a file), and its pages that have been read in.
Definition
vm.h:132
vm_object::ref
size_t ref
how many mappings it has
Definition
vm.h:140
vm_object::p
void * p
the pager's own data (a file's vnode)
Definition
vm.h:146
vm_object::type
int type
its kind (VMOBJ_*)
Definition
vm.h:137
vm_object::pages
struct hashmap * pages
its pages that have been read in, by their offset
Definition
vm.h:134
vm_page
A page of physical memory (pages[] has one for every page of RAM).
Definition
vm.h:150
vm_page::off
size_t off
its offset in its object or anon
Definition
vm.h:155
vnode
A file in memory (a vnode): what its inode says, and the kernel's own state.
Definition
vfs.h:113
vnode::ref
size_t ref
how many references there are to it
Definition
vfs.h:133
vfs.h
vm.h
VMOBJ_FILE
#define VMOBJ_FILE
a file's pages
Definition
vm.h:60
vm_object_decref
void vm_object_decref(struct vm_object *vm_object)
Drops a reference to a vm object: one mapping of it less.
Definition
vm_object.c:38
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).
Definition
vm_object.c:52
vm_object_incref
void vm_object_incref(struct vm_object *vm_object)
Adds a reference to a vm object: one more mapping of it.
Definition
vm_object.c:25
kernel
mm
vm_object.c
Generated by
1.18.0