xref: /netbsd-src/sys/arch/sh3/include/userret.h (revision cbd452c1eaab9d6c5bc8642cb7ad2b7643666552)
1*cbd452c1Sskrll /*	$NetBSD: userret.h,v 1.18 2020/01/07 07:41:20 skrll Exp $	*/
210807995Such 
310807995Such /*
49b6bd2d9Srmind  * Copyright (c) 1988 University of Utah.
510807995Such  * Copyright (c) 1992, 1993
610807995Such  *	The Regents of the University of California.  All rights reserved.
710807995Such  *
810807995Such  * This code is derived from software contributed to Berkeley by
910807995Such  * the Systems Programming Group of the University of Utah Computer
1010807995Such  * Science Department and Ralph Campbell.
1110807995Such  *
1210807995Such  * Redistribution and use in source and binary forms, with or without
1310807995Such  * modification, are permitted provided that the following conditions
1410807995Such  * are met:
1510807995Such  * 1. Redistributions of source code must retain the above copyright
1610807995Such  *    notice, this list of conditions and the following disclaimer.
1710807995Such  * 2. Redistributions in binary form must reproduce the above copyright
1810807995Such  *    notice, this list of conditions and the following disclaimer in the
1910807995Such  *    documentation and/or other materials provided with the distribution.
20aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
21aad01611Sagc  *    may be used to endorse or promote products derived from this software
22aad01611Sagc  *    without specific prior written permission.
23aad01611Sagc  *
24aad01611Sagc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25aad01611Sagc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26aad01611Sagc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27aad01611Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28aad01611Sagc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29aad01611Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30aad01611Sagc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31aad01611Sagc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32aad01611Sagc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33aad01611Sagc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34aad01611Sagc  * SUCH DAMAGE.
35aad01611Sagc  *
36aad01611Sagc  * from: Utah Hdr: trap.c 1.32 91/04/06
37aad01611Sagc  *
38aad01611Sagc  *	@(#)trap.c	8.5 (Berkeley) 1/11/94
39aad01611Sagc  */
4010807995Such 
4110807995Such #ifndef _SH3_USERRET_H_
4210807995Such #define	_SH3_USERRET_H_
4310807995Such 
44ef56cc40Scl #include <sys/userret.h>
45ef56cc40Scl 
464826f91fSuwe #include <sh3/ubcreg.h>
474826f91fSuwe #include "opt_ptrace.h"
484826f91fSuwe 
494826f91fSuwe 
50fbae48b9Sperry static __inline void
userret(struct lwp * l)5149784e4bSthorpej userret(struct lwp *l)
5210807995Such {
5310807995Such 
54106905eaSad 	/* This must come first... */
55106905eaSad 	l->l_md.md_astpending = 0;
56106905eaSad 
57106905eaSad 	if (l->l_pflag & LP_OWEUPC) {
58106905eaSad 		l->l_pflag &= ~LP_OWEUPC;
59106905eaSad 		ADDUPROF(l);
60106905eaSad 	}
61106905eaSad 
62ef56cc40Scl 	/* Invoke MI userret code */
63ef56cc40Scl 	mi_userret(l);
644826f91fSuwe 
65a60b9909Spgoyette #ifdef PTRACE_HOOKS
664826f91fSuwe 	/* Check if lwp is being PT_STEP'ed */
67d2228640Sdsl 	if (l->l_md.md_flags & MDL_SSTEP) {
684826f91fSuwe 		struct trapframe *tf = l->l_md.md_regs;
694826f91fSuwe 
704826f91fSuwe 		/*
714826f91fSuwe 		 * Channel A is set up for single stepping in sh_cpu_init().
724826f91fSuwe 		 * Before RTE we write tf_ubc to BBRA and tf_spc to BARA.
734826f91fSuwe 		 */
744826f91fSuwe #ifdef SH3
754826f91fSuwe 		if (CPU_IS_SH3) {
764826f91fSuwe 			tf->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ
774826f91fSuwe 				| SH3_UBC_CYCLE_CPU;
784826f91fSuwe 		}
794826f91fSuwe #endif
804826f91fSuwe #ifdef SH4
814826f91fSuwe 		if (CPU_IS_SH4) {
824826f91fSuwe 			tf->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ;
834826f91fSuwe 		}
844826f91fSuwe #endif
854826f91fSuwe 	}
86a60b9909Spgoyette #endif /* PTRACE_HOOKS */
8710807995Such }
8810807995Such 
8910807995Such #endif /* !_SH3_USERRET_H_ */
90