1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2004 Tim J. Robbins
5 * Copyright (c) 2001 Doug Rabson
6 * Copyright (c) 1994-1996 Søren Schmidt
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer
14 * in this position and unchanged.
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. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD$
33 */
34
35 #ifndef _X86_LINUX_SIGFRAME_H_
36 #define _X86_LINUX_SIGFRAME_H_
37
38 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
39
40 /* The Linux sigcontext, pretty much a standard 386 trapframe. */
41 struct l_sigcontext {
42 l_uint sc_gs;
43 l_uint sc_fs;
44 l_uint sc_es;
45 l_uint sc_ds;
46 l_uint sc_edi;
47 l_uint sc_esi;
48 l_uint sc_ebp;
49 l_uint sc_esp;
50 l_uint sc_ebx;
51 l_uint sc_edx;
52 l_uint sc_ecx;
53 l_uint sc_eax;
54 l_uint sc_trapno;
55 l_uint sc_err;
56 l_uint sc_eip;
57 l_uint sc_cs;
58 l_uint sc_eflags;
59 l_uint sc_esp_at_signal;
60 l_uint sc_ss;
61 l_uint sc_387;
62 l_uint sc_mask;
63 l_uint sc_cr2;
64 };
65
66 struct l_ucontext {
67 l_ulong uc_flags;
68 l_uintptr_t uc_link;
69 l_stack_t uc_stack;
70 struct l_sigcontext uc_mcontext;
71 l_sigset_t uc_sigmask;
72 } __packed;
73
74 struct l_fpreg {
75 u_int16_t significand[4];
76 u_int16_t exponent;
77 };
78
79 struct l_fpxreg {
80 u_int16_t significand[4];
81 u_int16_t exponent;
82 u_int16_t padding[3];
83 };
84
85 struct l_xmmreg {
86 u_int32_t element[4];
87 };
88
89 struct l_fpstate {
90 /* Regular FPU environment */
91 u_int32_t cw;
92 u_int32_t sw;
93 u_int32_t tag;
94 u_int32_t ipoff;
95 u_int32_t cssel;
96 u_int32_t dataoff;
97 u_int32_t datasel;
98 struct l_fpreg _st[8];
99 u_int16_t status;
100 u_int16_t magic; /* 0xffff = regular FPU data */
101
102 /* FXSR FPU environment */
103 u_int32_t _fxsr_env[6]; /* env is ignored. */
104 u_int32_t mxcsr;
105 u_int32_t reserved;
106 struct l_fpxreg _fxsr_st[8]; /* reg data is ignored. */
107 struct l_xmmreg _xmm[8];
108 u_int32_t padding[56];
109 };
110
111 /*
112 * We make the stack look like Linux expects it when calling a signal
113 * handler, but use the BSD way of calling the handler and sigreturn().
114 */
115 struct l_sigframe {
116 l_int sf_sig;
117 struct l_sigcontext sf_sc;
118 struct l_fpstate sf_fpstate;
119 sigset_t sf_sigmask;
120 };
121
122 struct l_rt_sigframe {
123 l_int sf_sig;
124 l_uintptr_t sf_siginfo;
125 l_uintptr_t sf_ucontext;
126 l_siginfo_t sf_si;
127 struct l_ucontext sf_uc;
128 };
129
130 #else
131
132 struct l_fpstate {
133 u_int16_t cwd;
134 u_int16_t swd;
135 u_int16_t twd;
136 u_int16_t fop;
137 u_int64_t rip;
138 u_int64_t rdp;
139 u_int32_t mxcsr;
140 u_int32_t mxcsr_mask;
141 u_int32_t st_space[32];
142 u_int32_t xmm_space[64];
143 u_int32_t reserved2[24];
144 };
145
146 struct l_sigcontext {
147 l_ulong sc_r8;
148 l_ulong sc_r9;
149 l_ulong sc_r10;
150 l_ulong sc_r11;
151 l_ulong sc_r12;
152 l_ulong sc_r13;
153 l_ulong sc_r14;
154 l_ulong sc_r15;
155 l_ulong sc_rdi;
156 l_ulong sc_rsi;
157 l_ulong sc_rbp;
158 l_ulong sc_rbx;
159 l_ulong sc_rdx;
160 l_ulong sc_rax;
161 l_ulong sc_rcx;
162 l_ulong sc_rsp;
163 l_ulong sc_rip;
164 l_ulong sc_rflags;
165 l_ushort sc_cs;
166 l_ushort sc_gs;
167 l_ushort sc_fs;
168 l_ushort sc___pad0;
169 l_ulong sc_err;
170 l_ulong sc_trapno;
171 l_sigset_t sc_mask;
172 l_ulong sc_cr2;
173 struct l_fpstate *sc_fpstate;
174 l_ulong sc_reserved1[8];
175 };
176
177 struct l_ucontext {
178 l_ulong uc_flags;
179 l_uintptr_t uc_link;
180 l_stack_t uc_stack;
181 struct l_sigcontext uc_mcontext;
182 l_sigset_t uc_sigmask;
183 };
184
185 /*
186 * We make the stack look like Linux expects it when calling a signal
187 * handler, but use the BSD way of calling the handler and sigreturn().
188 */
189 struct l_rt_sigframe {
190 struct l_ucontext sf_uc;
191 struct l_siginfo sf_si;
192 };
193
194 #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
195
196 #endif /* !_X86_LINUX_SIGFRAME_H_ */
Cache object: 92e5ca2c2193a810dba8926b558335cd
|