Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / kernel / process / process.c
index 91fe240860211153d3b6b8d3d31e86803b8ee46f..de533c7f5eda32e4292a55f495f1e900f50f1aad 100644 (file)
@@ -61,23 +61,22 @@ int
 spawn_process(struct thread** created, ptr_t entry, bool with_ustack) 
 {
     struct proc_info* kproc = alloc_process();
+    struct proc_mm* mm = vmspace(kproc);
 
-    procvm_init_clean(kproc);
+    procvm_initvms_mount(mm);
 
-    vmm_mount_pd(VMS_MOUNT_1, vmroot(kproc));
-    
-    struct thread* kthread = create_thread(kproc, VMS_MOUNT_1, with_ustack);
+    struct thread* kthread = create_thread(kproc, with_ustack);
 
     if (!kthread) {
-        vmm_unmount_pd(VMS_MOUNT_1);
+        procvm_unmount(mm);
         delete_process(kproc);
         return -1;
     }
 
     commit_process(kproc);
-    start_thread(kthread, VMS_MOUNT_1, entry);
+    start_thread(kthread, entry);
 
-    vmm_unmount_pd(VMS_MOUNT_1);
+    procvm_unmount(mm);
 
     if (created) {
         *created = kthread;
@@ -92,39 +91,38 @@ spawn_process_usr(struct thread** created, char* path,
 {
     // FIXME remote injection of user stack not yet implemented
 
-    struct proc_info* proc = alloc_process();
+    struct proc_info* proc   = alloc_process();
+    struct proc_mm*   mm     = vmspace(proc);
     
     assert(!kernel_process(proc));
 
-    procvm_init_clean(proc);
-
-    vmm_mount_pd(VMS_MOUNT_1, vmroot(proc));
+    procvm_initvms_mount(mm);
 
     int errno = 0;
     struct thread* main_thread;
-    if (!(main_thread = create_thread(proc, VMS_MOUNT_1, true))) {
+    if (!(main_thread = create_thread(proc, true))) {
         errno = ENOMEM;
         goto fail;
     }
 
-    struct exec_container container;
+    struct exec_host container;
     exec_init_container(&container, main_thread, VMS_MOUNT_1, argv, envp);
     if ((errno = exec_load_byname(&container, path))) {
         goto fail;
     }
 
     commit_process(proc);
-    start_thread(main_thread, VMS_MOUNT_1, container.exe.entry);
+    start_thread(main_thread, container.exe.entry);
 
     if (created) {
         *created = main_thread;
     }
 
-    vmm_unmount_pd(VMS_MOUNT_1);
+    procvm_unmount(mm);
     return 0;
 
 fail:
-    vmm_unmount_pd(VMS_MOUNT_1);
+    procvm_unmount(mm);
     delete_process(proc);
     return errno;
 }