45#define VM_NOCACHE 0x0040
46#define VM_SHARED 0x0080
49#define VM_KRW (VM_KR|VM_KW)
50#define VM_KRX (VM_KR|VM_KX)
51#define VM_KWX (VM_KW|VM_KX)
52#define VM_KRWX (VM_KR|VM_KW|VM_KX)
53#define VM_URW (VM_UR|VM_UW)
54#define VM_URX (VM_UR|VM_UX)
55#define VM_UWX (VM_UW|VM_UX)
56#define VM_URWX (VM_UR|VM_UW|VM_UX)
59#define VMOBJ_ZERO 0x0000
60#define VMOBJ_FILE 0x0001
void vnode_pages_update(struct vnode *vnode, off_t start, off_t end)
Reads a file's cached pages again after a write or a truncation changed a range of it.
void vnode_pages_free(struct vnode *vnode)
Frees a vnode's vm object and its cached pages, when the vnode itself is freed.
struct vm_object * vm_object_vnode(struct vnode *vnode)
Gets a vnode's vm object, making it the first time.
#define MALLOC_DECLARE(type)
A queue's node, holding one entry.
An anon: a mapping's private pages, those the process wrote to.
struct hashmap * arefs
its arefs, by the offset of their page in the mapping
int flags
its flags (VM_COPY: to be copied before it's written to)
size_t ref
how many mappings share the anon
An anon's reference to a page (an aref).
uint32_t flags
its flags (VM_COPY)
size_t ref
how many anons have the aref
struct vm_page * vm_page
the page
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
struct vm_anon * vm_anon
its anon: the pages the process wrote to
uint32_t flags
its permissions and flags (VM_*)
paddr_t paddr
physical memory to map all at once (vm_map()), or 0 for pages that come in on page faults
size_t off
where the mapping starts in its object
vaddr_t base
where the mapping starts in its address space
struct vm_object * vm_object
its object: what its other pages come from (a file)
A vm object: what a mapping's pages come from (a file), and its pages that have been read in.
size_t ref
how many mappings it has
void * p
the pager's own data (a file's vnode)
int type
its kind (VMOBJ_*)
struct vm_pager * pager
its pager
struct hashmap * pages
its pages that have been read in, by their offset
A page of physical memory (pages[] has one for every page of RAM).
size_t off
its offset in its object or anon
size_t ref
how many references it has
struct vm_object * vm_object
the object it belongs to, or NULL
paddr_t paddr
its physical address
An address space: its mappings, and its page tables.
struct pmap * pmap
its page tables (the architecture's)
struct queue vm_entries
its mappings (map entries), in address order
A file in memory (a vnode): what its inode says, and the kernel's own state.
void kvmem_selftest(void)
Runs the allocator's self-test, for the kvmem.test kernel argument, and prints whether it passed.
void vm_unmap_full(struct vm_space *vm_space, struct vm_entry *vm_entry)
Unmaps every page of a map entry's range.
void kvmem_setup(void)
Sets up the kernel's allocator at boot, once physical memory and the page tables are ready.
void vm_anon_destroy(struct vm_anon *vm_anon)
Releases an anon's arefs, and the pages of those that no other anon shares.
int vm_map(struct vm_space *vm_space, struct vm_entry *vm_entry)
Maps a map entry's whole range at once: its physical memory (paddr), or new pages of memory if it has...
int vm_space_insert(struct vm_space *vm_space, struct vm_entry *vm_entry)
Adds a map entry to an address space, in address order.
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).
void kvmem_guardtest(void)
Writes one byte past the end of an object, for the kvmem.guard kernel argument: the guard page should...
void vm_entry_destroy(struct vm_entry *vm_entry)
Releases what a map entry holds: its references to its anon and its object.
void vm_anon_incref(struct vm_anon *vm_anon)
Adds a reference to an anon: another mapping shares it (a fork).
struct vm_anon * vm_anon_new(void)
Makes a new, empty anon.
struct vm_entry * vm_entry_new(void)
Makes a new, empty map entry.
struct vm_space kvm_space
struct vm_anon * vm_anon_copy(struct vm_anon *vm_anon)
Makes a copy of an anon that shares its arefs, and so its pages, when a mapping's shared anon is writ...
int vm_space_fork(struct vm_space *parent, struct vm_space *child)
Copies an address space's mappings into another, for fork().
void vm_object_incref(struct vm_object *vm_object)
Adds a reference to a vm object: one more mapping of it.
void vm_anon_decref(struct vm_anon *vm_anon)
Drops a reference to an anon, and frees it with the last one.
void vm_space_destroy(struct vm_space *vm_space)
Removes all the mappings of an address space: its entries are released and freed, and its page tables...
struct vm_entry * vm_space_find(struct vm_space *vm_space, vaddr_t vaddr)
Finds the map entry that an address is in.