X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/69777bdcab284335651a8002e2896f3862fa423d..c166bd62fbb907f95f79f621e2a2fb4fdde08e01:/lunaix-os/arch/i386/mm/vmutils.c diff --git a/lunaix-os/arch/i386/mm/vmutils.c b/lunaix-os/arch/i386/mm/vmutils.c index d7a98ea..c787892 100644 --- a/lunaix-os/arch/i386/mm/vmutils.c +++ b/lunaix-os/arch/i386/mm/vmutils.c @@ -1,23 +1,28 @@ -#include -#include +#include #include -ptr_t -vmm_dup_page(ptr_t pa) +struct leaflet* +dup_leaflet(struct leaflet* leaflet) { - ptr_t new_ppg = pmm_alloc_page(0); - mount_page(PG_MOUNT_3, new_ppg); - mount_page(PG_MOUNT_4, pa); + ptr_t dest_va, src_va; + struct leaflet* new_leaflet; + + new_leaflet = alloc_leaflet(leaflet_order(leaflet)); + + src_va = leaflet_mount(leaflet); + dest_va = vmap(new_leaflet, KERNEL_DATA); + + size_t cnt_wordsz = leaflet_size(new_leaflet) / sizeof(ptr_t); asm volatile("movl %1, %%edi\n" "movl %2, %%esi\n" - "rep movsl\n" ::"c"(1024), - "r"(PG_MOUNT_3), - "r"(PG_MOUNT_4) + "rep movsl\n" ::"c"(cnt_wordsz), + "r"(dest_va), + "r"(src_va) : "memory", "%edi", "%esi"); - unmount_page(PG_MOUNT_3); - unmount_page(PG_MOUNT_4); + leaflet_unmount(leaflet); + vunmap(dest_va, new_leaflet); - return new_ppg; + return new_leaflet; } \ No newline at end of file