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