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