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