xref: /freebsd/sys/compat/freebsd32/freebsd32.h (revision 8657387683946d0c03e09fe77029edfe309eeb20)
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  * i386 is the only arch with a 32-bit time_t
47  */
48 #ifdef __amd64__
49 typedef	int32_t	time32_t;
50 #else
51 typedef	int64_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_MFSNAMELEN	16
111 #define FREEBSD4_MNAMELEN	(88 - 2 * sizeof(int32_t))
112 
113 /* 4.x version */
114 struct statfs32 {
115 	int32_t	f_spare2;
116 	int32_t	f_bsize;
117 	int32_t	f_iosize;
118 	int32_t	f_blocks;
119 	int32_t	f_bfree;
120 	int32_t	f_bavail;
121 	int32_t	f_files;
122 	int32_t	f_ffree;
123 	fsid_t	f_fsid;
124 	uid_t	f_owner;
125 	int32_t	f_type;
126 	int32_t	f_flags;
127 	int32_t	f_syncwrites;
128 	int32_t	f_asyncwrites;
129 	char	f_fstypename[FREEBSD4_MFSNAMELEN];
130 	char	f_mntonname[FREEBSD4_MNAMELEN];
131 	int32_t	f_syncreads;
132 	int32_t	f_asyncreads;
133 	int16_t	f_spares1;
134 	char	f_mntfromname[FREEBSD4_MNAMELEN];
135 	int16_t	f_spares2 __packed;
136 	int32_t f_spare[2];
137 };
138 
139 struct kevent32 {
140 	uint32_t	ident;		/* identifier for this event */
141 	short		filter;		/* filter for event */
142 	u_short		flags;
143 	u_int		fflags;
144 #ifndef __amd64__
145 	uint32_t	pad0;
146 #endif
147 	int32_t		data1, data2;
148 	uint32_t	udata;		/* opaque user data identifier */
149 #ifndef __amd64__
150 	uint32_t	pad1;
151 #endif
152 	uint32_t	ext64[8];
153 };
154 
155 struct iovec32 {
156 	u_int32_t iov_base;
157 	int	iov_len;
158 };
159 
160 struct msghdr32 {
161 	u_int32_t	 msg_name;
162 	socklen_t	 msg_namelen;
163 	u_int32_t	 msg_iov;
164 	int		 msg_iovlen;
165 	u_int32_t	 msg_control;
166 	socklen_t	 msg_controllen;
167 	int		 msg_flags;
168 };
169 
170 #if defined(__amd64__)
171 #define	__STAT32_TIME_T_EXT	1
172 #endif
173 
174 struct stat32 {
175 	dev_t st_dev;
176 	ino_t st_ino;
177 	nlink_t st_nlink;
178 	mode_t	st_mode;
179 	u_int16_t st_padding0;
180 	uid_t	st_uid;
181 	gid_t	st_gid;
182 	u_int32_t st_padding1;
183 	dev_t st_rdev;
184 #ifdef	__STAT32_TIME_T_EXT
185 	__int32_t st_atim_ext;
186 #endif
187 	struct timespec32 st_atim;
188 #ifdef	__STAT32_TIME_T_EXT
189 	__int32_t st_mtim_ext;
190 #endif
191 	struct timespec32 st_mtim;
192 #ifdef	__STAT32_TIME_T_EXT
193 	__int32_t st_ctim_ext;
194 #endif
195 	struct timespec32 st_ctim;
196 #ifdef	__STAT32_TIME_T_EXT
197 	__int32_t st_btim_ext;
198 #endif
199 	struct timespec32 st_birthtim;
200 	off_t	st_size;
201 	int64_t	st_blocks;
202 	u_int32_t st_blksize;
203 	u_int32_t st_flags;
204 	u_int64_t st_gen;
205 	u_int64_t st_spare[10];
206 };
207 struct freebsd11_stat32 {
208 	u_int32_t st_dev;
209 	u_int32_t st_ino;
210 	mode_t	st_mode;
211 	u_int16_t st_nlink;
212 	uid_t	st_uid;
213 	gid_t	st_gid;
214 	u_int32_t st_rdev;
215 	struct timespec32 st_atim;
216 	struct timespec32 st_mtim;
217 	struct timespec32 st_ctim;
218 	off_t	st_size;
219 	int64_t	st_blocks;
220 	u_int32_t st_blksize;
221 	u_int32_t st_flags;
222 	u_int32_t st_gen;
223 	int32_t	st_lspare;
224 	struct timespec32 st_birthtim;
225 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
226 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
227 };
228 
229 struct ostat32 {
230 	__uint16_t st_dev;
231 	__uint32_t st_ino;
232 	mode_t	st_mode;
233 	__uint16_t st_nlink;
234 	__uint16_t st_uid;
235 	__uint16_t st_gid;
236 	__uint16_t st_rdev;
237 	__int32_t st_size;
238 	struct timespec32 st_atim;
239 	struct timespec32 st_mtim;
240 	struct timespec32 st_ctim;
241 	__int32_t st_blksize;
242 	__int32_t st_blocks;
243 	u_int32_t st_flags;
244 	__uint32_t st_gen;
245 };
246 
247 struct jail32_v0 {
248 	u_int32_t	version;
249 	uint32_t	path;
250 	uint32_t	hostname;
251 	u_int32_t	ip_number;
252 };
253 
254 struct jail32 {
255 	uint32_t	version;
256 	uint32_t	path;
257 	uint32_t	hostname;
258 	uint32_t	jailname;
259 	uint32_t	ip4s;
260 	uint32_t	ip6s;
261 	uint32_t	ip4;
262 	uint32_t	ip6;
263 };
264 
265 struct sigaction32 {
266 	u_int32_t	sa_u;
267 	int		sa_flags;
268 	sigset_t	sa_mask;
269 };
270 
271 struct thr_param32 {
272 	uint32_t start_func;
273 	uint32_t arg;
274 	uint32_t stack_base;
275 	uint32_t stack_size;
276 	uint32_t tls_base;
277 	uint32_t tls_size;
278 	uint32_t child_tid;
279 	uint32_t parent_tid;
280 	int32_t	 flags;
281 	uint32_t rtp;
282 	uint32_t spare[3];
283 };
284 
285 struct i386_ldt_args32 {
286 	uint32_t start;
287 	uint32_t descs;
288 	uint32_t num;
289 };
290 
291 struct mq_attr32 {
292 	int	mq_flags;
293 	int	mq_maxmsg;
294 	int	mq_msgsize;
295 	int	mq_curmsgs;
296 	int	__reserved[4];
297 };
298 
299 struct kinfo_proc32 {
300 	int	ki_structsize;
301 	int	ki_layout;
302 	uint32_t ki_args;
303 	uint32_t ki_paddr;
304 	uint32_t ki_addr;
305 	uint32_t ki_tracep;
306 	uint32_t ki_textvp;
307 	uint32_t ki_fd;
308 	uint32_t ki_vmspace;
309 	uint32_t ki_wchan;
310 	pid_t	ki_pid;
311 	pid_t	ki_ppid;
312 	pid_t	ki_pgid;
313 	pid_t	ki_tpgid;
314 	pid_t	ki_sid;
315 	pid_t	ki_tsid;
316 	short	ki_jobc;
317 	short	ki_spare_short1;
318 	uint32_t ki_tdev_freebsd11;
319 	sigset_t ki_siglist;
320 	sigset_t ki_sigmask;
321 	sigset_t ki_sigignore;
322 	sigset_t ki_sigcatch;
323 	uid_t	ki_uid;
324 	uid_t	ki_ruid;
325 	uid_t	ki_svuid;
326 	gid_t	ki_rgid;
327 	gid_t	ki_svgid;
328 	short	ki_ngroups;
329 	short	ki_spare_short2;
330 	gid_t 	ki_groups[KI_NGROUPS];
331 	uint32_t ki_size;
332 	int32_t ki_rssize;
333 	int32_t ki_swrss;
334 	int32_t ki_tsize;
335 	int32_t ki_dsize;
336 	int32_t ki_ssize;
337 	u_short	ki_xstat;
338 	u_short	ki_acflag;
339 	fixpt_t	ki_pctcpu;
340 	u_int	ki_estcpu;
341 	u_int	ki_slptime;
342 	u_int	ki_swtime;
343 	u_int	ki_cow;
344 	u_int64_t ki_runtime;
345 	struct	timeval32 ki_start;
346 	struct	timeval32 ki_childtime;
347 	int	ki_flag;
348 	int	ki_kiflag;
349 	int	ki_traceflag;
350 	char	ki_stat;
351 	signed char ki_nice;
352 	char	ki_lock;
353 	char	ki_rqindex;
354 	u_char	ki_oncpu_old;
355 	u_char	ki_lastcpu_old;
356 	char	ki_tdname[TDNAMLEN+1];
357 	char	ki_wmesg[WMESGLEN+1];
358 	char	ki_login[LOGNAMELEN+1];
359 	char	ki_lockname[LOCKNAMELEN+1];
360 	char	ki_comm[COMMLEN+1];
361 	char	ki_emul[KI_EMULNAMELEN+1];
362 	char	ki_loginclass[LOGINCLASSLEN+1];
363 	char	ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
364 	char	ki_sparestrings[46];
365 	int	ki_spareints[KI_NSPARE_INT];
366 	uint64_t ki_tdev;
367 	int	ki_oncpu;
368 	int	ki_lastcpu;
369 	int	ki_tracer;
370 	int	ki_flag2;
371 	int	ki_fibnum;
372 	u_int	ki_cr_flags;
373 	int	ki_jid;
374 	int	ki_numthreads;
375 	lwpid_t	ki_tid;
376 	struct	priority ki_pri;
377 	struct	rusage32 ki_rusage;
378 	struct	rusage32 ki_rusage_ch;
379 	uint32_t ki_pcb;
380 	uint32_t ki_kstack;
381 	uint32_t ki_udata;
382 	uint32_t ki_tdaddr;
383 	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
384 	int	ki_sparelongs[KI_NSPARE_LONG];
385 	int	ki_sflag;
386 	int	ki_tdflags;
387 };
388 
389 struct kinfo_sigtramp32 {
390 	uint32_t ksigtramp_start;
391 	uint32_t ksigtramp_end;
392 	uint32_t ksigtramp_spare[4];
393 };
394 
395 struct kld32_file_stat_1 {
396 	int	version;	/* set to sizeof(struct kld_file_stat_1) */
397 	char	name[MAXPATHLEN];
398 	int	refs;
399 	int	id;
400 	uint32_t address;	/* load address */
401 	uint32_t size;		/* size in bytes */
402 };
403 
404 struct kld32_file_stat {
405 	int	version;	/* set to sizeof(struct kld_file_stat) */
406 	char	name[MAXPATHLEN];
407 	int	refs;
408 	int	id;
409 	uint32_t address;	/* load address */
410 	uint32_t size;		/* size in bytes */
411 	char	pathname[MAXPATHLEN];
412 };
413 
414 struct procctl_reaper_pids32 {
415 	u_int	rp_count;
416 	u_int	rp_pad0[15];
417 	uint32_t rp_pids;
418 };
419 
420 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
421