xref: /freebsd/sys/compat/freebsd32/freebsd32.h (revision f05cddf9)
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 rusage32 {
73 	struct timeval32 ru_utime;
74 	struct timeval32 ru_stime;
75 	int32_t	ru_maxrss;
76 	int32_t	ru_ixrss;
77 	int32_t	ru_idrss;
78 	int32_t	ru_isrss;
79 	int32_t	ru_minflt;
80 	int32_t	ru_majflt;
81 	int32_t	ru_nswap;
82 	int32_t	ru_inblock;
83 	int32_t	ru_oublock;
84 	int32_t	ru_msgsnd;
85 	int32_t	ru_msgrcv;
86 	int32_t	ru_nsignals;
87 	int32_t	ru_nvcsw;
88 	int32_t	ru_nivcsw;
89 };
90 
91 struct wrusage32 {
92 	struct rusage32	wru_self;
93 	struct rusage32 wru_children;
94 };
95 
96 struct itimerval32 {
97 	struct timeval32 it_interval;
98 	struct timeval32 it_value;
99 };
100 
101 #define FREEBSD4_MNAMELEN        (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */
102 
103 /* 4.x version */
104 struct statfs32 {
105 	int32_t	f_spare2;
106 	int32_t	f_bsize;
107 	int32_t	f_iosize;
108 	int32_t	f_blocks;
109 	int32_t	f_bfree;
110 	int32_t	f_bavail;
111 	int32_t	f_files;
112 	int32_t	f_ffree;
113 	fsid_t	f_fsid;
114 	uid_t	f_owner;
115 	int32_t	f_type;
116 	int32_t	f_flags;
117 	int32_t	f_syncwrites;
118 	int32_t	f_asyncwrites;
119 	char	f_fstypename[MFSNAMELEN];
120 	char	f_mntonname[FREEBSD4_MNAMELEN];
121 	int32_t	f_syncreads;
122 	int32_t	f_asyncreads;
123 	int16_t	f_spares1;
124 	char	f_mntfromname[FREEBSD4_MNAMELEN];
125 	int16_t	f_spares2 __packed;
126 	int32_t f_spare[2];
127 };
128 
129 struct kevent32 {
130 	u_int32_t	ident;		/* identifier for this event */
131 	short		filter;		/* filter for event */
132 	u_short		flags;
133 	u_int		fflags;
134 	int32_t		data;
135 	u_int32_t	udata;		/* opaque user data identifier */
136 };
137 
138 struct iovec32 {
139 	u_int32_t iov_base;
140 	int	iov_len;
141 };
142 
143 struct msghdr32 {
144 	u_int32_t	 msg_name;
145 	socklen_t	 msg_namelen;
146 	u_int32_t	 msg_iov;
147 	int		 msg_iovlen;
148 	u_int32_t	 msg_control;
149 	socklen_t	 msg_controllen;
150 	int		 msg_flags;
151 };
152 
153 struct stat32 {
154 	dev_t	st_dev;
155 	ino_t	st_ino;
156 	mode_t	st_mode;
157 	nlink_t	st_nlink;
158 	uid_t	st_uid;
159 	gid_t	st_gid;
160 	dev_t	st_rdev;
161 	struct timespec32 st_atim;
162 	struct timespec32 st_mtim;
163 	struct timespec32 st_ctim;
164 	off_t	st_size;
165 	int64_t	st_blocks;
166 	u_int32_t st_blksize;
167 	u_int32_t st_flags;
168 	u_int32_t st_gen;
169 	struct timespec32 st_birthtim;
170 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
171 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
172 };
173 
174 struct ostat32 {
175 	__uint16_t st_dev;
176 	ino_t	st_ino;
177 	mode_t	st_mode;
178 	nlink_t	st_nlink;
179 	__uint16_t st_uid;
180 	__uint16_t st_gid;
181 	__uint16_t st_rdev;
182 	__int32_t st_size;
183 	struct timespec32 st_atim;
184 	struct timespec32 st_mtim;
185 	struct timespec32 st_ctim;
186 	__int32_t st_blksize;
187 	__int32_t st_blocks;
188 	u_int32_t st_flags;
189 	__uint32_t st_gen;
190 };
191 
192 struct jail32_v0 {
193 	u_int32_t	version;
194 	uint32_t	path;
195 	uint32_t	hostname;
196 	u_int32_t	ip_number;
197 };
198 
199 struct jail32 {
200 	uint32_t	version;
201 	uint32_t	path;
202 	uint32_t	hostname;
203 	uint32_t	jailname;
204 	uint32_t	ip4s;
205 	uint32_t	ip6s;
206 	uint32_t	ip4;
207 	uint32_t	ip6;
208 };
209 
210 struct sigaction32 {
211 	u_int32_t	sa_u;
212 	int		sa_flags;
213 	sigset_t	sa_mask;
214 };
215 
216 struct thr_param32 {
217 	uint32_t start_func;
218 	uint32_t arg;
219 	uint32_t stack_base;
220 	uint32_t stack_size;
221 	uint32_t tls_base;
222 	uint32_t tls_size;
223 	uint32_t child_tid;
224 	uint32_t parent_tid;
225 	int32_t	 flags;
226 	uint32_t rtp;
227 	uint32_t spare[3];
228 };
229 
230 struct i386_ldt_args32 {
231 	uint32_t start;
232 	uint32_t descs;
233 	uint32_t num;
234 };
235 
236 /*
237  * Alternative layouts for <sys/procfs.h>
238  */
239 struct prstatus32 {
240         int     pr_version;
241         u_int   pr_statussz;
242         u_int   pr_gregsetsz;
243         u_int   pr_fpregsetsz;
244         int     pr_osreldate;
245         int     pr_cursig;
246         pid_t   pr_pid;
247         struct reg32 pr_reg;
248 };
249 
250 struct prpsinfo32 {
251         int     pr_version;
252         u_int   pr_psinfosz;
253         char    pr_fname[PRFNAMESZ+1];
254         char    pr_psargs[PRARGSZ+1];
255 };
256 
257 struct thrmisc32 {
258         char    pr_tname[MAXCOMLEN+1];
259         u_int   _pad;
260 };
261 
262 struct mq_attr32 {
263 	int	mq_flags;
264 	int	mq_maxmsg;
265 	int	mq_msgsize;
266 	int	mq_curmsgs;
267 	int	__reserved[4];
268 };
269 
270 struct kinfo_proc32 {
271 	int	ki_structsize;
272 	int	ki_layout;
273 	uint32_t ki_args;
274 	uint32_t ki_paddr;
275 	uint32_t ki_addr;
276 	uint32_t ki_tracep;
277 	uint32_t ki_textvp;
278 	uint32_t ki_fd;
279 	uint32_t ki_vmspace;
280 	uint32_t ki_wchan;
281 	pid_t	ki_pid;
282 	pid_t	ki_ppid;
283 	pid_t	ki_pgid;
284 	pid_t	ki_tpgid;
285 	pid_t	ki_sid;
286 	pid_t	ki_tsid;
287 	short	ki_jobc;
288 	short	ki_spare_short1;
289 	dev_t	ki_tdev;
290 	sigset_t ki_siglist;
291 	sigset_t ki_sigmask;
292 	sigset_t ki_sigignore;
293 	sigset_t ki_sigcatch;
294 	uid_t	ki_uid;
295 	uid_t	ki_ruid;
296 	uid_t	ki_svuid;
297 	gid_t	ki_rgid;
298 	gid_t	ki_svgid;
299 	short	ki_ngroups;
300 	short	ki_spare_short2;
301 	gid_t 	ki_groups[KI_NGROUPS];
302 	uint32_t ki_size;
303 	int32_t ki_rssize;
304 	int32_t ki_swrss;
305 	int32_t ki_tsize;
306 	int32_t ki_dsize;
307 	int32_t ki_ssize;
308 	u_short	ki_xstat;
309 	u_short	ki_acflag;
310 	fixpt_t	ki_pctcpu;
311 	u_int	ki_estcpu;
312 	u_int	ki_slptime;
313 	u_int	ki_swtime;
314 	u_int	ki_cow;
315 	u_int64_t ki_runtime;
316 	struct	timeval32 ki_start;
317 	struct	timeval32 ki_childtime;
318 	int	ki_flag;
319 	int	ki_kiflag;
320 	int	ki_traceflag;
321 	char	ki_stat;
322 	signed char ki_nice;
323 	char	ki_lock;
324 	char	ki_rqindex;
325 	u_char	ki_oncpu;
326 	u_char	ki_lastcpu;
327 	char	ki_tdname[TDNAMLEN+1];
328 	char	ki_wmesg[WMESGLEN+1];
329 	char	ki_login[LOGNAMELEN+1];
330 	char	ki_lockname[LOCKNAMELEN+1];
331 	char	ki_comm[COMMLEN+1];
332 	char	ki_emul[KI_EMULNAMELEN+1];
333 	char	ki_loginclass[LOGINCLASSLEN+1];
334 	char	ki_sparestrings[50];
335 	int	ki_spareints[KI_NSPARE_INT];
336 	u_int	ki_cr_flags;
337 	int	ki_jid;
338 	int	ki_numthreads;
339 	lwpid_t	ki_tid;
340 	struct	priority ki_pri;
341 	struct	rusage32 ki_rusage;
342 	struct	rusage32 ki_rusage_ch;
343 	uint32_t ki_pcb;
344 	uint32_t ki_kstack;
345 	uint32_t ki_udata;
346 	uint32_t ki_tdaddr;
347 	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
348 	int	ki_sparelongs[KI_NSPARE_LONG];
349 	int	ki_sflag;
350 	int	ki_tdflags;
351 };
352 
353 struct kld32_file_stat_1 {
354 	int	version;	/* set to sizeof(struct kld_file_stat_1) */
355 	char	name[MAXPATHLEN];
356 	int	refs;
357 	int	id;
358 	uint32_t address;	/* load address */
359 	uint32_t size;		/* size in bytes */
360 };
361 
362 struct kld32_file_stat {
363 	int	version;	/* set to sizeof(struct kld_file_stat) */
364 	char	name[MAXPATHLEN];
365 	int	refs;
366 	int	id;
367 	uint32_t address;	/* load address */
368 	uint32_t size;		/* size in bytes */
369 	char	pathname[MAXPATHLEN];
370 };
371 
372 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
373