56#include <kernel/spinlock.h>
57#include <kernel/types.h>
63#include <utils/compiler.h>
64#include <utils/container_of.h>
110static_assert(
sizeof(
vma_t) <= VMA_SIZE,
"Update the allocated size for VMA "
130static inline size_t vma_size(
const vma_t *
vma)
135static inline u32 vma_flags(
const vma_t *
vma)
184 BITMAP(reserved, VMM_RESERVED_SIZE / VMA_SIZE);
189#define MMAP_INVALID NULL
202#define IS_KERNEL_ADDRESS(_addr) ((vaddr_t)(_addr) >= KERNEL_MEMORY_START)
error_t unmap_file(struct file *file, void *addr)
Delete a file's memory mapping.
Definition: vmm.c:696
static vaddr_t vma_end(const vma_t *vma)
Compute the end address of a VMA.
Definition: vmm.h:119
void vmm_free(vmm_t *, vaddr_t, size_t length)
Free a virtual address.
Definition: vmm.c:543
vmm_t kernel_vmm
Global kernel VMM, used to allocate shared kernel addresses.
Definition: vmm.c:45
static vaddr_t vma_start(const vma_t *vma)
Definition: vmm.h:125
struct vm_segment * vmm_find(const vmm_t *, vaddr_t)
Find the VMA to which a virtual address belongs.
Definition: vmm.c:592
void * map_file(struct file *file, int prot)
Map a file into kernel memory.
Definition: vmm.c:669
error_t vmm_resize(vmm_t *, vma_t *, size_t)
Change the size of a VMA.
Definition: vmm.c:565
struct vm_segment * vmm_allocate(vmm_t *, vaddr_t, size_t size, int flags)
Allocate a virtual area of the given size.
Definition: vmm.c:477
void vmm_destroy(vmm_t *vmm)
Free the VMM struct.
Definition: vmm.c:637
void vmm_clear(vmm_t *vmm)
Release all the VMAs inside a VMM instance.
Definition: vmm.c:630
bool vmm_init(vmm_t *vmm, vaddr_t start, vaddr_t end)
Initialize a VMM instance.
Definition: vmm.c:139
void vmm_copy(vmm_t *dst, vmm_t *src)
Copy the content of a VMM instance inside another one.
Definition: vmm.c:647
#define container_of(_ptr, _struct, _field)
Cast a member of a structure out to the containing structure.
Definition: container_of.h:12
Address space.
Definition: vm.h:45
A single node of an AVL tree.
Definition: avl.h:52
Opened file description.
Definition: file.h:29
Spinlock.
Definition: spinlock.h:29
Segment of contiguous virtual memory.
Definition: vm.h:152
size_t size
Definition: vm.h:155
vaddr_t start
Definition: vm.h:154
u32 flags
Definition: vm.h:156
Intrusive AVL tree structures used by the VMM libalgo/avl.H.
Definition: vmm.h:101
struct avl by_address
Definition: vmm.h:102
struct avl by_size
Definition: vmm.h:103
Virtual Memory Area.
Definition: vmm.h:91
bool allocated
Definition: vmm.h:95
struct vm_segment segment
Definition: vmm.h:93
Roots of the AVL trees containing the VMAs.
Definition: vmm.h:172
Virtual Memory Manager.
Definition: vmm.h:164
vaddr_t start
Definition: vmm.h:166
vaddr_t end
Definition: vmm.h:167
BITMAP(reserved, VMM_RESERVED_SIZE/VMA_SIZE)
Bitmap of the available virtual addreses inside the reserved area.
spinlock_t lock
Definition: vmm.h:177