signal.h revision 1.5 1 1.5 briggs /* $NetBSD: signal.h,v 1.5 2003/10/18 17:57:21 briggs Exp $ */
2 1.1 bjh21
3 1.1 bjh21 /*
4 1.1 bjh21 * Copyright (c) 1994-1996 Mark Brinicombe.
5 1.1 bjh21 * Copyright (c) 1994 Brini.
6 1.1 bjh21 * All rights reserved.
7 1.1 bjh21 *
8 1.1 bjh21 * This code is derived from software written for Brini by Mark Brinicombe
9 1.1 bjh21 *
10 1.1 bjh21 * Redistribution and use in source and binary forms, with or without
11 1.1 bjh21 * modification, are permitted provided that the following conditions
12 1.1 bjh21 * are met:
13 1.1 bjh21 * 1. Redistributions of source code must retain the above copyright
14 1.1 bjh21 * notice, this list of conditions and the following disclaimer.
15 1.1 bjh21 * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 bjh21 * notice, this list of conditions and the following disclaimer in the
17 1.1 bjh21 * documentation and/or other materials provided with the distribution.
18 1.1 bjh21 * 3. All advertising materials mentioning features or use of this software
19 1.1 bjh21 * must display the following acknowledgement:
20 1.1 bjh21 * This product includes software developed by Brini.
21 1.1 bjh21 * 4. The name of the company nor the name of the author may be used to
22 1.1 bjh21 * endorse or promote products derived from this software without specific
23 1.1 bjh21 * prior written permission.
24 1.1 bjh21 *
25 1.1 bjh21 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 1.1 bjh21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 1.1 bjh21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 1.1 bjh21 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 1.1 bjh21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 1.1 bjh21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 1.1 bjh21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 bjh21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 bjh21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 bjh21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 bjh21 * SUCH DAMAGE.
36 1.1 bjh21 *
37 1.1 bjh21 * RiscBSD kernel project
38 1.1 bjh21 *
39 1.1 bjh21 * signal.h
40 1.1 bjh21 *
41 1.1 bjh21 * Architecture dependant signal types and structures
42 1.1 bjh21 *
43 1.1 bjh21 * Created : 30/09/94
44 1.1 bjh21 */
45 1.1 bjh21
46 1.1 bjh21 #ifndef _ARM32_SIGNAL_H_
47 1.1 bjh21 #define _ARM32_SIGNAL_H_
48 1.1 bjh21
49 1.3 bjh21 #include <sys/featuretest.h>
50 1.3 bjh21
51 1.1 bjh21 #ifndef _LOCORE
52 1.1 bjh21 typedef int sig_atomic_t;
53 1.1 bjh21 #endif
54 1.1 bjh21
55 1.4 matt #define __HAVE_SIGINFO
56 1.4 matt
57 1.3 bjh21 #if defined(_NETBSD_SOURCE)
58 1.5 briggs
59 1.5 briggs #ifdef COMPAT_16
60 1.5 briggs #define SIGTRAMP_VALID(vers) ((unsigned)(vers) <= 2)
61 1.5 briggs #else
62 1.5 briggs #define SIGTRAMP_VALID(vers) ((vers) == 2)
63 1.5 briggs #endif
64 1.5 briggs
65 1.1 bjh21 #ifndef _LOCORE
66 1.1 bjh21 /*
67 1.1 bjh21 * Information pushed on stack when a signal is delivered.
68 1.1 bjh21 * This is used by the kernel to restore state following
69 1.1 bjh21 * execution of the signal handler. It is also made available
70 1.1 bjh21 * to the handler to allow it to restore state properly if
71 1.1 bjh21 * a non-standard exit is performed.
72 1.1 bjh21 */
73 1.1 bjh21
74 1.1 bjh21 #if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
75 1.1 bjh21 struct sigcontext13 {
76 1.1 bjh21 int sc_onstack; /* sigstack state to restore */
77 1.1 bjh21 int sc_mask; /* signal mask to restore (old style) */
78 1.1 bjh21
79 1.1 bjh21 unsigned int sc_spsr;
80 1.1 bjh21 unsigned int sc_r0;
81 1.1 bjh21 unsigned int sc_r1;
82 1.1 bjh21 unsigned int sc_r2;
83 1.1 bjh21 unsigned int sc_r3;
84 1.1 bjh21 unsigned int sc_r4;
85 1.1 bjh21 unsigned int sc_r5;
86 1.1 bjh21 unsigned int sc_r6;
87 1.1 bjh21 unsigned int sc_r7;
88 1.1 bjh21 unsigned int sc_r8;
89 1.1 bjh21 unsigned int sc_r9;
90 1.1 bjh21 unsigned int sc_r10;
91 1.1 bjh21 unsigned int sc_r11;
92 1.1 bjh21 unsigned int sc_r12;
93 1.1 bjh21 unsigned int sc_usr_sp;
94 1.1 bjh21 unsigned int sc_usr_lr;
95 1.1 bjh21 unsigned int sc_svc_lr;
96 1.1 bjh21 unsigned int sc_pc;
97 1.1 bjh21 };
98 1.1 bjh21 #endif /* __LIBC12_SOURCE__ || _KERNEL */
99 1.1 bjh21
100 1.4 matt #ifdef COMPAT_16
101 1.1 bjh21 struct sigcontext {
102 1.1 bjh21 int sc_onstack; /* sigstack state to restore */
103 1.1 bjh21 int __sc_mask13; /* signal mask to restore (old style) */
104 1.1 bjh21
105 1.1 bjh21 unsigned int sc_spsr;
106 1.1 bjh21 unsigned int sc_r0;
107 1.1 bjh21 unsigned int sc_r1;
108 1.1 bjh21 unsigned int sc_r2;
109 1.1 bjh21 unsigned int sc_r3;
110 1.1 bjh21 unsigned int sc_r4;
111 1.1 bjh21 unsigned int sc_r5;
112 1.1 bjh21 unsigned int sc_r6;
113 1.1 bjh21 unsigned int sc_r7;
114 1.1 bjh21 unsigned int sc_r8;
115 1.1 bjh21 unsigned int sc_r9;
116 1.1 bjh21 unsigned int sc_r10;
117 1.1 bjh21 unsigned int sc_r11;
118 1.1 bjh21 unsigned int sc_r12;
119 1.1 bjh21 unsigned int sc_usr_sp;
120 1.1 bjh21 unsigned int sc_usr_lr;
121 1.1 bjh21 unsigned int sc_svc_lr;
122 1.1 bjh21 unsigned int sc_pc;
123 1.1 bjh21
124 1.1 bjh21 sigset_t sc_mask; /* signal mask to restore (new style) */
125 1.1 bjh21 };
126 1.4 matt #endif
127 1.2 thorpej
128 1.2 thorpej /*
129 1.2 thorpej * The following macros are used to convert from a ucontext to sigcontext,
130 1.2 thorpej * and vice-versa. This is for building a sigcontext to deliver to old-style
131 1.2 thorpej * signal handlers, and converting back (in the event the handler modifies
132 1.2 thorpej * the context).
133 1.2 thorpej */
134 1.2 thorpej #define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \
135 1.2 thorpej do { \
136 1.2 thorpej (sc)->sc_spsr = (uc)->uc_mcontext.__gregs[_REG_CPSR]; \
137 1.2 thorpej memcpy(&(sc)->sc_r0, (uc)->uc_mcontext.__gregs, \
138 1.2 thorpej 15 * sizeof(unsigned int)); \
139 1.2 thorpej (sc)->sc_svc_lr = 0; /* XXX */ \
140 1.2 thorpej (sc)->sc_pc = (uc)->uc_mcontext.__gregs[_REG_PC]; \
141 1.2 thorpej } while (/*CONSTCOND*/0)
142 1.2 thorpej
143 1.2 thorpej #define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \
144 1.2 thorpej do { \
145 1.2 thorpej (uc)->uc_mcontext.__gregs[_REG_CPSR] = (sc)->sc_spsr; \
146 1.2 thorpej memcpy((uc)->uc_mcontext.__gregs, &(sc)->sc_r0, \
147 1.2 thorpej 15 * sizeof(unsigned int)); \
148 1.2 thorpej (uc)->uc_mcontext.__gregs[_REG_PC] = (sc)->sc_pc; \
149 1.2 thorpej } while (/*CONSTCOND*/0)
150 1.1 bjh21
151 1.1 bjh21 #endif /* !_LOCORE */
152 1.1 bjh21
153 1.1 bjh21 /* Signals codes */
154 1.1 bjh21
155 1.1 bjh21 /*
156 1.1 bjh21 * SIGFPE codes
157 1.1 bjh21 *
158 1.1 bjh21 * see ieeefp.h for definition of FP exception codes
159 1.1 bjh21 */
160 1.1 bjh21
161 1.1 bjh21 #define SIG_CODE_FPE_CODE_MASK 0x00000f00 /* Mask for exception code */
162 1.1 bjh21 #define SIG_CODE_FPE_CODE_SHIFT 8 /* Shift for exception code */
163 1.1 bjh21 #define SIG_CODE_FPE_TYPE_MASK 0x000000ff /* Mask for specific code */
164 1.1 bjh21
165 1.1 bjh21 /*
166 1.1 bjh21 * SIGILL codes
167 1.1 bjh21 *
168 1.1 bjh21 * the signal code is the instruction that raised the signal
169 1.1 bjh21 */
170 1.1 bjh21
171 1.1 bjh21 /*
172 1.1 bjh21 * SIGBUS and SIGSEGV codes
173 1.1 bjh21 *
174 1.1 bjh21 * The signal code is combination of the fault address and the fault code.
175 1.1 bjh21 *
176 1.1 bjh21 * The fault code is the coproc #15 fault status code
177 1.1 bjh21 *
178 1.1 bjh21 * The exception to this is a SIGBUS or SIGSEGV from a prefetch abort.
179 1.1 bjh21 * In this case the fault status code is not valid so the TYPE_MASK
180 1.1 bjh21 * should be treated as undefined (in practice it is the bottom 4 bits
181 1.1 bjh21 * of the fault address).
182 1.1 bjh21 */
183 1.1 bjh21
184 1.1 bjh21 #define SIG_CODE_BUS_ADDR_MASK 0xfffffff0
185 1.1 bjh21 #define SIG_CODE_BUS_TYPE_MASK 0x0000000f
186 1.1 bjh21 #define SIG_CODE_SEGV_ADDR_MASK SIG_CODE_BUS_ADDR_MASK
187 1.1 bjh21 #define SIG_CODE_SEGV_TYPE_MASK SIG_CODE_BUS_TYPE_MASK
188 1.1 bjh21
189 1.3 bjh21 #endif /* _NETBSD_SOURCE */
190 1.1 bjh21 #endif /* !_ARM_SIGNAL_H_ */
191 1.1 bjh21
192 1.1 bjh21 /* End of signal.h */
193