Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / includes / lunaix / process.h
index 78756de7ab5f121a1c088e665dc6354ded813e23..92b9407c013bcb0d89e8319314a74aedee735fe4 100644 (file)
@@ -6,13 +6,13 @@
 #include <lunaix/fs.h>
 #include <lunaix/iopoll.h>
 #include <lunaix/mm/mm.h>
-#include <lunaix/mm/page.h>
+#include <lunaix/mm/pagetable.h>
 #include <lunaix/mm/region.h>
 #include <lunaix/signal.h>
 #include <lunaix/timer.h>
 #include <lunaix/types.h>
 #include <lunaix/spike.h>
-#include <lunaix/pcontext.h>
+#include <lunaix/hart_state.h>
 #include <stdint.h>
 
 
@@ -60,7 +60,7 @@ struct proc_sig
     int sig_num;
     void* sigact;
     void* sighand;
-    isr_param* saved_ictx;
+    struct hart_state* saved_hstate;
 } __attribute__((packed));
 
 
@@ -76,12 +76,12 @@ struct thread
 {
     /*
         Any change to *critical section*, including layout, size
-        must be reflected in arch/i386/interrupt.S.inc to avoid
+        must be reflected in arch/x86/interrupt.S.inc to avoid
         disaster!
      */
     struct
     {
-        isr_param* intr_ctx;
+        struct hart_state* hstate;
         ptr_t ustack_top;
     };                              // *critical section
 
@@ -133,7 +133,7 @@ struct proc_info
     };
 
     struct proc_mm* mm;
-    struct sigregister* sigreg;
+    struct sigregistry* sigreg;
     struct v_fdtable* fdtable;
     struct v_dnode* cwd;
     struct {
@@ -167,19 +167,26 @@ set_current_executing(struct thread* thread)
 static inline struct proc_mm* 
 vmspace(struct proc_info* proc) 
 {
-    return proc->mm;
+    return proc ? proc->mm : NULL;
 }
 
 static inline ptr_t
 vmroot(struct proc_info* proc) 
 {
-    return proc->mm->vmroot;
+    return proc ? proc->mm->vmroot : 0;
 }
 
 static inline vm_regions_t* 
 vmregions(struct proc_info* proc) 
 {
-    return &proc->mm->regions;
+    return proc ? &proc->mm->regions : NULL;
+}
+
+
+static inline unsigned int
+procvm_asid(struct proc_mm* mm)
+{
+    return mm->proc->pid;
 }
 
 static inline void
@@ -302,7 +309,7 @@ struct thread*
 alloc_thread(struct proc_info* process);
 
 void
-destory_thread(ptr_t vm_mnt, struct thread* thread);
+destory_thread(struct thread* thread);
 
 void
 terminate_thread(struct thread* thread, ptr_t val);
@@ -311,26 +318,26 @@ void
 terminate_current_thread(ptr_t val);
 
 struct thread*
-create_thread(struct proc_info* proc, ptr_t vm_mnt, bool with_ustack);
+create_thread(struct proc_info* proc, bool with_ustack);
 
 void
-start_thread(struct thread* th, ptr_t vm_mnt, ptr_t entry);
+start_thread(struct thread* th, ptr_t entry);
 
 static inline void
 spawn_kthread(ptr_t entry) {
     assert(kernel_process(__current));
 
-    struct thread* th = create_thread(__current, VMS_SELF, false);
+    struct thread* th = create_thread(__current, false);
     
     assert(th);
-    start_thread(th, VMS_SELF, entry);
+    start_thread(th, entry);
 }
 
 void 
 exit_thread(void* val);
 
 void
-thread_release_mem(struct thread* thread, ptr_t vm_mnt);
+thread_release_mem(struct thread* thread);
 
 /* 
     ========= Signal =========
@@ -344,7 +351,7 @@ thread_release_mem(struct thread* thread, ptr_t vm_mnt);
 static inline struct sigact*
 active_signal(struct thread* thread) {
     struct sigctx* sigctx = &thread->sigctx;
-    struct sigregister* sigreg = thread->process->sigreg;
+    struct sigregistry* sigreg = thread->process->sigreg;
     return sigreg->signals[sigctx->sig_active];
 }