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