xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 4eeea4f3f12a85ef955ac162c81a153a020cf9d7)
131e31b8aSbellard /* common syscall defines for all architectures */
231e31b8aSbellard 
32521d698Sbellard /* Note: although the syscall numbers change between architectures,
4b4916d7bSDong Xu Wang    most of them stay the same, so we handle it by putting ifdefs if
52521d698Sbellard    necessary */
62521d698Sbellard 
76180a181Sbellard #include "syscall_nr.h"
82521d698Sbellard 
931e31b8aSbellard #define SOCKOP_socket           1
1031e31b8aSbellard #define SOCKOP_bind             2
1131e31b8aSbellard #define SOCKOP_connect          3
1231e31b8aSbellard #define SOCKOP_listen           4
1331e31b8aSbellard #define SOCKOP_accept           5
1431e31b8aSbellard #define SOCKOP_getsockname      6
1531e31b8aSbellard #define SOCKOP_getpeername      7
1631e31b8aSbellard #define SOCKOP_socketpair       8
1731e31b8aSbellard #define SOCKOP_send             9
1831e31b8aSbellard #define SOCKOP_recv             10
1931e31b8aSbellard #define SOCKOP_sendto           11
2031e31b8aSbellard #define SOCKOP_recvfrom         12
2131e31b8aSbellard #define SOCKOP_shutdown         13
2231e31b8aSbellard #define SOCKOP_setsockopt       14
2331e31b8aSbellard #define SOCKOP_getsockopt       15
2431e31b8aSbellard #define SOCKOP_sendmsg          16
2531e31b8aSbellard #define SOCKOP_recvmsg          17
2631e31b8aSbellard 
278853f86eSbellard #define IPCOP_semop		1
288853f86eSbellard #define IPCOP_semget		2
298853f86eSbellard #define IPCOP_semctl		3
308853f86eSbellard #define IPCOP_semtimedop	4
318853f86eSbellard #define IPCOP_msgsnd		11
328853f86eSbellard #define IPCOP_msgrcv		12
338853f86eSbellard #define IPCOP_msgget		13
348853f86eSbellard #define IPCOP_msgctl		14
358853f86eSbellard #define IPCOP_shmat		21
368853f86eSbellard #define IPCOP_shmdt		22
378853f86eSbellard #define IPCOP_shmget		23
388853f86eSbellard #define IPCOP_shmctl		24
398853f86eSbellard 
402521d698Sbellard /*
412521d698Sbellard  * The following is for compatibility across the various Linux
422521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
432521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
442521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
452521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
462521d698Sbellard  * below from now on.
472521d698Sbellard  */
482521d698Sbellard #define TARGET_IOC_NRBITS	8
492521d698Sbellard #define TARGET_IOC_TYPEBITS	8
502521d698Sbellard 
5174d753acSMika Westerberg #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
520c866a7eSRiku Voipio     || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
5374d753acSMika Westerberg     /* 16 bit uid wrappers emulation */
5474d753acSMika Westerberg #define USE_UID16
550c866a7eSRiku Voipio #define target_id uint16_t
560c866a7eSRiku Voipio #else
570c866a7eSRiku Voipio #define target_id uint32_t
5874d753acSMika Westerberg #endif
5974d753acSMika Westerberg 
60e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
61a4c075f1SUlrich Hecht     || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \
62d962783eSJia Liu     || defined(TARGET_S390X) || defined(TARGET_OPENRISC)
632521d698Sbellard 
642521d698Sbellard #define TARGET_IOC_SIZEBITS	14
652521d698Sbellard #define TARGET_IOC_DIRBITS	2
662521d698Sbellard 
672521d698Sbellard #define TARGET_IOC_NONE	  0U
682521d698Sbellard #define TARGET_IOC_WRITE  1U
692521d698Sbellard #define TARGET_IOC_READ	  2U
702521d698Sbellard 
71048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
72b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
73b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
742521d698Sbellard 
752521d698Sbellard #define TARGET_IOC_SIZEBITS	13
762521d698Sbellard #define TARGET_IOC_DIRBITS	3
772521d698Sbellard 
782521d698Sbellard #define TARGET_IOC_NONE	  1U
792521d698Sbellard #define TARGET_IOC_READ	  2U
802521d698Sbellard #define TARGET_IOC_WRITE  4U
812521d698Sbellard 
822521d698Sbellard #else
832521d698Sbellard #error unsupported CPU
842521d698Sbellard #endif
852521d698Sbellard 
862521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
872521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
882521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
892521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
902521d698Sbellard 
912521d698Sbellard #define TARGET_IOC_NRSHIFT	0
922521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
932521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
942521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
952521d698Sbellard 
962521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
972521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
982521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
992521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1002521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1012521d698Sbellard 
1022521d698Sbellard /* used to create numbers */
1032521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1042521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1052521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1062521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1072521d698Sbellard 
1082521d698Sbellard /* the size is automatically computed for these defines */
1092521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1102521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1112521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1122521d698Sbellard 
1137854b056Sbellard struct target_sockaddr {
1147854b056Sbellard     uint16_t sa_family;
1157854b056Sbellard     uint8_t sa_data[14];
1167854b056Sbellard };
1177854b056Sbellard 
118b975b83bSLionel Landwerlin struct target_in_addr {
119b975b83bSLionel Landwerlin     uint32_t s_addr; /* big endian */
120b975b83bSLionel Landwerlin };
121b975b83bSLionel Landwerlin 
122b975b83bSLionel Landwerlin struct target_ip_mreq {
123b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
124b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
125b975b83bSLionel Landwerlin };
126b975b83bSLionel Landwerlin 
127b975b83bSLionel Landwerlin struct target_ip_mreqn {
128b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
129b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
130b975b83bSLionel Landwerlin     abi_long imr_ifindex;
131b975b83bSLionel Landwerlin };
132b975b83bSLionel Landwerlin 
1336e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
1346e3cb58fSLionel Landwerlin     /* big endian */
1356e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
1366e3cb58fSLionel Landwerlin     uint32_t imr_interface;
1376e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
1386e3cb58fSLionel Landwerlin };
1396e3cb58fSLionel Landwerlin 
14031e31b8aSbellard struct target_timeval {
141992f48a0Sblueswir1     abi_long tv_sec;
142992f48a0Sblueswir1     abi_long tv_usec;
14331e31b8aSbellard };
14431e31b8aSbellard 
1451b6b029eSbellard struct target_timespec {
146992f48a0Sblueswir1     abi_long tv_sec;
147992f48a0Sblueswir1     abi_long tv_nsec;
1481b6b029eSbellard };
1491b6b029eSbellard 
15066fb9763Sbellard struct target_itimerval {
15166fb9763Sbellard     struct target_timeval it_interval;
15266fb9763Sbellard     struct target_timeval it_value;
15366fb9763Sbellard };
15466fb9763Sbellard 
155c227f099SAnthony Liguori typedef abi_long target_clock_t;
15632f36bceSbellard 
157c596ed17Sbellard #define TARGET_HZ 100
158c596ed17Sbellard 
15932f36bceSbellard struct target_tms {
160c227f099SAnthony Liguori     target_clock_t tms_utime;
161c227f099SAnthony Liguori     target_clock_t tms_stime;
162c227f099SAnthony Liguori     target_clock_t tms_cutime;
163c227f099SAnthony Liguori     target_clock_t tms_cstime;
16432f36bceSbellard };
16532f36bceSbellard 
1666180a181Sbellard struct target_utimbuf {
167992f48a0Sblueswir1     abi_long actime;
168992f48a0Sblueswir1     abi_long modtime;
1696180a181Sbellard };
1706180a181Sbellard 
171f2674e31Sbellard struct target_sel_arg_struct {
172992f48a0Sblueswir1     abi_long n;
173992f48a0Sblueswir1     abi_long inp, outp, exp;
174992f48a0Sblueswir1     abi_long tvp;
175f2674e31Sbellard };
176f2674e31Sbellard 
17731e31b8aSbellard struct target_iovec {
178992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
179992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
18031e31b8aSbellard };
18131e31b8aSbellard 
1821a9353d2Sbellard struct target_msghdr {
183992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
1841a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
185992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
186992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
187992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
188992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
1891a9353d2Sbellard     unsigned int msg_flags;
1901a9353d2Sbellard };
1911a9353d2Sbellard 
1927854b056Sbellard struct target_cmsghdr {
193992f48a0Sblueswir1     abi_long     cmsg_len;
1947854b056Sbellard     int          cmsg_level;
1957854b056Sbellard     int          cmsg_type;
1967854b056Sbellard };
1977854b056Sbellard 
1987854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
1997854b056Sbellard #define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
200992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
201992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
2027854b056Sbellard #define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
2037854b056Sbellard                                + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
2047854b056Sbellard #define TARGET_CMSG_LEN(len)   (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
2057854b056Sbellard 
2067854b056Sbellard static __inline__ struct target_cmsghdr *
2077854b056Sbellard __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
2087854b056Sbellard {
2092b8bdefcSths   struct target_cmsghdr *__ptr;
2107854b056Sbellard 
2112b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
212cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
213cbb21eedSMatthias Braun   if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control))
214cbb21eedSMatthias Braun       > tswapal(__mhdr->msg_controllen))
2157854b056Sbellard     /* No more entries.  */
2162b8bdefcSths     return (struct target_cmsghdr *)0;
2177854b056Sbellard   return __cmsg;
2187854b056Sbellard }
2197854b056Sbellard 
2207854b056Sbellard 
22131e31b8aSbellard struct  target_rusage {
22231e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
22331e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
224992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
225992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
226992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
227992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
228992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
229992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
230992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
231992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
232992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
233992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
234992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
235992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
236992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
237992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
23831e31b8aSbellard };
23931e31b8aSbellard 
24031e31b8aSbellard typedef struct {
24131e31b8aSbellard         int     val[2];
242c227f099SAnthony Liguori } kernel_fsid_t;
24331e31b8aSbellard 
24472f03900Sbellard struct kernel_statfs {
24531e31b8aSbellard 	int f_type;
24631e31b8aSbellard 	int f_bsize;
24731e31b8aSbellard 	int f_blocks;
24831e31b8aSbellard 	int f_bfree;
24931e31b8aSbellard 	int f_bavail;
25031e31b8aSbellard 	int f_files;
25131e31b8aSbellard 	int f_ffree;
252c227f099SAnthony Liguori         kernel_fsid_t f_fsid;
25331e31b8aSbellard 	int f_namelen;
25431e31b8aSbellard 	int f_spare[6];
25531e31b8aSbellard };
25631e31b8aSbellard 
257dab2ed99Sbellard struct target_dirent {
258992f48a0Sblueswir1 	abi_long	d_ino;
259992f48a0Sblueswir1 	abi_long	d_off;
260dab2ed99Sbellard 	unsigned short	d_reclen;
261dab2ed99Sbellard 	char		d_name[256]; /* We must not include limits.h! */
262dab2ed99Sbellard };
263dab2ed99Sbellard 
264dab2ed99Sbellard struct target_dirent64 {
265dab2ed99Sbellard 	uint64_t	d_ino;
266dab2ed99Sbellard 	int64_t		d_off;
267dab2ed99Sbellard 	unsigned short	d_reclen;
268dab2ed99Sbellard 	unsigned char	d_type;
269dab2ed99Sbellard 	char		d_name[256];
270dab2ed99Sbellard };
271dab2ed99Sbellard 
272dab2ed99Sbellard 
27331e31b8aSbellard /* mostly generic signal stuff */
274992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
275992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
276992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
27731e31b8aSbellard 
27831e31b8aSbellard #ifdef TARGET_MIPS
27931e31b8aSbellard #define TARGET_NSIG	   128
28031e31b8aSbellard #else
28131e31b8aSbellard #define TARGET_NSIG	   64
28231e31b8aSbellard #endif
283992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
28431e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
28531e31b8aSbellard 
28631e31b8aSbellard typedef struct {
287992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
288c227f099SAnthony Liguori } target_sigset_t;
28931e31b8aSbellard 
29066fb9763Sbellard #ifdef BSWAP_NEEDED
291c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
29266fb9763Sbellard {
29366fb9763Sbellard     int i;
29466fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
295cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
29666fb9763Sbellard }
29766fb9763Sbellard #else
298c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
29966fb9763Sbellard {
30066fb9763Sbellard     *d = *s;
30166fb9763Sbellard }
30266fb9763Sbellard #endif
30366fb9763Sbellard 
304c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
30566fb9763Sbellard {
30666fb9763Sbellard     int i;
30766fb9763Sbellard     d->sig[0] = set;
30866fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
30966fb9763Sbellard         d->sig[i] = 0;
31066fb9763Sbellard }
31166fb9763Sbellard 
312c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
313c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
314992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
31566fb9763Sbellard                                const sigset_t *sigset);
31666fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
317992f48a0Sblueswir1                                const abi_ulong *old_sigset);
31866fb9763Sbellard struct target_sigaction;
31966fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
32066fb9763Sbellard                  struct target_sigaction *oact);
32166fb9763Sbellard 
322d2fbca94SGuan Xuetao #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
323d2fbca94SGuan Xuetao     || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
324d2fbca94SGuan Xuetao     || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
325a4c075f1SUlrich Hecht     || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
326d962783eSJia Liu     || defined(TARGET_S390X) || defined(TARGET_OPENRISC)
3272521d698Sbellard 
328048f6b4dSbellard #if defined(TARGET_SPARC)
329048f6b4dSbellard #define TARGET_SA_NOCLDSTOP    8u
330048f6b4dSbellard #define TARGET_SA_NOCLDWAIT    0x100u
331048f6b4dSbellard #define TARGET_SA_SIGINFO      0x200u
332048f6b4dSbellard #define TARGET_SA_ONSTACK      1u
333048f6b4dSbellard #define TARGET_SA_RESTART      2u
334048f6b4dSbellard #define TARGET_SA_NODEFER      0x20u
335048f6b4dSbellard #define TARGET_SA_RESETHAND    4u
336048f6b4dSbellard #elif defined(TARGET_MIPS)
337048f6b4dSbellard #define TARGET_SA_NOCLDSTOP	0x00000001
338048f6b4dSbellard #define TARGET_SA_NOCLDWAIT	0x00010000
339048f6b4dSbellard #define TARGET_SA_SIGINFO	0x00000008
340048f6b4dSbellard #define TARGET_SA_ONSTACK	0x08000000
341048f6b4dSbellard #define TARGET_SA_NODEFER	0x40000000
342048f6b4dSbellard #define TARGET_SA_RESTART	0x10000000
343048f6b4dSbellard #define TARGET_SA_RESETHAND	0x80000000
344d26bc211Sths #if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
345d26bc211Sths #define TARGET_SA_RESTORER	0x04000000	/* Only for O32 */
346540635baSths #endif
347d962783eSJia Liu #elif defined(TARGET_OPENRISC)
348d962783eSJia Liu #define TARGET_SA_NOCLDSTOP    0x00000001
349d962783eSJia Liu #define TARGET_SA_NOCLDWAIT    0x00000002
350d962783eSJia Liu #define TARGET_SA_SIGINFO      0x00000004
351d962783eSJia Liu #define TARGET_SA_ONSTACK      0x08000000
352d962783eSJia Liu #define TARGET_SA_RESTART      0x10000000
353d962783eSJia Liu #define TARGET_SA_NODEFER      0x40000000
354d962783eSJia Liu #define TARGET_SA_RESETHAND    0x80000000
35557f18a95SRichard Henderson #elif defined(TARGET_ALPHA)
35657f18a95SRichard Henderson #define TARGET_SA_ONSTACK	0x00000001
35757f18a95SRichard Henderson #define TARGET_SA_RESTART	0x00000002
35857f18a95SRichard Henderson #define TARGET_SA_NOCLDSTOP	0x00000004
35957f18a95SRichard Henderson #define TARGET_SA_NODEFER	0x00000008
36057f18a95SRichard Henderson #define TARGET_SA_RESETHAND	0x00000010
36157f18a95SRichard Henderson #define TARGET_SA_NOCLDWAIT	0x00000020 /* not supported yet */
36257f18a95SRichard Henderson #define TARGET_SA_SIGINFO	0x00000040
363048f6b4dSbellard #else
3642521d698Sbellard #define TARGET_SA_NOCLDSTOP	0x00000001
3652521d698Sbellard #define TARGET_SA_NOCLDWAIT	0x00000002 /* not supported yet */
3662521d698Sbellard #define TARGET_SA_SIGINFO	0x00000004
3672521d698Sbellard #define TARGET_SA_ONSTACK	0x08000000
3682521d698Sbellard #define TARGET_SA_RESTART	0x10000000
3692521d698Sbellard #define TARGET_SA_NODEFER	0x40000000
3702521d698Sbellard #define TARGET_SA_RESETHAND	0x80000000
3712521d698Sbellard #define TARGET_SA_RESTORER	0x04000000
3726d5e216dSbellard #endif
3736d5e216dSbellard 
374d0f20495SRichard Henderson #if defined(TARGET_ALPHA)
375d0f20495SRichard Henderson 
376d0f20495SRichard Henderson #define TARGET_SIGHUP            1
377d0f20495SRichard Henderson #define TARGET_SIGINT            2
378d0f20495SRichard Henderson #define TARGET_SIGQUIT           3
379d0f20495SRichard Henderson #define TARGET_SIGILL            4
380d0f20495SRichard Henderson #define TARGET_SIGTRAP           5
381d0f20495SRichard Henderson #define TARGET_SIGABRT           6
382d0f20495SRichard Henderson #define TARGET_SIGSTKFLT         7 /* actually SIGEMT */
383d0f20495SRichard Henderson #define TARGET_SIGFPE            8
384d0f20495SRichard Henderson #define TARGET_SIGKILL           9
385d0f20495SRichard Henderson #define TARGET_SIGBUS           10
386d0f20495SRichard Henderson #define TARGET_SIGSEGV          11
387d0f20495SRichard Henderson #define TARGET_SIGSYS           12
388d0f20495SRichard Henderson #define TARGET_SIGPIPE          13
389d0f20495SRichard Henderson #define TARGET_SIGALRM          14
390d0f20495SRichard Henderson #define TARGET_SIGTERM          15
391d0f20495SRichard Henderson #define TARGET_SIGURG           16
392d0f20495SRichard Henderson #define TARGET_SIGSTOP          17
393d0f20495SRichard Henderson #define TARGET_SIGTSTP          18
394d0f20495SRichard Henderson #define TARGET_SIGCONT          19
395d0f20495SRichard Henderson #define TARGET_SIGCHLD          20
396d0f20495SRichard Henderson #define TARGET_SIGTTIN          21
397d0f20495SRichard Henderson #define TARGET_SIGTTOU          22
398d0f20495SRichard Henderson #define TARGET_SIGIO            23
399d0f20495SRichard Henderson #define TARGET_SIGXCPU          24
400d0f20495SRichard Henderson #define TARGET_SIGXFSZ          25
401d0f20495SRichard Henderson #define TARGET_SIGVTALRM        26
402d0f20495SRichard Henderson #define TARGET_SIGPROF          27
403d0f20495SRichard Henderson #define TARGET_SIGWINCH         28
404d0f20495SRichard Henderson #define TARGET_SIGPWR           29 /* actually SIGINFO */
405d0f20495SRichard Henderson #define TARGET_SIGUSR1          30
406d0f20495SRichard Henderson #define TARGET_SIGUSR2          31
407d0f20495SRichard Henderson #define TARGET_SIGRTMIN         32
408d0f20495SRichard Henderson 
409d0f20495SRichard Henderson #define TARGET_SIG_BLOCK         1
410d0f20495SRichard Henderson #define TARGET_SIG_UNBLOCK       2
411d0f20495SRichard Henderson #define TARGET_SIG_SETMASK       3
412d0f20495SRichard Henderson 
413d0f20495SRichard Henderson #elif defined(TARGET_SPARC)
4146d5e216dSbellard 
4156d5e216dSbellard #define TARGET_SIGHUP		 1
4166d5e216dSbellard #define TARGET_SIGINT		 2
4176d5e216dSbellard #define TARGET_SIGQUIT		 3
4186d5e216dSbellard #define TARGET_SIGILL		 4
4196d5e216dSbellard #define TARGET_SIGTRAP		 5
4206d5e216dSbellard #define TARGET_SIGABRT		 6
4216d5e216dSbellard #define TARGET_SIGIOT		 6
4226d5e216dSbellard #define TARGET_SIGSTKFLT	 7 /* actually EMT */
4236d5e216dSbellard #define TARGET_SIGFPE		 8
4246d5e216dSbellard #define TARGET_SIGKILL		 9
4256d5e216dSbellard #define TARGET_SIGBUS		10
4266d5e216dSbellard #define TARGET_SIGSEGV		11
4276d5e216dSbellard #define TARGET_SIGSYS		12
4286d5e216dSbellard #define TARGET_SIGPIPE		13
4296d5e216dSbellard #define TARGET_SIGALRM		14
4306d5e216dSbellard #define TARGET_SIGTERM		15
4316d5e216dSbellard #define TARGET_SIGURG		16
4326d5e216dSbellard #define TARGET_SIGSTOP		17
4336d5e216dSbellard #define TARGET_SIGTSTP		18
4346d5e216dSbellard #define TARGET_SIGCONT		19
4356d5e216dSbellard #define TARGET_SIGCHLD		20
4366d5e216dSbellard #define TARGET_SIGTTIN		21
4376d5e216dSbellard #define TARGET_SIGTTOU		22
4386d5e216dSbellard #define TARGET_SIGIO		23
4396d5e216dSbellard #define TARGET_SIGXCPU		24
4406d5e216dSbellard #define TARGET_SIGXFSZ		25
4416d5e216dSbellard #define TARGET_SIGVTALRM	26
4426d5e216dSbellard #define TARGET_SIGPROF		27
4436d5e216dSbellard #define TARGET_SIGWINCH	        28
4446d5e216dSbellard #define TARGET_SIGPWR		29
4456d5e216dSbellard #define TARGET_SIGUSR1		30
4466d5e216dSbellard #define TARGET_SIGUSR2		31
4476d5e216dSbellard #define TARGET_SIGRTMIN         32
4486d5e216dSbellard 
4496d5e216dSbellard #define TARGET_SIG_BLOCK          0x01 /* for blocking signals */
4506d5e216dSbellard #define TARGET_SIG_UNBLOCK        0x02 /* for unblocking signals */
4516d5e216dSbellard #define TARGET_SIG_SETMASK        0x04 /* for setting the signal mask */
4526d5e216dSbellard 
453048f6b4dSbellard #elif defined(TARGET_MIPS)
454048f6b4dSbellard 
455048f6b4dSbellard #define TARGET_SIGHUP		 1	/* Hangup (POSIX).  */
456048f6b4dSbellard #define TARGET_SIGINT		 2	/* Interrupt (ANSI).  */
457048f6b4dSbellard #define TARGET_SIGQUIT		 3	/* Quit (POSIX).  */
458048f6b4dSbellard #define TARGET_SIGILL		 4	/* Illegal instruction (ANSI).  */
459048f6b4dSbellard #define TARGET_SIGTRAP		 5	/* Trace trap (POSIX).  */
460048f6b4dSbellard #define TARGET_SIGIOT		 6	/* IOT trap (4.2 BSD).  */
461048f6b4dSbellard #define TARGET_SIGABRT		 TARGET_SIGIOT	/* Abort (ANSI).  */
462048f6b4dSbellard #define TARGET_SIGEMT		 7
463048f6b4dSbellard #define TARGET_SIGSTKFLT	 7 /* XXX: incorrect */
464048f6b4dSbellard #define TARGET_SIGFPE		 8	/* Floating-point exception (ANSI).  */
465048f6b4dSbellard #define TARGET_SIGKILL		 9	/* Kill, unblockable (POSIX).  */
466048f6b4dSbellard #define TARGET_SIGBUS		10	/* BUS error (4.2 BSD).  */
467048f6b4dSbellard #define TARGET_SIGSEGV		11	/* Segmentation violation (ANSI).  */
468048f6b4dSbellard #define TARGET_SIGSYS		12
469048f6b4dSbellard #define TARGET_SIGPIPE		13	/* Broken pipe (POSIX).  */
470048f6b4dSbellard #define TARGET_SIGALRM		14	/* Alarm clock (POSIX).  */
471048f6b4dSbellard #define TARGET_SIGTERM		15	/* Termination (ANSI).  */
472048f6b4dSbellard #define TARGET_SIGUSR1		16	/* User-defined signal 1 (POSIX).  */
473048f6b4dSbellard #define TARGET_SIGUSR2		17	/* User-defined signal 2 (POSIX).  */
474048f6b4dSbellard #define TARGET_SIGCHLD		18	/* Child status has changed (POSIX).  */
475048f6b4dSbellard #define TARGET_SIGCLD		TARGET_SIGCHLD	/* Same as TARGET_SIGCHLD (System V).  */
476048f6b4dSbellard #define TARGET_SIGPWR		19	/* Power failure restart (System V).  */
477048f6b4dSbellard #define TARGET_SIGWINCH	20	/* Window size change (4.3 BSD, Sun).  */
478048f6b4dSbellard #define TARGET_SIGURG		21	/* Urgent condition on socket (4.2 BSD).  */
479048f6b4dSbellard #define TARGET_SIGIO		22	/* I/O now possible (4.2 BSD).  */
480048f6b4dSbellard #define TARGET_SIGPOLL		TARGET_SIGIO	/* Pollable event occurred (System V).  */
481048f6b4dSbellard #define TARGET_SIGSTOP		23	/* Stop, unblockable (POSIX).  */
482048f6b4dSbellard #define TARGET_SIGTSTP		24	/* Keyboard stop (POSIX).  */
483048f6b4dSbellard #define TARGET_SIGCONT		25	/* Continue (POSIX).  */
484048f6b4dSbellard #define TARGET_SIGTTIN		26	/* Background read from tty (POSIX).  */
485048f6b4dSbellard #define TARGET_SIGTTOU		27	/* Background write to tty (POSIX).  */
486048f6b4dSbellard #define TARGET_SIGVTALRM	28	/* Virtual alarm clock (4.2 BSD).  */
487048f6b4dSbellard #define TARGET_SIGPROF		29	/* Profiling alarm clock (4.2 BSD).  */
488048f6b4dSbellard #define TARGET_SIGXCPU		30	/* CPU limit exceeded (4.2 BSD).  */
489048f6b4dSbellard #define TARGET_SIGXFSZ		31	/* File size limit exceeded (4.2 BSD).  */
490048f6b4dSbellard #define TARGET_SIGRTMIN         32
491048f6b4dSbellard 
492048f6b4dSbellard #define TARGET_SIG_BLOCK	1	/* for blocking signals */
493048f6b4dSbellard #define TARGET_SIG_UNBLOCK	2	/* for unblocking signals */
494048f6b4dSbellard #define TARGET_SIG_SETMASK	3	/* for setting the signal mask */
495048f6b4dSbellard 
4966d5e216dSbellard #else
4972521d698Sbellard 
498d962783eSJia Liu /* OpenRISC Using the general signals */
4992521d698Sbellard #define TARGET_SIGHUP		 1
5002521d698Sbellard #define TARGET_SIGINT		 2
5012521d698Sbellard #define TARGET_SIGQUIT		 3
5022521d698Sbellard #define TARGET_SIGILL		 4
5032521d698Sbellard #define TARGET_SIGTRAP		 5
5042521d698Sbellard #define TARGET_SIGABRT		 6
5052521d698Sbellard #define TARGET_SIGIOT		 6
5062521d698Sbellard #define TARGET_SIGBUS		 7
5072521d698Sbellard #define TARGET_SIGFPE		 8
5082521d698Sbellard #define TARGET_SIGKILL		 9
5092521d698Sbellard #define TARGET_SIGUSR1		10
5102521d698Sbellard #define TARGET_SIGSEGV		11
5112521d698Sbellard #define TARGET_SIGUSR2		12
5122521d698Sbellard #define TARGET_SIGPIPE		13
5132521d698Sbellard #define TARGET_SIGALRM		14
5142521d698Sbellard #define TARGET_SIGTERM		15
5152521d698Sbellard #define TARGET_SIGSTKFLT	16
5162521d698Sbellard #define TARGET_SIGCHLD		17
5172521d698Sbellard #define TARGET_SIGCONT		18
5182521d698Sbellard #define TARGET_SIGSTOP		19
5192521d698Sbellard #define TARGET_SIGTSTP		20
5202521d698Sbellard #define TARGET_SIGTTIN		21
5212521d698Sbellard #define TARGET_SIGTTOU		22
5222521d698Sbellard #define TARGET_SIGURG		23
5232521d698Sbellard #define TARGET_SIGXCPU		24
5242521d698Sbellard #define TARGET_SIGXFSZ		25
5252521d698Sbellard #define TARGET_SIGVTALRM	26
5262521d698Sbellard #define TARGET_SIGPROF		27
5272521d698Sbellard #define TARGET_SIGWINCH	        28
5282521d698Sbellard #define TARGET_SIGIO		29
529c596ed17Sbellard #define TARGET_SIGPWR		30
530c596ed17Sbellard #define TARGET_SIGSYS		31
5312521d698Sbellard #define TARGET_SIGRTMIN         32
5322521d698Sbellard 
5332521d698Sbellard #define TARGET_SIG_BLOCK          0    /* for blocking signals */
5342521d698Sbellard #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
5352521d698Sbellard #define TARGET_SIG_SETMASK        2    /* for setting the signal mask */
5362521d698Sbellard 
5376d5e216dSbellard #endif
5386d5e216dSbellard 
5396049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
5406049f4f8SRichard Henderson struct target_old_sigaction {
5416049f4f8SRichard Henderson     abi_ulong _sa_handler;
5426049f4f8SRichard Henderson     abi_ulong sa_mask;
5436049f4f8SRichard Henderson     abi_ulong sa_flags;
5446049f4f8SRichard Henderson };
545106ec879Sbellard 
5466049f4f8SRichard Henderson struct target_rt_sigaction {
5476049f4f8SRichard Henderson     abi_ulong _sa_handler;
5486049f4f8SRichard Henderson     abi_ulong sa_flags;
5496049f4f8SRichard Henderson     target_sigset_t sa_mask;
5506049f4f8SRichard Henderson };
5516049f4f8SRichard Henderson 
5526049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
5536049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
5546049f4f8SRichard Henderson struct target_sigaction {
5556049f4f8SRichard Henderson     abi_ulong _sa_handler;
5566049f4f8SRichard Henderson     abi_ulong sa_flags;
5576049f4f8SRichard Henderson     target_sigset_t sa_mask;
5586049f4f8SRichard Henderson     abi_ulong sa_restorer;
5596049f4f8SRichard Henderson };
5606049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
561106ec879Sbellard struct target_sigaction {
562540635baSths 	uint32_t	sa_flags;
563d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
564540635baSths 	uint32_t	_sa_handler;
565540635baSths #else
566992f48a0Sblueswir1 	abi_ulong	_sa_handler;
567540635baSths #endif
568c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
569106ec879Sbellard };
570106ec879Sbellard #else
5712521d698Sbellard struct target_old_sigaction {
572992f48a0Sblueswir1         abi_ulong _sa_handler;
573992f48a0Sblueswir1         abi_ulong sa_mask;
574992f48a0Sblueswir1         abi_ulong sa_flags;
575992f48a0Sblueswir1         abi_ulong sa_restorer;
5762521d698Sbellard };
5772521d698Sbellard 
5782521d698Sbellard struct target_sigaction {
579992f48a0Sblueswir1         abi_ulong _sa_handler;
580992f48a0Sblueswir1         abi_ulong sa_flags;
581992f48a0Sblueswir1         abi_ulong sa_restorer;
582c227f099SAnthony Liguori         target_sigset_t sa_mask;
5832521d698Sbellard };
584106ec879Sbellard #endif
5852521d698Sbellard 
5862521d698Sbellard typedef union target_sigval {
5872521d698Sbellard 	int sival_int;
588992f48a0Sblueswir1         abi_ulong sival_ptr;
589c227f099SAnthony Liguori } target_sigval_t;
5906d5e216dSbellard #if 0
5916d5e216dSbellard #if defined (TARGET_SPARC)
5926d5e216dSbellard typedef struct {
5936d5e216dSbellard 	struct {
594992f48a0Sblueswir1 		abi_ulong psr;
595992f48a0Sblueswir1 		abi_ulong pc;
596992f48a0Sblueswir1 		abi_ulong npc;
597992f48a0Sblueswir1 		abi_ulong y;
598992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5996d5e216dSbellard 	}		si_regs;
6006d5e216dSbellard 	int		si_mask;
6016d5e216dSbellard } __siginfo_t;
6026d5e216dSbellard 
6036d5e216dSbellard typedef struct {
6046d5e216dSbellard 	unsigned   long si_float_regs [32];
6056d5e216dSbellard 	unsigned   long si_fsr;
6066d5e216dSbellard 	unsigned   long si_fpqdepth;
6076d5e216dSbellard 	struct {
6086d5e216dSbellard 		unsigned long *insn_addr;
6096d5e216dSbellard 		unsigned long insn;
6106d5e216dSbellard 	} si_fpqueue [16];
6116d5e216dSbellard } __siginfo_fpu_t;
6126d5e216dSbellard #endif
6136d5e216dSbellard #endif
6142521d698Sbellard 
6152521d698Sbellard #define TARGET_SI_MAX_SIZE	128
6162521d698Sbellard #define TARGET_SI_PAD_SIZE	((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
6172521d698Sbellard 
6182521d698Sbellard typedef struct target_siginfo {
6193f53d546Spbrook #ifdef TARGET_MIPS
6203f53d546Spbrook 	int si_signo;
6213f53d546Spbrook 	int si_code;
6223f53d546Spbrook 	int si_errno;
6233f53d546Spbrook #else
6242521d698Sbellard 	int si_signo;
6252521d698Sbellard 	int si_errno;
6262521d698Sbellard 	int si_code;
6273f53d546Spbrook #endif
6282521d698Sbellard 
6292521d698Sbellard 	union {
6302521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
6312521d698Sbellard 
6322521d698Sbellard 		/* kill() */
6332521d698Sbellard 		struct {
6342521d698Sbellard 			pid_t _pid;		/* sender's pid */
6352521d698Sbellard 			uid_t _uid;		/* sender's uid */
6362521d698Sbellard 		} _kill;
6372521d698Sbellard 
6382521d698Sbellard 		/* POSIX.1b timers */
6392521d698Sbellard 		struct {
6402521d698Sbellard 			unsigned int _timer1;
6412521d698Sbellard 			unsigned int _timer2;
6422521d698Sbellard 		} _timer;
6432521d698Sbellard 
6442521d698Sbellard 		/* POSIX.1b signals */
6452521d698Sbellard 		struct {
6462521d698Sbellard 			pid_t _pid;		/* sender's pid */
6472521d698Sbellard 			uid_t _uid;		/* sender's uid */
648c227f099SAnthony Liguori 			target_sigval_t _sigval;
6492521d698Sbellard 		} _rt;
6502521d698Sbellard 
6512521d698Sbellard 		/* SIGCHLD */
6522521d698Sbellard 		struct {
6532521d698Sbellard 			pid_t _pid;		/* which child */
6542521d698Sbellard 			uid_t _uid;		/* sender's uid */
6552521d698Sbellard 			int _status;		/* exit code */
656c227f099SAnthony Liguori 			target_clock_t _utime;
657c227f099SAnthony Liguori                         target_clock_t _stime;
6582521d698Sbellard 		} _sigchld;
6592521d698Sbellard 
6602521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
6612521d698Sbellard 		struct {
662992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
6632521d698Sbellard 		} _sigfault;
6642521d698Sbellard 
6652521d698Sbellard 		/* SIGPOLL */
6662521d698Sbellard 		struct {
6672521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
6682521d698Sbellard 			int _fd;
6692521d698Sbellard 		} _sigpoll;
6702521d698Sbellard 	} _sifields;
671c227f099SAnthony Liguori } target_siginfo_t;
6722521d698Sbellard 
6732521d698Sbellard /*
6742521d698Sbellard  * si_code values
6752521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6762521d698Sbellard  */
6772521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6782521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6792521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6802521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6812521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6822521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6832521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6842521d698Sbellard 
6852521d698Sbellard /*
6862521d698Sbellard  * SIGILL si_codes
6872521d698Sbellard  */
688ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6892521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
690ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
691ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
692ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
693ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
694ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
695ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
6962521d698Sbellard 
6972521d698Sbellard /*
6982521d698Sbellard  * SIGFPE si_codes
6992521d698Sbellard  */
7002521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
7012521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
7022521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
7032521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
7042521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
7052521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
7062521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
7072521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
7082521d698Sbellard #define TARGET_NSIGFPE         8
7092521d698Sbellard 
7102521d698Sbellard /*
7112521d698Sbellard  * SIGSEGV si_codes
7122521d698Sbellard  */
7132521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
7142521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
7152521d698Sbellard 
7162521d698Sbellard /*
717ffa65c3bSbellard  * SIGBUS si_codes
718ffa65c3bSbellard  */
719ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
720b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
721ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
722ffa65c3bSbellard 
723ffa65c3bSbellard /*
7242521d698Sbellard  * SIGTRAP si_codes
7252521d698Sbellard  */
7262521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
7272521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
7282521d698Sbellard 
7292521d698Sbellard #endif /* defined(TARGET_I386) || defined(TARGET_ARM) */
7302521d698Sbellard 
7319de5e440Sbellard struct target_rlimit {
732992f48a0Sblueswir1         abi_ulong   rlim_cur;
733992f48a0Sblueswir1         abi_ulong   rlim_max;
7349de5e440Sbellard };
7359de5e440Sbellard 
73681bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
737e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
7386cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
73981bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
74081bbe906Stakasi-y@ops.dti.ne.jp #else
74126b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
74281bbe906Stakasi-y@ops.dti.ne.jp #endif
74381bbe906Stakasi-y@ops.dti.ne.jp 
744e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
745e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
746e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
747e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
748e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
749e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
750e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
751e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
752e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
753e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
754e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
755e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
756e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
757e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
758e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
759e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
760e22b7015SWesley W. Terpstra #else
761e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
762e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
763e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
764e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
765e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
766e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7676cafd027SMatthias Braun #if defined(TARGET_SPARC)
7686cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7696cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7706cafd027SMatthias Braun #else
771e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
772e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7736cafd027SMatthias Braun #endif
774e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
775e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
776e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
777e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
778e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
779e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
780e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
781e22b7015SWesley W. Terpstra #endif
782e22b7015SWesley W. Terpstra 
7839de5e440Sbellard struct target_pollfd {
7849de5e440Sbellard     int fd;           /* file descriptor */
7859de5e440Sbellard     short events;     /* requested events */
7869de5e440Sbellard     short revents;    /* returned events */
7879de5e440Sbellard };
7889de5e440Sbellard 
7898e5a0667Sbellard /* virtual terminal ioctls */
7900221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7910221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7928e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
793f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
794f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
795f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7960221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7970221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
798e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
799e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
800e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
801e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
8028e5a0667Sbellard 
8032521d698Sbellard #define TARGET_SIOCATMARK      0x8905
8042521d698Sbellard 
80531e31b8aSbellard /* Networking ioctls */
80631e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
80731e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
80831e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
80931e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
81031e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
81131e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
81231e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
81331e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
81431e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
81531e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
81631e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
81731e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
81831e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
81931e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
82031e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
82131e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
82231e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
82331e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
82431e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
82531e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
82631e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
82731e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
82831e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
82931e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
83031e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
83131e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
83231e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
83331e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
83431e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
83531e31b8aSbellard 
83631e31b8aSbellard /* Bridging control calls */
83731e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
83831e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
83931e31b8aSbellard 
84031e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
84131e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
84231e31b8aSbellard 
84331e31b8aSbellard /* ARP cache control calls. */
84431e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
84531e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
84631e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
84731e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
84831e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
84931e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
85031e31b8aSbellard 
85131e31b8aSbellard /* RARP cache control calls. */
85231e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
85331e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
85431e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
85531e31b8aSbellard 
85631e31b8aSbellard /* Driver configuration calls */
85731e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
85831e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
85931e31b8aSbellard 
86031e31b8aSbellard /* DLCI configuration calls */
86131e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
86231e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
86331e31b8aSbellard 
86486fcd946SLaurent Vivier /* From <linux/wireless.h> */
86586fcd946SLaurent Vivier 
86686fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
86731e31b8aSbellard 
86831e31b8aSbellard /* From <linux/fs.h> */
86931e31b8aSbellard 
87031e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
87131e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
87231e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
87331e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
87431e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
87531e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
87631e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
87731e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
87831e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
87931e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
88031e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
88131e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
88231e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
883edafea13SAlexander Graf #define TARGET_BLKBSZGET  TARGET_IOR(0x12,112,int)
884edafea13SAlexander Graf #define TARGET_BLKBSZSET  TARGET_IOW(0x12,113,int)
885edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
886edafea13SAlexander Graf                                              /* return device size in bytes
887edafea13SAlexander Graf                                                 (u64 *arg) */
88831e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
88931e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
890285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
89131e31b8aSbellard 
89231e31b8aSbellard /* cdrom commands */
89331e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
89431e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
89531e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
89631e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
89731e31b8aSbellard                                            (struct cdrom_ti) */
89831e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
89931e31b8aSbellard                                            (struct cdrom_tochdr) */
90031e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
90131e31b8aSbellard                                            (struct cdrom_tocentry) */
90231e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
90331e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
90431e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
90531e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
90631e31b8aSbellard                                            (struct cdrom_volctrl) */
90731e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
90831e31b8aSbellard                                            (struct cdrom_subchnl) */
90931e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
91031e31b8aSbellard                                            (struct cdrom_read) */
91131e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
91231e31b8aSbellard                                            (struct cdrom_read) */
91331e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
91431e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
91531e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
91631e31b8aSbellard                                            address of multi session disks
91731e31b8aSbellard                                            (struct cdrom_multisession) */
91831e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
91931e31b8aSbellard                                            if available (struct cdrom_mcn) */
92031e31b8aSbellard #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is depricated,
921b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
92231e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
92331e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
92431e31b8aSbellard                                           (struct cdrom_volctrl) */
92531e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
92631e31b8aSbellard                                            (struct cdrom_read) */
92731e31b8aSbellard /*
92831e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
92931e31b8aSbellard  */
93031e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
93131e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
93231e31b8aSbellard 
93331e31b8aSbellard /*
93431e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
93531e31b8aSbellard    It is for playing audio in logical block addressing mode.
93631e31b8aSbellard  */
93731e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
93831e31b8aSbellard 
93931e31b8aSbellard /*
94031e31b8aSbellard  * These ioctls are only used in optcd.c
94131e31b8aSbellard  */
94231e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
94331e31b8aSbellard 
94431e31b8aSbellard /*
94531e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
94631e31b8aSbellard  * drive spindown time.  They should be implemented in the
94731e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
94831e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
94931e31b8aSbellard  *  -Erik
95031e31b8aSbellard  */
95131e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
95231e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
95331e31b8aSbellard 
95431e31b8aSbellard /*
95531e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
95631e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
95731e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
95831e31b8aSbellard  */
95931e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
96031e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
96131e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
96231e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
96331e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
96431e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
96531e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
96631e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
96731e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
96831e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
96931e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
97031e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
97131e31b8aSbellard 
97231e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
97331e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
97431e31b8aSbellard  */
97531e31b8aSbellard 
97631e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
97731e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
97831e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
97931e31b8aSbellard 
98031e31b8aSbellard /* DVD-ROM Specific ioctls */
98131e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
98231e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
98331e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
98431e31b8aSbellard 
98531e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
98631e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
98731e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
98831e31b8aSbellard 
98931e31b8aSbellard /* HD commands */
99031e31b8aSbellard 
99131e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
99231e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
99331e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
99431e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
99531e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
99631e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
99731e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
99831e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
9992521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
100031e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
100131e31b8aSbellard 
100231e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
100331e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
100431e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
100531e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
100631e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
100731e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
100831e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
100931e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
10102521d698Sbellard 
1011b8005914Sbalrog /* loop ioctls */
1012b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1013b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1014b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1015b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1016b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1017b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1018b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
10192521d698Sbellard 
1020f7680a55SUlrich Hecht /* fb ioctls */
1021f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1022f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1023f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
102412b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
102512b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
102612b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
102712b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
102812b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1029f7680a55SUlrich Hecht 
1030f7680a55SUlrich Hecht /* vt ioctls */
1031f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1032f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1033f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1034f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1035f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1036f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1037774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1038774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1039774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1040774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1041f7680a55SUlrich Hecht 
104256e904ecSAlexander Graf /* device mapper */
104356e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
104456e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
104556e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
104656e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
104756e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
104856e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
104956e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
105056e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
105156e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
105256e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
105356e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
105456e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
105556e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
105656e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
105756e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
105856e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
105956e904ecSAlexander Graf 
10602521d698Sbellard /* from asm/termbits.h */
10612521d698Sbellard 
10623bfd9da1Sbellard #define TARGET_NCC 8
10633bfd9da1Sbellard struct target_termio {
10643bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
10653bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
10663bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
10673bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
10682521d698Sbellard 	unsigned char c_line;		/* line discipline */
10693bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
10702521d698Sbellard };
10712521d698Sbellard 
10723bfd9da1Sbellard struct target_winsize {
10733bfd9da1Sbellard 	unsigned short ws_row;
10743bfd9da1Sbellard 	unsigned short ws_col;
10753bfd9da1Sbellard 	unsigned short ws_xpixel;
10763bfd9da1Sbellard 	unsigned short ws_ypixel;
10773bfd9da1Sbellard };
10782521d698Sbellard 
10793bfd9da1Sbellard #include "termbits.h"
10802521d698Sbellard 
10819e0b74a4SPaul Brook #if defined(TARGET_MIPS)
10829e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
10839e0b74a4SPaul Brook #else
10849e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
10859e0b74a4SPaul Brook #endif
10869e0b74a4SPaul Brook 
1087e44a3e79Saurel32 /* Common */
10882521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
10892521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
10902521d698Sbellard #define TARGET_MAP_TYPE		0x0f		/* Mask for type of mapping */
1091e44a3e79Saurel32 
1092e44a3e79Saurel32 /* Target specific */
1093048f6b4dSbellard #if defined(TARGET_MIPS)
1094e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1095048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1096048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1097048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1098048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1099048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1100048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1101540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1102540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1103e44a3e79Saurel32 #elif defined(TARGET_PPC)
1104e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
11052521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
11062521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
11072521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
11082521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
11097ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
11107ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1111e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1112e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1113e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1114e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1115e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1116e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1117e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1118e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1119e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1120e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1121e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1122e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
11237ec93196Sj_mayer #else
1124e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1125e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1126e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1127e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1128e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
11292521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
11302521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1131540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1132540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1133906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
11347ec93196Sj_mayer #endif
11352521d698Sbellard 
1136d2fbca94SGuan Xuetao #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) \
1137d962783eSJia Liu     || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \
1138d962783eSJia Liu     || defined(TARGET_OPENRISC)
11392521d698Sbellard struct target_stat {
11402521d698Sbellard 	unsigned short st_dev;
11412521d698Sbellard 	unsigned short __pad1;
1142992f48a0Sblueswir1 	abi_ulong st_ino;
11432521d698Sbellard 	unsigned short st_mode;
11442521d698Sbellard 	unsigned short st_nlink;
11452521d698Sbellard 	unsigned short st_uid;
11462521d698Sbellard 	unsigned short st_gid;
11472521d698Sbellard 	unsigned short st_rdev;
11482521d698Sbellard 	unsigned short __pad2;
1149992f48a0Sblueswir1 	abi_ulong  st_size;
1150992f48a0Sblueswir1 	abi_ulong  st_blksize;
1151992f48a0Sblueswir1 	abi_ulong  st_blocks;
1152992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1153992f48a0Sblueswir1 	abi_ulong  __unused1;
1154992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1155992f48a0Sblueswir1 	abi_ulong  __unused2;
1156992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1157992f48a0Sblueswir1 	abi_ulong  __unused3;
1158992f48a0Sblueswir1 	abi_ulong  __unused4;
1159992f48a0Sblueswir1 	abi_ulong  __unused5;
11602521d698Sbellard };
11612521d698Sbellard 
11622521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
11632521d698Sbellard  * insane amounts of padding around dev_t's.
11642521d698Sbellard  */
11652521d698Sbellard struct target_stat64 {
11662521d698Sbellard 	unsigned short	st_dev;
11672521d698Sbellard 	unsigned char	__pad0[10];
11682521d698Sbellard 
11692521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1170992f48a0Sblueswir1 	abi_ulong	__st_ino;
11712521d698Sbellard 
11722521d698Sbellard 	unsigned int	st_mode;
11732521d698Sbellard 	unsigned int	st_nlink;
11742521d698Sbellard 
1175992f48a0Sblueswir1 	abi_ulong	st_uid;
1176992f48a0Sblueswir1 	abi_ulong	st_gid;
11772521d698Sbellard 
11782521d698Sbellard 	unsigned short	st_rdev;
11792521d698Sbellard 	unsigned char	__pad3[10];
11802521d698Sbellard 
11812521d698Sbellard 	long long	st_size;
1182992f48a0Sblueswir1 	abi_ulong	st_blksize;
11832521d698Sbellard 
1184992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1185992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
11862521d698Sbellard 
1187992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1188992f48a0Sblueswir1 	abi_ulong	__pad5;
11892521d698Sbellard 
1190992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1191992f48a0Sblueswir1 	abi_ulong	__pad6;
11922521d698Sbellard 
1193992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1194992f48a0Sblueswir1 	abi_ulong	__pad7;		/* will be high 32 bits of ctime someday */
11952521d698Sbellard 
11962521d698Sbellard 	unsigned long long	st_ino;
1197541dc0d4SStefan Weil } QEMU_PACKED;
11982521d698Sbellard 
1199ce4defa0Spbrook #ifdef TARGET_ARM
1200ce4defa0Spbrook struct target_eabi_stat64 {
1201ce4defa0Spbrook         unsigned long long st_dev;
1202ce4defa0Spbrook         unsigned int    __pad1;
1203992f48a0Sblueswir1         abi_ulong    __st_ino;
1204ce4defa0Spbrook         unsigned int    st_mode;
1205ce4defa0Spbrook         unsigned int    st_nlink;
1206ce4defa0Spbrook 
1207992f48a0Sblueswir1         abi_ulong    st_uid;
1208992f48a0Sblueswir1         abi_ulong    st_gid;
1209ce4defa0Spbrook 
1210ce4defa0Spbrook         unsigned long long st_rdev;
1211ce4defa0Spbrook         unsigned int    __pad2[2];
1212ce4defa0Spbrook 
1213ce4defa0Spbrook         long long       st_size;
1214992f48a0Sblueswir1         abi_ulong    st_blksize;
1215ce4defa0Spbrook         unsigned int    __pad3;
1216ce4defa0Spbrook         unsigned long long st_blocks;
1217ce4defa0Spbrook 
1218992f48a0Sblueswir1         abi_ulong    target_st_atime;
1219992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1220ce4defa0Spbrook 
1221992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1222992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1223ce4defa0Spbrook 
1224992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1225992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1226ce4defa0Spbrook 
1227ce4defa0Spbrook         unsigned long long st_ino;
1228541dc0d4SStefan Weil } QEMU_PACKED;
1229ce4defa0Spbrook #endif
1230ce4defa0Spbrook 
1231992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
12321b8dd648Sblueswir1 struct target_stat {
12331b8dd648Sblueswir1 	unsigned int	st_dev;
1234992f48a0Sblueswir1 	abi_ulong	st_ino;
12351b8dd648Sblueswir1 	unsigned int	st_mode;
12361b8dd648Sblueswir1 	unsigned int	st_nlink;
12371b8dd648Sblueswir1 	unsigned int	st_uid;
12381b8dd648Sblueswir1 	unsigned int	st_gid;
12391b8dd648Sblueswir1 	unsigned int	st_rdev;
1240992f48a0Sblueswir1 	abi_long	st_size;
1241992f48a0Sblueswir1 	abi_long	target_st_atime;
1242992f48a0Sblueswir1 	abi_long	target_st_mtime;
1243992f48a0Sblueswir1 	abi_long	target_st_ctime;
1244992f48a0Sblueswir1 	abi_long	st_blksize;
1245992f48a0Sblueswir1 	abi_long	st_blocks;
1246992f48a0Sblueswir1 	abi_ulong	__unused4[2];
12471b8dd648Sblueswir1 };
12481b8dd648Sblueswir1 
12491b8dd648Sblueswir1 struct target_stat64 {
12501b8dd648Sblueswir1 	unsigned char	__pad0[6];
12511b8dd648Sblueswir1 	unsigned short	st_dev;
12521b8dd648Sblueswir1 
12531b8dd648Sblueswir1 	uint64_t	st_ino;
12541b8dd648Sblueswir1 	uint64_t	st_nlink;
12551b8dd648Sblueswir1 
12561b8dd648Sblueswir1 	unsigned int	st_mode;
12571b8dd648Sblueswir1 
12581b8dd648Sblueswir1 	unsigned int	st_uid;
12591b8dd648Sblueswir1 	unsigned int	st_gid;
12601b8dd648Sblueswir1 
12611b8dd648Sblueswir1 	unsigned char	__pad2[6];
12621b8dd648Sblueswir1 	unsigned short	st_rdev;
12631b8dd648Sblueswir1 
12641b8dd648Sblueswir1         int64_t		st_size;
12651b8dd648Sblueswir1 	int64_t		st_blksize;
12661b8dd648Sblueswir1 
12671b8dd648Sblueswir1 	unsigned char	__pad4[4];
12681b8dd648Sblueswir1 	unsigned int	st_blocks;
12691b8dd648Sblueswir1 
1270992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1271992f48a0Sblueswir1 	abi_ulong	__unused1;
12721b8dd648Sblueswir1 
1273992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1274992f48a0Sblueswir1 	abi_ulong	__unused2;
12751b8dd648Sblueswir1 
1276992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1277992f48a0Sblueswir1 	abi_ulong	__unused3;
12781b8dd648Sblueswir1 
1279992f48a0Sblueswir1 	abi_ulong	__unused4[3];
12801b8dd648Sblueswir1 };
12811b8dd648Sblueswir1 
12823bfd9da1Sbellard #elif defined(TARGET_SPARC)
12833bfd9da1Sbellard 
12843bfd9da1Sbellard struct target_stat {
12853bfd9da1Sbellard 	unsigned short	st_dev;
1286992f48a0Sblueswir1 	abi_ulong	st_ino;
12873bfd9da1Sbellard 	unsigned short	st_mode;
12883bfd9da1Sbellard 	short		st_nlink;
12893bfd9da1Sbellard 	unsigned short	st_uid;
12903bfd9da1Sbellard 	unsigned short	st_gid;
12913bfd9da1Sbellard 	unsigned short	st_rdev;
1292992f48a0Sblueswir1 	abi_long	st_size;
1293992f48a0Sblueswir1 	abi_long	target_st_atime;
1294992f48a0Sblueswir1 	abi_ulong	__unused1;
1295992f48a0Sblueswir1 	abi_long	target_st_mtime;
1296992f48a0Sblueswir1 	abi_ulong	__unused2;
1297992f48a0Sblueswir1 	abi_long	target_st_ctime;
1298992f48a0Sblueswir1 	abi_ulong	__unused3;
1299992f48a0Sblueswir1 	abi_long	st_blksize;
1300992f48a0Sblueswir1 	abi_long	st_blocks;
1301992f48a0Sblueswir1 	abi_ulong	__unused4[2];
13023bfd9da1Sbellard };
13033bfd9da1Sbellard 
13043bfd9da1Sbellard struct target_stat64 {
13053bfd9da1Sbellard 	unsigned char	__pad0[6];
13063bfd9da1Sbellard 	unsigned short	st_dev;
13073bfd9da1Sbellard 
13083bfd9da1Sbellard 	uint64_t st_ino;
13093bfd9da1Sbellard 
13103bfd9da1Sbellard 	unsigned int	st_mode;
13113bfd9da1Sbellard 	unsigned int	st_nlink;
13123bfd9da1Sbellard 
13133bfd9da1Sbellard 	unsigned int	st_uid;
13143bfd9da1Sbellard 	unsigned int	st_gid;
13153bfd9da1Sbellard 
13163bfd9da1Sbellard 	unsigned char	__pad2[6];
13173bfd9da1Sbellard 	unsigned short	st_rdev;
13183bfd9da1Sbellard 
13193bfd9da1Sbellard 	unsigned char	__pad3[8];
13203bfd9da1Sbellard 
13213bfd9da1Sbellard         int64_t	st_size;
13223bfd9da1Sbellard 	unsigned int	st_blksize;
13233bfd9da1Sbellard 
13243bfd9da1Sbellard 	unsigned char	__pad4[8];
13253bfd9da1Sbellard 	unsigned int	st_blocks;
13263bfd9da1Sbellard 
13273bfd9da1Sbellard 	unsigned int	target_st_atime;
13283bfd9da1Sbellard 	unsigned int	__unused1;
13293bfd9da1Sbellard 
13303bfd9da1Sbellard 	unsigned int	target_st_mtime;
13313bfd9da1Sbellard 	unsigned int	__unused2;
13323bfd9da1Sbellard 
13333bfd9da1Sbellard 	unsigned int	target_st_ctime;
13343bfd9da1Sbellard 	unsigned int	__unused3;
13353bfd9da1Sbellard 
13363bfd9da1Sbellard 	unsigned int	__unused4;
13373bfd9da1Sbellard 	unsigned int	__unused5;
13383bfd9da1Sbellard };
13393bfd9da1Sbellard 
134067867308Sbellard #elif defined(TARGET_PPC)
134167867308Sbellard 
134267867308Sbellard struct target_stat {
1343e32448e0Sj_mayer 	abi_ulong st_dev;
1344992f48a0Sblueswir1 	abi_ulong st_ino;
1345325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1346e32448e0Sj_mayer 	abi_ulong st_nlink;
1347325e651fSj_mayer 	unsigned int st_mode;
1348325e651fSj_mayer #else
134967867308Sbellard 	unsigned int st_mode;
135067867308Sbellard 	unsigned short st_nlink;
1351325e651fSj_mayer #endif
135267867308Sbellard 	unsigned int st_uid;
135367867308Sbellard 	unsigned int st_gid;
1354e32448e0Sj_mayer 	abi_ulong  st_rdev;
1355992f48a0Sblueswir1 	abi_ulong  st_size;
1356992f48a0Sblueswir1 	abi_ulong  st_blksize;
1357992f48a0Sblueswir1 	abi_ulong  st_blocks;
1358992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1359e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1360992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1361e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1362992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1363e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1364992f48a0Sblueswir1 	abi_ulong  __unused4;
1365992f48a0Sblueswir1 	abi_ulong  __unused5;
1366325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1367325e651fSj_mayer 	abi_ulong  __unused6;
1368325e651fSj_mayer #endif
136967867308Sbellard };
137067867308Sbellard 
1371541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
137267867308Sbellard 	unsigned long long st_dev;
137367867308Sbellard         unsigned long long st_ino;
137467867308Sbellard 	unsigned int st_mode;
137567867308Sbellard 	unsigned int st_nlink;
137667867308Sbellard 	unsigned int st_uid;
137767867308Sbellard 	unsigned int st_gid;
137867867308Sbellard 	unsigned long long st_rdev;
1379e1ce5e40Saurel32 	unsigned long long __pad0;
138067867308Sbellard 	long long      st_size;
1381e32448e0Sj_mayer 	int	       st_blksize;
1382e1ce5e40Saurel32 	unsigned int   __pad1;
138361322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1384e32448e0Sj_mayer 	int	       target_st_atime;
1385e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1386e32448e0Sj_mayer 	int	       target_st_mtime;
1387e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1388e32448e0Sj_mayer 	int            target_st_ctime;
1389e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1390e32448e0Sj_mayer         unsigned int   __unused4;
1391e32448e0Sj_mayer         unsigned int   __unused5;
139267867308Sbellard };
139367867308Sbellard 
1394b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1395b779e29eSEdgar E. Iglesias 
1396b779e29eSEdgar E. Iglesias struct target_stat {
1397b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1398b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1399b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1400b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1401b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1402b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1403b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1404b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1405b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1406b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1407b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1408b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1409b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1410b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1411b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1412b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1413b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1414b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1415b779e29eSEdgar E. Iglesias };
1416b779e29eSEdgar E. Iglesias 
1417b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
1418541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1419b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1420a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1421a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1422a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1423a523eb06SEdgar E. Iglesias 
1424b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1425b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1426b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1427b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1428b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
142921ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1430b779e29eSEdgar E. Iglesias 
1431b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1432b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
143321ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1434b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1435b779e29eSEdgar E. Iglesias 
1436b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1437b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1438b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1439b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1440b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1441b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1442a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1443b779e29eSEdgar E. Iglesias };
1444b779e29eSEdgar E. Iglesias 
1445e6e5906bSpbrook #elif defined(TARGET_M68K)
1446e6e5906bSpbrook 
1447e6e5906bSpbrook struct target_stat {
1448e6e5906bSpbrook 	unsigned short st_dev;
1449e6e5906bSpbrook 	unsigned short __pad1;
1450992f48a0Sblueswir1 	abi_ulong st_ino;
1451e6e5906bSpbrook 	unsigned short st_mode;
1452e6e5906bSpbrook 	unsigned short st_nlink;
1453e6e5906bSpbrook 	unsigned short st_uid;
1454e6e5906bSpbrook 	unsigned short st_gid;
1455e6e5906bSpbrook 	unsigned short st_rdev;
1456e6e5906bSpbrook 	unsigned short __pad2;
1457992f48a0Sblueswir1 	abi_ulong  st_size;
1458992f48a0Sblueswir1 	abi_ulong  st_blksize;
1459992f48a0Sblueswir1 	abi_ulong  st_blocks;
1460992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1461992f48a0Sblueswir1 	abi_ulong  __unused1;
1462992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1463992f48a0Sblueswir1 	abi_ulong  __unused2;
1464992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1465992f48a0Sblueswir1 	abi_ulong  __unused3;
1466992f48a0Sblueswir1 	abi_ulong  __unused4;
1467992f48a0Sblueswir1 	abi_ulong  __unused5;
1468e6e5906bSpbrook };
1469e6e5906bSpbrook 
1470e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1471e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1472e6e5906bSpbrook  */
1473e6e5906bSpbrook struct target_stat64 {
1474e6e5906bSpbrook 	unsigned long long	st_dev;
1475e6e5906bSpbrook 	unsigned char	__pad1[2];
1476e6e5906bSpbrook 
1477e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1478992f48a0Sblueswir1 	abi_ulong	__st_ino;
1479e6e5906bSpbrook 
1480e6e5906bSpbrook 	unsigned int	st_mode;
1481e6e5906bSpbrook 	unsigned int	st_nlink;
1482e6e5906bSpbrook 
1483992f48a0Sblueswir1 	abi_ulong	st_uid;
1484992f48a0Sblueswir1 	abi_ulong	st_gid;
1485e6e5906bSpbrook 
1486e6e5906bSpbrook 	unsigned long long	st_rdev;
1487e6e5906bSpbrook 	unsigned char	__pad3[2];
1488e6e5906bSpbrook 
1489e6e5906bSpbrook 	long long	st_size;
1490992f48a0Sblueswir1 	abi_ulong	st_blksize;
1491e6e5906bSpbrook 
1492992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1493992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1494e6e5906bSpbrook 
1495992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1496992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1497e6e5906bSpbrook 
1498992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1499992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1500e6e5906bSpbrook 
1501992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1502992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1503e6e5906bSpbrook 
1504e6e5906bSpbrook 	unsigned long long	st_ino;
1505541dc0d4SStefan Weil } QEMU_PACKED;
1506e6e5906bSpbrook 
1507d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1508540635baSths 
1509540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1510540635baSths struct target_stat {
1511540635baSths 	unsigned int		st_dev;
1512540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1513540635baSths 
1514992f48a0Sblueswir1 	abi_ulong		st_ino;
1515540635baSths 
1516540635baSths 	unsigned int		st_mode;
1517540635baSths 	unsigned int		st_nlink;
1518540635baSths 
1519540635baSths 	int			st_uid;
1520540635baSths 	int			st_gid;
1521540635baSths 
1522540635baSths 	unsigned int		st_rdev;
1523540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1524540635baSths 
1525992f48a0Sblueswir1 	abi_ulong		st_size;
1526540635baSths 
1527540635baSths 	/*
1528540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1529540635baSths 	 * but we don't have it under Linux.
1530540635baSths 	 */
1531540635baSths 	unsigned int		target_st_atime;
1532540635baSths 	unsigned int		target_st_atime_nsec;
1533540635baSths 
1534540635baSths 	unsigned int		target_st_mtime;
1535540635baSths 	unsigned int		target_st_mtime_nsec;
1536540635baSths 
1537540635baSths 	unsigned int		target_st_ctime;
1538540635baSths 	unsigned int		target_st_ctime_nsec;
1539540635baSths 
1540540635baSths 	unsigned int		st_blksize;
1541540635baSths 	unsigned int		st_pad2;
1542540635baSths 
1543992f48a0Sblueswir1 	abi_ulong		st_blocks;
1544540635baSths };
1545540635baSths 
1546d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1547540635baSths 
1548540635baSths struct target_stat {
1549540635baSths 	unsigned	st_dev;
1550540635baSths 	int		st_pad1[3];		/* Reserved for network id */
1551540635baSths 	unsigned int	st_ino;
1552540635baSths 	unsigned int	st_mode;
1553540635baSths 	unsigned int	st_nlink;
1554540635baSths 	int		st_uid;
1555540635baSths 	int		st_gid;
1556540635baSths 	unsigned 	st_rdev;
1557540635baSths 	unsigned int	st_pad2[2];
1558540635baSths 	unsigned int	st_size;
1559540635baSths 	unsigned int	st_pad3;
1560540635baSths 	/*
1561540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1562540635baSths 	 * but we don't have it under Linux.
1563540635baSths 	 */
1564540635baSths 	unsigned int		target_st_atime;
1565540635baSths 	unsigned int		target_st_atime_nsec;
1566540635baSths 	unsigned int		target_st_mtime;
1567540635baSths 	unsigned int		target_st_mtime_nsec;
1568540635baSths 	unsigned int		target_st_ctime;
1569540635baSths 	unsigned int		target_st_ctime_nsec;
1570540635baSths 	unsigned int		st_blksize;
1571540635baSths 	unsigned int		st_blocks;
1572540635baSths 	unsigned int		st_pad4[14];
1573540635baSths };
1574540635baSths 
1575540635baSths /*
1576540635baSths  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1577540635baSths  * amounts of padding around dev_t's.  The memory layout is the same as of
1578540635baSths  * struct stat of the 64-bit kernel.
1579540635baSths  */
1580540635baSths 
1581540635baSths struct target_stat64 {
1582540635baSths 	unsigned int	st_dev;
1583540635baSths 	unsigned int	st_pad0[3];	/* Reserved for st_dev expansion  */
1584540635baSths 
1585540635baSths 	target_ulong	st_ino;
1586540635baSths 
1587540635baSths         unsigned int	st_mode;
1588540635baSths         unsigned int	st_nlink;
1589540635baSths 
1590540635baSths 	int		st_uid;
1591540635baSths 	int		st_gid;
1592540635baSths 
1593540635baSths 	unsigned int	st_rdev;
1594540635baSths 	unsigned int	st_pad1[3];	/* Reserved for st_rdev expansion  */
1595540635baSths 
1596540635baSths 	int		st_size;
1597540635baSths 
1598540635baSths 	/*
1599540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1600540635baSths 	 * but we don't have it under Linux.
1601540635baSths 	 */
1602540635baSths 	int		target_st_atime;
1603540635baSths 	unsigned int	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1604540635baSths 
1605540635baSths 	int		target_st_mtime;
1606540635baSths 	unsigned int	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1607540635baSths 
1608540635baSths 	int		target_st_ctime;
1609540635baSths 	unsigned int	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1610540635baSths 
1611540635baSths 	unsigned int	st_blksize;
1612540635baSths 	unsigned int	st_pad2;
1613540635baSths 
1614540635baSths 	int		st_blocks;
1615540635baSths };
1616540635baSths 
1617d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1618048f6b4dSbellard 
1619048f6b4dSbellard struct target_stat {
1620048f6b4dSbellard 	unsigned	st_dev;
1621992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1622992f48a0Sblueswir1 	abi_ulong	st_ino;
1623048f6b4dSbellard 	unsigned int	st_mode;
1624048f6b4dSbellard 	unsigned int	st_nlink;
1625048f6b4dSbellard 	int		st_uid;
1626048f6b4dSbellard 	int		st_gid;
1627048f6b4dSbellard 	unsigned 	st_rdev;
1628992f48a0Sblueswir1 	abi_long	st_pad2[2];
1629992f48a0Sblueswir1 	abi_long	st_size;
1630992f48a0Sblueswir1 	abi_long	st_pad3;
1631048f6b4dSbellard 	/*
1632048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1633048f6b4dSbellard 	 * but we don't have it under Linux.
1634048f6b4dSbellard 	 */
1635992f48a0Sblueswir1 	abi_long		target_st_atime;
1636992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1637992f48a0Sblueswir1 	abi_long		target_st_mtime;
1638992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1639992f48a0Sblueswir1 	abi_long		target_st_ctime;
1640992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1641992f48a0Sblueswir1 	abi_long		st_blksize;
1642992f48a0Sblueswir1 	abi_long		st_blocks;
1643992f48a0Sblueswir1 	abi_long		st_pad4[14];
1644048f6b4dSbellard };
1645048f6b4dSbellard 
1646048f6b4dSbellard /*
1647048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1648048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1649048f6b4dSbellard  * struct stat of the 64-bit kernel.
1650048f6b4dSbellard  */
1651048f6b4dSbellard 
1652048f6b4dSbellard struct target_stat64 {
1653992f48a0Sblueswir1 	abi_ulong	st_dev;
1654992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1655048f6b4dSbellard 
1656048f6b4dSbellard 	uint64_t	st_ino;
1657048f6b4dSbellard 
1658048f6b4dSbellard         unsigned int	st_mode;
1659048f6b4dSbellard         unsigned int	st_nlink;
1660048f6b4dSbellard 
1661048f6b4dSbellard 	int		st_uid;
1662048f6b4dSbellard 	int		st_gid;
1663048f6b4dSbellard 
1664992f48a0Sblueswir1 	abi_ulong	st_rdev;
1665992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1666048f6b4dSbellard 
1667048f6b4dSbellard 	int64_t 	st_size;
1668048f6b4dSbellard 
1669048f6b4dSbellard 	/*
1670048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1671048f6b4dSbellard 	 * but we don't have it under Linux.
1672048f6b4dSbellard 	 */
1673992f48a0Sblueswir1 	abi_long	target_st_atime;
1674992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1675048f6b4dSbellard 
1676992f48a0Sblueswir1 	abi_long	target_st_mtime;
1677992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1678048f6b4dSbellard 
1679992f48a0Sblueswir1 	abi_long	target_st_ctime;
1680992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1681048f6b4dSbellard 
1682992f48a0Sblueswir1 	abi_ulong	st_blksize;
1683992f48a0Sblueswir1 	abi_ulong	st_pad2;
1684048f6b4dSbellard 
1685048f6b4dSbellard 	int64_t  	st_blocks;
1686048f6b4dSbellard };
16877a3148a9Sj_mayer 
16887a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
16897a3148a9Sj_mayer 
16907a3148a9Sj_mayer struct target_stat {
16917a3148a9Sj_mayer        unsigned int    st_dev;
16927a3148a9Sj_mayer        unsigned int    st_ino;
16937a3148a9Sj_mayer        unsigned int    st_mode;
16947a3148a9Sj_mayer        unsigned int    st_nlink;
16957a3148a9Sj_mayer        unsigned int    st_uid;
16967a3148a9Sj_mayer        unsigned int    st_gid;
16977a3148a9Sj_mayer        unsigned int    st_rdev;
1698992f48a0Sblueswir1        abi_long     st_size;
1699992f48a0Sblueswir1        abi_ulong    target_st_atime;
1700992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1701992f48a0Sblueswir1        abi_ulong    target_st_ctime;
17027a3148a9Sj_mayer        unsigned int    st_blksize;
17037a3148a9Sj_mayer        unsigned int    st_blocks;
17047a3148a9Sj_mayer        unsigned int    st_flags;
17057a3148a9Sj_mayer        unsigned int    st_gen;
17067a3148a9Sj_mayer };
17077a3148a9Sj_mayer 
17087a3148a9Sj_mayer struct target_stat64 {
1709992f48a0Sblueswir1        abi_ulong    st_dev;
1710992f48a0Sblueswir1        abi_ulong    st_ino;
1711992f48a0Sblueswir1        abi_ulong    st_rdev;
1712992f48a0Sblueswir1        abi_long     st_size;
1713992f48a0Sblueswir1        abi_ulong    st_blocks;
17147a3148a9Sj_mayer 
17157a3148a9Sj_mayer        unsigned int    st_mode;
17167a3148a9Sj_mayer        unsigned int    st_uid;
17177a3148a9Sj_mayer        unsigned int    st_gid;
17187a3148a9Sj_mayer        unsigned int    st_blksize;
17197a3148a9Sj_mayer        unsigned int    st_nlink;
17207a3148a9Sj_mayer        unsigned int    __pad0;
17217a3148a9Sj_mayer 
1722992f48a0Sblueswir1        abi_ulong    target_st_atime;
1723992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1724992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1725992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1726992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1727992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1728992f48a0Sblueswir1        abi_long     __unused[3];
17297a3148a9Sj_mayer };
17307a3148a9Sj_mayer 
17316db45e65Sths #elif defined(TARGET_SH4)
17326db45e65Sths 
17336db45e65Sths struct target_stat {
1734992f48a0Sblueswir1 	abi_ulong  st_dev;
1735992f48a0Sblueswir1 	abi_ulong  st_ino;
17366db45e65Sths 	unsigned short st_mode;
17376db45e65Sths 	unsigned short st_nlink;
17386db45e65Sths 	unsigned short st_uid;
17396db45e65Sths 	unsigned short st_gid;
1740992f48a0Sblueswir1 	abi_ulong  st_rdev;
1741992f48a0Sblueswir1 	abi_ulong  st_size;
1742992f48a0Sblueswir1 	abi_ulong  st_blksize;
1743992f48a0Sblueswir1 	abi_ulong  st_blocks;
1744992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1745992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1746992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1747992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1748992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1749992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1750992f48a0Sblueswir1 	abi_ulong  __unused4;
1751992f48a0Sblueswir1 	abi_ulong  __unused5;
17526db45e65Sths };
17536db45e65Sths 
17546db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
17556db45e65Sths  * insane amounts of padding around dev_t's.
17566db45e65Sths  */
1757541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
17586db45e65Sths 	unsigned long long	st_dev;
17596db45e65Sths 	unsigned char	__pad0[4];
17606db45e65Sths 
17616db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1762992f48a0Sblueswir1 	abi_ulong	__st_ino;
17636db45e65Sths 
17646db45e65Sths 	unsigned int	st_mode;
17656db45e65Sths 	unsigned int	st_nlink;
17666db45e65Sths 
1767992f48a0Sblueswir1 	abi_ulong	st_uid;
1768992f48a0Sblueswir1 	abi_ulong	st_gid;
17696db45e65Sths 
17706db45e65Sths 	unsigned long long	st_rdev;
17716db45e65Sths 	unsigned char	__pad3[4];
17726db45e65Sths 
17736db45e65Sths 	long long	st_size;
1774992f48a0Sblueswir1 	abi_ulong	st_blksize;
17756db45e65Sths 
17766db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
17776db45e65Sths 
1778992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1779992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
17806db45e65Sths 
1781992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1782992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
17836db45e65Sths 
1784992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1785992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
17866db45e65Sths 
17876db45e65Sths 	unsigned long long	st_ino;
17886db45e65Sths };
17896db45e65Sths 
1790d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1791d2fd1af7Sbellard struct target_stat {
1792d2fd1af7Sbellard 	abi_ulong	st_dev;
1793d2fd1af7Sbellard 	abi_ulong	st_ino;
1794d2fd1af7Sbellard 	abi_ulong	st_nlink;
1795d2fd1af7Sbellard 
1796d2fd1af7Sbellard 	unsigned int	st_mode;
1797d2fd1af7Sbellard 	unsigned int	st_uid;
1798d2fd1af7Sbellard 	unsigned int	st_gid;
1799d2fd1af7Sbellard 	unsigned int	__pad0;
1800d2fd1af7Sbellard 	abi_ulong	st_rdev;
1801d2fd1af7Sbellard 	abi_long	st_size;
1802d2fd1af7Sbellard 	abi_long	st_blksize;
1803d2fd1af7Sbellard     	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1804d2fd1af7Sbellard 
1805d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1806d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1807d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1808d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1809d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1810d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1811d2fd1af7Sbellard 
1812d2fd1af7Sbellard   	abi_long	__unused[3];
1813d2fd1af7Sbellard };
1814a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1815a4c075f1SUlrich Hecht struct target_stat {
1816a4c075f1SUlrich Hecht     abi_ulong  st_dev;
1817a4c075f1SUlrich Hecht     abi_ulong  st_ino;
1818a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
1819a4c075f1SUlrich Hecht     unsigned int   st_mode;
1820a4c075f1SUlrich Hecht     unsigned int   st_uid;
1821a4c075f1SUlrich Hecht     unsigned int   st_gid;
1822a4c075f1SUlrich Hecht     unsigned int   __pad1;
1823a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
1824a4c075f1SUlrich Hecht     abi_ulong  st_size;
1825a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
1826a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
1827a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
1828a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
1829a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
1830a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
1831a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
1832a4c075f1SUlrich Hecht     abi_long       st_blocks;
1833a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
1834a4c075f1SUlrich Hecht };
1835d962783eSJia Liu #elif defined(TARGET_OPENRISC)
1836d962783eSJia Liu struct target_stat {
1837d962783eSJia Liu     abi_ulong st_dev;
1838d962783eSJia Liu     abi_ulong st_ino;
1839d962783eSJia Liu     abi_ulong st_nlink;
1840d962783eSJia Liu 
1841d962783eSJia Liu     unsigned int st_mode;
1842d962783eSJia Liu     unsigned int st_uid;
1843d962783eSJia Liu     unsigned int st_gid;
1844d962783eSJia Liu     unsigned int __pad0;
1845d962783eSJia Liu     abi_ulong st_rdev;
1846d962783eSJia Liu     abi_long st_size;
1847d962783eSJia Liu     abi_long st_blksize;
1848d962783eSJia Liu     abi_long st_blocks;    /* Number 512-byte blocks allocated. */
1849d962783eSJia Liu 
1850d962783eSJia Liu     abi_ulong target_st_atime;
1851d962783eSJia Liu     abi_ulong target_st_atime_nsec;
1852d962783eSJia Liu     abi_ulong target_st_mtime;
1853d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
1854d962783eSJia Liu     abi_ulong target_st_ctime;
1855d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
1856d962783eSJia Liu 
1857d962783eSJia Liu     abi_long __unused[3];
1858d962783eSJia Liu };
1859048f6b4dSbellard #else
1860048f6b4dSbellard #error unsupported CPU
1861048f6b4dSbellard #endif
18622521d698Sbellard 
18634ce6f8deSths typedef struct {
18644ce6f8deSths         int     val[2];
1865c227f099SAnthony Liguori } target_fsid_t;
18664ce6f8deSths 
186756c8f68fSbellard #ifdef TARGET_MIPS
1868d26bc211Sths #ifdef TARGET_ABI_MIPSN32
1869540635baSths struct target_statfs {
1870540635baSths 	int32_t			f_type;
1871540635baSths 	int32_t			f_bsize;
1872540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
1873540635baSths 	int32_t			f_blocks;
1874540635baSths 	int32_t			f_bfree;
1875540635baSths 	int32_t			f_files;
1876540635baSths 	int32_t			f_ffree;
1877540635baSths 	int32_t			f_bavail;
1878540635baSths 
1879540635baSths 	/* Linux specials */
1880c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
1881540635baSths 	int32_t			f_namelen;
1882540635baSths 	int32_t			f_spare[6];
1883540635baSths };
1884540635baSths #else
188556c8f68fSbellard struct target_statfs {
1886992f48a0Sblueswir1 	abi_long		f_type;
1887992f48a0Sblueswir1 	abi_long		f_bsize;
1888992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
1889992f48a0Sblueswir1 	abi_long		f_blocks;
1890992f48a0Sblueswir1 	abi_long		f_bfree;
1891992f48a0Sblueswir1 	abi_long		f_files;
1892992f48a0Sblueswir1 	abi_long		f_ffree;
1893992f48a0Sblueswir1 	abi_long		f_bavail;
189456c8f68fSbellard 
189556c8f68fSbellard 	/* Linux specials */
1896c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
1897992f48a0Sblueswir1 	abi_long		f_namelen;
1898992f48a0Sblueswir1 	abi_long		f_spare[6];
189956c8f68fSbellard };
1900540635baSths #endif
190156c8f68fSbellard 
190256c8f68fSbellard struct target_statfs64 {
190356c8f68fSbellard 	uint32_t	f_type;
190456c8f68fSbellard 	uint32_t	f_bsize;
190556c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
190656c8f68fSbellard 	uint32_t	__pad;
190756c8f68fSbellard 	uint64_t	f_blocks;
190856c8f68fSbellard 	uint64_t	f_bfree;
190956c8f68fSbellard 	uint64_t	f_files;
191056c8f68fSbellard 	uint64_t	f_ffree;
191156c8f68fSbellard 	uint64_t	f_bavail;
1912c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
191356c8f68fSbellard 	uint32_t	f_namelen;
191456c8f68fSbellard 	uint32_t	f_spare[6];
191556c8f68fSbellard };
1916c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
1917c4d10628Sbalrog        defined(TARGET_SPARC64)) && !defined(TARGET_ABI32)
1918325e651fSj_mayer struct target_statfs {
1919325e651fSj_mayer 	abi_long f_type;
1920325e651fSj_mayer 	abi_long f_bsize;
1921325e651fSj_mayer 	abi_long f_blocks;
1922325e651fSj_mayer 	abi_long f_bfree;
1923325e651fSj_mayer 	abi_long f_bavail;
1924325e651fSj_mayer 	abi_long f_files;
1925325e651fSj_mayer 	abi_long f_ffree;
1926c227f099SAnthony Liguori 	target_fsid_t f_fsid;
1927325e651fSj_mayer 	abi_long f_namelen;
1928325e651fSj_mayer 	abi_long f_frsize;
1929325e651fSj_mayer 	abi_long f_spare[5];
1930325e651fSj_mayer };
1931325e651fSj_mayer 
1932325e651fSj_mayer struct target_statfs64 {
1933325e651fSj_mayer 	abi_long f_type;
1934325e651fSj_mayer 	abi_long f_bsize;
1935325e651fSj_mayer 	abi_long f_blocks;
1936325e651fSj_mayer 	abi_long f_bfree;
1937325e651fSj_mayer 	abi_long f_bavail;
1938325e651fSj_mayer 	abi_long f_files;
1939325e651fSj_mayer 	abi_long f_ffree;
1940c227f099SAnthony Liguori 	target_fsid_t f_fsid;
1941325e651fSj_mayer 	abi_long f_namelen;
1942325e651fSj_mayer 	abi_long f_frsize;
1943325e651fSj_mayer 	abi_long f_spare[5];
1944325e651fSj_mayer };
1945a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1946a4c075f1SUlrich Hecht struct target_statfs {
1947a4c075f1SUlrich Hecht     int32_t  f_type;
1948a4c075f1SUlrich Hecht     int32_t  f_bsize;
1949a4c075f1SUlrich Hecht     abi_long f_blocks;
1950a4c075f1SUlrich Hecht     abi_long f_bfree;
1951a4c075f1SUlrich Hecht     abi_long f_bavail;
1952a4c075f1SUlrich Hecht     abi_long f_files;
1953a4c075f1SUlrich Hecht     abi_long f_ffree;
1954a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
1955a4c075f1SUlrich Hecht     int32_t  f_namelen;
1956a4c075f1SUlrich Hecht     int32_t  f_frsize;
1957a4c075f1SUlrich Hecht     int32_t  f_spare[5];
1958a4c075f1SUlrich Hecht };
1959a4c075f1SUlrich Hecht 
1960a4c075f1SUlrich Hecht struct target_statfs64 {
1961a4c075f1SUlrich Hecht     int32_t  f_type;
1962a4c075f1SUlrich Hecht     int32_t  f_bsize;
1963a4c075f1SUlrich Hecht     abi_long f_blocks;
1964a4c075f1SUlrich Hecht     abi_long f_bfree;
1965a4c075f1SUlrich Hecht     abi_long f_bavail;
1966a4c075f1SUlrich Hecht     abi_long f_files;
1967a4c075f1SUlrich Hecht     abi_long f_ffree;
1968a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
1969a4c075f1SUlrich Hecht     int32_t  f_namelen;
1970a4c075f1SUlrich Hecht     int32_t  f_frsize;
1971a4c075f1SUlrich Hecht     int32_t  f_spare[5];
1972a4c075f1SUlrich Hecht };
197356c8f68fSbellard #else
197456c8f68fSbellard struct target_statfs {
197556c8f68fSbellard 	uint32_t f_type;
197656c8f68fSbellard 	uint32_t f_bsize;
197756c8f68fSbellard 	uint32_t f_blocks;
197856c8f68fSbellard 	uint32_t f_bfree;
197956c8f68fSbellard 	uint32_t f_bavail;
198056c8f68fSbellard 	uint32_t f_files;
198156c8f68fSbellard 	uint32_t f_ffree;
1982c227f099SAnthony Liguori 	target_fsid_t f_fsid;
198356c8f68fSbellard 	uint32_t f_namelen;
198456c8f68fSbellard 	uint32_t f_frsize;
198556c8f68fSbellard 	uint32_t f_spare[5];
198656c8f68fSbellard };
198756c8f68fSbellard 
198856c8f68fSbellard struct target_statfs64 {
198956c8f68fSbellard 	uint32_t f_type;
199056c8f68fSbellard 	uint32_t f_bsize;
199156c8f68fSbellard 	uint64_t f_blocks;
199256c8f68fSbellard 	uint64_t f_bfree;
199356c8f68fSbellard 	uint64_t f_bavail;
199456c8f68fSbellard 	uint64_t f_files;
199556c8f68fSbellard 	uint64_t f_ffree;
1996c227f099SAnthony Liguori 	target_fsid_t f_fsid;
199756c8f68fSbellard         uint32_t f_namelen;
199856c8f68fSbellard 	uint32_t f_frsize;
199956c8f68fSbellard 	uint32_t f_spare[5];
200056c8f68fSbellard };
200156c8f68fSbellard #endif
200256c8f68fSbellard 
200356c8f68fSbellard 
20042521d698Sbellard #define TARGET_F_DUPFD         0       /* dup */
20052521d698Sbellard #define TARGET_F_GETFD         1       /* get close_on_exec */
20062521d698Sbellard #define TARGET_F_SETFD         2       /* set/clear close_on_exec */
20072521d698Sbellard #define TARGET_F_GETFL         3       /* get file->f_flags */
20082521d698Sbellard #define TARGET_F_SETFL         4       /* set file->f_flags */
20092521d698Sbellard 
20102521d698Sbellard #if defined(TARGET_ALPHA)
20112521d698Sbellard #define TARGET_F_GETLK         7
20122521d698Sbellard #define TARGET_F_SETLK         8
20132521d698Sbellard #define TARGET_F_SETLKW        9
20142521d698Sbellard #define TARGET_F_SETOWN        5       /*  for sockets. */
20152521d698Sbellard #define TARGET_F_GETOWN        6       /*  for sockets. */
20165f106811SArnaud Patard (Rtp) #elif defined(TARGET_MIPS)
20175f106811SArnaud Patard (Rtp) #define TARGET_F_GETLK         14
20185f106811SArnaud Patard (Rtp) #define TARGET_F_SETLK         6
20195f106811SArnaud Patard (Rtp) #define TARGET_F_SETLKW        7
20205f106811SArnaud Patard (Rtp) #define TARGET_F_SETOWN        24       /*  for sockets. */
20215f106811SArnaud Patard (Rtp) #define TARGET_F_GETOWN        25       /*  for sockets. */
20222521d698Sbellard #else
20232521d698Sbellard #define TARGET_F_GETLK         5
20242521d698Sbellard #define TARGET_F_SETLK         6
20252521d698Sbellard #define TARGET_F_SETLKW        7
20262521d698Sbellard #define TARGET_F_SETOWN        8       /*  for sockets. */
20272521d698Sbellard #define TARGET_F_GETOWN        9       /*  for sockets. */
20282521d698Sbellard #endif
20292521d698Sbellard 
20302521d698Sbellard #define TARGET_F_SETSIG        10      /*  for sockets. */
20312521d698Sbellard #define TARGET_F_GETSIG        11      /*  for sockets. */
20322521d698Sbellard 
20335f106811SArnaud Patard (Rtp) #if defined(TARGET_MIPS)
20345f106811SArnaud Patard (Rtp) #define TARGET_F_GETLK64       33      /*  using 'struct flock64' */
20355f106811SArnaud Patard (Rtp) #define TARGET_F_SETLK64       34
20365f106811SArnaud Patard (Rtp) #define TARGET_F_SETLKW64      35
20375f106811SArnaud Patard (Rtp) #else
20382521d698Sbellard #define TARGET_F_GETLK64       12      /*  using 'struct flock64' */
20392521d698Sbellard #define TARGET_F_SETLK64       13
20402521d698Sbellard #define TARGET_F_SETLKW64      14
20415f106811SArnaud Patard (Rtp) #endif
20427e22e546SUlrich Hecht 
20437e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
20447e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
20457e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
20467e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
20477e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
20487e22e546SUlrich Hecht 
2049*4eeea4f3SRichard Henderson #if defined(TARGET_ALPHA)
2050*4eeea4f3SRichard Henderson #define TARGET_O_NONBLOCK           04
2051*4eeea4f3SRichard Henderson #define TARGET_O_APPEND            010
2052*4eeea4f3SRichard Henderson #define TARGET_O_CREAT           01000 /* not fcntl */
2053*4eeea4f3SRichard Henderson #define TARGET_O_TRUNC           02000 /* not fcntl */
2054*4eeea4f3SRichard Henderson #define TARGET_O_EXCL            04000 /* not fcntl */
2055*4eeea4f3SRichard Henderson #define TARGET_O_NOCTTY         010000 /* not fcntl */
2056*4eeea4f3SRichard Henderson #define TARGET_O_DSYNC          040000
2057*4eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE           0 /* not necessary, always 64-bit */
2058*4eeea4f3SRichard Henderson #define TARGET_O_DIRECTORY     0100000 /* must be a directory */
2059*4eeea4f3SRichard Henderson #define TARGET_O_NOFOLLOW      0200000 /* don't follow links */
2060*4eeea4f3SRichard Henderson #define TARGET_O_DIRECT       02000000 /* direct disk access hint */
2061*4eeea4f3SRichard Henderson #define TARGET_O_NOATIME      04000000
2062*4eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC     010000000
2063*4eeea4f3SRichard Henderson #define TARGET___O_SYNC      020000000
2064*4eeea4f3SRichard Henderson #define TARGET_O_PATH        040000000
2065*4eeea4f3SRichard Henderson #elif defined(TARGET_ARM) || defined(TARGET_M68K)
2066f09936acSbellard #define TARGET_O_DIRECTORY      040000 /* must be a directory */
2067f09936acSbellard #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
2068f09936acSbellard #define TARGET_O_DIRECT        0200000 /* direct disk access hint */
2069f09936acSbellard #define TARGET_O_LARGEFILE     0400000
2070048f6b4dSbellard #elif defined(TARGET_MIPS)
2071048f6b4dSbellard #define TARGET_O_APPEND         0x0008
2072*4eeea4f3SRichard Henderson #define TARGET_O_DSYNC          0x0010
2073048f6b4dSbellard #define TARGET_O_NONBLOCK       0x0080
2074048f6b4dSbellard #define TARGET_O_CREAT          0x0100  /* not fcntl */
2075048f6b4dSbellard #define TARGET_O_TRUNC          0x0200  /* not fcntl */
2076048f6b4dSbellard #define TARGET_O_EXCL           0x0400  /* not fcntl */
2077048f6b4dSbellard #define TARGET_O_NOCTTY         0x0800  /* not fcntl */
2078048f6b4dSbellard #define TARGET_FASYNC           0x1000  /* fcntl, for BSD compatibility */
2079048f6b4dSbellard #define TARGET_O_LARGEFILE      0x2000  /* allow large file opens */
2080*4eeea4f3SRichard Henderson #define TARGET___O_SYNC         0x4000
2081048f6b4dSbellard #define TARGET_O_DIRECT         0x8000  /* direct disk access hint */
2082*4eeea4f3SRichard Henderson #elif defined (TARGET_PPC)
2083*4eeea4f3SRichard Henderson #define TARGET_O_DIRECTORY      040000 /* must be a directory */
2084*4eeea4f3SRichard Henderson #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
2085*4eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE     0200000
2086*4eeea4f3SRichard Henderson #define TARGET_O_DIRECT        0400000 /* direct disk access hint */
2087*4eeea4f3SRichard Henderson #elif defined (TARGET_SPARC)
20881f961124Saurel32 #define TARGET_O_APPEND         0x0008
2089*4eeea4f3SRichard Henderson #define TARGET_FASYNC           0x0040  /* fcntl, for BSD compatibility */
20901f961124Saurel32 #define TARGET_O_CREAT          0x0200  /* not fcntl */
20911f961124Saurel32 #define TARGET_O_TRUNC          0x0400  /* not fcntl */
20921f961124Saurel32 #define TARGET_O_EXCL           0x0800  /* not fcntl */
2093*4eeea4f3SRichard Henderson #define TARGET_O_DSYNC          0x2000
2094*4eeea4f3SRichard Henderson #define TARGET_O_NONBLOCK       0x4000
2095*4eeea4f3SRichard Henderson # ifdef TARGET_SPARC64
2096*4eeea4f3SRichard Henderson #  define TARGET_O_NDELAY       0x0004
2097ffa65c3bSbellard # else
2098*4eeea4f3SRichard Henderson #  define TARGET_O_NDELAY       (0x0004 | TARGET_O_NONBLOCK)
2099*4eeea4f3SRichard Henderson # endif
2100*4eeea4f3SRichard Henderson #define TARGET_O_NOCTTY         0x8000  /* not fcntl */
2101*4eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE     0x40000
2102*4eeea4f3SRichard Henderson #define TARGET_O_DIRECT       0x100000  /* direct disk access hint */
2103*4eeea4f3SRichard Henderson #define TARGET_O_NOATIME      0x200000
2104*4eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC      0x400000
2105*4eeea4f3SRichard Henderson #define TARGET___O_SYNC       0x800000
2106*4eeea4f3SRichard Henderson #define TARGET_O_PATH        0x1000000
2107*4eeea4f3SRichard Henderson #endif
2108*4eeea4f3SRichard Henderson 
2109*4eeea4f3SRichard Henderson /* <asm-generic/fcntl.h> values follow.  */
2110ffa65c3bSbellard #define TARGET_O_ACCMODE          0003
2111ffa65c3bSbellard #define TARGET_O_RDONLY             00
2112ffa65c3bSbellard #define TARGET_O_WRONLY             01
2113ffa65c3bSbellard #define TARGET_O_RDWR               02
2114*4eeea4f3SRichard Henderson #ifndef TARGET_O_CREAT
2115ffa65c3bSbellard #define TARGET_O_CREAT            0100 /* not fcntl */
2116*4eeea4f3SRichard Henderson #endif
2117*4eeea4f3SRichard Henderson #ifndef TARGET_O_EXCL
2118ffa65c3bSbellard #define TARGET_O_EXCL             0200 /* not fcntl */
2119*4eeea4f3SRichard Henderson #endif
2120*4eeea4f3SRichard Henderson #ifndef TARGET_O_NOCTTY
2121ffa65c3bSbellard #define TARGET_O_NOCTTY           0400 /* not fcntl */
2122*4eeea4f3SRichard Henderson #endif
2123*4eeea4f3SRichard Henderson #ifndef TARGET_O_TRUNC
2124ffa65c3bSbellard #define TARGET_O_TRUNC           01000 /* not fcntl */
2125*4eeea4f3SRichard Henderson #endif
2126*4eeea4f3SRichard Henderson #ifndef TARGET_O_APPEND
2127ffa65c3bSbellard #define TARGET_O_APPEND          02000
2128*4eeea4f3SRichard Henderson #endif
2129*4eeea4f3SRichard Henderson #ifndef TARGET_O_NONBLOCK
2130ffa65c3bSbellard #define TARGET_O_NONBLOCK        04000
2131*4eeea4f3SRichard Henderson #endif
2132*4eeea4f3SRichard Henderson #ifndef TARGET_O_DSYNC
2133*4eeea4f3SRichard Henderson #define TARGET_O_DSYNC          010000
2134*4eeea4f3SRichard Henderson #endif
2135*4eeea4f3SRichard Henderson #ifndef TARGET_FASYNC
2136ffa65c3bSbellard #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
2137*4eeea4f3SRichard Henderson #endif
2138*4eeea4f3SRichard Henderson #ifndef TARGET_O_DIRECT
2139ffa65c3bSbellard #define TARGET_O_DIRECT         040000 /* direct disk access hint */
2140*4eeea4f3SRichard Henderson #endif
2141*4eeea4f3SRichard Henderson #ifndef TARGET_O_LARGEFILE
2142ffa65c3bSbellard #define TARGET_O_LARGEFILE     0100000
2143*4eeea4f3SRichard Henderson #endif
2144*4eeea4f3SRichard Henderson #ifndef TARGET_O_DIRECTORY
2145ffa65c3bSbellard #define TARGET_O_DIRECTORY     0200000 /* must be a directory */
2146*4eeea4f3SRichard Henderson #endif
2147*4eeea4f3SRichard Henderson #ifndef TARGET_O_NOFOLLOW
2148ffa65c3bSbellard #define TARGET_O_NOFOLLOW      0400000 /* don't follow links */
2149ffa65c3bSbellard #endif
2150*4eeea4f3SRichard Henderson #ifndef TARGET_O_NOATIME
2151*4eeea4f3SRichard Henderson #define TARGET_O_NOATIME      01000000
2152*4eeea4f3SRichard Henderson #endif
2153*4eeea4f3SRichard Henderson #ifndef TARGET_O_CLOEXEC
2154*4eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC      02000000
2155*4eeea4f3SRichard Henderson #endif
2156*4eeea4f3SRichard Henderson #ifndef TARGET___O_SYNC
2157*4eeea4f3SRichard Henderson #define TARGET___O_SYNC       04000000
2158*4eeea4f3SRichard Henderson #endif
2159*4eeea4f3SRichard Henderson #ifndef TARGET_O_PATH
2160*4eeea4f3SRichard Henderson #define TARGET_O_PATH        010000000
2161*4eeea4f3SRichard Henderson #endif
2162*4eeea4f3SRichard Henderson #ifndef TARGET_O_NDELAY
2163*4eeea4f3SRichard Henderson #define TARGET_O_NDELAY  TARGET_O_NONBLOCK
2164*4eeea4f3SRichard Henderson #endif
2165*4eeea4f3SRichard Henderson #ifndef TARGET_O_SYNC
2166*4eeea4f3SRichard Henderson #define TARGET_O_SYNC    (TARGET___O_SYNC | TARGET_O_DSYNC)
2167*4eeea4f3SRichard Henderson #endif
2168ffa65c3bSbellard 
21692521d698Sbellard struct target_flock {
21702521d698Sbellard 	short l_type;
21712521d698Sbellard 	short l_whence;
2172992f48a0Sblueswir1 	abi_ulong l_start;
2173992f48a0Sblueswir1 	abi_ulong l_len;
21742521d698Sbellard 	int l_pid;
21752521d698Sbellard };
21762521d698Sbellard 
21772521d698Sbellard struct target_flock64 {
21782521d698Sbellard 	short  l_type;
21792521d698Sbellard 	short  l_whence;
2180b779e29eSEdgar E. Iglesias #if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) || defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined (TARGET_MICROBLAZE)
2181ce3f0e2fSaurel32         int __pad;
2182ce3f0e2fSaurel32 #endif
21832521d698Sbellard 	unsigned long long l_start;
21842521d698Sbellard 	unsigned long long l_len;
21852521d698Sbellard 	int  l_pid;
2186541dc0d4SStefan Weil } QEMU_PACKED;
21872521d698Sbellard 
2188ce4defa0Spbrook #ifdef TARGET_ARM
2189ce4defa0Spbrook struct target_eabi_flock64 {
2190ce4defa0Spbrook 	short  l_type;
2191ce4defa0Spbrook 	short  l_whence;
2192ce4defa0Spbrook         int __pad;
2193ce4defa0Spbrook 	unsigned long long l_start;
2194ce4defa0Spbrook 	unsigned long long l_len;
2195ce4defa0Spbrook 	int  l_pid;
2196541dc0d4SStefan Weil } QEMU_PACKED;
2197ce4defa0Spbrook #endif
21982521d698Sbellard 
21992521d698Sbellard /* soundcard defines */
22002521d698Sbellard /* XXX: convert them all to arch indepedent entries */
22012521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
22022521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
22032521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
22042521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
22052521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
22062521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
22072521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
22082521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
22092521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
22102521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
22112521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
22122521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
22132521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
22142521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
22152521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
22162521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
22172521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
22182521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
22192521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
22202521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
22212521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
22222521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
22232521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
22242521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
22252521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
22262521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
22272521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
22282521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
22292521d698Sbellard #define TARGET_SNDCTL_DSP_MAPINBUF        0x80085013
22302521d698Sbellard #define TARGET_SNDCTL_DSP_MAPOUTBUF       0x80085014
22312521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
22322521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
22332521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
22342521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
22352521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
22362521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
22372521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
22382521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
22392521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
22402521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
22412521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
22422521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
22432521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
22442521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
22452521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
22462521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
22472521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
22482521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
22492521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
22502521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
22512521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
22522521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
22532521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
22542521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
22552521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
22562521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
22572521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
22582521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
22592521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
22602521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
22612521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
22622521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
22632521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
22642521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
22652521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
22662521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
22672521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
22682521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
22692521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
22702521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
22712521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
22722521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
22732521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
22742521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
22752521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
22762521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
22772521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
22782521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
22792521d698Sbellard 
22802521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
22812521d698Sbellard 
22822521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
22832521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
22842521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
22852521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
22862521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
22872521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
22882521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
22892521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
22902521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
22912521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
22922521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
22932521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
22942521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
22952521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
22962521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
22972521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
22982521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
22992521d698Sbellard 
23002521d698Sbellard /* Obsolete macros */
23012521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
23022521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
23032521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
23042521d698Sbellard 
23052521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
23062521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
23072521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
23082521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
23092521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
23102521d698Sbellard 
23112521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
23122521d698Sbellard 
23132521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
23142521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
23152521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
23162521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
23172521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
23182521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
23192521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
23202521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
23212521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
23222521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
23232521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
23242521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
23252521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
23262521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
23272521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
23282521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
23292521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
23302521d698Sbellard 
23312521d698Sbellard /* Obsolete macros */
23322521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
23332521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
23342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
23352521d698Sbellard 
23362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
23372521d698Sbellard 
23382521d698Sbellard /* vfat ioctls */
23392521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
23402521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2341a5448a7dSbellard 
23428fbd6b52Sbalrog #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct mtop)
23438fbd6b52Sbalrog #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct mtget)
23448fbd6b52Sbalrog #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct mtpos)
23458fbd6b52Sbalrog 
2346a5448a7dSbellard struct target_sysinfo {
2347992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2348992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2349992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2350992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2351992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2352992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2353992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2354992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2355a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2356a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2357992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2358992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2359a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2360992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2361a5448a7dSbellard };
23623532fa74Sbellard 
23636556a833Saurel32 struct linux_dirent {
23646556a833Saurel32     long            d_ino;
23656556a833Saurel32     unsigned long   d_off;
23666556a833Saurel32     unsigned short  d_reclen;
23676556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
23686556a833Saurel32 };
23696556a833Saurel32 
23706556a833Saurel32 struct linux_dirent64 {
23716556a833Saurel32     uint64_t        d_ino;
23726556a833Saurel32     int64_t         d_off;
23736556a833Saurel32     unsigned short  d_reclen;
23746556a833Saurel32     unsigned char   d_type;
23756556a833Saurel32     char            d_name[256];
23766556a833Saurel32 };
23776556a833Saurel32 
237824e1003aSaurel32 struct target_mq_attr {
237924e1003aSaurel32     abi_long mq_flags;
238024e1003aSaurel32     abi_long mq_maxmsg;
238124e1003aSaurel32     abi_long mq_msgsize;
238224e1003aSaurel32     abi_long mq_curmsgs;
238324e1003aSaurel32 };
238424e1003aSaurel32 
23853532fa74Sbellard #include "socket.h"
2386637947f1Sths 
2387637947f1Sths #include "errno_defs.h"
238803dfe9f8SRiku Voipio 
238903dfe9f8SRiku Voipio #define FUTEX_WAIT              0
239003dfe9f8SRiku Voipio #define FUTEX_WAKE              1
239103dfe9f8SRiku Voipio #define FUTEX_FD                2
239203dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
239303dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
239403dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
239503dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
239603dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
239703dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
239803dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
239903dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
240003dfe9f8SRiku Voipio 
240103dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
240203dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
240303dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
240403dfe9f8SRiku Voipio 
24053b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
24063b6edd16SPeter Maydell typedef union target_epoll_data {
24073b6edd16SPeter Maydell     abi_ulong ptr;
24083b6edd16SPeter Maydell     abi_ulong fd;
24093b6edd16SPeter Maydell     uint32_t u32;
24103b6edd16SPeter Maydell     uint64_t u64;
24113b6edd16SPeter Maydell } target_epoll_data_t;
24123b6edd16SPeter Maydell 
24133b6edd16SPeter Maydell struct target_epoll_event {
24143b6edd16SPeter Maydell     uint32_t events;
24153b6edd16SPeter Maydell     target_epoll_data_t data;
24163b6edd16SPeter Maydell };
24173b6edd16SPeter Maydell #endif
2418163a05a8SPeter Maydell struct target_rlimit64 {
2419163a05a8SPeter Maydell     uint64_t rlim_cur;
2420163a05a8SPeter Maydell     uint64_t rlim_max;
2421163a05a8SPeter Maydell };
2422583359a6SAkos PASZTORY 
2423583359a6SAkos PASZTORY struct target_ucred {
2424583359a6SAkos PASZTORY     uint32_t pid;
2425583359a6SAkos PASZTORY     uint32_t uid;
2426583359a6SAkos PASZTORY     uint32_t gid;
2427583359a6SAkos PASZTORY };
2428