xref: /openbmc/qemu/bsd-user/syscall_defs.h (revision 366c5c9f)
184778508Sblueswir1 /*
2*366c5c9fSWarner Losh  *  System call related declarations
384778508Sblueswir1  *
4*366c5c9fSWarner Losh  *  Copyright (c) 2013-15 Stacey D. Son (sson at FreeBSD)
584778508Sblueswir1  *
6*366c5c9fSWarner Losh  *  This program is free software; you can redistribute it and/or modify
7*366c5c9fSWarner Losh  *  it under the terms of the GNU General Public License as published by
8*366c5c9fSWarner Losh  *  the Free Software Foundation; either version 2 of the License, or
9*366c5c9fSWarner Losh  *  (at your option) any later version.
1084778508Sblueswir1  *
11*366c5c9fSWarner Losh  *  This program is distributed in the hope that it will be useful,
12*366c5c9fSWarner Losh  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*366c5c9fSWarner Losh  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*366c5c9fSWarner Losh  *  GNU General Public License for more details.
15*366c5c9fSWarner Losh  *
16*366c5c9fSWarner Losh  *  You should have received a copy of the GNU General Public License
17*366c5c9fSWarner Losh  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
1884778508Sblueswir1  */
1984778508Sblueswir1 
20*366c5c9fSWarner Losh #ifndef _SYSCALL_DEFS_H_
21*366c5c9fSWarner Losh #define _SYSCALL_DEFS_H_
2284778508Sblueswir1 
23*366c5c9fSWarner Losh #include <sys/syscall.h>
2484778508Sblueswir1 
2584778508Sblueswir1 #include "errno_defs.h"
2684778508Sblueswir1 
2784778508Sblueswir1 #include "freebsd/syscall_nr.h"
2884778508Sblueswir1 #include "netbsd/syscall_nr.h"
2984778508Sblueswir1 #include "openbsd/syscall_nr.h"
3078cfb07fSJuergen Lock 
31*366c5c9fSWarner Losh /*
32*366c5c9fSWarner Losh  * machine/_types.h
33*366c5c9fSWarner Losh  * or x86/_types.h
34*366c5c9fSWarner Losh  */
35*366c5c9fSWarner Losh 
36*366c5c9fSWarner Losh /*
37*366c5c9fSWarner Losh  * time_t seems to be very inconsistly defined for the different *BSD's...
38*366c5c9fSWarner Losh  *
39*366c5c9fSWarner Losh  * FreeBSD uses a 64bits time_t except on i386
40*366c5c9fSWarner Losh  * so we have to add a special case here.
41*366c5c9fSWarner Losh  *
42*366c5c9fSWarner Losh  * On NetBSD time_t is always defined as an int64_t.  On OpenBSD time_t
43*366c5c9fSWarner Losh  * is always defined as an int.
44*366c5c9fSWarner Losh  *
45*366c5c9fSWarner Losh  */
46*366c5c9fSWarner Losh #if (!defined(TARGET_I386))
47*366c5c9fSWarner Losh typedef int64_t target_freebsd_time_t;
48*366c5c9fSWarner Losh #else
49*366c5c9fSWarner Losh typedef int32_t target_freebsd_time_t;
50*366c5c9fSWarner Losh #endif
51*366c5c9fSWarner Losh 
5278cfb07fSJuergen Lock struct target_iovec {
5378cfb07fSJuergen Lock     abi_long iov_base;   /* Starting address */
5478cfb07fSJuergen Lock     abi_long iov_len;   /* Number of bytes */
5578cfb07fSJuergen Lock };
5678cfb07fSJuergen Lock 
57*366c5c9fSWarner Losh /*
58*366c5c9fSWarner Losh  *  sys/mman.h
59*366c5c9fSWarner Losh  */
60*366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080  /* previously misimplemented */
61*366c5c9fSWarner Losh                                                 /* MAP_INHERIT */
62*366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100  /* previously unimplemented */
63*366c5c9fSWarner Losh                                                 /* MAP_NOEXTEND */
64*366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK        0x0400  /* region grows down, like a */
65*366c5c9fSWarner Losh                                                 /* stack */
66*366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC       0x0800  /* page to but do not sync */
67*366c5c9fSWarner Losh                                                 /* underlying file */
68*366c5c9fSWarner Losh 
69*366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK     0x1ff7
70*366c5c9fSWarner Losh 
71*366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT       0x0080  /* region is retained after */
72*366c5c9fSWarner Losh                                                 /* exec */
73*366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED      0x0400  /* attempt hint address, even */
74*366c5c9fSWarner Losh                                                 /* within break */
75*366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED         0x0800  /* mlock() mapping when it is */
76*366c5c9fSWarner Losh                                                 /* established */
77*366c5c9fSWarner Losh 
78*366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK         0x2000  /* allocated from memory, */
79*366c5c9fSWarner Losh                                                 /* swap space (stack) */
80*366c5c9fSWarner Losh 
81*366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK      0x3ff7
82*366c5c9fSWarner Losh 
83*366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT      0x0080  /* region is retained after */
84*366c5c9fSWarner Losh                                                 /* exec */
85*366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND     0x0100  /* for MAP_FILE, don't change */
86*366c5c9fSWarner Losh                                                 /* file size */
87*366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED     0x0400  /* attempt hint address, */
88*366c5c9fSWarner Losh                                                 /* even within heap */
89*366c5c9fSWarner Losh 
90*366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK     0x17f7
91*366c5c9fSWarner Losh 
92*366c5c9fSWarner Losh /* XXX */
93*366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK         0x3ff7
94*366c5c9fSWarner Losh 
95*366c5c9fSWarner Losh /*
96*366c5c9fSWarner Losh  * sys/time.h
97*366c5c9fSWarner Losh  * sys/timex.h
98*366c5c9fSWarner Losh  */
99*366c5c9fSWarner Losh 
100*366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t;
101*366c5c9fSWarner Losh 
102*366c5c9fSWarner Losh /* compare to sys/timespec.h */
103*366c5c9fSWarner Losh struct target_freebsd_timespec {
104*366c5c9fSWarner Losh     target_freebsd_time_t   tv_sec;     /* seconds */
105*366c5c9fSWarner Losh     abi_long                tv_nsec;    /* and nanoseconds */
106*366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
107*366c5c9fSWarner Losh     abi_long _pad;
108*366c5c9fSWarner Losh #endif
109*366c5c9fSWarner Losh };
110*366c5c9fSWarner Losh 
111*366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID   0
112*366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID   1
113*366c5c9fSWarner Losh 
114*366c5c9fSWarner Losh /* sys/umtx.h */
115*366c5c9fSWarner Losh struct target_freebsd__umtx_time {
116*366c5c9fSWarner Losh     struct target_freebsd_timespec  _timeout;
117*366c5c9fSWarner Losh     uint32_t    _flags;
118*366c5c9fSWarner Losh     uint32_t    _clockid;
119*366c5c9fSWarner Losh };
120*366c5c9fSWarner Losh 
121*366c5c9fSWarner Losh struct target_freebsd_timeval {
122*366c5c9fSWarner Losh     target_freebsd_time_t       tv_sec; /* seconds */
123*366c5c9fSWarner Losh     target_freebsd_suseconds_t  tv_usec;/* and microseconds */
124*366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
125*366c5c9fSWarner Losh     abi_long _pad;
126*366c5c9fSWarner Losh #endif
127*366c5c9fSWarner Losh };
128*366c5c9fSWarner Losh 
129*366c5c9fSWarner Losh /*
130*366c5c9fSWarner Losh  *  sys/resource.h
131*366c5c9fSWarner Losh  */
132*366c5c9fSWarner Losh #if defined(__FreeBSD__)
133*366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY    RLIM_INFINITY
134*366c5c9fSWarner Losh #else
135*366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY    ((abi_ulong)-1)
136*366c5c9fSWarner Losh #endif
137*366c5c9fSWarner Losh 
138*366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU       0
139*366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE     1
140*366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA      2
141*366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK     3
142*366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE      4
143*366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS       5
144*366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK   6
145*366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC     7
146*366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE    8
147*366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE    9
148*366c5c9fSWarner Losh #define TARGET_RLIMIT_AS        10
149*366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS      11
150*366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP      12
151*366c5c9fSWarner Losh 
152*366c5c9fSWarner Losh struct target_rlimit {
153*366c5c9fSWarner Losh     uint64_t rlim_cur;
154*366c5c9fSWarner Losh     uint64_t rlim_max;
155*366c5c9fSWarner Losh };
156*366c5c9fSWarner Losh 
157*366c5c9fSWarner Losh struct target_freebsd_rusage {
158*366c5c9fSWarner Losh     struct target_freebsd_timeval ru_utime; /* user time used */
159*366c5c9fSWarner Losh     struct target_freebsd_timeval ru_stime; /* system time used */
160*366c5c9fSWarner Losh     abi_long    ru_maxrss;      /* maximum resident set size */
161*366c5c9fSWarner Losh     abi_long    ru_ixrss;       /* integral shared memory size */
162*366c5c9fSWarner Losh     abi_long    ru_idrss;       /* integral unshared data size */
163*366c5c9fSWarner Losh     abi_long    ru_isrss;       /* integral unshared stack size */
164*366c5c9fSWarner Losh     abi_long    ru_minflt;      /* page reclaims */
165*366c5c9fSWarner Losh     abi_long    ru_majflt;      /* page faults */
166*366c5c9fSWarner Losh     abi_long    ru_nswap;       /* swaps */
167*366c5c9fSWarner Losh     abi_long    ru_inblock;     /* block input operations */
168*366c5c9fSWarner Losh     abi_long    ru_oublock;     /* block output operations */
169*366c5c9fSWarner Losh     abi_long    ru_msgsnd;      /* messages sent */
170*366c5c9fSWarner Losh     abi_long    ru_msgrcv;      /* messages received */
171*366c5c9fSWarner Losh     abi_long    ru_nsignals;    /* signals received */
172*366c5c9fSWarner Losh     abi_long    ru_nvcsw;       /* voluntary context switches */
173*366c5c9fSWarner Losh     abi_long    ru_nivcsw;      /* involuntary context switches */
174*366c5c9fSWarner Losh };
175*366c5c9fSWarner Losh 
176*366c5c9fSWarner Losh struct target_freebsd__wrusage {
177*366c5c9fSWarner Losh     struct target_freebsd_rusage wru_self;
178*366c5c9fSWarner Losh     struct target_freebsd_rusage wru_children;
179*366c5c9fSWarner Losh };
180*366c5c9fSWarner Losh 
181*366c5c9fSWarner Losh #endif /* ! _SYSCALL_DEFS_H_ */
182