33#include <kernel/spinlock.h>
36#include <utils/bits.h>
41#define AS_ASSERT_OWNED(_as) \
42 WARN_ON((_as) != &kernel_address_space && (_as) != current->process->as);
57typedef enum vm_flags {
73#define VM_KERNEL_RO (VM_KERNEL | VM_READ)
74#define VM_KERNEL_WO (VM_KERNEL | VM_WRITE)
75#define VM_KERNEL_RW (VM_KERNEL | VM_READ | VM_WRITE)
77#define VM_USER_RO (VM_READ)
78#define VM_USER_WO (VM_WRITE)
79#define VM_USER_RW (VM_READ | VM_WRITE)
85#define VM_IOMEM (VM_KERNEL_RW | VM_CACHE_UC)
87#define VM_CACHE_MASK (VM_CACHE_UC | VM_CACHE_WT | VM_CACHE_WB | VM_CACHE_WC)
183static inline vaddr_t segment_end(
const struct vm_segment *segment)
227error_t address_space_fault(
struct address_space *,
void *,
bool is_cow);
235void *vm_alloc_start(
struct address_space *,
void *,
size_t, vm_flags_t);
240void *vm_alloc_at(
struct address_space *, paddr_t,
size_t, vm_flags_t);
255error_t vm_set_policy(
struct address_space *,
void *, vm_flags_t policy);
#define BIT(_n)
Generate the nth power of 2 (nth bit set)
Definition: bits.h:20
Address space.
Definition: vm.h:45
vaddr_t brk_end
Definition: vm.h:53
spinlock_t lock
Definition: vm.h:47
llist_t * segments
Definition: vm.h:51
vaddr_t data_end
Definition: vm.h:52
paddr_t mmu
Definition: vm.h:50
struct vmm * vmm
Definition: vm.h:49
The head of a doubly linked list.
Definition: linked_list.h:43
Intrusive doubly-linked list node.
Definition: linked_list.h:27
Spinlock.
Definition: spinlock.h:29
Segment driver.
Definition: vm.h:94
error_t(* vm_fault)(struct address_space *, struct vm_segment *)
Handle a page fault exception on a known segment.
Definition: vm.h:149
error_t(* vm_set_policy)(struct address_space *, struct vm_segment *, vm_flags_t policy)
Configure the effective caching policy for a segment.
Definition: vm.h:155
error_t(* vm_map)(struct address_space *, struct vm_segment *, vm_flags_t)
Map this segment onto a physical address.
Definition: vm.h:152
void(* vm_free)(struct address_space *, struct vm_segment *)
Free a contiguous virtual memory segment.
Definition: vm.h:130
error_t(* vm_resize)(struct address_space *, struct vm_segment *, size_t)
Resize a virtual memory segment.
Definition: vm.h:141
Segment of contiguous virtual memory.
Definition: vm.h:173
size_t size
Definition: vm.h:176
vaddr_t start
Definition: vm.h:175
const struct vm_segment_driver * driver
Definition: vm.h:178
u32 flags
Definition: vm.h:177
Virtual Memory Manager.
Definition: vmm.h:164