xref: /freebsd/sys/compat/ia32/ia32_signal.h (revision 273c26a3c3bea87a241d6879abd4f991db180bf0)
1 /*-
2  * Copyright (c) 1999 Marcel Moolenaar
3  * Copyright (c) 2003 Peter Wemm
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer
11  *    in this position and unchanged.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef	_COMPAT_IA32_IA32_SIGNAL_H
33 #define	_COMPAT_IA32_IA32_SIGNAL_H
34 
35 #include <compat/freebsd32/freebsd32_signal.h>
36 
37 #define	_MC_IA32_HASSEGS	0x1
38 #define	_MC_IA32_HASBASES	0x2
39 #define	_MC_IA32_HASFPXSTATE	0x4
40 #define	_MC_IA32_FLAG_MASK	\
41     (_MC_IA32_HASSEGS | _MC_IA32_HASBASES | _MC_IA32_HASFPXSTATE)
42 
43 struct ia32_mcontext {
44 	u_int32_t	mc_onstack;		/* XXX - sigcontext compat. */
45 	u_int32_t	mc_gs;			/* machine state (struct trapframe) */
46 	u_int32_t	mc_fs;
47 	u_int32_t	mc_es;
48 	u_int32_t	mc_ds;
49 	u_int32_t	mc_edi;
50 	u_int32_t	mc_esi;
51 	u_int32_t	mc_ebp;
52 	u_int32_t	mc_isp;
53 	u_int32_t	mc_ebx;
54 	u_int32_t	mc_edx;
55 	u_int32_t	mc_ecx;
56 	u_int32_t	mc_eax;
57 	u_int32_t	mc_trapno;
58 	u_int32_t	mc_err;
59 	u_int32_t	mc_eip;
60 	u_int32_t	mc_cs;
61 	u_int32_t	mc_eflags;
62 	u_int32_t	mc_esp;
63 	u_int32_t	mc_ss;
64 	u_int32_t	mc_len;			/* sizeof(struct ia32_mcontext) */
65 	/* We use the same values for fpformat and ownedfp */
66 	u_int32_t	mc_fpformat;
67 	u_int32_t	mc_ownedfp;
68 	u_int32_t	mc_flags;
69 	/*
70 	 * See <i386/include/npx.h> for the internals of mc_fpstate[].
71 	 */
72 	u_int32_t	mc_fpstate[128] __aligned(16);
73 	u_int32_t	mc_fsbase;
74 	u_int32_t	mc_gsbase;
75 	u_int32_t	mc_xfpustate;
76 	u_int32_t	mc_xfpustate_len;
77 	u_int32_t	mc_spare2[4];
78 };
79 
80 struct ia32_ucontext {
81 	sigset_t		uc_sigmask;
82 	struct ia32_mcontext	uc_mcontext;
83 	u_int32_t		uc_link;
84 	struct sigaltstack32	uc_stack;
85 	u_int32_t		uc_flags;
86 	u_int32_t		__spare__[4];
87 };
88 
89 
90 #if defined(COMPAT_FREEBSD4)
91 struct ia32_mcontext4 {
92 	u_int32_t	mc_onstack;		/* XXX - sigcontext compat. */
93 	u_int32_t	mc_gs;			/* machine state (struct trapframe) */
94 	u_int32_t	mc_fs;
95 	u_int32_t	mc_es;
96 	u_int32_t	mc_ds;
97 	u_int32_t	mc_edi;
98 	u_int32_t	mc_esi;
99 	u_int32_t	mc_ebp;
100 	u_int32_t	mc_isp;
101 	u_int32_t	mc_ebx;
102 	u_int32_t	mc_edx;
103 	u_int32_t	mc_ecx;
104 	u_int32_t	mc_eax;
105 	u_int32_t	mc_trapno;
106 	u_int32_t	mc_err;
107 	u_int32_t	mc_eip;
108 	u_int32_t	mc_cs;
109 	u_int32_t	mc_eflags;
110 	u_int32_t	mc_esp;
111 	u_int32_t	mc_ss;
112 	u_int32_t	mc_fpregs[28];
113 	u_int32_t	__spare__[17];
114 };
115 
116 struct ia32_ucontext4 {
117 	sigset_t		uc_sigmask;
118 	struct ia32_mcontext4	uc_mcontext;
119 	u_int32_t		uc_link;
120 	struct sigaltstack32	uc_stack;
121 	u_int32_t		__spare__[8];
122 };
123 #endif
124 
125 #ifdef COMPAT_43
126 struct ia32_sigcontext3 {
127 	u_int32_t	sc_onstack;
128 	u_int32_t	sc_mask;
129 	u_int32_t	sc_esp;
130 	u_int32_t	sc_ebp;
131 	u_int32_t	sc_isp;
132 	u_int32_t	sc_eip;
133 	u_int32_t	sc_eflags;
134 	u_int32_t	sc_es;
135 	u_int32_t	sc_ds;
136 	u_int32_t	sc_cs;
137 	u_int32_t	sc_ss;
138 	u_int32_t	sc_edi;
139 	u_int32_t	sc_esi;
140 	u_int32_t	sc_ebx;
141 	u_int32_t	sc_edx;
142 	u_int32_t	sc_ecx;
143 	u_int32_t	sc_eax;
144 	u_int32_t	sc_gs;
145 	u_int32_t	sc_fs;
146 	u_int32_t	sc_trapno;
147 	u_int32_t	sc_err;
148 };
149 #endif
150 
151 /*
152  * Signal frames, arguments passed to application signal handlers.
153  */
154 
155 #ifdef COMPAT_FREEBSD4
156 struct ia32_sigframe4 {
157 	u_int32_t		sf_signum;
158 	u_int32_t		sf_siginfo;	/* code or pointer to sf_si */
159 	u_int32_t		sf_ucontext;	/* points to sf_uc */
160 	u_int32_t		sf_addr;	/* undocumented 4th arg */
161 	u_int32_t		sf_ah;		/* action/handler pointer */
162 	struct ia32_ucontext4	sf_uc;		/* = *sf_ucontext */
163 	struct siginfo32	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
164 };
165 #endif
166 
167 struct ia32_sigframe {
168 	u_int32_t		sf_signum;
169 	u_int32_t		sf_siginfo;	/* code or pointer to sf_si */
170 	u_int32_t		sf_ucontext;	/* points to sf_uc */
171 	u_int32_t		sf_addr;	/* undocumented 4th arg */
172 	u_int32_t		sf_ah;		/* action/handler pointer */
173 	/* Beware, hole due to ucontext being 16 byte aligned! */
174 	struct ia32_ucontext	sf_uc;		/* = *sf_ucontext */
175 	struct siginfo32	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
176 };
177 
178 #ifdef COMPAT_43
179 struct ia32_siginfo3 {
180 	struct ia32_sigcontext3 si_sc;
181 	int			si_signo;
182 	int			si_code;
183 	union sigval32		si_value;
184 };
185 struct ia32_sigframe3 {
186 	int			sf_signum;
187 	u_int32_t		sf_arg2;	/* int or siginfo_t */
188 	u_int32_t		sf_scp;
189 	u_int32_t		sf_addr;
190 	u_int32_t		sf_ah;		/* action/handler pointer */
191 	struct ia32_siginfo3	sf_siginfo;
192 };
193 #endif
194 
195 struct ksiginfo;
196 struct image_params;
197 extern char ia32_sigcode[];
198 extern char freebsd4_ia32_sigcode[];
199 extern char ia32_osigcode[];
200 extern char lcall_tramp;
201 extern int sz_ia32_sigcode;
202 extern int sz_freebsd4_ia32_sigcode;
203 extern int sz_ia32_osigcode;
204 extern int sz_lcall_tramp;
205 void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *);
206 void ia32_setregs(struct thread *td, struct image_params *imgp,
207     u_long stack);
208 int setup_lcall_gate(void);
209 
210 #endif
211