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