xref: /illumos-gate/usr/src/boot/sys/x86/include/signal.h (revision 5642709d)
1199767f8SToomas Soome /*-
2199767f8SToomas Soome  * Copyright (c) 1986, 1989, 1991, 1993
3199767f8SToomas Soome  *	The Regents of the University of California.  All rights reserved.
4199767f8SToomas Soome  * Copyright (c) 2003 Peter Wemm.
5199767f8SToomas Soome  *
6199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
7199767f8SToomas Soome  * modification, are permitted provided that the following conditions
8199767f8SToomas Soome  * are met:
9199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
10199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
11199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
12199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
13199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
14199767f8SToomas Soome  * 4. Neither the name of the University nor the names of its contributors
15199767f8SToomas Soome  *    may be used to endorse or promote products derived from this software
16199767f8SToomas Soome  *    without specific prior written permission.
17199767f8SToomas Soome  *
18199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28199767f8SToomas Soome  * SUCH DAMAGE.
29199767f8SToomas Soome  *
30199767f8SToomas Soome  *	@(#)signal.h	8.1 (Berkeley) 6/11/93
31199767f8SToomas Soome  * $FreeBSD$
32199767f8SToomas Soome  */
33199767f8SToomas Soome 
34199767f8SToomas Soome #ifndef _X86_SIGNAL_H
35199767f8SToomas Soome #define	_X86_SIGNAL_H 1
36199767f8SToomas Soome 
37199767f8SToomas Soome /*
38199767f8SToomas Soome  * Machine-dependent signal definitions
39199767f8SToomas Soome  */
40199767f8SToomas Soome 
41199767f8SToomas Soome #include <sys/cdefs.h>
42199767f8SToomas Soome #include <sys/_sigset.h>
43199767f8SToomas Soome 
44199767f8SToomas Soome #if __BSD_VISIBLE
45199767f8SToomas Soome #include <machine/trap.h>	/* codes for SIGILL, SIGFPE */
46199767f8SToomas Soome #endif
47199767f8SToomas Soome 
48*5642709dSToomas Soome #if defined(__i386__) && !defined(__amd64__)
49199767f8SToomas Soome typedef int sig_atomic_t;
50199767f8SToomas Soome 
51199767f8SToomas Soome #if __BSD_VISIBLE
52199767f8SToomas Soome struct sigcontext {
53199767f8SToomas Soome 	struct __sigset sc_mask;	/* signal mask to restore */
54199767f8SToomas Soome 	int	sc_onstack;		/* sigstack state to restore */
55199767f8SToomas Soome 	int	sc_gs;			/* machine state (struct trapframe) */
56199767f8SToomas Soome 	int	sc_fs;
57199767f8SToomas Soome 	int	sc_es;
58199767f8SToomas Soome 	int	sc_ds;
59199767f8SToomas Soome 	int	sc_edi;
60199767f8SToomas Soome 	int	sc_esi;
61199767f8SToomas Soome 	int	sc_ebp;
62199767f8SToomas Soome 	int	sc_isp;
63199767f8SToomas Soome 	int	sc_ebx;
64199767f8SToomas Soome 	int	sc_edx;
65199767f8SToomas Soome 	int	sc_ecx;
66199767f8SToomas Soome 	int	sc_eax;
67199767f8SToomas Soome 	int	sc_trapno;
68199767f8SToomas Soome 	int	sc_err;
69199767f8SToomas Soome 	int	sc_eip;
70199767f8SToomas Soome 	int	sc_cs;
71199767f8SToomas Soome 	int	sc_efl;
72199767f8SToomas Soome 	int	sc_esp;
73199767f8SToomas Soome 	int	sc_ss;
74199767f8SToomas Soome 	int	sc_len;			/* sizeof(mcontext_t) */
75199767f8SToomas Soome 	/*
76199767f8SToomas Soome 	 * See <machine/ucontext.h> and <machine/npx.h> for
77199767f8SToomas Soome 	 * the following fields.
78199767f8SToomas Soome 	 */
79199767f8SToomas Soome 	int	sc_fpformat;
80199767f8SToomas Soome 	int	sc_ownedfp;
81199767f8SToomas Soome 	int	sc_flags;
82199767f8SToomas Soome 	int	sc_fpstate[128] __aligned(16);
83199767f8SToomas Soome 
84199767f8SToomas Soome 	int	sc_fsbase;
85199767f8SToomas Soome 	int	sc_gsbase;
86199767f8SToomas Soome 
87199767f8SToomas Soome 	int	sc_xfpustate;
88199767f8SToomas Soome 	int	sc_xfpustate_len;
89199767f8SToomas Soome 
90199767f8SToomas Soome 	int	sc_spare2[4];
91199767f8SToomas Soome };
92199767f8SToomas Soome 
93199767f8SToomas Soome #define	sc_sp		sc_esp
94199767f8SToomas Soome #define	sc_fp		sc_ebp
95199767f8SToomas Soome #define	sc_pc		sc_eip
96199767f8SToomas Soome #define	sc_ps		sc_efl
97199767f8SToomas Soome #define	sc_eflags	sc_efl
98199767f8SToomas Soome 
99199767f8SToomas Soome #endif /* __BSD_VISIBLE */
100199767f8SToomas Soome #endif /* __i386__ */
101199767f8SToomas Soome 
102199767f8SToomas Soome #ifdef __amd64__
103199767f8SToomas Soome typedef long sig_atomic_t;
104199767f8SToomas Soome 
105199767f8SToomas Soome #if __BSD_VISIBLE
106199767f8SToomas Soome /*
107199767f8SToomas Soome  * Information pushed on stack when a signal is delivered.
108199767f8SToomas Soome  * This is used by the kernel to restore state following
109199767f8SToomas Soome  * execution of the signal handler.  It is also made available
110199767f8SToomas Soome  * to the handler to allow it to restore state properly if
111199767f8SToomas Soome  * a non-standard exit is performed.
112199767f8SToomas Soome  *
113199767f8SToomas Soome  * The sequence of the fields/registers after sc_mask in struct
114199767f8SToomas Soome  * sigcontext must match those in mcontext_t and struct trapframe.
115199767f8SToomas Soome  */
116199767f8SToomas Soome struct sigcontext {
117199767f8SToomas Soome 	struct __sigset sc_mask;	/* signal mask to restore */
118199767f8SToomas Soome 	long	sc_onstack;		/* sigstack state to restore */
119199767f8SToomas Soome 	long	sc_rdi;		/* machine state (struct trapframe) */
120199767f8SToomas Soome 	long	sc_rsi;
121199767f8SToomas Soome 	long	sc_rdx;
122199767f8SToomas Soome 	long	sc_rcx;
123199767f8SToomas Soome 	long	sc_r8;
124199767f8SToomas Soome 	long	sc_r9;
125199767f8SToomas Soome 	long	sc_rax;
126199767f8SToomas Soome 	long	sc_rbx;
127199767f8SToomas Soome 	long	sc_rbp;
128199767f8SToomas Soome 	long	sc_r10;
129199767f8SToomas Soome 	long	sc_r11;
130199767f8SToomas Soome 	long	sc_r12;
131199767f8SToomas Soome 	long	sc_r13;
132199767f8SToomas Soome 	long	sc_r14;
133199767f8SToomas Soome 	long	sc_r15;
134199767f8SToomas Soome 	int	sc_trapno;
135199767f8SToomas Soome 	short	sc_fs;
136199767f8SToomas Soome 	short	sc_gs;
137199767f8SToomas Soome 	long	sc_addr;
138199767f8SToomas Soome 	int	sc_flags;
139199767f8SToomas Soome 	short	sc_es;
140199767f8SToomas Soome 	short	sc_ds;
141199767f8SToomas Soome 	long	sc_err;
142199767f8SToomas Soome 	long	sc_rip;
143199767f8SToomas Soome 	long	sc_cs;
144199767f8SToomas Soome 	long	sc_rflags;
145199767f8SToomas Soome 	long	sc_rsp;
146199767f8SToomas Soome 	long	sc_ss;
147199767f8SToomas Soome 	long	sc_len;			/* sizeof(mcontext_t) */
148199767f8SToomas Soome 	/*
149199767f8SToomas Soome 	 * See <machine/ucontext.h> and <machine/fpu.h> for the following
150199767f8SToomas Soome 	 * fields.
151199767f8SToomas Soome 	 */
152199767f8SToomas Soome 	long	sc_fpformat;
153199767f8SToomas Soome 	long	sc_ownedfp;
154199767f8SToomas Soome 	long	sc_fpstate[64] __aligned(16);
155199767f8SToomas Soome 
156199767f8SToomas Soome 	long	sc_fsbase;
157199767f8SToomas Soome 	long	sc_gsbase;
158199767f8SToomas Soome 
159199767f8SToomas Soome 	long	sc_xfpustate;
160199767f8SToomas Soome 	long	sc_xfpustate_len;
161199767f8SToomas Soome 
162199767f8SToomas Soome 	long	sc_spare[4];
163199767f8SToomas Soome };
164199767f8SToomas Soome #endif /* __BSD_VISIBLE */
165199767f8SToomas Soome #endif /* __amd64__ */
166199767f8SToomas Soome 
167199767f8SToomas Soome #endif
168