xref: /freebsd/sys/compat/ia32/ia32_signal.h (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
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 
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 	uint32_t	mc_onstack;		/* XXX - sigcontext compat. */
45 	uint32_t	mc_gs;			/* machine state (struct trapframe) */
46 	uint32_t	mc_fs;
47 	uint32_t	mc_es;
48 	uint32_t	mc_ds;
49 	uint32_t	mc_edi;
50 	uint32_t	mc_esi;
51 	uint32_t	mc_ebp;
52 	uint32_t	mc_isp;
53 	uint32_t	mc_ebx;
54 	uint32_t	mc_edx;
55 	uint32_t	mc_ecx;
56 	uint32_t	mc_eax;
57 	uint32_t	mc_trapno;
58 	uint32_t	mc_err;
59 	uint32_t	mc_eip;
60 	uint32_t	mc_cs;
61 	uint32_t	mc_eflags;
62 	uint32_t	mc_esp;
63 	uint32_t	mc_ss;
64 	uint32_t	mc_len;			/* sizeof(struct ia32_mcontext) */
65 	/* We use the same values for fpformat and ownedfp */
66 	uint32_t	mc_fpformat;
67 	uint32_t	mc_ownedfp;
68 	uint32_t	mc_flags;
69 	/*
70 	 * See <i386/include/npx.h> for the internals of mc_fpstate[].
71 	 */
72 	uint32_t	mc_fpstate[128] __aligned(16);
73 	uint32_t	mc_fsbase;
74 	uint32_t	mc_gsbase;
75 	uint32_t	mc_xfpustate;
76 	uint32_t	mc_xfpustate_len;
77 	uint32_t	mc_spare2[4];
78 };
79 
80 struct ia32_ucontext {
81 	sigset_t		uc_sigmask;
82 	struct ia32_mcontext	uc_mcontext;
83 	uint32_t		uc_link;
84 	struct sigaltstack32	uc_stack;
85 	uint32_t		uc_flags;
86 	uint32_t		__spare__[4];
87 };
88 
89 struct ia32_freebsd4_mcontext {
90 	uint32_t	mc_onstack;		/* XXX - sigcontext compat. */
91 	uint32_t	mc_gs;			/* machine state (struct trapframe) */
92 	uint32_t	mc_fs;
93 	uint32_t	mc_es;
94 	uint32_t	mc_ds;
95 	uint32_t	mc_edi;
96 	uint32_t	mc_esi;
97 	uint32_t	mc_ebp;
98 	uint32_t	mc_isp;
99 	uint32_t	mc_ebx;
100 	uint32_t	mc_edx;
101 	uint32_t	mc_ecx;
102 	uint32_t	mc_eax;
103 	uint32_t	mc_trapno;
104 	uint32_t	mc_err;
105 	uint32_t	mc_eip;
106 	uint32_t	mc_cs;
107 	uint32_t	mc_eflags;
108 	uint32_t	mc_esp;
109 	uint32_t	mc_ss;
110 	uint32_t	mc_fpregs[28];
111 	uint32_t	__spare__[17];
112 };
113 
114 struct ia32_freebsd4_ucontext {
115 	sigset_t		uc_sigmask;
116 	struct ia32_freebsd4_mcontext	uc_mcontext;
117 	uint32_t		uc_link;
118 	struct sigaltstack32	uc_stack;
119 	uint32_t		__spare__[8];
120 };
121 
122 struct ia32_osigcontext {
123 	uint32_t	sc_onstack;
124 	uint32_t	sc_mask;
125 	uint32_t	sc_esp;
126 	uint32_t	sc_ebp;
127 	uint32_t	sc_isp;
128 	uint32_t	sc_eip;
129 	uint32_t	sc_eflags;
130 	uint32_t	sc_es;
131 	uint32_t	sc_ds;
132 	uint32_t	sc_cs;
133 	uint32_t	sc_ss;
134 	uint32_t	sc_edi;
135 	uint32_t	sc_esi;
136 	uint32_t	sc_ebx;
137 	uint32_t	sc_edx;
138 	uint32_t	sc_ecx;
139 	uint32_t	sc_eax;
140 	uint32_t	sc_gs;
141 	uint32_t	sc_fs;
142 	uint32_t	sc_trapno;
143 	uint32_t	sc_err;
144 };
145 
146 /*
147  * Signal frames, arguments passed to application signal handlers.
148  */
149 
150 struct ia32_freebsd4_sigframe {
151 	uint32_t		sf_signum;
152 	uint32_t		sf_siginfo;	/* code or pointer to sf_si */
153 	uint32_t		sf_ucontext;	/* points to sf_uc */
154 	uint32_t		sf_addr;	/* undocumented 4th arg */
155 	uint32_t		sf_ah;		/* action/handler pointer */
156 	struct ia32_freebsd4_ucontext	sf_uc;		/* = *sf_ucontext */
157 	struct siginfo32	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
158 };
159 
160 struct ia32_sigframe {
161 	uint32_t		sf_signum;
162 	uint32_t		sf_siginfo;	/* code or pointer to sf_si */
163 	uint32_t		sf_ucontext;	/* points to sf_uc */
164 	uint32_t		sf_addr;	/* undocumented 4th arg */
165 	uint32_t		sf_ah;		/* action/handler pointer */
166 	/* Beware, hole due to ucontext being 16 byte aligned! */
167 	struct ia32_ucontext	sf_uc;		/* = *sf_ucontext */
168 	struct siginfo32	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
169 };
170 
171 struct ia32_osiginfo {
172 	struct ia32_osigcontext si_sc;
173 	int			si_signo;
174 	int			si_code;
175 	union sigval32		si_value;
176 };
177 struct ia32_osigframe {
178 	int			sf_signum;
179 	uint32_t		sf_arg2;	/* int or siginfo_t */
180 	uint32_t		sf_scp;
181 	uint32_t		sf_addr;
182 	uint32_t		sf_ah;		/* action/handler pointer */
183 	struct ia32_osiginfo	sf_siginfo;
184 };
185 
186 struct ksiginfo;
187 struct image_params;
188 void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *);
189 void ia32_setregs(struct thread *td, struct image_params *imgp,
190     uintptr_t stack);
191 int setup_lcall_gate(void);
192 
193 #endif
194