BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / e59e4fe0bbf5a3f56db0700ee49a81131b590f9c / mem / vm.h

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
#ifndef KERNEL_MEM_VM_H
#define KERNEL_MEM_VM_H

#include <stddef.h>
#include <stdint.h>
#include <sys/mman.h>
#include "../vfs/vfs.h"

typedef struct VirtualMemory VirtualMemory;
typedef struct VMRegion VMRegion;
typedef struct VMObject VMObject;

/* Virtual Memory Namespace */
struct VirtualMemory {
	VMRegion *regions;
	refcount_t usage;
};

/* Structure for a Virtual Memory Map Entry */
struct VMRegion {
	VMRegion *prev, *next;
	uintptr_t start, end;
	int prot;
	int flags;
	off_t offset;
	File *front, *back;
};

VMRegion *vm_create_region(void *addr, size_t len, int prot, int flags,
                           off_t offset, File *back);
void vm_remove_region(VMRegion *region);
void vm_destroy_region(VMRegion *region);
VMRegion *vm_clone_regions(VMRegion *head);

int verify_access(const void *addr, size_t len, int prot);

#endif