NetBSD/sys/arch/pc532/pc532/compat_13_machdep.c

112 lines
3.9 KiB
C

/* $NetBSD: compat_13_machdep.c,v 1.1 1998/09/17 02:01:59 thorpej Exp $ */
/*-
* Copyright (c) 1996 Matthias Pfaller.
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
* Copyright (c) 1993 Philip A. Nelson.
* Copyright (c) 1992 Terrence R. Lambert.
* Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)machdep.c 7.4 (Berkeley) 6/3/91
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/map.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
int
compat_13_sys_sigreturn(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct compat_13_sys_sigreturn_args /* {
syscallarg(struct sigcontext13 *) sigcntxp;
} */ *uap = v;
struct sigcontext13 *scp, context;
struct reg *regs;
sigset_t mask;
/*
* The trampoline code hands us the context.
* It is unsafe to keep track of it ourselves, in the event that a
* program jumps out of a signal handler.
*/
scp = SCARG(uap, sigcntxp);
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
return (EFAULT);
/* Restore the register context. */
regs = p->p_md.md_regs;
/*
* Check for security violations.
*/
if (((context.sc_ps ^ regs->r_psr) & PSL_USERSTATIC) != 0)
return (EINVAL);
regs->r_fp = context.sc_fp;
regs->r_sp = context.sc_sp;
regs->r_pc = context.sc_pc;
regs->r_psr = context.sc_ps;
regs->r_sb = context.sc_sb;
regs->r_r7 = context.sc_reg[REG_R7];
regs->r_r6 = context.sc_reg[REG_R6];
regs->r_r5 = context.sc_reg[REG_R5];
regs->r_r4 = context.sc_reg[REG_R4];
regs->r_r3 = context.sc_reg[REG_R3];
regs->r_r2 = context.sc_reg[REG_R2];
regs->r_r1 = context.sc_reg[REG_R1];
regs->r_r0 = context.sc_reg[REG_R0];
/* Restore signal stack. */
if (context.sc_onstack & SS_ONSTACK)
p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
else
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
/* Restore signal mask. */
native_sigset13_to_sigset(&context.sc_mask, &mask);
(void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
return(EJUSTRETURN);
}