1 /*- 2 * Copyright (c) 2001 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ 30 #define _COMPAT_FREEBSD32_FREEBSD32_H_ 31 32 #include <sys/procfs.h> 33 #include <sys/socket.h> 34 #include <sys/user.h> 35 36 #define PTRIN(v) (void *)(uintptr_t) (v) 37 #define PTROUT(v) (u_int32_t)(uintptr_t) (v) 38 39 #define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) 40 #define PTRIN_CP(src,dst,fld) \ 41 do { (dst).fld = PTRIN((src).fld); } while (0) 42 #define PTROUT_CP(src,dst,fld) \ 43 do { (dst).fld = PTROUT((src).fld); } while (0) 44 45 struct timeval32 { 46 int32_t tv_sec; 47 int32_t tv_usec; 48 }; 49 #define TV_CP(src,dst,fld) do { \ 50 CP((src).fld,(dst).fld,tv_sec); \ 51 CP((src).fld,(dst).fld,tv_usec); \ 52 } while (0) 53 54 struct timespec32 { 55 u_int32_t tv_sec; 56 u_int32_t tv_nsec; 57 }; 58 #define TS_CP(src,dst,fld) do { \ 59 CP((src).fld,(dst).fld,tv_sec); \ 60 CP((src).fld,(dst).fld,tv_nsec); \ 61 } while (0); 62 63 struct rusage32 { 64 struct timeval32 ru_utime; 65 struct timeval32 ru_stime; 66 int32_t ru_maxrss; 67 int32_t ru_ixrss; 68 int32_t ru_idrss; 69 int32_t ru_isrss; 70 int32_t ru_minflt; 71 int32_t ru_majflt; 72 int32_t ru_nswap; 73 int32_t ru_inblock; 74 int32_t ru_oublock; 75 int32_t ru_msgsnd; 76 int32_t ru_msgrcv; 77 int32_t ru_nsignals; 78 int32_t ru_nvcsw; 79 int32_t ru_nivcsw; 80 }; 81 82 struct itimerval32 { 83 struct timeval32 it_interval; 84 struct timeval32 it_value; 85 }; 86 87 #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ 88 89 /* 4.x version */ 90 struct statfs32 { 91 int32_t f_spare2; 92 int32_t f_bsize; 93 int32_t f_iosize; 94 int32_t f_blocks; 95 int32_t f_bfree; 96 int32_t f_bavail; 97 int32_t f_files; 98 int32_t f_ffree; 99 fsid_t f_fsid; 100 uid_t f_owner; 101 int32_t f_type; 102 int32_t f_flags; 103 int32_t f_syncwrites; 104 int32_t f_asyncwrites; 105 char f_fstypename[MFSNAMELEN]; 106 char f_mntonname[FREEBSD4_MNAMELEN]; 107 int32_t f_syncreads; 108 int32_t f_asyncreads; 109 int16_t f_spares1; 110 char f_mntfromname[FREEBSD4_MNAMELEN]; 111 int16_t f_spares2 __packed; 112 int32_t f_spare[2]; 113 }; 114 115 struct kevent32 { 116 u_int32_t ident; /* identifier for this event */ 117 short filter; /* filter for event */ 118 u_short flags; 119 u_int fflags; 120 int32_t data; 121 u_int32_t udata; /* opaque user data identifier */ 122 }; 123 124 struct iovec32 { 125 u_int32_t iov_base; 126 int iov_len; 127 }; 128 129 struct msghdr32 { 130 u_int32_t msg_name; 131 socklen_t msg_namelen; 132 u_int32_t msg_iov; 133 int msg_iovlen; 134 u_int32_t msg_control; 135 socklen_t msg_controllen; 136 int msg_flags; 137 }; 138 139 struct stat32 { 140 dev_t st_dev; 141 ino_t st_ino; 142 mode_t st_mode; 143 nlink_t st_nlink; 144 uid_t st_uid; 145 gid_t st_gid; 146 dev_t st_rdev; 147 struct timespec32 st_atim; 148 struct timespec32 st_mtim; 149 struct timespec32 st_ctim; 150 off_t st_size; 151 int64_t st_blocks; 152 u_int32_t st_blksize; 153 u_int32_t st_flags; 154 u_int32_t st_gen; 155 struct timespec32 st_birthtim; 156 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 157 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 158 }; 159 160 struct ostat32 { 161 __uint16_t st_dev; 162 ino_t st_ino; 163 mode_t st_mode; 164 nlink_t st_nlink; 165 __uint16_t st_uid; 166 __uint16_t st_gid; 167 __uint16_t st_rdev; 168 __int32_t st_size; 169 struct timespec32 st_atim; 170 struct timespec32 st_mtim; 171 struct timespec32 st_ctim; 172 __int32_t st_blksize; 173 __int32_t st_blocks; 174 u_int32_t st_flags; 175 __uint32_t st_gen; 176 }; 177 178 struct jail32_v0 { 179 u_int32_t version; 180 uint32_t path; 181 uint32_t hostname; 182 u_int32_t ip_number; 183 }; 184 185 struct jail32 { 186 uint32_t version; 187 uint32_t path; 188 uint32_t hostname; 189 uint32_t jailname; 190 uint32_t ip4s; 191 uint32_t ip6s; 192 uint32_t ip4; 193 uint32_t ip6; 194 }; 195 196 struct sigaction32 { 197 u_int32_t sa_u; 198 int sa_flags; 199 sigset_t sa_mask; 200 }; 201 202 struct thr_param32 { 203 uint32_t start_func; 204 uint32_t arg; 205 uint32_t stack_base; 206 uint32_t stack_size; 207 uint32_t tls_base; 208 uint32_t tls_size; 209 uint32_t child_tid; 210 uint32_t parent_tid; 211 int32_t flags; 212 uint32_t rtp; 213 uint32_t spare[3]; 214 }; 215 216 struct i386_ldt_args32 { 217 uint32_t start; 218 uint32_t descs; 219 uint32_t num; 220 }; 221 222 /* 223 * Alternative layouts for <sys/procfs.h> 224 */ 225 struct prstatus32 { 226 int pr_version; 227 u_int pr_statussz; 228 u_int pr_gregsetsz; 229 u_int pr_fpregsetsz; 230 int pr_osreldate; 231 int pr_cursig; 232 pid_t pr_pid; 233 struct reg32 pr_reg; 234 }; 235 236 struct prpsinfo32 { 237 int pr_version; 238 u_int pr_psinfosz; 239 char pr_fname[PRFNAMESZ+1]; 240 char pr_psargs[PRARGSZ+1]; 241 }; 242 243 struct thrmisc32 { 244 char pr_tname[MAXCOMLEN+1]; 245 u_int _pad; 246 }; 247 248 struct mq_attr32 { 249 int mq_flags; 250 int mq_maxmsg; 251 int mq_msgsize; 252 int mq_curmsgs; 253 int __reserved[4]; 254 }; 255 256 struct kinfo_proc32 { 257 int ki_structsize; 258 int ki_layout; 259 uint32_t ki_args; 260 uint32_t ki_paddr; 261 uint32_t ki_addr; 262 uint32_t ki_tracep; 263 uint32_t ki_textvp; 264 uint32_t ki_fd; 265 uint32_t ki_vmspace; 266 uint32_t ki_wchan; 267 pid_t ki_pid; 268 pid_t ki_ppid; 269 pid_t ki_pgid; 270 pid_t ki_tpgid; 271 pid_t ki_sid; 272 pid_t ki_tsid; 273 short ki_jobc; 274 short ki_spare_short1; 275 dev_t ki_tdev; 276 sigset_t ki_siglist; 277 sigset_t ki_sigmask; 278 sigset_t ki_sigignore; 279 sigset_t ki_sigcatch; 280 uid_t ki_uid; 281 uid_t ki_ruid; 282 uid_t ki_svuid; 283 gid_t ki_rgid; 284 gid_t ki_svgid; 285 short ki_ngroups; 286 short ki_spare_short2; 287 gid_t ki_groups[KI_NGROUPS]; 288 uint32_t ki_size; 289 int32_t ki_rssize; 290 int32_t ki_swrss; 291 int32_t ki_tsize; 292 int32_t ki_dsize; 293 int32_t ki_ssize; 294 u_short ki_xstat; 295 u_short ki_acflag; 296 fixpt_t ki_pctcpu; 297 u_int ki_estcpu; 298 u_int ki_slptime; 299 u_int ki_swtime; 300 int ki_spareint1; 301 u_int64_t ki_runtime; 302 struct timeval32 ki_start; 303 struct timeval32 ki_childtime; 304 int ki_flag; 305 int ki_kiflag; 306 int ki_traceflag; 307 char ki_stat; 308 signed char ki_nice; 309 char ki_lock; 310 char ki_rqindex; 311 u_char ki_oncpu; 312 u_char ki_lastcpu; 313 char ki_ocomm[OCOMMLEN+1]; 314 char ki_wmesg[WMESGLEN+1]; 315 char ki_login[LOGNAMELEN+1]; 316 char ki_lockname[LOCKNAMELEN+1]; 317 char ki_comm[COMMLEN+1]; 318 char ki_emul[KI_EMULNAMELEN+1]; 319 char ki_loginclass[LOGINCLASSLEN+1]; 320 char ki_sparestrings[50]; 321 int ki_spareints[KI_NSPARE_INT]; 322 u_int ki_cr_flags; 323 int ki_jid; 324 int ki_numthreads; 325 lwpid_t ki_tid; 326 struct priority ki_pri; 327 struct rusage32 ki_rusage; 328 struct rusage32 ki_rusage_ch; 329 uint32_t ki_pcb; 330 uint32_t ki_kstack; 331 uint32_t ki_udata; 332 uint32_t ki_tdaddr; 333 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 334 int ki_sparelongs[KI_NSPARE_LONG]; 335 int ki_sflag; 336 int ki_tdflags; 337 }; 338 339 struct kld32_file_stat_1 { 340 int version; /* set to sizeof(struct kld_file_stat_1) */ 341 char name[MAXPATHLEN]; 342 int refs; 343 int id; 344 uint32_t address; /* load address */ 345 uint32_t size; /* size in bytes */ 346 }; 347 348 struct kld32_file_stat { 349 int version; /* set to sizeof(struct kld_file_stat) */ 350 char name[MAXPATHLEN]; 351 int refs; 352 int id; 353 uint32_t address; /* load address */ 354 uint32_t size; /* size in bytes */ 355 char pathname[MAXPATHLEN]; 356 }; 357 358 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 359