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