xref: /netbsd-src/sys/compat/linux/arch/m68k/linux_machdep.h (revision aaf4ece63a859a04e37cf3a7229b5fab0157cc06)
1 /*	$NetBSD: linux_machdep.h,v 1.5 2005/11/11 23:22:08 chs Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by ITOH Yasufumi.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _M68K_LINUX_MACHDEP_H
40 #define _M68K_LINUX_MACHDEP_H
41 
42 #include <m68k/frame.h>
43 #include <compat/linux/common/linux_types.h>
44 #include <compat/linux/common/linux_signal.h>
45 #include <compat/linux/common/linux_siginfo.h>
46 
47 /*
48  * Signal stack definitions for old signal interface.
49  */
50 
51 struct linux_sigcontext {
52 	linux_old_sigset_t	sc_mask;	/* signal mask to restore */
53 	u_int			sc_sp;		/* usp to restore */
54 	u_int			sc_d0;
55 	u_int			sc_d1;
56 	u_int			sc_a0;
57 	u_int			sc_a1;
58 	u_short			sc_ps;		/* processor status (sr reg) */
59 	u_int			sc_pc;
60 
61 	/*
62 	 * The Linux sigstate (state of hardware).
63 	 */
64 	struct linux_sigstate {
65 		u_short		ss_format:4,	/* frame # */
66 				ss_vector:12;	/* vector offset */
67 		struct linux_fpframe {
68 			u_int		fpf_regs[2][3];	/* only fp0 and fp1 */
69 			u_int		fpf_fpcr;
70 			u_int		fpf_fpsr;
71 			u_int		fpf_fpiar;
72 			union FPF_u1	FPF_u1;
73 			union FPF_u2	FPF_u2;
74 		} ss_fpstate;			/* 68881/68882 state info */
75 		union F_u	ss_frame;	/* original exception frame */
76 	} sc_ss;
77 };
78 
79 /*
80  * The Linux compatible signal frame
81  * On Linux, the sigtramp code is on the frame structure.
82  */
83 struct linux_sigframe {
84 	void		*sf_psigtramp;
85 	int		sf_signum;	/* signo for handler */
86 	int		sf_code;	/* Linux stores vector offset here */
87 	struct linux_sigcontext	*sf_scp; /* context ptr for handler */
88 	int		sf_sigtramp[2];
89 	struct linux_sigc2 {
90 #if LINUX__NSIG_WORDS > 1
91 		/* This breaks backward compatibility, but Linux 2.1 has.... */
92 		u_long	c_extrasigmask[LINUX__NSIG_WORDS - 1];
93 #endif
94 		struct	linux_sigcontext c_sc;	/* actual context */
95 	} sf_c;
96 };
97 
98 #define LINUX_SF_SIGTRAMP0 0xDEFC0014	/* addaw #20,sp */
99 #define LINUX_SF_SIGTRAMP1 (0x70004E40 | (LINUX_SYS_sigreturn << 16))
100 				/* moveq #LINUX_SYS_sigreturn,d0; trap #0 */
101 
102 /*
103  * Signal stack definitions for new RT signal interface.
104  */
105 
106 typedef struct linux_gregset {
107 	u_int	gr_regs[16];		/* d0-d7/a0-a6/usp */
108 	u_int	gr_pc;
109 	u_int	gr_sr;
110 } linux_gregset_t;
111 
112 typedef struct linux_fpregset {
113 	u_int	fpr_fpcr;
114 	u_int	fpr_fpsr;
115 	u_int	fpr_fpiar;
116 	u_int	fpr_regs[8][3];		/* fp0-fp7 */
117 } linux_fpregset_t;
118 
119 struct linux_mcontext {
120 	int			mc_version;
121 	linux_gregset_t		mc_gregs;
122 	linux_fpregset_t	mc_fpregs;
123 };
124 
125 #define LINUX_MCONTEXT_VERSION	2
126 
127 struct linux_ucontext {
128 	u_long			uc_flags;	/* 0 */
129 	struct linux_ucontext	*uc_link;	/* 0 */
130 	linux_stack_t		uc_stack;
131 	struct linux_mcontext	uc_mc;
132 	struct linux_rt_sigstate {
133 		struct linux_rt_fpframe {
134 			union FPF_u1	FPF_u1;
135 			union FPF_u2	FPF_u2;
136 		} ss_fpstate;
137 		unsigned int	ss_unused1:16,
138 				ss_format:4,
139 				ss_vector:12;
140 		union F_u	ss_frame;	/* original exception frame */
141 		int		ss_unused2[4];
142 	} uc_ss;
143 	linux_sigset_t		uc_sigmask;
144 };
145 
146 /*
147  * The Linux compatible RT signal frame
148  * On Linux, the sigtramp code is on the frame structure.
149  */
150 struct linux_rt_sigframe {
151 	void			*sf_psigtramp;
152 	int			sf_signum;
153 	struct linux_siginfo	*sf_pinfo;
154 	void			*sf_puc;
155 	struct linux_siginfo	sf_info;
156 	struct linux_ucontext	sf_uc;
157 	int			sf_sigtramp[2];
158 };
159 
160 #define LINUX_RT_SF_SIGTRAMP0 (0x203C0000 | (LINUX_SYS_rt_sigreturn >> 16))
161 #define LINUX_RT_SF_SIGTRAMP1 (0x00004E40 | (LINUX_SYS_rt_sigreturn << 16))
162 			/* movel #LINUX_SYS_rt_sigreturn,#d0; trap #0 */
163 
164 #ifdef _KERNEL
165 __BEGIN_DECLS
166 void linux_syscall_intern __P((struct proc *));
167 __END_DECLS
168 #endif /* !_KERNEL */
169 
170 #endif /* _M68K_LINUX_MACHDEP_H */
171