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 procvm_prune_vmr(ptr_t vm_mnt, struct mm_region* region);
56 * @brief Initialize and mount the vm of `proc` to duplication of current process
59 * @return struct proc_mm*
62 procvm_dupvms_mount(struct proc_mm* proc);
65 procvm_unmount_release(struct proc_mm* proc);
68 procvm_mount(struct proc_mm* mm);
71 procvm_unmount(struct proc_mm* mm);
74 * @brief Initialize and mount the vms of `proc` as a clean slate which contains
75 * nothing but shared global mapping of kernel image.
80 procvm_initvms_mount(struct proc_mm* mm);
84 Mount and unmount from VMS_SELF.
85 Although every vms is mounted to that spot by default,
86 this just serve the purpose to ensure the scheduled
87 vms does not dangling in some other's vms.
91 procvm_mount_self(struct proc_mm* mm);
94 procvm_unmount_self(struct proc_mm* mm);
98 remote virtual memory manipulation
101 #define REMOTEVM_MAX_PAGES 128
104 procvm_enter_remote_transaction(struct remote_vmctx* rvmctx, struct proc_mm* mm,
105 ptr_t remote_base, size_t size);
108 procvm_copy_remote(struct remote_vmctx* rvmctx,
109 ptr_t remote_dest, void* local_src, size_t sz);
112 procvm_exit_remote(struct remote_vmctx* rvmctx);
115 architecture-specific
119 procvm_link_kernel(ptr_t dest_mnt);
122 procvm_unlink_kernel();
124 #endif /* __LUNAIX_PROCVM_H */