xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 541e1690420d293c1b09eeb128fac74e98cbef7a)
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 
7cb9c377fSPaolo Bonzini #ifndef SYSCALL_DEFS_H
81b3c4fdfSMarkus Armbruster #define SYSCALL_DEFS_H
9cb9c377fSPaolo Bonzini 
106180a181Sbellard #include "syscall_nr.h"
112521d698Sbellard 
12ff71a454SAleksandar Markovic 
13ff71a454SAleksandar Markovic /* socket operations for socketcall() */
14ff71a454SAleksandar Markovic #define TARGET_SYS_SOCKET       1         /* socket()              */
15ff71a454SAleksandar Markovic #define TARGET_SYS_BIND         2         /* bind()                */
16ff71a454SAleksandar Markovic #define TARGET_SYS_CONNECT      3         /* connect()             */
17ff71a454SAleksandar Markovic #define TARGET_SYS_LISTEN       4         /* listen()              */
18ff71a454SAleksandar Markovic #define TARGET_SYS_ACCEPT       5         /* accept()              */
19ff71a454SAleksandar Markovic #define TARGET_SYS_GETSOCKNAME  6         /* getsockname()         */
20ff71a454SAleksandar Markovic #define TARGET_SYS_GETPEERNAME  7         /* getpeername()         */
21ff71a454SAleksandar Markovic #define TARGET_SYS_SOCKETPAIR   8         /* socketpair()          */
22ff71a454SAleksandar Markovic #define TARGET_SYS_SEND         9         /* send()                */
23ff71a454SAleksandar Markovic #define TARGET_SYS_RECV         10        /* recv()                */
24ff71a454SAleksandar Markovic #define TARGET_SYS_SENDTO       11        /* sendto()              */
25ff71a454SAleksandar Markovic #define TARGET_SYS_RECVFROM     12        /* recvfrom()            */
26ff71a454SAleksandar Markovic #define TARGET_SYS_SHUTDOWN     13        /* shutdown()            */
27ff71a454SAleksandar Markovic #define TARGET_SYS_SETSOCKOPT   14        /* setsockopt()          */
28ff71a454SAleksandar Markovic #define TARGET_SYS_GETSOCKOPT   15        /* getsockopt()          */
29ff71a454SAleksandar Markovic #define TARGET_SYS_SENDMSG      16        /* sendmsg()             */
30ff71a454SAleksandar Markovic #define TARGET_SYS_RECVMSG      17        /* recvmsg()             */
31ff71a454SAleksandar Markovic #define TARGET_SYS_ACCEPT4      18        /* accept4()             */
32ff71a454SAleksandar Markovic #define TARGET_SYS_RECVMMSG     19        /* recvmmsg()            */
33ff71a454SAleksandar Markovic #define TARGET_SYS_SENDMMSG     20        /* sendmmsg()            */
3431e31b8aSbellard 
358853f86eSbellard #define IPCOP_semop		1
368853f86eSbellard #define IPCOP_semget		2
378853f86eSbellard #define IPCOP_semctl		3
388853f86eSbellard #define IPCOP_semtimedop	4
398853f86eSbellard #define IPCOP_msgsnd		11
408853f86eSbellard #define IPCOP_msgrcv		12
418853f86eSbellard #define IPCOP_msgget		13
428853f86eSbellard #define IPCOP_msgctl		14
438853f86eSbellard #define IPCOP_shmat		21
448853f86eSbellard #define IPCOP_shmdt		22
458853f86eSbellard #define IPCOP_shmget		23
468853f86eSbellard #define IPCOP_shmctl		24
478853f86eSbellard 
482521d698Sbellard /*
492521d698Sbellard  * The following is for compatibility across the various Linux
502521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
512521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
522521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
532521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
542521d698Sbellard  * below from now on.
552521d698Sbellard  */
562521d698Sbellard #define TARGET_IOC_NRBITS	8
572521d698Sbellard #define TARGET_IOC_TYPEBITS	8
582521d698Sbellard 
59716f3fbeSPeter Maydell #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
60716f3fbeSPeter Maydell     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
61cd98d390SAndreas Schwab     || defined(TARGET_SPARC) \
620c866a7eSRiku Voipio     || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
6374d753acSMika Westerberg     /* 16 bit uid wrappers emulation */
6474d753acSMika Westerberg #define USE_UID16
650c866a7eSRiku Voipio #define target_id uint16_t
660c866a7eSRiku Voipio #else
670c866a7eSRiku Voipio #define target_id uint32_t
6874d753acSMika Westerberg #endif
6974d753acSMika Westerberg 
70e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
71b16189b2SChen Gang     || defined(TARGET_M68K) || defined(TARGET_CRIS) \
72b16189b2SChen Gang     || defined(TARGET_UNICORE32) || defined(TARGET_S390X) \
73a0a839b6SMarek Vasut     || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
74a0a839b6SMarek Vasut     || defined(TARGET_NIOS2)
752521d698Sbellard 
762521d698Sbellard #define TARGET_IOC_SIZEBITS	14
772521d698Sbellard #define TARGET_IOC_DIRBITS	2
782521d698Sbellard 
792521d698Sbellard #define TARGET_IOC_NONE	  0U
802521d698Sbellard #define TARGET_IOC_WRITE  1U
812521d698Sbellard #define TARGET_IOC_READ	  2U
822521d698Sbellard 
83048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
84b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
85b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
862521d698Sbellard 
872521d698Sbellard #define TARGET_IOC_SIZEBITS	13
882521d698Sbellard #define TARGET_IOC_DIRBITS	3
892521d698Sbellard 
902521d698Sbellard #define TARGET_IOC_NONE	  1U
912521d698Sbellard #define TARGET_IOC_READ	  2U
922521d698Sbellard #define TARGET_IOC_WRITE  4U
932521d698Sbellard 
94a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
95a10d1e50SRichard Henderson 
96a10d1e50SRichard Henderson #define TARGET_IOC_SIZEBITS  14
97a10d1e50SRichard Henderson #define TARGET_IOC_DIRBITS    2
98a10d1e50SRichard Henderson 
99a10d1e50SRichard Henderson #define TARGET_IOC_NONE   0U
100a10d1e50SRichard Henderson #define TARGET_IOC_WRITE  2U
101a10d1e50SRichard Henderson #define TARGET_IOC_READ   1U
102a10d1e50SRichard Henderson 
1032521d698Sbellard #else
1042521d698Sbellard #error unsupported CPU
1052521d698Sbellard #endif
1062521d698Sbellard 
1072521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
1082521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
1092521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
1102521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
1112521d698Sbellard 
1122521d698Sbellard #define TARGET_IOC_NRSHIFT	0
1132521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
1142521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
1152521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
1162521d698Sbellard 
1172521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
1182521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
1192521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
1202521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1212521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1222521d698Sbellard 
1232521d698Sbellard /* used to create numbers */
1242521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1252521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1262521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1272521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1282521d698Sbellard 
1292521d698Sbellard /* the size is automatically computed for these defines */
1302521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1312521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1322521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1332521d698Sbellard 
1347854b056Sbellard struct target_sockaddr {
1357854b056Sbellard     uint16_t sa_family;
1367854b056Sbellard     uint8_t sa_data[14];
1377854b056Sbellard };
1387854b056Sbellard 
13933a29b51SJoakim Tjernlund struct target_sockaddr_ll {
14033a29b51SJoakim Tjernlund     uint16_t sll_family;   /* Always AF_PACKET */
14133a29b51SJoakim Tjernlund     uint16_t sll_protocol; /* Physical layer protocol */
14233a29b51SJoakim Tjernlund     int      sll_ifindex;  /* Interface number */
14333a29b51SJoakim Tjernlund     uint16_t sll_hatype;   /* ARP hardware type */
14433a29b51SJoakim Tjernlund     uint8_t  sll_pkttype;  /* Packet type */
14533a29b51SJoakim Tjernlund     uint8_t  sll_halen;    /* Length of address */
14633a29b51SJoakim Tjernlund     uint8_t  sll_addr[8];  /* Physical layer address */
14733a29b51SJoakim Tjernlund };
14833a29b51SJoakim Tjernlund 
149fb3aabf3SLaurent Vivier struct target_sockaddr_un {
150fb3aabf3SLaurent Vivier     uint16_t su_family;
151fb3aabf3SLaurent Vivier     uint8_t sun_path[108];
152fb3aabf3SLaurent Vivier };
153fb3aabf3SLaurent Vivier 
154fb3aabf3SLaurent Vivier struct target_in_addr {
155fb3aabf3SLaurent Vivier     uint32_t s_addr; /* big endian */
156fb3aabf3SLaurent Vivier };
157fb3aabf3SLaurent Vivier 
158fb3aabf3SLaurent Vivier struct target_sockaddr_in {
159fb3aabf3SLaurent Vivier   uint16_t sin_family;
160fb3aabf3SLaurent Vivier   int16_t sin_port; /* big endian */
161fb3aabf3SLaurent Vivier   struct target_in_addr sin_addr;
162fb3aabf3SLaurent Vivier   uint8_t __pad[sizeof(struct target_sockaddr) -
163fb3aabf3SLaurent Vivier                 sizeof(uint16_t) - sizeof(int16_t) -
164fb3aabf3SLaurent Vivier                 sizeof(struct target_in_addr)];
165fb3aabf3SLaurent Vivier };
166fb3aabf3SLaurent Vivier 
167ee1ac3a1SHelge Deller struct target_sockaddr_in6 {
168ee1ac3a1SHelge Deller     uint16_t sin6_family;
169ee1ac3a1SHelge Deller     uint16_t sin6_port; /* big endian */
170ee1ac3a1SHelge Deller     uint32_t sin6_flowinfo; /* big endian */
171ee1ac3a1SHelge Deller     struct in6_addr sin6_addr; /* IPv6 address, big endian */
172ee1ac3a1SHelge Deller     uint32_t sin6_scope_id;
173ee1ac3a1SHelge Deller };
174ee1ac3a1SHelge Deller 
175f57d4192SLaurent Vivier struct target_sock_filter {
176f57d4192SLaurent Vivier     abi_ushort code;
177f57d4192SLaurent Vivier     uint8_t jt;
178f57d4192SLaurent Vivier     uint8_t jf;
179f57d4192SLaurent Vivier     abi_uint k;
180f57d4192SLaurent Vivier };
181f57d4192SLaurent Vivier 
182f57d4192SLaurent Vivier struct target_sock_fprog {
183f57d4192SLaurent Vivier     abi_ushort len;
184f57d4192SLaurent Vivier     abi_ulong filter;
185f57d4192SLaurent Vivier };
186f57d4192SLaurent Vivier 
187b975b83bSLionel Landwerlin struct target_ip_mreq {
188b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
189b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
190b975b83bSLionel Landwerlin };
191b975b83bSLionel Landwerlin 
192b975b83bSLionel Landwerlin struct target_ip_mreqn {
193b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
194b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
195b975b83bSLionel Landwerlin     abi_long imr_ifindex;
196b975b83bSLionel Landwerlin };
197b975b83bSLionel Landwerlin 
1986e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
1996e3cb58fSLionel Landwerlin     /* big endian */
2006e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
2016e3cb58fSLionel Landwerlin     uint32_t imr_interface;
2026e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
2036e3cb58fSLionel Landwerlin };
2046e3cb58fSLionel Landwerlin 
20531e31b8aSbellard struct target_timeval {
206992f48a0Sblueswir1     abi_long tv_sec;
207992f48a0Sblueswir1     abi_long tv_usec;
20831e31b8aSbellard };
20931e31b8aSbellard 
2101b6b029eSbellard struct target_timespec {
211992f48a0Sblueswir1     abi_long tv_sec;
212992f48a0Sblueswir1     abi_long tv_nsec;
2131b6b029eSbellard };
2141b6b029eSbellard 
215ef4467e9SPaul Burton struct target_timezone {
216ef4467e9SPaul Burton     abi_int tz_minuteswest;
217ef4467e9SPaul Burton     abi_int tz_dsttime;
218ef4467e9SPaul Burton };
219ef4467e9SPaul Burton 
22066fb9763Sbellard struct target_itimerval {
22166fb9763Sbellard     struct target_timeval it_interval;
22266fb9763Sbellard     struct target_timeval it_value;
22366fb9763Sbellard };
22466fb9763Sbellard 
225905bba13SErik de Castro Lopo struct target_itimerspec {
226905bba13SErik de Castro Lopo     struct target_timespec it_interval;
227905bba13SErik de Castro Lopo     struct target_timespec it_value;
228905bba13SErik de Castro Lopo };
229905bba13SErik de Castro Lopo 
23019f59bceSAleksandar Markovic struct target_timex {
23119f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
23219f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
23319f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
23419f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
23519f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
23619f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
23719f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
23819f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
23919f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
24019f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
24119f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
24219f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
24319f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
24419f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
24519f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
24619f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
24719f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
24819f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
24919f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
25019f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
25119f59bceSAleksandar Markovic 
25219f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
25319f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
25419f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
25519f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
25619f59bceSAleksandar Markovic };
25719f59bceSAleksandar Markovic 
258c227f099SAnthony Liguori typedef abi_long target_clock_t;
25932f36bceSbellard 
260c596ed17Sbellard #define TARGET_HZ 100
261c596ed17Sbellard 
26232f36bceSbellard struct target_tms {
263c227f099SAnthony Liguori     target_clock_t tms_utime;
264c227f099SAnthony Liguori     target_clock_t tms_stime;
265c227f099SAnthony Liguori     target_clock_t tms_cutime;
266c227f099SAnthony Liguori     target_clock_t tms_cstime;
26732f36bceSbellard };
26832f36bceSbellard 
2696180a181Sbellard struct target_utimbuf {
270992f48a0Sblueswir1     abi_long actime;
271992f48a0Sblueswir1     abi_long modtime;
2726180a181Sbellard };
2736180a181Sbellard 
274f2674e31Sbellard struct target_sel_arg_struct {
275992f48a0Sblueswir1     abi_long n;
276992f48a0Sblueswir1     abi_long inp, outp, exp;
277992f48a0Sblueswir1     abi_long tvp;
278f2674e31Sbellard };
279f2674e31Sbellard 
28031e31b8aSbellard struct target_iovec {
281992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
282992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
28331e31b8aSbellard };
28431e31b8aSbellard 
2851a9353d2Sbellard struct target_msghdr {
286992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
2871a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
288992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
289992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
290992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
291992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
2921a9353d2Sbellard     unsigned int msg_flags;
2931a9353d2Sbellard };
2941a9353d2Sbellard 
2957854b056Sbellard struct target_cmsghdr {
296992f48a0Sblueswir1     abi_long     cmsg_len;
2977854b056Sbellard     int          cmsg_level;
2987854b056Sbellard     int          cmsg_type;
2997854b056Sbellard };
3007854b056Sbellard 
3017854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
302ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
303ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
304992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
305992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
3067854b056Sbellard #define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
3077854b056Sbellard                                + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
3087854b056Sbellard #define TARGET_CMSG_LEN(len)   (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
3097854b056Sbellard 
3107854b056Sbellard static __inline__ struct target_cmsghdr *
311ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
312ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
313ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3147854b056Sbellard {
3152b8bdefcSths   struct target_cmsghdr *__ptr;
3167854b056Sbellard 
3172b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
318cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
319ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
320ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3217854b056Sbellard     /* No more entries.  */
3222b8bdefcSths     return (struct target_cmsghdr *)0;
323ee104587SJonathan Neuschäfer   }
324ee104587SJonathan Neuschäfer   return __ptr;
3257854b056Sbellard }
3267854b056Sbellard 
327f19e00d7SAlexander Graf struct target_mmsghdr {
328f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
329f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
330f19e00d7SAlexander Graf };
3317854b056Sbellard 
33231e31b8aSbellard struct  target_rusage {
33331e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
33431e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
335992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
336992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
337992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
338992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
339992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
340992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
341992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
342992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
343992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
344992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
345992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
346992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
347992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
348992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
34931e31b8aSbellard };
35031e31b8aSbellard 
35131e31b8aSbellard typedef struct {
35231e31b8aSbellard         int     val[2];
353c227f099SAnthony Liguori } kernel_fsid_t;
35431e31b8aSbellard 
35572f03900Sbellard struct kernel_statfs {
35631e31b8aSbellard 	int f_type;
35731e31b8aSbellard 	int f_bsize;
35831e31b8aSbellard 	int f_blocks;
35931e31b8aSbellard 	int f_bfree;
36031e31b8aSbellard 	int f_bavail;
36131e31b8aSbellard 	int f_files;
36231e31b8aSbellard 	int f_ffree;
363c227f099SAnthony Liguori         kernel_fsid_t f_fsid;
36431e31b8aSbellard 	int f_namelen;
36531e31b8aSbellard 	int f_spare[6];
36631e31b8aSbellard };
36731e31b8aSbellard 
368dab2ed99Sbellard struct target_dirent {
369992f48a0Sblueswir1         abi_long        d_ino;
370992f48a0Sblueswir1         abi_long        d_off;
371dab2ed99Sbellard         unsigned short  d_reclen;
372333858b7SDmitry V. Levin         char            d_name[];
373dab2ed99Sbellard };
374dab2ed99Sbellard 
375dab2ed99Sbellard struct target_dirent64 {
376dab2ed99Sbellard 	uint64_t	d_ino;
377dab2ed99Sbellard 	int64_t		d_off;
378dab2ed99Sbellard 	unsigned short	d_reclen;
379dab2ed99Sbellard 	unsigned char	d_type;
380dab2ed99Sbellard 	char		d_name[256];
381dab2ed99Sbellard };
382dab2ed99Sbellard 
383dab2ed99Sbellard 
38431e31b8aSbellard /* mostly generic signal stuff */
385992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
386992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
387992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
38831e31b8aSbellard 
38931e31b8aSbellard #ifdef TARGET_MIPS
39031e31b8aSbellard #define TARGET_NSIG	   128
39131e31b8aSbellard #else
39231e31b8aSbellard #define TARGET_NSIG	   64
39331e31b8aSbellard #endif
394992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
39531e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
39631e31b8aSbellard 
39731e31b8aSbellard typedef struct {
398992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
399c227f099SAnthony Liguori } target_sigset_t;
40031e31b8aSbellard 
40166fb9763Sbellard #ifdef BSWAP_NEEDED
402c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
40366fb9763Sbellard {
40466fb9763Sbellard     int i;
40566fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
406cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
40766fb9763Sbellard }
40866fb9763Sbellard #else
409c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
41066fb9763Sbellard {
41166fb9763Sbellard     *d = *s;
41266fb9763Sbellard }
41366fb9763Sbellard #endif
41466fb9763Sbellard 
415c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
41666fb9763Sbellard {
41766fb9763Sbellard     int i;
41866fb9763Sbellard     d->sig[0] = set;
41966fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
42066fb9763Sbellard         d->sig[i] = 0;
42166fb9763Sbellard }
42266fb9763Sbellard 
423c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
424c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
425992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
42666fb9763Sbellard                                const sigset_t *sigset);
42766fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
428992f48a0Sblueswir1                                const abi_ulong *old_sigset);
42966fb9763Sbellard struct target_sigaction;
43066fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
43166fb9763Sbellard                  struct target_sigaction *oact);
43266fb9763Sbellard 
433d2fbca94SGuan Xuetao #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
434d2fbca94SGuan Xuetao     || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
435d2fbca94SGuan Xuetao     || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
436a4c075f1SUlrich Hecht     || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
437b16189b2SChen Gang     || defined(TARGET_S390X) || defined(TARGET_OPENRISC) \
438a0a839b6SMarek Vasut     || defined(TARGET_TILEGX) || defined(TARGET_HPPA) || defined(TARGET_NIOS2)
4392521d698Sbellard 
440048f6b4dSbellard #if defined(TARGET_SPARC)
441048f6b4dSbellard #define TARGET_SA_NOCLDSTOP    8u
442048f6b4dSbellard #define TARGET_SA_NOCLDWAIT    0x100u
443048f6b4dSbellard #define TARGET_SA_SIGINFO      0x200u
444048f6b4dSbellard #define TARGET_SA_ONSTACK      1u
445048f6b4dSbellard #define TARGET_SA_RESTART      2u
446048f6b4dSbellard #define TARGET_SA_NODEFER      0x20u
447048f6b4dSbellard #define TARGET_SA_RESETHAND    4u
4487f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
449048f6b4dSbellard #elif defined(TARGET_MIPS)
450048f6b4dSbellard #define TARGET_SA_NOCLDSTOP	0x00000001
451048f6b4dSbellard #define TARGET_SA_NOCLDWAIT	0x00010000
452048f6b4dSbellard #define TARGET_SA_SIGINFO	0x00000008
453048f6b4dSbellard #define TARGET_SA_ONSTACK	0x08000000
454048f6b4dSbellard #define TARGET_SA_NODEFER	0x40000000
455048f6b4dSbellard #define TARGET_SA_RESTART	0x10000000
456048f6b4dSbellard #define TARGET_SA_RESETHAND	0x80000000
457d26bc211Sths #if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
458d26bc211Sths #define TARGET_SA_RESTORER	0x04000000	/* Only for O32 */
459540635baSths #endif
460d962783eSJia Liu #elif defined(TARGET_OPENRISC)
461d962783eSJia Liu #define TARGET_SA_NOCLDSTOP    0x00000001
462d962783eSJia Liu #define TARGET_SA_NOCLDWAIT    0x00000002
463d962783eSJia Liu #define TARGET_SA_SIGINFO      0x00000004
464d962783eSJia Liu #define TARGET_SA_ONSTACK      0x08000000
465d962783eSJia Liu #define TARGET_SA_RESTART      0x10000000
466d962783eSJia Liu #define TARGET_SA_NODEFER      0x40000000
467d962783eSJia Liu #define TARGET_SA_RESETHAND    0x80000000
46857f18a95SRichard Henderson #elif defined(TARGET_ALPHA)
46957f18a95SRichard Henderson #define TARGET_SA_ONSTACK	0x00000001
47057f18a95SRichard Henderson #define TARGET_SA_RESTART	0x00000002
47157f18a95SRichard Henderson #define TARGET_SA_NOCLDSTOP	0x00000004
47257f18a95SRichard Henderson #define TARGET_SA_NODEFER	0x00000008
47357f18a95SRichard Henderson #define TARGET_SA_RESETHAND	0x00000010
47457f18a95SRichard Henderson #define TARGET_SA_NOCLDWAIT	0x00000020 /* not supported yet */
47557f18a95SRichard Henderson #define TARGET_SA_SIGINFO	0x00000040
4762da6e76cSHelge Deller #elif defined(TARGET_HPPA)
4772da6e76cSHelge Deller #define TARGET_SA_ONSTACK       0x00000001
4782da6e76cSHelge Deller #define TARGET_SA_RESETHAND     0x00000004
4792da6e76cSHelge Deller #define TARGET_SA_NOCLDSTOP     0x00000008
4802da6e76cSHelge Deller #define TARGET_SA_SIGINFO       0x00000010
4812da6e76cSHelge Deller #define TARGET_SA_NODEFER       0x00000020
4822da6e76cSHelge Deller #define TARGET_SA_RESTART       0x00000040
4832da6e76cSHelge Deller #define TARGET_SA_NOCLDWAIT     0x00000080
484048f6b4dSbellard #else
4852521d698Sbellard #define TARGET_SA_NOCLDSTOP	0x00000001
4862521d698Sbellard #define TARGET_SA_NOCLDWAIT	0x00000002 /* not supported yet */
4872521d698Sbellard #define TARGET_SA_SIGINFO	0x00000004
4882521d698Sbellard #define TARGET_SA_ONSTACK	0x08000000
4892521d698Sbellard #define TARGET_SA_RESTART	0x10000000
4902521d698Sbellard #define TARGET_SA_NODEFER	0x40000000
4912521d698Sbellard #define TARGET_SA_RESETHAND	0x80000000
4922521d698Sbellard #define TARGET_SA_RESTORER	0x04000000
4936d5e216dSbellard #endif
4946d5e216dSbellard 
4957f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
4967f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
4977f047de1SRichard Henderson #endif
4987f047de1SRichard Henderson 
499d0f20495SRichard Henderson #if defined(TARGET_ALPHA)
500d0f20495SRichard Henderson 
501d0f20495SRichard Henderson #define TARGET_SIGHUP            1
502d0f20495SRichard Henderson #define TARGET_SIGINT            2
503d0f20495SRichard Henderson #define TARGET_SIGQUIT           3
504d0f20495SRichard Henderson #define TARGET_SIGILL            4
505d0f20495SRichard Henderson #define TARGET_SIGTRAP           5
506d0f20495SRichard Henderson #define TARGET_SIGABRT           6
507d0f20495SRichard Henderson #define TARGET_SIGSTKFLT         7 /* actually SIGEMT */
508d0f20495SRichard Henderson #define TARGET_SIGFPE            8
509d0f20495SRichard Henderson #define TARGET_SIGKILL           9
510d0f20495SRichard Henderson #define TARGET_SIGBUS           10
511d0f20495SRichard Henderson #define TARGET_SIGSEGV          11
512d0f20495SRichard Henderson #define TARGET_SIGSYS           12
513d0f20495SRichard Henderson #define TARGET_SIGPIPE          13
514d0f20495SRichard Henderson #define TARGET_SIGALRM          14
515d0f20495SRichard Henderson #define TARGET_SIGTERM          15
516d0f20495SRichard Henderson #define TARGET_SIGURG           16
517d0f20495SRichard Henderson #define TARGET_SIGSTOP          17
518d0f20495SRichard Henderson #define TARGET_SIGTSTP          18
519d0f20495SRichard Henderson #define TARGET_SIGCONT          19
520d0f20495SRichard Henderson #define TARGET_SIGCHLD          20
521d0f20495SRichard Henderson #define TARGET_SIGTTIN          21
522d0f20495SRichard Henderson #define TARGET_SIGTTOU          22
523d0f20495SRichard Henderson #define TARGET_SIGIO            23
524d0f20495SRichard Henderson #define TARGET_SIGXCPU          24
525d0f20495SRichard Henderson #define TARGET_SIGXFSZ          25
526d0f20495SRichard Henderson #define TARGET_SIGVTALRM        26
527d0f20495SRichard Henderson #define TARGET_SIGPROF          27
528d0f20495SRichard Henderson #define TARGET_SIGWINCH         28
529d0f20495SRichard Henderson #define TARGET_SIGPWR           29 /* actually SIGINFO */
530d0f20495SRichard Henderson #define TARGET_SIGUSR1          30
531d0f20495SRichard Henderson #define TARGET_SIGUSR2          31
532d0f20495SRichard Henderson #define TARGET_SIGRTMIN         32
533d0f20495SRichard Henderson 
534d0f20495SRichard Henderson #define TARGET_SIG_BLOCK         1
535d0f20495SRichard Henderson #define TARGET_SIG_UNBLOCK       2
536d0f20495SRichard Henderson #define TARGET_SIG_SETMASK       3
537d0f20495SRichard Henderson 
538d0f20495SRichard Henderson #elif defined(TARGET_SPARC)
5396d5e216dSbellard 
5406d5e216dSbellard #define TARGET_SIGHUP		 1
5416d5e216dSbellard #define TARGET_SIGINT		 2
5426d5e216dSbellard #define TARGET_SIGQUIT		 3
5436d5e216dSbellard #define TARGET_SIGILL		 4
5446d5e216dSbellard #define TARGET_SIGTRAP		 5
5456d5e216dSbellard #define TARGET_SIGABRT		 6
5466d5e216dSbellard #define TARGET_SIGIOT		 6
5476d5e216dSbellard #define TARGET_SIGSTKFLT	 7 /* actually EMT */
5486d5e216dSbellard #define TARGET_SIGFPE		 8
5496d5e216dSbellard #define TARGET_SIGKILL		 9
5506d5e216dSbellard #define TARGET_SIGBUS		10
5516d5e216dSbellard #define TARGET_SIGSEGV		11
5526d5e216dSbellard #define TARGET_SIGSYS		12
5536d5e216dSbellard #define TARGET_SIGPIPE		13
5546d5e216dSbellard #define TARGET_SIGALRM		14
5556d5e216dSbellard #define TARGET_SIGTERM		15
5566d5e216dSbellard #define TARGET_SIGURG		16
5576d5e216dSbellard #define TARGET_SIGSTOP		17
5586d5e216dSbellard #define TARGET_SIGTSTP		18
5596d5e216dSbellard #define TARGET_SIGCONT		19
5606d5e216dSbellard #define TARGET_SIGCHLD		20
5616d5e216dSbellard #define TARGET_SIGTTIN		21
5626d5e216dSbellard #define TARGET_SIGTTOU		22
5636d5e216dSbellard #define TARGET_SIGIO		23
5646d5e216dSbellard #define TARGET_SIGXCPU		24
5656d5e216dSbellard #define TARGET_SIGXFSZ		25
5666d5e216dSbellard #define TARGET_SIGVTALRM	26
5676d5e216dSbellard #define TARGET_SIGPROF		27
5686d5e216dSbellard #define TARGET_SIGWINCH	        28
5696d5e216dSbellard #define TARGET_SIGPWR		29
5706d5e216dSbellard #define TARGET_SIGUSR1		30
5716d5e216dSbellard #define TARGET_SIGUSR2		31
5726d5e216dSbellard #define TARGET_SIGRTMIN         32
5736d5e216dSbellard 
5746d5e216dSbellard #define TARGET_SIG_BLOCK          0x01 /* for blocking signals */
5756d5e216dSbellard #define TARGET_SIG_UNBLOCK        0x02 /* for unblocking signals */
5766d5e216dSbellard #define TARGET_SIG_SETMASK        0x04 /* for setting the signal mask */
5776d5e216dSbellard 
578048f6b4dSbellard #elif defined(TARGET_MIPS)
579048f6b4dSbellard 
580048f6b4dSbellard #define TARGET_SIGHUP		 1	/* Hangup (POSIX).  */
581048f6b4dSbellard #define TARGET_SIGINT		 2	/* Interrupt (ANSI).  */
582048f6b4dSbellard #define TARGET_SIGQUIT		 3	/* Quit (POSIX).  */
583048f6b4dSbellard #define TARGET_SIGILL		 4	/* Illegal instruction (ANSI).  */
584048f6b4dSbellard #define TARGET_SIGTRAP		 5	/* Trace trap (POSIX).  */
585048f6b4dSbellard #define TARGET_SIGIOT		 6	/* IOT trap (4.2 BSD).  */
586048f6b4dSbellard #define TARGET_SIGABRT		 TARGET_SIGIOT	/* Abort (ANSI).  */
587048f6b4dSbellard #define TARGET_SIGEMT		 7
588048f6b4dSbellard #define TARGET_SIGSTKFLT	 7 /* XXX: incorrect */
589048f6b4dSbellard #define TARGET_SIGFPE		 8	/* Floating-point exception (ANSI).  */
590048f6b4dSbellard #define TARGET_SIGKILL		 9	/* Kill, unblockable (POSIX).  */
591048f6b4dSbellard #define TARGET_SIGBUS		10	/* BUS error (4.2 BSD).  */
592048f6b4dSbellard #define TARGET_SIGSEGV		11	/* Segmentation violation (ANSI).  */
593048f6b4dSbellard #define TARGET_SIGSYS		12
594048f6b4dSbellard #define TARGET_SIGPIPE		13	/* Broken pipe (POSIX).  */
595048f6b4dSbellard #define TARGET_SIGALRM		14	/* Alarm clock (POSIX).  */
596048f6b4dSbellard #define TARGET_SIGTERM		15	/* Termination (ANSI).  */
597048f6b4dSbellard #define TARGET_SIGUSR1		16	/* User-defined signal 1 (POSIX).  */
598048f6b4dSbellard #define TARGET_SIGUSR2		17	/* User-defined signal 2 (POSIX).  */
599048f6b4dSbellard #define TARGET_SIGCHLD		18	/* Child status has changed (POSIX).  */
600048f6b4dSbellard #define TARGET_SIGCLD		TARGET_SIGCHLD	/* Same as TARGET_SIGCHLD (System V).  */
601048f6b4dSbellard #define TARGET_SIGPWR		19	/* Power failure restart (System V).  */
602048f6b4dSbellard #define TARGET_SIGWINCH	20	/* Window size change (4.3 BSD, Sun).  */
603048f6b4dSbellard #define TARGET_SIGURG		21	/* Urgent condition on socket (4.2 BSD).  */
604048f6b4dSbellard #define TARGET_SIGIO		22	/* I/O now possible (4.2 BSD).  */
605048f6b4dSbellard #define TARGET_SIGPOLL		TARGET_SIGIO	/* Pollable event occurred (System V).  */
606048f6b4dSbellard #define TARGET_SIGSTOP		23	/* Stop, unblockable (POSIX).  */
607048f6b4dSbellard #define TARGET_SIGTSTP		24	/* Keyboard stop (POSIX).  */
608048f6b4dSbellard #define TARGET_SIGCONT		25	/* Continue (POSIX).  */
609048f6b4dSbellard #define TARGET_SIGTTIN		26	/* Background read from tty (POSIX).  */
610048f6b4dSbellard #define TARGET_SIGTTOU		27	/* Background write to tty (POSIX).  */
611048f6b4dSbellard #define TARGET_SIGVTALRM	28	/* Virtual alarm clock (4.2 BSD).  */
612048f6b4dSbellard #define TARGET_SIGPROF		29	/* Profiling alarm clock (4.2 BSD).  */
613048f6b4dSbellard #define TARGET_SIGXCPU		30	/* CPU limit exceeded (4.2 BSD).  */
614048f6b4dSbellard #define TARGET_SIGXFSZ		31	/* File size limit exceeded (4.2 BSD).  */
615048f6b4dSbellard #define TARGET_SIGRTMIN         32
616048f6b4dSbellard 
617048f6b4dSbellard #define TARGET_SIG_BLOCK	1	/* for blocking signals */
618048f6b4dSbellard #define TARGET_SIG_UNBLOCK	2	/* for unblocking signals */
619048f6b4dSbellard #define TARGET_SIG_SETMASK	3	/* for setting the signal mask */
620048f6b4dSbellard 
621a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
622a10d1e50SRichard Henderson 
623a10d1e50SRichard Henderson #define TARGET_SIGHUP           1
624a10d1e50SRichard Henderson #define TARGET_SIGINT           2
625a10d1e50SRichard Henderson #define TARGET_SIGQUIT          3
626a10d1e50SRichard Henderson #define TARGET_SIGILL           4
627a10d1e50SRichard Henderson #define TARGET_SIGTRAP          5
628a10d1e50SRichard Henderson #define TARGET_SIGABRT          6
629a10d1e50SRichard Henderson #define TARGET_SIGIOT           6
630a10d1e50SRichard Henderson #define TARGET_SIGSTKFLT        7
631a10d1e50SRichard Henderson #define TARGET_SIGFPE           8
632a10d1e50SRichard Henderson #define TARGET_SIGKILL          9
633a10d1e50SRichard Henderson #define TARGET_SIGBUS          10
634a10d1e50SRichard Henderson #define TARGET_SIGSEGV         11
635a10d1e50SRichard Henderson #define TARGET_SIGXCPU         12
636a10d1e50SRichard Henderson #define TARGET_SIGPIPE         13
637a10d1e50SRichard Henderson #define TARGET_SIGALRM         14
638a10d1e50SRichard Henderson #define TARGET_SIGTERM         15
639a10d1e50SRichard Henderson #define TARGET_SIGUSR1         16
640a10d1e50SRichard Henderson #define TARGET_SIGUSR2         17
641a10d1e50SRichard Henderson #define TARGET_SIGCHLD         18
642a10d1e50SRichard Henderson #define TARGET_SIGPWR          19
643a10d1e50SRichard Henderson #define TARGET_SIGVTALRM       20
644a10d1e50SRichard Henderson #define TARGET_SIGPROF         21
645a10d1e50SRichard Henderson #define TARGET_SIGIO           22
646a10d1e50SRichard Henderson #define TARGET_SIGPOLL         TARGET_SIGIO
647a10d1e50SRichard Henderson #define TARGET_SIGWINCH        23
648a10d1e50SRichard Henderson #define TARGET_SIGSTOP         24
649a10d1e50SRichard Henderson #define TARGET_SIGTSTP         25
650a10d1e50SRichard Henderson #define TARGET_SIGCONT         26
651a10d1e50SRichard Henderson #define TARGET_SIGTTIN         27
652a10d1e50SRichard Henderson #define TARGET_SIGTTOU         28
653a10d1e50SRichard Henderson #define TARGET_SIGURG          29
654a10d1e50SRichard Henderson #define TARGET_SIGXFSZ         30
655a10d1e50SRichard Henderson #define TARGET_SIGSYS          31
656a10d1e50SRichard Henderson 
657a10d1e50SRichard Henderson #define TARGET_SIG_BLOCK       0
658a10d1e50SRichard Henderson #define TARGET_SIG_UNBLOCK     1
659a10d1e50SRichard Henderson #define TARGET_SIG_SETMASK     2
660a10d1e50SRichard Henderson 
6616d5e216dSbellard #else
6622521d698Sbellard 
663d962783eSJia Liu /* OpenRISC Using the general signals */
6642521d698Sbellard #define TARGET_SIGHUP		 1
6652521d698Sbellard #define TARGET_SIGINT		 2
6662521d698Sbellard #define TARGET_SIGQUIT		 3
6672521d698Sbellard #define TARGET_SIGILL		 4
6682521d698Sbellard #define TARGET_SIGTRAP		 5
6692521d698Sbellard #define TARGET_SIGABRT		 6
6702521d698Sbellard #define TARGET_SIGIOT		 6
6712521d698Sbellard #define TARGET_SIGBUS		 7
6722521d698Sbellard #define TARGET_SIGFPE		 8
6732521d698Sbellard #define TARGET_SIGKILL		 9
6742521d698Sbellard #define TARGET_SIGUSR1		10
6752521d698Sbellard #define TARGET_SIGSEGV		11
6762521d698Sbellard #define TARGET_SIGUSR2		12
6772521d698Sbellard #define TARGET_SIGPIPE		13
6782521d698Sbellard #define TARGET_SIGALRM		14
6792521d698Sbellard #define TARGET_SIGTERM		15
6802521d698Sbellard #define TARGET_SIGSTKFLT	16
6812521d698Sbellard #define TARGET_SIGCHLD		17
6822521d698Sbellard #define TARGET_SIGCONT		18
6832521d698Sbellard #define TARGET_SIGSTOP		19
6842521d698Sbellard #define TARGET_SIGTSTP		20
6852521d698Sbellard #define TARGET_SIGTTIN		21
6862521d698Sbellard #define TARGET_SIGTTOU		22
6872521d698Sbellard #define TARGET_SIGURG		23
6882521d698Sbellard #define TARGET_SIGXCPU		24
6892521d698Sbellard #define TARGET_SIGXFSZ		25
6902521d698Sbellard #define TARGET_SIGVTALRM	26
6912521d698Sbellard #define TARGET_SIGPROF		27
6922521d698Sbellard #define TARGET_SIGWINCH	        28
6932521d698Sbellard #define TARGET_SIGIO		29
694c596ed17Sbellard #define TARGET_SIGPWR		30
695c596ed17Sbellard #define TARGET_SIGSYS		31
6962521d698Sbellard #define TARGET_SIGRTMIN         32
6972521d698Sbellard 
6982521d698Sbellard #define TARGET_SIG_BLOCK          0    /* for blocking signals */
6992521d698Sbellard #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
7002521d698Sbellard #define TARGET_SIG_SETMASK        2    /* for setting the signal mask */
7012521d698Sbellard 
7026d5e216dSbellard #endif
7036d5e216dSbellard 
7046049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
7056049f4f8SRichard Henderson struct target_old_sigaction {
7066049f4f8SRichard Henderson     abi_ulong _sa_handler;
7076049f4f8SRichard Henderson     abi_ulong sa_mask;
708d2565875SRichard Henderson     int32_t sa_flags;
7096049f4f8SRichard Henderson };
710106ec879Sbellard 
7116049f4f8SRichard Henderson struct target_rt_sigaction {
7126049f4f8SRichard Henderson     abi_ulong _sa_handler;
7136049f4f8SRichard Henderson     abi_ulong sa_flags;
7146049f4f8SRichard Henderson     target_sigset_t sa_mask;
7156049f4f8SRichard Henderson };
7166049f4f8SRichard Henderson 
7176049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
7186049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
7196049f4f8SRichard Henderson struct target_sigaction {
7206049f4f8SRichard Henderson     abi_ulong _sa_handler;
7216049f4f8SRichard Henderson     abi_ulong sa_flags;
7226049f4f8SRichard Henderson     target_sigset_t sa_mask;
7236049f4f8SRichard Henderson     abi_ulong sa_restorer;
7246049f4f8SRichard Henderson };
7256049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
726106ec879Sbellard struct target_sigaction {
727540635baSths 	uint32_t	sa_flags;
728d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
729540635baSths 	uint32_t	_sa_handler;
730540635baSths #else
731992f48a0Sblueswir1 	abi_ulong	_sa_handler;
732540635baSths #endif
733c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
7347f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
7357f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
7367f047de1SRichard Henderson         abi_ulong sa_restorer;
7377f047de1SRichard Henderson #endif
738106ec879Sbellard };
739106ec879Sbellard #else
7402521d698Sbellard struct target_old_sigaction {
741992f48a0Sblueswir1         abi_ulong _sa_handler;
742992f48a0Sblueswir1         abi_ulong sa_mask;
743992f48a0Sblueswir1         abi_ulong sa_flags;
7447f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
745992f48a0Sblueswir1         abi_ulong sa_restorer;
7467f047de1SRichard Henderson #endif
7472521d698Sbellard };
7482521d698Sbellard 
7492521d698Sbellard struct target_sigaction {
750992f48a0Sblueswir1         abi_ulong _sa_handler;
751992f48a0Sblueswir1         abi_ulong sa_flags;
7527f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
753992f48a0Sblueswir1         abi_ulong sa_restorer;
7547f047de1SRichard Henderson #endif
755c227f099SAnthony Liguori         target_sigset_t sa_mask;
7562521d698Sbellard };
757106ec879Sbellard #endif
7582521d698Sbellard 
7592521d698Sbellard typedef union target_sigval {
7602521d698Sbellard 	int sival_int;
761992f48a0Sblueswir1         abi_ulong sival_ptr;
762c227f099SAnthony Liguori } target_sigval_t;
7636d5e216dSbellard #if 0
7646d5e216dSbellard #if defined (TARGET_SPARC)
7656d5e216dSbellard typedef struct {
7666d5e216dSbellard 	struct {
767992f48a0Sblueswir1 		abi_ulong psr;
768992f48a0Sblueswir1 		abi_ulong pc;
769992f48a0Sblueswir1 		abi_ulong npc;
770992f48a0Sblueswir1 		abi_ulong y;
771992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
7726d5e216dSbellard 	}		si_regs;
7736d5e216dSbellard 	int		si_mask;
7746d5e216dSbellard } __siginfo_t;
7756d5e216dSbellard 
7766d5e216dSbellard typedef struct {
7776d5e216dSbellard 	unsigned   long si_float_regs [32];
7786d5e216dSbellard 	unsigned   long si_fsr;
7796d5e216dSbellard 	unsigned   long si_fpqdepth;
7806d5e216dSbellard 	struct {
7816d5e216dSbellard 		unsigned long *insn_addr;
7826d5e216dSbellard 		unsigned long insn;
7836d5e216dSbellard 	} si_fpqueue [16];
7846d5e216dSbellard } __siginfo_fpu_t;
7856d5e216dSbellard #endif
7866d5e216dSbellard #endif
7872521d698Sbellard 
7882521d698Sbellard #define TARGET_SI_MAX_SIZE	128
789aa5e03d2SMaxim Ostapenko 
790aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
791aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
792aa5e03d2SMaxim Ostapenko #else
793aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
794aa5e03d2SMaxim Ostapenko #endif
795aa5e03d2SMaxim Ostapenko 
796aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
7972521d698Sbellard 
798a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
799a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
800a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
801a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
802a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
803a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
804a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
805a70dadc7SPeter Maydell  */
806a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
807a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
808a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
809a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
810a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
811a70dadc7SPeter Maydell #define QEMU_SI_RT 5
812a70dadc7SPeter Maydell 
8132521d698Sbellard typedef struct target_siginfo {
8143f53d546Spbrook #ifdef TARGET_MIPS
8153f53d546Spbrook 	int si_signo;
8163f53d546Spbrook 	int si_code;
8173f53d546Spbrook 	int si_errno;
8183f53d546Spbrook #else
8192521d698Sbellard 	int si_signo;
8202521d698Sbellard 	int si_errno;
8212521d698Sbellard 	int si_code;
8223f53d546Spbrook #endif
8232521d698Sbellard 
8242521d698Sbellard 	union {
8252521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
8262521d698Sbellard 
8272521d698Sbellard 		/* kill() */
8282521d698Sbellard 		struct {
8292521d698Sbellard 			pid_t _pid;		/* sender's pid */
8302521d698Sbellard 			uid_t _uid;		/* sender's uid */
8312521d698Sbellard 		} _kill;
8322521d698Sbellard 
8332521d698Sbellard 		/* POSIX.1b timers */
8342521d698Sbellard 		struct {
8352521d698Sbellard 			unsigned int _timer1;
8362521d698Sbellard 			unsigned int _timer2;
8372521d698Sbellard 		} _timer;
8382521d698Sbellard 
8392521d698Sbellard 		/* POSIX.1b signals */
8402521d698Sbellard 		struct {
8412521d698Sbellard 			pid_t _pid;		/* sender's pid */
8422521d698Sbellard 			uid_t _uid;		/* sender's uid */
843c227f099SAnthony Liguori 			target_sigval_t _sigval;
8442521d698Sbellard 		} _rt;
8452521d698Sbellard 
8462521d698Sbellard 		/* SIGCHLD */
8472521d698Sbellard 		struct {
8482521d698Sbellard 			pid_t _pid;		/* which child */
8492521d698Sbellard 			uid_t _uid;		/* sender's uid */
8502521d698Sbellard 			int _status;		/* exit code */
851c227f099SAnthony Liguori 			target_clock_t _utime;
852c227f099SAnthony Liguori                         target_clock_t _stime;
8532521d698Sbellard 		} _sigchld;
8542521d698Sbellard 
8552521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
8562521d698Sbellard 		struct {
857992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
8582521d698Sbellard 		} _sigfault;
8592521d698Sbellard 
8602521d698Sbellard 		/* SIGPOLL */
8612521d698Sbellard 		struct {
8622521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
8632521d698Sbellard 			int _fd;
8642521d698Sbellard 		} _sigpoll;
8652521d698Sbellard 	} _sifields;
866c227f099SAnthony Liguori } target_siginfo_t;
8672521d698Sbellard 
8682521d698Sbellard /*
8692521d698Sbellard  * si_code values
8702521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
8712521d698Sbellard  */
8722521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
8732521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
8742521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
8752521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
8762521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
8772521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
8782521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
8792521d698Sbellard 
8802521d698Sbellard /*
8812521d698Sbellard  * SIGILL si_codes
8822521d698Sbellard  */
883ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
8842521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
885ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
886ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
887ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
888ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
889ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
890ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
891de2fdd56SChen Gang #ifdef TARGET_TILEGX
892de2fdd56SChen Gang #define TARGET_ILL_DBLFLT       (9)     /* double fault */
893de2fdd56SChen Gang #define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
894de2fdd56SChen Gang #endif
8952521d698Sbellard 
8962521d698Sbellard /*
8972521d698Sbellard  * SIGFPE si_codes
8982521d698Sbellard  */
8992521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
9002521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
9012521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
9022521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
9032521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
9042521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
9052521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
9062521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
9072521d698Sbellard #define TARGET_NSIGFPE         8
9082521d698Sbellard 
9092521d698Sbellard /*
9102521d698Sbellard  * SIGSEGV si_codes
9112521d698Sbellard  */
9122521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
9132521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
914de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
9152521d698Sbellard 
9162521d698Sbellard /*
917ffa65c3bSbellard  * SIGBUS si_codes
918ffa65c3bSbellard  */
919ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
920b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
921ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
922de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
923de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
924de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
925de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
926ffa65c3bSbellard 
927ffa65c3bSbellard /*
9282521d698Sbellard  * SIGTRAP si_codes
9292521d698Sbellard  */
9302521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
9312521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
932de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
933de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
9342521d698Sbellard 
9352521d698Sbellard #endif /* defined(TARGET_I386) || defined(TARGET_ARM) */
9362521d698Sbellard 
9379de5e440Sbellard struct target_rlimit {
938992f48a0Sblueswir1         abi_ulong   rlim_cur;
939992f48a0Sblueswir1         abi_ulong   rlim_max;
9409de5e440Sbellard };
9419de5e440Sbellard 
94281bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
943e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
9446cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
94581bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
94681bbe906Stakasi-y@ops.dti.ne.jp #else
94726b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
94881bbe906Stakasi-y@ops.dti.ne.jp #endif
94981bbe906Stakasi-y@ops.dti.ne.jp 
950e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
951e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
952e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
953e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
954e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
955e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
956e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
957e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
958e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
959e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
960e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
961e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
962e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
963e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
964e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
965e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
966e22b7015SWesley W. Terpstra #else
967e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
968e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
969e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
970e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
971e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
972e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
9736cafd027SMatthias Braun #if defined(TARGET_SPARC)
9746cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
9756cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
9766cafd027SMatthias Braun #else
977e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
978e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
9796cafd027SMatthias Braun #endif
980e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
981e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
982e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
983e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
984e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
985e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
986e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
987e22b7015SWesley W. Terpstra #endif
988e22b7015SWesley W. Terpstra 
9899de5e440Sbellard struct target_pollfd {
9909de5e440Sbellard     int fd;           /* file descriptor */
9919de5e440Sbellard     short events;     /* requested events */
9929de5e440Sbellard     short revents;    /* returned events */
9939de5e440Sbellard };
9949de5e440Sbellard 
9958e5a0667Sbellard /* virtual terminal ioctls */
9960221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
9970221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
9988e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
999f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
1000f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
1001f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
10020221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
10030221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
1004e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
1005e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
1006e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
1007e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
1008ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
10098e5a0667Sbellard 
1010e1be1606SAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4)
1011e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
1012405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
1013e1be1606SAleksandar Markovic #else
10142521d698Sbellard #define TARGET_SIOCATMARK      0x8905
1015405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
1016e1be1606SAleksandar Markovic #endif
1017405b4915SHelge Deller #define TARGET_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
1018405b4915SHelge Deller #define TARGET_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
10192521d698Sbellard 
102031e31b8aSbellard /* Networking ioctls */
102131e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
102231e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
102331e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
102431e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
102531e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
102631e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
102731e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
102831e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
102931e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
103031e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
103131e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
103231e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
103331e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
103431e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
103531e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
103631e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
103731e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
103831e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
103931e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
104031e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
104131e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
104231e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
104331e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
104431e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
104531e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
104631e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
104731e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
104831e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
104931e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
1050f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
105131e31b8aSbellard 
105231e31b8aSbellard /* Bridging control calls */
105331e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
105431e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
105531e31b8aSbellard 
105631e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
105731e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
105831e31b8aSbellard 
105931e31b8aSbellard /* ARP cache control calls. */
106031e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
106131e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
106231e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
106331e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
106431e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
106531e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
106631e31b8aSbellard 
106731e31b8aSbellard /* RARP cache control calls. */
106831e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
106931e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
107031e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
107131e31b8aSbellard 
107231e31b8aSbellard /* Driver configuration calls */
107331e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
107431e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
107531e31b8aSbellard 
107631e31b8aSbellard /* DLCI configuration calls */
107731e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
107831e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
107931e31b8aSbellard 
108086fcd946SLaurent Vivier /* From <linux/wireless.h> */
108186fcd946SLaurent Vivier 
108286fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
108331e31b8aSbellard 
1084d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
1085d6d6d6feSMarco A L Barbosa 
1086d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
1087d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
1088d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
1089d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
1090d6d6d6feSMarco A L Barbosa 
109131e31b8aSbellard /* From <linux/fs.h> */
109231e31b8aSbellard 
109331e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
109431e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
109531e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
109631e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
109731e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
109831e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
109931e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
110031e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
110131e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
110231e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
110331e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
110431e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
1105fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
110631e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
1107c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
1108c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
1109edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
1110edafea13SAlexander Graf                                              /* return device size in bytes
1111edafea13SAlexander Graf                                                 (u64 *arg) */
11124715856aSPeter Maydell 
11134715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
11144715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
11154715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
11164715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
11174715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
11184715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
11194715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
11204715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
11214715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
11224715856aSPeter Maydell 
112331e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
112431e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
112521992cb6SHelge Deller 
112621992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
112721992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
112821992cb6SHelge Deller 
112960807231SPeter Maydell /* Note that the ioctl numbers claim type "long" but the actual type
113060807231SPeter Maydell  * used by the kernel is "int".
113160807231SPeter Maydell  */
11321847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
11331847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
113460807231SPeter Maydell 
1135285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
113631e31b8aSbellard 
113731e31b8aSbellard /* cdrom commands */
113831e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
113931e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
114031e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
114131e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
114231e31b8aSbellard                                            (struct cdrom_ti) */
114331e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
114431e31b8aSbellard                                            (struct cdrom_tochdr) */
114531e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
114631e31b8aSbellard                                            (struct cdrom_tocentry) */
114731e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
114831e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
114931e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
115031e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
115131e31b8aSbellard                                            (struct cdrom_volctrl) */
115231e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
115331e31b8aSbellard                                            (struct cdrom_subchnl) */
115431e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
115531e31b8aSbellard                                            (struct cdrom_read) */
115631e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
115731e31b8aSbellard                                            (struct cdrom_read) */
115831e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
115931e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
116031e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
116131e31b8aSbellard                                            address of multi session disks
116231e31b8aSbellard                                            (struct cdrom_multisession) */
116331e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
116431e31b8aSbellard                                            if available (struct cdrom_mcn) */
116567cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
1166b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
116731e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
116831e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
116931e31b8aSbellard                                           (struct cdrom_volctrl) */
117031e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
117131e31b8aSbellard                                            (struct cdrom_read) */
117231e31b8aSbellard /*
117331e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
117431e31b8aSbellard  */
117531e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
117631e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
117731e31b8aSbellard 
117831e31b8aSbellard /*
117931e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
118031e31b8aSbellard    It is for playing audio in logical block addressing mode.
118131e31b8aSbellard  */
118231e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
118331e31b8aSbellard 
118431e31b8aSbellard /*
118531e31b8aSbellard  * These ioctls are only used in optcd.c
118631e31b8aSbellard  */
118731e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
118831e31b8aSbellard 
118931e31b8aSbellard /*
119031e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
119131e31b8aSbellard  * drive spindown time.  They should be implemented in the
119231e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
119331e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
119431e31b8aSbellard  *  -Erik
119531e31b8aSbellard  */
119631e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
119731e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
119831e31b8aSbellard 
119931e31b8aSbellard /*
120031e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
120131e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
120231e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
120331e31b8aSbellard  */
120431e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
120531e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
120631e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
120731e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
120831e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
120931e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
121031e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
121131e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
121231e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
121331e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
121431e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
121531e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
121631e31b8aSbellard 
121731e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
121831e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
121931e31b8aSbellard  */
122031e31b8aSbellard 
122131e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
122231e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
122331e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
122431e31b8aSbellard 
122531e31b8aSbellard /* DVD-ROM Specific ioctls */
122631e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
122731e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
122831e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
122931e31b8aSbellard 
123031e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
123131e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
123231e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
123331e31b8aSbellard 
123431e31b8aSbellard /* HD commands */
123531e31b8aSbellard 
123631e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
123731e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
123831e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
123931e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
124031e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
124131e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
124231e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
124331e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
12442521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
124531e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
124631e31b8aSbellard 
124731e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
124831e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
124931e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
125031e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
125131e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
125231e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
125331e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
125431e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
12552521d698Sbellard 
1256b8005914Sbalrog /* loop ioctls */
1257b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1258b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1259b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1260b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1261b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1262b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1263b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
12642521d698Sbellard 
1265884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1266884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1267884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1268884cdc48SPeter Maydell 
1269f7680a55SUlrich Hecht /* fb ioctls */
1270f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1271f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1272f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
127312b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
127412b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
127512b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
127612b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
127712b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1278f7680a55SUlrich Hecht 
1279f7680a55SUlrich Hecht /* vt ioctls */
1280f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1281f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1282f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1283f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1284f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1285f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1286774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1287774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1288774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1289774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1290f7680a55SUlrich Hecht 
129156e904ecSAlexander Graf /* device mapper */
129256e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
129356e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
129456e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
129556e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
129656e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
129756e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
129856e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
129956e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
130056e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
130156e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
130256e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
130356e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
130456e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
130556e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
130656e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
130756e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
130856e904ecSAlexander Graf 
13092521d698Sbellard /* from asm/termbits.h */
13102521d698Sbellard 
13113bfd9da1Sbellard #define TARGET_NCC 8
13123bfd9da1Sbellard struct target_termio {
13133bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
13143bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
13153bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
13163bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
13172521d698Sbellard 	unsigned char c_line;		/* line discipline */
13183bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
13192521d698Sbellard };
13202521d698Sbellard 
13213bfd9da1Sbellard struct target_winsize {
13223bfd9da1Sbellard 	unsigned short ws_row;
13233bfd9da1Sbellard 	unsigned short ws_col;
13243bfd9da1Sbellard 	unsigned short ws_xpixel;
13253bfd9da1Sbellard 	unsigned short ws_ypixel;
13263bfd9da1Sbellard };
13272521d698Sbellard 
13283bfd9da1Sbellard #include "termbits.h"
13292521d698Sbellard 
13309e0b74a4SPaul Brook #if defined(TARGET_MIPS)
13319e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
13329e0b74a4SPaul Brook #else
13339e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
13349e0b74a4SPaul Brook #endif
13359e0b74a4SPaul Brook 
1336e44a3e79Saurel32 /* Common */
13372521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
13382521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1339e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1340e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1341e65be6a7SHelge Deller #else
13422521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1343e65be6a7SHelge Deller #endif
1344e44a3e79Saurel32 
1345e44a3e79Saurel32 /* Target specific */
1346048f6b4dSbellard #if defined(TARGET_MIPS)
1347e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1348048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1349048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1350048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1351048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1352048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1353048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1354540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1355540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1356*541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1357*541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1358e44a3e79Saurel32 #elif defined(TARGET_PPC)
1359e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
13602521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
13612521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
13622521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
13632521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
13647ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
13657ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1366e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1367e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1368*541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1369*541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1370e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1371e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1372e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1373e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1374e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1375e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1376e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1377e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1378e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1379e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1380*541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1381*541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1382a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1383a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1384a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1385a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1386a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1387a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1388a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1389a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1390a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1391a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1392*541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1393*541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
13947ec93196Sj_mayer #else
1395e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1396e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1397e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1398e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1399e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
14002521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
14012521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1402540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1403540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1404*541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1405*541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1406906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
14077ec93196Sj_mayer #endif
14082521d698Sbellard 
140909701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
141009701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1411c7819dfbSPeter Maydell     || defined(TARGET_CRIS) || defined(TARGET_UNICORE32)
14122521d698Sbellard struct target_stat {
14132521d698Sbellard 	unsigned short st_dev;
14142521d698Sbellard 	unsigned short __pad1;
1415992f48a0Sblueswir1 	abi_ulong st_ino;
14162521d698Sbellard 	unsigned short st_mode;
14172521d698Sbellard 	unsigned short st_nlink;
14182521d698Sbellard 	unsigned short st_uid;
14192521d698Sbellard 	unsigned short st_gid;
14202521d698Sbellard 	unsigned short st_rdev;
14212521d698Sbellard 	unsigned short __pad2;
1422992f48a0Sblueswir1 	abi_ulong  st_size;
1423992f48a0Sblueswir1 	abi_ulong  st_blksize;
1424992f48a0Sblueswir1 	abi_ulong  st_blocks;
1425992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1426992f48a0Sblueswir1 	abi_ulong  __unused1;
1427992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1428992f48a0Sblueswir1 	abi_ulong  __unused2;
1429992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1430992f48a0Sblueswir1 	abi_ulong  __unused3;
1431992f48a0Sblueswir1 	abi_ulong  __unused4;
1432992f48a0Sblueswir1 	abi_ulong  __unused5;
14332521d698Sbellard };
14342521d698Sbellard 
14352521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
14362521d698Sbellard  * insane amounts of padding around dev_t's.
14372521d698Sbellard  */
143820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14392521d698Sbellard struct target_stat64 {
14402521d698Sbellard 	unsigned short	st_dev;
14412521d698Sbellard 	unsigned char	__pad0[10];
14422521d698Sbellard 
14432521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1444992f48a0Sblueswir1 	abi_ulong	__st_ino;
14452521d698Sbellard 
14462521d698Sbellard 	unsigned int	st_mode;
14472521d698Sbellard 	unsigned int	st_nlink;
14482521d698Sbellard 
1449992f48a0Sblueswir1 	abi_ulong	st_uid;
1450992f48a0Sblueswir1 	abi_ulong	st_gid;
14512521d698Sbellard 
14522521d698Sbellard 	unsigned short	st_rdev;
14532521d698Sbellard 	unsigned char	__pad3[10];
14542521d698Sbellard 
14552521d698Sbellard 	long long	st_size;
1456992f48a0Sblueswir1 	abi_ulong	st_blksize;
14572521d698Sbellard 
1458992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1459992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
14602521d698Sbellard 
1461992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1462992f48a0Sblueswir1 	abi_ulong	__pad5;
14632521d698Sbellard 
1464992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1465992f48a0Sblueswir1 	abi_ulong	__pad6;
14662521d698Sbellard 
1467992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1468992f48a0Sblueswir1 	abi_ulong	__pad7;		/* will be high 32 bits of ctime someday */
14692521d698Sbellard 
14702521d698Sbellard 	unsigned long long	st_ino;
1471541dc0d4SStefan Weil } QEMU_PACKED;
14722521d698Sbellard 
1473ce4defa0Spbrook #ifdef TARGET_ARM
147420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1475ce4defa0Spbrook struct target_eabi_stat64 {
1476ce4defa0Spbrook         unsigned long long st_dev;
1477ce4defa0Spbrook         unsigned int    __pad1;
1478992f48a0Sblueswir1         abi_ulong    __st_ino;
1479ce4defa0Spbrook         unsigned int    st_mode;
1480ce4defa0Spbrook         unsigned int    st_nlink;
1481ce4defa0Spbrook 
1482992f48a0Sblueswir1         abi_ulong    st_uid;
1483992f48a0Sblueswir1         abi_ulong    st_gid;
1484ce4defa0Spbrook 
1485ce4defa0Spbrook         unsigned long long st_rdev;
1486ce4defa0Spbrook         unsigned int    __pad2[2];
1487ce4defa0Spbrook 
1488ce4defa0Spbrook         long long       st_size;
1489992f48a0Sblueswir1         abi_ulong    st_blksize;
1490ce4defa0Spbrook         unsigned int    __pad3;
1491ce4defa0Spbrook         unsigned long long st_blocks;
1492ce4defa0Spbrook 
1493992f48a0Sblueswir1         abi_ulong    target_st_atime;
1494992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1495ce4defa0Spbrook 
1496992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1497992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1498ce4defa0Spbrook 
1499992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1500992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1501ce4defa0Spbrook 
1502ce4defa0Spbrook         unsigned long long st_ino;
1503541dc0d4SStefan Weil } QEMU_PACKED;
1504ce4defa0Spbrook #endif
1505ce4defa0Spbrook 
1506992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
15071b8dd648Sblueswir1 struct target_stat {
15081b8dd648Sblueswir1 	unsigned int	st_dev;
1509992f48a0Sblueswir1 	abi_ulong	st_ino;
15101b8dd648Sblueswir1 	unsigned int	st_mode;
15111b8dd648Sblueswir1 	unsigned int	st_nlink;
15121b8dd648Sblueswir1 	unsigned int	st_uid;
15131b8dd648Sblueswir1 	unsigned int	st_gid;
15141b8dd648Sblueswir1 	unsigned int	st_rdev;
1515992f48a0Sblueswir1 	abi_long	st_size;
1516992f48a0Sblueswir1 	abi_long	target_st_atime;
1517992f48a0Sblueswir1 	abi_long	target_st_mtime;
1518992f48a0Sblueswir1 	abi_long	target_st_ctime;
1519992f48a0Sblueswir1 	abi_long	st_blksize;
1520992f48a0Sblueswir1 	abi_long	st_blocks;
1521992f48a0Sblueswir1 	abi_ulong	__unused4[2];
15221b8dd648Sblueswir1 };
15231b8dd648Sblueswir1 
152420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
15251b8dd648Sblueswir1 struct target_stat64 {
15261b8dd648Sblueswir1 	unsigned char	__pad0[6];
15271b8dd648Sblueswir1 	unsigned short	st_dev;
15281b8dd648Sblueswir1 
15291b8dd648Sblueswir1 	uint64_t	st_ino;
15301b8dd648Sblueswir1 	uint64_t	st_nlink;
15311b8dd648Sblueswir1 
15321b8dd648Sblueswir1 	unsigned int	st_mode;
15331b8dd648Sblueswir1 
15341b8dd648Sblueswir1 	unsigned int	st_uid;
15351b8dd648Sblueswir1 	unsigned int	st_gid;
15361b8dd648Sblueswir1 
15371b8dd648Sblueswir1 	unsigned char	__pad2[6];
15381b8dd648Sblueswir1 	unsigned short	st_rdev;
15391b8dd648Sblueswir1 
15401b8dd648Sblueswir1         int64_t		st_size;
15411b8dd648Sblueswir1 	int64_t		st_blksize;
15421b8dd648Sblueswir1 
15431b8dd648Sblueswir1 	unsigned char	__pad4[4];
15441b8dd648Sblueswir1 	unsigned int	st_blocks;
15451b8dd648Sblueswir1 
1546992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1547992f48a0Sblueswir1 	abi_ulong	__unused1;
15481b8dd648Sblueswir1 
1549992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1550992f48a0Sblueswir1 	abi_ulong	__unused2;
15511b8dd648Sblueswir1 
1552992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1553992f48a0Sblueswir1 	abi_ulong	__unused3;
15541b8dd648Sblueswir1 
1555992f48a0Sblueswir1 	abi_ulong	__unused4[3];
15561b8dd648Sblueswir1 };
15571b8dd648Sblueswir1 
15583bfd9da1Sbellard #elif defined(TARGET_SPARC)
15593bfd9da1Sbellard 
15603bfd9da1Sbellard struct target_stat {
15613bfd9da1Sbellard 	unsigned short	st_dev;
1562992f48a0Sblueswir1 	abi_ulong	st_ino;
15633bfd9da1Sbellard 	unsigned short	st_mode;
15643bfd9da1Sbellard 	short		st_nlink;
15653bfd9da1Sbellard 	unsigned short	st_uid;
15663bfd9da1Sbellard 	unsigned short	st_gid;
15673bfd9da1Sbellard 	unsigned short	st_rdev;
1568992f48a0Sblueswir1 	abi_long	st_size;
1569992f48a0Sblueswir1 	abi_long	target_st_atime;
1570992f48a0Sblueswir1 	abi_ulong	__unused1;
1571992f48a0Sblueswir1 	abi_long	target_st_mtime;
1572992f48a0Sblueswir1 	abi_ulong	__unused2;
1573992f48a0Sblueswir1 	abi_long	target_st_ctime;
1574992f48a0Sblueswir1 	abi_ulong	__unused3;
1575992f48a0Sblueswir1 	abi_long	st_blksize;
1576992f48a0Sblueswir1 	abi_long	st_blocks;
1577992f48a0Sblueswir1 	abi_ulong	__unused4[2];
15783bfd9da1Sbellard };
15793bfd9da1Sbellard 
158020d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
15813bfd9da1Sbellard struct target_stat64 {
15823bfd9da1Sbellard 	unsigned char	__pad0[6];
15833bfd9da1Sbellard 	unsigned short	st_dev;
15843bfd9da1Sbellard 
15853bfd9da1Sbellard 	uint64_t st_ino;
15863bfd9da1Sbellard 
15873bfd9da1Sbellard 	unsigned int	st_mode;
15883bfd9da1Sbellard 	unsigned int	st_nlink;
15893bfd9da1Sbellard 
15903bfd9da1Sbellard 	unsigned int	st_uid;
15913bfd9da1Sbellard 	unsigned int	st_gid;
15923bfd9da1Sbellard 
15933bfd9da1Sbellard 	unsigned char	__pad2[6];
15943bfd9da1Sbellard 	unsigned short	st_rdev;
15953bfd9da1Sbellard 
15963bfd9da1Sbellard 	unsigned char	__pad3[8];
15973bfd9da1Sbellard 
15983bfd9da1Sbellard         int64_t	st_size;
15993bfd9da1Sbellard 	unsigned int	st_blksize;
16003bfd9da1Sbellard 
16013bfd9da1Sbellard 	unsigned char	__pad4[8];
16023bfd9da1Sbellard 	unsigned int	st_blocks;
16033bfd9da1Sbellard 
16043bfd9da1Sbellard 	unsigned int	target_st_atime;
16053bfd9da1Sbellard 	unsigned int	__unused1;
16063bfd9da1Sbellard 
16073bfd9da1Sbellard 	unsigned int	target_st_mtime;
16083bfd9da1Sbellard 	unsigned int	__unused2;
16093bfd9da1Sbellard 
16103bfd9da1Sbellard 	unsigned int	target_st_ctime;
16113bfd9da1Sbellard 	unsigned int	__unused3;
16123bfd9da1Sbellard 
16133bfd9da1Sbellard 	unsigned int	__unused4;
16143bfd9da1Sbellard 	unsigned int	__unused5;
16153bfd9da1Sbellard };
16163bfd9da1Sbellard 
161767867308Sbellard #elif defined(TARGET_PPC)
161867867308Sbellard 
161967867308Sbellard struct target_stat {
1620e32448e0Sj_mayer 	abi_ulong st_dev;
1621992f48a0Sblueswir1 	abi_ulong st_ino;
1622325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1623e32448e0Sj_mayer 	abi_ulong st_nlink;
1624325e651fSj_mayer 	unsigned int st_mode;
1625325e651fSj_mayer #else
162667867308Sbellard 	unsigned int st_mode;
162767867308Sbellard 	unsigned short st_nlink;
1628325e651fSj_mayer #endif
162967867308Sbellard 	unsigned int st_uid;
163067867308Sbellard 	unsigned int st_gid;
1631e32448e0Sj_mayer 	abi_ulong  st_rdev;
1632992f48a0Sblueswir1 	abi_ulong  st_size;
1633992f48a0Sblueswir1 	abi_ulong  st_blksize;
1634992f48a0Sblueswir1 	abi_ulong  st_blocks;
1635992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1636e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1637992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1638e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1639992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1640e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1641992f48a0Sblueswir1 	abi_ulong  __unused4;
1642992f48a0Sblueswir1 	abi_ulong  __unused5;
1643325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1644325e651fSj_mayer 	abi_ulong  __unused6;
1645325e651fSj_mayer #endif
164667867308Sbellard };
164767867308Sbellard 
164820d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
164920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1650541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
165167867308Sbellard 	unsigned long long st_dev;
165267867308Sbellard         unsigned long long st_ino;
165367867308Sbellard 	unsigned int st_mode;
165467867308Sbellard 	unsigned int st_nlink;
165567867308Sbellard 	unsigned int st_uid;
165667867308Sbellard 	unsigned int st_gid;
165767867308Sbellard 	unsigned long long st_rdev;
1658e1ce5e40Saurel32 	unsigned long long __pad0;
165967867308Sbellard 	long long      st_size;
1660e32448e0Sj_mayer 	int	       st_blksize;
1661e1ce5e40Saurel32 	unsigned int   __pad1;
166261322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1663e32448e0Sj_mayer 	int	       target_st_atime;
1664e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1665e32448e0Sj_mayer 	int	       target_st_mtime;
1666e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1667e32448e0Sj_mayer 	int            target_st_ctime;
1668e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1669e32448e0Sj_mayer         unsigned int   __unused4;
1670e32448e0Sj_mayer         unsigned int   __unused5;
167167867308Sbellard };
167220d155bcSStefan Weil #endif
167367867308Sbellard 
1674b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1675b779e29eSEdgar E. Iglesias 
1676b779e29eSEdgar E. Iglesias struct target_stat {
1677b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1678b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1679b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1680b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1681b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1682b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1683b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1684b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1685b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1686b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1687b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1688b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1689b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1690b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1691b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1692b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1693b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1694b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1695b779e29eSEdgar E. Iglesias };
1696b779e29eSEdgar E. Iglesias 
1697b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
169820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1699541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1700b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1701a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1702a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1703a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1704a523eb06SEdgar E. Iglesias 
1705b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1706b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1707b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1708b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1709b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
171021ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1711b779e29eSEdgar E. Iglesias 
1712b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1713b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
171421ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1715b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1716b779e29eSEdgar E. Iglesias 
1717b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1718b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1719b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1720b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1721b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1722b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1723a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1724b779e29eSEdgar E. Iglesias };
1725b779e29eSEdgar E. Iglesias 
1726e6e5906bSpbrook #elif defined(TARGET_M68K)
1727e6e5906bSpbrook 
1728e6e5906bSpbrook struct target_stat {
1729e6e5906bSpbrook 	unsigned short st_dev;
1730e6e5906bSpbrook 	unsigned short __pad1;
1731992f48a0Sblueswir1 	abi_ulong st_ino;
1732e6e5906bSpbrook 	unsigned short st_mode;
1733e6e5906bSpbrook 	unsigned short st_nlink;
1734e6e5906bSpbrook 	unsigned short st_uid;
1735e6e5906bSpbrook 	unsigned short st_gid;
1736e6e5906bSpbrook 	unsigned short st_rdev;
1737e6e5906bSpbrook 	unsigned short __pad2;
1738992f48a0Sblueswir1 	abi_ulong  st_size;
1739992f48a0Sblueswir1 	abi_ulong  st_blksize;
1740992f48a0Sblueswir1 	abi_ulong  st_blocks;
1741992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1742992f48a0Sblueswir1 	abi_ulong  __unused1;
1743992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1744992f48a0Sblueswir1 	abi_ulong  __unused2;
1745992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1746992f48a0Sblueswir1 	abi_ulong  __unused3;
1747992f48a0Sblueswir1 	abi_ulong  __unused4;
1748992f48a0Sblueswir1 	abi_ulong  __unused5;
1749e6e5906bSpbrook };
1750e6e5906bSpbrook 
1751e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1752e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1753e6e5906bSpbrook  */
175420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1755e6e5906bSpbrook struct target_stat64 {
1756e6e5906bSpbrook 	unsigned long long	st_dev;
1757e6e5906bSpbrook 	unsigned char	__pad1[2];
1758e6e5906bSpbrook 
1759e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1760992f48a0Sblueswir1 	abi_ulong	__st_ino;
1761e6e5906bSpbrook 
1762e6e5906bSpbrook 	unsigned int	st_mode;
1763e6e5906bSpbrook 	unsigned int	st_nlink;
1764e6e5906bSpbrook 
1765992f48a0Sblueswir1 	abi_ulong	st_uid;
1766992f48a0Sblueswir1 	abi_ulong	st_gid;
1767e6e5906bSpbrook 
1768e6e5906bSpbrook 	unsigned long long	st_rdev;
1769e6e5906bSpbrook 	unsigned char	__pad3[2];
1770e6e5906bSpbrook 
1771e6e5906bSpbrook 	long long	st_size;
1772992f48a0Sblueswir1 	abi_ulong	st_blksize;
1773e6e5906bSpbrook 
1774992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1775992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1776e6e5906bSpbrook 
1777992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1778992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1779e6e5906bSpbrook 
1780992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1781992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1782e6e5906bSpbrook 
1783992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1784992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1785e6e5906bSpbrook 
1786e6e5906bSpbrook 	unsigned long long	st_ino;
1787541dc0d4SStefan Weil } QEMU_PACKED;
1788e6e5906bSpbrook 
1789d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1790540635baSths 
1791540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1792540635baSths struct target_stat {
1793540635baSths 	unsigned int		st_dev;
1794540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1795540635baSths 
1796992f48a0Sblueswir1 	abi_ulong		st_ino;
1797540635baSths 
1798540635baSths 	unsigned int		st_mode;
1799540635baSths 	unsigned int		st_nlink;
1800540635baSths 
1801540635baSths 	int			st_uid;
1802540635baSths 	int			st_gid;
1803540635baSths 
1804540635baSths 	unsigned int		st_rdev;
1805540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1806540635baSths 
1807992f48a0Sblueswir1 	abi_ulong		st_size;
1808540635baSths 
1809540635baSths 	/*
1810540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1811540635baSths 	 * but we don't have it under Linux.
1812540635baSths 	 */
1813540635baSths 	unsigned int		target_st_atime;
1814540635baSths 	unsigned int		target_st_atime_nsec;
1815540635baSths 
1816540635baSths 	unsigned int		target_st_mtime;
1817540635baSths 	unsigned int		target_st_mtime_nsec;
1818540635baSths 
1819540635baSths 	unsigned int		target_st_ctime;
1820540635baSths 	unsigned int		target_st_ctime_nsec;
1821540635baSths 
1822540635baSths 	unsigned int		st_blksize;
1823540635baSths 	unsigned int		st_pad2;
1824540635baSths 
1825992f48a0Sblueswir1 	abi_ulong		st_blocks;
1826540635baSths };
1827540635baSths 
1828d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1829540635baSths 
1830540635baSths struct target_stat {
18311ab2aea2SLeon Alrae         abi_ulong    st_dev;
18321ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
18331ab2aea2SLeon Alrae         uint64_t     st_ino;
1834540635baSths         unsigned int st_mode;
1835540635baSths         unsigned int st_nlink;
1836540635baSths         int          st_uid;
1837540635baSths         int          st_gid;
18381ab2aea2SLeon Alrae         abi_ulong    st_rdev;
18391ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
18401ab2aea2SLeon Alrae         int64_t      st_size;
18411ab2aea2SLeon Alrae         abi_long     target_st_atime;
18421ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
18431ab2aea2SLeon Alrae         abi_long     target_st_mtime;
18441ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
18451ab2aea2SLeon Alrae         abi_long     target_st_ctime;
18461ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
18471ab2aea2SLeon Alrae         abi_ulong    st_blksize;
18481ab2aea2SLeon Alrae         abi_ulong    st_pad2;
18491ab2aea2SLeon Alrae         int64_t      st_blocks;
1850540635baSths };
1851540635baSths 
1852d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1853048f6b4dSbellard 
1854048f6b4dSbellard struct target_stat {
1855048f6b4dSbellard 	unsigned	st_dev;
1856992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1857992f48a0Sblueswir1 	abi_ulong	st_ino;
1858048f6b4dSbellard 	unsigned int	st_mode;
1859048f6b4dSbellard 	unsigned int	st_nlink;
1860048f6b4dSbellard 	int		st_uid;
1861048f6b4dSbellard 	int		st_gid;
1862048f6b4dSbellard 	unsigned 	st_rdev;
1863992f48a0Sblueswir1 	abi_long	st_pad2[2];
1864992f48a0Sblueswir1 	abi_long	st_size;
1865992f48a0Sblueswir1 	abi_long	st_pad3;
1866048f6b4dSbellard 	/*
1867048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1868048f6b4dSbellard 	 * but we don't have it under Linux.
1869048f6b4dSbellard 	 */
1870992f48a0Sblueswir1 	abi_long		target_st_atime;
1871992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1872992f48a0Sblueswir1 	abi_long		target_st_mtime;
1873992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1874992f48a0Sblueswir1 	abi_long		target_st_ctime;
1875992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1876992f48a0Sblueswir1 	abi_long		st_blksize;
1877992f48a0Sblueswir1 	abi_long		st_blocks;
1878992f48a0Sblueswir1 	abi_long		st_pad4[14];
1879048f6b4dSbellard };
1880048f6b4dSbellard 
1881048f6b4dSbellard /*
1882048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1883048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1884048f6b4dSbellard  * struct stat of the 64-bit kernel.
1885048f6b4dSbellard  */
1886048f6b4dSbellard 
188720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1888048f6b4dSbellard struct target_stat64 {
1889992f48a0Sblueswir1 	abi_ulong	st_dev;
1890992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1891048f6b4dSbellard 
1892048f6b4dSbellard 	uint64_t	st_ino;
1893048f6b4dSbellard 
1894048f6b4dSbellard         unsigned int	st_mode;
1895048f6b4dSbellard         unsigned int	st_nlink;
1896048f6b4dSbellard 
1897048f6b4dSbellard 	int		st_uid;
1898048f6b4dSbellard 	int		st_gid;
1899048f6b4dSbellard 
1900992f48a0Sblueswir1 	abi_ulong	st_rdev;
1901992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1902048f6b4dSbellard 
1903048f6b4dSbellard 	int64_t 	st_size;
1904048f6b4dSbellard 
1905048f6b4dSbellard 	/*
1906048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1907048f6b4dSbellard 	 * but we don't have it under Linux.
1908048f6b4dSbellard 	 */
1909992f48a0Sblueswir1 	abi_long	target_st_atime;
1910992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1911048f6b4dSbellard 
1912992f48a0Sblueswir1 	abi_long	target_st_mtime;
1913992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1914048f6b4dSbellard 
1915992f48a0Sblueswir1 	abi_long	target_st_ctime;
1916992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1917048f6b4dSbellard 
1918992f48a0Sblueswir1 	abi_ulong	st_blksize;
1919992f48a0Sblueswir1 	abi_ulong	st_pad2;
1920048f6b4dSbellard 
1921048f6b4dSbellard 	int64_t  	st_blocks;
1922048f6b4dSbellard };
19237a3148a9Sj_mayer 
19247a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
19257a3148a9Sj_mayer 
19267a3148a9Sj_mayer struct target_stat {
19277a3148a9Sj_mayer        unsigned int    st_dev;
19287a3148a9Sj_mayer        unsigned int    st_ino;
19297a3148a9Sj_mayer        unsigned int    st_mode;
19307a3148a9Sj_mayer        unsigned int    st_nlink;
19317a3148a9Sj_mayer        unsigned int    st_uid;
19327a3148a9Sj_mayer        unsigned int    st_gid;
19337a3148a9Sj_mayer        unsigned int    st_rdev;
1934992f48a0Sblueswir1        abi_long     st_size;
1935992f48a0Sblueswir1        abi_ulong    target_st_atime;
1936992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1937992f48a0Sblueswir1        abi_ulong    target_st_ctime;
19387a3148a9Sj_mayer        unsigned int    st_blksize;
19397a3148a9Sj_mayer        unsigned int    st_blocks;
19407a3148a9Sj_mayer        unsigned int    st_flags;
19417a3148a9Sj_mayer        unsigned int    st_gen;
19427a3148a9Sj_mayer };
19437a3148a9Sj_mayer 
194420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
19457a3148a9Sj_mayer struct target_stat64 {
1946992f48a0Sblueswir1        abi_ulong    st_dev;
1947992f48a0Sblueswir1        abi_ulong    st_ino;
1948992f48a0Sblueswir1        abi_ulong    st_rdev;
1949992f48a0Sblueswir1        abi_long     st_size;
1950992f48a0Sblueswir1        abi_ulong    st_blocks;
19517a3148a9Sj_mayer 
19527a3148a9Sj_mayer        unsigned int    st_mode;
19537a3148a9Sj_mayer        unsigned int    st_uid;
19547a3148a9Sj_mayer        unsigned int    st_gid;
19557a3148a9Sj_mayer        unsigned int    st_blksize;
19567a3148a9Sj_mayer        unsigned int    st_nlink;
19577a3148a9Sj_mayer        unsigned int    __pad0;
19587a3148a9Sj_mayer 
1959992f48a0Sblueswir1        abi_ulong    target_st_atime;
1960992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1961992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1962992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1963992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1964992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1965992f48a0Sblueswir1        abi_long     __unused[3];
19667a3148a9Sj_mayer };
19677a3148a9Sj_mayer 
19686db45e65Sths #elif defined(TARGET_SH4)
19696db45e65Sths 
19706db45e65Sths struct target_stat {
1971992f48a0Sblueswir1 	abi_ulong  st_dev;
1972992f48a0Sblueswir1 	abi_ulong  st_ino;
19736db45e65Sths 	unsigned short st_mode;
19746db45e65Sths 	unsigned short st_nlink;
19756db45e65Sths 	unsigned short st_uid;
19766db45e65Sths 	unsigned short st_gid;
1977992f48a0Sblueswir1 	abi_ulong  st_rdev;
1978992f48a0Sblueswir1 	abi_ulong  st_size;
1979992f48a0Sblueswir1 	abi_ulong  st_blksize;
1980992f48a0Sblueswir1 	abi_ulong  st_blocks;
1981992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1982992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1983992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1984992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1985992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1986992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1987992f48a0Sblueswir1 	abi_ulong  __unused4;
1988992f48a0Sblueswir1 	abi_ulong  __unused5;
19896db45e65Sths };
19906db45e65Sths 
19916db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
19926db45e65Sths  * insane amounts of padding around dev_t's.
19936db45e65Sths  */
199420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1995541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
19966db45e65Sths 	unsigned long long	st_dev;
19976db45e65Sths 	unsigned char	__pad0[4];
19986db45e65Sths 
19996db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
2000992f48a0Sblueswir1 	abi_ulong	__st_ino;
20016db45e65Sths 
20026db45e65Sths 	unsigned int	st_mode;
20036db45e65Sths 	unsigned int	st_nlink;
20046db45e65Sths 
2005992f48a0Sblueswir1 	abi_ulong	st_uid;
2006992f48a0Sblueswir1 	abi_ulong	st_gid;
20076db45e65Sths 
20086db45e65Sths 	unsigned long long	st_rdev;
20096db45e65Sths 	unsigned char	__pad3[4];
20106db45e65Sths 
20116db45e65Sths 	long long	st_size;
2012992f48a0Sblueswir1 	abi_ulong	st_blksize;
20136db45e65Sths 
20146db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
20156db45e65Sths 
2016992f48a0Sblueswir1 	abi_ulong	target_st_atime;
2017992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
20186db45e65Sths 
2019992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
2020992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
20216db45e65Sths 
2022992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
2023992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
20246db45e65Sths 
20256db45e65Sths 	unsigned long long	st_ino;
20266db45e65Sths };
20276db45e65Sths 
2028d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
2029d2fd1af7Sbellard struct target_stat {
2030d2fd1af7Sbellard 	abi_ulong	st_dev;
2031d2fd1af7Sbellard 	abi_ulong	st_ino;
2032d2fd1af7Sbellard 	abi_ulong	st_nlink;
2033d2fd1af7Sbellard 
2034d2fd1af7Sbellard 	unsigned int	st_mode;
2035d2fd1af7Sbellard 	unsigned int	st_uid;
2036d2fd1af7Sbellard 	unsigned int	st_gid;
2037d2fd1af7Sbellard 	unsigned int	__pad0;
2038d2fd1af7Sbellard 	abi_ulong	st_rdev;
2039d2fd1af7Sbellard 	abi_long	st_size;
2040d2fd1af7Sbellard 	abi_long	st_blksize;
2041d2fd1af7Sbellard     	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
2042d2fd1af7Sbellard 
2043d2fd1af7Sbellard 	abi_ulong	target_st_atime;
2044d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
2045d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
2046d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
2047d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
2048d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
2049d2fd1af7Sbellard 
2050d2fd1af7Sbellard   	abi_long	__unused[3];
2051d2fd1af7Sbellard };
2052a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2053a4c075f1SUlrich Hecht struct target_stat {
2054a4c075f1SUlrich Hecht     abi_ulong  st_dev;
2055a4c075f1SUlrich Hecht     abi_ulong  st_ino;
2056a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
2057a4c075f1SUlrich Hecht     unsigned int   st_mode;
2058a4c075f1SUlrich Hecht     unsigned int   st_uid;
2059a4c075f1SUlrich Hecht     unsigned int   st_gid;
2060a4c075f1SUlrich Hecht     unsigned int   __pad1;
2061a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
2062a4c075f1SUlrich Hecht     abi_ulong  st_size;
2063a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
2064a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
2065a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
2066a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
2067a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
2068a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
2069a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
2070a4c075f1SUlrich Hecht     abi_long       st_blocks;
2071a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
2072a4c075f1SUlrich Hecht };
207309701199SAlexander Graf #elif defined(TARGET_AARCH64)
207409701199SAlexander Graf struct target_stat {
207509701199SAlexander Graf     abi_ulong  st_dev;
207609701199SAlexander Graf     abi_ulong  st_ino;
207709701199SAlexander Graf     unsigned int st_mode;
207809701199SAlexander Graf     unsigned int st_nlink;
207909701199SAlexander Graf     unsigned int   st_uid;
208009701199SAlexander Graf     unsigned int   st_gid;
208109701199SAlexander Graf     abi_ulong  st_rdev;
208209701199SAlexander Graf     abi_ulong  _pad1;
208309701199SAlexander Graf     abi_long  st_size;
208409701199SAlexander Graf     int        st_blksize;
208509701199SAlexander Graf     int        __pad2;
208609701199SAlexander Graf     abi_long   st_blocks;
208709701199SAlexander Graf     abi_long  target_st_atime;
208809701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
208909701199SAlexander Graf     abi_long  target_st_mtime;
209009701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
209109701199SAlexander Graf     abi_long  target_st_ctime;
209209701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
209309701199SAlexander Graf     unsigned int __unused[2];
209409701199SAlexander Graf };
2095a0a839b6SMarek Vasut #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
2096a0a839b6SMarek Vasut       defined(TARGET_NIOS2)
2097c7819dfbSPeter Maydell 
2098c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
2099c7819dfbSPeter Maydell 
2100d962783eSJia Liu struct target_stat {
2101d962783eSJia Liu     abi_ulong st_dev;
2102d962783eSJia Liu     abi_ulong st_ino;
2103d962783eSJia Liu     unsigned int st_mode;
2104c7819dfbSPeter Maydell     unsigned int st_nlink;
2105d962783eSJia Liu     unsigned int st_uid;
2106d962783eSJia Liu     unsigned int st_gid;
2107d962783eSJia Liu     abi_ulong st_rdev;
2108c7819dfbSPeter Maydell     abi_ulong __pad1;
2109d962783eSJia Liu     abi_long st_size;
2110c7819dfbSPeter Maydell     int st_blksize;
2111c7819dfbSPeter Maydell     int __pad2;
2112c7819dfbSPeter Maydell     abi_long st_blocks;
2113c7819dfbSPeter Maydell     abi_long target_st_atime;
2114d962783eSJia Liu     abi_ulong target_st_atime_nsec;
2115c7819dfbSPeter Maydell     abi_long target_st_mtime;
2116d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
2117c7819dfbSPeter Maydell     abi_long target_st_ctime;
2118d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
2119c7819dfbSPeter Maydell     unsigned int __unused4;
2120c7819dfbSPeter Maydell     unsigned int __unused5;
2121d962783eSJia Liu };
2122c7819dfbSPeter Maydell 
212320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
2124c7819dfbSPeter Maydell struct target_stat64 {
2125c7819dfbSPeter Maydell     uint64_t st_dev;
2126c7819dfbSPeter Maydell     uint64_t st_ino;
2127c7819dfbSPeter Maydell     unsigned int st_mode;
2128c7819dfbSPeter Maydell     unsigned int st_nlink;
2129c7819dfbSPeter Maydell     unsigned int st_uid;
2130c7819dfbSPeter Maydell     unsigned int st_gid;
2131c7819dfbSPeter Maydell     uint64_t st_rdev;
2132c7819dfbSPeter Maydell     uint64_t __pad1;
2133c7819dfbSPeter Maydell     int64_t st_size;
2134c7819dfbSPeter Maydell     int st_blksize;
2135c7819dfbSPeter Maydell     int __pad2;
2136c7819dfbSPeter Maydell     int64_t st_blocks;
2137c7819dfbSPeter Maydell     int target_st_atime;
2138c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
2139c7819dfbSPeter Maydell     int target_st_mtime;
2140c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
2141c7819dfbSPeter Maydell     int target_st_ctime;
2142c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
2143c7819dfbSPeter Maydell     unsigned int __unused4;
2144c7819dfbSPeter Maydell     unsigned int __unused5;
2145c7819dfbSPeter Maydell };
2146c7819dfbSPeter Maydell 
2147a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2148a10d1e50SRichard Henderson 
2149a10d1e50SRichard Henderson struct target_stat {
2150a10d1e50SRichard Henderson     abi_uint   st_dev;
2151a10d1e50SRichard Henderson     abi_uint   st_ino;
2152a10d1e50SRichard Henderson     abi_ushort st_mode;
2153a10d1e50SRichard Henderson     abi_ushort st_nlink;
2154a10d1e50SRichard Henderson     abi_ushort _res1;
2155a10d1e50SRichard Henderson     abi_ushort _res2;
2156a10d1e50SRichard Henderson     abi_uint   st_rdev;
2157a10d1e50SRichard Henderson     abi_int    st_size;
2158a10d1e50SRichard Henderson     abi_int    target_st_atime;
2159a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2160a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2161a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2162a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2163a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2164a10d1e50SRichard Henderson     abi_int    st_blksize;
2165a10d1e50SRichard Henderson     abi_int    st_blocks;
2166a10d1e50SRichard Henderson     abi_uint   _unused1;
2167a10d1e50SRichard Henderson     abi_uint   _unused2;
2168a10d1e50SRichard Henderson     abi_uint   _unused3;
2169a10d1e50SRichard Henderson     abi_uint   _unused4;
2170a10d1e50SRichard Henderson     abi_ushort _unused5;
2171a10d1e50SRichard Henderson     abi_short  st_fstype;
2172a10d1e50SRichard Henderson     abi_uint   st_realdev;
2173a10d1e50SRichard Henderson     abi_ushort st_basemode;
2174a10d1e50SRichard Henderson     abi_ushort _unused6;
2175a10d1e50SRichard Henderson     abi_uint   st_uid;
2176a10d1e50SRichard Henderson     abi_uint   st_gid;
2177a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2178a10d1e50SRichard Henderson };
2179a10d1e50SRichard Henderson 
2180a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2181a10d1e50SRichard Henderson struct target_stat64 {
2182a10d1e50SRichard Henderson     uint64_t   st_dev;
2183a10d1e50SRichard Henderson     abi_uint   _pad1;
2184a10d1e50SRichard Henderson     abi_uint   _res1;
2185a10d1e50SRichard Henderson     abi_uint   st_mode;
2186a10d1e50SRichard Henderson     abi_uint   st_nlink;
2187a10d1e50SRichard Henderson     abi_uint   st_uid;
2188a10d1e50SRichard Henderson     abi_uint   st_gid;
2189a10d1e50SRichard Henderson     uint64_t   st_rdev;
2190a10d1e50SRichard Henderson     abi_uint   _pad2;
2191a10d1e50SRichard Henderson     int64_t    st_size;
2192a10d1e50SRichard Henderson     abi_int    st_blksize;
2193a10d1e50SRichard Henderson     int64_t    st_blocks;
2194a10d1e50SRichard Henderson     abi_int    target_st_atime;
2195a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2196a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2197a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2198a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2199a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2200a10d1e50SRichard Henderson     uint64_t   st_ino;
2201a10d1e50SRichard Henderson };
2202a10d1e50SRichard Henderson 
2203048f6b4dSbellard #else
2204048f6b4dSbellard #error unsupported CPU
2205048f6b4dSbellard #endif
22062521d698Sbellard 
22074ce6f8deSths typedef struct {
22084ce6f8deSths         int     val[2];
2209c227f099SAnthony Liguori } target_fsid_t;
22104ce6f8deSths 
221156c8f68fSbellard #ifdef TARGET_MIPS
2212d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2213540635baSths struct target_statfs {
2214540635baSths 	int32_t			f_type;
2215540635baSths 	int32_t			f_bsize;
2216540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2217540635baSths 	int32_t			f_blocks;
2218540635baSths 	int32_t			f_bfree;
2219540635baSths 	int32_t			f_files;
2220540635baSths 	int32_t			f_ffree;
2221540635baSths 	int32_t			f_bavail;
2222540635baSths 
2223540635baSths 	/* Linux specials */
2224c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2225540635baSths 	int32_t			f_namelen;
2226540635baSths 	int32_t			f_spare[6];
2227540635baSths };
2228540635baSths #else
222956c8f68fSbellard struct target_statfs {
2230992f48a0Sblueswir1 	abi_long		f_type;
2231992f48a0Sblueswir1 	abi_long		f_bsize;
2232992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2233992f48a0Sblueswir1 	abi_long		f_blocks;
2234992f48a0Sblueswir1 	abi_long		f_bfree;
2235992f48a0Sblueswir1 	abi_long		f_files;
2236992f48a0Sblueswir1 	abi_long		f_ffree;
2237992f48a0Sblueswir1 	abi_long		f_bavail;
223856c8f68fSbellard 
223956c8f68fSbellard 	/* Linux specials */
2240c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2241992f48a0Sblueswir1 	abi_long		f_namelen;
2242992f48a0Sblueswir1 	abi_long		f_spare[6];
224356c8f68fSbellard };
2244540635baSths #endif
224556c8f68fSbellard 
224656c8f68fSbellard struct target_statfs64 {
224756c8f68fSbellard 	uint32_t	f_type;
224856c8f68fSbellard 	uint32_t	f_bsize;
224956c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
225056c8f68fSbellard 	uint32_t	__pad;
225156c8f68fSbellard 	uint64_t	f_blocks;
225256c8f68fSbellard 	uint64_t	f_bfree;
225356c8f68fSbellard 	uint64_t	f_files;
225456c8f68fSbellard 	uint64_t	f_ffree;
225556c8f68fSbellard 	uint64_t	f_bavail;
2256c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
225756c8f68fSbellard 	uint32_t	f_namelen;
225856c8f68fSbellard 	uint32_t	f_spare[6];
225956c8f68fSbellard };
2260c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
226109701199SAlexander Graf        defined(TARGET_SPARC64) || defined(TARGET_AARCH64)) && \
226209701199SAlexander Graf        !defined(TARGET_ABI32)
2263325e651fSj_mayer struct target_statfs {
2264325e651fSj_mayer 	abi_long f_type;
2265325e651fSj_mayer 	abi_long f_bsize;
2266325e651fSj_mayer 	abi_long f_blocks;
2267325e651fSj_mayer 	abi_long f_bfree;
2268325e651fSj_mayer 	abi_long f_bavail;
2269325e651fSj_mayer 	abi_long f_files;
2270325e651fSj_mayer 	abi_long f_ffree;
2271c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2272325e651fSj_mayer 	abi_long f_namelen;
2273325e651fSj_mayer 	abi_long f_frsize;
2274325e651fSj_mayer 	abi_long f_spare[5];
2275325e651fSj_mayer };
2276325e651fSj_mayer 
2277325e651fSj_mayer struct target_statfs64 {
2278325e651fSj_mayer 	abi_long f_type;
2279325e651fSj_mayer 	abi_long f_bsize;
2280325e651fSj_mayer 	abi_long f_blocks;
2281325e651fSj_mayer 	abi_long f_bfree;
2282325e651fSj_mayer 	abi_long f_bavail;
2283325e651fSj_mayer 	abi_long f_files;
2284325e651fSj_mayer 	abi_long f_ffree;
2285c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2286325e651fSj_mayer 	abi_long f_namelen;
2287325e651fSj_mayer 	abi_long f_frsize;
2288325e651fSj_mayer 	abi_long f_spare[5];
2289325e651fSj_mayer };
2290a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2291a4c075f1SUlrich Hecht struct target_statfs {
2292a4c075f1SUlrich Hecht     int32_t  f_type;
2293a4c075f1SUlrich Hecht     int32_t  f_bsize;
2294a4c075f1SUlrich Hecht     abi_long f_blocks;
2295a4c075f1SUlrich Hecht     abi_long f_bfree;
2296a4c075f1SUlrich Hecht     abi_long f_bavail;
2297a4c075f1SUlrich Hecht     abi_long f_files;
2298a4c075f1SUlrich Hecht     abi_long f_ffree;
2299a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2300a4c075f1SUlrich Hecht     int32_t  f_namelen;
2301a4c075f1SUlrich Hecht     int32_t  f_frsize;
2302a4c075f1SUlrich Hecht     int32_t  f_spare[5];
2303a4c075f1SUlrich Hecht };
2304a4c075f1SUlrich Hecht 
2305a4c075f1SUlrich Hecht struct target_statfs64 {
2306a4c075f1SUlrich Hecht     int32_t  f_type;
2307a4c075f1SUlrich Hecht     int32_t  f_bsize;
2308a4c075f1SUlrich Hecht     abi_long f_blocks;
2309a4c075f1SUlrich Hecht     abi_long f_bfree;
2310a4c075f1SUlrich Hecht     abi_long f_bavail;
2311a4c075f1SUlrich Hecht     abi_long f_files;
2312a4c075f1SUlrich Hecht     abi_long f_ffree;
2313a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2314a4c075f1SUlrich Hecht     int32_t  f_namelen;
2315a4c075f1SUlrich Hecht     int32_t  f_frsize;
2316a4c075f1SUlrich Hecht     int32_t  f_spare[5];
2317a4c075f1SUlrich Hecht };
231856c8f68fSbellard #else
231956c8f68fSbellard struct target_statfs {
232056c8f68fSbellard 	uint32_t f_type;
232156c8f68fSbellard 	uint32_t f_bsize;
232256c8f68fSbellard 	uint32_t f_blocks;
232356c8f68fSbellard 	uint32_t f_bfree;
232456c8f68fSbellard 	uint32_t f_bavail;
232556c8f68fSbellard 	uint32_t f_files;
232656c8f68fSbellard 	uint32_t f_ffree;
2327c227f099SAnthony Liguori 	target_fsid_t f_fsid;
232856c8f68fSbellard 	uint32_t f_namelen;
232956c8f68fSbellard 	uint32_t f_frsize;
233056c8f68fSbellard 	uint32_t f_spare[5];
233156c8f68fSbellard };
233256c8f68fSbellard 
233356c8f68fSbellard struct target_statfs64 {
233456c8f68fSbellard 	uint32_t f_type;
233556c8f68fSbellard 	uint32_t f_bsize;
233656c8f68fSbellard 	uint64_t f_blocks;
233756c8f68fSbellard 	uint64_t f_bfree;
233856c8f68fSbellard 	uint64_t f_bavail;
233956c8f68fSbellard 	uint64_t f_files;
234056c8f68fSbellard 	uint64_t f_ffree;
2341c227f099SAnthony Liguori 	target_fsid_t f_fsid;
234256c8f68fSbellard         uint32_t f_namelen;
234356c8f68fSbellard 	uint32_t f_frsize;
234456c8f68fSbellard 	uint32_t f_spare[5];
234556c8f68fSbellard };
234656c8f68fSbellard #endif
234756c8f68fSbellard 
234856c8f68fSbellard 
23492521d698Sbellard #define TARGET_F_DUPFD         0       /* dup */
23502521d698Sbellard #define TARGET_F_GETFD         1       /* get close_on_exec */
23512521d698Sbellard #define TARGET_F_SETFD         2       /* set/clear close_on_exec */
23522521d698Sbellard #define TARGET_F_GETFL         3       /* get file->f_flags */
23532521d698Sbellard #define TARGET_F_SETFL         4       /* set file->f_flags */
23542521d698Sbellard 
23552521d698Sbellard #if defined(TARGET_ALPHA)
23562521d698Sbellard #define TARGET_F_GETLK         7
23572521d698Sbellard #define TARGET_F_SETLK         8
23582521d698Sbellard #define TARGET_F_SETLKW        9
23592521d698Sbellard #define TARGET_F_SETOWN        5       /*  for sockets. */
23602521d698Sbellard #define TARGET_F_GETOWN        6       /*  for sockets. */
23612ba7f730SLaurent Vivier 
23622ba7f730SLaurent Vivier #define TARGET_F_RDLCK         1
23632ba7f730SLaurent Vivier #define TARGET_F_WRLCK         2
23642ba7f730SLaurent Vivier #define TARGET_F_UNLCK         8
23652ba7f730SLaurent Vivier #define TARGET_F_EXLCK         16
23662ba7f730SLaurent Vivier #define TARGET_F_SHLCK         32
23675f106811SArnaud Patard (Rtp) #elif defined(TARGET_MIPS)
23685f106811SArnaud Patard (Rtp) #define TARGET_F_GETLK         14
23695f106811SArnaud Patard (Rtp) #define TARGET_F_SETLK         6
23705f106811SArnaud Patard (Rtp) #define TARGET_F_SETLKW        7
23715f106811SArnaud Patard (Rtp) #define TARGET_F_SETOWN        24       /*  for sockets. */
23723a87a954SAleksandar Markovic #define TARGET_F_GETOWN        23       /*  for sockets. */
2373b5c375e2SHelge Deller #elif defined(TARGET_HPPA)
23743d60c84dSHelge Deller #define TARGET_F_RDLCK         1
23753d60c84dSHelge Deller #define TARGET_F_WRLCK         2
23763d60c84dSHelge Deller #define TARGET_F_UNLCK         3
2377b5c375e2SHelge Deller #define TARGET_F_GETLK         5
2378b5c375e2SHelge Deller #define TARGET_F_SETLK         6
2379b5c375e2SHelge Deller #define TARGET_F_SETLKW        7
2380b5c375e2SHelge Deller #define TARGET_F_GETOWN        11       /*  for sockets. */
2381b5c375e2SHelge Deller #define TARGET_F_SETOWN        12       /*  for sockets. */
23822521d698Sbellard #else
23832521d698Sbellard #define TARGET_F_GETLK         5
23842521d698Sbellard #define TARGET_F_SETLK         6
23852521d698Sbellard #define TARGET_F_SETLKW        7
23862521d698Sbellard #define TARGET_F_SETOWN        8       /*  for sockets. */
23872521d698Sbellard #define TARGET_F_GETOWN        9       /*  for sockets. */
23882521d698Sbellard #endif
23898d5d3004SAndreas Schwab #define TARGET_F_SETOWN_EX     15
23908d5d3004SAndreas Schwab #define TARGET_F_GETOWN_EX     16
23912521d698Sbellard 
23922ba7f730SLaurent Vivier #ifndef TARGET_F_RDLCK
23932ba7f730SLaurent Vivier #define TARGET_F_RDLCK         0
23942ba7f730SLaurent Vivier #define TARGET_F_WRLCK         1
23952ba7f730SLaurent Vivier #define TARGET_F_UNLCK         2
23962ba7f730SLaurent Vivier #endif
23972ba7f730SLaurent Vivier 
23982ba7f730SLaurent Vivier #ifndef TARGET_F_EXLCK
23992ba7f730SLaurent Vivier #define TARGET_F_EXLCK         4
24002ba7f730SLaurent Vivier #define TARGET_F_SHLCK         8
24012ba7f730SLaurent Vivier #endif
24022ba7f730SLaurent Vivier 
24032ba7f730SLaurent Vivier 
2404b5c375e2SHelge Deller #if defined(TARGET_HPPA)
2405b5c375e2SHelge Deller #define TARGET_F_SETSIG        13      /*  for sockets. */
2406b5c375e2SHelge Deller #define TARGET_F_GETSIG        14      /*  for sockets. */
2407b5c375e2SHelge Deller #else
24082521d698Sbellard #define TARGET_F_SETSIG        10      /*  for sockets. */
24092521d698Sbellard #define TARGET_F_GETSIG        11      /*  for sockets. */
2410b5c375e2SHelge Deller #endif
24112521d698Sbellard 
24125f106811SArnaud Patard (Rtp) #if defined(TARGET_MIPS)
24135f106811SArnaud Patard (Rtp) #define TARGET_F_GETLK64       33      /*  using 'struct flock64' */
24145f106811SArnaud Patard (Rtp) #define TARGET_F_SETLK64       34
24155f106811SArnaud Patard (Rtp) #define TARGET_F_SETLKW64      35
2416b5c375e2SHelge Deller #elif defined(TARGET_HPPA)
2417b5c375e2SHelge Deller #define TARGET_F_GETLK64       8       /*  using 'struct flock64' */
2418b5c375e2SHelge Deller #define TARGET_F_SETLK64       9
2419b5c375e2SHelge Deller #define TARGET_F_SETLKW64      10
24205f106811SArnaud Patard (Rtp) #else
24212521d698Sbellard #define TARGET_F_GETLK64       12      /*  using 'struct flock64' */
24222521d698Sbellard #define TARGET_F_SETLK64       13
24232521d698Sbellard #define TARGET_F_SETLKW64      14
24245f106811SArnaud Patard (Rtp) #endif
24257e22e546SUlrich Hecht 
24267e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
24277e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
24287e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
24297e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
24307e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
24317e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
24327e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
24337e22e546SUlrich Hecht 
24344eeea4f3SRichard Henderson #if defined(TARGET_ALPHA)
24354eeea4f3SRichard Henderson #define TARGET_O_NONBLOCK           04
24364eeea4f3SRichard Henderson #define TARGET_O_APPEND            010
24374eeea4f3SRichard Henderson #define TARGET_O_CREAT           01000 /* not fcntl */
24384eeea4f3SRichard Henderson #define TARGET_O_TRUNC           02000 /* not fcntl */
24394eeea4f3SRichard Henderson #define TARGET_O_EXCL            04000 /* not fcntl */
24404eeea4f3SRichard Henderson #define TARGET_O_NOCTTY         010000 /* not fcntl */
24414eeea4f3SRichard Henderson #define TARGET_O_DSYNC          040000
24424eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE           0 /* not necessary, always 64-bit */
24434eeea4f3SRichard Henderson #define TARGET_O_DIRECTORY     0100000 /* must be a directory */
24444eeea4f3SRichard Henderson #define TARGET_O_NOFOLLOW      0200000 /* don't follow links */
24454eeea4f3SRichard Henderson #define TARGET_O_DIRECT       02000000 /* direct disk access hint */
24464eeea4f3SRichard Henderson #define TARGET_O_NOATIME      04000000
24474eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC     010000000
24484eeea4f3SRichard Henderson #define TARGET___O_SYNC      020000000
24494eeea4f3SRichard Henderson #define TARGET_O_PATH        040000000
2450a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2451a10d1e50SRichard Henderson #define TARGET_O_NONBLOCK    000200004 /* HPUX has separate NDELAY & NONBLOCK */
2452a10d1e50SRichard Henderson #define TARGET_O_APPEND      000000010
2453a10d1e50SRichard Henderson #define TARGET_O_CREAT       000000400 /* not fcntl */
2454a10d1e50SRichard Henderson #define TARGET_O_EXCL        000002000 /* not fcntl */
2455a10d1e50SRichard Henderson #define TARGET_O_NOCTTY      000400000 /* not fcntl */
2456a10d1e50SRichard Henderson #define TARGET_O_DSYNC       001000000
2457a10d1e50SRichard Henderson #define TARGET_O_LARGEFILE   000004000
2458a10d1e50SRichard Henderson #define TARGET_O_DIRECTORY   000010000 /* must be a directory */
2459a10d1e50SRichard Henderson #define TARGET_O_NOFOLLOW    000000200 /* don't follow links */
2460a10d1e50SRichard Henderson #define TARGET_O_NOATIME     004000000
2461a10d1e50SRichard Henderson #define TARGET_O_CLOEXEC     010000000
2462a10d1e50SRichard Henderson #define TARGET___O_SYNC      000100000
2463a10d1e50SRichard Henderson #define TARGET_O_PATH        020000000
24645f9cee46SRiku Voipio #elif defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_AARCH64)
2465f09936acSbellard #define TARGET_O_DIRECTORY      040000 /* must be a directory */
2466f09936acSbellard #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
2467f09936acSbellard #define TARGET_O_DIRECT        0200000 /* direct disk access hint */
2468f09936acSbellard #define TARGET_O_LARGEFILE     0400000
2469048f6b4dSbellard #elif defined(TARGET_MIPS)
2470048f6b4dSbellard #define TARGET_O_APPEND         0x0008
24714eeea4f3SRichard Henderson #define TARGET_O_DSYNC          0x0010
2472048f6b4dSbellard #define TARGET_O_NONBLOCK       0x0080
2473048f6b4dSbellard #define TARGET_O_CREAT          0x0100  /* not fcntl */
2474048f6b4dSbellard #define TARGET_O_TRUNC          0x0200  /* not fcntl */
2475048f6b4dSbellard #define TARGET_O_EXCL           0x0400  /* not fcntl */
2476048f6b4dSbellard #define TARGET_O_NOCTTY         0x0800  /* not fcntl */
2477048f6b4dSbellard #define TARGET_FASYNC           0x1000  /* fcntl, for BSD compatibility */
2478048f6b4dSbellard #define TARGET_O_LARGEFILE      0x2000  /* allow large file opens */
24794eeea4f3SRichard Henderson #define TARGET___O_SYNC         0x4000
2480048f6b4dSbellard #define TARGET_O_DIRECT         0x8000  /* direct disk access hint */
24814eeea4f3SRichard Henderson #elif defined (TARGET_PPC)
24824eeea4f3SRichard Henderson #define TARGET_O_DIRECTORY      040000 /* must be a directory */
24834eeea4f3SRichard Henderson #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
24844eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE     0200000
24854eeea4f3SRichard Henderson #define TARGET_O_DIRECT        0400000 /* direct disk access hint */
24864eeea4f3SRichard Henderson #elif defined (TARGET_SPARC)
24871f961124Saurel32 #define TARGET_O_APPEND         0x0008
24884eeea4f3SRichard Henderson #define TARGET_FASYNC           0x0040  /* fcntl, for BSD compatibility */
24891f961124Saurel32 #define TARGET_O_CREAT          0x0200  /* not fcntl */
24901f961124Saurel32 #define TARGET_O_TRUNC          0x0400  /* not fcntl */
24911f961124Saurel32 #define TARGET_O_EXCL           0x0800  /* not fcntl */
24924eeea4f3SRichard Henderson #define TARGET_O_DSYNC          0x2000
24934eeea4f3SRichard Henderson #define TARGET_O_NONBLOCK       0x4000
24944eeea4f3SRichard Henderson # ifdef TARGET_SPARC64
24954eeea4f3SRichard Henderson #  define TARGET_O_NDELAY       0x0004
2496ffa65c3bSbellard # else
24974eeea4f3SRichard Henderson #  define TARGET_O_NDELAY       (0x0004 | TARGET_O_NONBLOCK)
24984eeea4f3SRichard Henderson # endif
24994eeea4f3SRichard Henderson #define TARGET_O_NOCTTY         0x8000  /* not fcntl */
25004eeea4f3SRichard Henderson #define TARGET_O_LARGEFILE     0x40000
25014eeea4f3SRichard Henderson #define TARGET_O_DIRECT       0x100000  /* direct disk access hint */
25024eeea4f3SRichard Henderson #define TARGET_O_NOATIME      0x200000
25034eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC      0x400000
25044eeea4f3SRichard Henderson #define TARGET___O_SYNC       0x800000
25054eeea4f3SRichard Henderson #define TARGET_O_PATH        0x1000000
25064eeea4f3SRichard Henderson #endif
25074eeea4f3SRichard Henderson 
25084eeea4f3SRichard Henderson /* <asm-generic/fcntl.h> values follow.  */
2509ffa65c3bSbellard #define TARGET_O_ACCMODE          0003
2510ffa65c3bSbellard #define TARGET_O_RDONLY             00
2511ffa65c3bSbellard #define TARGET_O_WRONLY             01
2512ffa65c3bSbellard #define TARGET_O_RDWR               02
25134eeea4f3SRichard Henderson #ifndef TARGET_O_CREAT
2514ffa65c3bSbellard #define TARGET_O_CREAT            0100 /* not fcntl */
25154eeea4f3SRichard Henderson #endif
25164eeea4f3SRichard Henderson #ifndef TARGET_O_EXCL
2517ffa65c3bSbellard #define TARGET_O_EXCL             0200 /* not fcntl */
25184eeea4f3SRichard Henderson #endif
25194eeea4f3SRichard Henderson #ifndef TARGET_O_NOCTTY
2520ffa65c3bSbellard #define TARGET_O_NOCTTY           0400 /* not fcntl */
25214eeea4f3SRichard Henderson #endif
25224eeea4f3SRichard Henderson #ifndef TARGET_O_TRUNC
2523ffa65c3bSbellard #define TARGET_O_TRUNC           01000 /* not fcntl */
25244eeea4f3SRichard Henderson #endif
25254eeea4f3SRichard Henderson #ifndef TARGET_O_APPEND
2526ffa65c3bSbellard #define TARGET_O_APPEND          02000
25274eeea4f3SRichard Henderson #endif
25284eeea4f3SRichard Henderson #ifndef TARGET_O_NONBLOCK
2529ffa65c3bSbellard #define TARGET_O_NONBLOCK        04000
25304eeea4f3SRichard Henderson #endif
25314eeea4f3SRichard Henderson #ifndef TARGET_O_DSYNC
25324eeea4f3SRichard Henderson #define TARGET_O_DSYNC          010000
25334eeea4f3SRichard Henderson #endif
25344eeea4f3SRichard Henderson #ifndef TARGET_FASYNC
2535ffa65c3bSbellard #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
25364eeea4f3SRichard Henderson #endif
25374eeea4f3SRichard Henderson #ifndef TARGET_O_DIRECT
2538ffa65c3bSbellard #define TARGET_O_DIRECT         040000 /* direct disk access hint */
25394eeea4f3SRichard Henderson #endif
25404eeea4f3SRichard Henderson #ifndef TARGET_O_LARGEFILE
2541ffa65c3bSbellard #define TARGET_O_LARGEFILE     0100000
25424eeea4f3SRichard Henderson #endif
25434eeea4f3SRichard Henderson #ifndef TARGET_O_DIRECTORY
2544ffa65c3bSbellard #define TARGET_O_DIRECTORY     0200000 /* must be a directory */
25454eeea4f3SRichard Henderson #endif
25464eeea4f3SRichard Henderson #ifndef TARGET_O_NOFOLLOW
2547ffa65c3bSbellard #define TARGET_O_NOFOLLOW      0400000 /* don't follow links */
2548ffa65c3bSbellard #endif
25494eeea4f3SRichard Henderson #ifndef TARGET_O_NOATIME
25504eeea4f3SRichard Henderson #define TARGET_O_NOATIME      01000000
25514eeea4f3SRichard Henderson #endif
25524eeea4f3SRichard Henderson #ifndef TARGET_O_CLOEXEC
25534eeea4f3SRichard Henderson #define TARGET_O_CLOEXEC      02000000
25544eeea4f3SRichard Henderson #endif
25554eeea4f3SRichard Henderson #ifndef TARGET___O_SYNC
25564eeea4f3SRichard Henderson #define TARGET___O_SYNC       04000000
25574eeea4f3SRichard Henderson #endif
25584eeea4f3SRichard Henderson #ifndef TARGET_O_PATH
25594eeea4f3SRichard Henderson #define TARGET_O_PATH        010000000
25604eeea4f3SRichard Henderson #endif
25615f9cee46SRiku Voipio #ifndef TARGET___O_TMPFILE
25625f9cee46SRiku Voipio #define TARGET___O_TMPFILE   020000000
25635f9cee46SRiku Voipio #endif
25645f9cee46SRiku Voipio #ifndef TARGET_O_TMPFILE
25655f9cee46SRiku Voipio #define TARGET_O_TMPFILE     (TARGET___O_TMPFILE | TARGET_O_DIRECTORY)
25665f9cee46SRiku Voipio #endif
25674eeea4f3SRichard Henderson #ifndef TARGET_O_NDELAY
25684eeea4f3SRichard Henderson #define TARGET_O_NDELAY  TARGET_O_NONBLOCK
25694eeea4f3SRichard Henderson #endif
25704eeea4f3SRichard Henderson #ifndef TARGET_O_SYNC
25714eeea4f3SRichard Henderson #define TARGET_O_SYNC    (TARGET___O_SYNC | TARGET_O_DSYNC)
25724eeea4f3SRichard Henderson #endif
2573ffa65c3bSbellard 
25742521d698Sbellard struct target_flock {
25752521d698Sbellard     short l_type;
25762521d698Sbellard     short l_whence;
25778efb2ed5SPeter Maydell     abi_long l_start;
25788efb2ed5SPeter Maydell     abi_long l_len;
25798a8001b1SAleksandar Markovic #if defined(TARGET_MIPS)
25808a8001b1SAleksandar Markovic     abi_long l_sysid;
25818a8001b1SAleksandar Markovic #endif
25822521d698Sbellard     int l_pid;
25838a8001b1SAleksandar Markovic #if defined(TARGET_MIPS)
25848a8001b1SAleksandar Markovic     abi_long pad[4];
25858a8001b1SAleksandar Markovic #endif
25862521d698Sbellard };
25872521d698Sbellard 
25882521d698Sbellard struct target_flock64 {
25892521d698Sbellard     short  l_type;
25902521d698Sbellard     short  l_whence;
2591429b31a2SRichard Henderson #if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) \
2592429b31a2SRichard Henderson     || defined(TARGET_SPARC) || defined(TARGET_HPPA) \
2593b16189b2SChen Gang     || defined(TARGET_MICROBLAZE) || defined(TARGET_TILEGX)
2594ce3f0e2fSaurel32     int __pad;
2595ce3f0e2fSaurel32 #endif
25968efb2ed5SPeter Maydell     abi_llong l_start;
25978efb2ed5SPeter Maydell     abi_llong l_len;
25982521d698Sbellard     int  l_pid;
2599541dc0d4SStefan Weil } QEMU_PACKED;
26002521d698Sbellard 
2601ce4defa0Spbrook #ifdef TARGET_ARM
2602ce4defa0Spbrook struct target_eabi_flock64 {
2603ce4defa0Spbrook     short  l_type;
2604ce4defa0Spbrook     short  l_whence;
2605ce4defa0Spbrook     int __pad;
26068efb2ed5SPeter Maydell     abi_llong l_start;
26078efb2ed5SPeter Maydell     abi_llong l_len;
2608ce4defa0Spbrook     int  l_pid;
2609541dc0d4SStefan Weil } QEMU_PACKED;
2610ce4defa0Spbrook #endif
26112521d698Sbellard 
26128d5d3004SAndreas Schwab struct target_f_owner_ex {
26138d5d3004SAndreas Schwab         int type;	/* Owner type of ID.  */
26148d5d3004SAndreas Schwab         int pid;	/* ID of owner.  */
26158d5d3004SAndreas Schwab };
26168d5d3004SAndreas Schwab 
26172521d698Sbellard /* soundcard defines */
261867cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
26192521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
26202521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
26212521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
26222521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
26232521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
26242521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
26252521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
26262521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
26272521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
26282521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
26292521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
26302521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
26312521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
26322521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
26332521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
26342521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
26352521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
26362521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
26372521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
26382521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
26392521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
26402521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
26412521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
26422521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
26432521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
26442521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
26452521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
26462521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
26475f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
26485f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
26492521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
26502521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
26512521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
26522521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
26532521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
26542521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
26552521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
26562521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
26572521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
26582521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
26592521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
26602521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
26612521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
26622521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
26632521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
26642521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
26652521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
26662521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
26672521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
26682521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
26692521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
26702521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
26712521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
26722521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
26732521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
26742521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
26752521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
26762521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
26772521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
26782521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
26792521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
26802521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
26812521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
26822521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
26832521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
26842521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
26852521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
26862521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
26872521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
26882521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
26892521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
26902521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
26912521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
26922521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
26932521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
26942521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
26952521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
26962521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
26972521d698Sbellard 
26982521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
26992521d698Sbellard 
27002521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
27012521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
27022521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
27032521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
27042521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
27052521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
27062521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
27072521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
27082521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
27092521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
27102521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
27112521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
27122521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
27132521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
27142521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
27152521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
27162521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
27172521d698Sbellard 
27182521d698Sbellard /* Obsolete macros */
27192521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
27202521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
27212521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
27222521d698Sbellard 
27232521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
27242521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
27252521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
27262521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
27272521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
27282521d698Sbellard 
27292521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
27302521d698Sbellard 
27312521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
27322521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
27332521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
27342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
27352521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
27362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
27372521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
27382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
27392521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
27402521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
27412521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
27422521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
27432521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
27442521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
27452521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
27462521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
27472521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
27482521d698Sbellard 
27492521d698Sbellard /* Obsolete macros */
27502521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
27512521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
27522521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
27532521d698Sbellard 
27542521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
27552521d698Sbellard 
27562521d698Sbellard /* vfat ioctls */
27572521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
27582521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2759a5448a7dSbellard 
2760f443e396SPeter Maydell struct target_mtop {
2761f443e396SPeter Maydell     abi_short mt_op;
2762f443e396SPeter Maydell     abi_int mt_count;
2763f443e396SPeter Maydell };
2764f443e396SPeter Maydell 
2765f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2766f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2767f443e396SPeter Maydell #else
2768f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2769f443e396SPeter Maydell #endif
2770f443e396SPeter Maydell 
2771f443e396SPeter Maydell struct target_mtget {
2772f443e396SPeter Maydell     abi_long mt_type;
2773f443e396SPeter Maydell     abi_long mt_resid;
2774f443e396SPeter Maydell     abi_long mt_dsreg;
2775f443e396SPeter Maydell     abi_long mt_gstat;
2776f443e396SPeter Maydell     abi_long mt_erreg;
2777f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2778f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2779f443e396SPeter Maydell };
2780f443e396SPeter Maydell 
2781f443e396SPeter Maydell struct target_mtpos {
2782f443e396SPeter Maydell     abi_long mt_blkno;
2783f443e396SPeter Maydell };
2784f443e396SPeter Maydell 
2785f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2786f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2787f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
27888fbd6b52Sbalrog 
2789a5448a7dSbellard struct target_sysinfo {
2790992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2791992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2792992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2793992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2794992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2795992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2796992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2797992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2798a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2799a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2800992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2801992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2802a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2803992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2804a5448a7dSbellard };
28053532fa74Sbellard 
28066556a833Saurel32 struct linux_dirent {
28076556a833Saurel32     long            d_ino;
28086556a833Saurel32     unsigned long   d_off;
28096556a833Saurel32     unsigned short  d_reclen;
28106556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
28116556a833Saurel32 };
28126556a833Saurel32 
28136556a833Saurel32 struct linux_dirent64 {
28146556a833Saurel32     uint64_t        d_ino;
28156556a833Saurel32     int64_t         d_off;
28166556a833Saurel32     unsigned short  d_reclen;
28176556a833Saurel32     unsigned char   d_type;
28186556a833Saurel32     char            d_name[256];
28196556a833Saurel32 };
28206556a833Saurel32 
282124e1003aSaurel32 struct target_mq_attr {
282224e1003aSaurel32     abi_long mq_flags;
282324e1003aSaurel32     abi_long mq_maxmsg;
282424e1003aSaurel32     abi_long mq_msgsize;
282524e1003aSaurel32     abi_long mq_curmsgs;
282624e1003aSaurel32 };
282724e1003aSaurel32 
28283532fa74Sbellard #include "socket.h"
2829637947f1Sths 
2830637947f1Sths #include "errno_defs.h"
283103dfe9f8SRiku Voipio 
283203dfe9f8SRiku Voipio #define FUTEX_WAIT              0
283303dfe9f8SRiku Voipio #define FUTEX_WAKE              1
283403dfe9f8SRiku Voipio #define FUTEX_FD                2
283503dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
283603dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
283703dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
283803dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
283903dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
284003dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
284103dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
284203dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
284303dfe9f8SRiku Voipio 
284403dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
284503dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
284603dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
284703dfe9f8SRiku Voipio 
28483b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2849928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2850928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2851928bed6aSLaurent Vivier #else
2852928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2853928bed6aSLaurent Vivier #endif
2854928bed6aSLaurent Vivier 
28553b6edd16SPeter Maydell typedef union target_epoll_data {
28563b6edd16SPeter Maydell     abi_ulong ptr;
2857928bed6aSLaurent Vivier     abi_int fd;
2858928bed6aSLaurent Vivier     abi_uint u32;
2859928bed6aSLaurent Vivier     abi_ullong u64;
28603b6edd16SPeter Maydell } target_epoll_data_t;
28613b6edd16SPeter Maydell 
28623b6edd16SPeter Maydell struct target_epoll_event {
2863928bed6aSLaurent Vivier     abi_uint events;
28643b6edd16SPeter Maydell     target_epoll_data_t data;
2865928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
28662ba7fae3SPeter Maydell 
28672ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
28682ba7fae3SPeter Maydell 
28693b6edd16SPeter Maydell #endif
2870163a05a8SPeter Maydell struct target_rlimit64 {
2871163a05a8SPeter Maydell     uint64_t rlim_cur;
2872163a05a8SPeter Maydell     uint64_t rlim_max;
2873163a05a8SPeter Maydell };
2874583359a6SAkos PASZTORY 
2875583359a6SAkos PASZTORY struct target_ucred {
2876583359a6SAkos PASZTORY     uint32_t pid;
2877583359a6SAkos PASZTORY     uint32_t uid;
2878583359a6SAkos PASZTORY     uint32_t gid;
2879583359a6SAkos PASZTORY };
2880cb9c377fSPaolo Bonzini 
2881aecc8861SAlexander Graf typedef int32_t target_timer_t;
2882905bba13SErik de Castro Lopo 
288334d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
288434d60862SNatanael Copa 
288534d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
288634d60862SNatanael Copa #ifdef TARGET_MIPS
288734d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
288834d60862SNatanael Copa #else
288934d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
289034d60862SNatanael Copa                                     + sizeof(target_sigval_t))
289134d60862SNatanael Copa #endif
289234d60862SNatanael Copa 
289334d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
289434d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
289534d60862SNatanael Copa                                / sizeof(int32_t))
289634d60862SNatanael Copa 
2897905bba13SErik de Castro Lopo struct target_sigevent {
2898905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
289917351c3fSPeter Maydell     abi_int sigev_signo;
290017351c3fSPeter Maydell     abi_int sigev_notify;
2901905bba13SErik de Castro Lopo     union {
290217351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
290317351c3fSPeter Maydell         abi_int _tid;
2904905bba13SErik de Castro Lopo 
290517351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
290617351c3fSPeter Maydell          * they're only used as part of the ABI between a
290717351c3fSPeter Maydell          * userspace program and libc.
290817351c3fSPeter Maydell          */
2909905bba13SErik de Castro Lopo         struct {
291017351c3fSPeter Maydell             abi_ulong _function;
291117351c3fSPeter Maydell             abi_ulong _attribute;
2912905bba13SErik de Castro Lopo         } _sigev_thread;
2913905bba13SErik de Castro Lopo     } _sigev_un;
2914905bba13SErik de Castro Lopo };
2915e0eb210eSPeter Maydell 
2916e0eb210eSPeter Maydell struct target_user_cap_header {
2917e0eb210eSPeter Maydell     uint32_t version;
2918e0eb210eSPeter Maydell     int pid;
2919e0eb210eSPeter Maydell };
2920e0eb210eSPeter Maydell 
2921e0eb210eSPeter Maydell struct target_user_cap_data {
2922e0eb210eSPeter Maydell     uint32_t effective;
2923e0eb210eSPeter Maydell     uint32_t permitted;
2924e0eb210eSPeter Maydell     uint32_t inheritable;
2925e0eb210eSPeter Maydell };
29261b3c4fdfSMarkus Armbruster 
2927da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2928da2c8ad7SAleksandar Markovic 
2929da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2930da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2931da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2932da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2933da2c8ad7SAleksandar Markovic /* Read from the log. */
2934da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2935da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2936da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2937da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2938da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2939da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2940da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2941da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2942da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2943da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2944da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2945da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2946da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2947da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2948da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2949da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2950da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2951da2c8ad7SAleksandar Markovic 
29521b3c4fdfSMarkus Armbruster #endif
2953