refactor: one more step towards arch-agnostic design
[lunaix-os.git] / lunaix-os / includes / lunaix / process.h
index 7d385a472d899283bb2773cc581513245df4df1e..6ef1ff0eed297e13f557963a638ff9c9a44e0449 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __LUNAIX_PROCESS_H
 #define __LUNAIX_PROCESS_H
 
-#include <arch/x86/interrupts.h>
 #include <lunaix/clock.h>
 #include <lunaix/ds/waitq.h>
 #include <lunaix/fs.h>
@@ -11,6 +10,7 @@
 #include <lunaix/timer.h>
 #include <lunaix/types.h>
 #include <stdint.h>
+#include <sys/interrupts.h>
 
 // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
 #define KERNEL_PID -1
@@ -45,8 +45,6 @@
 #define proc_hanged(proc) (((proc)->state) & PS_BLOCKED)
 #define proc_runnable(proc) (((proc)->state) & PS_PAUSED)
 
-#define PROC_FINPAUSE 1
-
 struct sigact
 {
     struct sigact* prev;
@@ -76,17 +74,17 @@ struct proc_info
 {
     /*
         Any change to *critical section*, including layout, size
-        must be reflected in kernel/asm/x86/interrupt.S to avoid
+        must be reflected in arch/i386/interrupt.S.inc to avoid
         disaster!
      */
 
     /* ---- critical section start ---- */
 
-    pid_t pid;                // offset = 0
-    struct proc_info* parent; // offset = 4
-    isr_param* intr_ctx;      // offset = 8
-    ptr_t ustack_top;         // offset = 84 -> 56 -> 60 -> 12
-    ptr_t page_table;         // offset = 88 -> 60 -> 64 -> 16
+    pid_t pid;
+    struct proc_info* parent;
+    isr_param* intr_ctx;
+    ptr_t ustack_top;
+    ptr_t page_table;
 
     /* ---- critical section end ---- */
 
@@ -108,7 +106,6 @@ struct proc_info
     u8_t state;
     int32_t exit_code;
     int32_t k_status;
-    int flags;
     struct sighail sigctx;
     struct v_fdtable* fdtable;
     struct v_dnode* cwd;
@@ -195,4 +192,13 @@ get_process(pid_t pid);
 void
 proc_setsignal(struct proc_info* proc, int signum);
 
+void
+proc_clear_signal(struct proc_info* proc);
+
+// enable interrupt upon transfer
+#define TRANSFER_IE 1
+
+void
+proc_init_transfer(struct proc_info* proc, ptr_t stop, ptr_t target, int flags);
+
 #endif /* __LUNAIX_PROCESS_H */