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 /* 46 * Being a newer port, 32-bit FreeBSD/MIPS uses 64-bit time_t. 47 */ 48 #ifdef __mips__ 49 typedef int64_t time32_t; 50 #else 51 typedef int32_t time32_t; 52 #endif 53 54 struct timeval32 { 55 time32_t tv_sec; 56 int32_t tv_usec; 57 }; 58 #define TV_CP(src,dst,fld) do { \ 59 CP((src).fld,(dst).fld,tv_sec); \ 60 CP((src).fld,(dst).fld,tv_usec); \ 61 } while (0) 62 63 struct timespec32 { 64 time32_t tv_sec; 65 int32_t tv_nsec; 66 }; 67 #define TS_CP(src,dst,fld) do { \ 68 CP((src).fld,(dst).fld,tv_sec); \ 69 CP((src).fld,(dst).fld,tv_nsec); \ 70 } while (0) 71 72 struct itimerspec32 { 73 struct timespec32 it_interval; 74 struct timespec32 it_value; 75 }; 76 #define ITS_CP(src, dst) do { \ 77 TS_CP((src), (dst), it_interval); \ 78 TS_CP((src), (dst), it_value); \ 79 } while (0) 80 81 struct rusage32 { 82 struct timeval32 ru_utime; 83 struct timeval32 ru_stime; 84 int32_t ru_maxrss; 85 int32_t ru_ixrss; 86 int32_t ru_idrss; 87 int32_t ru_isrss; 88 int32_t ru_minflt; 89 int32_t ru_majflt; 90 int32_t ru_nswap; 91 int32_t ru_inblock; 92 int32_t ru_oublock; 93 int32_t ru_msgsnd; 94 int32_t ru_msgrcv; 95 int32_t ru_nsignals; 96 int32_t ru_nvcsw; 97 int32_t ru_nivcsw; 98 }; 99 100 struct wrusage32 { 101 struct rusage32 wru_self; 102 struct rusage32 wru_children; 103 }; 104 105 struct itimerval32 { 106 struct timeval32 it_interval; 107 struct timeval32 it_value; 108 }; 109 110 #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ 111 112 /* 4.x version */ 113 struct statfs32 { 114 int32_t f_spare2; 115 int32_t f_bsize; 116 int32_t f_iosize; 117 int32_t f_blocks; 118 int32_t f_bfree; 119 int32_t f_bavail; 120 int32_t f_files; 121 int32_t f_ffree; 122 fsid_t f_fsid; 123 uid_t f_owner; 124 int32_t f_type; 125 int32_t f_flags; 126 int32_t f_syncwrites; 127 int32_t f_asyncwrites; 128 char f_fstypename[MFSNAMELEN]; 129 char f_mntonname[FREEBSD4_MNAMELEN]; 130 int32_t f_syncreads; 131 int32_t f_asyncreads; 132 int16_t f_spares1; 133 char f_mntfromname[FREEBSD4_MNAMELEN]; 134 int16_t f_spares2 __packed; 135 int32_t f_spare[2]; 136 }; 137 138 struct kevent32 { 139 u_int32_t ident; /* identifier for this event */ 140 short filter; /* filter for event */ 141 u_short flags; 142 u_int fflags; 143 int32_t data; 144 u_int32_t udata; /* opaque user data identifier */ 145 }; 146 147 struct iovec32 { 148 u_int32_t iov_base; 149 int iov_len; 150 }; 151 152 struct msghdr32 { 153 u_int32_t msg_name; 154 socklen_t msg_namelen; 155 u_int32_t msg_iov; 156 int msg_iovlen; 157 u_int32_t msg_control; 158 socklen_t msg_controllen; 159 int msg_flags; 160 }; 161 162 struct stat32 { 163 dev_t st_dev; 164 ino_t st_ino; 165 mode_t st_mode; 166 nlink_t st_nlink; 167 uid_t st_uid; 168 gid_t st_gid; 169 dev_t st_rdev; 170 struct timespec32 st_atim; 171 struct timespec32 st_mtim; 172 struct timespec32 st_ctim; 173 off_t st_size; 174 int64_t st_blocks; 175 u_int32_t st_blksize; 176 u_int32_t st_flags; 177 u_int32_t st_gen; 178 struct timespec32 st_birthtim; 179 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 180 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 181 }; 182 183 struct ostat32 { 184 __uint16_t st_dev; 185 ino_t st_ino; 186 mode_t st_mode; 187 nlink_t st_nlink; 188 __uint16_t st_uid; 189 __uint16_t st_gid; 190 __uint16_t st_rdev; 191 __int32_t st_size; 192 struct timespec32 st_atim; 193 struct timespec32 st_mtim; 194 struct timespec32 st_ctim; 195 __int32_t st_blksize; 196 __int32_t st_blocks; 197 u_int32_t st_flags; 198 __uint32_t st_gen; 199 }; 200 201 struct jail32_v0 { 202 u_int32_t version; 203 uint32_t path; 204 uint32_t hostname; 205 u_int32_t ip_number; 206 }; 207 208 struct jail32 { 209 uint32_t version; 210 uint32_t path; 211 uint32_t hostname; 212 uint32_t jailname; 213 uint32_t ip4s; 214 uint32_t ip6s; 215 uint32_t ip4; 216 uint32_t ip6; 217 }; 218 219 struct sigaction32 { 220 u_int32_t sa_u; 221 int sa_flags; 222 sigset_t sa_mask; 223 }; 224 225 struct thr_param32 { 226 uint32_t start_func; 227 uint32_t arg; 228 uint32_t stack_base; 229 uint32_t stack_size; 230 uint32_t tls_base; 231 uint32_t tls_size; 232 uint32_t child_tid; 233 uint32_t parent_tid; 234 int32_t flags; 235 uint32_t rtp; 236 uint32_t spare[3]; 237 }; 238 239 struct i386_ldt_args32 { 240 uint32_t start; 241 uint32_t descs; 242 uint32_t num; 243 }; 244 245 /* 246 * Alternative layouts for <sys/procfs.h> 247 */ 248 struct prstatus32 { 249 int pr_version; 250 u_int pr_statussz; 251 u_int pr_gregsetsz; 252 u_int pr_fpregsetsz; 253 int pr_osreldate; 254 int pr_cursig; 255 pid_t pr_pid; 256 struct reg32 pr_reg; 257 }; 258 259 struct prpsinfo32 { 260 int pr_version; 261 u_int pr_psinfosz; 262 char pr_fname[PRFNAMESZ+1]; 263 char pr_psargs[PRARGSZ+1]; 264 }; 265 266 struct thrmisc32 { 267 char pr_tname[MAXCOMLEN+1]; 268 u_int _pad; 269 }; 270 271 struct mq_attr32 { 272 int mq_flags; 273 int mq_maxmsg; 274 int mq_msgsize; 275 int mq_curmsgs; 276 int __reserved[4]; 277 }; 278 279 struct kinfo_proc32 { 280 int ki_structsize; 281 int ki_layout; 282 uint32_t ki_args; 283 uint32_t ki_paddr; 284 uint32_t ki_addr; 285 uint32_t ki_tracep; 286 uint32_t ki_textvp; 287 uint32_t ki_fd; 288 uint32_t ki_vmspace; 289 uint32_t ki_wchan; 290 pid_t ki_pid; 291 pid_t ki_ppid; 292 pid_t ki_pgid; 293 pid_t ki_tpgid; 294 pid_t ki_sid; 295 pid_t ki_tsid; 296 short ki_jobc; 297 short ki_spare_short1; 298 dev_t ki_tdev; 299 sigset_t ki_siglist; 300 sigset_t ki_sigmask; 301 sigset_t ki_sigignore; 302 sigset_t ki_sigcatch; 303 uid_t ki_uid; 304 uid_t ki_ruid; 305 uid_t ki_svuid; 306 gid_t ki_rgid; 307 gid_t ki_svgid; 308 short ki_ngroups; 309 short ki_spare_short2; 310 gid_t ki_groups[KI_NGROUPS]; 311 uint32_t ki_size; 312 int32_t ki_rssize; 313 int32_t ki_swrss; 314 int32_t ki_tsize; 315 int32_t ki_dsize; 316 int32_t ki_ssize; 317 u_short ki_xstat; 318 u_short ki_acflag; 319 fixpt_t ki_pctcpu; 320 u_int ki_estcpu; 321 u_int ki_slptime; 322 u_int ki_swtime; 323 u_int ki_cow; 324 u_int64_t ki_runtime; 325 struct timeval32 ki_start; 326 struct timeval32 ki_childtime; 327 int ki_flag; 328 int ki_kiflag; 329 int ki_traceflag; 330 char ki_stat; 331 signed char ki_nice; 332 char ki_lock; 333 char ki_rqindex; 334 u_char ki_oncpu; 335 u_char ki_lastcpu; 336 char ki_tdname[TDNAMLEN+1]; 337 char ki_wmesg[WMESGLEN+1]; 338 char ki_login[LOGNAMELEN+1]; 339 char ki_lockname[LOCKNAMELEN+1]; 340 char ki_comm[COMMLEN+1]; 341 char ki_emul[KI_EMULNAMELEN+1]; 342 char ki_loginclass[LOGINCLASSLEN+1]; 343 char ki_sparestrings[50]; 344 int ki_spareints[KI_NSPARE_INT]; 345 u_int ki_cr_flags; 346 int ki_jid; 347 int ki_numthreads; 348 lwpid_t ki_tid; 349 struct priority ki_pri; 350 struct rusage32 ki_rusage; 351 struct rusage32 ki_rusage_ch; 352 uint32_t ki_pcb; 353 uint32_t ki_kstack; 354 uint32_t ki_udata; 355 uint32_t ki_tdaddr; 356 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 357 int ki_sparelongs[KI_NSPARE_LONG]; 358 int ki_sflag; 359 int ki_tdflags; 360 }; 361 362 struct kld32_file_stat_1 { 363 int version; /* set to sizeof(struct kld_file_stat_1) */ 364 char name[MAXPATHLEN]; 365 int refs; 366 int id; 367 uint32_t address; /* load address */ 368 uint32_t size; /* size in bytes */ 369 }; 370 371 struct kld32_file_stat { 372 int version; /* set to sizeof(struct kld_file_stat) */ 373 char name[MAXPATHLEN]; 374 int refs; 375 int id; 376 uint32_t address; /* load address */ 377 uint32_t size; /* size in bytes */ 378 char pathname[MAXPATHLEN]; 379 }; 380 381 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 382