sweep through entire page table to free up intermediate tables
[lunaix-os.git] / lunaix-os / includes / lunaix / mm / mm.h
index 43ef96eaa87f71f371042747c0d2bdc9b740c095..abb18cf1545b74b11608db8441aa2bf278153a30 100644 (file)
@@ -1,20 +1,12 @@
 #ifndef __LUNAIX_MM_H
 #define __LUNAIX_MM_H
 
-#include <lunaix/ds/llist.h>
-#include <lunaix/ds/mutex.h>
-#include <lunaix/fs.h>
 #include <lunaix/types.h>
+#include <lunaix/ds/llist.h>
 
-#include <usr/sys/mann_flags.h>
+#include <asm/pagetable.h>
 
-typedef struct
-{
-    void* start;
-    void* brk;
-    void* max_addr;
-    mutex_t lock;
-} heap_context_t;
+#include <usr/lunaix/mann_flags.h>
 
 /**
  * @brief 私有区域,该区域中的页无法进行任何形式的共享。
@@ -45,6 +37,7 @@ typedef struct
 #define REGION_EXEC PROT_EXEC
 #define REGION_ANON MAP_ANON
 #define REGION_RW REGION_READ | REGION_WRITE
+#define REGION_KERNEL (1 << 31)
 
 #define REGION_TYPE_CODE (1 << 16)
 #define REGION_TYPE_GENERAL (2 << 16)
@@ -55,15 +48,27 @@ typedef struct
 struct mm_region
 {
     struct llist_header head; // must be first field!
+    struct proc_mm* proc_vms;
+
+    // file mapped to this region
     struct v_file* mfile;
-    u32_t offset;
+    // mapped file offset
+    off_t foff;
+    // mapped file length
+
     ptr_t start;
     ptr_t end;
     u32_t attr;
+    size_t flen;
+
+    void** index; // fast reference, to accelerate access to this very region.
 
     void* data;
-    int (*init_page)(struct mm_region*, void*, off_t);
+    // when a region is copied
+    void (*region_copied)(struct mm_region*);
+    // when a region is unmapped
     void (*destruct_region)(struct mm_region*);
 };
 
+
 #endif /* __LUNAIX_MM_H */