refactor: decouple the executable file implementations with execve functionality.
[lunaix-os.git] / lunaix-os / includes / lunaix / mm / mmap.h
1 #ifndef __LUNAIX_MMAP_H
2 #define __LUNAIX_MMAP_H
3
4 #include <lunaix/fs.h>
5 #include <lunaix/mm/region.h>
6 #include <lunaix/types.h>
7
8 struct mmap_param
9 {
10     ptr_t vms_mnt;        // vm mount point
11     struct proc_mm* pvms; // process vm
12     off_t offset;         // mapped file offset
13     size_t mlen;          // mapped memory length
14     size_t flen;          // mapped file length
15     u32_t proct;          // protections
16     u32_t flags;          // other options
17     u32_t type;           // region type
18 };
19
20 int
21 mem_adjust_inplace(vm_regions_t* regions,
22                    struct mm_region* region,
23                    ptr_t newend);
24
25 int
26 mem_map(void** addr_out,
27         struct mm_region** created,
28         void* addr,
29         struct v_file* file,
30         struct mmap_param* param);
31
32 int
33 mem_unmap(ptr_t mnt, vm_regions_t* regions, void* addr, size_t length);
34
35 void
36 mem_unmap_region(ptr_t mnt, struct mm_region* region);
37
38 void
39 mem_sync_pages(ptr_t mnt,
40                struct mm_region* region,
41                ptr_t start,
42                ptr_t length,
43                int options);
44
45 int
46 mem_msync(ptr_t mnt,
47           vm_regions_t* regions,
48           ptr_t addr,
49           size_t length,
50           int options);
51
52 #endif /* __LUNAIX_MMAP_H */