1 /* The kernel call that is implemented in this file:
2 * m_type: SYS_SIGRETURN
3 *
4 * The parameters for this kernel call are:
5 * m2_i1: SIG_PROC # process returning from handler
6 * m2_p1: SIG_CTXT_PTR # pointer to sigcontext structure
7 *
8 */
9
10 #include "../system.h"
11 #include <string.h>
12 #include <signal.h>
13 #include <sys/sigcontext.h>
14
15 #if USE_SIGRETURN
16
17 /*===========================================================================*
18 * do_sigreturn *
19 *===========================================================================*/
20 PUBLIC int do_sigreturn(m_ptr)
21 message *m_ptr; /* pointer to request message */
22 {
23 /* POSIX style signals require sys_sigreturn to put things in order before
24 * the signalled process can resume execution
25 */
26 struct sigcontext sc;
27 register struct proc *rp;
28 phys_bytes src_phys;
29
30 if (! isokprocn(m_ptr->SIG_PROC)) return(EINVAL);
31 if (iskerneln(m_ptr->SIG_PROC)) return(EPERM);
32 rp = proc_addr(m_ptr->SIG_PROC);
33
34 /* Copy in the sigcontext structure. */
35 src_phys = umap_local(rp, D, (vir_bytes) m_ptr->SIG_CTXT_PTR,
36 (vir_bytes) sizeof(struct sigcontext));
37 if (src_phys == 0) return(EFAULT);
38 phys_copy(src_phys, vir2phys(&sc), (phys_bytes) sizeof(struct sigcontext));
39
40 /* Make sure that this is not just a jump buffer. */
41 if ((sc.sc_flags & SC_SIGCONTEXT) == 0) return(EINVAL);
42
43 /* Fix up only certain key registers if the compiler doesn't use
44 * register variables within functions containing setjmp.
45 */
46 if (sc.sc_flags & SC_NOREGLOCALS) {
47 rp->p_reg.retreg = sc.sc_retreg;
48 rp->p_reg.fp = sc.sc_fp;
49 rp->p_reg.pc = sc.sc_pc;
50 rp->p_reg.sp = sc.sc_sp;
51 return(OK);
52 }
53 sc.sc_psw = rp->p_reg.psw;
54
55 #if (CHIP == INTEL)
56 /* Don't panic kernel if user gave bad selectors. */
57 sc.sc_cs = rp->p_reg.cs;
58 sc.sc_ds = rp->p_reg.ds;
59 sc.sc_es = rp->p_reg.es;
60 #if _WORD_SIZE == 4
61 sc.sc_fs = rp->p_reg.fs;
62 sc.sc_gs = rp->p_reg.gs;
63 #endif
64 #endif
65
66 /* Restore the registers. */
67 memcpy(&rp->p_reg, &sc.sc_regs, sizeof(struct sigregs));
68 return(OK);
69 }
70 #endif /* USE_SIGRETURN */
71
Cache object: 883ab15e4e21d3891226ee00dbebb9e3
|