Merge branch 'master' into prog-loader
[lunaix-os.git] / lunaix-os / kernel / process / signal.c
index 5f0c868789d9af36d6286dfae989b9a385e28546..0f43b1f65216adc7d1dfadae52f365318b40248e 100644 (file)
@@ -1,5 +1,3 @@
-#include <lunaix/lunistd.h>
-#include <lunaix/lxsignal.h>
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
 #include <lunaix/signal.h>
@@ -7,6 +5,8 @@
 #include <lunaix/status.h>
 #include <lunaix/syscall.h>
 
+#include <klibc/string.h>
+
 extern struct scheduler sched_ctx; /* kernel/sched.c */
 
 void __USER__
@@ -22,7 +22,7 @@ void* default_handlers[_SIG_NUM] = {
     [_SIGINT] = default_sighandler_term,
 };
 
-volatile isr_param __temp_save;
+volatile struct proc_sigstate __temp_save;
 // Referenced in kernel/asm/x86/interrupt.S
 void*
 signal_dispatch()
@@ -79,7 +79,9 @@ signal_dispatch()
 
         解决办法就是先吧intr_ctx拷贝到一个静态分配的区域里,然后再注入到用户栈。
     */
-    __temp_save = __current->intr_ctx;
+    __temp_save.proc_regs = __current->intr_ctx;
+    memcpy(__temp_save.fxstate, __current->fxstate, 512);
+
     sig_ctx->prev_context = __temp_save;
 
     sig_ctx->sig_num = sig_selected;
@@ -126,7 +128,6 @@ send_grp:
     {
         __SIGSET(pos->sig_pending, signum);
     }
-    return 0;
 
 send_single:
     if (PROC_TERMINATED(proc->state)) {
@@ -139,7 +140,8 @@ send_single:
 
 __DEFINE_LXSYSCALL1(int, sigreturn, struct proc_sig, *sig_ctx)
 {
-    __current->intr_ctx = sig_ctx->prev_context;
+    memcpy(__current->fxstate, sig_ctx->prev_context.fxstate, 512);
+    __current->intr_ctx = sig_ctx->prev_context.proc_regs;
     __current->flags &= ~PROC_FINPAUSE;
     __SIGCLEAR(__current->sig_inprogress, sig_ctx->sig_num);
     schedule();