xref: /minix3/sys/arch/arm/include/frame.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: frame.h,v 1.18 2013/08/18 05:07:19 matt Exp $	*/
202222606SBen Gras 
302222606SBen Gras /*
402222606SBen Gras  * Copyright (c) 1994-1997 Mark Brinicombe.
502222606SBen Gras  * Copyright (c) 1994 Brini.
602222606SBen Gras  * All rights reserved.
702222606SBen Gras  *
802222606SBen Gras  * This code is derived from software written for Brini by Mark Brinicombe
902222606SBen Gras  *
1002222606SBen Gras  * Redistribution and use in source and binary forms, with or without
1102222606SBen Gras  * modification, are permitted provided that the following conditions
1202222606SBen Gras  * are met:
1302222606SBen Gras  * 1. Redistributions of source code must retain the above copyright
1402222606SBen Gras  *    notice, this list of conditions and the following disclaimer.
1502222606SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
1602222606SBen Gras  *    notice, this list of conditions and the following disclaimer in the
1702222606SBen Gras  *    documentation and/or other materials provided with the distribution.
1802222606SBen Gras  * 3. All advertising materials mentioning features or use of this software
1902222606SBen Gras  *    must display the following acknowledgement:
2002222606SBen Gras  *	This product includes software developed by Brini.
2102222606SBen Gras  * 4. The name of the company nor the name of the author may be used to
2202222606SBen Gras  *    endorse or promote products derived from this software without specific
2302222606SBen Gras  *    prior written permission.
2402222606SBen Gras  *
2502222606SBen Gras  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
2602222606SBen Gras  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2702222606SBen Gras  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2802222606SBen Gras  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
2902222606SBen Gras  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3002222606SBen Gras  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3102222606SBen Gras  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3202222606SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3302222606SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3402222606SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3502222606SBen Gras  * SUCH DAMAGE.
3602222606SBen Gras  */
3702222606SBen Gras /*
3802222606SBen Gras  * arm/frame.h - Stack frames structures common to arm26 and arm32
3902222606SBen Gras  */
4002222606SBen Gras 
4102222606SBen Gras #ifndef _ARM_FRAME_H_
4202222606SBen Gras #define _ARM_FRAME_H_
4302222606SBen Gras 
4402222606SBen Gras #ifndef _LOCORE
4502222606SBen Gras 
4602222606SBen Gras #include <sys/signal.h>
4702222606SBen Gras #include <sys/ucontext.h>
4802222606SBen Gras 
4902222606SBen Gras /*
5002222606SBen Gras  * Trap frame.  Pushed onto the kernel stack on a trap (synchronous exception).
5102222606SBen Gras  */
5202222606SBen Gras 
5302222606SBen Gras typedef struct trapframe {
5402222606SBen Gras 	register_t tf_spsr; /* Zero on arm26 */
55*84d9c625SLionel Sambuc 	register_t tf_fill; /* fill here so r0 will be dword aligned */
5602222606SBen Gras 	register_t tf_r0;
5702222606SBen Gras 	register_t tf_r1;
5802222606SBen Gras 	register_t tf_r2;
5902222606SBen Gras 	register_t tf_r3;
6002222606SBen Gras 	register_t tf_r4;
6102222606SBen Gras 	register_t tf_r5;
6202222606SBen Gras 	register_t tf_r6;
6302222606SBen Gras 	register_t tf_r7;
6402222606SBen Gras 	register_t tf_r8;
6502222606SBen Gras 	register_t tf_r9;
6602222606SBen Gras 	register_t tf_r10;
6702222606SBen Gras 	register_t tf_r11;
6802222606SBen Gras 	register_t tf_r12;
6902222606SBen Gras 	register_t tf_usr_sp;
7002222606SBen Gras 	register_t tf_usr_lr;
7102222606SBen Gras 	register_t tf_svc_sp; /* Not used on arm26 */
7202222606SBen Gras 	register_t tf_svc_lr; /* Not used on arm26 */
7302222606SBen Gras 	register_t tf_pc;
7402222606SBen Gras } trapframe_t;
7502222606SBen Gras 
7602222606SBen Gras /* Register numbers */
7702222606SBen Gras #define tf_ip tf_r12
7802222606SBen Gras #define tf_r13 tf_usr_sp
7902222606SBen Gras #define tf_r14 tf_usr_lr
8002222606SBen Gras #define tf_r15 tf_pc
8102222606SBen Gras 
8202222606SBen Gras #ifdef __PROG32
8302222606SBen Gras #define TRAP_USERMODE(tf)	(((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
8402222606SBen Gras #elif defined(__PROG26)
8502222606SBen Gras #define TRAP_USERMODE(tf)	(((tf)->tf_r15 & R15_MODE) == R15_MODE_USR)
8602222606SBen Gras #endif
8702222606SBen Gras 
8802222606SBen Gras /*
8902222606SBen Gras  * Signal frame.  Pushed onto user stack before calling sigcode.
9002222606SBen Gras  */
917597f4a8SBen Gras #if defined(COMPAT_16) || defined(__minix)
9202222606SBen Gras struct sigframe_sigcontext {
93*84d9c625SLionel Sambuc #if defined(__minix)
947597f4a8SBen Gras 	struct	sigcontext *sf_scp;	/* Let sigreturn find sigcontext */
95*84d9c625SLionel Sambuc #endif /* defined(__minix) */
9602222606SBen Gras 	struct	sigcontext sf_sc;
9702222606SBen Gras };
9802222606SBen Gras #endif
9902222606SBen Gras 
10002222606SBen Gras /* the pointers are use in the trampoline code to locate the ucontext */
10102222606SBen Gras struct sigframe_siginfo {
10202222606SBen Gras 	siginfo_t	sf_si;		/* actual saved siginfo */
10302222606SBen Gras 	ucontext_t	sf_uc;		/* actual saved ucontext */
10402222606SBen Gras };
10502222606SBen Gras 
10602222606SBen Gras #ifdef _KERNEL
10702222606SBen Gras __BEGIN_DECLS
10802222606SBen Gras void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
10902222606SBen Gras void *getframe(struct lwp *, int, int *);
11002222606SBen Gras __END_DECLS
11102222606SBen Gras #define lwp_trapframe(l)		((l)->l_md.md_tf)
11202222606SBen Gras #define lwp_settrapframe(l, tf)		((l)->l_md.md_tf = (tf))
11302222606SBen Gras #endif
11402222606SBen Gras 
11502222606SBen Gras #endif /* _LOCORE */
11602222606SBen Gras 
11702222606SBen Gras #endif /* _ARM_FRAME_H_ */
11802222606SBen Gras 
11902222606SBen Gras /* End of frame.h */
120