]> git.proxmox.com Git - mirror_qemu.git/blame - linux-user/syscall_defs.h
migration/block-dirty-bitmap: move mutex init to dirty_bitmap_mig_init
[mirror_qemu.git] / linux-user / syscall_defs.h
CommitLineData
31e31b8a
FB
1/* common syscall defines for all architectures */
2
2521d698 3/* Note: although the syscall numbers change between architectures,
b4916d7b 4 most of them stay the same, so we handle it by putting ifdefs if
2521d698
FB
5 necessary */
6
cb9c377f 7#ifndef SYSCALL_DEFS_H
1b3c4fdf 8#define SYSCALL_DEFS_H
cb9c377f 9
6180a181 10#include "syscall_nr.h"
2521d698 11
ff71a454
AM
12
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() */
31e31b8a 34
524fa340 35#define IPCOP_CALL(VERSION, OP) ((VERSION) << 16 | (OP))
8853f86e
FB
36#define IPCOP_semop 1
37#define IPCOP_semget 2
38#define IPCOP_semctl 3
39#define IPCOP_semtimedop 4
40#define IPCOP_msgsnd 11
41#define IPCOP_msgrcv 12
42#define IPCOP_msgget 13
43#define IPCOP_msgctl 14
44#define IPCOP_shmat 21
45#define IPCOP_shmdt 22
46#define IPCOP_shmget 23
47#define IPCOP_shmctl 24
48
2521d698
FB
49/*
50 * The following is for compatibility across the various Linux
51 * platforms. The i386 ioctl numbering scheme doesn't really enforce
52 * a type field. De facto, however, the top 8 bits of the lower 16
53 * bits are indeed used as a type field, so we might just as well make
54 * this explicit here. Please be sure to use the decoding macros
55 * below from now on.
56 */
57#define TARGET_IOC_NRBITS 8
58#define TARGET_IOC_TYPEBITS 8
59
716f3fbe
PM
60#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
61 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
cd98d390 62 || defined(TARGET_SPARC) \
0c866a7e 63 || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
74d753ac
MW
64 /* 16 bit uid wrappers emulation */
65#define USE_UID16
0c866a7e
RV
66#define target_id uint16_t
67#else
68#define target_id uint32_t
74d753ac
MW
69#endif
70
e6e5906b 71#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
b16189b2 72 || defined(TARGET_M68K) || defined(TARGET_CRIS) \
daa4374a 73 || defined(TARGET_S390X) \
a0a839b6 74 || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
ba7651fb
MF
75 || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
76 || defined(TARGET_XTENSA)
2521d698
FB
77
78#define TARGET_IOC_SIZEBITS 14
79#define TARGET_IOC_DIRBITS 2
80
81#define TARGET_IOC_NONE 0U
82#define TARGET_IOC_WRITE 1U
83#define TARGET_IOC_READ 2U
84
048f6b4d 85#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
b779e29e
EI
86 defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
87 defined(TARGET_MIPS)
2521d698
FB
88
89#define TARGET_IOC_SIZEBITS 13
90#define TARGET_IOC_DIRBITS 3
91
92#define TARGET_IOC_NONE 1U
93#define TARGET_IOC_READ 2U
94#define TARGET_IOC_WRITE 4U
95
a10d1e50
RH
96#elif defined(TARGET_HPPA)
97
98#define TARGET_IOC_SIZEBITS 14
99#define TARGET_IOC_DIRBITS 2
100
101#define TARGET_IOC_NONE 0U
102#define TARGET_IOC_WRITE 2U
103#define TARGET_IOC_READ 1U
104
2521d698
FB
105#else
106#error unsupported CPU
107#endif
108
109#define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
110#define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
111#define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
112#define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
113
114#define TARGET_IOC_NRSHIFT 0
115#define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
116#define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
117#define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
118
119#define TARGET_IOC(dir,type,nr,size) \
120 (((dir) << TARGET_IOC_DIRSHIFT) | \
121 ((type) << TARGET_IOC_TYPESHIFT) | \
122 ((nr) << TARGET_IOC_NRSHIFT) | \
123 ((size) << TARGET_IOC_SIZESHIFT))
124
125/* used to create numbers */
126#define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
127#define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
128#define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
129#define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
130
131/* the size is automatically computed for these defines */
132#define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
133#define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
134#define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
135
7854b056 136struct target_sockaddr {
9a68960d 137 abi_ushort sa_family;
7854b056
FB
138 uint8_t sa_data[14];
139};
140
33a29b51 141struct target_sockaddr_ll {
9a68960d
PMD
142 abi_ushort sll_family; /* Always AF_PACKET */
143 abi_ushort sll_protocol; /* Physical layer protocol */
144 abi_int sll_ifindex; /* Interface number */
145 abi_ushort sll_hatype; /* ARP hardware type */
146 uint8_t sll_pkttype; /* Packet type */
147 uint8_t sll_halen; /* Length of address */
148 uint8_t sll_addr[8]; /* Physical layer address */
33a29b51
JT
149};
150
fb3aabf3 151struct target_sockaddr_un {
9a68960d 152 abi_ushort su_family;
fb3aabf3
LV
153 uint8_t sun_path[108];
154};
155
a47401bc
PMD
156struct target_sockaddr_nl {
157 abi_ushort nl_family; /* AF_NETLINK */
158 abi_ushort __pad;
159 abi_uint nl_pid;
160 abi_uint nl_groups;
161};
162
fb3aabf3 163struct target_in_addr {
9a68960d 164 abi_uint s_addr; /* big endian */
fb3aabf3
LV
165};
166
167struct target_sockaddr_in {
9a68960d
PMD
168 abi_ushort sin_family;
169 abi_short sin_port; /* big endian */
fb3aabf3
LV
170 struct target_in_addr sin_addr;
171 uint8_t __pad[sizeof(struct target_sockaddr) -
9a68960d 172 sizeof(abi_ushort) - sizeof(abi_short) -
fb3aabf3
LV
173 sizeof(struct target_in_addr)];
174};
175
ee1ac3a1 176struct target_sockaddr_in6 {
9a68960d
PMD
177 abi_ushort sin6_family;
178 abi_ushort sin6_port; /* big endian */
179 abi_uint sin6_flowinfo; /* big endian */
ee1ac3a1 180 struct in6_addr sin6_addr; /* IPv6 address, big endian */
9a68960d 181 abi_uint sin6_scope_id;
ee1ac3a1
HD
182};
183
f57d4192
LV
184struct target_sock_filter {
185 abi_ushort code;
186 uint8_t jt;
187 uint8_t jf;
188 abi_uint k;
189};
190
191struct target_sock_fprog {
192 abi_ushort len;
193 abi_ulong filter;
194};
195
b975b83b
LL
196struct target_ip_mreq {
197 struct target_in_addr imr_multiaddr;
198 struct target_in_addr imr_address;
199};
200
201struct target_ip_mreqn {
202 struct target_in_addr imr_multiaddr;
203 struct target_in_addr imr_address;
204 abi_long imr_ifindex;
205};
206
6e3cb58f
LL
207struct target_ip_mreq_source {
208 /* big endian */
209 uint32_t imr_multiaddr;
210 uint32_t imr_interface;
211 uint32_t imr_sourceaddr;
212};
213
83eb6e50
CMAB
214struct target_linger {
215 abi_int l_onoff; /* Linger active */
216 abi_int l_linger; /* How long to linger for */
217};
218
6d5d5dde
DB
219#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
220struct target_timeval {
221 abi_long tv_sec;
222 abi_int tv_usec;
223};
224#define target__kernel_sock_timeval target_timeval
225#else
31e31b8a 226struct target_timeval {
992f48a0
BS
227 abi_long tv_sec;
228 abi_long tv_usec;
31e31b8a
FB
229};
230
6d5d5dde
DB
231struct target__kernel_sock_timeval {
232 abi_llong tv_sec;
233 abi_llong tv_usec;
234};
235#endif
236
1b6b029e 237struct target_timespec {
992f48a0
BS
238 abi_long tv_sec;
239 abi_long tv_nsec;
1b6b029e
FB
240};
241
6d5d5dde
DB
242struct target__kernel_timespec {
243 abi_llong tv_sec;
244 abi_llong tv_nsec;
245};
246
ef4467e9
PB
247struct target_timezone {
248 abi_int tz_minuteswest;
249 abi_int tz_dsttime;
250};
251
66fb9763
FB
252struct target_itimerval {
253 struct target_timeval it_interval;
254 struct target_timeval it_value;
255};
256
905bba13
ECL
257struct target_itimerspec {
258 struct target_timespec it_interval;
259 struct target_timespec it_value;
260};
261
19f59bce
AM
262struct target_timex {
263 abi_uint modes; /* Mode selector */
264 abi_long offset; /* Time offset */
265 abi_long freq; /* Frequency offset */
266 abi_long maxerror; /* Maximum error (microseconds) */
267 abi_long esterror; /* Estimated error (microseconds) */
268 abi_int status; /* Clock command/status */
269 abi_long constant; /* PLL (phase-locked loop) time constant */
270 abi_long precision; /* Clock precision (microseconds, ro) */
271 abi_long tolerance; /* Clock freq. tolerance (ppm, ro) */
272 struct target_timeval time; /* Current time */
273 abi_long tick; /* Microseconds between clock ticks */
274 abi_long ppsfreq; /* PPS (pulse per second) frequency */
275 abi_long jitter; /* PPS jitter (ro); nanoseconds */
276 abi_int shift; /* PPS interval duration (seconds) */
277 abi_long stabil; /* PPS stability */
278 abi_long jitcnt; /* PPS jitter limit exceeded (ro) */
279 abi_long calcnt; /* PPS calibration intervals */
280 abi_long errcnt; /* PPS calibration errors */
281 abi_long stbcnt; /* PPS stability limit exceeded */
282 abi_int tai; /* TAI offset */
283
284 /* Further padding bytes to allow for future expansion */
285 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
286 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
287 abi_int:32; abi_int:32; abi_int:32;
288};
289
c227f099 290typedef abi_long target_clock_t;
32f36bce 291
c596ed17
FB
292#define TARGET_HZ 100
293
32f36bce 294struct target_tms {
c227f099
AL
295 target_clock_t tms_utime;
296 target_clock_t tms_stime;
297 target_clock_t tms_cutime;
298 target_clock_t tms_cstime;
32f36bce
FB
299};
300
6180a181 301struct target_utimbuf {
992f48a0
BS
302 abi_long actime;
303 abi_long modtime;
6180a181
FB
304};
305
f2674e31 306struct target_sel_arg_struct {
992f48a0
BS
307 abi_long n;
308 abi_long inp, outp, exp;
309 abi_long tvp;
f2674e31
FB
310};
311
31e31b8a 312struct target_iovec {
992f48a0
BS
313 abi_long iov_base; /* Starting address */
314 abi_long iov_len; /* Number of bytes */
31e31b8a
FB
315};
316
1a9353d2 317struct target_msghdr {
992f48a0
BS
318 abi_long msg_name; /* Socket name */
319 int msg_namelen; /* Length of name */
320 abi_long msg_iov; /* Data blocks */
321 abi_long msg_iovlen; /* Number of blocks */
322 abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
323 abi_long msg_controllen; /* Length of cmsg list */
1a9353d2
FB
324 unsigned int msg_flags;
325};
326
7854b056 327struct target_cmsghdr {
992f48a0 328 abi_long cmsg_len;
7854b056
FB
329 int cmsg_level;
330 int cmsg_type;
331};
332
333#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
ee104587
JN
334#define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
335 __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
992f48a0
BS
336#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
337 & (size_t) ~(sizeof (abi_long) - 1))
ad762b99
PM
338#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
339 TARGET_CMSG_ALIGN(len))
340#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
7854b056
FB
341
342static __inline__ struct target_cmsghdr *
ee104587
JN
343__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
344 struct target_cmsghdr *__cmsg,
345 struct target_cmsghdr *__cmsg_start)
7854b056 346{
2b8bdefc
TS
347 struct target_cmsghdr *__ptr;
348
349 __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
cbb21eed 350 + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
ee104587
JN
351 if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
352 > tswapal(__mhdr->msg_controllen)) {
7854b056 353 /* No more entries. */
2b8bdefc 354 return (struct target_cmsghdr *)0;
ee104587
JN
355 }
356 return __ptr;
7854b056
FB
357}
358
f19e00d7
AG
359struct target_mmsghdr {
360 struct target_msghdr msg_hdr; /* Message header */
361 unsigned int msg_len; /* Number of bytes transmitted */
362};
7854b056 363
31e31b8a
FB
364struct target_rusage {
365 struct target_timeval ru_utime; /* user time used */
366 struct target_timeval ru_stime; /* system time used */
992f48a0
BS
367 abi_long ru_maxrss; /* maximum resident set size */
368 abi_long ru_ixrss; /* integral shared memory size */
369 abi_long ru_idrss; /* integral unshared data size */
370 abi_long ru_isrss; /* integral unshared stack size */
371 abi_long ru_minflt; /* page reclaims */
372 abi_long ru_majflt; /* page faults */
373 abi_long ru_nswap; /* swaps */
374 abi_long ru_inblock; /* block input operations */
375 abi_long ru_oublock; /* block output operations */
376 abi_long ru_msgsnd; /* messages sent */
377 abi_long ru_msgrcv; /* messages received */
378 abi_long ru_nsignals; /* signals received */
379 abi_long ru_nvcsw; /* voluntary context switches */
380 abi_long ru_nivcsw; /* involuntary " */
31e31b8a
FB
381};
382
383typedef struct {
384 int val[2];
c227f099 385} kernel_fsid_t;
31e31b8a 386
dab2ed99 387struct target_dirent {
333858b7
DL
388 abi_long d_ino;
389 abi_long d_off;
390 unsigned short d_reclen;
391 char d_name[];
dab2ed99
FB
392};
393
394struct target_dirent64 {
395 uint64_t d_ino;
396 int64_t d_off;
397 unsigned short d_reclen;
398 unsigned char d_type;
399 char d_name[256];
400};
401
402
31e31b8a 403/* mostly generic signal stuff */
992f48a0
BS
404#define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
405#define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
406#define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
31e31b8a
FB
407
408#ifdef TARGET_MIPS
409#define TARGET_NSIG 128
410#else
411#define TARGET_NSIG 64
412#endif
992f48a0 413#define TARGET_NSIG_BPW TARGET_ABI_BITS
31e31b8a
FB
414#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
415
416typedef struct {
992f48a0 417 abi_ulong sig[TARGET_NSIG_WORDS];
c227f099 418} target_sigset_t;
31e31b8a 419
66fb9763 420#ifdef BSWAP_NEEDED
c227f099 421static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
422{
423 int i;
424 for(i = 0;i < TARGET_NSIG_WORDS; i++)
cbb21eed 425 d->sig[i] = tswapal(s->sig[i]);
66fb9763
FB
426}
427#else
c227f099 428static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
429{
430 *d = *s;
431}
432#endif
433
c227f099 434static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
66fb9763
FB
435{
436 int i;
437 d->sig[0] = set;
438 for(i = 1;i < TARGET_NSIG_WORDS; i++)
439 d->sig[i] = 0;
440}
441
c227f099
AL
442void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
443void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
992f48a0 444void host_to_target_old_sigset(abi_ulong *old_sigset,
66fb9763 445 const sigset_t *sigset);
5fafdf24 446void target_to_host_old_sigset(sigset_t *sigset,
992f48a0 447 const abi_ulong *old_sigset);
66fb9763
FB
448struct target_sigaction;
449int do_sigaction(int sig, const struct target_sigaction *act,
450 struct target_sigaction *oact);
451
9850f9f6
LV
452#include "target_signal.h"
453
7f047de1
RH
454#ifdef TARGET_SA_RESTORER
455#define TARGET_ARCH_HAS_SA_RESTORER 1
456#endif
457
6049f4f8
RH
458#if defined(TARGET_ALPHA)
459struct target_old_sigaction {
460 abi_ulong _sa_handler;
461 abi_ulong sa_mask;
d2565875 462 int32_t sa_flags;
6049f4f8
RH
463};
464
465struct target_rt_sigaction {
466 abi_ulong _sa_handler;
467 abi_ulong sa_flags;
468 target_sigset_t sa_mask;
469};
106ec879 470
6049f4f8
RH
471/* This is the struct used inside the kernel. The ka_restorer
472 field comes from the 5th argument to sys_rt_sigaction. */
473struct target_sigaction {
474 abi_ulong _sa_handler;
475 abi_ulong sa_flags;
476 target_sigset_t sa_mask;
477 abi_ulong sa_restorer;
478};
479#elif defined(TARGET_MIPS)
106ec879 480struct target_sigaction {
540635ba 481 uint32_t sa_flags;
d26bc211 482#if defined(TARGET_ABI_MIPSN32)
540635ba
TS
483 uint32_t _sa_handler;
484#else
992f48a0 485 abi_ulong _sa_handler;
540635ba 486#endif
c227f099 487 target_sigset_t sa_mask;
7f047de1
RH
488#ifdef TARGET_ARCH_HAS_SA_RESTORER
489 /* ??? This is always present, but ignored unless O32. */
490 abi_ulong sa_restorer;
491#endif
106ec879 492};
106ec879 493#else
2521d698 494struct target_old_sigaction {
992f48a0
BS
495 abi_ulong _sa_handler;
496 abi_ulong sa_mask;
497 abi_ulong sa_flags;
7f047de1 498#ifdef TARGET_ARCH_HAS_SA_RESTORER
992f48a0 499 abi_ulong sa_restorer;
7f047de1 500#endif
2521d698
FB
501};
502
503struct target_sigaction {
992f48a0
BS
504 abi_ulong _sa_handler;
505 abi_ulong sa_flags;
7f047de1 506#ifdef TARGET_ARCH_HAS_SA_RESTORER
992f48a0 507 abi_ulong sa_restorer;
7f047de1 508#endif
c227f099 509 target_sigset_t sa_mask;
5de154e8
LV
510#ifdef TARGET_ARCH_HAS_KA_RESTORER
511 abi_ulong ka_restorer;
512#endif
2521d698 513};
106ec879 514#endif
2521d698
FB
515
516typedef union target_sigval {
517 int sival_int;
992f48a0 518 abi_ulong sival_ptr;
c227f099 519} target_sigval_t;
6d5e216d
FB
520#if 0
521#if defined (TARGET_SPARC)
522typedef struct {
523 struct {
992f48a0
BS
524 abi_ulong psr;
525 abi_ulong pc;
526 abi_ulong npc;
527 abi_ulong y;
528 abi_ulong u_regs[16]; /* globals and ins */
6d5e216d
FB
529 } si_regs;
530 int si_mask;
531} __siginfo_t;
532
533typedef struct {
534 unsigned long si_float_regs [32];
535 unsigned long si_fsr;
536 unsigned long si_fpqdepth;
537 struct {
538 unsigned long *insn_addr;
539 unsigned long insn;
540 } si_fpqueue [16];
541} __siginfo_fpu_t;
542#endif
543#endif
2521d698
FB
544
545#define TARGET_SI_MAX_SIZE 128
aa5e03d2
MO
546
547#if TARGET_ABI_BITS == 32
548#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
549#else
550#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
551#endif
552
553#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
2521d698 554
a70dadc7
PM
555/* Within QEMU the top 16 bits of si_code indicate which of the parts of
556 * the union in target_siginfo is valid. This only applies between
557 * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
558 * appear either within host siginfo_t or in target_siginfo structures
559 * which we get from the guest userspace program. (The Linux kernel
560 * does a similar thing with using the top bits for its own internal
561 * purposes but not letting them be visible to userspace.)
562 */
563#define QEMU_SI_KILL 0
564#define QEMU_SI_TIMER 1
565#define QEMU_SI_POLL 2
566#define QEMU_SI_FAULT 3
567#define QEMU_SI_CHLD 4
568#define QEMU_SI_RT 5
569
2521d698 570typedef struct target_siginfo {
3f53d546
PB
571#ifdef TARGET_MIPS
572 int si_signo;
573 int si_code;
574 int si_errno;
575#else
2521d698
FB
576 int si_signo;
577 int si_errno;
578 int si_code;
3f53d546 579#endif
2521d698
FB
580
581 union {
582 int _pad[TARGET_SI_PAD_SIZE];
583
584 /* kill() */
585 struct {
586 pid_t _pid; /* sender's pid */
587 uid_t _uid; /* sender's uid */
588 } _kill;
589
590 /* POSIX.1b timers */
591 struct {
592 unsigned int _timer1;
593 unsigned int _timer2;
594 } _timer;
595
596 /* POSIX.1b signals */
597 struct {
598 pid_t _pid; /* sender's pid */
599 uid_t _uid; /* sender's uid */
c227f099 600 target_sigval_t _sigval;
2521d698
FB
601 } _rt;
602
603 /* SIGCHLD */
604 struct {
605 pid_t _pid; /* which child */
606 uid_t _uid; /* sender's uid */
607 int _status; /* exit code */
c227f099
AL
608 target_clock_t _utime;
609 target_clock_t _stime;
2521d698
FB
610 } _sigchld;
611
612 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
613 struct {
992f48a0 614 abi_ulong _addr; /* faulting insn/memory ref. */
2521d698
FB
615 } _sigfault;
616
617 /* SIGPOLL */
618 struct {
619 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
620 int _fd;
621 } _sigpoll;
622 } _sifields;
c227f099 623} target_siginfo_t;
2521d698
FB
624
625/*
626 * si_code values
627 * Digital reserves positive values for kernel-generated signals.
628 */
629#define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
630#define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
631#define TARGET_SI_QUEUE -1 /* sent by sigqueue */
632#define TARGET_SI_TIMER -2 /* sent by timer expiration */
633#define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
634#define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
635#define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
636
637/*
638 * SIGILL si_codes
639 */
ffa65c3b 640#define TARGET_ILL_ILLOPC (1) /* illegal opcode */
2521d698 641#define TARGET_ILL_ILLOPN (2) /* illegal operand */
ffa65c3b
FB
642#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
643#define TARGET_ILL_ILLTRP (4) /* illegal trap */
644#define TARGET_ILL_PRVOPC (5) /* privileged opcode */
645#define TARGET_ILL_PRVREG (6) /* privileged register */
646#define TARGET_ILL_COPROC (7) /* coprocessor error */
647#define TARGET_ILL_BADSTK (8) /* internal stack error */
de2fdd56
CG
648#ifdef TARGET_TILEGX
649#define TARGET_ILL_DBLFLT (9) /* double fault */
650#define TARGET_ILL_HARDWALL (10) /* user networks hardwall violation */
651#endif
2521d698
FB
652
653/*
654 * SIGFPE si_codes
655 */
656#define TARGET_FPE_INTDIV (1) /* integer divide by zero */
657#define TARGET_FPE_INTOVF (2) /* integer overflow */
658#define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
659#define TARGET_FPE_FLTOVF (4) /* floating point overflow */
660#define TARGET_FPE_FLTUND (5) /* floating point underflow */
661#define TARGET_FPE_FLTRES (6) /* floating point inexact result */
662#define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
663#define TARGET_FPE_FLTSUB (8) /* subscript out of range */
21ba8564
RH
664#define TARGET_FPE_FLTUNK (14) /* undiagnosed fp exception */
665#define TARGET_NSIGFPE 15
2521d698
FB
666
667/*
668 * SIGSEGV si_codes
669 */
670#define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
671#define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
de2fdd56 672#define TARGET_SEGV_BNDERR (3) /* failed address bound checks */
2521d698 673
ffa65c3b
FB
674/*
675 * SIGBUS si_codes
676 */
677#define TARGET_BUS_ADRALN (1) /* invalid address alignment */
b4916d7b 678#define TARGET_BUS_ADRERR (2) /* non-existent physical address */
ffa65c3b 679#define TARGET_BUS_OBJERR (3) /* object specific hardware error */
de2fdd56
CG
680/* hardware memory error consumed on a machine check: action required */
681#define TARGET_BUS_MCEERR_AR (4)
682/* hardware memory error detected in process but not consumed: action optional*/
683#define TARGET_BUS_MCEERR_AO (5)
ffa65c3b 684
2521d698
FB
685/*
686 * SIGTRAP si_codes
687 */
688#define TARGET_TRAP_BRKPT (1) /* process breakpoint */
689#define TARGET_TRAP_TRACE (2) /* process trace trap */
de2fdd56
CG
690#define TARGET_TRAP_BRANCH (3) /* process taken branch trap */
691#define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint */
2521d698 692
9de5e440 693struct target_rlimit {
992f48a0
BS
694 abi_ulong rlim_cur;
695 abi_ulong rlim_max;
9de5e440
FB
696};
697
81bbe906 698#if defined(TARGET_ALPHA)
e476492e 699#define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
6cafd027 700#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
81bbe906
TY
701#define TARGET_RLIM_INFINITY 0x7fffffffUL
702#else
26b746db 703#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
81bbe906
TY
704#endif
705
e22b7015
WT
706#if defined(TARGET_MIPS)
707#define TARGET_RLIMIT_CPU 0
708#define TARGET_RLIMIT_FSIZE 1
709#define TARGET_RLIMIT_DATA 2
710#define TARGET_RLIMIT_STACK 3
711#define TARGET_RLIMIT_CORE 4
712#define TARGET_RLIMIT_RSS 7
713#define TARGET_RLIMIT_NPROC 8
714#define TARGET_RLIMIT_NOFILE 5
715#define TARGET_RLIMIT_MEMLOCK 9
716#define TARGET_RLIMIT_AS 6
717#define TARGET_RLIMIT_LOCKS 10
718#define TARGET_RLIMIT_SIGPENDING 11
719#define TARGET_RLIMIT_MSGQUEUE 12
720#define TARGET_RLIMIT_NICE 13
721#define TARGET_RLIMIT_RTPRIO 14
722#else
723#define TARGET_RLIMIT_CPU 0
724#define TARGET_RLIMIT_FSIZE 1
725#define TARGET_RLIMIT_DATA 2
726#define TARGET_RLIMIT_STACK 3
727#define TARGET_RLIMIT_CORE 4
728#define TARGET_RLIMIT_RSS 5
6cafd027
MB
729#if defined(TARGET_SPARC)
730#define TARGET_RLIMIT_NOFILE 6
731#define TARGET_RLIMIT_NPROC 7
732#else
e22b7015
WT
733#define TARGET_RLIMIT_NPROC 6
734#define TARGET_RLIMIT_NOFILE 7
6cafd027 735#endif
e22b7015
WT
736#define TARGET_RLIMIT_MEMLOCK 8
737#define TARGET_RLIMIT_AS 9
738#define TARGET_RLIMIT_LOCKS 10
739#define TARGET_RLIMIT_SIGPENDING 11
740#define TARGET_RLIMIT_MSGQUEUE 12
741#define TARGET_RLIMIT_NICE 13
742#define TARGET_RLIMIT_RTPRIO 14
743#endif
744
9de5e440
FB
745struct target_pollfd {
746 int fd; /* file descriptor */
747 short events; /* requested events */
748 short revents; /* returned events */
749};
750
8e5a0667 751/* virtual terminal ioctls */
0221cfcd
FB
752#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
753#define TARGET_KDMKTONE 0x4B30 /* generate tone */
8e5a0667 754#define TARGET_KDGKBTYPE 0x4b33
f7680a55
UH
755#define TARGET_KDSETMODE 0x4b3a
756#define TARGET_KDGKBMODE 0x4b44
757#define TARGET_KDSKBMODE 0x4b45
0221cfcd
FB
758#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
759#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
e6fe18fb
CV
760#define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
761#define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
762#define TARGET_KDGETLED 0x4B31 /* return current led state */
763#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
ca56f5b5 764#define TARGET_KDSIGACCEPT 0x4B4E
8e5a0667 765
373b067f
FB
766struct target_rtc_pll_info {
767 int pll_ctrl;
768 int pll_value;
769 int pll_max;
770 int pll_min;
771 int pll_posmult;
772 int pll_negmult;
773 abi_long pll_clock;
774};
775
68365f96
FB
776/* real time clock ioctls */
777#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01)
778#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02)
779#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03)
780#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04)
781#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05)
782#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06)
783#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f)
784#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10)
178b14a0
FB
785#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time)
786#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time)
787#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time)
788#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time)
fa857eb5
FB
789#define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong)
790#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong)
791#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong)
792#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
abc81bf6
FB
793#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm)
794#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
373b067f
FB
795#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \
796 struct target_rtc_pll_info)
797#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \
798 struct target_rtc_pll_info)
a7b09746
FB
799#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int)
800#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14)
68365f96 801
d14eabbe
AM
802#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
803 defined(TARGET_XTENSA)
4e4b173f
AM
804#define TARGET_FIOGETOWN TARGET_IOR('f', 123, int)
805#define TARGET_FIOSETOWN TARGET_IOW('f', 124, int)
e1be1606 806#define TARGET_SIOCATMARK TARGET_IOR('s', 7, int)
c495a793 807#define TARGET_SIOCSPGRP TARGET_IOW('s', 8, pid_t)
405b4915 808#define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)
e1be1606 809#else
4e4b173f
AM
810#define TARGET_FIOGETOWN 0x8903
811#define TARGET_FIOSETOWN 0x8901
2521d698 812#define TARGET_SIOCATMARK 0x8905
c495a793 813#define TARGET_SIOCSPGRP 0x8902
405b4915 814#define TARGET_SIOCGPGRP 0x8904
e1be1606 815#endif
c495a793 816
6d5d5dde
DB
817#if defined(TARGET_SH4)
818#define TARGET_SIOCGSTAMP_OLD TARGET_IOR('s', 100, struct target_timeval)
819#define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
820#else
821#define TARGET_SIOCGSTAMP_OLD 0x8906
822#define TARGET_SIOCGSTAMPNS_OLD 0x8907
823#endif
824
825#define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2])
826#define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
2521d698 827
31e31b8a
FB
828/* Networking ioctls */
829#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
830#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
831#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
832#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
833#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
834#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
835#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
836#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
837#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
838#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
839#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
840#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
841#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
842#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
843#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
844#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
845#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
846#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
847#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
848#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
849#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
850#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
851#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
852#define TARGET_SIOCSIFENCAP 0x8926
853#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
854#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
855#define TARGET_SIOCSIFSLAVE 0x8930
856#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
857#define TARGET_SIOCDELMULTI 0x8932
f63eb01a 858#define TARGET_SIOCGIFINDEX 0x8933
4bdcd79e
NC
859#define TARGET_SIOCSIFPFLAGS 0x8934 /* set extended flags */
860#define TARGET_SIOCGIFPFLAGS 0x8935 /* get extended flags */
31e31b8a
FB
861
862/* Bridging control calls */
863#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
864#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
865
866#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
867#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
868
869/* ARP cache control calls. */
870#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
871#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
872#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
873#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
874#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
875#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
876
877/* RARP cache control calls. */
878#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
879#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
880#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
881
882/* Driver configuration calls */
883#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
884#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
885
886/* DLCI configuration calls */
887#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
888#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
889
86fcd946
LV
890/* From <linux/wireless.h> */
891
892#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
31e31b8a 893
d6d6d6fe
MB
894/* From <linux/random.h> */
895
896#define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
897#define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
898#define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
899#define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
92c096f0 900#define TARGET_RNDRESEEDCRNG TARGET_IO('R', 0x07)
d6d6d6fe 901
31e31b8a
FB
902/* From <linux/fs.h> */
903
904#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
905#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
906#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
907#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
908#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
909#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
910#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
911#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
912#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
913#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
914#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
915#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
fff8c539 916#define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
31e31b8a 917/* A jump here: 108-111 have been used for various private purposes. */
c8b0bf54
PM
918#define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
919#define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
edafea13
AG
920#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
921 /* return device size in bytes
922 (u64 *arg) */
4715856a
PM
923
924#define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
925#define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
926#define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
927#define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
928#define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
929#define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
930#define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
931#define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
932#define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
933
ab22b4dd
YS
934/* From <linux/fd.h> */
935
7e35fc8b
AM
936#define TARGET_FDMSGON TARGET_IO(2, 0x45)
937#define TARGET_FDMSGOFF TARGET_IO(2, 0x46)
08e3ce59
AM
938#define TARGET_FDFMTBEG TARGET_IO(2, 0x47)
939#define TARGET_FDFMTTRK TARGET_IOW(2, 0x48, struct format_descr)
940#define TARGET_FDFMTEND TARGET_IO(2, 0x49)
81eb1a36 941#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
ab22b4dd 942#define TARGET_FDFLUSH TARGET_IO(2, 0x4b)
81eb1a36
AM
943#define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors)
944#define TARGET_FDGETMAXERRS TARGET_IOR(2, 0x0e, struct floppy_max_errors)
5eea9429
AM
945#define TARGET_FDRESET TARGET_IO(2, 0x54)
946#define TARGET_FDRAWCMD TARGET_IO(2, 0x58)
947#define TARGET_FDTWADDLE TARGET_IO(2, 0x59)
948#define TARGET_FDEJECT TARGET_IO(2, 0x5a)
ab22b4dd 949
31e31b8a
FB
950#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
951#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
21992cb6
HD
952
953#define TARGET_FICLONE TARGET_IOW(0x94, 9, int)
954#define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
955
5ae774a9
AM
956/*
957 * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
958 * claim type "long" but the actual type used by the kernel is "int".
60807231 959 */
1847b7ba
PM
960#define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
961#define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
5ae774a9
AM
962#define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
963#define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
285da2b9 964#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
0b471ba6
AM
965#define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
966#define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
0d899cd6
AM
967#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
968#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
31e31b8a 969
6c753a63
CT
970/* usb ioctls */
971#define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
972#define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
973#define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
974#define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
975#define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U', 5)
976#define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
a133367e
CT
977#define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
978#define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
979#define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
980#define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
6c753a63
CT
981#define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
982#define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
983#define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
984#define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
985#define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
986#define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
987#define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
988#define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
989#define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
990#define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
991#define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
992#define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
993#define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
994#define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
995#define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
996#define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
997
31e31b8a 998/* cdrom commands */
5fafdf24 999#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
31e31b8a
FB
1000#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
1001#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
5fafdf24 1002#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
31e31b8a 1003 (struct cdrom_ti) */
5fafdf24 1004#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
31e31b8a 1005 (struct cdrom_tochdr) */
5fafdf24 1006#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
31e31b8a
FB
1007 (struct cdrom_tocentry) */
1008#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
1009#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
1010#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
5fafdf24 1011#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
31e31b8a 1012 (struct cdrom_volctrl) */
5fafdf24 1013#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
31e31b8a 1014 (struct cdrom_subchnl) */
5fafdf24 1015#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
31e31b8a
FB
1016 (struct cdrom_read) */
1017#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
1018 (struct cdrom_read) */
1019#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
1020#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
5fafdf24
TS
1021#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
1022 address of multi session disks
31e31b8a 1023 (struct cdrom_multisession) */
5fafdf24 1024#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
31e31b8a 1025 if available (struct cdrom_mcn) */
67cc32eb 1026#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is deprecated,
b4916d7b 1027 but here anyway for compatibility */
31e31b8a 1028#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
5fafdf24 1029#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
31e31b8a
FB
1030 (struct cdrom_volctrl) */
1031#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
1032 (struct cdrom_read) */
5fafdf24 1033/*
31e31b8a
FB
1034 * These ioctls are used only used in aztcd.c and optcd.c
1035 */
1036#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
1037#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
3b46e624 1038
31e31b8a 1039/*
3b46e624 1040 * This ioctl is only used by the scsi-cd driver.
31e31b8a
FB
1041 It is for playing audio in logical block addressing mode.
1042 */
1043#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
1044
5fafdf24 1045/*
31e31b8a
FB
1046 * These ioctls are only used in optcd.c
1047 */
1048#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
1049
5fafdf24
TS
1050/*
1051 * These ioctls are (now) only in ide-cd.c for controlling
31e31b8a
FB
1052 * drive spindown time. They should be implemented in the
1053 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
1054 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
1055 * -Erik
1056 */
1057#define TARGET_CDROMGETSPINDOWN 0x531d
1058#define TARGET_CDROMSETSPINDOWN 0x531e
1059
5fafdf24 1060/*
31e31b8a
FB
1061 * These ioctls are implemented through the uniform CD-ROM driver
1062 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
1063 * drivers are eventually ported to the uniform CD-ROM driver interface.
1064 */
1065#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
1066#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
1067#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
1068#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
1069#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
1070#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
1071#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
1072#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
1073#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
1074#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
1075#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
1076#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
1077
1078/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
1079 * Future CDROM ioctls should be kept below 0x537F
1080 */
1081
1082/* This ioctl is only used by sbpcd at the moment */
1083#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
1084 /* conflict with SCSI_IOCTL_GET_IDLUN */
1085
1086/* DVD-ROM Specific ioctls */
1087#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
1088#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
1089#define TARGET_DVD_AUTH 0x5392 /* Authentication */
1090
1091#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
1092#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
1093#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
1094
1095/* HD commands */
1096
1097/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
1098#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
1099#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
1100#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
31e31b8a
FB
1101#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
1102#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
1103#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
1104#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
2521d698 1105#define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
31e31b8a
FB
1106#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
1107
1108/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
1109#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
1110#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
1111#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
1112#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
1113#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
1114#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
1115#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
2521d698 1116
b8005914
AZ
1117/* loop ioctls */
1118#define TARGET_LOOP_SET_FD 0x4C00
1119#define TARGET_LOOP_CLR_FD 0x4C01
1120#define TARGET_LOOP_SET_STATUS 0x4C02
1121#define TARGET_LOOP_GET_STATUS 0x4C03
1122#define TARGET_LOOP_SET_STATUS64 0x4C04
1123#define TARGET_LOOP_GET_STATUS64 0x4C05
1124#define TARGET_LOOP_CHANGE_FD 0x4C06
2521d698 1125
884cdc48
PM
1126#define TARGET_LOOP_CTL_ADD 0x4C80
1127#define TARGET_LOOP_CTL_REMOVE 0x4C81
1128#define TARGET_LOOP_CTL_GET_FREE 0x4C82
1129
f7680a55
UH
1130/* fb ioctls */
1131#define TARGET_FBIOGET_VSCREENINFO 0x4600
1132#define TARGET_FBIOPUT_VSCREENINFO 0x4601
1133#define TARGET_FBIOGET_FSCREENINFO 0x4602
12b81b71
CV
1134#define TARGET_FBIOGETCMAP 0x4604
1135#define TARGET_FBIOPUTCMAP 0x4605
1136#define TARGET_FBIOPAN_DISPLAY 0x4606
1137#define TARGET_FBIOGET_CON2FBMAP 0x460F
1138#define TARGET_FBIOPUT_CON2FBMAP 0x4610
f7680a55
UH
1139
1140/* vt ioctls */
1141#define TARGET_VT_OPENQRY 0x5600
1142#define TARGET_VT_GETSTATE 0x5603
1143#define TARGET_VT_ACTIVATE 0x5606
1144#define TARGET_VT_WAITACTIVE 0x5607
1145#define TARGET_VT_LOCKSWITCH 0x560b
1146#define TARGET_VT_UNLOCKSWITCH 0x560c
774750c0
CV
1147#define TARGET_VT_GETMODE 0x5601
1148#define TARGET_VT_SETMODE 0x5602
1149#define TARGET_VT_RELDISP 0x5605
1150#define TARGET_VT_DISALLOCATE 0x5608
f7680a55 1151
56e904ec
AG
1152/* device mapper */
1153#define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
1154#define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
1155#define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
1156#define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
1157#define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
1158#define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
1159#define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
1160#define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
1161#define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
1162#define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
1163#define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
1164#define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
1165#define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
1166#define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
1167#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
1168#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
1169
e865b97f
CG
1170/* drm ioctls */
1171#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00)
1172
2521d698
FB
1173/* from asm/termbits.h */
1174
3bfd9da1
FB
1175#define TARGET_NCC 8
1176struct target_termio {
1177 unsigned short c_iflag; /* input mode flags */
1178 unsigned short c_oflag; /* output mode flags */
1179 unsigned short c_cflag; /* control mode flags */
1180 unsigned short c_lflag; /* local mode flags */
1181 unsigned char c_line; /* line discipline */
1182 unsigned char c_cc[TARGET_NCC]; /* control characters */
1183};
2521d698 1184
3bfd9da1
FB
1185struct target_winsize {
1186 unsigned short ws_row;
1187 unsigned short ws_col;
1188 unsigned short ws_xpixel;
1189 unsigned short ws_ypixel;
2521d698
FB
1190};
1191
3bfd9da1 1192#include "termbits.h"
2521d698 1193
9e0b74a4
PB
1194#if defined(TARGET_MIPS)
1195#define TARGET_PROT_SEM 0x10
1196#else
1197#define TARGET_PROT_SEM 0x08
1198#endif
1199
e44a3e79 1200/* Common */
2521d698
FB
1201#define TARGET_MAP_SHARED 0x01 /* Share changes */
1202#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
e65be6a7
HD
1203#if defined(TARGET_HPPA)
1204#define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
1205#else
1206#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
1207#endif
e44a3e79
AJ
1208
1209/* Target specific */
048f6b4d 1210#if defined(TARGET_MIPS)
e44a3e79 1211#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
048f6b4d
FB
1212#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1213#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1214#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1215#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1216#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1217#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
540635ba
TS
1218#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1219#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
541e1690
HD
1220#define TARGET_MAP_STACK 0x40000 /* ignored */
1221#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
e44a3e79
AJ
1222#elif defined(TARGET_PPC)
1223#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
2521d698 1224#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
2521d698
FB
1225#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1226#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1227#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
7ec93196
JM
1228#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
1229#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
e44a3e79
AJ
1230#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1231#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
541e1690
HD
1232#define TARGET_MAP_STACK 0x20000 /* ignored */
1233#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
e44a3e79
AJ
1234#elif defined(TARGET_ALPHA)
1235#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1236#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
1237#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
1238#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
1239#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
1240#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
1241#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
1242#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
1243#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
541e1690
HD
1244#define TARGET_MAP_STACK 0x80000 /* ignored */
1245#define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
a10d1e50
RH
1246#elif defined(TARGET_HPPA)
1247#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1248#define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
1249#define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */
1250#define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */
1251#define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */
1252#define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */
1253#define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
1254#define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
1255#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
541e1690
HD
1256#define TARGET_MAP_STACK 0x40000 /* ignored */
1257#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
ba7651fb
MF
1258#elif defined(TARGET_XTENSA)
1259#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1260#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1261#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1262#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1263#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1264#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1265#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
1266#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1267#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
1268#define TARGET_MAP_STACK 0x40000
1269#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
7ec93196 1270#else
e44a3e79
AJ
1271#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1272#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
1273#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1274#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1275#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
2521d698
FB
1276#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
1277#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
540635ba
TS
1278#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1279#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
541e1690
HD
1280#define TARGET_MAP_STACK 0x20000 /* ignored */
1281#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
906c1b8e 1282#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
7ec93196 1283#endif
2521d698 1284
09701199
AG
1285#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
1286 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
daa4374a 1287 || defined(TARGET_CRIS)
5f992db6 1288#define TARGET_STAT_HAVE_NSEC
2521d698
FB
1289struct target_stat {
1290 unsigned short st_dev;
1291 unsigned short __pad1;
992f48a0 1292 abi_ulong st_ino;
2521d698
FB
1293 unsigned short st_mode;
1294 unsigned short st_nlink;
1295 unsigned short st_uid;
1296 unsigned short st_gid;
1297 unsigned short st_rdev;
1298 unsigned short __pad2;
992f48a0
BS
1299 abi_ulong st_size;
1300 abi_ulong st_blksize;
1301 abi_ulong st_blocks;
1302 abi_ulong target_st_atime;
5f992db6 1303 abi_ulong target_st_atime_nsec;
992f48a0 1304 abi_ulong target_st_mtime;
5f992db6 1305 abi_ulong target_st_mtime_nsec;
992f48a0 1306 abi_ulong target_st_ctime;
5f992db6 1307 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1308 abi_ulong __unused4;
1309 abi_ulong __unused5;
2521d698
FB
1310};
1311
1312/* This matches struct stat64 in glibc2.1, hence the absolutely
1313 * insane amounts of padding around dev_t's.
1314 */
20d155bc 1315#define TARGET_HAS_STRUCT_STAT64
2521d698
FB
1316struct target_stat64 {
1317 unsigned short st_dev;
1318 unsigned char __pad0[10];
1319
1320#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1321 abi_ulong __st_ino;
2521d698
FB
1322
1323 unsigned int st_mode;
1324 unsigned int st_nlink;
1325
992f48a0
BS
1326 abi_ulong st_uid;
1327 abi_ulong st_gid;
2521d698
FB
1328
1329 unsigned short st_rdev;
1330 unsigned char __pad3[10];
1331
1332 long long st_size;
992f48a0 1333 abi_ulong st_blksize;
2521d698 1334
992f48a0
BS
1335 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
1336 abi_ulong __pad4; /* future possible st_blocks high bits */
2521d698 1337
992f48a0 1338 abi_ulong target_st_atime;
5f992db6 1339 abi_ulong target_st_atime_nsec;
2521d698 1340
992f48a0 1341 abi_ulong target_st_mtime;
5f992db6 1342 abi_ulong target_st_mtime_nsec;
2521d698 1343
992f48a0 1344 abi_ulong target_st_ctime;
5f992db6 1345 abi_ulong target_st_ctime_nsec;
2521d698
FB
1346
1347 unsigned long long st_ino;
541dc0d4 1348} QEMU_PACKED;
2521d698 1349
ce4defa0 1350#ifdef TARGET_ARM
20d155bc 1351#define TARGET_HAS_STRUCT_STAT64
ce4defa0
PB
1352struct target_eabi_stat64 {
1353 unsigned long long st_dev;
1354 unsigned int __pad1;
992f48a0 1355 abi_ulong __st_ino;
ce4defa0
PB
1356 unsigned int st_mode;
1357 unsigned int st_nlink;
1358
992f48a0
BS
1359 abi_ulong st_uid;
1360 abi_ulong st_gid;
ce4defa0
PB
1361
1362 unsigned long long st_rdev;
1363 unsigned int __pad2[2];
1364
1365 long long st_size;
992f48a0 1366 abi_ulong st_blksize;
ce4defa0
PB
1367 unsigned int __pad3;
1368 unsigned long long st_blocks;
1369
992f48a0
BS
1370 abi_ulong target_st_atime;
1371 abi_ulong target_st_atime_nsec;
ce4defa0 1372
992f48a0
BS
1373 abi_ulong target_st_mtime;
1374 abi_ulong target_st_mtime_nsec;
ce4defa0 1375
992f48a0
BS
1376 abi_ulong target_st_ctime;
1377 abi_ulong target_st_ctime_nsec;
ce4defa0
PB
1378
1379 unsigned long long st_ino;
541dc0d4 1380} QEMU_PACKED;
ce4defa0
PB
1381#endif
1382
992f48a0 1383#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
1b8dd648
BS
1384struct target_stat {
1385 unsigned int st_dev;
992f48a0 1386 abi_ulong st_ino;
1b8dd648
BS
1387 unsigned int st_mode;
1388 unsigned int st_nlink;
1389 unsigned int st_uid;
1390 unsigned int st_gid;
1391 unsigned int st_rdev;
992f48a0
BS
1392 abi_long st_size;
1393 abi_long target_st_atime;
1394 abi_long target_st_mtime;
1395 abi_long target_st_ctime;
1396 abi_long st_blksize;
1397 abi_long st_blocks;
1398 abi_ulong __unused4[2];
1b8dd648
BS
1399};
1400
20d155bc 1401#define TARGET_HAS_STRUCT_STAT64
1b8dd648
BS
1402struct target_stat64 {
1403 unsigned char __pad0[6];
1404 unsigned short st_dev;
1405
1406 uint64_t st_ino;
1407 uint64_t st_nlink;
1408
1409 unsigned int st_mode;
1410
1411 unsigned int st_uid;
1412 unsigned int st_gid;
1413
1414 unsigned char __pad2[6];
1415 unsigned short st_rdev;
1416
1417 int64_t st_size;
1418 int64_t st_blksize;
1419
1420 unsigned char __pad4[4];
1421 unsigned int st_blocks;
1422
992f48a0 1423 abi_ulong target_st_atime;
5f992db6 1424 abi_ulong target_st_atime_nsec;
1b8dd648 1425
992f48a0 1426 abi_ulong target_st_mtime;
5f992db6 1427 abi_ulong target_st_mtime_nsec;
1b8dd648 1428
992f48a0 1429 abi_ulong target_st_ctime;
5f992db6 1430 abi_ulong target_st_ctime_nsec;
1b8dd648 1431
992f48a0 1432 abi_ulong __unused4[3];
1b8dd648
BS
1433};
1434
3bfd9da1
FB
1435#elif defined(TARGET_SPARC)
1436
5f992db6 1437#define TARGET_STAT_HAVE_NSEC
3bfd9da1
FB
1438struct target_stat {
1439 unsigned short st_dev;
992f48a0 1440 abi_ulong st_ino;
3bfd9da1
FB
1441 unsigned short st_mode;
1442 short st_nlink;
1443 unsigned short st_uid;
1444 unsigned short st_gid;
1445 unsigned short st_rdev;
992f48a0
BS
1446 abi_long st_size;
1447 abi_long target_st_atime;
5f992db6 1448 abi_ulong target_st_atime_nsec;
992f48a0 1449 abi_long target_st_mtime;
5f992db6 1450 abi_ulong target_st_mtime_nsec;
992f48a0 1451 abi_long target_st_ctime;
5f992db6 1452 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1453 abi_long st_blksize;
1454 abi_long st_blocks;
5f992db6 1455 abi_ulong __unused1[2];
3bfd9da1
FB
1456};
1457
20d155bc 1458#define TARGET_HAS_STRUCT_STAT64
3bfd9da1
FB
1459struct target_stat64 {
1460 unsigned char __pad0[6];
1461 unsigned short st_dev;
1462
1463 uint64_t st_ino;
1464
1465 unsigned int st_mode;
1466 unsigned int st_nlink;
1467
1468 unsigned int st_uid;
1469 unsigned int st_gid;
1470
1471 unsigned char __pad2[6];
1472 unsigned short st_rdev;
1473
1474 unsigned char __pad3[8];
1475
1476 int64_t st_size;
1477 unsigned int st_blksize;
1478
1479 unsigned char __pad4[8];
1480 unsigned int st_blocks;
1481
1482 unsigned int target_st_atime;
5f992db6 1483 unsigned int target_st_atime_nsec;
3bfd9da1
FB
1484
1485 unsigned int target_st_mtime;
5f992db6 1486 unsigned int target_st_mtime_nsec;
3bfd9da1
FB
1487
1488 unsigned int target_st_ctime;
5f992db6 1489 unsigned int target_st_ctime_nsec;
3bfd9da1 1490
5f992db6
CYT
1491 unsigned int __unused1;
1492 unsigned int __unused2;
3bfd9da1
FB
1493};
1494
67867308
FB
1495#elif defined(TARGET_PPC)
1496
5f992db6 1497#define TARGET_STAT_HAVE_NSEC
67867308 1498struct target_stat {
e32448e0 1499 abi_ulong st_dev;
992f48a0 1500 abi_ulong st_ino;
325e651f 1501#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
e32448e0 1502 abi_ulong st_nlink;
325e651f
JM
1503 unsigned int st_mode;
1504#else
67867308
FB
1505 unsigned int st_mode;
1506 unsigned short st_nlink;
325e651f 1507#endif
67867308
FB
1508 unsigned int st_uid;
1509 unsigned int st_gid;
e32448e0 1510 abi_ulong st_rdev;
992f48a0
BS
1511 abi_ulong st_size;
1512 abi_ulong st_blksize;
1513 abi_ulong st_blocks;
1514 abi_ulong target_st_atime;
e32448e0 1515 abi_ulong target_st_atime_nsec;
992f48a0 1516 abi_ulong target_st_mtime;
e32448e0 1517 abi_ulong target_st_mtime_nsec;
992f48a0 1518 abi_ulong target_st_ctime;
e32448e0 1519 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1520 abi_ulong __unused4;
1521 abi_ulong __unused5;
325e651f
JM
1522#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1523 abi_ulong __unused6;
1524#endif
67867308
FB
1525};
1526
20d155bc
SW
1527#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
1528#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1529struct QEMU_PACKED target_stat64 {
67867308 1530 unsigned long long st_dev;
67867308 1531 unsigned long long st_ino;
3bfd9da1
FB
1532 unsigned int st_mode;
1533 unsigned int st_nlink;
67867308
FB
1534 unsigned int st_uid;
1535 unsigned int st_gid;
3bfd9da1 1536 unsigned long long st_rdev;
e1ce5e40 1537 unsigned long long __pad0;
e32448e0
JM
1538 long long st_size;
1539 int st_blksize;
e1ce5e40 1540 unsigned int __pad1;
61322e91 1541 long long st_blocks; /* Number 512-byte blocks allocated. */
e32448e0
JM
1542 int target_st_atime;
1543 unsigned int target_st_atime_nsec;
1544 int target_st_mtime;
1545 unsigned int target_st_mtime_nsec;
1546 int target_st_ctime;
1547 unsigned int target_st_ctime_nsec;
1548 unsigned int __unused4;
1549 unsigned int __unused5;
67867308 1550};
20d155bc 1551#endif
67867308 1552
b779e29e
EI
1553#elif defined(TARGET_MICROBLAZE)
1554
5f992db6 1555#define TARGET_STAT_HAVE_NSEC
b779e29e
EI
1556struct target_stat {
1557 abi_ulong st_dev;
1558 abi_ulong st_ino;
1559 unsigned int st_mode;
1560 unsigned short st_nlink;
1561 unsigned int st_uid;
1562 unsigned int st_gid;
1563 abi_ulong st_rdev;
1564 abi_ulong st_size;
1565 abi_ulong st_blksize;
1566 abi_ulong st_blocks;
1567 abi_ulong target_st_atime;
1568 abi_ulong target_st_atime_nsec;
1569 abi_ulong target_st_mtime;
1570 abi_ulong target_st_mtime_nsec;
1571 abi_ulong target_st_ctime;
1572 abi_ulong target_st_ctime_nsec;
1573 abi_ulong __unused4;
1574 abi_ulong __unused5;
1575};
1576
1577/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
20d155bc 1578#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1579struct QEMU_PACKED target_stat64 {
b779e29e 1580 uint64_t st_dev;
a523eb06
EI
1581#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1582 uint32_t pad0;
1583 uint32_t __st_ino;
1584
b779e29e
EI
1585 uint32_t st_mode;
1586 uint32_t st_nlink;
1587 uint32_t st_uid;
1588 uint32_t st_gid;
1589 uint64_t st_rdev;
21ebeb23 1590 uint64_t __pad1;
b779e29e
EI
1591
1592 int64_t st_size;
21ebeb23
EI
1593 int32_t st_blksize;
1594 uint32_t __pad2;
b779e29e
EI
1595 int64_t st_blocks; /* Number 512-byte blocks allocated. */
1596
1597 int target_st_atime;
a523eb06 1598 unsigned int target_st_atime_nsec;
b779e29e 1599 int target_st_mtime;
a523eb06 1600 unsigned int target_st_mtime_nsec;
b779e29e 1601 int target_st_ctime;
a523eb06
EI
1602 unsigned int target_st_ctime_nsec;
1603 uint64_t st_ino;
b779e29e
EI
1604};
1605
e6e5906b
PB
1606#elif defined(TARGET_M68K)
1607
1608struct target_stat {
1609 unsigned short st_dev;
1610 unsigned short __pad1;
992f48a0 1611 abi_ulong st_ino;
e6e5906b
PB
1612 unsigned short st_mode;
1613 unsigned short st_nlink;
1614 unsigned short st_uid;
1615 unsigned short st_gid;
1616 unsigned short st_rdev;
1617 unsigned short __pad2;
992f48a0
BS
1618 abi_ulong st_size;
1619 abi_ulong st_blksize;
1620 abi_ulong st_blocks;
1621 abi_ulong target_st_atime;
1622 abi_ulong __unused1;
1623 abi_ulong target_st_mtime;
1624 abi_ulong __unused2;
1625 abi_ulong target_st_ctime;
1626 abi_ulong __unused3;
1627 abi_ulong __unused4;
1628 abi_ulong __unused5;
e6e5906b
PB
1629};
1630
1631/* This matches struct stat64 in glibc2.1, hence the absolutely
1632 * insane amounts of padding around dev_t's.
1633 */
20d155bc 1634#define TARGET_HAS_STRUCT_STAT64
e6e5906b
PB
1635struct target_stat64 {
1636 unsigned long long st_dev;
1637 unsigned char __pad1[2];
1638
1639#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1640 abi_ulong __st_ino;
e6e5906b
PB
1641
1642 unsigned int st_mode;
1643 unsigned int st_nlink;
1644
992f48a0
BS
1645 abi_ulong st_uid;
1646 abi_ulong st_gid;
e6e5906b
PB
1647
1648 unsigned long long st_rdev;
1649 unsigned char __pad3[2];
1650
1651 long long st_size;
992f48a0 1652 abi_ulong st_blksize;
e6e5906b 1653
992f48a0
BS
1654 abi_ulong __pad4; /* future possible st_blocks high bits */
1655 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
e6e5906b 1656
992f48a0
BS
1657 abi_ulong target_st_atime;
1658 abi_ulong target_st_atime_nsec;
e6e5906b 1659
992f48a0
BS
1660 abi_ulong target_st_mtime;
1661 abi_ulong target_st_mtime_nsec;
e6e5906b 1662
992f48a0
BS
1663 abi_ulong target_st_ctime;
1664 abi_ulong target_st_ctime_nsec;
e6e5906b
PB
1665
1666 unsigned long long st_ino;
541dc0d4 1667} QEMU_PACKED;
e6e5906b 1668
d26bc211 1669#elif defined(TARGET_ABI_MIPSN64)
540635ba 1670
5f992db6 1671#define TARGET_STAT_HAVE_NSEC
540635ba
TS
1672/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
1673struct target_stat {
1674 unsigned int st_dev;
1675 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1676
992f48a0 1677 abi_ulong st_ino;
540635ba
TS
1678
1679 unsigned int st_mode;
1680 unsigned int st_nlink;
1681
1682 int st_uid;
1683 int st_gid;
1684
1685 unsigned int st_rdev;
1686 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1687
992f48a0 1688 abi_ulong st_size;
540635ba
TS
1689
1690 /*
1691 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1692 * but we don't have it under Linux.
1693 */
1694 unsigned int target_st_atime;
1695 unsigned int target_st_atime_nsec;
1696
1697 unsigned int target_st_mtime;
1698 unsigned int target_st_mtime_nsec;
1699
1700 unsigned int target_st_ctime;
1701 unsigned int target_st_ctime_nsec;
1702
1703 unsigned int st_blksize;
1704 unsigned int st_pad2;
1705
992f48a0 1706 abi_ulong st_blocks;
540635ba
TS
1707};
1708
d26bc211 1709#elif defined(TARGET_ABI_MIPSN32)
540635ba 1710
5f992db6 1711#define TARGET_STAT_HAVE_NSEC
540635ba 1712struct target_stat {
1ab2aea2
LA
1713 abi_ulong st_dev;
1714 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
1715 uint64_t st_ino;
1716 unsigned int st_mode;
1717 unsigned int st_nlink;
1718 int st_uid;
1719 int st_gid;
1720 abi_ulong st_rdev;
1721 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
1722 int64_t st_size;
1723 abi_long target_st_atime;
1724 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
1725 abi_long target_st_mtime;
1726 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
1727 abi_long target_st_ctime;
1728 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
1729 abi_ulong st_blksize;
1730 abi_ulong st_pad2;
1731 int64_t st_blocks;
540635ba
TS
1732};
1733
d26bc211 1734#elif defined(TARGET_ABI_MIPSO32)
048f6b4d 1735
5f992db6 1736#define TARGET_STAT_HAVE_NSEC
048f6b4d
FB
1737struct target_stat {
1738 unsigned st_dev;
992f48a0
BS
1739 abi_long st_pad1[3]; /* Reserved for network id */
1740 abi_ulong st_ino;
048f6b4d
FB
1741 unsigned int st_mode;
1742 unsigned int st_nlink;
1743 int st_uid;
1744 int st_gid;
1745 unsigned st_rdev;
992f48a0
BS
1746 abi_long st_pad2[2];
1747 abi_long st_size;
1748 abi_long st_pad3;
048f6b4d
FB
1749 /*
1750 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1751 * but we don't have it under Linux.
1752 */
992f48a0
BS
1753 abi_long target_st_atime;
1754 abi_long target_st_atime_nsec;
1755 abi_long target_st_mtime;
1756 abi_long target_st_mtime_nsec;
1757 abi_long target_st_ctime;
1758 abi_long target_st_ctime_nsec;
1759 abi_long st_blksize;
1760 abi_long st_blocks;
1761 abi_long st_pad4[14];
048f6b4d
FB
1762};
1763
1764/*
1765 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1766 * amounts of padding around dev_t's. The memory layout is the same as of
1767 * struct stat of the 64-bit kernel.
1768 */
1769
20d155bc 1770#define TARGET_HAS_STRUCT_STAT64
048f6b4d 1771struct target_stat64 {
992f48a0
BS
1772 abi_ulong st_dev;
1773 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
048f6b4d
FB
1774
1775 uint64_t st_ino;
1776
1777 unsigned int st_mode;
1778 unsigned int st_nlink;
1779
1780 int st_uid;
1781 int st_gid;
1782
992f48a0
BS
1783 abi_ulong st_rdev;
1784 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
048f6b4d
FB
1785
1786 int64_t st_size;
1787
1788 /*
1789 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1790 * but we don't have it under Linux.
1791 */
992f48a0
BS
1792 abi_long target_st_atime;
1793 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
048f6b4d 1794
992f48a0
BS
1795 abi_long target_st_mtime;
1796 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
048f6b4d 1797
992f48a0
BS
1798 abi_long target_st_ctime;
1799 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
048f6b4d 1800
992f48a0
BS
1801 abi_ulong st_blksize;
1802 abi_ulong st_pad2;
048f6b4d
FB
1803
1804 int64_t st_blocks;
1805};
7a3148a9
JM
1806
1807#elif defined(TARGET_ALPHA)
1808
1809struct target_stat {
1810 unsigned int st_dev;
1811 unsigned int st_ino;
1812 unsigned int st_mode;
1813 unsigned int st_nlink;
1814 unsigned int st_uid;
1815 unsigned int st_gid;
1816 unsigned int st_rdev;
992f48a0
BS
1817 abi_long st_size;
1818 abi_ulong target_st_atime;
1819 abi_ulong target_st_mtime;
1820 abi_ulong target_st_ctime;
7a3148a9
JM
1821 unsigned int st_blksize;
1822 unsigned int st_blocks;
1823 unsigned int st_flags;
1824 unsigned int st_gen;
1825};
1826
20d155bc 1827#define TARGET_HAS_STRUCT_STAT64
7a3148a9 1828struct target_stat64 {
992f48a0
BS
1829 abi_ulong st_dev;
1830 abi_ulong st_ino;
1831 abi_ulong st_rdev;
1832 abi_long st_size;
1833 abi_ulong st_blocks;
7a3148a9
JM
1834
1835 unsigned int st_mode;
1836 unsigned int st_uid;
1837 unsigned int st_gid;
1838 unsigned int st_blksize;
1839 unsigned int st_nlink;
1840 unsigned int __pad0;
1841
992f48a0
BS
1842 abi_ulong target_st_atime;
1843 abi_ulong target_st_atime_nsec;
1844 abi_ulong target_st_mtime;
1845 abi_ulong target_st_mtime_nsec;
1846 abi_ulong target_st_ctime;
1847 abi_ulong target_st_ctime_nsec;
1848 abi_long __unused[3];
7a3148a9
JM
1849};
1850
6db45e65
TS
1851#elif defined(TARGET_SH4)
1852
5f992db6 1853#define TARGET_STAT_HAVE_NSEC
6db45e65 1854struct target_stat {
992f48a0
BS
1855 abi_ulong st_dev;
1856 abi_ulong st_ino;
6db45e65
TS
1857 unsigned short st_mode;
1858 unsigned short st_nlink;
1859 unsigned short st_uid;
1860 unsigned short st_gid;
992f48a0
BS
1861 abi_ulong st_rdev;
1862 abi_ulong st_size;
1863 abi_ulong st_blksize;
1864 abi_ulong st_blocks;
1865 abi_ulong target_st_atime;
1866 abi_ulong target_st_atime_nsec;
1867 abi_ulong target_st_mtime;
1868 abi_ulong target_st_mtime_nsec;
1869 abi_ulong target_st_ctime;
1870 abi_ulong target_st_ctime_nsec;
1871 abi_ulong __unused4;
1872 abi_ulong __unused5;
6db45e65
TS
1873};
1874
1875/* This matches struct stat64 in glibc2.1, hence the absolutely
1876 * insane amounts of padding around dev_t's.
1877 */
20d155bc 1878#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1879struct QEMU_PACKED target_stat64 {
6db45e65
TS
1880 unsigned long long st_dev;
1881 unsigned char __pad0[4];
1882
1883#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1884 abi_ulong __st_ino;
6db45e65
TS
1885
1886 unsigned int st_mode;
1887 unsigned int st_nlink;
1888
992f48a0
BS
1889 abi_ulong st_uid;
1890 abi_ulong st_gid;
6db45e65
TS
1891
1892 unsigned long long st_rdev;
1893 unsigned char __pad3[4];
1894
1895 long long st_size;
992f48a0 1896 abi_ulong st_blksize;
6db45e65
TS
1897
1898 unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
1899
992f48a0
BS
1900 abi_ulong target_st_atime;
1901 abi_ulong target_st_atime_nsec;
6db45e65 1902
992f48a0
BS
1903 abi_ulong target_st_mtime;
1904 abi_ulong target_st_mtime_nsec;
6db45e65 1905
992f48a0
BS
1906 abi_ulong target_st_ctime;
1907 abi_ulong target_st_ctime_nsec;
6db45e65
TS
1908
1909 unsigned long long st_ino;
1910};
1911
d2fd1af7 1912#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
5f992db6 1913#define TARGET_STAT_HAVE_NSEC
d2fd1af7
FB
1914struct target_stat {
1915 abi_ulong st_dev;
1916 abi_ulong st_ino;
1917 abi_ulong st_nlink;
1918
1919 unsigned int st_mode;
1920 unsigned int st_uid;
1921 unsigned int st_gid;
1922 unsigned int __pad0;
1923 abi_ulong st_rdev;
1924 abi_long st_size;
1925 abi_long st_blksize;
72e21db7 1926 abi_long st_blocks; /* Number 512-byte blocks allocated. */
d2fd1af7
FB
1927
1928 abi_ulong target_st_atime;
1929 abi_ulong target_st_atime_nsec;
1930 abi_ulong target_st_mtime;
1931 abi_ulong target_st_mtime_nsec;
1932 abi_ulong target_st_ctime;
1933 abi_ulong target_st_ctime_nsec;
1934
72e21db7 1935 abi_long __unused[3];
d2fd1af7 1936};
a4c075f1
UH
1937#elif defined(TARGET_S390X)
1938struct target_stat {
1939 abi_ulong st_dev;
1940 abi_ulong st_ino;
1941 abi_ulong st_nlink;
1942 unsigned int st_mode;
1943 unsigned int st_uid;
1944 unsigned int st_gid;
1945 unsigned int __pad1;
1946 abi_ulong st_rdev;
1947 abi_ulong st_size;
1948 abi_ulong target_st_atime;
1949 abi_ulong target_st_atime_nsec;
1950 abi_ulong target_st_mtime;
1951 abi_ulong target_st_mtime_nsec;
1952 abi_ulong target_st_ctime;
1953 abi_ulong target_st_ctime_nsec;
1954 abi_ulong st_blksize;
1955 abi_long st_blocks;
1956 abi_ulong __unused[3];
1957};
09701199 1958#elif defined(TARGET_AARCH64)
5f992db6 1959#define TARGET_STAT_HAVE_NSEC
09701199
AG
1960struct target_stat {
1961 abi_ulong st_dev;
1962 abi_ulong st_ino;
1963 unsigned int st_mode;
1964 unsigned int st_nlink;
1965 unsigned int st_uid;
1966 unsigned int st_gid;
1967 abi_ulong st_rdev;
1968 abi_ulong _pad1;
1969 abi_long st_size;
1970 int st_blksize;
1971 int __pad2;
1972 abi_long st_blocks;
1973 abi_long target_st_atime;
1974 abi_ulong target_st_atime_nsec;
1975 abi_long target_st_mtime;
1976 abi_ulong target_st_mtime_nsec;
1977 abi_long target_st_ctime;
1978 abi_ulong target_st_ctime_nsec;
1979 unsigned int __unused[2];
1980};
ba7651fb 1981#elif defined(TARGET_XTENSA)
5f992db6 1982#define TARGET_STAT_HAVE_NSEC
ba7651fb
MF
1983struct target_stat {
1984 abi_ulong st_dev;
1985 abi_ulong st_ino;
1986 unsigned int st_mode;
1987 unsigned int st_nlink;
1988 unsigned int st_uid;
1989 unsigned int st_gid;
1990 abi_ulong st_rdev;
1991 abi_long st_size;
1992 abi_ulong st_blksize;
1993 abi_ulong st_blocks;
1994 abi_ulong target_st_atime;
1995 abi_ulong target_st_atime_nsec;
1996 abi_ulong target_st_mtime;
1997 abi_ulong target_st_mtime_nsec;
1998 abi_ulong target_st_ctime;
1999 abi_ulong target_st_ctime_nsec;
2000 abi_ulong __unused4;
2001 abi_ulong __unused5;
2002};
2003
2004#define TARGET_HAS_STRUCT_STAT64
2005struct target_stat64 {
2006 uint64_t st_dev; /* Device */
2007 uint64_t st_ino; /* File serial number */
2008 unsigned int st_mode; /* File mode. */
2009 unsigned int st_nlink; /* Link count. */
2010 unsigned int st_uid; /* User ID of the file's owner. */
2011 unsigned int st_gid; /* Group ID of the file's group. */
2012 uint64_t st_rdev; /* Device number, if device. */
2013 int64_t st_size; /* Size of file, in bytes. */
2014 abi_ulong st_blksize; /* Optimal block size for I/O. */
2015 abi_ulong __unused2;
2016 uint64_t st_blocks; /* Number 512-byte blocks allocated. */
2017 abi_ulong target_st_atime; /* Time of last access. */
2018 abi_ulong target_st_atime_nsec;
2019 abi_ulong target_st_mtime; /* Time of last modification. */
2020 abi_ulong target_st_mtime_nsec;
2021 abi_ulong target_st_ctime; /* Time of last status change. */
2022 abi_ulong target_st_ctime_nsec;
2023 abi_ulong __unused4;
2024 abi_ulong __unused5;
2025};
2026
a0a839b6 2027#elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
47ae93cd 2028 defined(TARGET_NIOS2) || defined(TARGET_RISCV)
c7819dfb
PM
2029
2030/* These are the asm-generic versions of the stat and stat64 structures */
2031
5f992db6 2032#define TARGET_STAT_HAVE_NSEC
d962783e
JL
2033struct target_stat {
2034 abi_ulong st_dev;
2035 abi_ulong st_ino;
d962783e 2036 unsigned int st_mode;
c7819dfb 2037 unsigned int st_nlink;
d962783e
JL
2038 unsigned int st_uid;
2039 unsigned int st_gid;
d962783e 2040 abi_ulong st_rdev;
c7819dfb 2041 abi_ulong __pad1;
d962783e 2042 abi_long st_size;
c7819dfb
PM
2043 int st_blksize;
2044 int __pad2;
2045 abi_long st_blocks;
2046 abi_long target_st_atime;
d962783e 2047 abi_ulong target_st_atime_nsec;
c7819dfb 2048 abi_long target_st_mtime;
d962783e 2049 abi_ulong target_st_mtime_nsec;
c7819dfb 2050 abi_long target_st_ctime;
d962783e 2051 abi_ulong target_st_ctime_nsec;
c7819dfb
PM
2052 unsigned int __unused4;
2053 unsigned int __unused5;
2054};
d962783e 2055
47ae93cd 2056#if !defined(TARGET_RISCV64)
20d155bc 2057#define TARGET_HAS_STRUCT_STAT64
c7819dfb
PM
2058struct target_stat64 {
2059 uint64_t st_dev;
2060 uint64_t st_ino;
2061 unsigned int st_mode;
2062 unsigned int st_nlink;
2063 unsigned int st_uid;
2064 unsigned int st_gid;
2065 uint64_t st_rdev;
2066 uint64_t __pad1;
2067 int64_t st_size;
2068 int st_blksize;
2069 int __pad2;
2070 int64_t st_blocks;
2071 int target_st_atime;
2072 unsigned int target_st_atime_nsec;
2073 int target_st_mtime;
2074 unsigned int target_st_mtime_nsec;
2075 int target_st_ctime;
2076 unsigned int target_st_ctime_nsec;
2077 unsigned int __unused4;
2078 unsigned int __unused5;
d962783e 2079};
47ae93cd 2080#endif
c7819dfb 2081
a10d1e50
RH
2082#elif defined(TARGET_HPPA)
2083
5f992db6 2084#define TARGET_STAT_HAVE_NSEC
a10d1e50
RH
2085struct target_stat {
2086 abi_uint st_dev;
2087 abi_uint st_ino;
2088 abi_ushort st_mode;
2089 abi_ushort st_nlink;
2090 abi_ushort _res1;
2091 abi_ushort _res2;
2092 abi_uint st_rdev;
2093 abi_int st_size;
2094 abi_int target_st_atime;
2095 abi_uint target_st_atime_nsec;
2096 abi_int target_st_mtime;
2097 abi_uint target_st_mtime_nsec;
2098 abi_int target_st_ctime;
2099 abi_uint target_st_ctime_nsec;
2100 abi_int st_blksize;
2101 abi_int st_blocks;
2102 abi_uint _unused1;
2103 abi_uint _unused2;
2104 abi_uint _unused3;
2105 abi_uint _unused4;
2106 abi_ushort _unused5;
2107 abi_short st_fstype;
2108 abi_uint st_realdev;
2109 abi_ushort st_basemode;
2110 abi_ushort _unused6;
2111 abi_uint st_uid;
2112 abi_uint st_gid;
2113 abi_uint _unused7[3];
2114};
2115
2116#define TARGET_HAS_STRUCT_STAT64
2117struct target_stat64 {
2118 uint64_t st_dev;
2119 abi_uint _pad1;
2120 abi_uint _res1;
2121 abi_uint st_mode;
2122 abi_uint st_nlink;
2123 abi_uint st_uid;
2124 abi_uint st_gid;
2125 uint64_t st_rdev;
2126 abi_uint _pad2;
2127 int64_t st_size;
2128 abi_int st_blksize;
2129 int64_t st_blocks;
2130 abi_int target_st_atime;
2131 abi_uint target_st_atime_nsec;
2132 abi_int target_st_mtime;
2133 abi_uint target_st_mtime_nsec;
2134 abi_int target_st_ctime;
2135 abi_uint target_st_ctime_nsec;
2136 uint64_t st_ino;
2137};
2138
048f6b4d
FB
2139#else
2140#error unsupported CPU
2141#endif
2521d698 2142
4ce6f8de
TS
2143typedef struct {
2144 int val[2];
c227f099 2145} target_fsid_t;
4ce6f8de 2146
56c8f68f 2147#ifdef TARGET_MIPS
d26bc211 2148#ifdef TARGET_ABI_MIPSN32
540635ba
TS
2149struct target_statfs {
2150 int32_t f_type;
2151 int32_t f_bsize;
2152 int32_t f_frsize; /* Fragment size - unsupported */
2153 int32_t f_blocks;
2154 int32_t f_bfree;
2155 int32_t f_files;
2156 int32_t f_ffree;
2157 int32_t f_bavail;
2158
2159 /* Linux specials */
c227f099 2160 target_fsid_t f_fsid;
540635ba 2161 int32_t f_namelen;
d4247ec2
SL
2162 int32_t f_flags;
2163 int32_t f_spare[5];
540635ba
TS
2164};
2165#else
56c8f68f 2166struct target_statfs {
992f48a0
BS
2167 abi_long f_type;
2168 abi_long f_bsize;
2169 abi_long f_frsize; /* Fragment size - unsupported */
2170 abi_long f_blocks;
2171 abi_long f_bfree;
2172 abi_long f_files;
2173 abi_long f_ffree;
2174 abi_long f_bavail;
56c8f68f
FB
2175
2176 /* Linux specials */
c227f099 2177 target_fsid_t f_fsid;
992f48a0 2178 abi_long f_namelen;
d4247ec2
SL
2179 abi_long f_flags;
2180 abi_long f_spare[5];
56c8f68f 2181};
540635ba 2182#endif
56c8f68f
FB
2183
2184struct target_statfs64 {
2185 uint32_t f_type;
2186 uint32_t f_bsize;
2187 uint32_t f_frsize; /* Fragment size - unsupported */
2188 uint32_t __pad;
2189 uint64_t f_blocks;
2190 uint64_t f_bfree;
2191 uint64_t f_files;
2192 uint64_t f_ffree;
2193 uint64_t f_bavail;
c227f099 2194 target_fsid_t f_fsid;
56c8f68f 2195 uint32_t f_namelen;
d4247ec2
SL
2196 uint32_t f_flags;
2197 uint32_t f_spare[5];
56c8f68f 2198};
c4d10628 2199#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
47ae93cd
MC
2200 defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
2201 defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
325e651f
JM
2202struct target_statfs {
2203 abi_long f_type;
2204 abi_long f_bsize;
2205 abi_long f_blocks;
2206 abi_long f_bfree;
2207 abi_long f_bavail;
2208 abi_long f_files;
2209 abi_long f_ffree;
c227f099 2210 target_fsid_t f_fsid;
325e651f
JM
2211 abi_long f_namelen;
2212 abi_long f_frsize;
d4247ec2
SL
2213 abi_long f_flags;
2214 abi_long f_spare[4];
325e651f
JM
2215};
2216
2217struct target_statfs64 {
2218 abi_long f_type;
2219 abi_long f_bsize;
2220 abi_long f_blocks;
2221 abi_long f_bfree;
2222 abi_long f_bavail;
2223 abi_long f_files;
2224 abi_long f_ffree;
c227f099 2225 target_fsid_t f_fsid;
325e651f
JM
2226 abi_long f_namelen;
2227 abi_long f_frsize;
d4247ec2
SL
2228 abi_long f_flags;
2229 abi_long f_spare[4];
325e651f 2230};
a4c075f1
UH
2231#elif defined(TARGET_S390X)
2232struct target_statfs {
2233 int32_t f_type;
2234 int32_t f_bsize;
2235 abi_long f_blocks;
2236 abi_long f_bfree;
2237 abi_long f_bavail;
2238 abi_long f_files;
2239 abi_long f_ffree;
2240 kernel_fsid_t f_fsid;
2241 int32_t f_namelen;
2242 int32_t f_frsize;
d4247ec2
SL
2243 int32_t f_flags;
2244 int32_t f_spare[4];
2245
a4c075f1
UH
2246};
2247
2248struct target_statfs64 {
2249 int32_t f_type;
2250 int32_t f_bsize;
2251 abi_long f_blocks;
2252 abi_long f_bfree;
2253 abi_long f_bavail;
2254 abi_long f_files;
2255 abi_long f_ffree;
2256 kernel_fsid_t f_fsid;
2257 int32_t f_namelen;
2258 int32_t f_frsize;
d4247ec2
SL
2259 int32_t f_flags;
2260 int32_t f_spare[4];
a4c075f1 2261};
56c8f68f
FB
2262#else
2263struct target_statfs {
2264 uint32_t f_type;
2265 uint32_t f_bsize;
2266 uint32_t f_blocks;
2267 uint32_t f_bfree;
2268 uint32_t f_bavail;
2269 uint32_t f_files;
2270 uint32_t f_ffree;
c227f099 2271 target_fsid_t f_fsid;
56c8f68f
FB
2272 uint32_t f_namelen;
2273 uint32_t f_frsize;
d4247ec2
SL
2274 uint32_t f_flags;
2275 uint32_t f_spare[4];
56c8f68f
FB
2276};
2277
2278struct target_statfs64 {
2279 uint32_t f_type;
2280 uint32_t f_bsize;
2281 uint64_t f_blocks;
2282 uint64_t f_bfree;
2283 uint64_t f_bavail;
2284 uint64_t f_files;
2285 uint64_t f_ffree;
c227f099 2286 target_fsid_t f_fsid;
56c8f68f
FB
2287 uint32_t f_namelen;
2288 uint32_t f_frsize;
d4247ec2
SL
2289 uint32_t f_flags;
2290 uint32_t f_spare[4];
56c8f68f
FB
2291};
2292#endif
2293
7e22e546
UH
2294#define TARGET_F_LINUX_SPECIFIC_BASE 1024
2295#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
2296#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
2297#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
7e3b92ec
PM
2298#define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
2299#define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
7e22e546
UH
2300#define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
2301
5de7706e 2302#include "target_fcntl.h"
8d5d3004 2303
2521d698 2304/* soundcard defines */
67cc32eb 2305/* XXX: convert them all to arch independent entries */
2521d698
FB
2306#define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
2307#define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
2308#define TARGET_SNDCTL_COPR_RCODE 0xc0144303
2309#define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
2310#define TARGET_SNDCTL_COPR_RDATA 0xc0144302
2311#define TARGET_SNDCTL_COPR_RESET 0x00004300
2312#define TARGET_SNDCTL_COPR_RUN 0xc0144306
2313#define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
2314#define TARGET_SNDCTL_COPR_WCODE 0x40144305
2315#define TARGET_SNDCTL_COPR_WDATA 0x40144304
2316#define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
2317#define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
2318#define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
2319#define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
2320#define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
2321#define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
2322#define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
2323#define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
2324#define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
2325#define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
2326#define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
2327#define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
2328#define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
2329#define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
2330#define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
2331#define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
2332#define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
2333#define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
5f72307d
PM
2334#define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
2335#define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
2521d698
FB
2336#define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
2337#define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
2338#define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
2339#define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
2340#define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
2341#define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
2342#define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
2343#define TARGET_SNDCTL_MIDI_INFO 0xc074510c
2344#define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
2345#define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
2346#define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
2347#define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
2348#define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
2349#define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
2350#define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
2351#define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
2352#define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
2353#define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
2354#define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
2355#define TARGET_SNDCTL_SEQ_PANIC 0x00005111
2356#define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
2357#define TARGET_SNDCTL_SEQ_RESET 0x00005100
2358#define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
2359#define TARGET_SNDCTL_SEQ_SYNC 0x00005101
2360#define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
2361#define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
2362#define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
2363#define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
2364#define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
2365#define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
2366#define TARGET_SNDCTL_TMR_METRONOME 0x40045407
2367#define TARGET_SNDCTL_TMR_SELECT 0x40045408
2368#define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
2369#define TARGET_SNDCTL_TMR_START 0x00005402
2370#define TARGET_SNDCTL_TMR_STOP 0x00005403
2371#define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
2372#define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
2373#define TARGET_SOUND_PCM_READ_RATE 0x80045002
2374#define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
2375#define TARGET_SOUND_PCM_READ_BITS 0x80045005
2376#define TARGET_SOUND_PCM_READ_FILTER 0x80045007
2377#define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
2378#define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
2379#define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
2380#define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
2381#define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
2382#define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
2383#define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
2384
2385#define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
2386
2387#define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
2388#define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
2389#define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
2390#define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
2391#define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
2392#define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
2393#define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
2394#define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
2395#define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
2396#define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
2397#define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
2398#define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
2399#define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
2400#define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
2401#define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
2402#define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
2403#define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
2404
2405/* Obsolete macros */
2406#define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
2407#define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
2408#define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
2409
2410#define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
2411#define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
2412#define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
2413#define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
2414#define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
2415
2416#define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
2417
2418#define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
2419#define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
2420#define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
2421#define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
2422#define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
2423#define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
2424#define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
2425#define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
2426#define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
2427#define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
2428#define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
2429#define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
2430#define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
2431#define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
2432#define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
2433#define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
2434#define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
2435
2436/* Obsolete macros */
2437#define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
2438#define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
2439#define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
2440
2441#define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
2442
aca7708e
FB
2443struct target_snd_timer_id {
2444 int dev_class;
2445 int dev_sclass;
2446 int card;
2447 int device;
2448 int subdevice;
2449};
2450
2451struct target_snd_timer_ginfo {
2452 struct target_snd_timer_id tid;
2453 unsigned int flags;
2454 int card;
2455 unsigned char id[64];
2456 unsigned char name[80];
2457 abi_ulong reserved0;
2458 abi_ulong resolution;
2459 abi_ulong resolution_min;
2460 abi_ulong resolution_max;
2461 unsigned int clients;
2462 unsigned char reserved[32];
2463};
2464
2465struct target_snd_timer_gparams {
2466 struct target_snd_timer_id tid;
2467 abi_ulong period_num;
2468 abi_ulong period_den;
2469 unsigned char reserved[32];
2470};
2471
2472struct target_snd_timer_gstatus {
2473 struct target_snd_timer_id tid;
2474 abi_ulong resolution;
2475 abi_ulong resolution_num;
2476 abi_ulong resolution_den;
2477 unsigned char reserved[32];
2478};
2479
d22edf0a
FB
2480struct target_snd_timer_select {
2481 struct target_snd_timer_id id;
2482 unsigned char reserved[32];
2483};
2484
fe333025
FB
2485struct target_snd_timer_info {
2486 unsigned int flags;
2487 int card;
2488 unsigned char id[64];
2489 unsigned char name[80];
2490 abi_ulong reserved0;
2491 abi_ulong resolution;
2492 unsigned char reserved[64];
2493};
2494
2495struct target_snd_timer_status {
2496 struct target_timespec tstamp;
2497 unsigned int resolution;
2498 unsigned int lost;
2499 unsigned int overrun;
2500 unsigned int queue;
2501 unsigned char reserved[64];
2502};
2503
1c4c6fcd
FB
2504/* alsa timer ioctls */
2505#define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int)
2506#define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \
2507 struct snd_timer_id)
aca7708e
FB
2508#define TARGET_SNDRV_TIMER_IOCTL_GINFO TARGET_IOWR('T', 0x03, \
2509 struct target_snd_timer_ginfo)
2510#define TARGET_SNDRV_TIMER_IOCTL_GPARAMS TARGET_IOW('T', 0x04, \
2511 struct target_snd_timer_gparams)
2512#define TARGET_SNDRV_TIMER_IOCTL_GSTATUS TARGET_IOWR('T', 0x05, \
2513 struct target_snd_timer_gstatus)
d22edf0a
FB
2514#define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10, \
2515 struct target_snd_timer_select)
fe333025
FB
2516#define TARGET_SNDRV_TIMER_IOCTL_INFO TARGET_IOR('T', 0x11, \
2517 struct target_snd_timer_info)
2518#define TARGET_SNDRV_TIMER_IOCTL_PARAMS TARGET_IOW('T', 0x12, \
2519 struct snd_timer_params)
2520#define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14, \
2521 struct target_snd_timer_status)
045823a9
FB
2522#define TARGET_SNDRV_TIMER_IOCTL_START TARGET_IO('T', 0xa0)
2523#define TARGET_SNDRV_TIMER_IOCTL_STOP TARGET_IO('T', 0xa1)
2524#define TARGET_SNDRV_TIMER_IOCTL_CONTINUE TARGET_IO('T', 0xa2)
2525#define TARGET_SNDRV_TIMER_IOCTL_PAUSE TARGET_IO('T', 0xa3)
1c4c6fcd 2526
2521d698
FB
2527/* vfat ioctls */
2528#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
2529#define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
a5448a7d 2530
f443e396
PM
2531struct target_mtop {
2532 abi_short mt_op;
2533 abi_int mt_count;
2534};
2535
2536#if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2537typedef abi_long target_kernel_daddr_t;
2538#else
2539typedef abi_int target_kernel_daddr_t;
2540#endif
2541
2542struct target_mtget {
2543 abi_long mt_type;
2544 abi_long mt_resid;
2545 abi_long mt_dsreg;
2546 abi_long mt_gstat;
2547 abi_long mt_erreg;
2548 target_kernel_daddr_t mt_fileno;
2549 target_kernel_daddr_t mt_blkno;
2550};
2551
2552struct target_mtpos {
2553 abi_long mt_blkno;
2554};
2555
2556#define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct target_mtop)
2557#define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget)
2558#define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos)
8fbd6b52 2559
bd27e675
AM
2560/* kcov ioctls */
2561#define TARGET_KCOV_ENABLE TARGET_IO('c', 100)
2562#define TARGET_KCOV_DISABLE TARGET_IO('c', 101)
f7dbd8fe 2563#define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
bd27e675 2564
a5448a7d 2565struct target_sysinfo {
992f48a0
BS
2566 abi_long uptime; /* Seconds since boot */
2567 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
2568 abi_ulong totalram; /* Total usable main memory size */
2569 abi_ulong freeram; /* Available memory size */
2570 abi_ulong sharedram; /* Amount of shared memory */
2571 abi_ulong bufferram; /* Memory used by buffers */
2572 abi_ulong totalswap; /* Total swap space size */
2573 abi_ulong freeswap; /* swap space still available */
a5448a7d
FB
2574 unsigned short procs; /* Number of current processes */
2575 unsigned short pad; /* explicit padding for m68k */
992f48a0
BS
2576 abi_ulong totalhigh; /* Total high memory size */
2577 abi_ulong freehigh; /* Available high memory size */
a5448a7d 2578 unsigned int mem_unit; /* Memory unit size in bytes */
992f48a0 2579 char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
a5448a7d 2580};
3532fa74 2581
6556a833
AJ
2582struct linux_dirent {
2583 long d_ino;
2584 unsigned long d_off;
2585 unsigned short d_reclen;
2586 char d_name[256]; /* We must not include limits.h! */
2587};
2588
2589struct linux_dirent64 {
2590 uint64_t d_ino;
2591 int64_t d_off;
2592 unsigned short d_reclen;
2593 unsigned char d_type;
2594 char d_name[256];
2595};
2596
24e1003a
AJ
2597struct target_mq_attr {
2598 abi_long mq_flags;
2599 abi_long mq_maxmsg;
2600 abi_long mq_msgsize;
2601 abi_long mq_curmsgs;
2602};
2603
e865b97f
CG
2604struct target_drm_version {
2605 int version_major;
2606 int version_minor;
2607 int version_patchlevel;
2608 abi_ulong name_len;
2609 abi_ulong name;
2610 abi_ulong date_len;
2611 abi_ulong date;
2612 abi_ulong desc_len;
2613 abi_ulong desc;
2614};
2615
3532fa74 2616#include "socket.h"
637947f1
TS
2617
2618#include "errno_defs.h"
03dfe9f8
RV
2619
2620#define FUTEX_WAIT 0
2621#define FUTEX_WAKE 1
2622#define FUTEX_FD 2
2623#define FUTEX_REQUEUE 3
2624#define FUTEX_CMP_REQUEUE 4
2625#define FUTEX_WAKE_OP 5
2626#define FUTEX_LOCK_PI 6
2627#define FUTEX_UNLOCK_PI 7
2628#define FUTEX_TRYLOCK_PI 8
2629#define FUTEX_WAIT_BITSET 9
2630#define FUTEX_WAKE_BITSET 10
2631
2632#define FUTEX_PRIVATE_FLAG 128
2633#define FUTEX_CLOCK_REALTIME 256
2634#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2635
3b6edd16 2636#ifdef CONFIG_EPOLL
928bed6a
LV
2637#if defined(TARGET_X86_64)
2638#define TARGET_EPOLL_PACKED QEMU_PACKED
2639#else
2640#define TARGET_EPOLL_PACKED
2641#endif
2642
3b6edd16
PM
2643typedef union target_epoll_data {
2644 abi_ulong ptr;
928bed6a
LV
2645 abi_int fd;
2646 abi_uint u32;
2647 abi_ullong u64;
3b6edd16
PM
2648} target_epoll_data_t;
2649
2650struct target_epoll_event {
928bed6a 2651 abi_uint events;
3b6edd16 2652 target_epoll_data_t data;
928bed6a 2653} TARGET_EPOLL_PACKED;
2ba7fae3
PM
2654
2655#define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
2656
3b6edd16 2657#endif
163a05a8
PM
2658struct target_rlimit64 {
2659 uint64_t rlim_cur;
2660 uint64_t rlim_max;
2661};
583359a6
AP
2662
2663struct target_ucred {
2664 uint32_t pid;
2665 uint32_t uid;
2666 uint32_t gid;
2667};
cb9c377f 2668
aecc8861 2669typedef int32_t target_timer_t;
905bba13 2670
34d60862
NC
2671#define TARGET_SIGEV_MAX_SIZE 64
2672
2673/* This is architecture-specific but most architectures use the default */
2674#ifdef TARGET_MIPS
2675#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
2676#else
2677#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
2678 + sizeof(target_sigval_t))
2679#endif
2680
2681#define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
2682 - TARGET_SIGEV_PREAMBLE_SIZE) \
2683 / sizeof(int32_t))
2684
905bba13
ECL
2685struct target_sigevent {
2686 target_sigval_t sigev_value;
17351c3f
PM
2687 abi_int sigev_signo;
2688 abi_int sigev_notify;
905bba13 2689 union {
17351c3f
PM
2690 abi_int _pad[TARGET_SIGEV_PAD_SIZE];
2691 abi_int _tid;
905bba13 2692
17351c3f
PM
2693 /* The kernel (and thus QEMU) never looks at these;
2694 * they're only used as part of the ABI between a
2695 * userspace program and libc.
2696 */
905bba13 2697 struct {
17351c3f
PM
2698 abi_ulong _function;
2699 abi_ulong _attribute;
905bba13
ECL
2700 } _sigev_thread;
2701 } _sigev_un;
2702};
e0eb210e
PM
2703
2704struct target_user_cap_header {
2705 uint32_t version;
2706 int pid;
2707};
2708
2709struct target_user_cap_data {
2710 uint32_t effective;
2711 uint32_t permitted;
2712 uint32_t inheritable;
2713};
1b3c4fdf 2714
da2c8ad7
AM
2715/* from kernel's include/linux/syslog.h */
2716
2717/* Close the log. Currently a NOP. */
2718#define TARGET_SYSLOG_ACTION_CLOSE 0
2719/* Open the log. Currently a NOP. */
2720#define TARGET_SYSLOG_ACTION_OPEN 1
2721/* Read from the log. */
2722#define TARGET_SYSLOG_ACTION_READ 2
2723/* Read all messages remaining in the ring buffer. */
2724#define TARGET_SYSLOG_ACTION_READ_ALL 3
2725/* Read and clear all messages remaining in the ring buffer */
2726#define TARGET_SYSLOG_ACTION_READ_CLEAR 4
2727/* Clear ring buffer. */
2728#define TARGET_SYSLOG_ACTION_CLEAR 5
2729/* Disable printk's to console */
2730#define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6
2731/* Enable printk's to console */
2732#define TARGET_SYSLOG_ACTION_CONSOLE_ON 7
2733/* Set level of messages printed to console */
2734#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8
2735/* Return number of unread characters in the log buffer */
2736#define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9
2737/* Return size of the log buffer */
2738#define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10
2739
efa92184
AR
2740struct target_statx_timestamp {
2741 int64_t tv_sec;
2742 uint32_t tv_nsec;
2743 int32_t __reserved;
2744};
2745
2746struct target_statx {
2747 /* 0x00 */
2748 uint32_t stx_mask; /* What results were written [uncond] */
2749 uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
2750 uint64_t stx_attributes; /* Flags conveying information about the file */
2751 /* 0x10 */
2752 uint32_t stx_nlink; /* Number of hard links */
2753 uint32_t stx_uid; /* User ID of owner */
2754 uint32_t stx_gid; /* Group ID of owner */
2755 uint16_t stx_mode; /* File mode */
2756 uint16_t __spare0[1];
2757 /* 0x20 */
2758 uint64_t stx_ino; /* Inode number */
2759 uint64_t stx_size; /* File size */
2760 uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
2761 uint64_t stx_attributes_mask; /* Mask to show what is supported */
2762 /* 0x40 */
2763 struct target_statx_timestamp stx_atime; /* Last access time */
2764 struct target_statx_timestamp stx_btime; /* File creation time */
2765 struct target_statx_timestamp stx_ctime; /* Last attribute change time */
2766 struct target_statx_timestamp stx_mtime; /* Last data modification time */
2767 /* 0x80 */
2768 uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
2769 uint32_t stx_rdev_minor;
2770 uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2771 uint32_t stx_dev_minor;
2772 /* 0x90 */
2773 uint64_t __spare2[14]; /* Spare space for future expansion */
2774 /* 0x100 */
2775};
2776
1b3c4fdf 2777#endif