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