1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2001 Doug Rabson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ 30 #define _COMPAT_FREEBSD32_FREEBSD32_H_ 31 32 #include <sys/abi_compat.h> 33 #include <sys/procfs.h> 34 #include <sys/socket.h> 35 #include <sys/user.h> 36 37 /* 38 * i386 is the only arch with a 32-bit time_t 39 */ 40 #ifdef __amd64__ 41 typedef int32_t time32_t; 42 #else 43 typedef int64_t time32_t; 44 #endif 45 46 struct timeval32 { 47 time32_t tv_sec; 48 int32_t tv_usec; 49 }; 50 51 struct timespec32 { 52 time32_t tv_sec; 53 int32_t tv_nsec; 54 }; 55 56 struct itimerspec32 { 57 struct timespec32 it_interval; 58 struct timespec32 it_value; 59 }; 60 61 struct bintime32 { 62 time32_t sec; 63 uint32_t frac[2]; 64 }; 65 66 struct rusage32 { 67 struct timeval32 ru_utime; 68 struct timeval32 ru_stime; 69 int32_t ru_maxrss; 70 int32_t ru_ixrss; 71 int32_t ru_idrss; 72 int32_t ru_isrss; 73 int32_t ru_minflt; 74 int32_t ru_majflt; 75 int32_t ru_nswap; 76 int32_t ru_inblock; 77 int32_t ru_oublock; 78 int32_t ru_msgsnd; 79 int32_t ru_msgrcv; 80 int32_t ru_nsignals; 81 int32_t ru_nvcsw; 82 int32_t ru_nivcsw; 83 }; 84 85 struct wrusage32 { 86 struct rusage32 wru_self; 87 struct rusage32 wru_children; 88 }; 89 90 struct itimerval32 { 91 struct timeval32 it_interval; 92 struct timeval32 it_value; 93 }; 94 95 struct umtx_time32 { 96 struct timespec32 _timeout; 97 uint32_t _flags; 98 uint32_t _clockid; 99 }; 100 101 struct umtx_robust_lists_params_compat32 { 102 uint32_t robust_list_offset; 103 uint32_t robust_priv_list_offset; 104 uint32_t robust_inact_offset; 105 }; 106 107 struct umutex32 { 108 volatile __lwpid_t m_owner; /* Owner of the mutex */ 109 __uint32_t m_flags; /* Flags of the mutex */ 110 __uint32_t m_ceilings[2]; /* Priority protect ceiling */ 111 __uint32_t m_rb_lnk; /* Robust linkage */ 112 __uint32_t m_pad; 113 __uint32_t m_spare[2]; 114 }; 115 116 #define FREEBSD4_MFSNAMELEN 16 117 #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) 118 119 /* 4.x version */ 120 struct statfs32 { 121 int32_t f_spare2; 122 int32_t f_bsize; 123 int32_t f_iosize; 124 int32_t f_blocks; 125 int32_t f_bfree; 126 int32_t f_bavail; 127 int32_t f_files; 128 int32_t f_ffree; 129 fsid_t f_fsid; 130 uid_t f_owner; 131 int32_t f_type; 132 int32_t f_flags; 133 int32_t f_syncwrites; 134 int32_t f_asyncwrites; 135 char f_fstypename[FREEBSD4_MFSNAMELEN]; 136 char f_mntonname[FREEBSD4_MNAMELEN]; 137 int32_t f_syncreads; 138 int32_t f_asyncreads; 139 int16_t f_spares1; 140 char f_mntfromname[FREEBSD4_MNAMELEN]; 141 int16_t f_spares2 __packed; 142 int32_t f_spare[2]; 143 }; 144 145 struct iovec32 { 146 u_int32_t iov_base; 147 int iov_len; 148 }; 149 150 struct msghdr32 { 151 u_int32_t msg_name; 152 socklen_t msg_namelen; 153 u_int32_t msg_iov; 154 int msg_iovlen; 155 u_int32_t msg_control; 156 socklen_t msg_controllen; 157 int msg_flags; 158 }; 159 160 #if defined(__amd64__) 161 #define __STAT32_TIME_T_EXT 1 162 #endif 163 164 struct stat32 { 165 dev_t st_dev; 166 ino_t st_ino; 167 nlink_t st_nlink; 168 mode_t st_mode; 169 u_int16_t st_padding0; 170 uid_t st_uid; 171 gid_t st_gid; 172 u_int32_t st_padding1; 173 dev_t st_rdev; 174 #ifdef __STAT32_TIME_T_EXT 175 __int32_t st_atim_ext; 176 #endif 177 struct timespec32 st_atim; 178 #ifdef __STAT32_TIME_T_EXT 179 __int32_t st_mtim_ext; 180 #endif 181 struct timespec32 st_mtim; 182 #ifdef __STAT32_TIME_T_EXT 183 __int32_t st_ctim_ext; 184 #endif 185 struct timespec32 st_ctim; 186 #ifdef __STAT32_TIME_T_EXT 187 __int32_t st_btim_ext; 188 #endif 189 struct timespec32 st_birthtim; 190 off_t st_size; 191 int64_t st_blocks; 192 u_int32_t st_blksize; 193 u_int32_t st_flags; 194 u_int64_t st_gen; 195 u_int64_t st_spare[10]; 196 }; 197 struct freebsd11_stat32 { 198 u_int32_t st_dev; 199 u_int32_t st_ino; 200 mode_t st_mode; 201 u_int16_t st_nlink; 202 uid_t st_uid; 203 gid_t st_gid; 204 u_int32_t st_rdev; 205 struct timespec32 st_atim; 206 struct timespec32 st_mtim; 207 struct timespec32 st_ctim; 208 off_t st_size; 209 int64_t st_blocks; 210 u_int32_t st_blksize; 211 u_int32_t st_flags; 212 u_int32_t st_gen; 213 int32_t st_lspare; 214 struct timespec32 st_birthtim; 215 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 216 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 217 }; 218 219 struct ostat32 { 220 __uint16_t st_dev; 221 __uint32_t st_ino; 222 mode_t st_mode; 223 __uint16_t st_nlink; 224 __uint16_t st_uid; 225 __uint16_t st_gid; 226 __uint16_t st_rdev; 227 __int32_t st_size; 228 struct timespec32 st_atim; 229 struct timespec32 st_mtim; 230 struct timespec32 st_ctim; 231 __int32_t st_blksize; 232 __int32_t st_blocks; 233 u_int32_t st_flags; 234 __uint32_t st_gen; 235 }; 236 237 struct jail32_v0 { 238 u_int32_t version; 239 uint32_t path; 240 uint32_t hostname; 241 u_int32_t ip_number; 242 }; 243 244 struct jail32 { 245 uint32_t version; 246 uint32_t path; 247 uint32_t hostname; 248 uint32_t jailname; 249 uint32_t ip4s; 250 uint32_t ip6s; 251 uint32_t ip4; 252 uint32_t ip6; 253 }; 254 255 struct sigaction32 { 256 u_int32_t sa_u; 257 int sa_flags; 258 sigset_t sa_mask; 259 }; 260 261 struct thr_param32 { 262 uint32_t start_func; 263 uint32_t arg; 264 uint32_t stack_base; 265 uint32_t stack_size; 266 uint32_t tls_base; 267 uint32_t tls_size; 268 uint32_t child_tid; 269 uint32_t parent_tid; 270 int32_t flags; 271 uint32_t rtp; 272 uint32_t spare[3]; 273 }; 274 275 struct i386_ldt_args32 { 276 uint32_t start; 277 uint32_t descs; 278 uint32_t num; 279 }; 280 281 struct mq_attr32 { 282 int mq_flags; 283 int mq_maxmsg; 284 int mq_msgsize; 285 int mq_curmsgs; 286 int __reserved[4]; 287 }; 288 289 struct kinfo_proc32 { 290 int ki_structsize; 291 int ki_layout; 292 uint32_t ki_args; 293 uint32_t ki_paddr; 294 uint32_t ki_addr; 295 uint32_t ki_tracep; 296 uint32_t ki_textvp; 297 uint32_t ki_fd; 298 uint32_t ki_vmspace; 299 uint32_t ki_wchan; 300 pid_t ki_pid; 301 pid_t ki_ppid; 302 pid_t ki_pgid; 303 pid_t ki_tpgid; 304 pid_t ki_sid; 305 pid_t ki_tsid; 306 short ki_jobc; 307 short ki_spare_short1; 308 uint32_t ki_tdev_freebsd11; 309 sigset_t ki_siglist; 310 sigset_t ki_sigmask; 311 sigset_t ki_sigignore; 312 sigset_t ki_sigcatch; 313 uid_t ki_uid; 314 uid_t ki_ruid; 315 uid_t ki_svuid; 316 gid_t ki_rgid; 317 gid_t ki_svgid; 318 short ki_ngroups; 319 short ki_spare_short2; 320 gid_t ki_groups[KI_NGROUPS]; 321 uint32_t ki_size; 322 int32_t ki_rssize; 323 int32_t ki_swrss; 324 int32_t ki_tsize; 325 int32_t ki_dsize; 326 int32_t ki_ssize; 327 u_short ki_xstat; 328 u_short ki_acflag; 329 fixpt_t ki_pctcpu; 330 u_int ki_estcpu; 331 u_int ki_slptime; 332 u_int ki_swtime; 333 u_int ki_cow; 334 u_int64_t ki_runtime; 335 struct timeval32 ki_start; 336 struct timeval32 ki_childtime; 337 int ki_flag; 338 int ki_kiflag; 339 int ki_traceflag; 340 char ki_stat; 341 signed char ki_nice; 342 char ki_lock; 343 char ki_rqindex; 344 u_char ki_oncpu_old; 345 u_char ki_lastcpu_old; 346 char ki_tdname[TDNAMLEN+1]; 347 char ki_wmesg[WMESGLEN+1]; 348 char ki_login[LOGNAMELEN+1]; 349 char ki_lockname[LOCKNAMELEN+1]; 350 char ki_comm[COMMLEN+1]; 351 char ki_emul[KI_EMULNAMELEN+1]; 352 char ki_loginclass[LOGINCLASSLEN+1]; 353 char ki_moretdname[MAXCOMLEN-TDNAMLEN+1]; 354 char ki_sparestrings[46]; 355 int ki_spareints[KI_NSPARE_INT]; 356 uint64_t ki_tdev; 357 int ki_oncpu; 358 int ki_lastcpu; 359 int ki_tracer; 360 int ki_flag2; 361 int ki_fibnum; 362 u_int ki_cr_flags; 363 int ki_jid; 364 int ki_numthreads; 365 lwpid_t ki_tid; 366 struct priority ki_pri; 367 struct rusage32 ki_rusage; 368 struct rusage32 ki_rusage_ch; 369 uint32_t ki_pcb; 370 uint32_t ki_kstack; 371 uint32_t ki_udata; 372 uint32_t ki_tdaddr; 373 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 374 int ki_sparelongs[KI_NSPARE_LONG]; 375 int ki_sflag; 376 int ki_tdflags; 377 }; 378 379 struct kinfo_sigtramp32 { 380 uint32_t ksigtramp_start; 381 uint32_t ksigtramp_end; 382 uint32_t ksigtramp_spare[4]; 383 }; 384 385 struct kld32_file_stat_1 { 386 int version; /* set to sizeof(struct kld_file_stat_1) */ 387 char name[MAXPATHLEN]; 388 int refs; 389 int id; 390 uint32_t address; /* load address */ 391 uint32_t size; /* size in bytes */ 392 }; 393 394 struct kld32_file_stat { 395 int version; /* set to sizeof(struct kld_file_stat) */ 396 char name[MAXPATHLEN]; 397 int refs; 398 int id; 399 uint32_t address; /* load address */ 400 uint32_t size; /* size in bytes */ 401 char pathname[MAXPATHLEN]; 402 }; 403 404 struct procctl_reaper_pids32 { 405 u_int rp_count; 406 u_int rp_pad0[15]; 407 uint32_t rp_pids; 408 }; 409 410 struct timex32 { 411 unsigned int modes; 412 int32_t offset; 413 int32_t freq; 414 int32_t maxerror; 415 int32_t esterror; 416 int status; 417 int32_t constant; 418 int32_t precision; 419 int32_t tolerance; 420 int32_t ppsfreq; 421 int32_t jitter; 422 int shift; 423 int32_t stabil; 424 int32_t jitcnt; 425 int32_t calcnt; 426 int32_t errcnt; 427 int32_t stbcnt; 428 }; 429 430 struct ptrace_sc_ret32 { 431 uint32_t sr_retval[2]; 432 int sr_error; 433 }; 434 435 struct ptrace_coredump32 { 436 int pc_fd; 437 uint32_t pc_flags; 438 uint32_t pc_limit1, pc_limit2; 439 }; 440 441 struct ptrace_sc_remote32 { 442 struct ptrace_sc_ret32 pscr_ret; 443 u_int pscr_syscall; 444 u_int pscr_nargs; 445 uint32_t pscr_args; 446 }; 447 448 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 449