00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "../system.h"
00011 #include <string.h>
00012 #include <ibm/cpu.h>
00013 #include <sys/sigcontext.h>
00014
00015 #if USE_SIGRETURN
00016
00017
00018
00019
00020 PUBLIC int do_sigreturn(m_ptr)
00021 message *m_ptr;
00022 {
00023
00024
00025
00026 struct sigcontext sc;
00027 register struct proc *rp;
00028 int proc_nr, r;
00029
00030 if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL);
00031 if (iskerneln(proc_nr)) return(EPERM);
00032 rp = proc_addr(proc_nr);
00033
00034
00035 if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR,
00036 SYSTEM, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
00037 return r;
00038
00039
00040 sc.sc_psw = (sc.sc_psw & X86_FLAGS_USER) |
00041 (rp->p_reg.psw & ~X86_FLAGS_USER);
00042
00043 #if (_MINIX_CHIP == _CHIP_INTEL)
00044
00045 sc.sc_cs = rp->p_reg.cs;
00046 sc.sc_ds = rp->p_reg.ds;
00047 sc.sc_es = rp->p_reg.es;
00048 sc.sc_ss = rp->p_reg.ss;
00049 #if _WORD_SIZE == 4
00050 sc.sc_fs = rp->p_reg.fs;
00051 sc.sc_gs = rp->p_reg.gs;
00052 #endif
00053 #endif
00054
00055
00056 memcpy(&rp->p_reg, &sc.sc_regs, sizeof(sigregs));
00057 #if (_MINIX_CHIP == _CHIP_INTEL)
00058 if(sc.sc_flags & MF_FPU_INITIALIZED)
00059 {
00060 memcpy(rp->p_fpu_state.fpu_save_area_p, &sc.sc_fpu_state,
00061 FPU_XFP_SIZE);
00062 rp->p_misc_flags |= MF_FPU_INITIALIZED;
00063 }
00064 #endif
00065
00066 return(OK);
00067 }
00068 #endif
00069