userret.h revision 1.2
11.2Sthorpej/* $NetBSD: userret.h,v 1.2 2003/01/17 22:11:17 thorpej Exp $ */
21.1Sthorpej
31.1Sthorpej/*-
41.1Sthorpej * Copyright (c) 2000 The NetBSD Foundation, Inc.
51.1Sthorpej * All rights reserved.
61.1Sthorpej *
71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation
81.1Sthorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
91.1Sthorpej * NASA Ames Research Center, and by Charles M. Hannum.
101.1Sthorpej *
111.1Sthorpej * Redistribution and use in source and binary forms, with or without
121.1Sthorpej * modification, are permitted provided that the following conditions
131.1Sthorpej * are met:
141.1Sthorpej * 1. Redistributions of source code must retain the above copyright
151.1Sthorpej *    notice, this list of conditions and the following disclaimer.
161.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
171.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
181.1Sthorpej *    documentation and/or other materials provided with the distribution.
191.1Sthorpej * 3. All advertising materials mentioning features or use of this software
201.1Sthorpej *    must display the following acknowledgement:
211.1Sthorpej *	This product includes software developed by the NetBSD
221.1Sthorpej *	Foundation, Inc. and its contributors.
231.1Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
241.1Sthorpej *    contributors may be used to endorse or promote products derived
251.1Sthorpej *    from this software without specific prior written permission.
261.1Sthorpej *
271.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
281.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
291.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
301.1Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
311.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
321.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
331.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
341.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
351.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
361.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
371.1Sthorpej * POSSIBILITY OF SUCH DAMAGE.
381.1Sthorpej */
391.1Sthorpej
401.1Sthorpej/*
411.1Sthorpej * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
421.1Sthorpej *
431.1Sthorpej * Redistribution and use in source and binary forms, with or without
441.1Sthorpej * modification, are permitted provided that the following conditions
451.1Sthorpej * are met:
461.1Sthorpej * 1. Redistributions of source code must retain the above copyright
471.1Sthorpej *    notice, this list of conditions and the following disclaimer.
481.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
491.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
501.1Sthorpej *    documentation and/or other materials provided with the distribution.
511.1Sthorpej * 3. All advertising materials mentioning features or use of this software
521.1Sthorpej *    must display the following acknowledgement:
531.1Sthorpej *      This product includes software developed by Christopher G. Demetriou
541.1Sthorpej *	for the NetBSD Project.
551.1Sthorpej * 4. The name of the author may not be used to endorse or promote products
561.1Sthorpej *    derived from this software without specific prior written permission
571.1Sthorpej *
581.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
591.1Sthorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
601.1Sthorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
611.1Sthorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
621.1Sthorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
631.1Sthorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
641.1Sthorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
651.1Sthorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
661.1Sthorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
671.1Sthorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
681.1Sthorpej */
691.1Sthorpej
701.1Sthorpej/*
711.1Sthorpej * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
721.1Sthorpej * All rights reserved.
731.1Sthorpej *
741.1Sthorpej * Author: Chris G. Demetriou
751.1Sthorpej *
761.1Sthorpej * Permission to use, copy, modify and distribute this software and
771.1Sthorpej * its documentation is hereby granted, provided that both the copyright
781.1Sthorpej * notice and this permission notice appear in all copies of the
791.1Sthorpej * software, derivative works or modified versions, and any portions
801.1Sthorpej * thereof, and that both notices appear in supporting documentation.
811.1Sthorpej *
821.1Sthorpej * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
831.1Sthorpej * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
841.1Sthorpej * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
851.1Sthorpej *
861.1Sthorpej * Carnegie Mellon requests users of this software to return to
871.1Sthorpej *
881.1Sthorpej *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
891.1Sthorpej *  School of Computer Science
901.1Sthorpej *  Carnegie Mellon University
911.1Sthorpej *  Pittsburgh PA 15213-3890
921.1Sthorpej *
931.1Sthorpej * any improvements or extensions that they make and grant Carnegie the
941.1Sthorpej * rights to redistribute these changes.
951.1Sthorpej */
961.1Sthorpej
971.1Sthorpej#ifndef _ALPHA_USERRET_H_
981.1Sthorpej#define	_ALPHA_USERRET_H_
991.1Sthorpej
1001.1Sthorpej/*
1011.1Sthorpej * Define the code needed before returning to user mode, for
1021.1Sthorpej * trap and syscall.
1031.1Sthorpej */
1041.1Sthorpejstatic __inline void
1051.2Sthorpejuserret(struct lwp *l)
1061.1Sthorpej{
1071.1Sthorpej	int sig;
1081.2Sthorpej	struct proc *p = l->l_proc;
1091.1Sthorpej
1101.1Sthorpej	/* Do any deferred user pmap operations. */
1111.1Sthorpej	PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
1121.1Sthorpej
1131.1Sthorpej	/* take pending signals */
1141.2Sthorpej	while ((sig = CURSIG(l)) != 0)
1151.1Sthorpej		postsig(sig);
1161.1Sthorpej
1171.2Sthorpej	/* Invoke per-process kernel-exit handling, if any */
1181.2Sthorpej	if (p->p_userret)
1191.2Sthorpej		(p->p_userret)(l, p->p_userret_arg);
1201.2Sthorpej
1211.2Sthorpej	/* Invoke any pending upcalls. */
1221.2Sthorpej	while (l->l_flag & L_SA_UPCALL)
1231.2Sthorpej		sa_upcall_userret(l);
1241.2Sthorpej
1251.2Sthorpej	curcpu()->ci_schedstate.spc_curpriority = l->l_priority = l->l_usrpri;
1261.1Sthorpej}
1271.1Sthorpej
1281.1Sthorpej#endif /* _ALPHA_USERRET_H_ */
129