1 /*
2  *  FreeBSD siginfo related definitions
3  *
4  *  Copyright (c) 2013 Stacey D. Son
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef _TARGET_OS_SIGINFO_H_
20 #define _TARGET_OS_SIGINFO_H_
21 
22 #define TARGET_NSIG         128
23 #define TARGET_NSIG_BPW     (sizeof(uint32_t) * 8)
24 #define TARGET_NSIG_WORDS   (TARGET_NSIG / TARGET_NSIG_BPW)
25 
26 /* this struct defines a stack used during syscall handling */
27 typedef struct target_sigaltstack {
28     abi_long    ss_sp;
29     abi_ulong   ss_size;
30     abi_long    ss_flags;
31 } target_stack_t;
32 
33 typedef struct {
34     uint32_t __bits[TARGET_NSIG_WORDS];
35 } target_sigset_t;
36 
37 struct target_sigaction {
38     abi_ulong   _sa_handler;
39     int32_t     sa_flags;
40     target_sigset_t sa_mask;
41 };
42 
43 typedef union target_sigval {
44     int32_t sival_int;
45     abi_ulong sival_ptr;
46     int32_t sigval_int;
47     abi_ulong sigval_ptr;
48 } target_sigval_t;
49 
50 typedef struct target_siginfo {
51     int32_t si_signo;   /* signal number */
52     int32_t si_errno;   /* errno association */
53     int32_t si_code;    /* signal code */
54     int32_t si_pid;     /* sending process */
55     int32_t si_uid;     /* sender's ruid */
56     int32_t si_status;  /* exit value */
57     abi_ulong si_addr;  /* faulting instruction */
58     union target_sigval si_value;   /* signal value */
59     union {
60         struct {
61             int32_t _trapno;    /* machine specific trap code */
62         } _fault;
63 
64         /* POSIX.1b timers */
65         struct {
66             int32_t _timerid;
67             int32_t _overrun;
68         } _timer;
69 
70         struct {
71             int32_t _mqd;
72         } _mesgp;
73 
74         /* SIGPOLL */
75         struct {
76             int _band;  /* POLL_IN, POLL_OUT, POLL_MSG */
77         } _poll;
78 
79         struct {
80             abi_long __spare1__;
81             int32_t  __spare2_[7];
82         } __spare__;
83     } _reason;
84 } target_siginfo_t;
85 
86 struct target_sigevent {
87     abi_int sigev_notify;
88     abi_int sigev_signo;
89     target_sigval_t sigev_value;
90     union {
91         abi_int _threadid;
92 
93         /*
94          * The kernel (and thus QEMU) never looks at these;
95          * they're only used as part of the ABI between a
96          * userspace program and libc.
97          */
98         struct {
99             abi_ulong _function;
100             abi_ulong _attribute;
101         } _sigev_thread;
102         abi_ushort _kevent_flags;
103         abi_long _pad[8];
104     } _sigev_un;
105 };
106 
107 #define target_si_signo     si_signo
108 #define target_si_code      si_code
109 #define target_si_errno     si_errno
110 #define target_si_addr      si_addr
111 
112 /* SIGILL si_codes */
113 #define TARGET_ILL_ILLOPC   (1) /* Illegal opcode. */
114 #define TARGET_ILL_ILLOPN   (2) /* Illegal operand. */
115 #define TARGET_ILL_ILLADR   (3) /* Illegal addressing mode. */
116 #define TARGET_ILL_ILLTRP   (4) /* Illegal trap. */
117 #define TARGET_ILL_PRVOPC   (5) /* Privileged opcode. */
118 #define TARGET_ILL_PRVREG   (6) /* Privileged register. */
119 #define TARGET_ILL_COPROC   (7) /* Coprocessor error. */
120 #define TARGET_ILL_BADSTK   (8) /* Internal stack error. */
121 
122 /* SIGSEGV si_codes */
123 #define TARGET_SEGV_MAPERR  (1) /* address not mapped to object */
124 #define TARGET_SEGV_ACCERR  (2) /* invalid permissions for mapped object */
125 
126 /* SIGTRAP si_codes */
127 #define TARGET_TRAP_BRKPT   (1) /* process beakpoint */
128 #define TARGET_TRAP_TRACE   (2) /* process trace trap */
129 
130 /* SIGBUS si_codes */
131 #define TARGET_BUS_ADRALN   (1)
132 #define TARGET_BUS_ADRERR   (2)
133 #define TARGET_BUS_OBJERR   (3)
134 
135 /* SIGFPE codes */
136 #define TARGET_FPE_INTOVF   (1) /* Integer overflow. */
137 #define TARGET_FPE_INTDIV   (2) /* Integer divide by zero. */
138 #define TARGET_FPE_FLTDIV   (3) /* Floating point divide by zero. */
139 #define TARGET_FPE_FLTOVF   (4) /* Floating point overflow. */
140 #define TARGET_FPE_FLTUND   (5) /* Floating point underflow. */
141 #define TARGET_FPE_FLTRES   (6) /* Floating point inexact result. */
142 #define TARGET_FPE_FLTINV   (7) /* Invalid floating point operation. */
143 #define TARGET_FPE_FLTSUB   (8) /* Subscript out of range. */
144 
145 #endif /* !_TARGET_OS_SIGINFO_H_ */
146