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