add lunaix dynamic linker as submodule
[lunaix-os.git] / lunaix-os / kernel / mm / mmap.c
index f23ff60ab895702ee90271bcc5bc57e177db4bde..8a4c9bc6af509a653477f61833b389b2ce9e549d 100644 (file)
@@ -7,8 +7,10 @@
 #include <lunaix/syscall.h>
 #include <lunaix/syscall_utils.h>
 
+#include <sys/mm/mempart.h>
+
 // any size beyond this is bullshit
-#define BS_SIZE (KERNEL_MM_BASE - UMMAP_START)
+#define BS_SIZE (KERNEL_EXEC - UMMAP_START)
 
 int
 mem_has_overlap(vm_regions_t* regions, ptr_t start, ptr_t end)
@@ -101,7 +103,7 @@ mem_map(void** addr_out,
     return ENOMEM;
 
 found:
-    if (found_loc >= KERNEL_MM_BASE || found_loc < USER_START) {
+    if (found_loc >= KERNEL_EXEC || found_loc < USER_START) {
         return ENOMEM;
     }
 
@@ -177,7 +179,7 @@ mem_sync_pages(ptr_t mnt,
 
             *mapping.pte &= ~PG_DIRTY;
 
-            cpu_invplg((ptr_t)mapping.pte);
+            cpu_flush_page((ptr_t)mapping.pte);
         } else if ((options & MS_INVALIDATE)) {
             goto invalidate;
         }
@@ -191,7 +193,7 @@ mem_sync_pages(ptr_t mnt,
     invalidate:
         *mapping.pte &= ~PG_PRESENT;
         pmm_free_page(KERNEL_PID, mapping.pa);
-        cpu_invplg((ptr_t)mapping.pte);
+        cpu_flush_page((ptr_t)mapping.pte);
     }
 }
 
@@ -329,6 +331,7 @@ __DEFINE_LXSYSCALL3(void*, sys_mmap, void*, addr, size_t, length, va_list, lst)
 
     struct mmap_param param = { .flags = options,
                                 .mlen = ROUNDUP(length, PG_SIZE),
+                                .flen = length,
                                 .offset = offset,
                                 .type = REGION_TYPE_GENERAL,
                                 .proct = proct,