[9] | 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_ENDPT # 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 | int proc;
|
---|
| 30 |
|
---|
| 31 | if (! isokendpt(m_ptr->SIG_ENDPT, &proc)) return(EINVAL);
|
---|
| 32 | if (iskerneln(proc)) return(EPERM);
|
---|
| 33 | rp = proc_addr(proc);
|
---|
| 34 |
|
---|
| 35 | /* Copy in the sigcontext structure. */
|
---|
| 36 | src_phys = umap_local(rp, D, (vir_bytes) m_ptr->SIG_CTXT_PTR,
|
---|
| 37 | (vir_bytes) sizeof(struct sigcontext));
|
---|
| 38 | if (src_phys == 0) return(EFAULT);
|
---|
| 39 | phys_copy(src_phys, vir2phys(&sc), (phys_bytes) sizeof(struct sigcontext));
|
---|
| 40 |
|
---|
| 41 | /* Make sure that this is not just a jump buffer. */
|
---|
| 42 | if ((sc.sc_flags & SC_SIGCONTEXT) == 0) return(EINVAL);
|
---|
| 43 |
|
---|
| 44 | /* Fix up only certain key registers if the compiler doesn't use
|
---|
| 45 | * register variables within functions containing setjmp.
|
---|
| 46 | */
|
---|
| 47 | if (sc.sc_flags & SC_NOREGLOCALS) {
|
---|
| 48 | rp->p_reg.retreg = sc.sc_retreg;
|
---|
| 49 | rp->p_reg.fp = sc.sc_fp;
|
---|
| 50 | rp->p_reg.pc = sc.sc_pc;
|
---|
| 51 | rp->p_reg.sp = sc.sc_sp;
|
---|
| 52 | return(OK);
|
---|
| 53 | }
|
---|
| 54 | sc.sc_psw = rp->p_reg.psw;
|
---|
| 55 |
|
---|
| 56 | #if (CHIP == INTEL)
|
---|
| 57 | /* Don't panic kernel if user gave bad selectors. */
|
---|
| 58 | sc.sc_cs = rp->p_reg.cs;
|
---|
| 59 | sc.sc_ds = rp->p_reg.ds;
|
---|
| 60 | sc.sc_es = rp->p_reg.es;
|
---|
| 61 | #if _WORD_SIZE == 4
|
---|
| 62 | sc.sc_fs = rp->p_reg.fs;
|
---|
| 63 | sc.sc_gs = rp->p_reg.gs;
|
---|
| 64 | #endif
|
---|
| 65 | #endif
|
---|
| 66 |
|
---|
| 67 | /* Restore the registers. */
|
---|
| 68 | memcpy(&rp->p_reg, &sc.sc_regs, sizeof(struct sigregs));
|
---|
| 69 | return(OK);
|
---|
| 70 | }
|
---|
| 71 | #endif /* USE_SIGRETURN */
|
---|
| 72 |
|
---|