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