Code-base clean-up and refactoring (#47)
[lunaix-os.git] / lunaix-os / arch / generic / procvm.c
1 #include <lunaix/mm/procvm.h>
2 #include <lunaix/mm/pagetable.h>
3 #include <lunaix/mm/page.h>
4
5 _default void
6 procvm_link_kernel(ptr_t dest_mnt)
7 {
8     pte_t *ptep_smx, *src_smx;
9     struct leaflet* leaflet;
10     unsigned int i;
11     
12     i = va_level_index(KERNEL_RESIDENT, L0T_SIZE);
13     ptep_smx = mkl1tep_va(VMS_SELF, dest_mnt);
14     src_smx  = mkl0tep_va(VMS_SELF, 0);
15
16     for (; i < LEVEL_SIZE; i++)
17     {
18         pte_t* ptep = &ptep_smx[i];
19         pte_t  pte  = pte_at(&src_smx[i]);
20         if (lntep_implie_vmnts(ptep, L0T_SIZE)) {
21             continue;
22         }
23
24         // sanity check
25         leaflet = pte_leaflet_aligned(pte);
26         assert(leaflet_refcount(leaflet) > 0);
27
28         set_pte(ptep, pte);
29     }
30 }
31
32 _default void
33 procvm_unlink_kernel()
34 {
35     // nothing to do here.
36 }