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