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