blob: 12c8407144b51ad6ed24c7cd0517ee9aa07b5dec [file] [log] [blame]
bellard31e31b82003-02-18 22:55:36 +00001/* common syscall defines for all architectures */
2
bellard2521d692003-06-15 19:58:13 +00003/* Note: although the syscall numbers change between architectures,
Dong Xu Wangb4916d72011-11-22 18:06:17 +08004 most of them stay the same, so we handle it by putting ifdefs if
bellard2521d692003-06-15 19:58:13 +00005 necessary */
6
Paolo Bonzinicb9c3772012-12-06 12:15:58 +01007#ifndef SYSCALL_DEFS_H
Markus Armbruster1b3c4fd2016-06-29 15:54:17 +02008#define SYSCALL_DEFS_H
Paolo Bonzinicb9c3772012-12-06 12:15:58 +01009
bellard6180a182003-09-30 21:04:53 +000010#include "syscall_nr.h"
bellard2521d692003-06-15 19:58:13 +000011
Aleksandar Markovicff71a452016-09-22 18:56:57 +020012
13/* socket operations for socketcall() */
14#define TARGET_SYS_SOCKET 1 /* socket() */
15#define TARGET_SYS_BIND 2 /* bind() */
16#define TARGET_SYS_CONNECT 3 /* connect() */
17#define TARGET_SYS_LISTEN 4 /* listen() */
18#define TARGET_SYS_ACCEPT 5 /* accept() */
19#define TARGET_SYS_GETSOCKNAME 6 /* getsockname() */
20#define TARGET_SYS_GETPEERNAME 7 /* getpeername() */
21#define TARGET_SYS_SOCKETPAIR 8 /* socketpair() */
22#define TARGET_SYS_SEND 9 /* send() */
23#define TARGET_SYS_RECV 10 /* recv() */
24#define TARGET_SYS_SENDTO 11 /* sendto() */
25#define TARGET_SYS_RECVFROM 12 /* recvfrom() */
26#define TARGET_SYS_SHUTDOWN 13 /* shutdown() */
27#define TARGET_SYS_SETSOCKOPT 14 /* setsockopt() */
28#define TARGET_SYS_GETSOCKOPT 15 /* getsockopt() */
29#define TARGET_SYS_SENDMSG 16 /* sendmsg() */
30#define TARGET_SYS_RECVMSG 17 /* recvmsg() */
31#define TARGET_SYS_ACCEPT4 18 /* accept4() */
32#define TARGET_SYS_RECVMMSG 19 /* recvmmsg() */
33#define TARGET_SYS_SENDMMSG 20 /* sendmmsg() */
bellard31e31b82003-02-18 22:55:36 +000034
bellard8853f862004-02-22 14:57:26 +000035#define IPCOP_semop 1
36#define IPCOP_semget 2
37#define IPCOP_semctl 3
38#define IPCOP_semtimedop 4
39#define IPCOP_msgsnd 11
40#define IPCOP_msgrcv 12
41#define IPCOP_msgget 13
42#define IPCOP_msgctl 14
43#define IPCOP_shmat 21
44#define IPCOP_shmdt 22
45#define IPCOP_shmget 23
46#define IPCOP_shmctl 24
47
bellard2521d692003-06-15 19:58:13 +000048/*
49 * The following is for compatibility across the various Linux
50 * platforms. The i386 ioctl numbering scheme doesn't really enforce
51 * a type field. De facto, however, the top 8 bits of the lower 16
52 * bits are indeed used as a type field, so we might just as well make
53 * this explicit here. Please be sure to use the decoding macros
54 * below from now on.
55 */
56#define TARGET_IOC_NRBITS 8
57#define TARGET_IOC_TYPEBITS 8
58
Peter Maydell716f3fb2016-03-01 16:25:17 +000059#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
60 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
Andreas Schwabcd98d392014-03-02 19:36:40 +000061 || defined(TARGET_SPARC) \
Riku Voipio0c866a72011-04-18 15:23:06 +030062 || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
Mika Westerberg74d753a2009-04-07 16:57:29 +030063 /* 16 bit uid wrappers emulation */
64#define USE_UID16
Riku Voipio0c866a72011-04-18 15:23:06 +030065#define target_id uint16_t
66#else
67#define target_id uint32_t
Mika Westerberg74d753a2009-04-07 16:57:29 +030068#endif
69
pbrooke6e59062006-10-22 00:18:54 +000070#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
Chen Gangb16189b2015-08-21 05:36:37 +080071 || defined(TARGET_M68K) || defined(TARGET_CRIS) \
Peter Maydelldaa43742018-03-08 14:47:32 +000072 || defined(TARGET_S390X) \
Marek Vasuta0a839b2017-01-18 23:01:42 +010073 || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
Max Filippovba7651f2017-01-25 10:54:11 -080074 || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
75 || defined(TARGET_XTENSA)
bellard2521d692003-06-15 19:58:13 +000076
77#define TARGET_IOC_SIZEBITS 14
78#define TARGET_IOC_DIRBITS 2
79
80#define TARGET_IOC_NONE 0U
81#define TARGET_IOC_WRITE 1U
82#define TARGET_IOC_READ 2U
83
bellard048f6b42005-11-26 18:47:20 +000084#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +020085 defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
86 defined(TARGET_MIPS)
bellard2521d692003-06-15 19:58:13 +000087
88#define TARGET_IOC_SIZEBITS 13
89#define TARGET_IOC_DIRBITS 3
90
91#define TARGET_IOC_NONE 1U
92#define TARGET_IOC_READ 2U
93#define TARGET_IOC_WRITE 4U
94
Richard Hendersona10d1e52016-12-15 09:56:41 -080095#elif defined(TARGET_HPPA)
96
97#define TARGET_IOC_SIZEBITS 14
98#define TARGET_IOC_DIRBITS 2
99
100#define TARGET_IOC_NONE 0U
101#define TARGET_IOC_WRITE 2U
102#define TARGET_IOC_READ 1U
103
bellard2521d692003-06-15 19:58:13 +0000104#else
105#error unsupported CPU
106#endif
107
108#define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
109#define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
110#define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
111#define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
112
113#define TARGET_IOC_NRSHIFT 0
114#define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
115#define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
116#define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
117
118#define TARGET_IOC(dir,type,nr,size) \
119 (((dir) << TARGET_IOC_DIRSHIFT) | \
120 ((type) << TARGET_IOC_TYPESHIFT) | \
121 ((nr) << TARGET_IOC_NRSHIFT) | \
122 ((size) << TARGET_IOC_SIZESHIFT))
123
124/* used to create numbers */
125#define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
126#define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
127#define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
128#define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
129
130/* the size is automatically computed for these defines */
131#define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
132#define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
133#define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
134
bellard7854b052003-03-29 17:22:23 +0000135struct target_sockaddr {
136 uint16_t sa_family;
137 uint8_t sa_data[14];
138};
139
Joakim Tjernlund33a29b52014-07-12 15:47:07 +0200140struct target_sockaddr_ll {
141 uint16_t sll_family; /* Always AF_PACKET */
142 uint16_t sll_protocol; /* Physical layer protocol */
143 int sll_ifindex; /* Interface number */
144 uint16_t sll_hatype; /* ARP hardware type */
145 uint8_t sll_pkttype; /* Packet type */
146 uint8_t sll_halen; /* Length of address */
147 uint8_t sll_addr[8]; /* Physical layer address */
148};
149
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200150struct target_sockaddr_un {
151 uint16_t su_family;
152 uint8_t sun_path[108];
153};
154
155struct target_in_addr {
156 uint32_t s_addr; /* big endian */
157};
158
159struct target_sockaddr_in {
160 uint16_t sin_family;
161 int16_t sin_port; /* big endian */
162 struct target_in_addr sin_addr;
163 uint8_t __pad[sizeof(struct target_sockaddr) -
164 sizeof(uint16_t) - sizeof(int16_t) -
165 sizeof(struct target_in_addr)];
166};
167
Helge Delleree1ac3a2017-02-18 23:31:30 +0100168struct target_sockaddr_in6 {
169 uint16_t sin6_family;
170 uint16_t sin6_port; /* big endian */
171 uint32_t sin6_flowinfo; /* big endian */
172 struct in6_addr sin6_addr; /* IPv6 address, big endian */
173 uint32_t sin6_scope_id;
174};
175
Laurent Vivierf57d4192013-08-30 01:46:41 +0200176struct target_sock_filter {
177 abi_ushort code;
178 uint8_t jt;
179 uint8_t jf;
180 abi_uint k;
181};
182
183struct target_sock_fprog {
184 abi_ushort len;
185 abi_ulong filter;
186};
187
Lionel Landwerlinb975b832009-04-25 23:30:19 +0200188struct target_ip_mreq {
189 struct target_in_addr imr_multiaddr;
190 struct target_in_addr imr_address;
191};
192
193struct target_ip_mreqn {
194 struct target_in_addr imr_multiaddr;
195 struct target_in_addr imr_address;
196 abi_long imr_ifindex;
197};
198
Lionel Landwerlin6e3cb582009-04-25 23:31:18 +0200199struct target_ip_mreq_source {
200 /* big endian */
201 uint32_t imr_multiaddr;
202 uint32_t imr_interface;
203 uint32_t imr_sourceaddr;
204};
205
Carlo Marcelo Arenas Belón83eb6e52018-08-24 01:56:01 -0700206struct target_linger {
207 abi_int l_onoff; /* Linger active */
208 abi_int l_linger; /* How long to linger for */
209};
210
bellard31e31b82003-02-18 22:55:36 +0000211struct target_timeval {
blueswir1992f48a2007-10-14 16:27:31 +0000212 abi_long tv_sec;
213 abi_long tv_usec;
bellard31e31b82003-02-18 22:55:36 +0000214};
215
bellard1b6b0292003-03-22 17:31:38 +0000216struct target_timespec {
blueswir1992f48a2007-10-14 16:27:31 +0000217 abi_long tv_sec;
218 abi_long tv_nsec;
bellard1b6b0292003-03-22 17:31:38 +0000219};
220
Paul Burtonef4467e2014-06-22 11:25:40 +0100221struct target_timezone {
222 abi_int tz_minuteswest;
223 abi_int tz_dsttime;
224};
225
bellard66fb9762003-03-23 01:06:05 +0000226struct target_itimerval {
227 struct target_timeval it_interval;
228 struct target_timeval it_value;
229};
230
Erik de Castro Lopo905bba12013-11-29 18:39:22 +1100231struct target_itimerspec {
232 struct target_timespec it_interval;
233 struct target_timespec it_value;
234};
235
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200236struct target_timex {
237 abi_uint modes; /* Mode selector */
238 abi_long offset; /* Time offset */
239 abi_long freq; /* Frequency offset */
240 abi_long maxerror; /* Maximum error (microseconds) */
241 abi_long esterror; /* Estimated error (microseconds) */
242 abi_int status; /* Clock command/status */
243 abi_long constant; /* PLL (phase-locked loop) time constant */
244 abi_long precision; /* Clock precision (microseconds, ro) */
245 abi_long tolerance; /* Clock freq. tolerance (ppm, ro) */
246 struct target_timeval time; /* Current time */
247 abi_long tick; /* Microseconds between clock ticks */
248 abi_long ppsfreq; /* PPS (pulse per second) frequency */
249 abi_long jitter; /* PPS jitter (ro); nanoseconds */
250 abi_int shift; /* PPS interval duration (seconds) */
251 abi_long stabil; /* PPS stability */
252 abi_long jitcnt; /* PPS jitter limit exceeded (ro) */
253 abi_long calcnt; /* PPS calibration intervals */
254 abi_long errcnt; /* PPS calibration errors */
255 abi_long stbcnt; /* PPS stability limit exceeded */
256 abi_int tai; /* TAI offset */
257
258 /* Further padding bytes to allow for future expansion */
259 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
260 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
261 abi_int:32; abi_int:32; abi_int:32;
262};
263
Anthony Liguoric227f092009-10-01 16:12:16 -0500264typedef abi_long target_clock_t;
bellard32f36bc2003-03-30 21:29:48 +0000265
bellardc596ed12003-07-13 17:32:31 +0000266#define TARGET_HZ 100
267
bellard32f36bc2003-03-30 21:29:48 +0000268struct target_tms {
Anthony Liguoric227f092009-10-01 16:12:16 -0500269 target_clock_t tms_utime;
270 target_clock_t tms_stime;
271 target_clock_t tms_cutime;
272 target_clock_t tms_cstime;
bellard32f36bc2003-03-30 21:29:48 +0000273};
274
bellard6180a182003-09-30 21:04:53 +0000275struct target_utimbuf {
blueswir1992f48a2007-10-14 16:27:31 +0000276 abi_long actime;
277 abi_long modtime;
bellard6180a182003-09-30 21:04:53 +0000278};
279
bellardf2674e32003-07-09 12:26:09 +0000280struct target_sel_arg_struct {
blueswir1992f48a2007-10-14 16:27:31 +0000281 abi_long n;
282 abi_long inp, outp, exp;
283 abi_long tvp;
bellardf2674e32003-07-09 12:26:09 +0000284};
285
bellard31e31b82003-02-18 22:55:36 +0000286struct target_iovec {
blueswir1992f48a2007-10-14 16:27:31 +0000287 abi_long iov_base; /* Starting address */
288 abi_long iov_len; /* Number of bytes */
bellard31e31b82003-02-18 22:55:36 +0000289};
290
bellard1a9353d2003-03-16 20:28:50 +0000291struct target_msghdr {
blueswir1992f48a2007-10-14 16:27:31 +0000292 abi_long msg_name; /* Socket name */
293 int msg_namelen; /* Length of name */
294 abi_long msg_iov; /* Data blocks */
295 abi_long msg_iovlen; /* Number of blocks */
296 abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
297 abi_long msg_controllen; /* Length of cmsg list */
bellard1a9353d2003-03-16 20:28:50 +0000298 unsigned int msg_flags;
299};
300
bellard7854b052003-03-29 17:22:23 +0000301struct target_cmsghdr {
blueswir1992f48a2007-10-14 16:27:31 +0000302 abi_long cmsg_len;
bellard7854b052003-03-29 17:22:23 +0000303 int cmsg_level;
304 int cmsg_type;
305};
306
307#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
Jonathan Neuschäferee104582015-09-03 07:27:26 +0200308#define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
309 __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
blueswir1992f48a2007-10-14 16:27:31 +0000310#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
311 & (size_t) ~(sizeof (abi_long) - 1))
Peter Maydellad762b92017-12-15 13:52:56 +0000312#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
313 TARGET_CMSG_ALIGN(len))
314#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
bellard7854b052003-03-29 17:22:23 +0000315
316static __inline__ struct target_cmsghdr *
Jonathan Neuschäferee104582015-09-03 07:27:26 +0200317__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
318 struct target_cmsghdr *__cmsg,
319 struct target_cmsghdr *__cmsg_start)
bellard7854b052003-03-29 17:22:23 +0000320{
ths2b8bdef2007-05-28 21:35:23 +0000321 struct target_cmsghdr *__ptr;
bellard7854b052003-03-29 17:22:23 +0000322
ths2b8bdef2007-05-28 21:35:23 +0000323 __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
Matthias Brauncbb21ee2011-08-12 19:57:41 +0200324 + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
Jonathan Neuschäferee104582015-09-03 07:27:26 +0200325 if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
326 > tswapal(__mhdr->msg_controllen)) {
bellard7854b052003-03-29 17:22:23 +0000327 /* No more entries. */
ths2b8bdef2007-05-28 21:35:23 +0000328 return (struct target_cmsghdr *)0;
Jonathan Neuschäferee104582015-09-03 07:27:26 +0200329 }
330 return __ptr;
bellard7854b052003-03-29 17:22:23 +0000331}
332
Alexander Graff19e00d2014-03-02 19:36:42 +0000333struct target_mmsghdr {
334 struct target_msghdr msg_hdr; /* Message header */
335 unsigned int msg_len; /* Number of bytes transmitted */
336};
bellard7854b052003-03-29 17:22:23 +0000337
bellard31e31b82003-02-18 22:55:36 +0000338struct target_rusage {
339 struct target_timeval ru_utime; /* user time used */
340 struct target_timeval ru_stime; /* system time used */
blueswir1992f48a2007-10-14 16:27:31 +0000341 abi_long ru_maxrss; /* maximum resident set size */
342 abi_long ru_ixrss; /* integral shared memory size */
343 abi_long ru_idrss; /* integral unshared data size */
344 abi_long ru_isrss; /* integral unshared stack size */
345 abi_long ru_minflt; /* page reclaims */
346 abi_long ru_majflt; /* page faults */
347 abi_long ru_nswap; /* swaps */
348 abi_long ru_inblock; /* block input operations */
349 abi_long ru_oublock; /* block output operations */
350 abi_long ru_msgsnd; /* messages sent */
351 abi_long ru_msgrcv; /* messages received */
352 abi_long ru_nsignals; /* signals received */
353 abi_long ru_nvcsw; /* voluntary context switches */
354 abi_long ru_nivcsw; /* involuntary " */
bellard31e31b82003-02-18 22:55:36 +0000355};
356
357typedef struct {
358 int val[2];
Anthony Liguoric227f092009-10-01 16:12:16 -0500359} kernel_fsid_t;
bellard31e31b82003-02-18 22:55:36 +0000360
bellarddab2ed92003-03-22 15:23:14 +0000361struct target_dirent {
Dmitry V. Levin333858b2012-08-21 02:13:12 +0400362 abi_long d_ino;
363 abi_long d_off;
364 unsigned short d_reclen;
365 char d_name[];
bellarddab2ed92003-03-22 15:23:14 +0000366};
367
368struct target_dirent64 {
369 uint64_t d_ino;
370 int64_t d_off;
371 unsigned short d_reclen;
372 unsigned char d_type;
373 char d_name[256];
374};
375
376
bellard31e31b82003-02-18 22:55:36 +0000377/* mostly generic signal stuff */
blueswir1992f48a2007-10-14 16:27:31 +0000378#define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
379#define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
380#define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
bellard31e31b82003-02-18 22:55:36 +0000381
382#ifdef TARGET_MIPS
383#define TARGET_NSIG 128
384#else
385#define TARGET_NSIG 64
386#endif
blueswir1992f48a2007-10-14 16:27:31 +0000387#define TARGET_NSIG_BPW TARGET_ABI_BITS
bellard31e31b82003-02-18 22:55:36 +0000388#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
389
390typedef struct {
blueswir1992f48a2007-10-14 16:27:31 +0000391 abi_ulong sig[TARGET_NSIG_WORDS];
Anthony Liguoric227f092009-10-01 16:12:16 -0500392} target_sigset_t;
bellard31e31b82003-02-18 22:55:36 +0000393
bellard66fb9762003-03-23 01:06:05 +0000394#ifdef BSWAP_NEEDED
Anthony Liguoric227f092009-10-01 16:12:16 -0500395static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
bellard66fb9762003-03-23 01:06:05 +0000396{
397 int i;
398 for(i = 0;i < TARGET_NSIG_WORDS; i++)
Matthias Brauncbb21ee2011-08-12 19:57:41 +0200399 d->sig[i] = tswapal(s->sig[i]);
bellard66fb9762003-03-23 01:06:05 +0000400}
401#else
Anthony Liguoric227f092009-10-01 16:12:16 -0500402static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
bellard66fb9762003-03-23 01:06:05 +0000403{
404 *d = *s;
405}
406#endif
407
Anthony Liguoric227f092009-10-01 16:12:16 -0500408static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
bellard66fb9762003-03-23 01:06:05 +0000409{
410 int i;
411 d->sig[0] = set;
412 for(i = 1;i < TARGET_NSIG_WORDS; i++)
413 d->sig[i] = 0;
414}
415
Anthony Liguoric227f092009-10-01 16:12:16 -0500416void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
417void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
blueswir1992f48a2007-10-14 16:27:31 +0000418void host_to_target_old_sigset(abi_ulong *old_sigset,
bellard66fb9762003-03-23 01:06:05 +0000419 const sigset_t *sigset);
ths5fafdf22007-09-16 21:08:06 +0000420void target_to_host_old_sigset(sigset_t *sigset,
blueswir1992f48a2007-10-14 16:27:31 +0000421 const abi_ulong *old_sigset);
bellard66fb9762003-03-23 01:06:05 +0000422struct target_sigaction;
423int do_sigaction(int sig, const struct target_sigaction *act,
424 struct target_sigaction *oact);
425
Laurent Vivier9850f9f2018-05-29 21:42:00 +0200426#include "target_signal.h"
427
Richard Henderson7f047de2017-10-31 13:53:52 +0100428#ifdef TARGET_SA_RESTORER
429#define TARGET_ARCH_HAS_SA_RESTORER 1
430#endif
431
Richard Henderson6049f4f2009-12-27 18:30:03 -0800432#if defined(TARGET_ALPHA)
433struct target_old_sigaction {
434 abi_ulong _sa_handler;
435 abi_ulong sa_mask;
Richard Hendersond2565872013-01-04 16:39:32 -0800436 int32_t sa_flags;
Richard Henderson6049f4f2009-12-27 18:30:03 -0800437};
bellard106ec872006-06-27 21:08:10 +0000438
Richard Henderson6049f4f2009-12-27 18:30:03 -0800439struct target_rt_sigaction {
440 abi_ulong _sa_handler;
441 abi_ulong sa_flags;
442 target_sigset_t sa_mask;
443};
444
445/* This is the struct used inside the kernel. The ka_restorer
446 field comes from the 5th argument to sys_rt_sigaction. */
447struct target_sigaction {
448 abi_ulong _sa_handler;
449 abi_ulong sa_flags;
450 target_sigset_t sa_mask;
451 abi_ulong sa_restorer;
452};
453#elif defined(TARGET_MIPS)
bellard106ec872006-06-27 21:08:10 +0000454struct target_sigaction {
ths540635b2007-09-30 01:58:33 +0000455 uint32_t sa_flags;
thsd26bc212007-11-08 18:05:37 +0000456#if defined(TARGET_ABI_MIPSN32)
ths540635b2007-09-30 01:58:33 +0000457 uint32_t _sa_handler;
458#else
blueswir1992f48a2007-10-14 16:27:31 +0000459 abi_ulong _sa_handler;
ths540635b2007-09-30 01:58:33 +0000460#endif
Anthony Liguoric227f092009-10-01 16:12:16 -0500461 target_sigset_t sa_mask;
Richard Henderson7f047de2017-10-31 13:53:52 +0100462#ifdef TARGET_ARCH_HAS_SA_RESTORER
463 /* ??? This is always present, but ignored unless O32. */
464 abi_ulong sa_restorer;
465#endif
bellard106ec872006-06-27 21:08:10 +0000466};
bellard106ec872006-06-27 21:08:10 +0000467#else
bellard2521d692003-06-15 19:58:13 +0000468struct target_old_sigaction {
blueswir1992f48a2007-10-14 16:27:31 +0000469 abi_ulong _sa_handler;
470 abi_ulong sa_mask;
471 abi_ulong sa_flags;
Richard Henderson7f047de2017-10-31 13:53:52 +0100472#ifdef TARGET_ARCH_HAS_SA_RESTORER
blueswir1992f48a2007-10-14 16:27:31 +0000473 abi_ulong sa_restorer;
Richard Henderson7f047de2017-10-31 13:53:52 +0100474#endif
bellard2521d692003-06-15 19:58:13 +0000475};
476
477struct target_sigaction {
blueswir1992f48a2007-10-14 16:27:31 +0000478 abi_ulong _sa_handler;
479 abi_ulong sa_flags;
Richard Henderson7f047de2017-10-31 13:53:52 +0100480#ifdef TARGET_ARCH_HAS_SA_RESTORER
blueswir1992f48a2007-10-14 16:27:31 +0000481 abi_ulong sa_restorer;
Richard Henderson7f047de2017-10-31 13:53:52 +0100482#endif
Anthony Liguoric227f092009-10-01 16:12:16 -0500483 target_sigset_t sa_mask;
Laurent Vivier5de154e2018-04-02 12:24:52 +0200484#ifdef TARGET_ARCH_HAS_KA_RESTORER
485 abi_ulong ka_restorer;
486#endif
bellard2521d692003-06-15 19:58:13 +0000487};
bellard106ec872006-06-27 21:08:10 +0000488#endif
bellard2521d692003-06-15 19:58:13 +0000489
490typedef union target_sigval {
491 int sival_int;
blueswir1992f48a2007-10-14 16:27:31 +0000492 abi_ulong sival_ptr;
Anthony Liguoric227f092009-10-01 16:12:16 -0500493} target_sigval_t;
bellard6d5e2162004-09-30 22:04:13 +0000494#if 0
495#if defined (TARGET_SPARC)
496typedef struct {
497 struct {
blueswir1992f48a2007-10-14 16:27:31 +0000498 abi_ulong psr;
499 abi_ulong pc;
500 abi_ulong npc;
501 abi_ulong y;
502 abi_ulong u_regs[16]; /* globals and ins */
bellard6d5e2162004-09-30 22:04:13 +0000503 } si_regs;
504 int si_mask;
505} __siginfo_t;
506
507typedef struct {
508 unsigned long si_float_regs [32];
509 unsigned long si_fsr;
510 unsigned long si_fpqdepth;
511 struct {
512 unsigned long *insn_addr;
513 unsigned long insn;
514 } si_fpqueue [16];
515} __siginfo_fpu_t;
516#endif
517#endif
bellard2521d692003-06-15 19:58:13 +0000518
519#define TARGET_SI_MAX_SIZE 128
Maxim Ostapenkoaa5e03d2015-02-02 18:18:29 +0400520
521#if TARGET_ABI_BITS == 32
522#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
523#else
524#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
525#endif
526
527#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
bellard2521d692003-06-15 19:58:13 +0000528
Peter Maydella70dadc2016-05-27 15:51:59 +0100529/* Within QEMU the top 16 bits of si_code indicate which of the parts of
530 * the union in target_siginfo is valid. This only applies between
531 * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
532 * appear either within host siginfo_t or in target_siginfo structures
533 * which we get from the guest userspace program. (The Linux kernel
534 * does a similar thing with using the top bits for its own internal
535 * purposes but not letting them be visible to userspace.)
536 */
537#define QEMU_SI_KILL 0
538#define QEMU_SI_TIMER 1
539#define QEMU_SI_POLL 2
540#define QEMU_SI_FAULT 3
541#define QEMU_SI_CHLD 4
542#define QEMU_SI_RT 5
543
bellard2521d692003-06-15 19:58:13 +0000544typedef struct target_siginfo {
pbrook3f53d542009-04-21 00:59:40 +0000545#ifdef TARGET_MIPS
546 int si_signo;
547 int si_code;
548 int si_errno;
549#else
bellard2521d692003-06-15 19:58:13 +0000550 int si_signo;
551 int si_errno;
552 int si_code;
pbrook3f53d542009-04-21 00:59:40 +0000553#endif
bellard2521d692003-06-15 19:58:13 +0000554
555 union {
556 int _pad[TARGET_SI_PAD_SIZE];
557
558 /* kill() */
559 struct {
560 pid_t _pid; /* sender's pid */
561 uid_t _uid; /* sender's uid */
562 } _kill;
563
564 /* POSIX.1b timers */
565 struct {
566 unsigned int _timer1;
567 unsigned int _timer2;
568 } _timer;
569
570 /* POSIX.1b signals */
571 struct {
572 pid_t _pid; /* sender's pid */
573 uid_t _uid; /* sender's uid */
Anthony Liguoric227f092009-10-01 16:12:16 -0500574 target_sigval_t _sigval;
bellard2521d692003-06-15 19:58:13 +0000575 } _rt;
576
577 /* SIGCHLD */
578 struct {
579 pid_t _pid; /* which child */
580 uid_t _uid; /* sender's uid */
581 int _status; /* exit code */
Anthony Liguoric227f092009-10-01 16:12:16 -0500582 target_clock_t _utime;
583 target_clock_t _stime;
bellard2521d692003-06-15 19:58:13 +0000584 } _sigchld;
585
586 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
587 struct {
blueswir1992f48a2007-10-14 16:27:31 +0000588 abi_ulong _addr; /* faulting insn/memory ref. */
bellard2521d692003-06-15 19:58:13 +0000589 } _sigfault;
590
591 /* SIGPOLL */
592 struct {
593 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
594 int _fd;
595 } _sigpoll;
596 } _sifields;
Anthony Liguoric227f092009-10-01 16:12:16 -0500597} target_siginfo_t;
bellard2521d692003-06-15 19:58:13 +0000598
599/*
600 * si_code values
601 * Digital reserves positive values for kernel-generated signals.
602 */
603#define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
604#define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
605#define TARGET_SI_QUEUE -1 /* sent by sigqueue */
606#define TARGET_SI_TIMER -2 /* sent by timer expiration */
607#define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
608#define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
609#define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
610
611/*
612 * SIGILL si_codes
613 */
bellardffa65c32004-01-04 23:57:22 +0000614#define TARGET_ILL_ILLOPC (1) /* illegal opcode */
bellard2521d692003-06-15 19:58:13 +0000615#define TARGET_ILL_ILLOPN (2) /* illegal operand */
bellardffa65c32004-01-04 23:57:22 +0000616#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
617#define TARGET_ILL_ILLTRP (4) /* illegal trap */
618#define TARGET_ILL_PRVOPC (5) /* privileged opcode */
619#define TARGET_ILL_PRVREG (6) /* privileged register */
620#define TARGET_ILL_COPROC (7) /* coprocessor error */
621#define TARGET_ILL_BADSTK (8) /* internal stack error */
Chen Gangde2fdd52015-09-26 12:10:05 +0800622#ifdef TARGET_TILEGX
623#define TARGET_ILL_DBLFLT (9) /* double fault */
624#define TARGET_ILL_HARDWALL (10) /* user networks hardwall violation */
625#endif
bellard2521d692003-06-15 19:58:13 +0000626
627/*
628 * SIGFPE si_codes
629 */
630#define TARGET_FPE_INTDIV (1) /* integer divide by zero */
631#define TARGET_FPE_INTOVF (2) /* integer overflow */
632#define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
633#define TARGET_FPE_FLTOVF (4) /* floating point overflow */
634#define TARGET_FPE_FLTUND (5) /* floating point underflow */
635#define TARGET_FPE_FLTRES (6) /* floating point inexact result */
636#define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
637#define TARGET_FPE_FLTSUB (8) /* subscript out of range */
638#define TARGET_NSIGFPE 8
639
640/*
641 * SIGSEGV si_codes
642 */
643#define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
644#define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
Chen Gangde2fdd52015-09-26 12:10:05 +0800645#define TARGET_SEGV_BNDERR (3) /* failed address bound checks */
bellard2521d692003-06-15 19:58:13 +0000646
647/*
bellardffa65c32004-01-04 23:57:22 +0000648 * SIGBUS si_codes
649 */
650#define TARGET_BUS_ADRALN (1) /* invalid address alignment */
Dong Xu Wangb4916d72011-11-22 18:06:17 +0800651#define TARGET_BUS_ADRERR (2) /* non-existent physical address */
bellardffa65c32004-01-04 23:57:22 +0000652#define TARGET_BUS_OBJERR (3) /* object specific hardware error */
Chen Gangde2fdd52015-09-26 12:10:05 +0800653/* hardware memory error consumed on a machine check: action required */
654#define TARGET_BUS_MCEERR_AR (4)
655/* hardware memory error detected in process but not consumed: action optional*/
656#define TARGET_BUS_MCEERR_AO (5)
bellardffa65c32004-01-04 23:57:22 +0000657
658/*
bellard2521d692003-06-15 19:58:13 +0000659 * SIGTRAP si_codes
660 */
661#define TARGET_TRAP_BRKPT (1) /* process breakpoint */
662#define TARGET_TRAP_TRACE (2) /* process trace trap */
Chen Gangde2fdd52015-09-26 12:10:05 +0800663#define TARGET_TRAP_BRANCH (3) /* process taken branch trap */
664#define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint */
bellard2521d692003-06-15 19:58:13 +0000665
bellard9de5e442003-03-23 16:49:39 +0000666struct target_rlimit {
blueswir1992f48a2007-10-14 16:27:31 +0000667 abi_ulong rlim_cur;
668 abi_ulong rlim_max;
bellard9de5e442003-03-23 16:49:39 +0000669};
670
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900671#if defined(TARGET_ALPHA)
Aurelien Jarnoe4764922010-05-19 18:30:53 +0200672#define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
Matthias Braun6cafd022011-09-09 19:30:25 +0200673#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900674#define TARGET_RLIM_INFINITY 0x7fffffffUL
675#else
Matthias Braun26b746d2011-09-09 19:31:17 +0200676#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900677#endif
678
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300679#if defined(TARGET_MIPS)
680#define TARGET_RLIMIT_CPU 0
681#define TARGET_RLIMIT_FSIZE 1
682#define TARGET_RLIMIT_DATA 2
683#define TARGET_RLIMIT_STACK 3
684#define TARGET_RLIMIT_CORE 4
685#define TARGET_RLIMIT_RSS 7
686#define TARGET_RLIMIT_NPROC 8
687#define TARGET_RLIMIT_NOFILE 5
688#define TARGET_RLIMIT_MEMLOCK 9
689#define TARGET_RLIMIT_AS 6
690#define TARGET_RLIMIT_LOCKS 10
691#define TARGET_RLIMIT_SIGPENDING 11
692#define TARGET_RLIMIT_MSGQUEUE 12
693#define TARGET_RLIMIT_NICE 13
694#define TARGET_RLIMIT_RTPRIO 14
695#else
696#define TARGET_RLIMIT_CPU 0
697#define TARGET_RLIMIT_FSIZE 1
698#define TARGET_RLIMIT_DATA 2
699#define TARGET_RLIMIT_STACK 3
700#define TARGET_RLIMIT_CORE 4
701#define TARGET_RLIMIT_RSS 5
Matthias Braun6cafd022011-09-09 19:30:25 +0200702#if defined(TARGET_SPARC)
703#define TARGET_RLIMIT_NOFILE 6
704#define TARGET_RLIMIT_NPROC 7
705#else
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300706#define TARGET_RLIMIT_NPROC 6
707#define TARGET_RLIMIT_NOFILE 7
Matthias Braun6cafd022011-09-09 19:30:25 +0200708#endif
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300709#define TARGET_RLIMIT_MEMLOCK 8
710#define TARGET_RLIMIT_AS 9
711#define TARGET_RLIMIT_LOCKS 10
712#define TARGET_RLIMIT_SIGPENDING 11
713#define TARGET_RLIMIT_MSGQUEUE 12
714#define TARGET_RLIMIT_NICE 13
715#define TARGET_RLIMIT_RTPRIO 14
716#endif
717
bellard9de5e442003-03-23 16:49:39 +0000718struct target_pollfd {
719 int fd; /* file descriptor */
720 short events; /* requested events */
721 short revents; /* returned events */
722};
723
bellard8e5a0662003-05-08 15:42:10 +0000724/* virtual terminal ioctls */
bellard0221cfc2003-05-10 12:38:16 +0000725#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
726#define TARGET_KDMKTONE 0x4B30 /* generate tone */
bellard8e5a0662003-05-08 15:42:10 +0000727#define TARGET_KDGKBTYPE 0x4b33
Ulrich Hechtf7680a52009-10-16 17:00:44 +0200728#define TARGET_KDSETMODE 0x4b3a
729#define TARGET_KDGKBMODE 0x4b44
730#define TARGET_KDSKBMODE 0x4b45
bellard0221cfc2003-05-10 12:38:16 +0000731#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
732#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
Cédric VINCENTe6fe18f2011-06-29 15:09:09 +0200733#define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
734#define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
735#define TARGET_KDGETLED 0x4B31 /* return current led state */
736#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
Paul Burtonca56f5b2014-06-22 11:25:47 +0100737#define TARGET_KDSIGACCEPT 0x4B4E
bellard8e5a0662003-05-08 15:42:10 +0000738
Aleksandar Markovice1be1602016-09-19 13:44:38 +0200739#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4)
740#define TARGET_SIOCATMARK TARGET_IOR('s', 7, int)
Helge Deller405b4912016-12-07 11:31:46 -0800741#define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)
Aleksandar Markovice1be1602016-09-19 13:44:38 +0200742#else
bellard2521d692003-06-15 19:58:13 +0000743#define TARGET_SIOCATMARK 0x8905
Helge Deller405b4912016-12-07 11:31:46 -0800744#define TARGET_SIOCGPGRP 0x8904
Aleksandar Markovice1be1602016-09-19 13:44:38 +0200745#endif
Helge Deller405b4912016-12-07 11:31:46 -0800746#define TARGET_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
747#define TARGET_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
bellard2521d692003-06-15 19:58:13 +0000748
bellard31e31b82003-02-18 22:55:36 +0000749/* Networking ioctls */
750#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
751#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
752#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
753#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
754#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
755#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
756#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
757#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
758#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
759#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
760#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
761#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
762#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
763#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
764#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
765#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
766#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
767#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
768#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
769#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
770#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
771#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
772#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
773#define TARGET_SIOCSIFENCAP 0x8926
774#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
775#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
776#define TARGET_SIOCSIFSLAVE 0x8930
777#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
778#define TARGET_SIOCDELMULTI 0x8932
Paul Burtonf63eb012014-06-22 11:25:48 +0100779#define TARGET_SIOCGIFINDEX 0x8933
bellard31e31b82003-02-18 22:55:36 +0000780
781/* Bridging control calls */
782#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
783#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
784
785#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
786#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
787
788/* ARP cache control calls. */
789#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
790#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
791#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
792#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
793#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
794#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
795
796/* RARP cache control calls. */
797#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
798#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
799#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
800
801/* Driver configuration calls */
802#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
803#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
804
805/* DLCI configuration calls */
806#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
807#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
808
Laurent Vivier86fcd942011-03-30 01:35:23 +0200809/* From <linux/wireless.h> */
810
811#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
bellard31e31b82003-02-18 22:55:36 +0000812
Marco A L Barbosad6d6d6f2017-10-05 10:55:30 -0300813/* From <linux/random.h> */
814
815#define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
816#define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
817#define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
818#define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
819
bellard31e31b82003-02-18 22:55:36 +0000820/* From <linux/fs.h> */
821
822#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
823#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
824#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
825#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
826#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
827#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
828#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
829#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
830#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
831#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
832#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
833#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
Andreas Färberfff8c532014-01-18 07:38:30 +0100834#define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
bellard31e31b82003-02-18 22:55:36 +0000835/* A jump here: 108-111 have been used for various private purposes. */
Peter Maydellc8b0bf52012-07-23 08:05:20 +0000836#define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
837#define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
Alexander Grafedafea12012-01-31 20:10:20 +0100838#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
839 /* return device size in bytes
840 (u64 *arg) */
Peter Maydell47158562016-07-01 19:46:04 +0100841
842#define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
843#define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
844#define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
845#define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
846#define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
847#define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
848#define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
849#define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
850#define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
851
bellard31e31b82003-02-18 22:55:36 +0000852#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
853#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
Helge Deller21992cb2017-02-11 23:26:02 +0100854
855#define TARGET_FICLONE TARGET_IOW(0x94, 9, int)
856#define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
857
Peter Maydell60807232016-07-15 18:44:45 +0100858/* Note that the ioctl numbers claim type "long" but the actual type
859 * used by the kernel is "int".
860 */
Peter Maydell1847b7b2017-10-12 16:30:44 +0100861#define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
862#define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
Peter Maydell60807232016-07-15 18:44:45 +0100863
Peter Maydell285da2b2011-01-06 15:04:18 +0000864#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
bellard31e31b82003-02-18 22:55:36 +0000865
Cortland Tölva6c753a62018-10-08 09:35:20 -0700866/* usb ioctls */
867#define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
868#define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
869#define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
870#define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
871#define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U', 5)
872#define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
Cortland Tölvaa1333672018-10-08 09:35:21 -0700873#define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
874#define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
875#define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
876#define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
Cortland Tölva6c753a62018-10-08 09:35:20 -0700877#define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
878#define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
879#define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
880#define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
881#define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
882#define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
883#define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
884#define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
885#define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
886#define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
887#define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
888#define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
889#define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
890#define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
891#define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
892#define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
893
bellard31e31b82003-02-18 22:55:36 +0000894/* cdrom commands */
ths5fafdf22007-09-16 21:08:06 +0000895#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
bellard31e31b82003-02-18 22:55:36 +0000896#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
897#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
ths5fafdf22007-09-16 21:08:06 +0000898#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
bellard31e31b82003-02-18 22:55:36 +0000899 (struct cdrom_ti) */
ths5fafdf22007-09-16 21:08:06 +0000900#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
bellard31e31b82003-02-18 22:55:36 +0000901 (struct cdrom_tochdr) */
ths5fafdf22007-09-16 21:08:06 +0000902#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
bellard31e31b82003-02-18 22:55:36 +0000903 (struct cdrom_tocentry) */
904#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
905#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
906#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
ths5fafdf22007-09-16 21:08:06 +0000907#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
bellard31e31b82003-02-18 22:55:36 +0000908 (struct cdrom_volctrl) */
ths5fafdf22007-09-16 21:08:06 +0000909#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
bellard31e31b82003-02-18 22:55:36 +0000910 (struct cdrom_subchnl) */
ths5fafdf22007-09-16 21:08:06 +0000911#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
bellard31e31b82003-02-18 22:55:36 +0000912 (struct cdrom_read) */
913#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
914 (struct cdrom_read) */
915#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
916#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
ths5fafdf22007-09-16 21:08:06 +0000917#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
918 address of multi session disks
bellard31e31b82003-02-18 22:55:36 +0000919 (struct cdrom_multisession) */
ths5fafdf22007-09-16 21:08:06 +0000920#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
bellard31e31b82003-02-18 22:55:36 +0000921 if available (struct cdrom_mcn) */
Veres Lajos67cc32e2015-09-08 22:45:14 +0100922#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is deprecated,
Dong Xu Wangb4916d72011-11-22 18:06:17 +0800923 but here anyway for compatibility */
bellard31e31b82003-02-18 22:55:36 +0000924#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
ths5fafdf22007-09-16 21:08:06 +0000925#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
bellard31e31b82003-02-18 22:55:36 +0000926 (struct cdrom_volctrl) */
927#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
928 (struct cdrom_read) */
ths5fafdf22007-09-16 21:08:06 +0000929/*
bellard31e31b82003-02-18 22:55:36 +0000930 * These ioctls are used only used in aztcd.c and optcd.c
931 */
932#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
933#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
ths3b46e622007-09-17 08:09:54 +0000934
bellard31e31b82003-02-18 22:55:36 +0000935/*
ths3b46e622007-09-17 08:09:54 +0000936 * This ioctl is only used by the scsi-cd driver.
bellard31e31b82003-02-18 22:55:36 +0000937 It is for playing audio in logical block addressing mode.
938 */
939#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
940
ths5fafdf22007-09-16 21:08:06 +0000941/*
bellard31e31b82003-02-18 22:55:36 +0000942 * These ioctls are only used in optcd.c
943 */
944#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
945
ths5fafdf22007-09-16 21:08:06 +0000946/*
947 * These ioctls are (now) only in ide-cd.c for controlling
bellard31e31b82003-02-18 22:55:36 +0000948 * drive spindown time. They should be implemented in the
949 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
950 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
951 * -Erik
952 */
953#define TARGET_CDROMGETSPINDOWN 0x531d
954#define TARGET_CDROMSETSPINDOWN 0x531e
955
ths5fafdf22007-09-16 21:08:06 +0000956/*
bellard31e31b82003-02-18 22:55:36 +0000957 * These ioctls are implemented through the uniform CD-ROM driver
958 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
959 * drivers are eventually ported to the uniform CD-ROM driver interface.
960 */
961#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
962#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
963#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
964#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
965#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
966#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
967#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
968#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
969#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
970#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
971#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
972#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
973
974/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
975 * Future CDROM ioctls should be kept below 0x537F
976 */
977
978/* This ioctl is only used by sbpcd at the moment */
979#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
980 /* conflict with SCSI_IOCTL_GET_IDLUN */
981
982/* DVD-ROM Specific ioctls */
983#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
984#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
985#define TARGET_DVD_AUTH 0x5392 /* Authentication */
986
987#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
988#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
989#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
990
991/* HD commands */
992
993/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
994#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
995#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
996#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
bellard31e31b82003-02-18 22:55:36 +0000997#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
998#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
999#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
1000#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
bellard2521d692003-06-15 19:58:13 +00001001#define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
bellard31e31b82003-02-18 22:55:36 +00001002#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
1003
1004/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
1005#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
1006#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
1007#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
1008#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
1009#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
1010#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
1011#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
bellard2521d692003-06-15 19:58:13 +00001012
balrogb8005912008-04-26 14:44:49 +00001013/* loop ioctls */
1014#define TARGET_LOOP_SET_FD 0x4C00
1015#define TARGET_LOOP_CLR_FD 0x4C01
1016#define TARGET_LOOP_SET_STATUS 0x4C02
1017#define TARGET_LOOP_GET_STATUS 0x4C03
1018#define TARGET_LOOP_SET_STATUS64 0x4C04
1019#define TARGET_LOOP_GET_STATUS64 0x4C05
1020#define TARGET_LOOP_CHANGE_FD 0x4C06
bellard2521d692003-06-15 19:58:13 +00001021
Peter Maydell884cdc42016-07-04 17:06:17 +01001022#define TARGET_LOOP_CTL_ADD 0x4C80
1023#define TARGET_LOOP_CTL_REMOVE 0x4C81
1024#define TARGET_LOOP_CTL_GET_FREE 0x4C82
1025
Ulrich Hechtf7680a52009-10-16 17:00:44 +02001026/* fb ioctls */
1027#define TARGET_FBIOGET_VSCREENINFO 0x4600
1028#define TARGET_FBIOPUT_VSCREENINFO 0x4601
1029#define TARGET_FBIOGET_FSCREENINFO 0x4602
Cédric VINCENT12b81b72011-06-29 15:09:11 +02001030#define TARGET_FBIOGETCMAP 0x4604
1031#define TARGET_FBIOPUTCMAP 0x4605
1032#define TARGET_FBIOPAN_DISPLAY 0x4606
1033#define TARGET_FBIOGET_CON2FBMAP 0x460F
1034#define TARGET_FBIOPUT_CON2FBMAP 0x4610
Ulrich Hechtf7680a52009-10-16 17:00:44 +02001035
1036/* vt ioctls */
1037#define TARGET_VT_OPENQRY 0x5600
1038#define TARGET_VT_GETSTATE 0x5603
1039#define TARGET_VT_ACTIVATE 0x5606
1040#define TARGET_VT_WAITACTIVE 0x5607
1041#define TARGET_VT_LOCKSWITCH 0x560b
1042#define TARGET_VT_UNLOCKSWITCH 0x560c
Cédric VINCENT774750c2011-06-29 15:09:10 +02001043#define TARGET_VT_GETMODE 0x5601
1044#define TARGET_VT_SETMODE 0x5602
1045#define TARGET_VT_RELDISP 0x5605
1046#define TARGET_VT_DISALLOCATE 0x5608
Ulrich Hechtf7680a52009-10-16 17:00:44 +02001047
Alexander Graf56e904e2012-01-31 18:42:06 +01001048/* device mapper */
1049#define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
1050#define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
1051#define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
1052#define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
1053#define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
1054#define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
1055#define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
1056#define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
1057#define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
1058#define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
1059#define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
1060#define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
1061#define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
1062#define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
1063#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
1064#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
1065
bellard2521d692003-06-15 19:58:13 +00001066/* from asm/termbits.h */
1067
bellard3bfd9da2004-01-04 15:52:31 +00001068#define TARGET_NCC 8
1069struct target_termio {
1070 unsigned short c_iflag; /* input mode flags */
1071 unsigned short c_oflag; /* output mode flags */
1072 unsigned short c_cflag; /* control mode flags */
1073 unsigned short c_lflag; /* local mode flags */
1074 unsigned char c_line; /* line discipline */
1075 unsigned char c_cc[TARGET_NCC]; /* control characters */
bellard2521d692003-06-15 19:58:13 +00001076};
1077
bellard3bfd9da2004-01-04 15:52:31 +00001078struct target_winsize {
1079 unsigned short ws_row;
1080 unsigned short ws_col;
1081 unsigned short ws_xpixel;
1082 unsigned short ws_ypixel;
1083};
bellard2521d692003-06-15 19:58:13 +00001084
bellard3bfd9da2004-01-04 15:52:31 +00001085#include "termbits.h"
bellard2521d692003-06-15 19:58:13 +00001086
Paul Brook9e0b74a2010-06-16 13:03:51 +01001087#if defined(TARGET_MIPS)
1088#define TARGET_PROT_SEM 0x10
1089#else
1090#define TARGET_PROT_SEM 0x08
1091#endif
1092
aurel32e44a3e72008-09-29 17:23:09 +00001093/* Common */
bellard2521d692003-06-15 19:58:13 +00001094#define TARGET_MAP_SHARED 0x01 /* Share changes */
1095#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
Helge Dellere65be6a2017-10-31 13:53:56 +01001096#if defined(TARGET_HPPA)
1097#define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
1098#else
1099#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
1100#endif
aurel32e44a3e72008-09-29 17:23:09 +00001101
1102/* Target specific */
bellard048f6b42005-11-26 18:47:20 +00001103#if defined(TARGET_MIPS)
aurel32e44a3e72008-09-29 17:23:09 +00001104#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
bellard048f6b42005-11-26 18:47:20 +00001105#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1106#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1107#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1108#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1109#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1110#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
ths540635b2007-09-30 01:58:33 +00001111#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1112#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
Helge Deller541e1692017-10-31 13:53:58 +01001113#define TARGET_MAP_STACK 0x40000 /* ignored */
1114#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
aurel32e44a3e72008-09-29 17:23:09 +00001115#elif defined(TARGET_PPC)
1116#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
bellard2521d692003-06-15 19:58:13 +00001117#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
bellard2521d692003-06-15 19:58:13 +00001118#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1119#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1120#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
j_mayer7ec931962007-09-18 21:54:57 +00001121#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
1122#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
aurel32e44a3e72008-09-29 17:23:09 +00001123#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1124#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
Helge Deller541e1692017-10-31 13:53:58 +01001125#define TARGET_MAP_STACK 0x20000 /* ignored */
1126#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
aurel32e44a3e72008-09-29 17:23:09 +00001127#elif defined(TARGET_ALPHA)
1128#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1129#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
1130#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
1131#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
1132#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
1133#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
1134#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
1135#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
1136#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
Helge Deller541e1692017-10-31 13:53:58 +01001137#define TARGET_MAP_STACK 0x80000 /* ignored */
1138#define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
Richard Hendersona10d1e52016-12-15 09:56:41 -08001139#elif defined(TARGET_HPPA)
1140#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1141#define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
1142#define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */
1143#define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */
1144#define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */
1145#define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */
1146#define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
1147#define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
1148#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
Helge Deller541e1692017-10-31 13:53:58 +01001149#define TARGET_MAP_STACK 0x40000 /* ignored */
1150#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
Max Filippovba7651f2017-01-25 10:54:11 -08001151#elif defined(TARGET_XTENSA)
1152#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1153#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1154#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1155#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1156#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1157#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1158#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
1159#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1160#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
1161#define TARGET_MAP_STACK 0x40000
1162#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
j_mayer7ec931962007-09-18 21:54:57 +00001163#else
aurel32e44a3e72008-09-29 17:23:09 +00001164#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1165#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
1166#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1167#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1168#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
bellard2521d692003-06-15 19:58:13 +00001169#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
1170#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
ths540635b2007-09-30 01:58:33 +00001171#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1172#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
Helge Deller541e1692017-10-31 13:53:58 +01001173#define TARGET_MAP_STACK 0x20000 /* ignored */
1174#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
Mike Frysinger906c1b82011-02-07 01:05:52 -05001175#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
j_mayer7ec931962007-09-18 21:54:57 +00001176#endif
bellard2521d692003-06-15 19:58:13 +00001177
Alexander Graf09701192013-09-03 20:12:15 +01001178#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
1179 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
Peter Maydelldaa43742018-03-08 14:47:32 +00001180 || defined(TARGET_CRIS)
bellard2521d692003-06-15 19:58:13 +00001181struct target_stat {
1182 unsigned short st_dev;
1183 unsigned short __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001184 abi_ulong st_ino;
bellard2521d692003-06-15 19:58:13 +00001185 unsigned short st_mode;
1186 unsigned short st_nlink;
1187 unsigned short st_uid;
1188 unsigned short st_gid;
1189 unsigned short st_rdev;
1190 unsigned short __pad2;
blueswir1992f48a2007-10-14 16:27:31 +00001191 abi_ulong st_size;
1192 abi_ulong st_blksize;
1193 abi_ulong st_blocks;
1194 abi_ulong target_st_atime;
1195 abi_ulong __unused1;
1196 abi_ulong target_st_mtime;
1197 abi_ulong __unused2;
1198 abi_ulong target_st_ctime;
1199 abi_ulong __unused3;
1200 abi_ulong __unused4;
1201 abi_ulong __unused5;
bellard2521d692003-06-15 19:58:13 +00001202};
1203
1204/* This matches struct stat64 in glibc2.1, hence the absolutely
1205 * insane amounts of padding around dev_t's.
1206 */
Stefan Weil20d155b2013-10-30 22:52:24 +01001207#define TARGET_HAS_STRUCT_STAT64
bellard2521d692003-06-15 19:58:13 +00001208struct target_stat64 {
1209 unsigned short st_dev;
1210 unsigned char __pad0[10];
1211
1212#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001213 abi_ulong __st_ino;
bellard2521d692003-06-15 19:58:13 +00001214
1215 unsigned int st_mode;
1216 unsigned int st_nlink;
1217
blueswir1992f48a2007-10-14 16:27:31 +00001218 abi_ulong st_uid;
1219 abi_ulong st_gid;
bellard2521d692003-06-15 19:58:13 +00001220
1221 unsigned short st_rdev;
1222 unsigned char __pad3[10];
1223
1224 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001225 abi_ulong st_blksize;
bellard2521d692003-06-15 19:58:13 +00001226
blueswir1992f48a2007-10-14 16:27:31 +00001227 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
1228 abi_ulong __pad4; /* future possible st_blocks high bits */
bellard2521d692003-06-15 19:58:13 +00001229
blueswir1992f48a2007-10-14 16:27:31 +00001230 abi_ulong target_st_atime;
1231 abi_ulong __pad5;
bellard2521d692003-06-15 19:58:13 +00001232
blueswir1992f48a2007-10-14 16:27:31 +00001233 abi_ulong target_st_mtime;
1234 abi_ulong __pad6;
bellard2521d692003-06-15 19:58:13 +00001235
blueswir1992f48a2007-10-14 16:27:31 +00001236 abi_ulong target_st_ctime;
1237 abi_ulong __pad7; /* will be high 32 bits of ctime someday */
bellard2521d692003-06-15 19:58:13 +00001238
1239 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001240} QEMU_PACKED;
bellard2521d692003-06-15 19:58:13 +00001241
pbrookce4defa2006-02-09 16:49:55 +00001242#ifdef TARGET_ARM
Stefan Weil20d155b2013-10-30 22:52:24 +01001243#define TARGET_HAS_STRUCT_STAT64
pbrookce4defa2006-02-09 16:49:55 +00001244struct target_eabi_stat64 {
1245 unsigned long long st_dev;
1246 unsigned int __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001247 abi_ulong __st_ino;
pbrookce4defa2006-02-09 16:49:55 +00001248 unsigned int st_mode;
1249 unsigned int st_nlink;
1250
blueswir1992f48a2007-10-14 16:27:31 +00001251 abi_ulong st_uid;
1252 abi_ulong st_gid;
pbrookce4defa2006-02-09 16:49:55 +00001253
1254 unsigned long long st_rdev;
1255 unsigned int __pad2[2];
1256
1257 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001258 abi_ulong st_blksize;
pbrookce4defa2006-02-09 16:49:55 +00001259 unsigned int __pad3;
1260 unsigned long long st_blocks;
1261
blueswir1992f48a2007-10-14 16:27:31 +00001262 abi_ulong target_st_atime;
1263 abi_ulong target_st_atime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001264
blueswir1992f48a2007-10-14 16:27:31 +00001265 abi_ulong target_st_mtime;
1266 abi_ulong target_st_mtime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001267
blueswir1992f48a2007-10-14 16:27:31 +00001268 abi_ulong target_st_ctime;
1269 abi_ulong target_st_ctime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001270
1271 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001272} QEMU_PACKED;
pbrookce4defa2006-02-09 16:49:55 +00001273#endif
1274
blueswir1992f48a2007-10-14 16:27:31 +00001275#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
blueswir11b8dd642007-07-08 10:08:24 +00001276struct target_stat {
1277 unsigned int st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001278 abi_ulong st_ino;
blueswir11b8dd642007-07-08 10:08:24 +00001279 unsigned int st_mode;
1280 unsigned int st_nlink;
1281 unsigned int st_uid;
1282 unsigned int st_gid;
1283 unsigned int st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001284 abi_long st_size;
1285 abi_long target_st_atime;
1286 abi_long target_st_mtime;
1287 abi_long target_st_ctime;
1288 abi_long st_blksize;
1289 abi_long st_blocks;
1290 abi_ulong __unused4[2];
blueswir11b8dd642007-07-08 10:08:24 +00001291};
1292
Stefan Weil20d155b2013-10-30 22:52:24 +01001293#define TARGET_HAS_STRUCT_STAT64
blueswir11b8dd642007-07-08 10:08:24 +00001294struct target_stat64 {
1295 unsigned char __pad0[6];
1296 unsigned short st_dev;
1297
1298 uint64_t st_ino;
1299 uint64_t st_nlink;
1300
1301 unsigned int st_mode;
1302
1303 unsigned int st_uid;
1304 unsigned int st_gid;
1305
1306 unsigned char __pad2[6];
1307 unsigned short st_rdev;
1308
1309 int64_t st_size;
1310 int64_t st_blksize;
1311
1312 unsigned char __pad4[4];
1313 unsigned int st_blocks;
1314
blueswir1992f48a2007-10-14 16:27:31 +00001315 abi_ulong target_st_atime;
1316 abi_ulong __unused1;
blueswir11b8dd642007-07-08 10:08:24 +00001317
blueswir1992f48a2007-10-14 16:27:31 +00001318 abi_ulong target_st_mtime;
1319 abi_ulong __unused2;
blueswir11b8dd642007-07-08 10:08:24 +00001320
blueswir1992f48a2007-10-14 16:27:31 +00001321 abi_ulong target_st_ctime;
1322 abi_ulong __unused3;
blueswir11b8dd642007-07-08 10:08:24 +00001323
blueswir1992f48a2007-10-14 16:27:31 +00001324 abi_ulong __unused4[3];
blueswir11b8dd642007-07-08 10:08:24 +00001325};
1326
bellard3bfd9da2004-01-04 15:52:31 +00001327#elif defined(TARGET_SPARC)
1328
1329struct target_stat {
1330 unsigned short st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001331 abi_ulong st_ino;
bellard3bfd9da2004-01-04 15:52:31 +00001332 unsigned short st_mode;
1333 short st_nlink;
1334 unsigned short st_uid;
1335 unsigned short st_gid;
1336 unsigned short st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001337 abi_long st_size;
1338 abi_long target_st_atime;
1339 abi_ulong __unused1;
1340 abi_long target_st_mtime;
1341 abi_ulong __unused2;
1342 abi_long target_st_ctime;
1343 abi_ulong __unused3;
1344 abi_long st_blksize;
1345 abi_long st_blocks;
1346 abi_ulong __unused4[2];
bellard3bfd9da2004-01-04 15:52:31 +00001347};
1348
Stefan Weil20d155b2013-10-30 22:52:24 +01001349#define TARGET_HAS_STRUCT_STAT64
bellard3bfd9da2004-01-04 15:52:31 +00001350struct target_stat64 {
1351 unsigned char __pad0[6];
1352 unsigned short st_dev;
1353
1354 uint64_t st_ino;
1355
1356 unsigned int st_mode;
1357 unsigned int st_nlink;
1358
1359 unsigned int st_uid;
1360 unsigned int st_gid;
1361
1362 unsigned char __pad2[6];
1363 unsigned short st_rdev;
1364
1365 unsigned char __pad3[8];
1366
1367 int64_t st_size;
1368 unsigned int st_blksize;
1369
1370 unsigned char __pad4[8];
1371 unsigned int st_blocks;
1372
1373 unsigned int target_st_atime;
1374 unsigned int __unused1;
1375
1376 unsigned int target_st_mtime;
1377 unsigned int __unused2;
1378
1379 unsigned int target_st_ctime;
1380 unsigned int __unused3;
1381
1382 unsigned int __unused4;
1383 unsigned int __unused5;
1384};
1385
bellard67867302003-11-23 17:05:30 +00001386#elif defined(TARGET_PPC)
1387
1388struct target_stat {
j_mayere32448e2007-12-10 08:24:59 +00001389 abi_ulong st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001390 abi_ulong st_ino;
j_mayer325e6512007-11-21 13:06:54 +00001391#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
j_mayere32448e2007-12-10 08:24:59 +00001392 abi_ulong st_nlink;
j_mayer325e6512007-11-21 13:06:54 +00001393 unsigned int st_mode;
1394#else
bellard67867302003-11-23 17:05:30 +00001395 unsigned int st_mode;
1396 unsigned short st_nlink;
j_mayer325e6512007-11-21 13:06:54 +00001397#endif
bellard67867302003-11-23 17:05:30 +00001398 unsigned int st_uid;
1399 unsigned int st_gid;
j_mayere32448e2007-12-10 08:24:59 +00001400 abi_ulong st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001401 abi_ulong st_size;
1402 abi_ulong st_blksize;
1403 abi_ulong st_blocks;
1404 abi_ulong target_st_atime;
j_mayere32448e2007-12-10 08:24:59 +00001405 abi_ulong target_st_atime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001406 abi_ulong target_st_mtime;
j_mayere32448e2007-12-10 08:24:59 +00001407 abi_ulong target_st_mtime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001408 abi_ulong target_st_ctime;
j_mayere32448e2007-12-10 08:24:59 +00001409 abi_ulong target_st_ctime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001410 abi_ulong __unused4;
1411 abi_ulong __unused5;
j_mayer325e6512007-11-21 13:06:54 +00001412#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1413 abi_ulong __unused6;
1414#endif
bellard67867302003-11-23 17:05:30 +00001415};
1416
Stefan Weil20d155b2013-10-30 22:52:24 +01001417#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
1418#define TARGET_HAS_STRUCT_STAT64
Stefan Weil541dc0d2011-08-31 12:38:01 +02001419struct QEMU_PACKED target_stat64 {
bellard67867302003-11-23 17:05:30 +00001420 unsigned long long st_dev;
bellard67867302003-11-23 17:05:30 +00001421 unsigned long long st_ino;
bellard3bfd9da2004-01-04 15:52:31 +00001422 unsigned int st_mode;
1423 unsigned int st_nlink;
bellard67867302003-11-23 17:05:30 +00001424 unsigned int st_uid;
1425 unsigned int st_gid;
bellard3bfd9da2004-01-04 15:52:31 +00001426 unsigned long long st_rdev;
aurel32e1ce5e42009-01-30 19:48:32 +00001427 unsigned long long __pad0;
j_mayere32448e2007-12-10 08:24:59 +00001428 long long st_size;
1429 int st_blksize;
aurel32e1ce5e42009-01-30 19:48:32 +00001430 unsigned int __pad1;
Max Filippov61322e92009-09-01 23:27:47 +04001431 long long st_blocks; /* Number 512-byte blocks allocated. */
j_mayere32448e2007-12-10 08:24:59 +00001432 int target_st_atime;
1433 unsigned int target_st_atime_nsec;
1434 int target_st_mtime;
1435 unsigned int target_st_mtime_nsec;
1436 int target_st_ctime;
1437 unsigned int target_st_ctime_nsec;
1438 unsigned int __unused4;
1439 unsigned int __unused5;
bellard67867302003-11-23 17:05:30 +00001440};
Stefan Weil20d155b2013-10-30 22:52:24 +01001441#endif
bellard67867302003-11-23 17:05:30 +00001442
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001443#elif defined(TARGET_MICROBLAZE)
1444
1445struct target_stat {
1446 abi_ulong st_dev;
1447 abi_ulong st_ino;
1448 unsigned int st_mode;
1449 unsigned short st_nlink;
1450 unsigned int st_uid;
1451 unsigned int st_gid;
1452 abi_ulong st_rdev;
1453 abi_ulong st_size;
1454 abi_ulong st_blksize;
1455 abi_ulong st_blocks;
1456 abi_ulong target_st_atime;
1457 abi_ulong target_st_atime_nsec;
1458 abi_ulong target_st_mtime;
1459 abi_ulong target_st_mtime_nsec;
1460 abi_ulong target_st_ctime;
1461 abi_ulong target_st_ctime_nsec;
1462 abi_ulong __unused4;
1463 abi_ulong __unused5;
1464};
1465
1466/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
Stefan Weil20d155b2013-10-30 22:52:24 +01001467#define TARGET_HAS_STRUCT_STAT64
Stefan Weil541dc0d2011-08-31 12:38:01 +02001468struct QEMU_PACKED target_stat64 {
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001469 uint64_t st_dev;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001470#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1471 uint32_t pad0;
1472 uint32_t __st_ino;
1473
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001474 uint32_t st_mode;
1475 uint32_t st_nlink;
1476 uint32_t st_uid;
1477 uint32_t st_gid;
1478 uint64_t st_rdev;
Edgar E. Iglesias21ebeb22009-06-23 19:19:33 +02001479 uint64_t __pad1;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001480
1481 int64_t st_size;
Edgar E. Iglesias21ebeb22009-06-23 19:19:33 +02001482 int32_t st_blksize;
1483 uint32_t __pad2;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001484 int64_t st_blocks; /* Number 512-byte blocks allocated. */
1485
1486 int target_st_atime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001487 unsigned int target_st_atime_nsec;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001488 int target_st_mtime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001489 unsigned int target_st_mtime_nsec;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001490 int target_st_ctime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001491 unsigned int target_st_ctime_nsec;
1492 uint64_t st_ino;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001493};
1494
pbrooke6e59062006-10-22 00:18:54 +00001495#elif defined(TARGET_M68K)
1496
1497struct target_stat {
1498 unsigned short st_dev;
1499 unsigned short __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001500 abi_ulong st_ino;
pbrooke6e59062006-10-22 00:18:54 +00001501 unsigned short st_mode;
1502 unsigned short st_nlink;
1503 unsigned short st_uid;
1504 unsigned short st_gid;
1505 unsigned short st_rdev;
1506 unsigned short __pad2;
blueswir1992f48a2007-10-14 16:27:31 +00001507 abi_ulong st_size;
1508 abi_ulong st_blksize;
1509 abi_ulong st_blocks;
1510 abi_ulong target_st_atime;
1511 abi_ulong __unused1;
1512 abi_ulong target_st_mtime;
1513 abi_ulong __unused2;
1514 abi_ulong target_st_ctime;
1515 abi_ulong __unused3;
1516 abi_ulong __unused4;
1517 abi_ulong __unused5;
pbrooke6e59062006-10-22 00:18:54 +00001518};
1519
1520/* This matches struct stat64 in glibc2.1, hence the absolutely
1521 * insane amounts of padding around dev_t's.
1522 */
Stefan Weil20d155b2013-10-30 22:52:24 +01001523#define TARGET_HAS_STRUCT_STAT64
pbrooke6e59062006-10-22 00:18:54 +00001524struct target_stat64 {
1525 unsigned long long st_dev;
1526 unsigned char __pad1[2];
1527
1528#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001529 abi_ulong __st_ino;
pbrooke6e59062006-10-22 00:18:54 +00001530
1531 unsigned int st_mode;
1532 unsigned int st_nlink;
1533
blueswir1992f48a2007-10-14 16:27:31 +00001534 abi_ulong st_uid;
1535 abi_ulong st_gid;
pbrooke6e59062006-10-22 00:18:54 +00001536
1537 unsigned long long st_rdev;
1538 unsigned char __pad3[2];
1539
1540 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001541 abi_ulong st_blksize;
pbrooke6e59062006-10-22 00:18:54 +00001542
blueswir1992f48a2007-10-14 16:27:31 +00001543 abi_ulong __pad4; /* future possible st_blocks high bits */
1544 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
pbrooke6e59062006-10-22 00:18:54 +00001545
blueswir1992f48a2007-10-14 16:27:31 +00001546 abi_ulong target_st_atime;
1547 abi_ulong target_st_atime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001548
blueswir1992f48a2007-10-14 16:27:31 +00001549 abi_ulong target_st_mtime;
1550 abi_ulong target_st_mtime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001551
blueswir1992f48a2007-10-14 16:27:31 +00001552 abi_ulong target_st_ctime;
1553 abi_ulong target_st_ctime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001554
1555 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001556} QEMU_PACKED;
pbrooke6e59062006-10-22 00:18:54 +00001557
thsd26bc212007-11-08 18:05:37 +00001558#elif defined(TARGET_ABI_MIPSN64)
ths540635b2007-09-30 01:58:33 +00001559
1560/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
1561struct target_stat {
1562 unsigned int st_dev;
1563 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1564
blueswir1992f48a2007-10-14 16:27:31 +00001565 abi_ulong st_ino;
ths540635b2007-09-30 01:58:33 +00001566
1567 unsigned int st_mode;
1568 unsigned int st_nlink;
1569
1570 int st_uid;
1571 int st_gid;
1572
1573 unsigned int st_rdev;
1574 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1575
blueswir1992f48a2007-10-14 16:27:31 +00001576 abi_ulong st_size;
ths540635b2007-09-30 01:58:33 +00001577
1578 /*
1579 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1580 * but we don't have it under Linux.
1581 */
1582 unsigned int target_st_atime;
1583 unsigned int target_st_atime_nsec;
1584
1585 unsigned int target_st_mtime;
1586 unsigned int target_st_mtime_nsec;
1587
1588 unsigned int target_st_ctime;
1589 unsigned int target_st_ctime_nsec;
1590
1591 unsigned int st_blksize;
1592 unsigned int st_pad2;
1593
blueswir1992f48a2007-10-14 16:27:31 +00001594 abi_ulong st_blocks;
ths540635b2007-09-30 01:58:33 +00001595};
1596
thsd26bc212007-11-08 18:05:37 +00001597#elif defined(TARGET_ABI_MIPSN32)
ths540635b2007-09-30 01:58:33 +00001598
1599struct target_stat {
Leon Alrae1ab2aea2015-01-30 15:08:05 +00001600 abi_ulong st_dev;
1601 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
1602 uint64_t st_ino;
1603 unsigned int st_mode;
1604 unsigned int st_nlink;
1605 int st_uid;
1606 int st_gid;
1607 abi_ulong st_rdev;
1608 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
1609 int64_t st_size;
1610 abi_long target_st_atime;
1611 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
1612 abi_long target_st_mtime;
1613 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
1614 abi_long target_st_ctime;
1615 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
1616 abi_ulong st_blksize;
1617 abi_ulong st_pad2;
1618 int64_t st_blocks;
ths540635b2007-09-30 01:58:33 +00001619};
1620
thsd26bc212007-11-08 18:05:37 +00001621#elif defined(TARGET_ABI_MIPSO32)
bellard048f6b42005-11-26 18:47:20 +00001622
1623struct target_stat {
1624 unsigned st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001625 abi_long st_pad1[3]; /* Reserved for network id */
1626 abi_ulong st_ino;
bellard048f6b42005-11-26 18:47:20 +00001627 unsigned int st_mode;
1628 unsigned int st_nlink;
1629 int st_uid;
1630 int st_gid;
1631 unsigned st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001632 abi_long st_pad2[2];
1633 abi_long st_size;
1634 abi_long st_pad3;
bellard048f6b42005-11-26 18:47:20 +00001635 /*
1636 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1637 * but we don't have it under Linux.
1638 */
blueswir1992f48a2007-10-14 16:27:31 +00001639 abi_long target_st_atime;
1640 abi_long target_st_atime_nsec;
1641 abi_long target_st_mtime;
1642 abi_long target_st_mtime_nsec;
1643 abi_long target_st_ctime;
1644 abi_long target_st_ctime_nsec;
1645 abi_long st_blksize;
1646 abi_long st_blocks;
1647 abi_long st_pad4[14];
bellard048f6b42005-11-26 18:47:20 +00001648};
1649
1650/*
1651 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1652 * amounts of padding around dev_t's. The memory layout is the same as of
1653 * struct stat of the 64-bit kernel.
1654 */
1655
Stefan Weil20d155b2013-10-30 22:52:24 +01001656#define TARGET_HAS_STRUCT_STAT64
bellard048f6b42005-11-26 18:47:20 +00001657struct target_stat64 {
blueswir1992f48a2007-10-14 16:27:31 +00001658 abi_ulong st_dev;
1659 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
bellard048f6b42005-11-26 18:47:20 +00001660
1661 uint64_t st_ino;
1662
1663 unsigned int st_mode;
1664 unsigned int st_nlink;
1665
1666 int st_uid;
1667 int st_gid;
1668
blueswir1992f48a2007-10-14 16:27:31 +00001669 abi_ulong st_rdev;
1670 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
bellard048f6b42005-11-26 18:47:20 +00001671
1672 int64_t st_size;
1673
1674 /*
1675 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1676 * but we don't have it under Linux.
1677 */
blueswir1992f48a2007-10-14 16:27:31 +00001678 abi_long target_st_atime;
1679 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
bellard048f6b42005-11-26 18:47:20 +00001680
blueswir1992f48a2007-10-14 16:27:31 +00001681 abi_long target_st_mtime;
1682 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
bellard048f6b42005-11-26 18:47:20 +00001683
blueswir1992f48a2007-10-14 16:27:31 +00001684 abi_long target_st_ctime;
1685 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
bellard048f6b42005-11-26 18:47:20 +00001686
blueswir1992f48a2007-10-14 16:27:31 +00001687 abi_ulong st_blksize;
1688 abi_ulong st_pad2;
bellard048f6b42005-11-26 18:47:20 +00001689
1690 int64_t st_blocks;
1691};
j_mayer7a3148a2007-04-05 07:13:51 +00001692
1693#elif defined(TARGET_ALPHA)
1694
1695struct target_stat {
1696 unsigned int st_dev;
1697 unsigned int st_ino;
1698 unsigned int st_mode;
1699 unsigned int st_nlink;
1700 unsigned int st_uid;
1701 unsigned int st_gid;
1702 unsigned int st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001703 abi_long st_size;
1704 abi_ulong target_st_atime;
1705 abi_ulong target_st_mtime;
1706 abi_ulong target_st_ctime;
j_mayer7a3148a2007-04-05 07:13:51 +00001707 unsigned int st_blksize;
1708 unsigned int st_blocks;
1709 unsigned int st_flags;
1710 unsigned int st_gen;
1711};
1712
Stefan Weil20d155b2013-10-30 22:52:24 +01001713#define TARGET_HAS_STRUCT_STAT64
j_mayer7a3148a2007-04-05 07:13:51 +00001714struct target_stat64 {
blueswir1992f48a2007-10-14 16:27:31 +00001715 abi_ulong st_dev;
1716 abi_ulong st_ino;
1717 abi_ulong st_rdev;
1718 abi_long st_size;
1719 abi_ulong st_blocks;
j_mayer7a3148a2007-04-05 07:13:51 +00001720
1721 unsigned int st_mode;
1722 unsigned int st_uid;
1723 unsigned int st_gid;
1724 unsigned int st_blksize;
1725 unsigned int st_nlink;
1726 unsigned int __pad0;
1727
blueswir1992f48a2007-10-14 16:27:31 +00001728 abi_ulong target_st_atime;
1729 abi_ulong target_st_atime_nsec;
1730 abi_ulong target_st_mtime;
1731 abi_ulong target_st_mtime_nsec;
1732 abi_ulong target_st_ctime;
1733 abi_ulong target_st_ctime_nsec;
1734 abi_long __unused[3];
j_mayer7a3148a2007-04-05 07:13:51 +00001735};
1736
ths6db45e62007-06-22 10:15:10 +00001737#elif defined(TARGET_SH4)
1738
1739struct target_stat {
blueswir1992f48a2007-10-14 16:27:31 +00001740 abi_ulong st_dev;
1741 abi_ulong st_ino;
ths6db45e62007-06-22 10:15:10 +00001742 unsigned short st_mode;
1743 unsigned short st_nlink;
1744 unsigned short st_uid;
1745 unsigned short st_gid;
blueswir1992f48a2007-10-14 16:27:31 +00001746 abi_ulong st_rdev;
1747 abi_ulong st_size;
1748 abi_ulong st_blksize;
1749 abi_ulong st_blocks;
1750 abi_ulong target_st_atime;
1751 abi_ulong target_st_atime_nsec;
1752 abi_ulong target_st_mtime;
1753 abi_ulong target_st_mtime_nsec;
1754 abi_ulong target_st_ctime;
1755 abi_ulong target_st_ctime_nsec;
1756 abi_ulong __unused4;
1757 abi_ulong __unused5;
ths6db45e62007-06-22 10:15:10 +00001758};
1759
1760/* This matches struct stat64 in glibc2.1, hence the absolutely
1761 * insane amounts of padding around dev_t's.
1762 */
Stefan Weil20d155b2013-10-30 22:52:24 +01001763#define TARGET_HAS_STRUCT_STAT64
Stefan Weil541dc0d2011-08-31 12:38:01 +02001764struct QEMU_PACKED target_stat64 {
ths6db45e62007-06-22 10:15:10 +00001765 unsigned long long st_dev;
1766 unsigned char __pad0[4];
1767
1768#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001769 abi_ulong __st_ino;
ths6db45e62007-06-22 10:15:10 +00001770
1771 unsigned int st_mode;
1772 unsigned int st_nlink;
1773
blueswir1992f48a2007-10-14 16:27:31 +00001774 abi_ulong st_uid;
1775 abi_ulong st_gid;
ths6db45e62007-06-22 10:15:10 +00001776
1777 unsigned long long st_rdev;
1778 unsigned char __pad3[4];
1779
1780 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001781 abi_ulong st_blksize;
ths6db45e62007-06-22 10:15:10 +00001782
1783 unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
1784
blueswir1992f48a2007-10-14 16:27:31 +00001785 abi_ulong target_st_atime;
1786 abi_ulong target_st_atime_nsec;
ths6db45e62007-06-22 10:15:10 +00001787
blueswir1992f48a2007-10-14 16:27:31 +00001788 abi_ulong target_st_mtime;
1789 abi_ulong target_st_mtime_nsec;
ths6db45e62007-06-22 10:15:10 +00001790
blueswir1992f48a2007-10-14 16:27:31 +00001791 abi_ulong target_st_ctime;
1792 abi_ulong target_st_ctime_nsec;
ths6db45e62007-06-22 10:15:10 +00001793
1794 unsigned long long st_ino;
1795};
1796
bellardd2fd1af2007-11-14 18:08:56 +00001797#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1798struct target_stat {
1799 abi_ulong st_dev;
1800 abi_ulong st_ino;
1801 abi_ulong st_nlink;
1802
1803 unsigned int st_mode;
1804 unsigned int st_uid;
1805 unsigned int st_gid;
1806 unsigned int __pad0;
1807 abi_ulong st_rdev;
1808 abi_long st_size;
1809 abi_long st_blksize;
Paolo Bonzini72e21db2018-12-13 23:37:36 +01001810 abi_long st_blocks; /* Number 512-byte blocks allocated. */
bellardd2fd1af2007-11-14 18:08:56 +00001811
1812 abi_ulong target_st_atime;
1813 abi_ulong target_st_atime_nsec;
1814 abi_ulong target_st_mtime;
1815 abi_ulong target_st_mtime_nsec;
1816 abi_ulong target_st_ctime;
1817 abi_ulong target_st_ctime_nsec;
1818
Paolo Bonzini72e21db2018-12-13 23:37:36 +01001819 abi_long __unused[3];
bellardd2fd1af2007-11-14 18:08:56 +00001820};
Ulrich Hechta4c075f2009-07-24 16:57:31 +02001821#elif defined(TARGET_S390X)
1822struct target_stat {
1823 abi_ulong st_dev;
1824 abi_ulong st_ino;
1825 abi_ulong st_nlink;
1826 unsigned int st_mode;
1827 unsigned int st_uid;
1828 unsigned int st_gid;
1829 unsigned int __pad1;
1830 abi_ulong st_rdev;
1831 abi_ulong st_size;
1832 abi_ulong target_st_atime;
1833 abi_ulong target_st_atime_nsec;
1834 abi_ulong target_st_mtime;
1835 abi_ulong target_st_mtime_nsec;
1836 abi_ulong target_st_ctime;
1837 abi_ulong target_st_ctime_nsec;
1838 abi_ulong st_blksize;
1839 abi_long st_blocks;
1840 abi_ulong __unused[3];
1841};
Alexander Graf09701192013-09-03 20:12:15 +01001842#elif defined(TARGET_AARCH64)
1843struct target_stat {
1844 abi_ulong st_dev;
1845 abi_ulong st_ino;
1846 unsigned int st_mode;
1847 unsigned int st_nlink;
1848 unsigned int st_uid;
1849 unsigned int st_gid;
1850 abi_ulong st_rdev;
1851 abi_ulong _pad1;
1852 abi_long st_size;
1853 int st_blksize;
1854 int __pad2;
1855 abi_long st_blocks;
1856 abi_long target_st_atime;
1857 abi_ulong target_st_atime_nsec;
1858 abi_long target_st_mtime;
1859 abi_ulong target_st_mtime_nsec;
1860 abi_long target_st_ctime;
1861 abi_ulong target_st_ctime_nsec;
1862 unsigned int __unused[2];
1863};
Max Filippovba7651f2017-01-25 10:54:11 -08001864#elif defined(TARGET_XTENSA)
1865struct target_stat {
1866 abi_ulong st_dev;
1867 abi_ulong st_ino;
1868 unsigned int st_mode;
1869 unsigned int st_nlink;
1870 unsigned int st_uid;
1871 unsigned int st_gid;
1872 abi_ulong st_rdev;
1873 abi_long st_size;
1874 abi_ulong st_blksize;
1875 abi_ulong st_blocks;
1876 abi_ulong target_st_atime;
1877 abi_ulong target_st_atime_nsec;
1878 abi_ulong target_st_mtime;
1879 abi_ulong target_st_mtime_nsec;
1880 abi_ulong target_st_ctime;
1881 abi_ulong target_st_ctime_nsec;
1882 abi_ulong __unused4;
1883 abi_ulong __unused5;
1884};
1885
1886#define TARGET_HAS_STRUCT_STAT64
1887struct target_stat64 {
1888 uint64_t st_dev; /* Device */
1889 uint64_t st_ino; /* File serial number */
1890 unsigned int st_mode; /* File mode. */
1891 unsigned int st_nlink; /* Link count. */
1892 unsigned int st_uid; /* User ID of the file's owner. */
1893 unsigned int st_gid; /* Group ID of the file's group. */
1894 uint64_t st_rdev; /* Device number, if device. */
1895 int64_t st_size; /* Size of file, in bytes. */
1896 abi_ulong st_blksize; /* Optimal block size for I/O. */
1897 abi_ulong __unused2;
1898 uint64_t st_blocks; /* Number 512-byte blocks allocated. */
1899 abi_ulong target_st_atime; /* Time of last access. */
1900 abi_ulong target_st_atime_nsec;
1901 abi_ulong target_st_mtime; /* Time of last modification. */
1902 abi_ulong target_st_mtime_nsec;
1903 abi_ulong target_st_ctime; /* Time of last status change. */
1904 abi_ulong target_st_ctime_nsec;
1905 abi_ulong __unused4;
1906 abi_ulong __unused5;
1907};
1908
Marek Vasuta0a839b2017-01-18 23:01:42 +01001909#elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
Michael Clark47ae93c2018-03-03 01:31:11 +13001910 defined(TARGET_NIOS2) || defined(TARGET_RISCV)
Peter Maydellc7819df2013-07-06 21:44:53 +01001911
1912/* These are the asm-generic versions of the stat and stat64 structures */
1913
Jia Liud9627832012-07-20 15:50:52 +08001914struct target_stat {
1915 abi_ulong st_dev;
1916 abi_ulong st_ino;
Jia Liud9627832012-07-20 15:50:52 +08001917 unsigned int st_mode;
Peter Maydellc7819df2013-07-06 21:44:53 +01001918 unsigned int st_nlink;
Jia Liud9627832012-07-20 15:50:52 +08001919 unsigned int st_uid;
1920 unsigned int st_gid;
Jia Liud9627832012-07-20 15:50:52 +08001921 abi_ulong st_rdev;
Peter Maydellc7819df2013-07-06 21:44:53 +01001922 abi_ulong __pad1;
Jia Liud9627832012-07-20 15:50:52 +08001923 abi_long st_size;
Peter Maydellc7819df2013-07-06 21:44:53 +01001924 int st_blksize;
1925 int __pad2;
1926 abi_long st_blocks;
1927 abi_long target_st_atime;
Jia Liud9627832012-07-20 15:50:52 +08001928 abi_ulong target_st_atime_nsec;
Peter Maydellc7819df2013-07-06 21:44:53 +01001929 abi_long target_st_mtime;
Jia Liud9627832012-07-20 15:50:52 +08001930 abi_ulong target_st_mtime_nsec;
Peter Maydellc7819df2013-07-06 21:44:53 +01001931 abi_long target_st_ctime;
Jia Liud9627832012-07-20 15:50:52 +08001932 abi_ulong target_st_ctime_nsec;
Peter Maydellc7819df2013-07-06 21:44:53 +01001933 unsigned int __unused4;
1934 unsigned int __unused5;
Jia Liud9627832012-07-20 15:50:52 +08001935};
Peter Maydellc7819df2013-07-06 21:44:53 +01001936
Michael Clark47ae93c2018-03-03 01:31:11 +13001937#if !defined(TARGET_RISCV64)
Stefan Weil20d155b2013-10-30 22:52:24 +01001938#define TARGET_HAS_STRUCT_STAT64
Peter Maydellc7819df2013-07-06 21:44:53 +01001939struct target_stat64 {
1940 uint64_t st_dev;
1941 uint64_t st_ino;
1942 unsigned int st_mode;
1943 unsigned int st_nlink;
1944 unsigned int st_uid;
1945 unsigned int st_gid;
1946 uint64_t st_rdev;
1947 uint64_t __pad1;
1948 int64_t st_size;
1949 int st_blksize;
1950 int __pad2;
1951 int64_t st_blocks;
1952 int target_st_atime;
1953 unsigned int target_st_atime_nsec;
1954 int target_st_mtime;
1955 unsigned int target_st_mtime_nsec;
1956 int target_st_ctime;
1957 unsigned int target_st_ctime_nsec;
1958 unsigned int __unused4;
1959 unsigned int __unused5;
1960};
Michael Clark47ae93c2018-03-03 01:31:11 +13001961#endif
Peter Maydellc7819df2013-07-06 21:44:53 +01001962
Richard Hendersona10d1e52016-12-15 09:56:41 -08001963#elif defined(TARGET_HPPA)
1964
1965struct target_stat {
1966 abi_uint st_dev;
1967 abi_uint st_ino;
1968 abi_ushort st_mode;
1969 abi_ushort st_nlink;
1970 abi_ushort _res1;
1971 abi_ushort _res2;
1972 abi_uint st_rdev;
1973 abi_int st_size;
1974 abi_int target_st_atime;
1975 abi_uint target_st_atime_nsec;
1976 abi_int target_st_mtime;
1977 abi_uint target_st_mtime_nsec;
1978 abi_int target_st_ctime;
1979 abi_uint target_st_ctime_nsec;
1980 abi_int st_blksize;
1981 abi_int st_blocks;
1982 abi_uint _unused1;
1983 abi_uint _unused2;
1984 abi_uint _unused3;
1985 abi_uint _unused4;
1986 abi_ushort _unused5;
1987 abi_short st_fstype;
1988 abi_uint st_realdev;
1989 abi_ushort st_basemode;
1990 abi_ushort _unused6;
1991 abi_uint st_uid;
1992 abi_uint st_gid;
1993 abi_uint _unused7[3];
1994};
1995
1996#define TARGET_HAS_STRUCT_STAT64
1997struct target_stat64 {
1998 uint64_t st_dev;
1999 abi_uint _pad1;
2000 abi_uint _res1;
2001 abi_uint st_mode;
2002 abi_uint st_nlink;
2003 abi_uint st_uid;
2004 abi_uint st_gid;
2005 uint64_t st_rdev;
2006 abi_uint _pad2;
2007 int64_t st_size;
2008 abi_int st_blksize;
2009 int64_t st_blocks;
2010 abi_int target_st_atime;
2011 abi_uint target_st_atime_nsec;
2012 abi_int target_st_mtime;
2013 abi_uint target_st_mtime_nsec;
2014 abi_int target_st_ctime;
2015 abi_uint target_st_ctime_nsec;
2016 uint64_t st_ino;
2017};
2018
bellard048f6b42005-11-26 18:47:20 +00002019#else
2020#error unsupported CPU
2021#endif
bellard2521d692003-06-15 19:58:13 +00002022
ths4ce6f8d2007-07-20 15:54:27 +00002023typedef struct {
2024 int val[2];
Anthony Liguoric227f092009-10-01 16:12:16 -05002025} target_fsid_t;
ths4ce6f8d2007-07-20 15:54:27 +00002026
bellard56c8f682005-11-28 22:28:41 +00002027#ifdef TARGET_MIPS
thsd26bc212007-11-08 18:05:37 +00002028#ifdef TARGET_ABI_MIPSN32
ths540635b2007-09-30 01:58:33 +00002029struct target_statfs {
2030 int32_t f_type;
2031 int32_t f_bsize;
2032 int32_t f_frsize; /* Fragment size - unsupported */
2033 int32_t f_blocks;
2034 int32_t f_bfree;
2035 int32_t f_files;
2036 int32_t f_ffree;
2037 int32_t f_bavail;
2038
2039 /* Linux specials */
Anthony Liguoric227f092009-10-01 16:12:16 -05002040 target_fsid_t f_fsid;
ths540635b2007-09-30 01:58:33 +00002041 int32_t f_namelen;
Shea Levyd4247ec2018-03-01 06:15:00 -05002042 int32_t f_flags;
2043 int32_t f_spare[5];
ths540635b2007-09-30 01:58:33 +00002044};
2045#else
bellard56c8f682005-11-28 22:28:41 +00002046struct target_statfs {
blueswir1992f48a2007-10-14 16:27:31 +00002047 abi_long f_type;
2048 abi_long f_bsize;
2049 abi_long f_frsize; /* Fragment size - unsupported */
2050 abi_long f_blocks;
2051 abi_long f_bfree;
2052 abi_long f_files;
2053 abi_long f_ffree;
2054 abi_long f_bavail;
bellard56c8f682005-11-28 22:28:41 +00002055
2056 /* Linux specials */
Anthony Liguoric227f092009-10-01 16:12:16 -05002057 target_fsid_t f_fsid;
blueswir1992f48a2007-10-14 16:27:31 +00002058 abi_long f_namelen;
Shea Levyd4247ec2018-03-01 06:15:00 -05002059 abi_long f_flags;
2060 abi_long f_spare[5];
bellard56c8f682005-11-28 22:28:41 +00002061};
ths540635b2007-09-30 01:58:33 +00002062#endif
bellard56c8f682005-11-28 22:28:41 +00002063
2064struct target_statfs64 {
2065 uint32_t f_type;
2066 uint32_t f_bsize;
2067 uint32_t f_frsize; /* Fragment size - unsupported */
2068 uint32_t __pad;
2069 uint64_t f_blocks;
2070 uint64_t f_bfree;
2071 uint64_t f_files;
2072 uint64_t f_ffree;
2073 uint64_t f_bavail;
Anthony Liguoric227f092009-10-01 16:12:16 -05002074 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00002075 uint32_t f_namelen;
Shea Levyd4247ec2018-03-01 06:15:00 -05002076 uint32_t f_flags;
2077 uint32_t f_spare[5];
bellard56c8f682005-11-28 22:28:41 +00002078};
balrogc4d10622008-07-19 09:38:52 +00002079#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
Michael Clark47ae93c2018-03-03 01:31:11 +13002080 defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
2081 defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
j_mayer325e6512007-11-21 13:06:54 +00002082struct target_statfs {
2083 abi_long f_type;
2084 abi_long f_bsize;
2085 abi_long f_blocks;
2086 abi_long f_bfree;
2087 abi_long f_bavail;
2088 abi_long f_files;
2089 abi_long f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05002090 target_fsid_t f_fsid;
j_mayer325e6512007-11-21 13:06:54 +00002091 abi_long f_namelen;
2092 abi_long f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002093 abi_long f_flags;
2094 abi_long f_spare[4];
j_mayer325e6512007-11-21 13:06:54 +00002095};
2096
2097struct target_statfs64 {
2098 abi_long f_type;
2099 abi_long f_bsize;
2100 abi_long f_blocks;
2101 abi_long f_bfree;
2102 abi_long f_bavail;
2103 abi_long f_files;
2104 abi_long f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05002105 target_fsid_t f_fsid;
j_mayer325e6512007-11-21 13:06:54 +00002106 abi_long f_namelen;
2107 abi_long f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002108 abi_long f_flags;
2109 abi_long f_spare[4];
j_mayer325e6512007-11-21 13:06:54 +00002110};
Ulrich Hechta4c075f2009-07-24 16:57:31 +02002111#elif defined(TARGET_S390X)
2112struct target_statfs {
2113 int32_t f_type;
2114 int32_t f_bsize;
2115 abi_long f_blocks;
2116 abi_long f_bfree;
2117 abi_long f_bavail;
2118 abi_long f_files;
2119 abi_long f_ffree;
2120 kernel_fsid_t f_fsid;
2121 int32_t f_namelen;
2122 int32_t f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002123 int32_t f_flags;
2124 int32_t f_spare[4];
2125
Ulrich Hechta4c075f2009-07-24 16:57:31 +02002126};
2127
2128struct target_statfs64 {
2129 int32_t f_type;
2130 int32_t f_bsize;
2131 abi_long f_blocks;
2132 abi_long f_bfree;
2133 abi_long f_bavail;
2134 abi_long f_files;
2135 abi_long f_ffree;
2136 kernel_fsid_t f_fsid;
2137 int32_t f_namelen;
2138 int32_t f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002139 int32_t f_flags;
2140 int32_t f_spare[4];
Ulrich Hechta4c075f2009-07-24 16:57:31 +02002141};
bellard56c8f682005-11-28 22:28:41 +00002142#else
2143struct target_statfs {
2144 uint32_t f_type;
2145 uint32_t f_bsize;
2146 uint32_t f_blocks;
2147 uint32_t f_bfree;
2148 uint32_t f_bavail;
2149 uint32_t f_files;
2150 uint32_t f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05002151 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00002152 uint32_t f_namelen;
2153 uint32_t f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002154 uint32_t f_flags;
2155 uint32_t f_spare[4];
bellard56c8f682005-11-28 22:28:41 +00002156};
2157
2158struct target_statfs64 {
2159 uint32_t f_type;
2160 uint32_t f_bsize;
2161 uint64_t f_blocks;
2162 uint64_t f_bfree;
2163 uint64_t f_bavail;
2164 uint64_t f_files;
2165 uint64_t f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05002166 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00002167 uint32_t f_namelen;
2168 uint32_t f_frsize;
Shea Levyd4247ec2018-03-01 06:15:00 -05002169 uint32_t f_flags;
2170 uint32_t f_spare[4];
bellard56c8f682005-11-28 22:28:41 +00002171};
2172#endif
2173
Ulrich Hecht7e22e542009-07-24 19:10:27 +02002174#define TARGET_F_LINUX_SPECIFIC_BASE 1024
2175#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
2176#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
2177#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
Peter Maydell7e3b92e2016-06-20 15:50:37 +01002178#define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
2179#define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
Ulrich Hecht7e22e542009-07-24 19:10:27 +02002180#define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
2181
Laurent Vivier5de77062018-05-29 21:41:53 +02002182#include "target_fcntl.h"
Andreas Schwab8d5d3002014-03-07 15:24:08 +01002183
bellard2521d692003-06-15 19:58:13 +00002184/* soundcard defines */
Veres Lajos67cc32e2015-09-08 22:45:14 +01002185/* XXX: convert them all to arch independent entries */
bellard2521d692003-06-15 19:58:13 +00002186#define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
2187#define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
2188#define TARGET_SNDCTL_COPR_RCODE 0xc0144303
2189#define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
2190#define TARGET_SNDCTL_COPR_RDATA 0xc0144302
2191#define TARGET_SNDCTL_COPR_RESET 0x00004300
2192#define TARGET_SNDCTL_COPR_RUN 0xc0144306
2193#define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
2194#define TARGET_SNDCTL_COPR_WCODE 0x40144305
2195#define TARGET_SNDCTL_COPR_WDATA 0x40144304
2196#define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
2197#define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
2198#define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
2199#define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
2200#define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
2201#define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
2202#define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
2203#define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
2204#define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
2205#define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
2206#define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
2207#define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
2208#define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
2209#define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
2210#define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
2211#define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
2212#define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
2213#define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
Peter Maydell5f723072012-07-23 08:06:15 +00002214#define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
2215#define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
bellard2521d692003-06-15 19:58:13 +00002216#define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
2217#define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
2218#define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
2219#define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
2220#define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
2221#define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
2222#define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
2223#define TARGET_SNDCTL_MIDI_INFO 0xc074510c
2224#define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
2225#define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
2226#define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
2227#define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
2228#define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
2229#define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
2230#define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
2231#define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
2232#define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
2233#define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
2234#define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
2235#define TARGET_SNDCTL_SEQ_PANIC 0x00005111
2236#define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
2237#define TARGET_SNDCTL_SEQ_RESET 0x00005100
2238#define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
2239#define TARGET_SNDCTL_SEQ_SYNC 0x00005101
2240#define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
2241#define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
2242#define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
2243#define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
2244#define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
2245#define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
2246#define TARGET_SNDCTL_TMR_METRONOME 0x40045407
2247#define TARGET_SNDCTL_TMR_SELECT 0x40045408
2248#define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
2249#define TARGET_SNDCTL_TMR_START 0x00005402
2250#define TARGET_SNDCTL_TMR_STOP 0x00005403
2251#define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
2252#define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
2253#define TARGET_SOUND_PCM_READ_RATE 0x80045002
2254#define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
2255#define TARGET_SOUND_PCM_READ_BITS 0x80045005
2256#define TARGET_SOUND_PCM_READ_FILTER 0x80045007
2257#define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
2258#define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
2259#define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
2260#define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
2261#define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
2262#define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
2263#define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
2264
2265#define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
2266
2267#define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
2268#define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
2269#define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
2270#define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
2271#define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
2272#define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
2273#define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
2274#define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
2275#define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
2276#define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
2277#define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
2278#define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
2279#define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
2280#define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
2281#define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
2282#define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
2283#define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
2284
2285/* Obsolete macros */
2286#define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
2287#define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
2288#define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
2289
2290#define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
2291#define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
2292#define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
2293#define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
2294#define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
2295
2296#define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
2297
2298#define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
2299#define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
2300#define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
2301#define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
2302#define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
2303#define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
2304#define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
2305#define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
2306#define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
2307#define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
2308#define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
2309#define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
2310#define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
2311#define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
2312#define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
2313#define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
2314#define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
2315
2316/* Obsolete macros */
2317#define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
2318#define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
2319#define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
2320
2321#define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
2322
2323/* vfat ioctls */
2324#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
2325#define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
bellarda5448a72004-06-19 16:59:03 +00002326
Peter Maydellf443e392017-10-12 16:30:45 +01002327struct target_mtop {
2328 abi_short mt_op;
2329 abi_int mt_count;
2330};
2331
2332#if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2333typedef abi_long target_kernel_daddr_t;
2334#else
2335typedef abi_int target_kernel_daddr_t;
2336#endif
2337
2338struct target_mtget {
2339 abi_long mt_type;
2340 abi_long mt_resid;
2341 abi_long mt_dsreg;
2342 abi_long mt_gstat;
2343 abi_long mt_erreg;
2344 target_kernel_daddr_t mt_fileno;
2345 target_kernel_daddr_t mt_blkno;
2346};
2347
2348struct target_mtpos {
2349 abi_long mt_blkno;
2350};
2351
2352#define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct target_mtop)
2353#define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget)
2354#define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos)
balrog8fbd6b52008-09-20 03:03:09 +00002355
bellarda5448a72004-06-19 16:59:03 +00002356struct target_sysinfo {
blueswir1992f48a2007-10-14 16:27:31 +00002357 abi_long uptime; /* Seconds since boot */
2358 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
2359 abi_ulong totalram; /* Total usable main memory size */
2360 abi_ulong freeram; /* Available memory size */
2361 abi_ulong sharedram; /* Amount of shared memory */
2362 abi_ulong bufferram; /* Memory used by buffers */
2363 abi_ulong totalswap; /* Total swap space size */
2364 abi_ulong freeswap; /* swap space still available */
bellarda5448a72004-06-19 16:59:03 +00002365 unsigned short procs; /* Number of current processes */
2366 unsigned short pad; /* explicit padding for m68k */
blueswir1992f48a2007-10-14 16:27:31 +00002367 abi_ulong totalhigh; /* Total high memory size */
2368 abi_ulong freehigh; /* Available high memory size */
bellarda5448a72004-06-19 16:59:03 +00002369 unsigned int mem_unit; /* Memory unit size in bytes */
blueswir1992f48a2007-10-14 16:27:31 +00002370 char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
bellarda5448a72004-06-19 16:59:03 +00002371};
bellard3532fa72006-06-24 15:06:03 +00002372
aurel326556a832008-10-13 21:08:17 +00002373struct linux_dirent {
2374 long d_ino;
2375 unsigned long d_off;
2376 unsigned short d_reclen;
2377 char d_name[256]; /* We must not include limits.h! */
2378};
2379
2380struct linux_dirent64 {
2381 uint64_t d_ino;
2382 int64_t d_off;
2383 unsigned short d_reclen;
2384 unsigned char d_type;
2385 char d_name[256];
2386};
2387
aurel3224e10032009-04-15 16:11:43 +00002388struct target_mq_attr {
2389 abi_long mq_flags;
2390 abi_long mq_maxmsg;
2391 abi_long mq_msgsize;
2392 abi_long mq_curmsgs;
2393};
2394
bellard3532fa72006-06-24 15:06:03 +00002395#include "socket.h"
ths637947f2007-06-01 12:09:19 +00002396
2397#include "errno_defs.h"
Riku Voipio03dfe9f2009-06-18 22:51:31 +03002398
2399#define FUTEX_WAIT 0
2400#define FUTEX_WAKE 1
2401#define FUTEX_FD 2
2402#define FUTEX_REQUEUE 3
2403#define FUTEX_CMP_REQUEUE 4
2404#define FUTEX_WAKE_OP 5
2405#define FUTEX_LOCK_PI 6
2406#define FUTEX_UNLOCK_PI 7
2407#define FUTEX_TRYLOCK_PI 8
2408#define FUTEX_WAIT_BITSET 9
2409#define FUTEX_WAKE_BITSET 10
2410
2411#define FUTEX_PRIVATE_FLAG 128
2412#define FUTEX_CLOCK_REALTIME 256
2413#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2414
Peter Maydell3b6edd12011-02-15 18:35:05 +00002415#ifdef CONFIG_EPOLL
Laurent Vivier928bed62015-10-03 17:14:06 +02002416#if defined(TARGET_X86_64)
2417#define TARGET_EPOLL_PACKED QEMU_PACKED
2418#else
2419#define TARGET_EPOLL_PACKED
2420#endif
2421
Peter Maydell3b6edd12011-02-15 18:35:05 +00002422typedef union target_epoll_data {
2423 abi_ulong ptr;
Laurent Vivier928bed62015-10-03 17:14:06 +02002424 abi_int fd;
2425 abi_uint u32;
2426 abi_ullong u64;
Peter Maydell3b6edd12011-02-15 18:35:05 +00002427} target_epoll_data_t;
2428
2429struct target_epoll_event {
Laurent Vivier928bed62015-10-03 17:14:06 +02002430 abi_uint events;
Peter Maydell3b6edd12011-02-15 18:35:05 +00002431 target_epoll_data_t data;
Laurent Vivier928bed62015-10-03 17:14:06 +02002432} TARGET_EPOLL_PACKED;
Peter Maydell2ba7fae32016-07-18 15:35:59 +01002433
2434#define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
2435
Peter Maydell3b6edd12011-02-15 18:35:05 +00002436#endif
Peter Maydell163a05a2011-06-27 17:44:52 +01002437struct target_rlimit64 {
2438 uint64_t rlim_cur;
2439 uint64_t rlim_max;
2440};
Akos PASZTORY583359a2011-11-14 15:09:49 +02002441
2442struct target_ucred {
2443 uint32_t pid;
2444 uint32_t uid;
2445 uint32_t gid;
2446};
Paolo Bonzinicb9c3772012-12-06 12:15:58 +01002447
Alexander Grafaecc8862014-11-10 21:33:03 +01002448typedef int32_t target_timer_t;
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002449
Natanael Copa34d60862014-04-29 13:11:20 +02002450#define TARGET_SIGEV_MAX_SIZE 64
2451
2452/* This is architecture-specific but most architectures use the default */
2453#ifdef TARGET_MIPS
2454#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
2455#else
2456#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
2457 + sizeof(target_sigval_t))
2458#endif
2459
2460#define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
2461 - TARGET_SIGEV_PREAMBLE_SIZE) \
2462 / sizeof(int32_t))
2463
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002464struct target_sigevent {
2465 target_sigval_t sigev_value;
Peter Maydell17351c32016-09-02 18:40:01 +01002466 abi_int sigev_signo;
2467 abi_int sigev_notify;
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002468 union {
Peter Maydell17351c32016-09-02 18:40:01 +01002469 abi_int _pad[TARGET_SIGEV_PAD_SIZE];
2470 abi_int _tid;
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002471
Peter Maydell17351c32016-09-02 18:40:01 +01002472 /* The kernel (and thus QEMU) never looks at these;
2473 * they're only used as part of the ABI between a
2474 * userspace program and libc.
2475 */
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002476 struct {
Peter Maydell17351c32016-09-02 18:40:01 +01002477 abi_ulong _function;
2478 abi_ulong _attribute;
Erik de Castro Lopo905bba12013-11-29 18:39:22 +11002479 } _sigev_thread;
2480 } _sigev_un;
2481};
Peter Maydelle0eb2102014-03-17 12:15:35 +00002482
2483struct target_user_cap_header {
2484 uint32_t version;
2485 int pid;
2486};
2487
2488struct target_user_cap_data {
2489 uint32_t effective;
2490 uint32_t permitted;
2491 uint32_t inheritable;
2492};
Markus Armbruster1b3c4fd2016-06-29 15:54:17 +02002493
Aleksandar Markovicda2c8ad2016-09-22 18:56:58 +02002494/* from kernel's include/linux/syslog.h */
2495
2496/* Close the log. Currently a NOP. */
2497#define TARGET_SYSLOG_ACTION_CLOSE 0
2498/* Open the log. Currently a NOP. */
2499#define TARGET_SYSLOG_ACTION_OPEN 1
2500/* Read from the log. */
2501#define TARGET_SYSLOG_ACTION_READ 2
2502/* Read all messages remaining in the ring buffer. */
2503#define TARGET_SYSLOG_ACTION_READ_ALL 3
2504/* Read and clear all messages remaining in the ring buffer */
2505#define TARGET_SYSLOG_ACTION_READ_CLEAR 4
2506/* Clear ring buffer. */
2507#define TARGET_SYSLOG_ACTION_CLEAR 5
2508/* Disable printk's to console */
2509#define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6
2510/* Enable printk's to console */
2511#define TARGET_SYSLOG_ACTION_CONSOLE_ON 7
2512/* Set level of messages printed to console */
2513#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8
2514/* Return number of unread characters in the log buffer */
2515#define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9
2516/* Return size of the log buffer */
2517#define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10
2518
Markus Armbruster1b3c4fd2016-06-29 15:54:17 +02002519#endif