slight tuning of /etc/mk situation when making release.
[minix.git] / kernel / system / do_sigreturn.c
bloba0c751d6e0066dd4e4775ac8a2c4d27d81340ac8
1 /* The kernel call that is implemented in this file:
2 * m_type: SYS_SIGRETURN
4 * The parameters for this kernel call are:
5 * m2_i1: SIG_ENDPT # process returning from handler
6 * m2_p1: SIG_CTXT_PTR # pointer to sigcontext structure
8 */
10 #include "../system.h"
11 #include <string.h>
12 #include <ibm/cpu.h>
13 #include <sys/sigcontext.h>
15 #if USE_SIGRETURN
17 /*===========================================================================*
18 * do_sigreturn *
19 *===========================================================================*/
20 PUBLIC int do_sigreturn(struct proc * caller, message * m_ptr)
22 /* POSIX style signals require sys_sigreturn to put things in order before
23 * the signalled process can resume execution
25 struct sigcontext sc;
26 register struct proc *rp;
27 int proc_nr, r;
29 if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL);
30 if (iskerneln(proc_nr)) return(EPERM);
31 rp = proc_addr(proc_nr);
33 /* Copy in the sigcontext structure. */
34 if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR,
35 KERNEL, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
36 return r;
38 /* Restore user bits of psw from sc, maintain system bits from proc. */
39 sc.sc_psw = (sc.sc_psw & X86_FLAGS_USER) |
40 (rp->p_reg.psw & ~X86_FLAGS_USER);
42 #if (_MINIX_CHIP == _CHIP_INTEL)
43 /* Don't panic kernel if user gave bad selectors. */
44 sc.sc_cs = rp->p_reg.cs;
45 sc.sc_ds = rp->p_reg.ds;
46 sc.sc_es = rp->p_reg.es;
47 sc.sc_ss = rp->p_reg.ss;
48 #if _WORD_SIZE == 4
49 sc.sc_fs = rp->p_reg.fs;
50 sc.sc_gs = rp->p_reg.gs;
51 #endif
52 #endif
54 /* Restore the registers. */
55 memcpy(&rp->p_reg, &sc.sc_regs, sizeof(sigregs));
56 #if (_MINIX_CHIP == _CHIP_INTEL)
57 if(sc.sc_flags & MF_FPU_INITIALIZED)
59 memcpy(rp->p_fpu_state.fpu_save_area_p, &sc.sc_fpu_state,
60 FPU_XFP_SIZE);
61 rp->p_misc_flags |= MF_FPU_INITIALIZED; /* Restore math usage flag. */
63 #endif
65 return(OK);
67 #endif /* USE_SIGRETURN */