|
AquilaOS documentation
How it works, and its code
|
Address spaces: a process's mappings (map entries), kept in address order, and its page tables (pmap). More...
#include <core/system.h>#include <core/arch.h>#include <mm/pmap.h>#include <mm/vm.h>#include <ds/queue.h>Go to the source code of this file.
Functions | |
| 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. | |
| struct vm_entry * | vm_space_find (struct vm_space *vm_space, vaddr_t vaddr) |
| Finds the map entry that an address is in. | |
| 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 emptied. | |
| int | vm_space_fork (struct vm_space *src, struct vm_space *dst) |
| Copies an address space's mappings into another, for fork(). | |
Address spaces: a process's mappings (map entries), kept in address order, and its page tables (pmap).
Definition in file vm_space.c.
| 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 emptied.
| vm_space | the address space (NULL does nothing) |
Definition at line 124 of file vm_space.c.
References kfree(), NULL, vm_space::pmap, pmap_remove_all(), vm_space::vm_entries, vm_entry_destroy(), and vm_space_destroy().
Referenced by binfmt_fmt_load(), proc_fork(), proc_kill(), and vm_space_destroy().
Finds the map entry that an address is in.
| vm_space | the address space |
| vaddr | the address |
Definition at line 99 of file vm_space.c.
References vm_entry::base, NULL, PAGE_ALIGN, queue_for, vm_entry::size, vm_space::vm_entries, and vm_space_find().
Referenced by mm_page_fault(), and vm_space_find().
Copies an address space's mappings into another, for fork().
The two share the pages, copy on write: writable private mappings become read-only in src, and their anons are marked to be copied, so that the first write to a page gives the writer its own copy (mm/fault.c).
| src | the parent's address space |
| dst | the child's address space, empty |
Definition at line 152 of file vm_space.c.
References vm_entry::base, vm_anon::flags, vm_entry::flags, kfree(), kmalloc(), memcpy(), vm_space::pmap, pmap_protect(), vm_entry::qnode, queue_for, vm_entry::size, vm_entry::vm_anon, vm_anon_incref(), VM_COPY, vm_space::vm_entries, VM_KW, vm_entry::vm_object, vm_object_incref(), VM_SHARED, vm_space_fork(), and VM_UW.
Referenced by proc_fork(), and vm_space_fork().
Adds a map entry to an address space, in address order.
If the entry's base is 0, the entry is placed at the highest free gap between mappings that it fits in. The entry always goes before an existing one (the stack's, at the top of user space): an entry past the last one can't be added.
| vm_space | the address space |
| vm_entry | the entry, with its base (or 0) and size set |
Definition at line 27 of file vm_space.c.
References vm_entry::base, queue::count, queue::head, kmalloc(), M_ZERO, qnode::next, NULL, qnode::prev, vm_entry::qnode, queue_for, vm_entry::size, qnode::value, vm_space::vm_entries, and vm_space_insert().
Referenced by arch_sigcode_map(), sys_mmap(), and vm_space_insert().