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