1 /* $NetBSD: linux32_signal.h,v 1.2 2009/06/08 14:42:10 njoly Exp $ */ 2 3 /*- 4 * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Emmanuel Dreyfus 17 * 4. The name of the author may not be used to endorse or promote 18 * products derived from this software without specific prior written 19 * permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS'' 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 #ifndef _AMD64_LINUX32_SIGNAL_H_ 34 #define _AMD64_LINUX32_SIGNAL_H_ 35 36 #define native_to_linux32_signo native_to_linux_signo 37 #define linux32_to_native_signo linux_to_native_signo 38 39 typedef netbsd32_pointer_t linux32_handler_t; 40 typedef netbsd32_pointer_t linux32_restorer_t; 41 typedef netbsd32_pointer_t linux32_siginfop_t; 42 typedef netbsd32_pointer_t linux32_ucontextp_t; 43 typedef netbsd32_pointer_t linux32_sigcontextp_t; 44 typedef netbsd32_pointer_t linux32_fpstatep_t; 45 typedef u_int32_t linux32_old_sigset_t; 46 47 #define LINUX32__NSIG 64 48 #define LINUX32__NSIG_BPW 32 49 #define LINUX32__NSIG_WORDS (LINUX32__NSIG / LINUX32__NSIG_BPW) 50 51 #define LINUX32_SIG_BLOCK 0 52 #define LINUX32_SIG_UNBLOCK 1 53 #define LINUX32_SIG_SETMASK 2 54 55 #define LINUX32_SA_NOCLDSTOP 0x00000001 56 #define LINUX32_SA_NOCLDWAIT 0x00000002 57 #define LINUX32_SA_SIGINFO 0x00000004 58 #define LINUX32_SA_RESTORER 0x04000000 59 #define LINUX32_SA_ONSTACK 0x08000000 60 #define LINUX32_SA_RESTART 0x10000000 61 #define LINUX32_SA_INTERRUPT 0x20000000 62 #define LINUX32_SA_NOMASK 0x40000000 63 #define LINUX32_SA_ONESHOT 0x80000000 64 #define LINUX32_SA_ALLBITS 0xfc000007 65 66 #define LINUX32_SS_ONSTACK 1 67 #define LINUX32_SS_DISABLE 2 68 69 /* 70 * We only define the ones used in linux32_machdep.c, since they are 71 * the same on i386 and amd64... 72 */ 73 #define LINUX32_SIGILL LINUX_SIGILL 74 #define LINUX32_SIGFPE LINUX_SIGFPE 75 #define LINUX32_SIGSEGV LINUX_SIGSEGV 76 #define LINUX32_SIGBUS LINUX_SIGBUS 77 #define LINUX32_SIGTRAP LINUX_SIGTRAP 78 #define LINUX32_SIGCHLD LINUX_SIGCHLD 79 #define LINUX32_SIGIO LINUX_SIGIO 80 #define LINUX32_SIGALRM LINUX_SIGALRM 81 #define LINUX32_SIGRTMIN LINUX_SIGRTMIN 82 83 typedef struct { 84 u_int32_t sig[LINUX32__NSIG_WORDS]; 85 } linux32_sigset_t; 86 87 struct linux32_sigaction { 88 linux32_handler_t linux_sa_handler; 89 u_int32_t linux_sa_flags; 90 linux32_restorer_t linux_sa_restorer; 91 linux32_sigset_t linux_sa_mask; 92 }; 93 94 typedef union linux32_sigval { 95 int sival_int; 96 netbsd32_voidp sival_ptr; 97 } linux32_sigval_t; 98 99 #define SI_MAX_SIZE 128 100 #define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) 101 102 typedef struct linux32_siginfo { 103 int lsi_signo; 104 int lsi_errno; 105 int lsi_code; 106 union { 107 int _pad[SI_PAD_SIZE]; 108 109 /* kill() */ 110 struct { 111 linux32_pid_t _pid; 112 linux32_uid_t _uid; 113 } _kill; 114 115 /* POSIX.1b signals */ 116 struct { 117 linux32_pid_t _pid; 118 linux32_uid_t _uid; 119 linux32_sigval_t _sigval; 120 } _rt; 121 122 /* POSIX.1b timers */ 123 struct { 124 unsigned int _timer1; 125 unsigned int _timer2; 126 } _timer; 127 128 /* SIGCHLD */ 129 struct { 130 linux32_pid_t _pid; 131 linux32_uid_t _uid; 132 int _status; 133 linux32_clock_t _utime; 134 linux32_clock_t _stime; 135 } _sigchld; 136 137 /* SIGPOLL */ 138 struct { 139 int _band; 140 int _fd; 141 } _sigpoll; 142 143 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 144 struct { 145 netbsd32_voidp _addr; 146 } _sigfault; 147 } _sidata; 148 } linux32_siginfo_t; 149 150 #define lsi_pid _sidata._kill._pid 151 #define lsi_uid _sidata._kill._uid 152 #define lsi_status _sidata._sigchld._status 153 #define lsi_utime _sidata._sigchld._utime 154 #define lsi_stime _sidata._sigchld._stime 155 #define lsi_value _sidata._rt._sigval 156 #define lsi_int _sidata._rt._sigval.sival_int 157 #define lsi_ptr _sidata._rt._sigval.sival_ptr 158 #define lsi_addr _sidata._sigfault._addr 159 #define lsi_band _sidata._sigpoll._band 160 #define lsi_fd _sidata._sigpoll._fd 161 162 /* 163 * si_code values for non-signals 164 */ 165 #define LINUX32_SI_USER 0 166 #define LINUX32_SI_KERNEL 0x80 167 #define LINUX32_SI_QUEUE -1 168 #define LINUX32_SI_TIMER -2 169 #define LINUX32_SI_MESGQ -3 170 #define LINUX32_SI_ASYNCIO -4 171 #define LINUX32_SI_SIGIO -5 172 #define LINUX32_SI_SIGNL -6 173 174 /* si_code values for SIGILL */ 175 #define LINUX32_ILL_ILLOPC 1 176 #define LINUX32_ILL_ILLOPN 2 177 #define LINUX32_ILL_ILLADR 3 178 #define LINUX32_ILL_ILLTRP 4 179 #define LINUX32_ILL_PRVOPC 5 180 #define LINUX32_ILL_PRVREG 6 181 #define LINUX32_ILL_COPROC 7 182 #define LINUX32_ILL_BADSTK 8 183 184 /* si_code values for SIGFPE */ 185 #define LINUX32_FPE_INTDIV 1 186 #define LINUX32_FPE_INTOVF 2 187 #define LINUX32_FPE_FLTDIV 3 188 #define LINUX32_FPE_FLTOVF 4 189 #define LINUX32_FPE_FLTUND 5 190 #define LINUX32_FPE_FLTRES 6 191 #define LINUX32_FPE_FLTINV 7 192 #define LINUX32_FPE_FLTSUB 8 193 194 /* si_code values for SIGSEGV */ 195 #define LINUX32_SEGV_MAPERR 1 196 #define LINUX32_SEGV_ACCERR 2 197 198 /* si_code values for SIGBUS */ 199 #define LINUX32_BUS_ADRALN 1 200 #define LINUX32_BUS_ADRERR 2 201 #define LINUX32_BUS_OBJERR 3 202 203 /* si_code values for SIGTRAP */ 204 #define LINUX32_TRAP_BRKPT 1 205 #define LINUX32_TRAP_TRACE 2 206 207 /* si_code values for SIGCHLD */ 208 #define LINUX32_CLD_EXITED 1 209 #define LINUX32_CLD_KILLED 2 210 #define LINUX32_CLD_DUMPED 3 211 #define LINUX32_CLD_TRAPPED 4 212 #define LINUX32_CLD_STOPPED 5 213 #define LINUX32_CLD_CONTINUED 6 214 215 /* si_code values for SIGPOLL */ 216 #define LINUX32_POLL_IN 1 217 #define LINUX32_POLL_OUT 2 218 #define LINUX32_POLL_MSG 3 219 #define LINUX32_POLL_ERR 4 220 #define LINUX32_POLL_PRI 5 221 #define LINUX32_POLL_HUP 6 222 223 #define LINUX32_SI_FROMUSER(sp) ((sp)->si_code <= 0) 224 #define LINUX32_SI_FROMKERNEL(sp) ((sp)->si_code > 0) 225 226 struct linux32_sigaltstack { 227 netbsd32_voidp ss_sp; 228 int ss_flags; 229 netbsd32_size_t ss_size; 230 }; 231 232 struct linux32_sigcontext { 233 int sc_gs; 234 int sc_fs; 235 int sc_es; 236 int sc_ds; 237 int sc_edi; 238 int sc_esi; 239 int sc_ebp; 240 int sc_esp; 241 int sc_ebx; 242 int sc_edx; 243 int sc_ecx; 244 int sc_eax; 245 int sc_trapno; 246 int sc_err; 247 int sc_eip; 248 int sc_cs; 249 int sc_eflags; 250 int sc_esp_at_signal; 251 int sc_ss; 252 linux32_fpstatep_t sc_387; 253 /* XXX check this */ 254 linux32_old_sigset_t sc_mask; 255 int sc_cr2; 256 }; 257 258 struct linux32_libc_fpreg { 259 unsigned short significand[4]; 260 unsigned short exponent; 261 }; 262 263 struct linux32_libc_fpstate { 264 u_int32_t cw; 265 u_int32_t sw; 266 u_int32_t tag; 267 u_int32_t ipoff; 268 u_int32_t cssel; 269 u_int32_t dataoff; 270 u_int32_t datasel; 271 struct linux32_libc_fpreg _st[8]; 272 u_int32_t status; 273 }; 274 275 struct linux32_ucontext { 276 u_int32_t uc_flags; 277 linux32_ucontextp_t uc_link; 278 struct linux32_sigaltstack uc_stack; 279 struct linux32_sigcontext uc_mcontext; 280 linux32_sigset_t uc_sigmask; 281 struct linux32_libc_fpstate uc_fpregs_mem; 282 }; 283 284 struct linux32_rt_sigframe { 285 int sf_sig; 286 linux32_siginfop_t sf_sip; 287 linux32_ucontextp_t sf_ucp; 288 struct linux32_siginfo sf_si; 289 struct linux32_ucontext sf_uc; 290 linux32_handler_t sf_handler; 291 }; 292 293 struct linux32_sigframe { 294 int sf_sig; 295 struct linux32_sigcontext sf_sc; 296 linux32_handler_t sf_handler; 297 }; 298 299 #endif /* _AMD64_LINUX32_SIGNAL_H_ */ 300