xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 5f992db605e2c9ed0c8816c2b0f68b9bc8698f1b)
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) \
72daa4374aSPeter Maydell     || defined(TARGET_S390X) \
73a0a839b6SMarek Vasut     || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
74ba7651fbSMax Filippov     || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
75ba7651fbSMax Filippov     || defined(TARGET_XTENSA)
762521d698Sbellard 
772521d698Sbellard #define TARGET_IOC_SIZEBITS	14
782521d698Sbellard #define TARGET_IOC_DIRBITS	2
792521d698Sbellard 
802521d698Sbellard #define TARGET_IOC_NONE	  0U
812521d698Sbellard #define TARGET_IOC_WRITE  1U
822521d698Sbellard #define TARGET_IOC_READ	  2U
832521d698Sbellard 
84048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
85b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
86b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
872521d698Sbellard 
882521d698Sbellard #define TARGET_IOC_SIZEBITS	13
892521d698Sbellard #define TARGET_IOC_DIRBITS	3
902521d698Sbellard 
912521d698Sbellard #define TARGET_IOC_NONE	  1U
922521d698Sbellard #define TARGET_IOC_READ	  2U
932521d698Sbellard #define TARGET_IOC_WRITE  4U
942521d698Sbellard 
95a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
96a10d1e50SRichard Henderson 
97a10d1e50SRichard Henderson #define TARGET_IOC_SIZEBITS  14
98a10d1e50SRichard Henderson #define TARGET_IOC_DIRBITS    2
99a10d1e50SRichard Henderson 
100a10d1e50SRichard Henderson #define TARGET_IOC_NONE   0U
101a10d1e50SRichard Henderson #define TARGET_IOC_WRITE  2U
102a10d1e50SRichard Henderson #define TARGET_IOC_READ   1U
103a10d1e50SRichard Henderson 
1042521d698Sbellard #else
1052521d698Sbellard #error unsupported CPU
1062521d698Sbellard #endif
1072521d698Sbellard 
1082521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
1092521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
1102521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
1112521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
1122521d698Sbellard 
1132521d698Sbellard #define TARGET_IOC_NRSHIFT	0
1142521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
1152521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
1162521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
1172521d698Sbellard 
1182521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
1192521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
1202521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
1212521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1222521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1232521d698Sbellard 
1242521d698Sbellard /* used to create numbers */
1252521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1262521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1272521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1282521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1292521d698Sbellard 
1302521d698Sbellard /* the size is automatically computed for these defines */
1312521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1322521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1332521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1342521d698Sbellard 
1357854b056Sbellard struct target_sockaddr {
1367854b056Sbellard     uint16_t sa_family;
1377854b056Sbellard     uint8_t sa_data[14];
1387854b056Sbellard };
1397854b056Sbellard 
14033a29b51SJoakim Tjernlund struct target_sockaddr_ll {
14133a29b51SJoakim Tjernlund     uint16_t sll_family;   /* Always AF_PACKET */
14233a29b51SJoakim Tjernlund     uint16_t sll_protocol; /* Physical layer protocol */
14333a29b51SJoakim Tjernlund     int      sll_ifindex;  /* Interface number */
14433a29b51SJoakim Tjernlund     uint16_t sll_hatype;   /* ARP hardware type */
14533a29b51SJoakim Tjernlund     uint8_t  sll_pkttype;  /* Packet type */
14633a29b51SJoakim Tjernlund     uint8_t  sll_halen;    /* Length of address */
14733a29b51SJoakim Tjernlund     uint8_t  sll_addr[8];  /* Physical layer address */
14833a29b51SJoakim Tjernlund };
14933a29b51SJoakim Tjernlund 
150fb3aabf3SLaurent Vivier struct target_sockaddr_un {
151fb3aabf3SLaurent Vivier     uint16_t su_family;
152fb3aabf3SLaurent Vivier     uint8_t sun_path[108];
153fb3aabf3SLaurent Vivier };
154fb3aabf3SLaurent Vivier 
155fb3aabf3SLaurent Vivier struct target_in_addr {
156fb3aabf3SLaurent Vivier     uint32_t s_addr; /* big endian */
157fb3aabf3SLaurent Vivier };
158fb3aabf3SLaurent Vivier 
159fb3aabf3SLaurent Vivier struct target_sockaddr_in {
160fb3aabf3SLaurent Vivier   uint16_t sin_family;
161fb3aabf3SLaurent Vivier   int16_t sin_port; /* big endian */
162fb3aabf3SLaurent Vivier   struct target_in_addr sin_addr;
163fb3aabf3SLaurent Vivier   uint8_t __pad[sizeof(struct target_sockaddr) -
164fb3aabf3SLaurent Vivier                 sizeof(uint16_t) - sizeof(int16_t) -
165fb3aabf3SLaurent Vivier                 sizeof(struct target_in_addr)];
166fb3aabf3SLaurent Vivier };
167fb3aabf3SLaurent Vivier 
168ee1ac3a1SHelge Deller struct target_sockaddr_in6 {
169ee1ac3a1SHelge Deller     uint16_t sin6_family;
170ee1ac3a1SHelge Deller     uint16_t sin6_port; /* big endian */
171ee1ac3a1SHelge Deller     uint32_t sin6_flowinfo; /* big endian */
172ee1ac3a1SHelge Deller     struct in6_addr sin6_addr; /* IPv6 address, big endian */
173ee1ac3a1SHelge Deller     uint32_t sin6_scope_id;
174ee1ac3a1SHelge Deller };
175ee1ac3a1SHelge Deller 
176f57d4192SLaurent Vivier struct target_sock_filter {
177f57d4192SLaurent Vivier     abi_ushort code;
178f57d4192SLaurent Vivier     uint8_t jt;
179f57d4192SLaurent Vivier     uint8_t jf;
180f57d4192SLaurent Vivier     abi_uint k;
181f57d4192SLaurent Vivier };
182f57d4192SLaurent Vivier 
183f57d4192SLaurent Vivier struct target_sock_fprog {
184f57d4192SLaurent Vivier     abi_ushort len;
185f57d4192SLaurent Vivier     abi_ulong filter;
186f57d4192SLaurent Vivier };
187f57d4192SLaurent Vivier 
188b975b83bSLionel Landwerlin struct target_ip_mreq {
189b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
190b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
191b975b83bSLionel Landwerlin };
192b975b83bSLionel Landwerlin 
193b975b83bSLionel Landwerlin struct target_ip_mreqn {
194b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
195b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
196b975b83bSLionel Landwerlin     abi_long imr_ifindex;
197b975b83bSLionel Landwerlin };
198b975b83bSLionel Landwerlin 
1996e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
2006e3cb58fSLionel Landwerlin     /* big endian */
2016e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
2026e3cb58fSLionel Landwerlin     uint32_t imr_interface;
2036e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
2046e3cb58fSLionel Landwerlin };
2056e3cb58fSLionel Landwerlin 
20683eb6e50SCarlo Marcelo Arenas Belón struct target_linger {
20783eb6e50SCarlo Marcelo Arenas Belón     abi_int l_onoff;        /* Linger active                */
20883eb6e50SCarlo Marcelo Arenas Belón     abi_int l_linger;       /* How long to linger for       */
20983eb6e50SCarlo Marcelo Arenas Belón };
21083eb6e50SCarlo Marcelo Arenas Belón 
21131e31b8aSbellard struct target_timeval {
212992f48a0Sblueswir1     abi_long tv_sec;
213992f48a0Sblueswir1     abi_long tv_usec;
21431e31b8aSbellard };
21531e31b8aSbellard 
2161b6b029eSbellard struct target_timespec {
217992f48a0Sblueswir1     abi_long tv_sec;
218992f48a0Sblueswir1     abi_long tv_nsec;
2191b6b029eSbellard };
2201b6b029eSbellard 
221ef4467e9SPaul Burton struct target_timezone {
222ef4467e9SPaul Burton     abi_int tz_minuteswest;
223ef4467e9SPaul Burton     abi_int tz_dsttime;
224ef4467e9SPaul Burton };
225ef4467e9SPaul Burton 
22666fb9763Sbellard struct target_itimerval {
22766fb9763Sbellard     struct target_timeval it_interval;
22866fb9763Sbellard     struct target_timeval it_value;
22966fb9763Sbellard };
23066fb9763Sbellard 
231905bba13SErik de Castro Lopo struct target_itimerspec {
232905bba13SErik de Castro Lopo     struct target_timespec it_interval;
233905bba13SErik de Castro Lopo     struct target_timespec it_value;
234905bba13SErik de Castro Lopo };
235905bba13SErik de Castro Lopo 
23619f59bceSAleksandar Markovic struct target_timex {
23719f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
23819f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
23919f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
24019f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
24119f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
24219f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
24319f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
24419f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
24519f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
24619f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
24719f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
24819f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
24919f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
25019f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
25119f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
25219f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
25319f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
25419f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
25519f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
25619f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
25719f59bceSAleksandar Markovic 
25819f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
25919f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
26019f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
26119f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
26219f59bceSAleksandar Markovic };
26319f59bceSAleksandar Markovic 
264c227f099SAnthony Liguori typedef abi_long target_clock_t;
26532f36bceSbellard 
266c596ed17Sbellard #define TARGET_HZ 100
267c596ed17Sbellard 
26832f36bceSbellard struct target_tms {
269c227f099SAnthony Liguori     target_clock_t tms_utime;
270c227f099SAnthony Liguori     target_clock_t tms_stime;
271c227f099SAnthony Liguori     target_clock_t tms_cutime;
272c227f099SAnthony Liguori     target_clock_t tms_cstime;
27332f36bceSbellard };
27432f36bceSbellard 
2756180a181Sbellard struct target_utimbuf {
276992f48a0Sblueswir1     abi_long actime;
277992f48a0Sblueswir1     abi_long modtime;
2786180a181Sbellard };
2796180a181Sbellard 
280f2674e31Sbellard struct target_sel_arg_struct {
281992f48a0Sblueswir1     abi_long n;
282992f48a0Sblueswir1     abi_long inp, outp, exp;
283992f48a0Sblueswir1     abi_long tvp;
284f2674e31Sbellard };
285f2674e31Sbellard 
28631e31b8aSbellard struct target_iovec {
287992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
288992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
28931e31b8aSbellard };
29031e31b8aSbellard 
2911a9353d2Sbellard struct target_msghdr {
292992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
2931a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
294992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
295992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
296992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
297992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
2981a9353d2Sbellard     unsigned int msg_flags;
2991a9353d2Sbellard };
3001a9353d2Sbellard 
3017854b056Sbellard struct target_cmsghdr {
302992f48a0Sblueswir1     abi_long     cmsg_len;
3037854b056Sbellard     int          cmsg_level;
3047854b056Sbellard     int          cmsg_type;
3057854b056Sbellard };
3067854b056Sbellard 
3077854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
308ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
309ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
310992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
311992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
312ad762b99SPeter Maydell #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
313ad762b99SPeter Maydell                                 TARGET_CMSG_ALIGN(len))
314ad762b99SPeter Maydell #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
3157854b056Sbellard 
3167854b056Sbellard static __inline__ struct target_cmsghdr *
317ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
318ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
319ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3207854b056Sbellard {
3212b8bdefcSths   struct target_cmsghdr *__ptr;
3227854b056Sbellard 
3232b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
324cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
325ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
326ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3277854b056Sbellard     /* No more entries.  */
3282b8bdefcSths     return (struct target_cmsghdr *)0;
329ee104587SJonathan Neuschäfer   }
330ee104587SJonathan Neuschäfer   return __ptr;
3317854b056Sbellard }
3327854b056Sbellard 
333f19e00d7SAlexander Graf struct target_mmsghdr {
334f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
335f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
336f19e00d7SAlexander Graf };
3377854b056Sbellard 
33831e31b8aSbellard struct  target_rusage {
33931e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
34031e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
341992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
342992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
343992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
344992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
345992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
346992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
347992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
348992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
349992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
350992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
351992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
352992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
353992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
354992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
35531e31b8aSbellard };
35631e31b8aSbellard 
35731e31b8aSbellard typedef struct {
35831e31b8aSbellard         int     val[2];
359c227f099SAnthony Liguori } kernel_fsid_t;
36031e31b8aSbellard 
361dab2ed99Sbellard struct target_dirent {
362992f48a0Sblueswir1         abi_long        d_ino;
363992f48a0Sblueswir1         abi_long        d_off;
364dab2ed99Sbellard         unsigned short  d_reclen;
365333858b7SDmitry V. Levin         char            d_name[];
366dab2ed99Sbellard };
367dab2ed99Sbellard 
368dab2ed99Sbellard struct target_dirent64 {
369dab2ed99Sbellard 	uint64_t	d_ino;
370dab2ed99Sbellard 	int64_t		d_off;
371dab2ed99Sbellard 	unsigned short	d_reclen;
372dab2ed99Sbellard 	unsigned char	d_type;
373dab2ed99Sbellard 	char		d_name[256];
374dab2ed99Sbellard };
375dab2ed99Sbellard 
376dab2ed99Sbellard 
37731e31b8aSbellard /* mostly generic signal stuff */
378992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
379992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
380992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
38131e31b8aSbellard 
38231e31b8aSbellard #ifdef TARGET_MIPS
38331e31b8aSbellard #define TARGET_NSIG	   128
38431e31b8aSbellard #else
38531e31b8aSbellard #define TARGET_NSIG	   64
38631e31b8aSbellard #endif
387992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
38831e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
38931e31b8aSbellard 
39031e31b8aSbellard typedef struct {
391992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
392c227f099SAnthony Liguori } target_sigset_t;
39331e31b8aSbellard 
39466fb9763Sbellard #ifdef BSWAP_NEEDED
395c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
39666fb9763Sbellard {
39766fb9763Sbellard     int i;
39866fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
399cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
40066fb9763Sbellard }
40166fb9763Sbellard #else
402c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
40366fb9763Sbellard {
40466fb9763Sbellard     *d = *s;
40566fb9763Sbellard }
40666fb9763Sbellard #endif
40766fb9763Sbellard 
408c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
40966fb9763Sbellard {
41066fb9763Sbellard     int i;
41166fb9763Sbellard     d->sig[0] = set;
41266fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
41366fb9763Sbellard         d->sig[i] = 0;
41466fb9763Sbellard }
41566fb9763Sbellard 
416c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
417c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
418992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
41966fb9763Sbellard                                const sigset_t *sigset);
42066fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
421992f48a0Sblueswir1                                const abi_ulong *old_sigset);
42266fb9763Sbellard struct target_sigaction;
42366fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
42466fb9763Sbellard                  struct target_sigaction *oact);
42566fb9763Sbellard 
4269850f9f6SLaurent Vivier #include "target_signal.h"
4279850f9f6SLaurent Vivier 
4287f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
4297f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
4307f047de1SRichard Henderson #endif
4317f047de1SRichard Henderson 
4326049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
4336049f4f8SRichard Henderson struct target_old_sigaction {
4346049f4f8SRichard Henderson     abi_ulong _sa_handler;
4356049f4f8SRichard Henderson     abi_ulong sa_mask;
436d2565875SRichard Henderson     int32_t sa_flags;
4376049f4f8SRichard Henderson };
438106ec879Sbellard 
4396049f4f8SRichard Henderson struct target_rt_sigaction {
4406049f4f8SRichard Henderson     abi_ulong _sa_handler;
4416049f4f8SRichard Henderson     abi_ulong sa_flags;
4426049f4f8SRichard Henderson     target_sigset_t sa_mask;
4436049f4f8SRichard Henderson };
4446049f4f8SRichard Henderson 
4456049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
4466049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
4476049f4f8SRichard Henderson struct target_sigaction {
4486049f4f8SRichard Henderson     abi_ulong _sa_handler;
4496049f4f8SRichard Henderson     abi_ulong sa_flags;
4506049f4f8SRichard Henderson     target_sigset_t sa_mask;
4516049f4f8SRichard Henderson     abi_ulong sa_restorer;
4526049f4f8SRichard Henderson };
4536049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
454106ec879Sbellard struct target_sigaction {
455540635baSths 	uint32_t	sa_flags;
456d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
457540635baSths 	uint32_t	_sa_handler;
458540635baSths #else
459992f48a0Sblueswir1 	abi_ulong	_sa_handler;
460540635baSths #endif
461c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
4627f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
4637f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
4647f047de1SRichard Henderson         abi_ulong sa_restorer;
4657f047de1SRichard Henderson #endif
466106ec879Sbellard };
467106ec879Sbellard #else
4682521d698Sbellard struct target_old_sigaction {
469992f48a0Sblueswir1         abi_ulong _sa_handler;
470992f48a0Sblueswir1         abi_ulong sa_mask;
471992f48a0Sblueswir1         abi_ulong sa_flags;
4727f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
473992f48a0Sblueswir1         abi_ulong sa_restorer;
4747f047de1SRichard Henderson #endif
4752521d698Sbellard };
4762521d698Sbellard 
4772521d698Sbellard struct target_sigaction {
478992f48a0Sblueswir1         abi_ulong _sa_handler;
479992f48a0Sblueswir1         abi_ulong sa_flags;
4807f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
481992f48a0Sblueswir1         abi_ulong sa_restorer;
4827f047de1SRichard Henderson #endif
483c227f099SAnthony Liguori         target_sigset_t sa_mask;
4845de154e8SLaurent Vivier #ifdef TARGET_ARCH_HAS_KA_RESTORER
4855de154e8SLaurent Vivier         abi_ulong ka_restorer;
4865de154e8SLaurent Vivier #endif
4872521d698Sbellard };
488106ec879Sbellard #endif
4892521d698Sbellard 
4902521d698Sbellard typedef union target_sigval {
4912521d698Sbellard 	int sival_int;
492992f48a0Sblueswir1         abi_ulong sival_ptr;
493c227f099SAnthony Liguori } target_sigval_t;
4946d5e216dSbellard #if 0
4956d5e216dSbellard #if defined (TARGET_SPARC)
4966d5e216dSbellard typedef struct {
4976d5e216dSbellard 	struct {
498992f48a0Sblueswir1 		abi_ulong psr;
499992f48a0Sblueswir1 		abi_ulong pc;
500992f48a0Sblueswir1 		abi_ulong npc;
501992f48a0Sblueswir1 		abi_ulong y;
502992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5036d5e216dSbellard 	}		si_regs;
5046d5e216dSbellard 	int		si_mask;
5056d5e216dSbellard } __siginfo_t;
5066d5e216dSbellard 
5076d5e216dSbellard typedef struct {
5086d5e216dSbellard 	unsigned   long si_float_regs [32];
5096d5e216dSbellard 	unsigned   long si_fsr;
5106d5e216dSbellard 	unsigned   long si_fpqdepth;
5116d5e216dSbellard 	struct {
5126d5e216dSbellard 		unsigned long *insn_addr;
5136d5e216dSbellard 		unsigned long insn;
5146d5e216dSbellard 	} si_fpqueue [16];
5156d5e216dSbellard } __siginfo_fpu_t;
5166d5e216dSbellard #endif
5176d5e216dSbellard #endif
5182521d698Sbellard 
5192521d698Sbellard #define TARGET_SI_MAX_SIZE	128
520aa5e03d2SMaxim Ostapenko 
521aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
522aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
523aa5e03d2SMaxim Ostapenko #else
524aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
525aa5e03d2SMaxim Ostapenko #endif
526aa5e03d2SMaxim Ostapenko 
527aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
5282521d698Sbellard 
529a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
530a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
531a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
532a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
533a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
534a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
535a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
536a70dadc7SPeter Maydell  */
537a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
538a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
539a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
540a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
541a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
542a70dadc7SPeter Maydell #define QEMU_SI_RT 5
543a70dadc7SPeter Maydell 
5442521d698Sbellard typedef struct target_siginfo {
5453f53d546Spbrook #ifdef TARGET_MIPS
5463f53d546Spbrook 	int si_signo;
5473f53d546Spbrook 	int si_code;
5483f53d546Spbrook 	int si_errno;
5493f53d546Spbrook #else
5502521d698Sbellard 	int si_signo;
5512521d698Sbellard 	int si_errno;
5522521d698Sbellard 	int si_code;
5533f53d546Spbrook #endif
5542521d698Sbellard 
5552521d698Sbellard 	union {
5562521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
5572521d698Sbellard 
5582521d698Sbellard 		/* kill() */
5592521d698Sbellard 		struct {
5602521d698Sbellard 			pid_t _pid;		/* sender's pid */
5612521d698Sbellard 			uid_t _uid;		/* sender's uid */
5622521d698Sbellard 		} _kill;
5632521d698Sbellard 
5642521d698Sbellard 		/* POSIX.1b timers */
5652521d698Sbellard 		struct {
5662521d698Sbellard 			unsigned int _timer1;
5672521d698Sbellard 			unsigned int _timer2;
5682521d698Sbellard 		} _timer;
5692521d698Sbellard 
5702521d698Sbellard 		/* POSIX.1b signals */
5712521d698Sbellard 		struct {
5722521d698Sbellard 			pid_t _pid;		/* sender's pid */
5732521d698Sbellard 			uid_t _uid;		/* sender's uid */
574c227f099SAnthony Liguori 			target_sigval_t _sigval;
5752521d698Sbellard 		} _rt;
5762521d698Sbellard 
5772521d698Sbellard 		/* SIGCHLD */
5782521d698Sbellard 		struct {
5792521d698Sbellard 			pid_t _pid;		/* which child */
5802521d698Sbellard 			uid_t _uid;		/* sender's uid */
5812521d698Sbellard 			int _status;		/* exit code */
582c227f099SAnthony Liguori 			target_clock_t _utime;
583c227f099SAnthony Liguori                         target_clock_t _stime;
5842521d698Sbellard 		} _sigchld;
5852521d698Sbellard 
5862521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
5872521d698Sbellard 		struct {
588992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
5892521d698Sbellard 		} _sigfault;
5902521d698Sbellard 
5912521d698Sbellard 		/* SIGPOLL */
5922521d698Sbellard 		struct {
5932521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
5942521d698Sbellard 			int _fd;
5952521d698Sbellard 		} _sigpoll;
5962521d698Sbellard 	} _sifields;
597c227f099SAnthony Liguori } target_siginfo_t;
5982521d698Sbellard 
5992521d698Sbellard /*
6002521d698Sbellard  * si_code values
6012521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6022521d698Sbellard  */
6032521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6042521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6052521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6062521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6072521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6082521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6092521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6102521d698Sbellard 
6112521d698Sbellard /*
6122521d698Sbellard  * SIGILL si_codes
6132521d698Sbellard  */
614ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6152521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
616ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
617ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
618ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
619ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
620ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
621ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
622de2fdd56SChen Gang #ifdef TARGET_TILEGX
623de2fdd56SChen Gang #define TARGET_ILL_DBLFLT       (9)     /* double fault */
624de2fdd56SChen Gang #define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
625de2fdd56SChen Gang #endif
6262521d698Sbellard 
6272521d698Sbellard /*
6282521d698Sbellard  * SIGFPE si_codes
6292521d698Sbellard  */
6302521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
6312521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
6322521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
6332521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
6342521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
6352521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
6362521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
6372521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
63821ba8564SRichard Henderson #define TARGET_FPE_FLTUNK      (14) /* undiagnosed fp exception */
63921ba8564SRichard Henderson #define TARGET_NSIGFPE         15
6402521d698Sbellard 
6412521d698Sbellard /*
6422521d698Sbellard  * SIGSEGV si_codes
6432521d698Sbellard  */
6442521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
6452521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
646de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
6472521d698Sbellard 
6482521d698Sbellard /*
649ffa65c3bSbellard  * SIGBUS si_codes
650ffa65c3bSbellard  */
651ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
652b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
653ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
654de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
655de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
656de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
657de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
658ffa65c3bSbellard 
659ffa65c3bSbellard /*
6602521d698Sbellard  * SIGTRAP si_codes
6612521d698Sbellard  */
6622521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
6632521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
664de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
665de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
6662521d698Sbellard 
6679de5e440Sbellard struct target_rlimit {
668992f48a0Sblueswir1         abi_ulong   rlim_cur;
669992f48a0Sblueswir1         abi_ulong   rlim_max;
6709de5e440Sbellard };
6719de5e440Sbellard 
67281bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
673e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
6746cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
67581bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
67681bbe906Stakasi-y@ops.dti.ne.jp #else
67726b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
67881bbe906Stakasi-y@ops.dti.ne.jp #endif
67981bbe906Stakasi-y@ops.dti.ne.jp 
680e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
681e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
682e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
683e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
684e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
685e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
686e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
687e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
688e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
689e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
690e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
691e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
692e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
693e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
694e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
695e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
696e22b7015SWesley W. Terpstra #else
697e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
698e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
699e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
700e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
701e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
702e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7036cafd027SMatthias Braun #if defined(TARGET_SPARC)
7046cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7056cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7066cafd027SMatthias Braun #else
707e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
708e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7096cafd027SMatthias Braun #endif
710e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
711e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
712e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
713e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
714e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
715e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
716e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
717e22b7015SWesley W. Terpstra #endif
718e22b7015SWesley W. Terpstra 
7199de5e440Sbellard struct target_pollfd {
7209de5e440Sbellard     int fd;           /* file descriptor */
7219de5e440Sbellard     short events;     /* requested events */
7229de5e440Sbellard     short revents;    /* returned events */
7239de5e440Sbellard };
7249de5e440Sbellard 
7258e5a0667Sbellard /* virtual terminal ioctls */
7260221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7270221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7288e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
729f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
730f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
731f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7320221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7330221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
734e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
735e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
736e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
737e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
738ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
7398e5a0667Sbellard 
740d14eabbeSAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
741d14eabbeSAleksandar Markovic        defined(TARGET_XTENSA)
742e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
743c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
744405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
745e1be1606SAleksandar Markovic #else
7462521d698Sbellard #define TARGET_SIOCATMARK      0x8905
747c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       0x8902
748405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
749e1be1606SAleksandar Markovic #endif
750c495a793SAleksandar Markovic 
751405b4915SHelge Deller #define TARGET_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
752405b4915SHelge Deller #define TARGET_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
7532521d698Sbellard 
75431e31b8aSbellard /* Networking ioctls */
75531e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
75631e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
75731e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
75831e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
75931e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
76031e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
76131e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
76231e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
76331e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
76431e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
76531e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
76631e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
76731e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
76831e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
76931e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
77031e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
77131e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
77231e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
77331e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
77431e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
77531e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
77631e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
77731e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
77831e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
77931e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
78031e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
78131e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
78231e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
78331e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
784f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
7854bdcd79eSNeng Chen #define TARGET_SIOCSIFPFLAGS   0x8934          /* set extended flags          */
7864bdcd79eSNeng Chen #define TARGET_SIOCGIFPFLAGS   0x8935          /* get extended flags          */
78731e31b8aSbellard 
78831e31b8aSbellard /* Bridging control calls */
78931e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
79031e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
79131e31b8aSbellard 
79231e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
79331e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
79431e31b8aSbellard 
79531e31b8aSbellard /* ARP cache control calls. */
79631e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
79731e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
79831e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
79931e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
80031e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
80131e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
80231e31b8aSbellard 
80331e31b8aSbellard /* RARP cache control calls. */
80431e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
80531e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
80631e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
80731e31b8aSbellard 
80831e31b8aSbellard /* Driver configuration calls */
80931e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
81031e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
81131e31b8aSbellard 
81231e31b8aSbellard /* DLCI configuration calls */
81331e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
81431e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
81531e31b8aSbellard 
81686fcd946SLaurent Vivier /* From <linux/wireless.h> */
81786fcd946SLaurent Vivier 
81886fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
81931e31b8aSbellard 
820d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
821d6d6d6feSMarco A L Barbosa 
822d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
823d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
824d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
825d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
826d6d6d6feSMarco A L Barbosa 
82731e31b8aSbellard /* From <linux/fs.h> */
82831e31b8aSbellard 
82931e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
83031e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
83131e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
83231e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
83331e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
83431e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
83531e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
83631e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
83731e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
83831e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
83931e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
84031e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
841fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
84231e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
843c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
844c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
845edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
846edafea13SAlexander Graf                                              /* return device size in bytes
847edafea13SAlexander Graf                                                 (u64 *arg) */
8484715856aSPeter Maydell 
8494715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
8504715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
8514715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
8524715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
8534715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
8544715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
8554715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
8564715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
8574715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
8584715856aSPeter Maydell 
85931e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
86031e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
86121992cb6SHelge Deller 
86221992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
86321992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
86421992cb6SHelge Deller 
86560807231SPeter Maydell /* Note that the ioctl numbers claim type "long" but the actual type
86660807231SPeter Maydell  * used by the kernel is "int".
86760807231SPeter Maydell  */
8681847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
8691847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
87060807231SPeter Maydell 
871285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
87231e31b8aSbellard 
8736c753a63SCortland Tölva /* usb ioctls */
8746c753a63SCortland Tölva #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
8756c753a63SCortland Tölva #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
8766c753a63SCortland Tölva #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
8776c753a63SCortland Tölva #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
8786c753a63SCortland Tölva #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U',  5)
8796c753a63SCortland Tölva #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
880a133367eSCortland Tölva #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
881a133367eSCortland Tölva #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
882a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
883a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
8846c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
8856c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
8866c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
8876c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
8886c753a63SCortland Tölva #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
8896c753a63SCortland Tölva #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
8906c753a63SCortland Tölva #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
8916c753a63SCortland Tölva #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
8926c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
8936c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
8946c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
8956c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
8966c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
8976c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
8986c753a63SCortland Tölva #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
8996c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
9006c753a63SCortland Tölva 
90131e31b8aSbellard /* cdrom commands */
90231e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
90331e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
90431e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
90531e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
90631e31b8aSbellard                                            (struct cdrom_ti) */
90731e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
90831e31b8aSbellard                                            (struct cdrom_tochdr) */
90931e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
91031e31b8aSbellard                                            (struct cdrom_tocentry) */
91131e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
91231e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
91331e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
91431e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
91531e31b8aSbellard                                            (struct cdrom_volctrl) */
91631e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
91731e31b8aSbellard                                            (struct cdrom_subchnl) */
91831e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
91931e31b8aSbellard                                            (struct cdrom_read) */
92031e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
92131e31b8aSbellard                                            (struct cdrom_read) */
92231e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
92331e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
92431e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
92531e31b8aSbellard                                            address of multi session disks
92631e31b8aSbellard                                            (struct cdrom_multisession) */
92731e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
92831e31b8aSbellard                                            if available (struct cdrom_mcn) */
92967cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
930b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
93131e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
93231e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
93331e31b8aSbellard                                           (struct cdrom_volctrl) */
93431e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
93531e31b8aSbellard                                            (struct cdrom_read) */
93631e31b8aSbellard /*
93731e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
93831e31b8aSbellard  */
93931e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
94031e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
94131e31b8aSbellard 
94231e31b8aSbellard /*
94331e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
94431e31b8aSbellard    It is for playing audio in logical block addressing mode.
94531e31b8aSbellard  */
94631e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
94731e31b8aSbellard 
94831e31b8aSbellard /*
94931e31b8aSbellard  * These ioctls are only used in optcd.c
95031e31b8aSbellard  */
95131e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
95231e31b8aSbellard 
95331e31b8aSbellard /*
95431e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
95531e31b8aSbellard  * drive spindown time.  They should be implemented in the
95631e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
95731e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
95831e31b8aSbellard  *  -Erik
95931e31b8aSbellard  */
96031e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
96131e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
96231e31b8aSbellard 
96331e31b8aSbellard /*
96431e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
96531e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
96631e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
96731e31b8aSbellard  */
96831e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
96931e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
97031e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
97131e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
97231e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
97331e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
97431e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
97531e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
97631e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
97731e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
97831e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
97931e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
98031e31b8aSbellard 
98131e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
98231e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
98331e31b8aSbellard  */
98431e31b8aSbellard 
98531e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
98631e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
98731e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
98831e31b8aSbellard 
98931e31b8aSbellard /* DVD-ROM Specific ioctls */
99031e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
99131e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
99231e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
99331e31b8aSbellard 
99431e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
99531e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
99631e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
99731e31b8aSbellard 
99831e31b8aSbellard /* HD commands */
99931e31b8aSbellard 
100031e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
100131e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
100231e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
100331e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
100431e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
100531e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
100631e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
100731e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
10082521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
100931e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
101031e31b8aSbellard 
101131e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
101231e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
101331e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
101431e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
101531e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
101631e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
101731e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
101831e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
10192521d698Sbellard 
1020b8005914Sbalrog /* loop ioctls */
1021b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1022b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1023b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1024b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1025b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1026b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1027b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
10282521d698Sbellard 
1029884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1030884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1031884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1032884cdc48SPeter Maydell 
1033f7680a55SUlrich Hecht /* fb ioctls */
1034f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1035f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1036f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
103712b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
103812b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
103912b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
104012b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
104112b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1042f7680a55SUlrich Hecht 
1043f7680a55SUlrich Hecht /* vt ioctls */
1044f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1045f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1046f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1047f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1048f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1049f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1050774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1051774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1052774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1053774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1054f7680a55SUlrich Hecht 
105556e904ecSAlexander Graf /* device mapper */
105656e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
105756e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
105856e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
105956e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
106056e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
106156e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
106256e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
106356e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
106456e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
106556e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
106656e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
106756e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
106856e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
106956e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
107056e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
107156e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
107256e904ecSAlexander Graf 
10732521d698Sbellard /* from asm/termbits.h */
10742521d698Sbellard 
10753bfd9da1Sbellard #define TARGET_NCC 8
10763bfd9da1Sbellard struct target_termio {
10773bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
10783bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
10793bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
10803bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
10812521d698Sbellard 	unsigned char c_line;		/* line discipline */
10823bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
10832521d698Sbellard };
10842521d698Sbellard 
10853bfd9da1Sbellard struct target_winsize {
10863bfd9da1Sbellard 	unsigned short ws_row;
10873bfd9da1Sbellard 	unsigned short ws_col;
10883bfd9da1Sbellard 	unsigned short ws_xpixel;
10893bfd9da1Sbellard 	unsigned short ws_ypixel;
10903bfd9da1Sbellard };
10912521d698Sbellard 
10923bfd9da1Sbellard #include "termbits.h"
10932521d698Sbellard 
10949e0b74a4SPaul Brook #if defined(TARGET_MIPS)
10959e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
10969e0b74a4SPaul Brook #else
10979e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
10989e0b74a4SPaul Brook #endif
10999e0b74a4SPaul Brook 
1100e44a3e79Saurel32 /* Common */
11012521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
11022521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1103e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1104e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1105e65be6a7SHelge Deller #else
11062521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1107e65be6a7SHelge Deller #endif
1108e44a3e79Saurel32 
1109e44a3e79Saurel32 /* Target specific */
1110048f6b4dSbellard #if defined(TARGET_MIPS)
1111e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1112048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1113048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1114048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1115048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1116048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1117048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1118540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1119540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1120541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1121541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1122e44a3e79Saurel32 #elif defined(TARGET_PPC)
1123e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
11242521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
11252521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
11262521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
11272521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
11287ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
11297ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1130e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1131e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1132541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1133541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1134e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1135e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1136e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1137e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1138e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1139e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1140e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1141e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1142e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1143e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1144541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1145541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1146a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1147a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1148a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1149a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1150a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1151a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1152a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1153a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1154a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1155a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1156541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1157541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1158ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1159ba7651fbSMax Filippov #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1160ba7651fbSMax Filippov #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1161ba7651fbSMax Filippov #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1162ba7651fbSMax Filippov #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1163ba7651fbSMax Filippov #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1164ba7651fbSMax Filippov #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1165ba7651fbSMax Filippov #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1166ba7651fbSMax Filippov #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1167ba7651fbSMax Filippov #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1168ba7651fbSMax Filippov #define TARGET_MAP_STACK	0x40000
1169ba7651fbSMax Filippov #define TARGET_MAP_HUGETLB  0x80000         /* create a huge page mapping */
11707ec93196Sj_mayer #else
1171e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1172e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1173e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1174e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1175e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
11762521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
11772521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1178540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1179540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1180541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1181541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1182906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
11837ec93196Sj_mayer #endif
11842521d698Sbellard 
118509701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
118609701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1187daa4374aSPeter Maydell     || defined(TARGET_CRIS)
1188*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
11892521d698Sbellard struct target_stat {
11902521d698Sbellard 	unsigned short st_dev;
11912521d698Sbellard 	unsigned short __pad1;
1192992f48a0Sblueswir1 	abi_ulong st_ino;
11932521d698Sbellard 	unsigned short st_mode;
11942521d698Sbellard 	unsigned short st_nlink;
11952521d698Sbellard 	unsigned short st_uid;
11962521d698Sbellard 	unsigned short st_gid;
11972521d698Sbellard 	unsigned short st_rdev;
11982521d698Sbellard 	unsigned short __pad2;
1199992f48a0Sblueswir1 	abi_ulong  st_size;
1200992f48a0Sblueswir1 	abi_ulong  st_blksize;
1201992f48a0Sblueswir1 	abi_ulong  st_blocks;
1202992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1203*5f992db6SChen-Yu Tsai 	abi_ulong  target_st_atime_nsec;
1204992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1205*5f992db6SChen-Yu Tsai 	abi_ulong  target_st_mtime_nsec;
1206992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1207*5f992db6SChen-Yu Tsai 	abi_ulong  target_st_ctime_nsec;
1208992f48a0Sblueswir1 	abi_ulong  __unused4;
1209992f48a0Sblueswir1 	abi_ulong  __unused5;
12102521d698Sbellard };
12112521d698Sbellard 
12122521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
12132521d698Sbellard  * insane amounts of padding around dev_t's.
12142521d698Sbellard  */
121520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
12162521d698Sbellard struct target_stat64 {
12172521d698Sbellard 	unsigned short	st_dev;
12182521d698Sbellard 	unsigned char	__pad0[10];
12192521d698Sbellard 
12202521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1221992f48a0Sblueswir1 	abi_ulong	__st_ino;
12222521d698Sbellard 
12232521d698Sbellard 	unsigned int	st_mode;
12242521d698Sbellard 	unsigned int	st_nlink;
12252521d698Sbellard 
1226992f48a0Sblueswir1 	abi_ulong	st_uid;
1227992f48a0Sblueswir1 	abi_ulong	st_gid;
12282521d698Sbellard 
12292521d698Sbellard 	unsigned short	st_rdev;
12302521d698Sbellard 	unsigned char	__pad3[10];
12312521d698Sbellard 
12322521d698Sbellard 	long long	st_size;
1233992f48a0Sblueswir1 	abi_ulong	st_blksize;
12342521d698Sbellard 
1235992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1236992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
12372521d698Sbellard 
1238992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1239*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
12402521d698Sbellard 
1241992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1242*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
12432521d698Sbellard 
1244992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1245*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
12462521d698Sbellard 
12472521d698Sbellard 	unsigned long long	st_ino;
1248541dc0d4SStefan Weil } QEMU_PACKED;
12492521d698Sbellard 
1250ce4defa0Spbrook #ifdef TARGET_ARM
125120d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1252ce4defa0Spbrook struct target_eabi_stat64 {
1253ce4defa0Spbrook         unsigned long long st_dev;
1254ce4defa0Spbrook         unsigned int    __pad1;
1255992f48a0Sblueswir1         abi_ulong    __st_ino;
1256ce4defa0Spbrook         unsigned int    st_mode;
1257ce4defa0Spbrook         unsigned int    st_nlink;
1258ce4defa0Spbrook 
1259992f48a0Sblueswir1         abi_ulong    st_uid;
1260992f48a0Sblueswir1         abi_ulong    st_gid;
1261ce4defa0Spbrook 
1262ce4defa0Spbrook         unsigned long long st_rdev;
1263ce4defa0Spbrook         unsigned int    __pad2[2];
1264ce4defa0Spbrook 
1265ce4defa0Spbrook         long long       st_size;
1266992f48a0Sblueswir1         abi_ulong    st_blksize;
1267ce4defa0Spbrook         unsigned int    __pad3;
1268ce4defa0Spbrook         unsigned long long st_blocks;
1269ce4defa0Spbrook 
1270992f48a0Sblueswir1         abi_ulong    target_st_atime;
1271992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1272ce4defa0Spbrook 
1273992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1274992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1275ce4defa0Spbrook 
1276992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1277992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1278ce4defa0Spbrook 
1279ce4defa0Spbrook         unsigned long long st_ino;
1280541dc0d4SStefan Weil } QEMU_PACKED;
1281ce4defa0Spbrook #endif
1282ce4defa0Spbrook 
1283992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
12841b8dd648Sblueswir1 struct target_stat {
12851b8dd648Sblueswir1 	unsigned int	st_dev;
1286992f48a0Sblueswir1 	abi_ulong	st_ino;
12871b8dd648Sblueswir1 	unsigned int	st_mode;
12881b8dd648Sblueswir1 	unsigned int	st_nlink;
12891b8dd648Sblueswir1 	unsigned int	st_uid;
12901b8dd648Sblueswir1 	unsigned int	st_gid;
12911b8dd648Sblueswir1 	unsigned int	st_rdev;
1292992f48a0Sblueswir1 	abi_long	st_size;
1293992f48a0Sblueswir1 	abi_long	target_st_atime;
1294992f48a0Sblueswir1 	abi_long	target_st_mtime;
1295992f48a0Sblueswir1 	abi_long	target_st_ctime;
1296992f48a0Sblueswir1 	abi_long	st_blksize;
1297992f48a0Sblueswir1 	abi_long	st_blocks;
1298992f48a0Sblueswir1 	abi_ulong	__unused4[2];
12991b8dd648Sblueswir1 };
13001b8dd648Sblueswir1 
130120d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13021b8dd648Sblueswir1 struct target_stat64 {
13031b8dd648Sblueswir1 	unsigned char	__pad0[6];
13041b8dd648Sblueswir1 	unsigned short	st_dev;
13051b8dd648Sblueswir1 
13061b8dd648Sblueswir1 	uint64_t	st_ino;
13071b8dd648Sblueswir1 	uint64_t	st_nlink;
13081b8dd648Sblueswir1 
13091b8dd648Sblueswir1 	unsigned int	st_mode;
13101b8dd648Sblueswir1 
13111b8dd648Sblueswir1 	unsigned int	st_uid;
13121b8dd648Sblueswir1 	unsigned int	st_gid;
13131b8dd648Sblueswir1 
13141b8dd648Sblueswir1 	unsigned char	__pad2[6];
13151b8dd648Sblueswir1 	unsigned short	st_rdev;
13161b8dd648Sblueswir1 
13171b8dd648Sblueswir1         int64_t		st_size;
13181b8dd648Sblueswir1 	int64_t		st_blksize;
13191b8dd648Sblueswir1 
13201b8dd648Sblueswir1 	unsigned char	__pad4[4];
13211b8dd648Sblueswir1 	unsigned int	st_blocks;
13221b8dd648Sblueswir1 
1323992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1324*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
13251b8dd648Sblueswir1 
1326992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1327*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
13281b8dd648Sblueswir1 
1329992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1330*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
13311b8dd648Sblueswir1 
1332992f48a0Sblueswir1 	abi_ulong	__unused4[3];
13331b8dd648Sblueswir1 };
13341b8dd648Sblueswir1 
13353bfd9da1Sbellard #elif defined(TARGET_SPARC)
13363bfd9da1Sbellard 
1337*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
13383bfd9da1Sbellard struct target_stat {
13393bfd9da1Sbellard 	unsigned short	st_dev;
1340992f48a0Sblueswir1 	abi_ulong	st_ino;
13413bfd9da1Sbellard 	unsigned short	st_mode;
13423bfd9da1Sbellard 	short		st_nlink;
13433bfd9da1Sbellard 	unsigned short	st_uid;
13443bfd9da1Sbellard 	unsigned short	st_gid;
13453bfd9da1Sbellard 	unsigned short	st_rdev;
1346992f48a0Sblueswir1 	abi_long	st_size;
1347992f48a0Sblueswir1 	abi_long	target_st_atime;
1348*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
1349992f48a0Sblueswir1 	abi_long	target_st_mtime;
1350*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
1351992f48a0Sblueswir1 	abi_long	target_st_ctime;
1352*5f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
1353992f48a0Sblueswir1 	abi_long	st_blksize;
1354992f48a0Sblueswir1 	abi_long	st_blocks;
1355*5f992db6SChen-Yu Tsai 	abi_ulong	__unused1[2];
13563bfd9da1Sbellard };
13573bfd9da1Sbellard 
135820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13593bfd9da1Sbellard struct target_stat64 {
13603bfd9da1Sbellard 	unsigned char	__pad0[6];
13613bfd9da1Sbellard 	unsigned short	st_dev;
13623bfd9da1Sbellard 
13633bfd9da1Sbellard 	uint64_t st_ino;
13643bfd9da1Sbellard 
13653bfd9da1Sbellard 	unsigned int	st_mode;
13663bfd9da1Sbellard 	unsigned int	st_nlink;
13673bfd9da1Sbellard 
13683bfd9da1Sbellard 	unsigned int	st_uid;
13693bfd9da1Sbellard 	unsigned int	st_gid;
13703bfd9da1Sbellard 
13713bfd9da1Sbellard 	unsigned char	__pad2[6];
13723bfd9da1Sbellard 	unsigned short	st_rdev;
13733bfd9da1Sbellard 
13743bfd9da1Sbellard 	unsigned char	__pad3[8];
13753bfd9da1Sbellard 
13763bfd9da1Sbellard         int64_t	st_size;
13773bfd9da1Sbellard 	unsigned int	st_blksize;
13783bfd9da1Sbellard 
13793bfd9da1Sbellard 	unsigned char	__pad4[8];
13803bfd9da1Sbellard 	unsigned int	st_blocks;
13813bfd9da1Sbellard 
13823bfd9da1Sbellard 	unsigned int	target_st_atime;
1383*5f992db6SChen-Yu Tsai 	unsigned int	target_st_atime_nsec;
13843bfd9da1Sbellard 
13853bfd9da1Sbellard 	unsigned int	target_st_mtime;
1386*5f992db6SChen-Yu Tsai 	unsigned int	target_st_mtime_nsec;
13873bfd9da1Sbellard 
13883bfd9da1Sbellard 	unsigned int	target_st_ctime;
1389*5f992db6SChen-Yu Tsai 	unsigned int	target_st_ctime_nsec;
13903bfd9da1Sbellard 
1391*5f992db6SChen-Yu Tsai 	unsigned int	__unused1;
1392*5f992db6SChen-Yu Tsai 	unsigned int	__unused2;
13933bfd9da1Sbellard };
13943bfd9da1Sbellard 
139567867308Sbellard #elif defined(TARGET_PPC)
139667867308Sbellard 
1397*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
139867867308Sbellard struct target_stat {
1399e32448e0Sj_mayer 	abi_ulong st_dev;
1400992f48a0Sblueswir1 	abi_ulong st_ino;
1401325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1402e32448e0Sj_mayer 	abi_ulong st_nlink;
1403325e651fSj_mayer 	unsigned int st_mode;
1404325e651fSj_mayer #else
140567867308Sbellard 	unsigned int st_mode;
140667867308Sbellard 	unsigned short st_nlink;
1407325e651fSj_mayer #endif
140867867308Sbellard 	unsigned int st_uid;
140967867308Sbellard 	unsigned int st_gid;
1410e32448e0Sj_mayer 	abi_ulong  st_rdev;
1411992f48a0Sblueswir1 	abi_ulong  st_size;
1412992f48a0Sblueswir1 	abi_ulong  st_blksize;
1413992f48a0Sblueswir1 	abi_ulong  st_blocks;
1414992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1415e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1416992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1417e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1418992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1419e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1420992f48a0Sblueswir1 	abi_ulong  __unused4;
1421992f48a0Sblueswir1 	abi_ulong  __unused5;
1422325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1423325e651fSj_mayer 	abi_ulong  __unused6;
1424325e651fSj_mayer #endif
142567867308Sbellard };
142667867308Sbellard 
142720d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
142820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1429541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
143067867308Sbellard 	unsigned long long st_dev;
143167867308Sbellard         unsigned long long st_ino;
143267867308Sbellard 	unsigned int st_mode;
143367867308Sbellard 	unsigned int st_nlink;
143467867308Sbellard 	unsigned int st_uid;
143567867308Sbellard 	unsigned int st_gid;
143667867308Sbellard 	unsigned long long st_rdev;
1437e1ce5e40Saurel32 	unsigned long long __pad0;
143867867308Sbellard 	long long      st_size;
1439e32448e0Sj_mayer 	int	       st_blksize;
1440e1ce5e40Saurel32 	unsigned int   __pad1;
144161322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1442e32448e0Sj_mayer 	int	       target_st_atime;
1443e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1444e32448e0Sj_mayer 	int	       target_st_mtime;
1445e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1446e32448e0Sj_mayer 	int            target_st_ctime;
1447e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1448e32448e0Sj_mayer         unsigned int   __unused4;
1449e32448e0Sj_mayer         unsigned int   __unused5;
145067867308Sbellard };
145120d155bcSStefan Weil #endif
145267867308Sbellard 
1453b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1454b779e29eSEdgar E. Iglesias 
1455*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1456b779e29eSEdgar E. Iglesias struct target_stat {
1457b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1458b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1459b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1460b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1461b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1462b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1463b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1464b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1465b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1466b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1467b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1468b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1469b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1470b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1471b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1472b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1473b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1474b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1475b779e29eSEdgar E. Iglesias };
1476b779e29eSEdgar E. Iglesias 
1477b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
147820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1479541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1480b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1481a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1482a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1483a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1484a523eb06SEdgar E. Iglesias 
1485b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1486b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1487b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1488b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1489b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
149021ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1491b779e29eSEdgar E. Iglesias 
1492b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1493b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
149421ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1495b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1496b779e29eSEdgar E. Iglesias 
1497b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1498b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1499b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1500b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1501b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1502b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1503a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1504b779e29eSEdgar E. Iglesias };
1505b779e29eSEdgar E. Iglesias 
1506e6e5906bSpbrook #elif defined(TARGET_M68K)
1507e6e5906bSpbrook 
1508e6e5906bSpbrook struct target_stat {
1509e6e5906bSpbrook 	unsigned short st_dev;
1510e6e5906bSpbrook 	unsigned short __pad1;
1511992f48a0Sblueswir1 	abi_ulong st_ino;
1512e6e5906bSpbrook 	unsigned short st_mode;
1513e6e5906bSpbrook 	unsigned short st_nlink;
1514e6e5906bSpbrook 	unsigned short st_uid;
1515e6e5906bSpbrook 	unsigned short st_gid;
1516e6e5906bSpbrook 	unsigned short st_rdev;
1517e6e5906bSpbrook 	unsigned short __pad2;
1518992f48a0Sblueswir1 	abi_ulong  st_size;
1519992f48a0Sblueswir1 	abi_ulong  st_blksize;
1520992f48a0Sblueswir1 	abi_ulong  st_blocks;
1521992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1522992f48a0Sblueswir1 	abi_ulong  __unused1;
1523992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1524992f48a0Sblueswir1 	abi_ulong  __unused2;
1525992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1526992f48a0Sblueswir1 	abi_ulong  __unused3;
1527992f48a0Sblueswir1 	abi_ulong  __unused4;
1528992f48a0Sblueswir1 	abi_ulong  __unused5;
1529e6e5906bSpbrook };
1530e6e5906bSpbrook 
1531e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1532e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1533e6e5906bSpbrook  */
153420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1535e6e5906bSpbrook struct target_stat64 {
1536e6e5906bSpbrook 	unsigned long long	st_dev;
1537e6e5906bSpbrook 	unsigned char	__pad1[2];
1538e6e5906bSpbrook 
1539e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1540992f48a0Sblueswir1 	abi_ulong	__st_ino;
1541e6e5906bSpbrook 
1542e6e5906bSpbrook 	unsigned int	st_mode;
1543e6e5906bSpbrook 	unsigned int	st_nlink;
1544e6e5906bSpbrook 
1545992f48a0Sblueswir1 	abi_ulong	st_uid;
1546992f48a0Sblueswir1 	abi_ulong	st_gid;
1547e6e5906bSpbrook 
1548e6e5906bSpbrook 	unsigned long long	st_rdev;
1549e6e5906bSpbrook 	unsigned char	__pad3[2];
1550e6e5906bSpbrook 
1551e6e5906bSpbrook 	long long	st_size;
1552992f48a0Sblueswir1 	abi_ulong	st_blksize;
1553e6e5906bSpbrook 
1554992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1555992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1556e6e5906bSpbrook 
1557992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1558992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1559e6e5906bSpbrook 
1560992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1561992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1562e6e5906bSpbrook 
1563992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1564992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1565e6e5906bSpbrook 
1566e6e5906bSpbrook 	unsigned long long	st_ino;
1567541dc0d4SStefan Weil } QEMU_PACKED;
1568e6e5906bSpbrook 
1569d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1570540635baSths 
1571*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1572540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1573540635baSths struct target_stat {
1574540635baSths 	unsigned int		st_dev;
1575540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1576540635baSths 
1577992f48a0Sblueswir1 	abi_ulong		st_ino;
1578540635baSths 
1579540635baSths 	unsigned int		st_mode;
1580540635baSths 	unsigned int		st_nlink;
1581540635baSths 
1582540635baSths 	int			st_uid;
1583540635baSths 	int			st_gid;
1584540635baSths 
1585540635baSths 	unsigned int		st_rdev;
1586540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1587540635baSths 
1588992f48a0Sblueswir1 	abi_ulong		st_size;
1589540635baSths 
1590540635baSths 	/*
1591540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1592540635baSths 	 * but we don't have it under Linux.
1593540635baSths 	 */
1594540635baSths 	unsigned int		target_st_atime;
1595540635baSths 	unsigned int		target_st_atime_nsec;
1596540635baSths 
1597540635baSths 	unsigned int		target_st_mtime;
1598540635baSths 	unsigned int		target_st_mtime_nsec;
1599540635baSths 
1600540635baSths 	unsigned int		target_st_ctime;
1601540635baSths 	unsigned int		target_st_ctime_nsec;
1602540635baSths 
1603540635baSths 	unsigned int		st_blksize;
1604540635baSths 	unsigned int		st_pad2;
1605540635baSths 
1606992f48a0Sblueswir1 	abi_ulong		st_blocks;
1607540635baSths };
1608540635baSths 
1609d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1610540635baSths 
1611*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1612540635baSths struct target_stat {
16131ab2aea2SLeon Alrae         abi_ulong    st_dev;
16141ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
16151ab2aea2SLeon Alrae         uint64_t     st_ino;
1616540635baSths         unsigned int st_mode;
1617540635baSths         unsigned int st_nlink;
1618540635baSths         int          st_uid;
1619540635baSths         int          st_gid;
16201ab2aea2SLeon Alrae         abi_ulong    st_rdev;
16211ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
16221ab2aea2SLeon Alrae         int64_t      st_size;
16231ab2aea2SLeon Alrae         abi_long     target_st_atime;
16241ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
16251ab2aea2SLeon Alrae         abi_long     target_st_mtime;
16261ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
16271ab2aea2SLeon Alrae         abi_long     target_st_ctime;
16281ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
16291ab2aea2SLeon Alrae         abi_ulong    st_blksize;
16301ab2aea2SLeon Alrae         abi_ulong    st_pad2;
16311ab2aea2SLeon Alrae         int64_t      st_blocks;
1632540635baSths };
1633540635baSths 
1634d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1635048f6b4dSbellard 
1636*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1637048f6b4dSbellard struct target_stat {
1638048f6b4dSbellard 	unsigned	st_dev;
1639992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1640992f48a0Sblueswir1 	abi_ulong	st_ino;
1641048f6b4dSbellard 	unsigned int	st_mode;
1642048f6b4dSbellard 	unsigned int	st_nlink;
1643048f6b4dSbellard 	int		st_uid;
1644048f6b4dSbellard 	int		st_gid;
1645048f6b4dSbellard 	unsigned 	st_rdev;
1646992f48a0Sblueswir1 	abi_long	st_pad2[2];
1647992f48a0Sblueswir1 	abi_long	st_size;
1648992f48a0Sblueswir1 	abi_long	st_pad3;
1649048f6b4dSbellard 	/*
1650048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1651048f6b4dSbellard 	 * but we don't have it under Linux.
1652048f6b4dSbellard 	 */
1653992f48a0Sblueswir1 	abi_long		target_st_atime;
1654992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1655992f48a0Sblueswir1 	abi_long		target_st_mtime;
1656992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1657992f48a0Sblueswir1 	abi_long		target_st_ctime;
1658992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1659992f48a0Sblueswir1 	abi_long		st_blksize;
1660992f48a0Sblueswir1 	abi_long		st_blocks;
1661992f48a0Sblueswir1 	abi_long		st_pad4[14];
1662048f6b4dSbellard };
1663048f6b4dSbellard 
1664048f6b4dSbellard /*
1665048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1666048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1667048f6b4dSbellard  * struct stat of the 64-bit kernel.
1668048f6b4dSbellard  */
1669048f6b4dSbellard 
167020d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1671048f6b4dSbellard struct target_stat64 {
1672992f48a0Sblueswir1 	abi_ulong	st_dev;
1673992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1674048f6b4dSbellard 
1675048f6b4dSbellard 	uint64_t	st_ino;
1676048f6b4dSbellard 
1677048f6b4dSbellard         unsigned int	st_mode;
1678048f6b4dSbellard         unsigned int	st_nlink;
1679048f6b4dSbellard 
1680048f6b4dSbellard 	int		st_uid;
1681048f6b4dSbellard 	int		st_gid;
1682048f6b4dSbellard 
1683992f48a0Sblueswir1 	abi_ulong	st_rdev;
1684992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1685048f6b4dSbellard 
1686048f6b4dSbellard 	int64_t 	st_size;
1687048f6b4dSbellard 
1688048f6b4dSbellard 	/*
1689048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1690048f6b4dSbellard 	 * but we don't have it under Linux.
1691048f6b4dSbellard 	 */
1692992f48a0Sblueswir1 	abi_long	target_st_atime;
1693992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1694048f6b4dSbellard 
1695992f48a0Sblueswir1 	abi_long	target_st_mtime;
1696992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1697048f6b4dSbellard 
1698992f48a0Sblueswir1 	abi_long	target_st_ctime;
1699992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1700048f6b4dSbellard 
1701992f48a0Sblueswir1 	abi_ulong	st_blksize;
1702992f48a0Sblueswir1 	abi_ulong	st_pad2;
1703048f6b4dSbellard 
1704048f6b4dSbellard 	int64_t  	st_blocks;
1705048f6b4dSbellard };
17067a3148a9Sj_mayer 
17077a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
17087a3148a9Sj_mayer 
17097a3148a9Sj_mayer struct target_stat {
17107a3148a9Sj_mayer        unsigned int    st_dev;
17117a3148a9Sj_mayer        unsigned int    st_ino;
17127a3148a9Sj_mayer        unsigned int    st_mode;
17137a3148a9Sj_mayer        unsigned int    st_nlink;
17147a3148a9Sj_mayer        unsigned int    st_uid;
17157a3148a9Sj_mayer        unsigned int    st_gid;
17167a3148a9Sj_mayer        unsigned int    st_rdev;
1717992f48a0Sblueswir1        abi_long     st_size;
1718992f48a0Sblueswir1        abi_ulong    target_st_atime;
1719992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1720992f48a0Sblueswir1        abi_ulong    target_st_ctime;
17217a3148a9Sj_mayer        unsigned int    st_blksize;
17227a3148a9Sj_mayer        unsigned int    st_blocks;
17237a3148a9Sj_mayer        unsigned int    st_flags;
17247a3148a9Sj_mayer        unsigned int    st_gen;
17257a3148a9Sj_mayer };
17267a3148a9Sj_mayer 
172720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
17287a3148a9Sj_mayer struct target_stat64 {
1729992f48a0Sblueswir1        abi_ulong    st_dev;
1730992f48a0Sblueswir1        abi_ulong    st_ino;
1731992f48a0Sblueswir1        abi_ulong    st_rdev;
1732992f48a0Sblueswir1        abi_long     st_size;
1733992f48a0Sblueswir1        abi_ulong    st_blocks;
17347a3148a9Sj_mayer 
17357a3148a9Sj_mayer        unsigned int    st_mode;
17367a3148a9Sj_mayer        unsigned int    st_uid;
17377a3148a9Sj_mayer        unsigned int    st_gid;
17387a3148a9Sj_mayer        unsigned int    st_blksize;
17397a3148a9Sj_mayer        unsigned int    st_nlink;
17407a3148a9Sj_mayer        unsigned int    __pad0;
17417a3148a9Sj_mayer 
1742992f48a0Sblueswir1        abi_ulong    target_st_atime;
1743992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1744992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1745992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1746992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1747992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1748992f48a0Sblueswir1        abi_long     __unused[3];
17497a3148a9Sj_mayer };
17507a3148a9Sj_mayer 
17516db45e65Sths #elif defined(TARGET_SH4)
17526db45e65Sths 
1753*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
17546db45e65Sths struct target_stat {
1755992f48a0Sblueswir1 	abi_ulong  st_dev;
1756992f48a0Sblueswir1 	abi_ulong  st_ino;
17576db45e65Sths 	unsigned short st_mode;
17586db45e65Sths 	unsigned short st_nlink;
17596db45e65Sths 	unsigned short st_uid;
17606db45e65Sths 	unsigned short st_gid;
1761992f48a0Sblueswir1 	abi_ulong  st_rdev;
1762992f48a0Sblueswir1 	abi_ulong  st_size;
1763992f48a0Sblueswir1 	abi_ulong  st_blksize;
1764992f48a0Sblueswir1 	abi_ulong  st_blocks;
1765992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1766992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1767992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1768992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1769992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1770992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1771992f48a0Sblueswir1 	abi_ulong  __unused4;
1772992f48a0Sblueswir1 	abi_ulong  __unused5;
17736db45e65Sths };
17746db45e65Sths 
17756db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
17766db45e65Sths  * insane amounts of padding around dev_t's.
17776db45e65Sths  */
177820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1779541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
17806db45e65Sths 	unsigned long long	st_dev;
17816db45e65Sths 	unsigned char	__pad0[4];
17826db45e65Sths 
17836db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1784992f48a0Sblueswir1 	abi_ulong	__st_ino;
17856db45e65Sths 
17866db45e65Sths 	unsigned int	st_mode;
17876db45e65Sths 	unsigned int	st_nlink;
17886db45e65Sths 
1789992f48a0Sblueswir1 	abi_ulong	st_uid;
1790992f48a0Sblueswir1 	abi_ulong	st_gid;
17916db45e65Sths 
17926db45e65Sths 	unsigned long long	st_rdev;
17936db45e65Sths 	unsigned char	__pad3[4];
17946db45e65Sths 
17956db45e65Sths 	long long	st_size;
1796992f48a0Sblueswir1 	abi_ulong	st_blksize;
17976db45e65Sths 
17986db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
17996db45e65Sths 
1800992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1801992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
18026db45e65Sths 
1803992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1804992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
18056db45e65Sths 
1806992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1807992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
18086db45e65Sths 
18096db45e65Sths 	unsigned long long	st_ino;
18106db45e65Sths };
18116db45e65Sths 
1812d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1813*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1814d2fd1af7Sbellard struct target_stat {
1815d2fd1af7Sbellard 	abi_ulong	st_dev;
1816d2fd1af7Sbellard 	abi_ulong	st_ino;
1817d2fd1af7Sbellard 	abi_ulong	st_nlink;
1818d2fd1af7Sbellard 
1819d2fd1af7Sbellard 	unsigned int	st_mode;
1820d2fd1af7Sbellard 	unsigned int	st_uid;
1821d2fd1af7Sbellard 	unsigned int	st_gid;
1822d2fd1af7Sbellard 	unsigned int	__pad0;
1823d2fd1af7Sbellard 	abi_ulong	st_rdev;
1824d2fd1af7Sbellard 	abi_long	st_size;
1825d2fd1af7Sbellard 	abi_long	st_blksize;
1826d2fd1af7Sbellard 	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1827d2fd1af7Sbellard 
1828d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1829d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1830d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1831d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1832d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1833d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1834d2fd1af7Sbellard 
1835d2fd1af7Sbellard 	abi_long	__unused[3];
1836d2fd1af7Sbellard };
1837a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1838a4c075f1SUlrich Hecht struct target_stat {
1839a4c075f1SUlrich Hecht     abi_ulong  st_dev;
1840a4c075f1SUlrich Hecht     abi_ulong  st_ino;
1841a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
1842a4c075f1SUlrich Hecht     unsigned int   st_mode;
1843a4c075f1SUlrich Hecht     unsigned int   st_uid;
1844a4c075f1SUlrich Hecht     unsigned int   st_gid;
1845a4c075f1SUlrich Hecht     unsigned int   __pad1;
1846a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
1847a4c075f1SUlrich Hecht     abi_ulong  st_size;
1848a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
1849a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
1850a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
1851a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
1852a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
1853a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
1854a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
1855a4c075f1SUlrich Hecht     abi_long       st_blocks;
1856a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
1857a4c075f1SUlrich Hecht };
185809701199SAlexander Graf #elif defined(TARGET_AARCH64)
1859*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
186009701199SAlexander Graf struct target_stat {
186109701199SAlexander Graf     abi_ulong  st_dev;
186209701199SAlexander Graf     abi_ulong  st_ino;
186309701199SAlexander Graf     unsigned int st_mode;
186409701199SAlexander Graf     unsigned int st_nlink;
186509701199SAlexander Graf     unsigned int   st_uid;
186609701199SAlexander Graf     unsigned int   st_gid;
186709701199SAlexander Graf     abi_ulong  st_rdev;
186809701199SAlexander Graf     abi_ulong  _pad1;
186909701199SAlexander Graf     abi_long  st_size;
187009701199SAlexander Graf     int        st_blksize;
187109701199SAlexander Graf     int        __pad2;
187209701199SAlexander Graf     abi_long   st_blocks;
187309701199SAlexander Graf     abi_long  target_st_atime;
187409701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
187509701199SAlexander Graf     abi_long  target_st_mtime;
187609701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
187709701199SAlexander Graf     abi_long  target_st_ctime;
187809701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
187909701199SAlexander Graf     unsigned int __unused[2];
188009701199SAlexander Graf };
1881ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1882*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1883ba7651fbSMax Filippov struct target_stat {
1884ba7651fbSMax Filippov     abi_ulong       st_dev;
1885ba7651fbSMax Filippov     abi_ulong       st_ino;
1886ba7651fbSMax Filippov     unsigned int    st_mode;
1887ba7651fbSMax Filippov     unsigned int    st_nlink;
1888ba7651fbSMax Filippov     unsigned int    st_uid;
1889ba7651fbSMax Filippov     unsigned int    st_gid;
1890ba7651fbSMax Filippov     abi_ulong       st_rdev;
1891ba7651fbSMax Filippov     abi_long        st_size;
1892ba7651fbSMax Filippov     abi_ulong       st_blksize;
1893ba7651fbSMax Filippov     abi_ulong       st_blocks;
1894ba7651fbSMax Filippov     abi_ulong       target_st_atime;
1895ba7651fbSMax Filippov     abi_ulong       target_st_atime_nsec;
1896ba7651fbSMax Filippov     abi_ulong       target_st_mtime;
1897ba7651fbSMax Filippov     abi_ulong       target_st_mtime_nsec;
1898ba7651fbSMax Filippov     abi_ulong       target_st_ctime;
1899ba7651fbSMax Filippov     abi_ulong       target_st_ctime_nsec;
1900ba7651fbSMax Filippov     abi_ulong       __unused4;
1901ba7651fbSMax Filippov     abi_ulong       __unused5;
1902ba7651fbSMax Filippov };
1903ba7651fbSMax Filippov 
1904ba7651fbSMax Filippov #define TARGET_HAS_STRUCT_STAT64
1905ba7651fbSMax Filippov struct target_stat64  {
1906ba7651fbSMax Filippov     uint64_t st_dev;            /* Device */
1907ba7651fbSMax Filippov     uint64_t st_ino;            /* File serial number */
1908ba7651fbSMax Filippov     unsigned int  st_mode;      /* File mode. */
1909ba7651fbSMax Filippov     unsigned int  st_nlink;     /* Link count. */
1910ba7651fbSMax Filippov     unsigned int  st_uid;       /* User ID of the file's owner. */
1911ba7651fbSMax Filippov     unsigned int  st_gid;       /* Group ID of the file's group. */
1912ba7651fbSMax Filippov     uint64_t st_rdev;           /* Device number, if device. */
1913ba7651fbSMax Filippov     int64_t st_size;            /* Size of file, in bytes. */
1914ba7651fbSMax Filippov     abi_ulong st_blksize;       /* Optimal block size for I/O. */
1915ba7651fbSMax Filippov     abi_ulong __unused2;
1916ba7651fbSMax Filippov     uint64_t st_blocks;         /* Number 512-byte blocks allocated. */
1917ba7651fbSMax Filippov     abi_ulong target_st_atime;  /* Time of last access. */
1918ba7651fbSMax Filippov     abi_ulong target_st_atime_nsec;
1919ba7651fbSMax Filippov     abi_ulong target_st_mtime;  /* Time of last modification. */
1920ba7651fbSMax Filippov     abi_ulong target_st_mtime_nsec;
1921ba7651fbSMax Filippov     abi_ulong target_st_ctime;  /* Time of last status change. */
1922ba7651fbSMax Filippov     abi_ulong target_st_ctime_nsec;
1923ba7651fbSMax Filippov     abi_ulong __unused4;
1924ba7651fbSMax Filippov     abi_ulong __unused5;
1925ba7651fbSMax Filippov };
1926ba7651fbSMax Filippov 
1927a0a839b6SMarek Vasut #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
192847ae93cdSMichael Clark       defined(TARGET_NIOS2) || defined(TARGET_RISCV)
1929c7819dfbSPeter Maydell 
1930c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
1931c7819dfbSPeter Maydell 
1932*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1933d962783eSJia Liu struct target_stat {
1934d962783eSJia Liu     abi_ulong st_dev;
1935d962783eSJia Liu     abi_ulong st_ino;
1936d962783eSJia Liu     unsigned int st_mode;
1937c7819dfbSPeter Maydell     unsigned int st_nlink;
1938d962783eSJia Liu     unsigned int st_uid;
1939d962783eSJia Liu     unsigned int st_gid;
1940d962783eSJia Liu     abi_ulong st_rdev;
1941c7819dfbSPeter Maydell     abi_ulong __pad1;
1942d962783eSJia Liu     abi_long st_size;
1943c7819dfbSPeter Maydell     int st_blksize;
1944c7819dfbSPeter Maydell     int __pad2;
1945c7819dfbSPeter Maydell     abi_long st_blocks;
1946c7819dfbSPeter Maydell     abi_long target_st_atime;
1947d962783eSJia Liu     abi_ulong target_st_atime_nsec;
1948c7819dfbSPeter Maydell     abi_long target_st_mtime;
1949d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
1950c7819dfbSPeter Maydell     abi_long target_st_ctime;
1951d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
1952c7819dfbSPeter Maydell     unsigned int __unused4;
1953c7819dfbSPeter Maydell     unsigned int __unused5;
1954d962783eSJia Liu };
1955c7819dfbSPeter Maydell 
195647ae93cdSMichael Clark #if !defined(TARGET_RISCV64)
195720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1958c7819dfbSPeter Maydell struct target_stat64 {
1959c7819dfbSPeter Maydell     uint64_t st_dev;
1960c7819dfbSPeter Maydell     uint64_t st_ino;
1961c7819dfbSPeter Maydell     unsigned int st_mode;
1962c7819dfbSPeter Maydell     unsigned int st_nlink;
1963c7819dfbSPeter Maydell     unsigned int st_uid;
1964c7819dfbSPeter Maydell     unsigned int st_gid;
1965c7819dfbSPeter Maydell     uint64_t st_rdev;
1966c7819dfbSPeter Maydell     uint64_t __pad1;
1967c7819dfbSPeter Maydell     int64_t st_size;
1968c7819dfbSPeter Maydell     int st_blksize;
1969c7819dfbSPeter Maydell     int __pad2;
1970c7819dfbSPeter Maydell     int64_t st_blocks;
1971c7819dfbSPeter Maydell     int target_st_atime;
1972c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
1973c7819dfbSPeter Maydell     int target_st_mtime;
1974c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
1975c7819dfbSPeter Maydell     int target_st_ctime;
1976c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
1977c7819dfbSPeter Maydell     unsigned int __unused4;
1978c7819dfbSPeter Maydell     unsigned int __unused5;
1979c7819dfbSPeter Maydell };
198047ae93cdSMichael Clark #endif
1981c7819dfbSPeter Maydell 
1982a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1983a10d1e50SRichard Henderson 
1984*5f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1985a10d1e50SRichard Henderson struct target_stat {
1986a10d1e50SRichard Henderson     abi_uint   st_dev;
1987a10d1e50SRichard Henderson     abi_uint   st_ino;
1988a10d1e50SRichard Henderson     abi_ushort st_mode;
1989a10d1e50SRichard Henderson     abi_ushort st_nlink;
1990a10d1e50SRichard Henderson     abi_ushort _res1;
1991a10d1e50SRichard Henderson     abi_ushort _res2;
1992a10d1e50SRichard Henderson     abi_uint   st_rdev;
1993a10d1e50SRichard Henderson     abi_int    st_size;
1994a10d1e50SRichard Henderson     abi_int    target_st_atime;
1995a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
1996a10d1e50SRichard Henderson     abi_int    target_st_mtime;
1997a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
1998a10d1e50SRichard Henderson     abi_int    target_st_ctime;
1999a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2000a10d1e50SRichard Henderson     abi_int    st_blksize;
2001a10d1e50SRichard Henderson     abi_int    st_blocks;
2002a10d1e50SRichard Henderson     abi_uint   _unused1;
2003a10d1e50SRichard Henderson     abi_uint   _unused2;
2004a10d1e50SRichard Henderson     abi_uint   _unused3;
2005a10d1e50SRichard Henderson     abi_uint   _unused4;
2006a10d1e50SRichard Henderson     abi_ushort _unused5;
2007a10d1e50SRichard Henderson     abi_short  st_fstype;
2008a10d1e50SRichard Henderson     abi_uint   st_realdev;
2009a10d1e50SRichard Henderson     abi_ushort st_basemode;
2010a10d1e50SRichard Henderson     abi_ushort _unused6;
2011a10d1e50SRichard Henderson     abi_uint   st_uid;
2012a10d1e50SRichard Henderson     abi_uint   st_gid;
2013a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2014a10d1e50SRichard Henderson };
2015a10d1e50SRichard Henderson 
2016a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2017a10d1e50SRichard Henderson struct target_stat64 {
2018a10d1e50SRichard Henderson     uint64_t   st_dev;
2019a10d1e50SRichard Henderson     abi_uint   _pad1;
2020a10d1e50SRichard Henderson     abi_uint   _res1;
2021a10d1e50SRichard Henderson     abi_uint   st_mode;
2022a10d1e50SRichard Henderson     abi_uint   st_nlink;
2023a10d1e50SRichard Henderson     abi_uint   st_uid;
2024a10d1e50SRichard Henderson     abi_uint   st_gid;
2025a10d1e50SRichard Henderson     uint64_t   st_rdev;
2026a10d1e50SRichard Henderson     abi_uint   _pad2;
2027a10d1e50SRichard Henderson     int64_t    st_size;
2028a10d1e50SRichard Henderson     abi_int    st_blksize;
2029a10d1e50SRichard Henderson     int64_t    st_blocks;
2030a10d1e50SRichard Henderson     abi_int    target_st_atime;
2031a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2032a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2033a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2034a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2035a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2036a10d1e50SRichard Henderson     uint64_t   st_ino;
2037a10d1e50SRichard Henderson };
2038a10d1e50SRichard Henderson 
2039048f6b4dSbellard #else
2040048f6b4dSbellard #error unsupported CPU
2041048f6b4dSbellard #endif
20422521d698Sbellard 
20434ce6f8deSths typedef struct {
20444ce6f8deSths         int     val[2];
2045c227f099SAnthony Liguori } target_fsid_t;
20464ce6f8deSths 
204756c8f68fSbellard #ifdef TARGET_MIPS
2048d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2049540635baSths struct target_statfs {
2050540635baSths 	int32_t			f_type;
2051540635baSths 	int32_t			f_bsize;
2052540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2053540635baSths 	int32_t			f_blocks;
2054540635baSths 	int32_t			f_bfree;
2055540635baSths 	int32_t			f_files;
2056540635baSths 	int32_t			f_ffree;
2057540635baSths 	int32_t			f_bavail;
2058540635baSths 
2059540635baSths 	/* Linux specials */
2060c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2061540635baSths 	int32_t			f_namelen;
2062d4247ec2SShea Levy 	int32_t			f_flags;
2063d4247ec2SShea Levy 	int32_t			f_spare[5];
2064540635baSths };
2065540635baSths #else
206656c8f68fSbellard struct target_statfs {
2067992f48a0Sblueswir1 	abi_long		f_type;
2068992f48a0Sblueswir1 	abi_long		f_bsize;
2069992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2070992f48a0Sblueswir1 	abi_long		f_blocks;
2071992f48a0Sblueswir1 	abi_long		f_bfree;
2072992f48a0Sblueswir1 	abi_long		f_files;
2073992f48a0Sblueswir1 	abi_long		f_ffree;
2074992f48a0Sblueswir1 	abi_long		f_bavail;
207556c8f68fSbellard 
207656c8f68fSbellard 	/* Linux specials */
2077c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2078992f48a0Sblueswir1 	abi_long		f_namelen;
2079d4247ec2SShea Levy 	abi_long		f_flags;
2080d4247ec2SShea Levy 	abi_long		f_spare[5];
208156c8f68fSbellard };
2082540635baSths #endif
208356c8f68fSbellard 
208456c8f68fSbellard struct target_statfs64 {
208556c8f68fSbellard 	uint32_t	f_type;
208656c8f68fSbellard 	uint32_t	f_bsize;
208756c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
208856c8f68fSbellard 	uint32_t	__pad;
208956c8f68fSbellard 	uint64_t	f_blocks;
209056c8f68fSbellard 	uint64_t	f_bfree;
209156c8f68fSbellard 	uint64_t	f_files;
209256c8f68fSbellard 	uint64_t	f_ffree;
209356c8f68fSbellard 	uint64_t	f_bavail;
2094c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
209556c8f68fSbellard 	uint32_t	f_namelen;
2096d4247ec2SShea Levy 	uint32_t	f_flags;
2097d4247ec2SShea Levy 	uint32_t	f_spare[5];
209856c8f68fSbellard };
2099c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
210047ae93cdSMichael Clark        defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
210147ae93cdSMichael Clark        defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2102325e651fSj_mayer struct target_statfs {
2103325e651fSj_mayer 	abi_long f_type;
2104325e651fSj_mayer 	abi_long f_bsize;
2105325e651fSj_mayer 	abi_long f_blocks;
2106325e651fSj_mayer 	abi_long f_bfree;
2107325e651fSj_mayer 	abi_long f_bavail;
2108325e651fSj_mayer 	abi_long f_files;
2109325e651fSj_mayer 	abi_long f_ffree;
2110c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2111325e651fSj_mayer 	abi_long f_namelen;
2112325e651fSj_mayer 	abi_long f_frsize;
2113d4247ec2SShea Levy 	abi_long f_flags;
2114d4247ec2SShea Levy 	abi_long f_spare[4];
2115325e651fSj_mayer };
2116325e651fSj_mayer 
2117325e651fSj_mayer struct target_statfs64 {
2118325e651fSj_mayer 	abi_long f_type;
2119325e651fSj_mayer 	abi_long f_bsize;
2120325e651fSj_mayer 	abi_long f_blocks;
2121325e651fSj_mayer 	abi_long f_bfree;
2122325e651fSj_mayer 	abi_long f_bavail;
2123325e651fSj_mayer 	abi_long f_files;
2124325e651fSj_mayer 	abi_long f_ffree;
2125c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2126325e651fSj_mayer 	abi_long f_namelen;
2127325e651fSj_mayer 	abi_long f_frsize;
2128d4247ec2SShea Levy 	abi_long f_flags;
2129d4247ec2SShea Levy 	abi_long f_spare[4];
2130325e651fSj_mayer };
2131a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2132a4c075f1SUlrich Hecht struct target_statfs {
2133a4c075f1SUlrich Hecht     int32_t  f_type;
2134a4c075f1SUlrich Hecht     int32_t  f_bsize;
2135a4c075f1SUlrich Hecht     abi_long f_blocks;
2136a4c075f1SUlrich Hecht     abi_long f_bfree;
2137a4c075f1SUlrich Hecht     abi_long f_bavail;
2138a4c075f1SUlrich Hecht     abi_long f_files;
2139a4c075f1SUlrich Hecht     abi_long f_ffree;
2140a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2141a4c075f1SUlrich Hecht     int32_t  f_namelen;
2142a4c075f1SUlrich Hecht     int32_t  f_frsize;
2143d4247ec2SShea Levy     int32_t  f_flags;
2144d4247ec2SShea Levy     int32_t  f_spare[4];
2145d4247ec2SShea Levy 
2146a4c075f1SUlrich Hecht };
2147a4c075f1SUlrich Hecht 
2148a4c075f1SUlrich Hecht struct target_statfs64 {
2149a4c075f1SUlrich Hecht     int32_t  f_type;
2150a4c075f1SUlrich Hecht     int32_t  f_bsize;
2151a4c075f1SUlrich Hecht     abi_long f_blocks;
2152a4c075f1SUlrich Hecht     abi_long f_bfree;
2153a4c075f1SUlrich Hecht     abi_long f_bavail;
2154a4c075f1SUlrich Hecht     abi_long f_files;
2155a4c075f1SUlrich Hecht     abi_long f_ffree;
2156a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2157a4c075f1SUlrich Hecht     int32_t  f_namelen;
2158a4c075f1SUlrich Hecht     int32_t  f_frsize;
2159d4247ec2SShea Levy     int32_t  f_flags;
2160d4247ec2SShea Levy     int32_t  f_spare[4];
2161a4c075f1SUlrich Hecht };
216256c8f68fSbellard #else
216356c8f68fSbellard struct target_statfs {
216456c8f68fSbellard 	uint32_t f_type;
216556c8f68fSbellard 	uint32_t f_bsize;
216656c8f68fSbellard 	uint32_t f_blocks;
216756c8f68fSbellard 	uint32_t f_bfree;
216856c8f68fSbellard 	uint32_t f_bavail;
216956c8f68fSbellard 	uint32_t f_files;
217056c8f68fSbellard 	uint32_t f_ffree;
2171c227f099SAnthony Liguori 	target_fsid_t f_fsid;
217256c8f68fSbellard 	uint32_t f_namelen;
217356c8f68fSbellard 	uint32_t f_frsize;
2174d4247ec2SShea Levy 	uint32_t f_flags;
2175d4247ec2SShea Levy 	uint32_t f_spare[4];
217656c8f68fSbellard };
217756c8f68fSbellard 
217856c8f68fSbellard struct target_statfs64 {
217956c8f68fSbellard 	uint32_t f_type;
218056c8f68fSbellard 	uint32_t f_bsize;
218156c8f68fSbellard 	uint64_t f_blocks;
218256c8f68fSbellard 	uint64_t f_bfree;
218356c8f68fSbellard 	uint64_t f_bavail;
218456c8f68fSbellard 	uint64_t f_files;
218556c8f68fSbellard 	uint64_t f_ffree;
2186c227f099SAnthony Liguori 	target_fsid_t f_fsid;
218756c8f68fSbellard         uint32_t f_namelen;
218856c8f68fSbellard 	uint32_t f_frsize;
2189d4247ec2SShea Levy 	uint32_t f_flags;
2190d4247ec2SShea Levy 	uint32_t f_spare[4];
219156c8f68fSbellard };
219256c8f68fSbellard #endif
219356c8f68fSbellard 
21947e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
21957e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
21967e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
21977e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
21987e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
21997e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
22007e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
22017e22e546SUlrich Hecht 
22025de7706eSLaurent Vivier #include "target_fcntl.h"
22038d5d3004SAndreas Schwab 
22042521d698Sbellard /* soundcard defines */
220567cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
22062521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
22072521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
22082521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
22092521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
22102521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
22112521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
22122521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
22132521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
22142521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
22152521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
22162521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
22172521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
22182521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
22192521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
22202521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
22212521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
22222521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
22232521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
22242521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
22252521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
22262521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
22272521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
22282521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
22292521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
22302521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
22312521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
22322521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
22332521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
22345f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
22355f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
22362521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
22372521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
22382521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
22392521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
22402521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
22412521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
22422521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
22432521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
22442521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
22452521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
22462521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
22472521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
22482521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
22492521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
22502521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
22512521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
22522521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
22532521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
22542521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
22552521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
22562521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
22572521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
22582521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
22592521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
22602521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
22612521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
22622521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
22632521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
22642521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
22652521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
22662521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
22672521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
22682521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
22692521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
22702521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
22712521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
22722521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
22732521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
22742521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
22752521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
22762521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
22772521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
22782521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
22792521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
22802521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
22812521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
22822521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
22832521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
22842521d698Sbellard 
22852521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
22862521d698Sbellard 
22872521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
22882521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
22892521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
22902521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
22912521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
22922521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
22932521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
22942521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
22952521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
22962521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
22972521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
22982521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
22992521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
23002521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
23012521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
23022521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
23032521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
23042521d698Sbellard 
23052521d698Sbellard /* Obsolete macros */
23062521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
23072521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
23082521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
23092521d698Sbellard 
23102521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
23112521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
23122521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
23132521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
23142521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
23152521d698Sbellard 
23162521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
23172521d698Sbellard 
23182521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
23192521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
23202521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
23212521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
23222521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
23232521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
23242521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
23252521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
23262521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
23272521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
23282521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
23292521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
23302521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
23312521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
23322521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
23332521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
23342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
23352521d698Sbellard 
23362521d698Sbellard /* Obsolete macros */
23372521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
23382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
23392521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
23402521d698Sbellard 
23412521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
23422521d698Sbellard 
23432521d698Sbellard /* vfat ioctls */
23442521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
23452521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2346a5448a7dSbellard 
2347f443e396SPeter Maydell struct target_mtop {
2348f443e396SPeter Maydell     abi_short mt_op;
2349f443e396SPeter Maydell     abi_int mt_count;
2350f443e396SPeter Maydell };
2351f443e396SPeter Maydell 
2352f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2353f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2354f443e396SPeter Maydell #else
2355f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2356f443e396SPeter Maydell #endif
2357f443e396SPeter Maydell 
2358f443e396SPeter Maydell struct target_mtget {
2359f443e396SPeter Maydell     abi_long mt_type;
2360f443e396SPeter Maydell     abi_long mt_resid;
2361f443e396SPeter Maydell     abi_long mt_dsreg;
2362f443e396SPeter Maydell     abi_long mt_gstat;
2363f443e396SPeter Maydell     abi_long mt_erreg;
2364f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2365f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2366f443e396SPeter Maydell };
2367f443e396SPeter Maydell 
2368f443e396SPeter Maydell struct target_mtpos {
2369f443e396SPeter Maydell     abi_long mt_blkno;
2370f443e396SPeter Maydell };
2371f443e396SPeter Maydell 
2372f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2373f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2374f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
23758fbd6b52Sbalrog 
2376a5448a7dSbellard struct target_sysinfo {
2377992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2378992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2379992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2380992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2381992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2382992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2383992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2384992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2385a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2386a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2387992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2388992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2389a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2390992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2391a5448a7dSbellard };
23923532fa74Sbellard 
23936556a833Saurel32 struct linux_dirent {
23946556a833Saurel32     long            d_ino;
23956556a833Saurel32     unsigned long   d_off;
23966556a833Saurel32     unsigned short  d_reclen;
23976556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
23986556a833Saurel32 };
23996556a833Saurel32 
24006556a833Saurel32 struct linux_dirent64 {
24016556a833Saurel32     uint64_t        d_ino;
24026556a833Saurel32     int64_t         d_off;
24036556a833Saurel32     unsigned short  d_reclen;
24046556a833Saurel32     unsigned char   d_type;
24056556a833Saurel32     char            d_name[256];
24066556a833Saurel32 };
24076556a833Saurel32 
240824e1003aSaurel32 struct target_mq_attr {
240924e1003aSaurel32     abi_long mq_flags;
241024e1003aSaurel32     abi_long mq_maxmsg;
241124e1003aSaurel32     abi_long mq_msgsize;
241224e1003aSaurel32     abi_long mq_curmsgs;
241324e1003aSaurel32 };
241424e1003aSaurel32 
24153532fa74Sbellard #include "socket.h"
2416637947f1Sths 
2417637947f1Sths #include "errno_defs.h"
241803dfe9f8SRiku Voipio 
241903dfe9f8SRiku Voipio #define FUTEX_WAIT              0
242003dfe9f8SRiku Voipio #define FUTEX_WAKE              1
242103dfe9f8SRiku Voipio #define FUTEX_FD                2
242203dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
242303dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
242403dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
242503dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
242603dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
242703dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
242803dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
242903dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
243003dfe9f8SRiku Voipio 
243103dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
243203dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
243303dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
243403dfe9f8SRiku Voipio 
24353b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2436928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2437928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2438928bed6aSLaurent Vivier #else
2439928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2440928bed6aSLaurent Vivier #endif
2441928bed6aSLaurent Vivier 
24423b6edd16SPeter Maydell typedef union target_epoll_data {
24433b6edd16SPeter Maydell     abi_ulong ptr;
2444928bed6aSLaurent Vivier     abi_int fd;
2445928bed6aSLaurent Vivier     abi_uint u32;
2446928bed6aSLaurent Vivier     abi_ullong u64;
24473b6edd16SPeter Maydell } target_epoll_data_t;
24483b6edd16SPeter Maydell 
24493b6edd16SPeter Maydell struct target_epoll_event {
2450928bed6aSLaurent Vivier     abi_uint events;
24513b6edd16SPeter Maydell     target_epoll_data_t data;
2452928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
24532ba7fae3SPeter Maydell 
24542ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
24552ba7fae3SPeter Maydell 
24563b6edd16SPeter Maydell #endif
2457163a05a8SPeter Maydell struct target_rlimit64 {
2458163a05a8SPeter Maydell     uint64_t rlim_cur;
2459163a05a8SPeter Maydell     uint64_t rlim_max;
2460163a05a8SPeter Maydell };
2461583359a6SAkos PASZTORY 
2462583359a6SAkos PASZTORY struct target_ucred {
2463583359a6SAkos PASZTORY     uint32_t pid;
2464583359a6SAkos PASZTORY     uint32_t uid;
2465583359a6SAkos PASZTORY     uint32_t gid;
2466583359a6SAkos PASZTORY };
2467cb9c377fSPaolo Bonzini 
2468aecc8861SAlexander Graf typedef int32_t target_timer_t;
2469905bba13SErik de Castro Lopo 
247034d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
247134d60862SNatanael Copa 
247234d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
247334d60862SNatanael Copa #ifdef TARGET_MIPS
247434d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
247534d60862SNatanael Copa #else
247634d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
247734d60862SNatanael Copa                                     + sizeof(target_sigval_t))
247834d60862SNatanael Copa #endif
247934d60862SNatanael Copa 
248034d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
248134d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
248234d60862SNatanael Copa                                / sizeof(int32_t))
248334d60862SNatanael Copa 
2484905bba13SErik de Castro Lopo struct target_sigevent {
2485905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
248617351c3fSPeter Maydell     abi_int sigev_signo;
248717351c3fSPeter Maydell     abi_int sigev_notify;
2488905bba13SErik de Castro Lopo     union {
248917351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
249017351c3fSPeter Maydell         abi_int _tid;
2491905bba13SErik de Castro Lopo 
249217351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
249317351c3fSPeter Maydell          * they're only used as part of the ABI between a
249417351c3fSPeter Maydell          * userspace program and libc.
249517351c3fSPeter Maydell          */
2496905bba13SErik de Castro Lopo         struct {
249717351c3fSPeter Maydell             abi_ulong _function;
249817351c3fSPeter Maydell             abi_ulong _attribute;
2499905bba13SErik de Castro Lopo         } _sigev_thread;
2500905bba13SErik de Castro Lopo     } _sigev_un;
2501905bba13SErik de Castro Lopo };
2502e0eb210eSPeter Maydell 
2503e0eb210eSPeter Maydell struct target_user_cap_header {
2504e0eb210eSPeter Maydell     uint32_t version;
2505e0eb210eSPeter Maydell     int pid;
2506e0eb210eSPeter Maydell };
2507e0eb210eSPeter Maydell 
2508e0eb210eSPeter Maydell struct target_user_cap_data {
2509e0eb210eSPeter Maydell     uint32_t effective;
2510e0eb210eSPeter Maydell     uint32_t permitted;
2511e0eb210eSPeter Maydell     uint32_t inheritable;
2512e0eb210eSPeter Maydell };
25131b3c4fdfSMarkus Armbruster 
2514da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2515da2c8ad7SAleksandar Markovic 
2516da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2517da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2518da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2519da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2520da2c8ad7SAleksandar Markovic /* Read from the log. */
2521da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2522da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2523da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2524da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2525da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2526da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2527da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2528da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2529da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2530da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2531da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2532da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2533da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2534da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2535da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2536da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2537da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2538da2c8ad7SAleksandar Markovic 
25391b3c4fdfSMarkus Armbruster #endif
2540