diff --git a/sys/arch/sparc64/include/userret.h b/sys/arch/sparc64/include/userret.h new file mode 100644 index 000000000000..29bf53ecef93 --- /dev/null +++ b/sys/arch/sparc64/include/userret.h @@ -0,0 +1,98 @@ +/* $NetBSD: userret.h,v 1.1 2005/07/10 01:58:57 christos Exp $ */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. + * Copyright (c) 1996 + * The President and Fellows of Harvard College. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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, Lawrence Berkeley Laboratory. + * This product includes software developed by Harvard University. + * + * 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. + * This product includes software developed by Harvard University. + * 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. + * + * @(#)trap.c 8.4 (Berkeley) 9/23/93 + */ + +#include + +static __inline void userret __P((struct lwp *, int, u_quad_t)); +/* + * Define the code needed before returning to user mode, for + * trap, mem_access_fault, and syscall. + */ +static __inline void +userret(struct lwp *l, int pc, u_quad_t oticks) +{ + struct proc *p = l->l_proc; + + mi_userret(l); + + if (want_ast) { + want_ast = 0; + if (p->p_flag & P_OWEUPC) { + p->p_flag &= ~P_OWEUPC; + ADDUPROF(p); + } + } + + /* + * If profiling, charge recent system time to the trapped pc. + */ + if (p->p_flag & P_PROFIL) + addupc_task(p, pc, (int)(p->p_sticks - oticks)); + + curcpu()->ci_schedstate.spc_curpriority = l->l_priority = l->l_usrpri; +} + +static __inline void share_fpu __P((struct lwp *, struct trapframe64 *)); +/* + * If someone stole the FPU while we were away, do not enable it + * on return. This is not done in userret() above as it must follow + * the ktrsysret() in syscall(). Actually, it is likely that the + * ktrsysret should occur before the call to userret. + * + * Oh, and don't touch the FPU bit if we're returning to the kernel. + */ +static __inline void +share_fpu(struct lwp *l, struct trapframe64 *tf) +{ + if (!(tf->tf_tstate & (PSTATE_PRIV << TSTATE_PSTATE_SHIFT)) && + fplwp != l) + tf->tf_tstate &= ~(PSTATE_PEF << TSTATE_PSTATE_SHIFT); +}