13#define ALLOCATOR_REGION_NULL (region_t){ .name = "NULL", .start = 0, .end = 0 }
18#define ALLOCATOR_REGION_USER_STACK (region_t){ .name = "User stack", .start = 0x00003F0000001000, .end = 0x00003FFFFFFFEFF8 }
19#define ALLOCATOR_REGION_USER_HARDWARE (region_t){ .name = "User MMIO", .start = 0x00007F0000000000, .end = 0x00007FFFFFFFDFFF }
20#define ALLOCATOR_REGION_USER_IOPERM (region_t){ .name = "User ioperm bitmask", .start = 0x00007FFFFFFFE000, .end = 0x00007FFFFFFFFFFF }
22#define ALLOCATOR_REGION_SCRATCHPAD (region_t){ .name = "Kernel scratchpad", .start = 0xFFFFFFFF80000000, .end = 0xFFFFFFFF80FFFFFF }
23#define ALLOCATOR_REGION_KERNEL_BINARY (region_t){ .name = "Kernel binary", .start = 0xFFFFFFFF81000000, .end = 0xFFFFFFFF88FFFFFF }
24#define ALLOCATOR_REGION_SLAB_4K (region_t){ .name = "4k slab allocator", .start = 0xFFFFFFFF89000000, .end = 0xFFFFFFFF8FFFFFFF }
25#define ALLOCATOR_REGION_KERNEL_HEAP (region_t){ .name = "Kernel heap", .start = 0xFFFFFFFF90000000, .end = 0xFFFFFFFFFFFFFFFF }
29#define ALLOCATOR_REGION_DIRECT_MAPPING (region_t){ .name = "Physical mapping", .start = 0xFFFF800000000000, .end = 0xFFFF83FFFFFFFFFF }
void vm_context_unmap(struct vm_table *context, ptr_t virt)
static const uint8_t PageSize2MiB
void vm_context_map(struct vm_table *context, ptr_t virt, ptr_t physical, uint8_t pat)
void cleanup_boot_vm(void)
ptr_t vm_context_alloc_pages(struct vm_table *context, region_t region, size_t num)
struct vm_table * vm_current_context(void)
ptr_t vm_context_find_free(struct vm_table *context, region_t region, size_t num)
static const uint32_t PageLocked
Page is mapped in multiple processes as shared memory.
static const uint32_t PageCoW
Page accesses MMIO hardware, plain memory otherwise.
ptr_t vm_map_hardware(ptr_t hw, size_t len)
Map a given memory area in the currently running userspace process at a random location.
static const uint32_t PageUsagePagingStructure
Page is locked and cannot be unmapped.
static const uint32_t PageSharedMemory
Copy page on fault and give RW access on new page, normal #PF logic otherwise.
void vm_copy_range(struct vm_table *dst_ctx, struct vm_table *src_ctx, ptr_t addr, size_t size)
static const uint32_t PageUsageHardware
Page is used by kernel, userspace otherwise.
static const uint32_t PageUsageKernel
static const uint8_t PageSize4KiB
Page is used as paging structure.
void vm_context_activate(struct vm_table *context)
struct vm_table * vm_context_new(void)
int vm_table_get_free_index1(struct vm_table *table)
int vm_table_get_free_index3(struct vm_table *table, int start, int end)
void * vm_alloc(size_t size)
Like malloc but allocates full pages only. 16 byte data overhead.
struct vm_table * VM_KERNEL_CONTEXT
void vm_free(void *ptr)
the matching free() like function for vm_alloc
ptr_t vm_context_get_physical_for_virtual(struct vm_table *context, ptr_t virt)
static const uint8_t PageSize1GiB
uint16_t size
Size of the loaded file.
A paging table, when this is a PML4 it may also be called context.