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: stable/11/sys/compat/freebsd32/freebsd32.h 360451 2020-04-28 20:14:38Z brooks $
27 */
28
29#ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
30#define _COMPAT_FREEBSD32_FREEBSD32_H_
31
32#include <sys/abi_compat.h>
33#include <sys/procfs.h>
34#include <sys/socket.h>
35#include <sys/user.h>
36
37/*
38 * Being a newer port, 32-bit FreeBSD/MIPS uses 64-bit time_t.
39 */
40#ifdef __mips__
41typedef	int64_t	time32_t;
42#else
43typedef	int32_t	time32_t;
44#endif
45
46struct timeval32 {
47	time32_t tv_sec;
48	int32_t tv_usec;
49};
50
51struct timespec32 {
52	time32_t tv_sec;
53	int32_t tv_nsec;
54};
55
56struct itimerspec32 {
57	struct timespec32  it_interval;
58	struct timespec32  it_value;
59};
60
61struct bintime32 {
62	uint32_t sec;
63	uint32_t frac[2];
64};
65
66struct rusage32 {
67	struct timeval32 ru_utime;
68	struct timeval32 ru_stime;
69	int32_t	ru_maxrss;
70	int32_t	ru_ixrss;
71	int32_t	ru_idrss;
72	int32_t	ru_isrss;
73	int32_t	ru_minflt;
74	int32_t	ru_majflt;
75	int32_t	ru_nswap;
76	int32_t	ru_inblock;
77	int32_t	ru_oublock;
78	int32_t	ru_msgsnd;
79	int32_t	ru_msgrcv;
80	int32_t	ru_nsignals;
81	int32_t	ru_nvcsw;
82	int32_t	ru_nivcsw;
83};
84
85struct wrusage32 {
86	struct rusage32	wru_self;
87	struct rusage32 wru_children;
88};
89
90struct itimerval32 {
91	struct timeval32 it_interval;
92	struct timeval32 it_value;
93};
94
95#define FREEBSD4_MNAMELEN        (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */
96
97/* 4.x version */
98struct statfs32 {
99	int32_t	f_spare2;
100	int32_t	f_bsize;
101	int32_t	f_iosize;
102	int32_t	f_blocks;
103	int32_t	f_bfree;
104	int32_t	f_bavail;
105	int32_t	f_files;
106	int32_t	f_ffree;
107	fsid_t	f_fsid;
108	uid_t	f_owner;
109	int32_t	f_type;
110	int32_t	f_flags;
111	int32_t	f_syncwrites;
112	int32_t	f_asyncwrites;
113	char	f_fstypename[MFSNAMELEN];
114	char	f_mntonname[FREEBSD4_MNAMELEN];
115	int32_t	f_syncreads;
116	int32_t	f_asyncreads;
117	int16_t	f_spares1;
118	char	f_mntfromname[FREEBSD4_MNAMELEN];
119	int16_t	f_spares2 __packed;
120	int32_t f_spare[2];
121};
122
123struct iovec32 {
124	u_int32_t iov_base;
125	int	iov_len;
126};
127
128struct msghdr32 {
129	u_int32_t	 msg_name;
130	socklen_t	 msg_namelen;
131	u_int32_t	 msg_iov;
132	int		 msg_iovlen;
133	u_int32_t	 msg_control;
134	socklen_t	 msg_controllen;
135	int		 msg_flags;
136};
137
138struct stat32 {
139	dev_t	st_dev;
140	ino_t	st_ino;
141	mode_t	st_mode;
142	nlink_t	st_nlink;
143	uid_t	st_uid;
144	gid_t	st_gid;
145	dev_t	st_rdev;
146	struct timespec32 st_atim;
147	struct timespec32 st_mtim;
148	struct timespec32 st_ctim;
149	off_t	st_size;
150	int64_t	st_blocks;
151	u_int32_t st_blksize;
152	u_int32_t st_flags;
153	u_int32_t st_gen;
154	int32_t	st_lspare;
155	struct timespec32 st_birthtim;
156	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
157	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
158};
159
160struct ostat32 {
161	__uint16_t st_dev;
162	ino_t	st_ino;
163	mode_t	st_mode;
164	nlink_t	st_nlink;
165	__uint16_t st_uid;
166	__uint16_t st_gid;
167	__uint16_t st_rdev;
168	__int32_t st_size;
169	struct timespec32 st_atim;
170	struct timespec32 st_mtim;
171	struct timespec32 st_ctim;
172	__int32_t st_blksize;
173	__int32_t st_blocks;
174	u_int32_t st_flags;
175	__uint32_t st_gen;
176};
177
178struct jail32_v0 {
179	u_int32_t	version;
180	uint32_t	path;
181	uint32_t	hostname;
182	u_int32_t	ip_number;
183};
184
185struct jail32 {
186	uint32_t	version;
187	uint32_t	path;
188	uint32_t	hostname;
189	uint32_t	jailname;
190	uint32_t	ip4s;
191	uint32_t	ip6s;
192	uint32_t	ip4;
193	uint32_t	ip6;
194};
195
196struct sigaction32 {
197	u_int32_t	sa_u;
198	int		sa_flags;
199	sigset_t	sa_mask;
200};
201
202struct thr_param32 {
203	uint32_t start_func;
204	uint32_t arg;
205	uint32_t stack_base;
206	uint32_t stack_size;
207	uint32_t tls_base;
208	uint32_t tls_size;
209	uint32_t child_tid;
210	uint32_t parent_tid;
211	int32_t	 flags;
212	uint32_t rtp;
213	uint32_t spare[3];
214};
215
216struct i386_ldt_args32 {
217	uint32_t start;
218	uint32_t descs;
219	uint32_t num;
220};
221
222struct mq_attr32 {
223	int	mq_flags;
224	int	mq_maxmsg;
225	int	mq_msgsize;
226	int	mq_curmsgs;
227	int	__reserved[4];
228};
229
230struct kinfo_proc32 {
231	int	ki_structsize;
232	int	ki_layout;
233	uint32_t ki_args;
234	uint32_t ki_paddr;
235	uint32_t ki_addr;
236	uint32_t ki_tracep;
237	uint32_t ki_textvp;
238	uint32_t ki_fd;
239	uint32_t ki_vmspace;
240	uint32_t ki_wchan;
241	pid_t	ki_pid;
242	pid_t	ki_ppid;
243	pid_t	ki_pgid;
244	pid_t	ki_tpgid;
245	pid_t	ki_sid;
246	pid_t	ki_tsid;
247	short	ki_jobc;
248	short	ki_spare_short1;
249	dev_t	ki_tdev;
250	sigset_t ki_siglist;
251	sigset_t ki_sigmask;
252	sigset_t ki_sigignore;
253	sigset_t ki_sigcatch;
254	uid_t	ki_uid;
255	uid_t	ki_ruid;
256	uid_t	ki_svuid;
257	gid_t	ki_rgid;
258	gid_t	ki_svgid;
259	short	ki_ngroups;
260	short	ki_spare_short2;
261	gid_t 	ki_groups[KI_NGROUPS];
262	uint32_t ki_size;
263	int32_t ki_rssize;
264	int32_t ki_swrss;
265	int32_t ki_tsize;
266	int32_t ki_dsize;
267	int32_t ki_ssize;
268	u_short	ki_xstat;
269	u_short	ki_acflag;
270	fixpt_t	ki_pctcpu;
271	u_int	ki_estcpu;
272	u_int	ki_slptime;
273	u_int	ki_swtime;
274	u_int	ki_cow;
275	u_int64_t ki_runtime;
276	struct	timeval32 ki_start;
277	struct	timeval32 ki_childtime;
278	int	ki_flag;
279	int	ki_kiflag;
280	int	ki_traceflag;
281	char	ki_stat;
282	signed char ki_nice;
283	char	ki_lock;
284	char	ki_rqindex;
285	u_char	ki_oncpu_old;
286	u_char	ki_lastcpu_old;
287	char	ki_tdname[TDNAMLEN+1];
288	char	ki_wmesg[WMESGLEN+1];
289	char	ki_login[LOGNAMELEN+1];
290	char	ki_lockname[LOCKNAMELEN+1];
291	char	ki_comm[COMMLEN+1];
292	char	ki_emul[KI_EMULNAMELEN+1];
293	char	ki_loginclass[LOGINCLASSLEN+1];
294	char	ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
295	char	ki_sparestrings[46];
296	int	ki_spareints[KI_NSPARE_INT];
297	int	ki_oncpu;
298	int	ki_lastcpu;
299	int	ki_tracer;
300	int	ki_flag2;
301	int	ki_fibnum;
302	u_int	ki_cr_flags;
303	int	ki_jid;
304	int	ki_numthreads;
305	lwpid_t	ki_tid;
306	struct	priority ki_pri;
307	struct	rusage32 ki_rusage;
308	struct	rusage32 ki_rusage_ch;
309	uint32_t ki_pcb;
310	uint32_t ki_kstack;
311	uint32_t ki_udata;
312	uint32_t ki_tdaddr;
313	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
314	int	ki_sparelongs[KI_NSPARE_LONG];
315	int	ki_sflag;
316	int	ki_tdflags;
317};
318
319struct kinfo_sigtramp32 {
320	uint32_t ksigtramp_start;
321	uint32_t ksigtramp_end;
322	uint32_t ksigtramp_spare[4];
323};
324
325struct kld32_file_stat_1 {
326	int	version;	/* set to sizeof(struct kld_file_stat_1) */
327	char	name[MAXPATHLEN];
328	int	refs;
329	int	id;
330	uint32_t address;	/* load address */
331	uint32_t size;		/* size in bytes */
332};
333
334struct kld32_file_stat {
335	int	version;	/* set to sizeof(struct kld_file_stat) */
336	char	name[MAXPATHLEN];
337	int	refs;
338	int	id;
339	uint32_t address;	/* load address */
340	uint32_t size;		/* size in bytes */
341	char	pathname[MAXPATHLEN];
342};
343
344struct procctl_reaper_pids32 {
345	u_int	rp_count;
346	u_int	rp_pad0[15];
347	uint32_t rp_pids;
348};
349
350#endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
351