Unifying the Lunaix's Physical Memory Model (#28)
[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     u32_t proct;          // protections
15     u32_t flags;          // other options
16     u32_t type;           // region type
17     ptr_t range_start;
18     ptr_t range_end;
19 };
20
21 int
22 mem_adjust_inplace(vm_regions_t* regions,
23                    struct mm_region* region,
24                    ptr_t newend);
25
26 int 
27 mmap_user(void** addr_out,
28         struct mm_region** created,
29         ptr_t addr,
30         struct v_file* file,
31         struct mmap_param* param);
32
33 int
34 mem_map(void** addr_out,
35         struct mm_region** created,
36         ptr_t addr,
37         struct v_file* file,
38         struct mmap_param* param);
39
40 int
41 mem_unmap(ptr_t mnt, vm_regions_t* regions, ptr_t addr, size_t length);
42
43 void
44 mem_unmap_region(ptr_t mnt, struct mm_region* region);
45
46 void
47 mem_sync_pages(ptr_t mnt,
48                struct mm_region* region,
49                ptr_t start,
50                ptr_t length,
51                int options);
52
53 int
54 mem_msync(ptr_t mnt,
55           vm_regions_t* regions,
56           ptr_t addr,
57           size_t length,
58           int options);
59
60 #endif /* __LUNAIX_MMAP_H */