xref: /freebsd/sys/compat/freebsd32/freebsd32.h (revision a7623790fb345e6dc986dfd31df0ace115e6f2e4)
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 
39 /*
40  * i386 is the only arch with a 32-bit time_t
41  */
42 #ifdef __amd64__
43 typedef	int32_t	time32_t;
44 #else
45 typedef	int64_t	time32_t;
46 #endif
47 
48 struct timeval32 {
49 	time32_t tv_sec;
50 	int32_t tv_usec;
51 };
52 
53 struct timespec32 {
54 	time32_t tv_sec;
55 	int32_t tv_nsec;
56 };
57 
58 struct itimerspec32 {
59 	struct timespec32  it_interval;
60 	struct timespec32  it_value;
61 };
62 
63 struct bintime32 {
64 	time32_t sec;
65 	uint32_t frac[2];
66 };
67 
68 struct rusage32 {
69 	struct timeval32 ru_utime;
70 	struct timeval32 ru_stime;
71 	int32_t	ru_maxrss;
72 	int32_t	ru_ixrss;
73 	int32_t	ru_idrss;
74 	int32_t	ru_isrss;
75 	int32_t	ru_minflt;
76 	int32_t	ru_majflt;
77 	int32_t	ru_nswap;
78 	int32_t	ru_inblock;
79 	int32_t	ru_oublock;
80 	int32_t	ru_msgsnd;
81 	int32_t	ru_msgrcv;
82 	int32_t	ru_nsignals;
83 	int32_t	ru_nvcsw;
84 	int32_t	ru_nivcsw;
85 };
86 
87 struct wrusage32 {
88 	struct rusage32	wru_self;
89 	struct rusage32 wru_children;
90 };
91 
92 struct itimerval32 {
93 	struct timeval32 it_interval;
94 	struct timeval32 it_value;
95 };
96 
97 struct umtx_time32 {
98 	struct	timespec32	_timeout;
99 	uint32_t		_flags;
100 	uint32_t		_clockid;
101 };
102 
103 struct umtx_robust_lists_params_compat32 {
104 	uint32_t	robust_list_offset;
105 	uint32_t	robust_priv_list_offset;
106 	uint32_t	robust_inact_offset;
107 };
108 
109 struct umutex32 {
110 	volatile __lwpid_t	m_owner;	/* Owner of the mutex */
111 	__uint32_t		m_flags;	/* Flags of the mutex */
112 	__uint32_t		m_ceilings[2];	/* Priority protect ceiling */
113 	__uint32_t		m_rb_lnk;	/* Robust linkage */
114 	__uint32_t		m_pad;
115 	__uint32_t		m_spare[2];
116 };
117 
118 #define FREEBSD4_MFSNAMELEN	16
119 #define FREEBSD4_MNAMELEN	(88 - 2 * sizeof(int32_t))
120 
121 /* 4.x version */
122 struct statfs32 {
123 	int32_t	f_spare2;
124 	int32_t	f_bsize;
125 	int32_t	f_iosize;
126 	int32_t	f_blocks;
127 	int32_t	f_bfree;
128 	int32_t	f_bavail;
129 	int32_t	f_files;
130 	int32_t	f_ffree;
131 	fsid_t	f_fsid;
132 	uid_t	f_owner;
133 	int32_t	f_type;
134 	int32_t	f_flags;
135 	int32_t	f_syncwrites;
136 	int32_t	f_asyncwrites;
137 	char	f_fstypename[FREEBSD4_MFSNAMELEN];
138 	char	f_mntonname[FREEBSD4_MNAMELEN];
139 	int32_t	f_syncreads;
140 	int32_t	f_asyncreads;
141 	int16_t	f_spares1;
142 	char	f_mntfromname[FREEBSD4_MNAMELEN];
143 	int16_t	f_spares2 __packed;
144 	int32_t f_spare[2];
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 #if defined(__amd64__)
163 #define	__STAT32_TIME_T_EXT	1
164 #endif
165 
166 struct stat32 {
167 	dev_t st_dev;
168 	ino_t st_ino;
169 	nlink_t st_nlink;
170 	mode_t	st_mode;
171 	u_int16_t st_padding0;
172 	uid_t	st_uid;
173 	gid_t	st_gid;
174 	u_int32_t st_padding1;
175 	dev_t st_rdev;
176 #ifdef	__STAT32_TIME_T_EXT
177 	__int32_t st_atim_ext;
178 #endif
179 	struct timespec32 st_atim;
180 #ifdef	__STAT32_TIME_T_EXT
181 	__int32_t st_mtim_ext;
182 #endif
183 	struct timespec32 st_mtim;
184 #ifdef	__STAT32_TIME_T_EXT
185 	__int32_t st_ctim_ext;
186 #endif
187 	struct timespec32 st_ctim;
188 #ifdef	__STAT32_TIME_T_EXT
189 	__int32_t st_btim_ext;
190 #endif
191 	struct timespec32 st_birthtim;
192 	off_t	st_size;
193 	int64_t	st_blocks;
194 	u_int32_t st_blksize;
195 	u_int32_t st_flags;
196 	u_int64_t st_gen;
197 	u_int64_t st_spare[10];
198 };
199 struct freebsd11_stat32 {
200 	u_int32_t st_dev;
201 	u_int32_t st_ino;
202 	mode_t	st_mode;
203 	u_int16_t st_nlink;
204 	uid_t	st_uid;
205 	gid_t	st_gid;
206 	u_int32_t st_rdev;
207 	struct timespec32 st_atim;
208 	struct timespec32 st_mtim;
209 	struct timespec32 st_ctim;
210 	off_t	st_size;
211 	int64_t	st_blocks;
212 	u_int32_t st_blksize;
213 	u_int32_t st_flags;
214 	u_int32_t st_gen;
215 	int32_t	st_lspare;
216 	struct timespec32 st_birthtim;
217 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
218 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
219 };
220 
221 struct ostat32 {
222 	__uint16_t st_dev;
223 	__uint32_t st_ino;
224 	mode_t	st_mode;
225 	__uint16_t st_nlink;
226 	__uint16_t st_uid;
227 	__uint16_t st_gid;
228 	__uint16_t st_rdev;
229 	__int32_t st_size;
230 	struct timespec32 st_atim;
231 	struct timespec32 st_mtim;
232 	struct timespec32 st_ctim;
233 	__int32_t st_blksize;
234 	__int32_t st_blocks;
235 	u_int32_t st_flags;
236 	__uint32_t st_gen;
237 };
238 
239 struct jail32_v0 {
240 	u_int32_t	version;
241 	uint32_t	path;
242 	uint32_t	hostname;
243 	u_int32_t	ip_number;
244 };
245 
246 struct jail32 {
247 	uint32_t	version;
248 	uint32_t	path;
249 	uint32_t	hostname;
250 	uint32_t	jailname;
251 	uint32_t	ip4s;
252 	uint32_t	ip6s;
253 	uint32_t	ip4;
254 	uint32_t	ip6;
255 };
256 
257 struct sigaction32 {
258 	u_int32_t	sa_u;
259 	int		sa_flags;
260 	sigset_t	sa_mask;
261 };
262 
263 struct thr_param32 {
264 	uint32_t start_func;
265 	uint32_t arg;
266 	uint32_t stack_base;
267 	uint32_t stack_size;
268 	uint32_t tls_base;
269 	uint32_t tls_size;
270 	uint32_t child_tid;
271 	uint32_t parent_tid;
272 	int32_t	 flags;
273 	uint32_t rtp;
274 	uint32_t spare[3];
275 };
276 
277 struct i386_ldt_args32 {
278 	uint32_t start;
279 	uint32_t descs;
280 	uint32_t num;
281 };
282 
283 struct mq_attr32 {
284 	int	mq_flags;
285 	int	mq_maxmsg;
286 	int	mq_msgsize;
287 	int	mq_curmsgs;
288 	int	__reserved[4];
289 };
290 
291 struct kinfo_proc32 {
292 	int	ki_structsize;
293 	int	ki_layout;
294 	uint32_t ki_args;
295 	uint32_t ki_paddr;
296 	uint32_t ki_addr;
297 	uint32_t ki_tracep;
298 	uint32_t ki_textvp;
299 	uint32_t ki_fd;
300 	uint32_t ki_vmspace;
301 	uint32_t ki_wchan;
302 	pid_t	ki_pid;
303 	pid_t	ki_ppid;
304 	pid_t	ki_pgid;
305 	pid_t	ki_tpgid;
306 	pid_t	ki_sid;
307 	pid_t	ki_tsid;
308 	short	ki_jobc;
309 	short	ki_spare_short1;
310 	uint32_t ki_tdev_freebsd11;
311 	sigset_t ki_siglist;
312 	sigset_t ki_sigmask;
313 	sigset_t ki_sigignore;
314 	sigset_t ki_sigcatch;
315 	uid_t	ki_uid;
316 	uid_t	ki_ruid;
317 	uid_t	ki_svuid;
318 	gid_t	ki_rgid;
319 	gid_t	ki_svgid;
320 	short	ki_ngroups;
321 	short	ki_spare_short2;
322 	gid_t 	ki_groups[KI_NGROUPS];
323 	uint32_t ki_size;
324 	int32_t ki_rssize;
325 	int32_t ki_swrss;
326 	int32_t ki_tsize;
327 	int32_t ki_dsize;
328 	int32_t ki_ssize;
329 	u_short	ki_xstat;
330 	u_short	ki_acflag;
331 	fixpt_t	ki_pctcpu;
332 	u_int	ki_estcpu;
333 	u_int	ki_slptime;
334 	u_int	ki_swtime;
335 	u_int	ki_cow;
336 	u_int64_t ki_runtime;
337 	struct	timeval32 ki_start;
338 	struct	timeval32 ki_childtime;
339 	int	ki_flag;
340 	int	ki_kiflag;
341 	int	ki_traceflag;
342 	char	ki_stat;
343 	signed char ki_nice;
344 	char	ki_lock;
345 	char	ki_rqindex;
346 	u_char	ki_oncpu_old;
347 	u_char	ki_lastcpu_old;
348 	char	ki_tdname[TDNAMLEN+1];
349 	char	ki_wmesg[WMESGLEN+1];
350 	char	ki_login[LOGNAMELEN+1];
351 	char	ki_lockname[LOCKNAMELEN+1];
352 	char	ki_comm[COMMLEN+1];
353 	char	ki_emul[KI_EMULNAMELEN+1];
354 	char	ki_loginclass[LOGINCLASSLEN+1];
355 	char	ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
356 	char	ki_sparestrings[46];
357 	int	ki_spareints[KI_NSPARE_INT];
358 	uint64_t ki_tdev;
359 	int	ki_oncpu;
360 	int	ki_lastcpu;
361 	int	ki_tracer;
362 	int	ki_flag2;
363 	int	ki_fibnum;
364 	u_int	ki_cr_flags;
365 	int	ki_jid;
366 	int	ki_numthreads;
367 	lwpid_t	ki_tid;
368 	struct	priority ki_pri;
369 	struct	rusage32 ki_rusage;
370 	struct	rusage32 ki_rusage_ch;
371 	uint32_t ki_pcb;
372 	uint32_t ki_kstack;
373 	uint32_t ki_udata;
374 	uint32_t ki_tdaddr;
375 	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
376 	int	ki_sparelongs[KI_NSPARE_LONG];
377 	int	ki_sflag;
378 	int	ki_tdflags;
379 };
380 
381 struct kinfo_sigtramp32 {
382 	uint32_t ksigtramp_start;
383 	uint32_t ksigtramp_end;
384 	uint32_t ksigtramp_spare[4];
385 };
386 
387 struct kld32_file_stat_1 {
388 	int	version;	/* set to sizeof(struct kld_file_stat_1) */
389 	char	name[MAXPATHLEN];
390 	int	refs;
391 	int	id;
392 	uint32_t address;	/* load address */
393 	uint32_t size;		/* size in bytes */
394 };
395 
396 struct kld32_file_stat {
397 	int	version;	/* set to sizeof(struct kld_file_stat) */
398 	char	name[MAXPATHLEN];
399 	int	refs;
400 	int	id;
401 	uint32_t address;	/* load address */
402 	uint32_t size;		/* size in bytes */
403 	char	pathname[MAXPATHLEN];
404 };
405 
406 struct procctl_reaper_pids32 {
407 	u_int	rp_count;
408 	u_int	rp_pad0[15];
409 	uint32_t rp_pids;
410 };
411 
412 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
413