Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / includes / lunaix / mm / mmap.h
index 78c12d6f5839c631d6b564a60f7cb77c78411adf..307610b6aa4ec9f430bbe9161dc1bc06901a5940 100644 (file)
@@ -2,18 +2,60 @@
 #define __LUNAIX_MMAP_H
 
 #include <lunaix/fs.h>
 #define __LUNAIX_MMAP_H
 
 #include <lunaix/fs.h>
+#include <lunaix/mm/region.h>
 #include <lunaix/types.h>
 
 #include <lunaix/types.h>
 
-void*
-mem_map(ptr_t pd_ref,
-        struct llist_header* regions,
-        void* addr,
+struct mmap_param
+{
+    ptr_t vms_mnt;        // vm mount point
+    struct proc_mm* pvms; // process vm
+    off_t offset;         // mapped file offset
+    size_t mlen;          // mapped memory length
+    size_t flen;          // mapped file length
+    u32_t proct;          // protections
+    u32_t flags;          // other options
+    u32_t type;           // region type
+    ptr_t range_start;
+    ptr_t range_end;
+};
+
+int
+mem_adjust_inplace(vm_regions_t* regions,
+                   struct mm_region* region,
+                   ptr_t newend);
+
+int 
+mmap_user(void** addr_out,
+        struct mm_region** created,
+        ptr_t addr,
+        struct v_file* file,
+        struct mmap_param* param);
+
+int
+mem_map(void** addr_out,
+        struct mm_region** created,
+        ptr_t addr,
         struct v_file* file,
         struct v_file* file,
-        u32_t offset,
-        size_t length,
-        u32_t attrs);
+        struct mmap_param* param);
+
+int
+mem_unmap(ptr_t mnt, vm_regions_t* regions, ptr_t addr, size_t length);
+
+void
+mem_unmap_region(ptr_t mnt, struct mm_region* region);
+
+void
+mem_sync_pages(ptr_t mnt,
+               struct mm_region* region,
+               ptr_t start,
+               ptr_t length,
+               int options);
 
 
-void*
-mem_unmap(ptr_t mnt, struct llist_header* regions, void* addr, size_t length);
+int
+mem_msync(ptr_t mnt,
+          vm_regions_t* regions,
+          ptr_t addr,
+          size_t length,
+          int options);
 
 #endif /* __LUNAIX_MMAP_H */
 
 #endif /* __LUNAIX_MMAP_H */