1 #ifndef __LUNAIX_PROCVM_H
2 #define __LUNAIX_PROCVM_H
4 #include <lunaix/ds/llist.h>
5 #include <lunaix/ds/mutex.h>
7 #include <lunaix/types.h>
8 #include <lunaix/mm/mm.h>
23 mm_index(void** index, struct mm_region* target)
25 *index = (void*)target;
26 target->index = index;
29 typedef struct llist_header vm_regions_t;
33 // virtual memory root (i.e. root page table)
35 ptr_t vm_mnt; // current mount point
38 struct mm_region* heap;
39 struct proc_info* proc;
40 struct proc_mm* guest_mm; // vmspace mounted by this vmspace
44 * @brief Create a process virtual memory space descriptor
47 * @return struct proc_mm*
50 procvm_create(struct proc_info* proc);
53 * @brief Initialize and mount the vm of `proc` to duplication of current process
56 * @return struct proc_mm*
59 procvm_dupvms_mount(struct proc_mm* proc);
62 procvm_unmount_release(struct proc_mm* proc);
65 procvm_mount(struct proc_mm* mm);
68 procvm_unmount(struct proc_mm* mm);
71 * @brief Initialize and mount the vms of `proc` as a clean slate which contains
72 * nothing but shared global mapping of kernel image.
77 procvm_initvms_mount(struct proc_mm* mm);
81 Mount and unmount from VMS_SELF.
82 Although every vms is mounted to that spot by default,
83 this just serve the purpose to ensure the scheduled
84 vms does not dangling in some other's vms.
88 procvm_mount_self(struct proc_mm* mm);
91 procvm_unmount_self(struct proc_mm* mm);
95 remote virtual memory manipulation
98 #define REMOTEVM_MAX_PAGES 128
101 procvm_enter_remote_transaction(struct remote_vmctx* rvmctx, struct proc_mm* mm,
102 ptr_t remote_base, size_t size);
105 procvm_copy_remote(struct remote_vmctx* rvmctx,
106 ptr_t remote_dest, void* local_src, size_t sz);
109 procvm_exit_remote(struct remote_vmctx* rvmctx);
112 architecture-specific
116 procvm_link_kernel(ptr_t dest_mnt);
119 procvm_unlink_kernel();
121 #endif /* __LUNAIX_PROCVM_H */