xref: /netbsd-src/sys/arch/arm/include/frame.h (revision e65a0eaa66f2baacfbf4ae60f2f7b641eb98db8d)
1*e65a0eaaSskrll /*	$NetBSD: frame.h,v 1.23 2022/04/02 11:16:07 skrll Exp $	*/
22c89ce7eSbjh21 
32c89ce7eSbjh21 /*
42c89ce7eSbjh21  * Copyright (c) 1994-1997 Mark Brinicombe.
52c89ce7eSbjh21  * Copyright (c) 1994 Brini.
62c89ce7eSbjh21  * All rights reserved.
72c89ce7eSbjh21  *
82c89ce7eSbjh21  * This code is derived from software written for Brini by Mark Brinicombe
92c89ce7eSbjh21  *
102c89ce7eSbjh21  * Redistribution and use in source and binary forms, with or without
112c89ce7eSbjh21  * modification, are permitted provided that the following conditions
122c89ce7eSbjh21  * are met:
132c89ce7eSbjh21  * 1. Redistributions of source code must retain the above copyright
142c89ce7eSbjh21  *    notice, this list of conditions and the following disclaimer.
152c89ce7eSbjh21  * 2. Redistributions in binary form must reproduce the above copyright
162c89ce7eSbjh21  *    notice, this list of conditions and the following disclaimer in the
172c89ce7eSbjh21  *    documentation and/or other materials provided with the distribution.
182c89ce7eSbjh21  * 3. All advertising materials mentioning features or use of this software
192c89ce7eSbjh21  *    must display the following acknowledgement:
202c89ce7eSbjh21  *	This product includes software developed by Brini.
212c89ce7eSbjh21  * 4. The name of the company nor the name of the author may be used to
222c89ce7eSbjh21  *    endorse or promote products derived from this software without specific
232c89ce7eSbjh21  *    prior written permission.
242c89ce7eSbjh21  *
252c89ce7eSbjh21  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
262c89ce7eSbjh21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
272c89ce7eSbjh21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
282c89ce7eSbjh21  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
292c89ce7eSbjh21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
302c89ce7eSbjh21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
312c89ce7eSbjh21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
322c89ce7eSbjh21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
332c89ce7eSbjh21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
342c89ce7eSbjh21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
352c89ce7eSbjh21  * SUCH DAMAGE.
362c89ce7eSbjh21  */
372c89ce7eSbjh21 /*
38e0643849Sskrll  * arm/frame.h - Stack frames structures
392c89ce7eSbjh21  */
402c89ce7eSbjh21 
412c89ce7eSbjh21 #ifndef _ARM_FRAME_H_
422c89ce7eSbjh21 #define _ARM_FRAME_H_
432c89ce7eSbjh21 
442c89ce7eSbjh21 #ifndef _LOCORE
452c89ce7eSbjh21 
462c89ce7eSbjh21 #include <sys/signal.h>
4773ca5359Smatt #include <sys/ucontext.h>
482c89ce7eSbjh21 
492c89ce7eSbjh21 /*
508805bd8bSbjh21  * Trap frame.  Pushed onto the kernel stack on a trap (synchronous exception).
518805bd8bSbjh21  */
528805bd8bSbjh21 
538805bd8bSbjh21 typedef struct trapframe {
54e0643849Sskrll 	register_t tf_spsr;
5554ffa224Smatt 	register_t tf_fill; /* fill here so r0 will be dword aligned */
568805bd8bSbjh21 	register_t tf_r0;
578805bd8bSbjh21 	register_t tf_r1;
588805bd8bSbjh21 	register_t tf_r2;
598805bd8bSbjh21 	register_t tf_r3;
608805bd8bSbjh21 	register_t tf_r4;
618805bd8bSbjh21 	register_t tf_r5;
628805bd8bSbjh21 	register_t tf_r6;
638805bd8bSbjh21 	register_t tf_r7;
648805bd8bSbjh21 	register_t tf_r8;
658805bd8bSbjh21 	register_t tf_r9;
668805bd8bSbjh21 	register_t tf_r10;
678805bd8bSbjh21 	register_t tf_r11;
688805bd8bSbjh21 	register_t tf_r12;
698805bd8bSbjh21 	register_t tf_usr_sp;
708805bd8bSbjh21 	register_t tf_usr_lr;
71e0643849Sskrll 	register_t tf_svc_sp;
72e0643849Sskrll 	register_t tf_svc_lr;
738805bd8bSbjh21 	register_t tf_pc;
748805bd8bSbjh21 } trapframe_t;
758805bd8bSbjh21 
768805bd8bSbjh21 /* Register numbers */
77825088edSmatt #define tf_ip tf_r12
788805bd8bSbjh21 #define tf_r13 tf_usr_sp
798805bd8bSbjh21 #define tf_r14 tf_usr_lr
808805bd8bSbjh21 #define tf_r15 tf_pc
818805bd8bSbjh21 
82445ebaadSmatt #define TRAP_USERMODE(tf)	(((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
83445ebaadSmatt 
84*e65a0eaaSskrll #define FB_R4	0
85*e65a0eaaSskrll #define FB_R5	1
86*e65a0eaaSskrll #define FB_R6	2
87*e65a0eaaSskrll #define FB_R7	3
88*e65a0eaaSskrll #define FB_R8	4
89*e65a0eaaSskrll #define FB_R9	5
90*e65a0eaaSskrll #define FB_R10	6
91*e65a0eaaSskrll #define FB_R11	7
92*e65a0eaaSskrll #define FB_R12	8
93*e65a0eaaSskrll #define FB_R13	9
94*e65a0eaaSskrll #define FB_R14	10
95*e65a0eaaSskrll #define FB_MAX	11
96*e65a0eaaSskrll struct faultbuf {
97*e65a0eaaSskrll 	register_t fb_reg[FB_MAX];
98*e65a0eaaSskrll };
99*e65a0eaaSskrll 
1008805bd8bSbjh21 /*
1012c89ce7eSbjh21  * Signal frame.  Pushed onto user stack before calling sigcode.
1022c89ce7eSbjh21  */
10373ca5359Smatt #ifdef COMPAT_16
10473ca5359Smatt struct sigframe_sigcontext {
1052c89ce7eSbjh21 	struct	sigcontext sf_sc;
1062c89ce7eSbjh21 };
10773ca5359Smatt #endif
10873ca5359Smatt 
10973ca5359Smatt /* the pointers are use in the trampoline code to locate the ucontext */
11073ca5359Smatt struct sigframe_siginfo {
11173ca5359Smatt 	siginfo_t	sf_si;		/* actual saved siginfo */
11273ca5359Smatt 	ucontext_t	sf_uc;		/* actual saved ucontext */
11373ca5359Smatt };
1142c89ce7eSbjh21 
115320dbdd2Sskrll #if defined(_KERNEL) || defined(_KMEMUSER)
11673ca5359Smatt #ifdef _KERNEL
117afffbeb3Schristos __BEGIN_DECLS
11873ca5359Smatt void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
119afffbeb3Schristos void *getframe(struct lwp *, int, int *);
120afffbeb3Schristos __END_DECLS
121445ebaadSmatt #define lwp_settrapframe(l, tf)		((l)->l_md.md_tf = (tf))
12273ca5359Smatt #endif
123320dbdd2Sskrll #define lwp_trapframe(l)		((l)->l_md.md_tf)
124320dbdd2Sskrll #endif /* _KERNEL || _KMEMUSER */
12573ca5359Smatt 
126023bdd2bSsimonb #endif /* _LOCORE */
1272c89ce7eSbjh21 
1282c89ce7eSbjh21 #endif /* _ARM_FRAME_H_ */
1292c89ce7eSbjh21 
1302c89ce7eSbjh21 /* End of frame.h */
131