xref: /freebsd/sys/compat/freebsd32/freebsd32.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
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 #include <sys/_ffcounter.h>
37 
38 /*
39  * i386 is the only arch with a 32-bit time_t
40  */
41 #ifdef __amd64__
42 typedef	int32_t	time32_t;
43 #else
44 typedef	int64_t	time32_t;
45 #endif
46 
47 struct timeval32 {
48 	time32_t tv_sec;
49 	int32_t tv_usec;
50 };
51 
52 struct timespec32 {
53 	time32_t tv_sec;
54 	int32_t tv_nsec;
55 };
56 
57 struct itimerspec32 {
58 	struct timespec32  it_interval;
59 	struct timespec32  it_value;
60 };
61 
62 struct bintime32 {
63 	time32_t sec;
64 	uint32_t frac[2];
65 };
66 
67 struct ffclock_estimate32 {
68 	struct bintime32 update_time;
69 	ffcounter update_ffcount;
70 	ffcounter leapsec_next;
71 	uint64_t period;
72 	uint32_t errb_abs;
73 	uint32_t errb_rate;
74 	uint32_t status;
75 	int16_t leapsec_total;
76 	int8_t leapsec;
77 	int8_t _pad;
78 }
79 #if defined(__amd64__)
80 __attribute__((packed))
81 #endif
82 ;
83 #if defined(__amd64__)
84 _Static_assert(sizeof(struct ffclock_estimate32) == 52, "ffclock_estimate32 size");
85 #else
86 _Static_assert(sizeof(struct ffclock_estimate32) == 56, "ffclock_estimate32 size");
87 #endif
88 
89 struct rusage32 {
90 	struct timeval32 ru_utime;
91 	struct timeval32 ru_stime;
92 	int32_t	ru_maxrss;
93 	int32_t	ru_ixrss;
94 	int32_t	ru_idrss;
95 	int32_t	ru_isrss;
96 	int32_t	ru_minflt;
97 	int32_t	ru_majflt;
98 	int32_t	ru_nswap;
99 	int32_t	ru_inblock;
100 	int32_t	ru_oublock;
101 	int32_t	ru_msgsnd;
102 	int32_t	ru_msgrcv;
103 	int32_t	ru_nsignals;
104 	int32_t	ru_nvcsw;
105 	int32_t	ru_nivcsw;
106 };
107 
108 struct __wrusage32 {
109 	struct rusage32	wru_self;
110 	struct rusage32 wru_children;
111 };
112 
113 struct itimerval32 {
114 	struct timeval32 it_interval;
115 	struct timeval32 it_value;
116 };
117 
118 struct umtx_time32 {
119 	struct	timespec32	_timeout;
120 	uint32_t		_flags;
121 	uint32_t		_clockid;
122 };
123 
124 struct umtx_robust_lists_params_compat32 {
125 	uint32_t	robust_list_offset;
126 	uint32_t	robust_priv_list_offset;
127 	uint32_t	robust_inact_offset;
128 };
129 
130 struct umutex32 {
131 	volatile __lwpid_t	m_owner;	/* Owner of the mutex */
132 	__uint32_t		m_flags;	/* Flags of the mutex */
133 	__uint32_t		m_ceilings[2];	/* Priority protect ceiling */
134 	__uint32_t		m_rb_lnk;	/* Robust linkage */
135 	__uint32_t		m_pad;
136 	__uint32_t		m_spare[2];
137 };
138 
139 #define FREEBSD4_OMFSNAMELEN	16
140 #define FREEBSD4_OMNAMELEN	(88 - 2 * sizeof(int32_t))
141 
142 /* 4.x version */
143 struct ostatfs32 {
144 	int32_t	f_spare2;
145 	int32_t	f_bsize;
146 	int32_t	f_iosize;
147 	int32_t	f_blocks;
148 	int32_t	f_bfree;
149 	int32_t	f_bavail;
150 	int32_t	f_files;
151 	int32_t	f_ffree;
152 	fsid_t	f_fsid;
153 	uid_t	f_owner;
154 	int32_t	f_type;
155 	int32_t	f_flags;
156 	int32_t	f_syncwrites;
157 	int32_t	f_asyncwrites;
158 	char	f_fstypename[FREEBSD4_OMFSNAMELEN];
159 	char	f_mntonname[FREEBSD4_OMNAMELEN];
160 	int32_t	f_syncreads;
161 	int32_t	f_asyncreads;
162 	int16_t	f_spares1;
163 	char	f_mntfromname[FREEBSD4_OMNAMELEN];
164 	int16_t	f_spares2 __packed;
165 	int32_t f_spare[2];
166 };
167 
168 struct nstat32 {
169 	__uint32_t st_dev;		/* inode's device */
170 	__uint32_t st_ino;		/* inode's number */
171 	__uint32_t st_mode;		/* inode protection mode */
172 	__uint32_t st_nlink;		/* number of hard links */
173 	uid_t	  st_uid;		/* user ID of the file's owner */
174 	gid_t	  st_gid;		/* group ID of the file's group */
175 	__uint32_t st_rdev;		/* device type */
176 	struct	timespec32 st_atim;	/* time of last access */
177 	struct	timespec32 st_mtim;	/* time of last data modification */
178 	struct	timespec32 st_ctim;	/* time of last file status change */
179 	off_t	  st_size;		/* file size, in bytes */
180 	blkcnt_t st_blocks;		/* blocks allocated for file */
181 	blksize_t st_blksize;		/* optimal blocksize for I/O */
182 	fflags_t  st_flags;		/* user defined flags for file */
183 	__uint32_t st_gen;		/* file generation number */
184 	struct timespec32 st_birthtim;	/* time of file creation */
185 	/*
186 	 * See comment in the definition of struct freebsd11_stat
187 	 * in sys/stat.h about the following padding.
188 	 */
189 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
190 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
191 };
192 
193 struct iovec32 {
194 	uint32_t iov_base;
195 	int	iov_len;
196 };
197 
198 struct msghdr32 {
199 	uint32_t	 msg_name;
200 	socklen_t	 msg_namelen;
201 	uint32_t	 msg_iov;
202 	int		 msg_iovlen;
203 	uint32_t	 msg_control;
204 	socklen_t	 msg_controllen;
205 	int		 msg_flags;
206 };
207 
208 #if defined(__amd64__)
209 #define	__STAT32_TIME_T_EXT	1
210 #endif
211 
212 struct stat32 {
213 	dev_t st_dev;
214 	ino_t st_ino;
215 	nlink_t st_nlink;
216 	mode_t	st_mode;
217 	uint16_t st_padding0;
218 	uid_t	st_uid;
219 	gid_t	st_gid;
220 	uint32_t st_padding1;
221 	dev_t st_rdev;
222 #ifdef	__STAT32_TIME_T_EXT
223 	__int32_t st_atim_ext;
224 #endif
225 	struct timespec32 st_atim;
226 #ifdef	__STAT32_TIME_T_EXT
227 	__int32_t st_mtim_ext;
228 #endif
229 	struct timespec32 st_mtim;
230 #ifdef	__STAT32_TIME_T_EXT
231 	__int32_t st_ctim_ext;
232 #endif
233 	struct timespec32 st_ctim;
234 #ifdef	__STAT32_TIME_T_EXT
235 	__int32_t st_btim_ext;
236 #endif
237 	struct timespec32 st_birthtim;
238 	off_t	st_size;
239 	int64_t	st_blocks;
240 	uint32_t st_blksize;
241 	uint32_t st_flags;
242 	uint64_t st_gen;
243 	uint64_t st_spare[10];
244 };
245 struct freebsd11_stat32 {
246 	uint32_t st_dev;
247 	uint32_t st_ino;
248 	mode_t	st_mode;
249 	uint16_t st_nlink;
250 	uid_t	st_uid;
251 	gid_t	st_gid;
252 	uint32_t st_rdev;
253 	struct timespec32 st_atim;
254 	struct timespec32 st_mtim;
255 	struct timespec32 st_ctim;
256 	off_t	st_size;
257 	int64_t	st_blocks;
258 	uint32_t st_blksize;
259 	uint32_t st_flags;
260 	uint32_t st_gen;
261 	int32_t	st_lspare;
262 	struct timespec32 st_birthtim;
263 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
264 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
265 };
266 
267 struct ostat32 {
268 	__uint16_t st_dev;
269 	__uint32_t st_ino;
270 	mode_t	st_mode;
271 	__uint16_t st_nlink;
272 	__uint16_t st_uid;
273 	__uint16_t st_gid;
274 	__uint16_t st_rdev;
275 	__int32_t st_size;
276 	struct timespec32 st_atim;
277 	struct timespec32 st_mtim;
278 	struct timespec32 st_ctim;
279 	__int32_t st_blksize;
280 	__int32_t st_blocks;
281 	uint32_t st_flags;
282 	__uint32_t st_gen;
283 };
284 
285 struct jail32_v0 {
286 	uint32_t	version;
287 	uint32_t	path;
288 	uint32_t	hostname;
289 	uint32_t	ip_number;
290 };
291 
292 struct jail32 {
293 	uint32_t	version;
294 	uint32_t	path;
295 	uint32_t	hostname;
296 	uint32_t	jailname;
297 	uint32_t	ip4s;
298 	uint32_t	ip6s;
299 	uint32_t	ip4;
300 	uint32_t	ip6;
301 };
302 
303 struct sigaction32 {
304 	uint32_t	sa_u;
305 	int		sa_flags;
306 	sigset_t	sa_mask;
307 };
308 
309 struct thr_param32 {
310 	uint32_t start_func;
311 	uint32_t arg;
312 	uint32_t stack_base;
313 	uint32_t stack_size;
314 	uint32_t tls_base;
315 	uint32_t tls_size;
316 	uint32_t child_tid;
317 	uint32_t parent_tid;
318 	int32_t	 flags;
319 	uint32_t rtp;
320 	uint32_t spare[3];
321 };
322 
323 struct i386_ldt_args32 {
324 	uint32_t start;
325 	uint32_t descs;
326 	uint32_t num;
327 };
328 
329 struct mq_attr32 {
330 	int	mq_flags;
331 	int	mq_maxmsg;
332 	int	mq_msgsize;
333 	int	mq_curmsgs;
334 	int	__reserved[4];
335 };
336 
337 struct kinfo_proc32 {
338 	int	ki_structsize;
339 	int	ki_layout;
340 	uint32_t ki_args;
341 	uint32_t ki_paddr;
342 	uint32_t ki_addr;
343 	uint32_t ki_tracep;
344 	uint32_t ki_textvp;
345 	uint32_t ki_fd;
346 	uint32_t ki_vmspace;
347 	uint32_t ki_wchan;
348 	pid_t	ki_pid;
349 	pid_t	ki_ppid;
350 	pid_t	ki_pgid;
351 	pid_t	ki_tpgid;
352 	pid_t	ki_sid;
353 	pid_t	ki_tsid;
354 	short	ki_jobc;
355 	short	ki_spare_short1;
356 	uint32_t ki_tdev_freebsd11;
357 	sigset_t ki_siglist;
358 	sigset_t ki_sigmask;
359 	sigset_t ki_sigignore;
360 	sigset_t ki_sigcatch;
361 	uid_t	ki_uid;
362 	uid_t	ki_ruid;
363 	uid_t	ki_svuid;
364 	gid_t	ki_rgid;
365 	gid_t	ki_svgid;
366 	short	ki_ngroups;
367 	short	ki_spare_short2;
368 	gid_t 	ki_groups[KI_NGROUPS];
369 	uint32_t ki_size;
370 	int32_t ki_rssize;
371 	int32_t ki_swrss;
372 	int32_t ki_tsize;
373 	int32_t ki_dsize;
374 	int32_t ki_ssize;
375 	u_short	ki_xstat;
376 	u_short	ki_acflag;
377 	fixpt_t	ki_pctcpu;
378 	u_int	ki_estcpu;
379 	u_int	ki_slptime;
380 	u_int	ki_swtime;
381 	u_int	ki_cow;
382 	uint64_t ki_runtime;
383 	struct	timeval32 ki_start;
384 	struct	timeval32 ki_childtime;
385 	int	ki_flag;
386 	int	ki_kiflag;
387 	int	ki_traceflag;
388 	char	ki_stat;
389 	signed char ki_nice;
390 	char	ki_lock;
391 	char	ki_rqindex;
392 	u_char	ki_oncpu_old;
393 	u_char	ki_lastcpu_old;
394 	char	ki_tdname[TDNAMLEN+1];
395 	char	ki_wmesg[WMESGLEN+1];
396 	char	ki_login[LOGNAMELEN+1];
397 	char	ki_lockname[LOCKNAMELEN+1];
398 	char	ki_comm[COMMLEN+1];
399 	char	ki_emul[KI_EMULNAMELEN+1];
400 	char	ki_loginclass[LOGINCLASSLEN+1];
401 	char	ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
402 	char	ki_sparestrings[46];
403 	int	ki_spareints[KI_NSPARE_INT];
404 	uint64_t ki_tdev;
405 	int	ki_oncpu;
406 	int	ki_lastcpu;
407 	int	ki_tracer;
408 	int	ki_flag2;
409 	int	ki_fibnum;
410 	u_int	ki_cr_flags;
411 	int	ki_jid;
412 	int	ki_numthreads;
413 	lwpid_t	ki_tid;
414 	struct	priority ki_pri;
415 	struct	rusage32 ki_rusage;
416 	struct	rusage32 ki_rusage_ch;
417 	uint32_t ki_pcb;
418 	uint32_t ki_kstack;
419 	uint32_t ki_udata;
420 	uint32_t ki_tdaddr;
421 	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
422 	int	ki_sparelongs[KI_NSPARE_LONG];
423 	int	ki_sflag;
424 	int	ki_tdflags;
425 };
426 
427 struct kinfo_sigtramp32 {
428 	uint32_t ksigtramp_start;
429 	uint32_t ksigtramp_end;
430 	uint32_t ksigtramp_spare[4];
431 };
432 
433 struct kinfo_vm_layout32 {
434 	uint32_t	kvm_min_user_addr;
435 	uint32_t	kvm_max_user_addr;
436 	uint32_t	kvm_text_addr;
437 	uint32_t	kvm_text_size;
438 	uint32_t	kvm_data_addr;
439 	uint32_t	kvm_data_size;
440 	uint32_t	kvm_stack_addr;
441 	uint32_t	kvm_stack_size;
442 	int		kvm_map_flags;
443 	uint32_t	kvm_shp_addr;
444 	uint32_t	kvm_shp_size;
445 	uint32_t	kvm_spare[12];
446 };
447 
448 struct kld_file_stat_1_32 {
449 	int	version;	/* set to sizeof(struct kld_file_stat_1) */
450 	char	name[MAXPATHLEN];
451 	int	refs;
452 	int	id;
453 	uint32_t address;	/* load address */
454 	uint32_t size;		/* size in bytes */
455 };
456 
457 struct kld_file_stat32 {
458 	int	version;	/* set to sizeof(struct kld_file_stat) */
459 	char	name[MAXPATHLEN];
460 	int	refs;
461 	int	id;
462 	uint32_t address;	/* load address */
463 	uint32_t size;		/* size in bytes */
464 	char	pathname[MAXPATHLEN];
465 };
466 
467 struct procctl_reaper_pids32 {
468 	u_int	rp_count;
469 	u_int	rp_pad0[15];
470 	uint32_t rp_pids;
471 };
472 
473 struct timex32 {
474 	unsigned int modes;
475 	int32_t	offset;
476 	int32_t	freq;
477 	int32_t	maxerror;
478 	int32_t	esterror;
479 	int	status;
480 	int32_t	constant;
481 	int32_t	precision;
482 	int32_t	tolerance;
483 	int32_t	ppsfreq;
484 	int32_t	jitter;
485 	int	shift;
486 	int32_t	stabil;
487 	int32_t	jitcnt;
488 	int32_t	calcnt;
489 	int32_t	errcnt;
490 	int32_t	stbcnt;
491 };
492 
493 struct ptrace_sc_ret32 {
494 	uint32_t	sr_retval[2];
495 	int		sr_error;
496 };
497 
498 struct ptrace_coredump32 {
499 	int		pc_fd;
500 	uint32_t	pc_flags;
501 	uint32_t	pc_limit1, pc_limit2;
502 };
503 
504 struct ptrace_sc_remote32 {
505 	struct ptrace_sc_ret32 pscr_ret;
506 	u_int		pscr_syscall;
507 	u_int		pscr_nargs;
508 	uint32_t	pscr_args;
509 };
510 
511 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
512