taskfs fix up, minor refactoring
[lunaix-os.git] / lunaix-os / kernel / process / process.c
index 91fe240860211153d3b6b8d3d31e86803b8ee46f..bb5008df3dee688bf1de4d6c0a9eea511b18db02 100644 (file)
@@ -12,8 +12,8 @@
 #include <lunaix/exec.h>
 #include <lunaix/fs.h>
 
-#include <sys/abi.h>
-#include <sys/mm/mm_defs.h>
+#include <asm/abi.h>
+#include <asm/mm_defs.h>
 
 LOG_MODULE("PROC")
 
@@ -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;
 }