xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 1c4c6fcd1a2ae56e98be3a441e19a0933c508a51)
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 
35524fa340SLaurent Vivier #define IPCOP_CALL(VERSION, OP) ((VERSION) << 16 | (OP))
368853f86eSbellard #define IPCOP_semop		1
378853f86eSbellard #define IPCOP_semget		2
388853f86eSbellard #define IPCOP_semctl		3
398853f86eSbellard #define IPCOP_semtimedop	4
408853f86eSbellard #define IPCOP_msgsnd		11
418853f86eSbellard #define IPCOP_msgrcv		12
428853f86eSbellard #define IPCOP_msgget		13
438853f86eSbellard #define IPCOP_msgctl		14
448853f86eSbellard #define IPCOP_shmat		21
458853f86eSbellard #define IPCOP_shmdt		22
468853f86eSbellard #define IPCOP_shmget		23
478853f86eSbellard #define IPCOP_shmctl		24
488853f86eSbellard 
492521d698Sbellard /*
502521d698Sbellard  * The following is for compatibility across the various Linux
512521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
522521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
532521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
542521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
552521d698Sbellard  * below from now on.
562521d698Sbellard  */
572521d698Sbellard #define TARGET_IOC_NRBITS	8
582521d698Sbellard #define TARGET_IOC_TYPEBITS	8
592521d698Sbellard 
60716f3fbeSPeter Maydell #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
61716f3fbeSPeter Maydell     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
62cd98d390SAndreas Schwab     || defined(TARGET_SPARC) \
630c866a7eSRiku Voipio     || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
6474d753acSMika Westerberg     /* 16 bit uid wrappers emulation */
6574d753acSMika Westerberg #define USE_UID16
660c866a7eSRiku Voipio #define target_id uint16_t
670c866a7eSRiku Voipio #else
680c866a7eSRiku Voipio #define target_id uint32_t
6974d753acSMika Westerberg #endif
7074d753acSMika Westerberg 
71e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
72b16189b2SChen Gang     || defined(TARGET_M68K) || defined(TARGET_CRIS) \
73daa4374aSPeter Maydell     || defined(TARGET_S390X) \
74a0a839b6SMarek Vasut     || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
75ba7651fbSMax Filippov     || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
76ba7651fbSMax Filippov     || defined(TARGET_XTENSA)
772521d698Sbellard 
782521d698Sbellard #define TARGET_IOC_SIZEBITS	14
792521d698Sbellard #define TARGET_IOC_DIRBITS	2
802521d698Sbellard 
812521d698Sbellard #define TARGET_IOC_NONE	  0U
822521d698Sbellard #define TARGET_IOC_WRITE  1U
832521d698Sbellard #define TARGET_IOC_READ	  2U
842521d698Sbellard 
85048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
86b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
87b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
882521d698Sbellard 
892521d698Sbellard #define TARGET_IOC_SIZEBITS	13
902521d698Sbellard #define TARGET_IOC_DIRBITS	3
912521d698Sbellard 
922521d698Sbellard #define TARGET_IOC_NONE	  1U
932521d698Sbellard #define TARGET_IOC_READ	  2U
942521d698Sbellard #define TARGET_IOC_WRITE  4U
952521d698Sbellard 
96a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
97a10d1e50SRichard Henderson 
98a10d1e50SRichard Henderson #define TARGET_IOC_SIZEBITS  14
99a10d1e50SRichard Henderson #define TARGET_IOC_DIRBITS    2
100a10d1e50SRichard Henderson 
101a10d1e50SRichard Henderson #define TARGET_IOC_NONE   0U
102a10d1e50SRichard Henderson #define TARGET_IOC_WRITE  2U
103a10d1e50SRichard Henderson #define TARGET_IOC_READ   1U
104a10d1e50SRichard Henderson 
1052521d698Sbellard #else
1062521d698Sbellard #error unsupported CPU
1072521d698Sbellard #endif
1082521d698Sbellard 
1092521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
1102521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
1112521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
1122521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
1132521d698Sbellard 
1142521d698Sbellard #define TARGET_IOC_NRSHIFT	0
1152521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
1162521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
1172521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
1182521d698Sbellard 
1192521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
1202521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
1212521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
1222521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1232521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1242521d698Sbellard 
1252521d698Sbellard /* used to create numbers */
1262521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1272521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1282521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1292521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1302521d698Sbellard 
1312521d698Sbellard /* the size is automatically computed for these defines */
1322521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1332521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1342521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1352521d698Sbellard 
1367854b056Sbellard struct target_sockaddr {
1379a68960dSPhilippe Mathieu-Daudé     abi_ushort sa_family;
1387854b056Sbellard     uint8_t sa_data[14];
1397854b056Sbellard };
1407854b056Sbellard 
14133a29b51SJoakim Tjernlund struct target_sockaddr_ll {
1429a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_family;   /* Always AF_PACKET */
1439a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_protocol; /* Physical layer protocol */
1449a68960dSPhilippe Mathieu-Daudé     abi_int    sll_ifindex;  /* Interface number */
1459a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_hatype;   /* ARP hardware type */
14633a29b51SJoakim Tjernlund     uint8_t    sll_pkttype;  /* Packet type */
14733a29b51SJoakim Tjernlund     uint8_t    sll_halen;    /* Length of address */
14833a29b51SJoakim Tjernlund     uint8_t    sll_addr[8];  /* Physical layer address */
14933a29b51SJoakim Tjernlund };
15033a29b51SJoakim Tjernlund 
151fb3aabf3SLaurent Vivier struct target_sockaddr_un {
1529a68960dSPhilippe Mathieu-Daudé     abi_ushort su_family;
153fb3aabf3SLaurent Vivier     uint8_t sun_path[108];
154fb3aabf3SLaurent Vivier };
155fb3aabf3SLaurent Vivier 
156a47401bcSPhilippe Mathieu-Daudé struct target_sockaddr_nl {
157a47401bcSPhilippe Mathieu-Daudé     abi_ushort nl_family;   /* AF_NETLINK */
158a47401bcSPhilippe Mathieu-Daudé     abi_ushort __pad;
159a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_pid;
160a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_groups;
161a47401bcSPhilippe Mathieu-Daudé };
162a47401bcSPhilippe Mathieu-Daudé 
163fb3aabf3SLaurent Vivier struct target_in_addr {
1649a68960dSPhilippe Mathieu-Daudé     abi_uint s_addr; /* big endian */
165fb3aabf3SLaurent Vivier };
166fb3aabf3SLaurent Vivier 
167fb3aabf3SLaurent Vivier struct target_sockaddr_in {
1689a68960dSPhilippe Mathieu-Daudé   abi_ushort sin_family;
1699a68960dSPhilippe Mathieu-Daudé   abi_short sin_port; /* big endian */
170fb3aabf3SLaurent Vivier   struct target_in_addr sin_addr;
171fb3aabf3SLaurent Vivier   uint8_t __pad[sizeof(struct target_sockaddr) -
1729a68960dSPhilippe Mathieu-Daudé                 sizeof(abi_ushort) - sizeof(abi_short) -
173fb3aabf3SLaurent Vivier                 sizeof(struct target_in_addr)];
174fb3aabf3SLaurent Vivier };
175fb3aabf3SLaurent Vivier 
176ee1ac3a1SHelge Deller struct target_sockaddr_in6 {
1779a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_family;
1789a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_port; /* big endian */
1799a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_flowinfo; /* big endian */
180ee1ac3a1SHelge Deller     struct in6_addr sin6_addr; /* IPv6 address, big endian */
1819a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_scope_id;
182ee1ac3a1SHelge Deller };
183ee1ac3a1SHelge Deller 
184f57d4192SLaurent Vivier struct target_sock_filter {
185f57d4192SLaurent Vivier     abi_ushort code;
186f57d4192SLaurent Vivier     uint8_t jt;
187f57d4192SLaurent Vivier     uint8_t jf;
188f57d4192SLaurent Vivier     abi_uint k;
189f57d4192SLaurent Vivier };
190f57d4192SLaurent Vivier 
191f57d4192SLaurent Vivier struct target_sock_fprog {
192f57d4192SLaurent Vivier     abi_ushort len;
193f57d4192SLaurent Vivier     abi_ulong filter;
194f57d4192SLaurent Vivier };
195f57d4192SLaurent Vivier 
196b975b83bSLionel Landwerlin struct target_ip_mreq {
197b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
198b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
199b975b83bSLionel Landwerlin };
200b975b83bSLionel Landwerlin 
201b975b83bSLionel Landwerlin struct target_ip_mreqn {
202b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
203b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
204b975b83bSLionel Landwerlin     abi_long imr_ifindex;
205b975b83bSLionel Landwerlin };
206b975b83bSLionel Landwerlin 
2076e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
2086e3cb58fSLionel Landwerlin     /* big endian */
2096e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
2106e3cb58fSLionel Landwerlin     uint32_t imr_interface;
2116e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
2126e3cb58fSLionel Landwerlin };
2136e3cb58fSLionel Landwerlin 
21483eb6e50SCarlo Marcelo Arenas Belón struct target_linger {
21583eb6e50SCarlo Marcelo Arenas Belón     abi_int l_onoff;        /* Linger active                */
21683eb6e50SCarlo Marcelo Arenas Belón     abi_int l_linger;       /* How long to linger for       */
21783eb6e50SCarlo Marcelo Arenas Belón };
21883eb6e50SCarlo Marcelo Arenas Belón 
2196d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
2206d5d5ddeSDaniel P. Berrangé struct target_timeval {
2216d5d5ddeSDaniel P. Berrangé     abi_long tv_sec;
2226d5d5ddeSDaniel P. Berrangé     abi_int tv_usec;
2236d5d5ddeSDaniel P. Berrangé };
2246d5d5ddeSDaniel P. Berrangé #define target__kernel_sock_timeval target_timeval
2256d5d5ddeSDaniel P. Berrangé #else
22631e31b8aSbellard struct target_timeval {
227992f48a0Sblueswir1     abi_long tv_sec;
228992f48a0Sblueswir1     abi_long tv_usec;
22931e31b8aSbellard };
23031e31b8aSbellard 
2316d5d5ddeSDaniel P. Berrangé struct target__kernel_sock_timeval {
2326d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2336d5d5ddeSDaniel P. Berrangé     abi_llong tv_usec;
2346d5d5ddeSDaniel P. Berrangé };
2356d5d5ddeSDaniel P. Berrangé #endif
2366d5d5ddeSDaniel P. Berrangé 
2371b6b029eSbellard struct target_timespec {
238992f48a0Sblueswir1     abi_long tv_sec;
239992f48a0Sblueswir1     abi_long tv_nsec;
2401b6b029eSbellard };
2411b6b029eSbellard 
2426d5d5ddeSDaniel P. Berrangé struct target__kernel_timespec {
2436d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2446d5d5ddeSDaniel P. Berrangé     abi_llong tv_nsec;
2456d5d5ddeSDaniel P. Berrangé };
2466d5d5ddeSDaniel P. Berrangé 
247ef4467e9SPaul Burton struct target_timezone {
248ef4467e9SPaul Burton     abi_int tz_minuteswest;
249ef4467e9SPaul Burton     abi_int tz_dsttime;
250ef4467e9SPaul Burton };
251ef4467e9SPaul Burton 
25266fb9763Sbellard struct target_itimerval {
25366fb9763Sbellard     struct target_timeval it_interval;
25466fb9763Sbellard     struct target_timeval it_value;
25566fb9763Sbellard };
25666fb9763Sbellard 
257905bba13SErik de Castro Lopo struct target_itimerspec {
258905bba13SErik de Castro Lopo     struct target_timespec it_interval;
259905bba13SErik de Castro Lopo     struct target_timespec it_value;
260905bba13SErik de Castro Lopo };
261905bba13SErik de Castro Lopo 
26219f59bceSAleksandar Markovic struct target_timex {
26319f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
26419f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
26519f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
26619f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
26719f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
26819f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
26919f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
27019f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
27119f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
27219f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
27319f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
27419f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
27519f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
27619f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
27719f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
27819f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
27919f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
28019f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
28119f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
28219f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
28319f59bceSAleksandar Markovic 
28419f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
28519f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
28619f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
28719f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
28819f59bceSAleksandar Markovic };
28919f59bceSAleksandar Markovic 
290c227f099SAnthony Liguori typedef abi_long target_clock_t;
29132f36bceSbellard 
292c596ed17Sbellard #define TARGET_HZ 100
293c596ed17Sbellard 
29432f36bceSbellard struct target_tms {
295c227f099SAnthony Liguori     target_clock_t tms_utime;
296c227f099SAnthony Liguori     target_clock_t tms_stime;
297c227f099SAnthony Liguori     target_clock_t tms_cutime;
298c227f099SAnthony Liguori     target_clock_t tms_cstime;
29932f36bceSbellard };
30032f36bceSbellard 
3016180a181Sbellard struct target_utimbuf {
302992f48a0Sblueswir1     abi_long actime;
303992f48a0Sblueswir1     abi_long modtime;
3046180a181Sbellard };
3056180a181Sbellard 
306f2674e31Sbellard struct target_sel_arg_struct {
307992f48a0Sblueswir1     abi_long n;
308992f48a0Sblueswir1     abi_long inp, outp, exp;
309992f48a0Sblueswir1     abi_long tvp;
310f2674e31Sbellard };
311f2674e31Sbellard 
31231e31b8aSbellard struct target_iovec {
313992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
314992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
31531e31b8aSbellard };
31631e31b8aSbellard 
3171a9353d2Sbellard struct target_msghdr {
318992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
3191a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
320992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
321992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
322992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
323992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
3241a9353d2Sbellard     unsigned int msg_flags;
3251a9353d2Sbellard };
3261a9353d2Sbellard 
3277854b056Sbellard struct target_cmsghdr {
328992f48a0Sblueswir1     abi_long     cmsg_len;
3297854b056Sbellard     int          cmsg_level;
3307854b056Sbellard     int          cmsg_type;
3317854b056Sbellard };
3327854b056Sbellard 
3337854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
334ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
335ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
336992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
337992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
338ad762b99SPeter Maydell #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
339ad762b99SPeter Maydell                                 TARGET_CMSG_ALIGN(len))
340ad762b99SPeter Maydell #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
3417854b056Sbellard 
3427854b056Sbellard static __inline__ struct target_cmsghdr *
343ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
344ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
345ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3467854b056Sbellard {
3472b8bdefcSths   struct target_cmsghdr *__ptr;
3487854b056Sbellard 
3492b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
350cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
351ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
352ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3537854b056Sbellard     /* No more entries.  */
3542b8bdefcSths     return (struct target_cmsghdr *)0;
355ee104587SJonathan Neuschäfer   }
356ee104587SJonathan Neuschäfer   return __ptr;
3577854b056Sbellard }
3587854b056Sbellard 
359f19e00d7SAlexander Graf struct target_mmsghdr {
360f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
361f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
362f19e00d7SAlexander Graf };
3637854b056Sbellard 
36431e31b8aSbellard struct  target_rusage {
36531e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
36631e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
367992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
368992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
369992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
370992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
371992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
372992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
373992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
374992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
375992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
376992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
377992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
378992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
379992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
380992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
38131e31b8aSbellard };
38231e31b8aSbellard 
38331e31b8aSbellard typedef struct {
38431e31b8aSbellard         int     val[2];
385c227f099SAnthony Liguori } kernel_fsid_t;
38631e31b8aSbellard 
387dab2ed99Sbellard struct target_dirent {
388992f48a0Sblueswir1         abi_long        d_ino;
389992f48a0Sblueswir1         abi_long        d_off;
390dab2ed99Sbellard         unsigned short  d_reclen;
391333858b7SDmitry V. Levin         char            d_name[];
392dab2ed99Sbellard };
393dab2ed99Sbellard 
394dab2ed99Sbellard struct target_dirent64 {
395dab2ed99Sbellard 	uint64_t	d_ino;
396dab2ed99Sbellard 	int64_t		d_off;
397dab2ed99Sbellard 	unsigned short	d_reclen;
398dab2ed99Sbellard 	unsigned char	d_type;
399dab2ed99Sbellard 	char		d_name[256];
400dab2ed99Sbellard };
401dab2ed99Sbellard 
402dab2ed99Sbellard 
40331e31b8aSbellard /* mostly generic signal stuff */
404992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
405992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
406992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
40731e31b8aSbellard 
40831e31b8aSbellard #ifdef TARGET_MIPS
40931e31b8aSbellard #define TARGET_NSIG	   128
41031e31b8aSbellard #else
41131e31b8aSbellard #define TARGET_NSIG	   64
41231e31b8aSbellard #endif
413992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
41431e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
41531e31b8aSbellard 
41631e31b8aSbellard typedef struct {
417992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
418c227f099SAnthony Liguori } target_sigset_t;
41931e31b8aSbellard 
42066fb9763Sbellard #ifdef BSWAP_NEEDED
421c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
42266fb9763Sbellard {
42366fb9763Sbellard     int i;
42466fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
425cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
42666fb9763Sbellard }
42766fb9763Sbellard #else
428c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
42966fb9763Sbellard {
43066fb9763Sbellard     *d = *s;
43166fb9763Sbellard }
43266fb9763Sbellard #endif
43366fb9763Sbellard 
434c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
43566fb9763Sbellard {
43666fb9763Sbellard     int i;
43766fb9763Sbellard     d->sig[0] = set;
43866fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
43966fb9763Sbellard         d->sig[i] = 0;
44066fb9763Sbellard }
44166fb9763Sbellard 
442c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
443c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
444992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
44566fb9763Sbellard                                const sigset_t *sigset);
44666fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
447992f48a0Sblueswir1                                const abi_ulong *old_sigset);
44866fb9763Sbellard struct target_sigaction;
44966fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
45066fb9763Sbellard                  struct target_sigaction *oact);
45166fb9763Sbellard 
4529850f9f6SLaurent Vivier #include "target_signal.h"
4539850f9f6SLaurent Vivier 
4547f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
4557f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
4567f047de1SRichard Henderson #endif
4577f047de1SRichard Henderson 
4586049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
4596049f4f8SRichard Henderson struct target_old_sigaction {
4606049f4f8SRichard Henderson     abi_ulong _sa_handler;
4616049f4f8SRichard Henderson     abi_ulong sa_mask;
462d2565875SRichard Henderson     int32_t sa_flags;
4636049f4f8SRichard Henderson };
464106ec879Sbellard 
4656049f4f8SRichard Henderson struct target_rt_sigaction {
4666049f4f8SRichard Henderson     abi_ulong _sa_handler;
4676049f4f8SRichard Henderson     abi_ulong sa_flags;
4686049f4f8SRichard Henderson     target_sigset_t sa_mask;
4696049f4f8SRichard Henderson };
4706049f4f8SRichard Henderson 
4716049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
4726049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
4736049f4f8SRichard Henderson struct target_sigaction {
4746049f4f8SRichard Henderson     abi_ulong _sa_handler;
4756049f4f8SRichard Henderson     abi_ulong sa_flags;
4766049f4f8SRichard Henderson     target_sigset_t sa_mask;
4776049f4f8SRichard Henderson     abi_ulong sa_restorer;
4786049f4f8SRichard Henderson };
4796049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
480106ec879Sbellard struct target_sigaction {
481540635baSths 	uint32_t	sa_flags;
482d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
483540635baSths 	uint32_t	_sa_handler;
484540635baSths #else
485992f48a0Sblueswir1 	abi_ulong	_sa_handler;
486540635baSths #endif
487c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
4887f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
4897f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
4907f047de1SRichard Henderson         abi_ulong sa_restorer;
4917f047de1SRichard Henderson #endif
492106ec879Sbellard };
493106ec879Sbellard #else
4942521d698Sbellard struct target_old_sigaction {
495992f48a0Sblueswir1         abi_ulong _sa_handler;
496992f48a0Sblueswir1         abi_ulong sa_mask;
497992f48a0Sblueswir1         abi_ulong sa_flags;
4987f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
499992f48a0Sblueswir1         abi_ulong sa_restorer;
5007f047de1SRichard Henderson #endif
5012521d698Sbellard };
5022521d698Sbellard 
5032521d698Sbellard struct target_sigaction {
504992f48a0Sblueswir1         abi_ulong _sa_handler;
505992f48a0Sblueswir1         abi_ulong sa_flags;
5067f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
507992f48a0Sblueswir1         abi_ulong sa_restorer;
5087f047de1SRichard Henderson #endif
509c227f099SAnthony Liguori         target_sigset_t sa_mask;
5105de154e8SLaurent Vivier #ifdef TARGET_ARCH_HAS_KA_RESTORER
5115de154e8SLaurent Vivier         abi_ulong ka_restorer;
5125de154e8SLaurent Vivier #endif
5132521d698Sbellard };
514106ec879Sbellard #endif
5152521d698Sbellard 
5162521d698Sbellard typedef union target_sigval {
5172521d698Sbellard 	int sival_int;
518992f48a0Sblueswir1         abi_ulong sival_ptr;
519c227f099SAnthony Liguori } target_sigval_t;
5206d5e216dSbellard #if 0
5216d5e216dSbellard #if defined (TARGET_SPARC)
5226d5e216dSbellard typedef struct {
5236d5e216dSbellard 	struct {
524992f48a0Sblueswir1 		abi_ulong psr;
525992f48a0Sblueswir1 		abi_ulong pc;
526992f48a0Sblueswir1 		abi_ulong npc;
527992f48a0Sblueswir1 		abi_ulong y;
528992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5296d5e216dSbellard 	}		si_regs;
5306d5e216dSbellard 	int		si_mask;
5316d5e216dSbellard } __siginfo_t;
5326d5e216dSbellard 
5336d5e216dSbellard typedef struct {
5346d5e216dSbellard 	unsigned   long si_float_regs [32];
5356d5e216dSbellard 	unsigned   long si_fsr;
5366d5e216dSbellard 	unsigned   long si_fpqdepth;
5376d5e216dSbellard 	struct {
5386d5e216dSbellard 		unsigned long *insn_addr;
5396d5e216dSbellard 		unsigned long insn;
5406d5e216dSbellard 	} si_fpqueue [16];
5416d5e216dSbellard } __siginfo_fpu_t;
5426d5e216dSbellard #endif
5436d5e216dSbellard #endif
5442521d698Sbellard 
5452521d698Sbellard #define TARGET_SI_MAX_SIZE	128
546aa5e03d2SMaxim Ostapenko 
547aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
548aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
549aa5e03d2SMaxim Ostapenko #else
550aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
551aa5e03d2SMaxim Ostapenko #endif
552aa5e03d2SMaxim Ostapenko 
553aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
5542521d698Sbellard 
555a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
556a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
557a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
558a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
559a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
560a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
561a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
562a70dadc7SPeter Maydell  */
563a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
564a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
565a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
566a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
567a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
568a70dadc7SPeter Maydell #define QEMU_SI_RT 5
569a70dadc7SPeter Maydell 
5702521d698Sbellard typedef struct target_siginfo {
5713f53d546Spbrook #ifdef TARGET_MIPS
5723f53d546Spbrook 	int si_signo;
5733f53d546Spbrook 	int si_code;
5743f53d546Spbrook 	int si_errno;
5753f53d546Spbrook #else
5762521d698Sbellard 	int si_signo;
5772521d698Sbellard 	int si_errno;
5782521d698Sbellard 	int si_code;
5793f53d546Spbrook #endif
5802521d698Sbellard 
5812521d698Sbellard 	union {
5822521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
5832521d698Sbellard 
5842521d698Sbellard 		/* kill() */
5852521d698Sbellard 		struct {
5862521d698Sbellard 			pid_t _pid;		/* sender's pid */
5872521d698Sbellard 			uid_t _uid;		/* sender's uid */
5882521d698Sbellard 		} _kill;
5892521d698Sbellard 
5902521d698Sbellard 		/* POSIX.1b timers */
5912521d698Sbellard 		struct {
5922521d698Sbellard 			unsigned int _timer1;
5932521d698Sbellard 			unsigned int _timer2;
5942521d698Sbellard 		} _timer;
5952521d698Sbellard 
5962521d698Sbellard 		/* POSIX.1b signals */
5972521d698Sbellard 		struct {
5982521d698Sbellard 			pid_t _pid;		/* sender's pid */
5992521d698Sbellard 			uid_t _uid;		/* sender's uid */
600c227f099SAnthony Liguori 			target_sigval_t _sigval;
6012521d698Sbellard 		} _rt;
6022521d698Sbellard 
6032521d698Sbellard 		/* SIGCHLD */
6042521d698Sbellard 		struct {
6052521d698Sbellard 			pid_t _pid;		/* which child */
6062521d698Sbellard 			uid_t _uid;		/* sender's uid */
6072521d698Sbellard 			int _status;		/* exit code */
608c227f099SAnthony Liguori 			target_clock_t _utime;
609c227f099SAnthony Liguori                         target_clock_t _stime;
6102521d698Sbellard 		} _sigchld;
6112521d698Sbellard 
6122521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
6132521d698Sbellard 		struct {
614992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
6152521d698Sbellard 		} _sigfault;
6162521d698Sbellard 
6172521d698Sbellard 		/* SIGPOLL */
6182521d698Sbellard 		struct {
6192521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
6202521d698Sbellard 			int _fd;
6212521d698Sbellard 		} _sigpoll;
6222521d698Sbellard 	} _sifields;
623c227f099SAnthony Liguori } target_siginfo_t;
6242521d698Sbellard 
6252521d698Sbellard /*
6262521d698Sbellard  * si_code values
6272521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6282521d698Sbellard  */
6292521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6302521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6312521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6322521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6332521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6342521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6352521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6362521d698Sbellard 
6372521d698Sbellard /*
6382521d698Sbellard  * SIGILL si_codes
6392521d698Sbellard  */
640ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6412521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
642ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
643ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
644ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
645ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
646ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
647ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
648de2fdd56SChen Gang #ifdef TARGET_TILEGX
649de2fdd56SChen Gang #define TARGET_ILL_DBLFLT       (9)     /* double fault */
650de2fdd56SChen Gang #define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
651de2fdd56SChen Gang #endif
6522521d698Sbellard 
6532521d698Sbellard /*
6542521d698Sbellard  * SIGFPE si_codes
6552521d698Sbellard  */
6562521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
6572521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
6582521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
6592521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
6602521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
6612521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
6622521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
6632521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
66421ba8564SRichard Henderson #define TARGET_FPE_FLTUNK      (14) /* undiagnosed fp exception */
66521ba8564SRichard Henderson #define TARGET_NSIGFPE         15
6662521d698Sbellard 
6672521d698Sbellard /*
6682521d698Sbellard  * SIGSEGV si_codes
6692521d698Sbellard  */
6702521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
6712521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
672de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
6732521d698Sbellard 
6742521d698Sbellard /*
675ffa65c3bSbellard  * SIGBUS si_codes
676ffa65c3bSbellard  */
677ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
678b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
679ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
680de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
681de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
682de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
683de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
684ffa65c3bSbellard 
685ffa65c3bSbellard /*
6862521d698Sbellard  * SIGTRAP si_codes
6872521d698Sbellard  */
6882521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
6892521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
690de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
691de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
6922521d698Sbellard 
6939de5e440Sbellard struct target_rlimit {
694992f48a0Sblueswir1         abi_ulong   rlim_cur;
695992f48a0Sblueswir1         abi_ulong   rlim_max;
6969de5e440Sbellard };
6979de5e440Sbellard 
69881bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
699e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
7006cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
70181bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
70281bbe906Stakasi-y@ops.dti.ne.jp #else
70326b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
70481bbe906Stakasi-y@ops.dti.ne.jp #endif
70581bbe906Stakasi-y@ops.dti.ne.jp 
706e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
707e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
708e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
709e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
710e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
711e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
712e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
713e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
714e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
715e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
716e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
717e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
718e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
719e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
720e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
721e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
722e22b7015SWesley W. Terpstra #else
723e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
724e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
725e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
726e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
727e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
728e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7296cafd027SMatthias Braun #if defined(TARGET_SPARC)
7306cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7316cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7326cafd027SMatthias Braun #else
733e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
734e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7356cafd027SMatthias Braun #endif
736e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
737e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
738e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
739e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
740e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
741e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
742e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
743e22b7015SWesley W. Terpstra #endif
744e22b7015SWesley W. Terpstra 
7459de5e440Sbellard struct target_pollfd {
7469de5e440Sbellard     int fd;           /* file descriptor */
7479de5e440Sbellard     short events;     /* requested events */
7489de5e440Sbellard     short revents;    /* returned events */
7499de5e440Sbellard };
7509de5e440Sbellard 
7518e5a0667Sbellard /* virtual terminal ioctls */
7520221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7530221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7548e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
755f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
756f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
757f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7580221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7590221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
760e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
761e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
762e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
763e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
764ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
7658e5a0667Sbellard 
766373b067fSFilip Bozuta struct target_rtc_pll_info {
767373b067fSFilip Bozuta     int pll_ctrl;
768373b067fSFilip Bozuta     int pll_value;
769373b067fSFilip Bozuta     int pll_max;
770373b067fSFilip Bozuta     int pll_min;
771373b067fSFilip Bozuta     int pll_posmult;
772373b067fSFilip Bozuta     int pll_negmult;
773373b067fSFilip Bozuta     abi_long pll_clock;
774373b067fSFilip Bozuta };
775373b067fSFilip Bozuta 
77668365f96SFilip Bozuta /* real time clock ioctls */
77768365f96SFilip Bozuta #define TARGET_RTC_AIE_ON           TARGET_IO('p', 0x01)
77868365f96SFilip Bozuta #define TARGET_RTC_AIE_OFF          TARGET_IO('p', 0x02)
77968365f96SFilip Bozuta #define TARGET_RTC_UIE_ON           TARGET_IO('p', 0x03)
78068365f96SFilip Bozuta #define TARGET_RTC_UIE_OFF          TARGET_IO('p', 0x04)
78168365f96SFilip Bozuta #define TARGET_RTC_PIE_ON           TARGET_IO('p', 0x05)
78268365f96SFilip Bozuta #define TARGET_RTC_PIE_OFF          TARGET_IO('p', 0x06)
78368365f96SFilip Bozuta #define TARGET_RTC_WIE_ON           TARGET_IO('p', 0x0f)
78468365f96SFilip Bozuta #define TARGET_RTC_WIE_OFF          TARGET_IO('p', 0x10)
785178b14a0SFilip Bozuta #define TARGET_RTC_ALM_READ         TARGET_IOR('p', 0x08, struct rtc_time)
786178b14a0SFilip Bozuta #define TARGET_RTC_ALM_SET          TARGET_IOW('p', 0x07, struct rtc_time)
787178b14a0SFilip Bozuta #define TARGET_RTC_RD_TIME          TARGET_IOR('p', 0x09, struct rtc_time)
788178b14a0SFilip Bozuta #define TARGET_RTC_SET_TIME         TARGET_IOW('p', 0x0a, struct rtc_time)
789fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_READ        TARGET_IOR('p', 0x0b, abi_ulong)
790fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_SET         TARGET_IOW('p', 0x0c, abi_ulong)
791fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_READ       TARGET_IOR('p', 0x0d, abi_ulong)
792fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_SET        TARGET_IOW('p', 0x0e, abi_ulong)
793abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_RD         TARGET_IOR('p', 0x10, struct rtc_wkalrm)
794abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_SET        TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
795373b067fSFilip Bozuta #define TARGET_RTC_PLL_GET          TARGET_IOR('p', 0x11,                      \
796373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
797373b067fSFilip Bozuta #define TARGET_RTC_PLL_SET          TARGET_IOW('p', 0x12,                      \
798373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
799a7b09746SFilip Bozuta #define TARGET_RTC_VL_READ          TARGET_IOR('p', 0x13, int)
800a7b09746SFilip Bozuta #define TARGET_RTC_VL_CLR           TARGET_IO('p', 0x14)
80168365f96SFilip Bozuta 
802d14eabbeSAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
803d14eabbeSAleksandar Markovic        defined(TARGET_XTENSA)
8044e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       TARGET_IOR('f', 123, int)
8054e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       TARGET_IOW('f', 124, int)
806e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
807c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
808405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
809e1be1606SAleksandar Markovic #else
8104e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       0x8903
8114e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       0x8901
8122521d698Sbellard #define TARGET_SIOCATMARK      0x8905
813c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       0x8902
814405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
815e1be1606SAleksandar Markovic #endif
816c495a793SAleksandar Markovic 
8176d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SH4)
8186d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   TARGET_IOR('s', 100, struct target_timeval)
8196d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
8206d5d5ddeSDaniel P. Berrangé #else
8216d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   0x8906
8226d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD 0x8907
8236d5d5ddeSDaniel P. Berrangé #endif
8246d5d5ddeSDaniel P. Berrangé 
8256d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_NEW   TARGET_IOR(0x89, 0x06, abi_llong[2])
8266d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
8272521d698Sbellard 
82831e31b8aSbellard /* Networking ioctls */
82931e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
83031e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
83131e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
83231e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
83331e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
83431e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
83531e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
83631e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
83731e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
83831e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
83931e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
84031e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
84131e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
84231e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
84331e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
84431e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
84531e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
84631e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
84731e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
84831e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
84931e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
85031e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
85131e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
85231e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
85331e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
85431e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
85531e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
85631e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
85731e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
858f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
8594bdcd79eSNeng Chen #define TARGET_SIOCSIFPFLAGS   0x8934          /* set extended flags          */
8604bdcd79eSNeng Chen #define TARGET_SIOCGIFPFLAGS   0x8935          /* get extended flags          */
86131e31b8aSbellard 
86231e31b8aSbellard /* Bridging control calls */
86331e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
86431e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
86531e31b8aSbellard 
86631e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
86731e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
86831e31b8aSbellard 
86931e31b8aSbellard /* ARP cache control calls. */
87031e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
87131e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
87231e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
87331e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
87431e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
87531e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
87631e31b8aSbellard 
87731e31b8aSbellard /* RARP cache control calls. */
87831e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
87931e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
88031e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
88131e31b8aSbellard 
88231e31b8aSbellard /* Driver configuration calls */
88331e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
88431e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
88531e31b8aSbellard 
88631e31b8aSbellard /* DLCI configuration calls */
88731e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
88831e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
88931e31b8aSbellard 
89086fcd946SLaurent Vivier /* From <linux/wireless.h> */
89186fcd946SLaurent Vivier 
89286fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
89331e31b8aSbellard 
894d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
895d6d6d6feSMarco A L Barbosa 
896d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
897d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
898d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
899d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
90092c096f0SAleksandar Markovic #define TARGET_RNDRESEEDCRNG   TARGET_IO('R', 0x07)
901d6d6d6feSMarco A L Barbosa 
90231e31b8aSbellard /* From <linux/fs.h> */
90331e31b8aSbellard 
90431e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
90531e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
90631e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
90731e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
90831e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
90931e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
91031e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
91131e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
91231e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
91331e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
91431e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
91531e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
916fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
91731e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
918c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
919c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
920edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
921edafea13SAlexander Graf                                              /* return device size in bytes
922edafea13SAlexander Graf                                                 (u64 *arg) */
9234715856aSPeter Maydell 
9244715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
9254715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
9264715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
9274715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
9284715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
9294715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
9304715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
9314715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
9324715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
9334715856aSPeter Maydell 
934ab22b4ddSYunqiang Su /* From <linux/fd.h> */
935ab22b4ddSYunqiang Su 
9367e35fc8bSAleksandar Markovic #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
9377e35fc8bSAleksandar Markovic #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
93808e3ce59SAleksandar Markovic #define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
93908e3ce59SAleksandar Markovic #define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct format_descr)
94008e3ce59SAleksandar Markovic #define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
94181eb1a36SAleksandar Markovic #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
942ab22b4ddSYunqiang Su #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
94381eb1a36SAleksandar Markovic #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
94481eb1a36SAleksandar Markovic #define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
9455eea9429SAleksandar Markovic #define TARGET_FDRESET        TARGET_IO(2, 0x54)
9465eea9429SAleksandar Markovic #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
9475eea9429SAleksandar Markovic #define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
9485eea9429SAleksandar Markovic #define TARGET_FDEJECT        TARGET_IO(2, 0x5a)
949ab22b4ddSYunqiang Su 
95031e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
95131e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
95221992cb6SHelge Deller 
95321992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
95421992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
95521992cb6SHelge Deller 
9565ae774a9SAleksandar Markovic /*
9575ae774a9SAleksandar Markovic  * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
9585ae774a9SAleksandar Markovic  * claim type "long" but the actual type used by the kernel is "int".
95960807231SPeter Maydell  */
9601847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
9611847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
9625ae774a9SAleksandar Markovic #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
9635ae774a9SAleksandar Markovic #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
964285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
9650b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
9660b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
9670d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
9680d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
96931e31b8aSbellard 
9706c753a63SCortland Tölva /* usb ioctls */
9716c753a63SCortland Tölva #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
9726c753a63SCortland Tölva #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
9736c753a63SCortland Tölva #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
9746c753a63SCortland Tölva #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
9756c753a63SCortland Tölva #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U',  5)
9766c753a63SCortland Tölva #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
977a133367eSCortland Tölva #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
978a133367eSCortland Tölva #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
979a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
980a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
9816c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
9826c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
9836c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
9846c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
9856c753a63SCortland Tölva #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
9866c753a63SCortland Tölva #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
9876c753a63SCortland Tölva #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
9886c753a63SCortland Tölva #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
9896c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
9906c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
9916c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
9926c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
9936c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
9946c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
9956c753a63SCortland Tölva #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
9966c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
9976c753a63SCortland Tölva 
99831e31b8aSbellard /* cdrom commands */
99931e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
100031e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
100131e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
100231e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
100331e31b8aSbellard                                            (struct cdrom_ti) */
100431e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
100531e31b8aSbellard                                            (struct cdrom_tochdr) */
100631e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
100731e31b8aSbellard                                            (struct cdrom_tocentry) */
100831e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
100931e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
101031e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
101131e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
101231e31b8aSbellard                                            (struct cdrom_volctrl) */
101331e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
101431e31b8aSbellard                                            (struct cdrom_subchnl) */
101531e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
101631e31b8aSbellard                                            (struct cdrom_read) */
101731e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
101831e31b8aSbellard                                            (struct cdrom_read) */
101931e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
102031e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
102131e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
102231e31b8aSbellard                                            address of multi session disks
102331e31b8aSbellard                                            (struct cdrom_multisession) */
102431e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
102531e31b8aSbellard                                            if available (struct cdrom_mcn) */
102667cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
1027b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
102831e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
102931e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
103031e31b8aSbellard                                           (struct cdrom_volctrl) */
103131e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
103231e31b8aSbellard                                            (struct cdrom_read) */
103331e31b8aSbellard /*
103431e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
103531e31b8aSbellard  */
103631e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
103731e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
103831e31b8aSbellard 
103931e31b8aSbellard /*
104031e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
104131e31b8aSbellard    It is for playing audio in logical block addressing mode.
104231e31b8aSbellard  */
104331e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
104431e31b8aSbellard 
104531e31b8aSbellard /*
104631e31b8aSbellard  * These ioctls are only used in optcd.c
104731e31b8aSbellard  */
104831e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
104931e31b8aSbellard 
105031e31b8aSbellard /*
105131e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
105231e31b8aSbellard  * drive spindown time.  They should be implemented in the
105331e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
105431e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
105531e31b8aSbellard  *  -Erik
105631e31b8aSbellard  */
105731e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
105831e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
105931e31b8aSbellard 
106031e31b8aSbellard /*
106131e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
106231e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
106331e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
106431e31b8aSbellard  */
106531e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
106631e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
106731e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
106831e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
106931e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
107031e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
107131e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
107231e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
107331e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
107431e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
107531e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
107631e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
107731e31b8aSbellard 
107831e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
107931e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
108031e31b8aSbellard  */
108131e31b8aSbellard 
108231e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
108331e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
108431e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
108531e31b8aSbellard 
108631e31b8aSbellard /* DVD-ROM Specific ioctls */
108731e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
108831e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
108931e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
109031e31b8aSbellard 
109131e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
109231e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
109331e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
109431e31b8aSbellard 
109531e31b8aSbellard /* HD commands */
109631e31b8aSbellard 
109731e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
109831e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
109931e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
110031e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
110131e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
110231e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
110331e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
110431e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
11052521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
110631e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
110731e31b8aSbellard 
110831e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
110931e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
111031e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
111131e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
111231e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
111331e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
111431e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
111531e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
11162521d698Sbellard 
1117b8005914Sbalrog /* loop ioctls */
1118b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1119b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1120b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1121b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1122b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1123b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1124b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
11252521d698Sbellard 
1126884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1127884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1128884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1129884cdc48SPeter Maydell 
1130f7680a55SUlrich Hecht /* fb ioctls */
1131f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1132f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1133f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
113412b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
113512b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
113612b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
113712b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
113812b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1139f7680a55SUlrich Hecht 
1140f7680a55SUlrich Hecht /* vt ioctls */
1141f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1142f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1143f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1144f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1145f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1146f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1147774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1148774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1149774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1150774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1151f7680a55SUlrich Hecht 
115256e904ecSAlexander Graf /* device mapper */
115356e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
115456e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
115556e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
115656e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
115756e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
115856e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
115956e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
116056e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
116156e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
116256e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
116356e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
116456e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
116556e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
116656e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
116756e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
116856e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
116956e904ecSAlexander Graf 
11702521d698Sbellard /* from asm/termbits.h */
11712521d698Sbellard 
11723bfd9da1Sbellard #define TARGET_NCC 8
11733bfd9da1Sbellard struct target_termio {
11743bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
11753bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
11763bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
11773bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
11782521d698Sbellard 	unsigned char c_line;		/* line discipline */
11793bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
11802521d698Sbellard };
11812521d698Sbellard 
11823bfd9da1Sbellard struct target_winsize {
11833bfd9da1Sbellard 	unsigned short ws_row;
11843bfd9da1Sbellard 	unsigned short ws_col;
11853bfd9da1Sbellard 	unsigned short ws_xpixel;
11863bfd9da1Sbellard 	unsigned short ws_ypixel;
11873bfd9da1Sbellard };
11882521d698Sbellard 
11893bfd9da1Sbellard #include "termbits.h"
11902521d698Sbellard 
11919e0b74a4SPaul Brook #if defined(TARGET_MIPS)
11929e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
11939e0b74a4SPaul Brook #else
11949e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
11959e0b74a4SPaul Brook #endif
11969e0b74a4SPaul Brook 
1197e44a3e79Saurel32 /* Common */
11982521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
11992521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1200e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1201e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1202e65be6a7SHelge Deller #else
12032521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1204e65be6a7SHelge Deller #endif
1205e44a3e79Saurel32 
1206e44a3e79Saurel32 /* Target specific */
1207048f6b4dSbellard #if defined(TARGET_MIPS)
1208e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1209048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1210048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1211048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1212048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1213048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1214048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1215540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1216540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1217541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1218541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1219e44a3e79Saurel32 #elif defined(TARGET_PPC)
1220e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
12212521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
12222521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
12232521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
12242521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
12257ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
12267ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1227e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1228e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1229541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1230541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1231e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1232e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1233e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1234e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1235e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1236e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1237e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1238e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1239e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1240e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1241541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1242541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1243a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1244a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1245a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1246a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1247a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1248a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1249a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1250a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1251a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1252a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1253541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1254541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1255ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1256ba7651fbSMax Filippov #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1257ba7651fbSMax Filippov #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1258ba7651fbSMax Filippov #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1259ba7651fbSMax Filippov #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1260ba7651fbSMax Filippov #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1261ba7651fbSMax Filippov #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1262ba7651fbSMax Filippov #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1263ba7651fbSMax Filippov #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1264ba7651fbSMax Filippov #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1265ba7651fbSMax Filippov #define TARGET_MAP_STACK	0x40000
1266ba7651fbSMax Filippov #define TARGET_MAP_HUGETLB  0x80000         /* create a huge page mapping */
12677ec93196Sj_mayer #else
1268e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1269e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1270e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1271e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1272e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
12732521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
12742521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1275540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1276540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1277541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1278541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1279906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
12807ec93196Sj_mayer #endif
12812521d698Sbellard 
128209701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
128309701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1284daa4374aSPeter Maydell     || defined(TARGET_CRIS)
12855f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
12862521d698Sbellard struct target_stat {
12872521d698Sbellard 	unsigned short st_dev;
12882521d698Sbellard 	unsigned short __pad1;
1289992f48a0Sblueswir1 	abi_ulong st_ino;
12902521d698Sbellard 	unsigned short st_mode;
12912521d698Sbellard 	unsigned short st_nlink;
12922521d698Sbellard 	unsigned short st_uid;
12932521d698Sbellard 	unsigned short st_gid;
12942521d698Sbellard 	unsigned short st_rdev;
12952521d698Sbellard 	unsigned short __pad2;
1296992f48a0Sblueswir1 	abi_ulong  st_size;
1297992f48a0Sblueswir1 	abi_ulong  st_blksize;
1298992f48a0Sblueswir1 	abi_ulong  st_blocks;
1299992f48a0Sblueswir1 	abi_ulong  target_st_atime;
13005f992db6SChen-Yu Tsai 	abi_ulong  target_st_atime_nsec;
1301992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
13025f992db6SChen-Yu Tsai 	abi_ulong  target_st_mtime_nsec;
1303992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
13045f992db6SChen-Yu Tsai 	abi_ulong  target_st_ctime_nsec;
1305992f48a0Sblueswir1 	abi_ulong  __unused4;
1306992f48a0Sblueswir1 	abi_ulong  __unused5;
13072521d698Sbellard };
13082521d698Sbellard 
13092521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
13102521d698Sbellard  * insane amounts of padding around dev_t's.
13112521d698Sbellard  */
131220d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13132521d698Sbellard struct target_stat64 {
13142521d698Sbellard 	unsigned short	st_dev;
13152521d698Sbellard 	unsigned char	__pad0[10];
13162521d698Sbellard 
13172521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1318992f48a0Sblueswir1 	abi_ulong	__st_ino;
13192521d698Sbellard 
13202521d698Sbellard 	unsigned int	st_mode;
13212521d698Sbellard 	unsigned int	st_nlink;
13222521d698Sbellard 
1323992f48a0Sblueswir1 	abi_ulong	st_uid;
1324992f48a0Sblueswir1 	abi_ulong	st_gid;
13252521d698Sbellard 
13262521d698Sbellard 	unsigned short	st_rdev;
13272521d698Sbellard 	unsigned char	__pad3[10];
13282521d698Sbellard 
13292521d698Sbellard 	long long	st_size;
1330992f48a0Sblueswir1 	abi_ulong	st_blksize;
13312521d698Sbellard 
1332992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1333992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
13342521d698Sbellard 
1335992f48a0Sblueswir1 	abi_ulong	target_st_atime;
13365f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
13372521d698Sbellard 
1338992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
13395f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
13402521d698Sbellard 
1341992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
13425f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
13432521d698Sbellard 
13442521d698Sbellard 	unsigned long long	st_ino;
1345541dc0d4SStefan Weil } QEMU_PACKED;
13462521d698Sbellard 
1347ce4defa0Spbrook #ifdef TARGET_ARM
134820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1349ce4defa0Spbrook struct target_eabi_stat64 {
1350ce4defa0Spbrook         unsigned long long st_dev;
1351ce4defa0Spbrook         unsigned int    __pad1;
1352992f48a0Sblueswir1         abi_ulong    __st_ino;
1353ce4defa0Spbrook         unsigned int    st_mode;
1354ce4defa0Spbrook         unsigned int    st_nlink;
1355ce4defa0Spbrook 
1356992f48a0Sblueswir1         abi_ulong    st_uid;
1357992f48a0Sblueswir1         abi_ulong    st_gid;
1358ce4defa0Spbrook 
1359ce4defa0Spbrook         unsigned long long st_rdev;
1360ce4defa0Spbrook         unsigned int    __pad2[2];
1361ce4defa0Spbrook 
1362ce4defa0Spbrook         long long       st_size;
1363992f48a0Sblueswir1         abi_ulong    st_blksize;
1364ce4defa0Spbrook         unsigned int    __pad3;
1365ce4defa0Spbrook         unsigned long long st_blocks;
1366ce4defa0Spbrook 
1367992f48a0Sblueswir1         abi_ulong    target_st_atime;
1368992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1369ce4defa0Spbrook 
1370992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1371992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1372ce4defa0Spbrook 
1373992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1374992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1375ce4defa0Spbrook 
1376ce4defa0Spbrook         unsigned long long st_ino;
1377541dc0d4SStefan Weil } QEMU_PACKED;
1378ce4defa0Spbrook #endif
1379ce4defa0Spbrook 
1380992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
13811b8dd648Sblueswir1 struct target_stat {
13821b8dd648Sblueswir1 	unsigned int	st_dev;
1383992f48a0Sblueswir1 	abi_ulong	st_ino;
13841b8dd648Sblueswir1 	unsigned int	st_mode;
13851b8dd648Sblueswir1 	unsigned int	st_nlink;
13861b8dd648Sblueswir1 	unsigned int	st_uid;
13871b8dd648Sblueswir1 	unsigned int	st_gid;
13881b8dd648Sblueswir1 	unsigned int	st_rdev;
1389992f48a0Sblueswir1 	abi_long	st_size;
1390992f48a0Sblueswir1 	abi_long	target_st_atime;
1391992f48a0Sblueswir1 	abi_long	target_st_mtime;
1392992f48a0Sblueswir1 	abi_long	target_st_ctime;
1393992f48a0Sblueswir1 	abi_long	st_blksize;
1394992f48a0Sblueswir1 	abi_long	st_blocks;
1395992f48a0Sblueswir1 	abi_ulong	__unused4[2];
13961b8dd648Sblueswir1 };
13971b8dd648Sblueswir1 
139820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13991b8dd648Sblueswir1 struct target_stat64 {
14001b8dd648Sblueswir1 	unsigned char	__pad0[6];
14011b8dd648Sblueswir1 	unsigned short	st_dev;
14021b8dd648Sblueswir1 
14031b8dd648Sblueswir1 	uint64_t	st_ino;
14041b8dd648Sblueswir1 	uint64_t	st_nlink;
14051b8dd648Sblueswir1 
14061b8dd648Sblueswir1 	unsigned int	st_mode;
14071b8dd648Sblueswir1 
14081b8dd648Sblueswir1 	unsigned int	st_uid;
14091b8dd648Sblueswir1 	unsigned int	st_gid;
14101b8dd648Sblueswir1 
14111b8dd648Sblueswir1 	unsigned char	__pad2[6];
14121b8dd648Sblueswir1 	unsigned short	st_rdev;
14131b8dd648Sblueswir1 
14141b8dd648Sblueswir1         int64_t		st_size;
14151b8dd648Sblueswir1 	int64_t		st_blksize;
14161b8dd648Sblueswir1 
14171b8dd648Sblueswir1 	unsigned char	__pad4[4];
14181b8dd648Sblueswir1 	unsigned int	st_blocks;
14191b8dd648Sblueswir1 
1420992f48a0Sblueswir1 	abi_ulong	target_st_atime;
14215f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
14221b8dd648Sblueswir1 
1423992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
14245f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
14251b8dd648Sblueswir1 
1426992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
14275f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
14281b8dd648Sblueswir1 
1429992f48a0Sblueswir1 	abi_ulong	__unused4[3];
14301b8dd648Sblueswir1 };
14311b8dd648Sblueswir1 
14323bfd9da1Sbellard #elif defined(TARGET_SPARC)
14333bfd9da1Sbellard 
14345f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
14353bfd9da1Sbellard struct target_stat {
14363bfd9da1Sbellard 	unsigned short	st_dev;
1437992f48a0Sblueswir1 	abi_ulong	st_ino;
14383bfd9da1Sbellard 	unsigned short	st_mode;
14393bfd9da1Sbellard 	short		st_nlink;
14403bfd9da1Sbellard 	unsigned short	st_uid;
14413bfd9da1Sbellard 	unsigned short	st_gid;
14423bfd9da1Sbellard 	unsigned short	st_rdev;
1443992f48a0Sblueswir1 	abi_long	st_size;
1444992f48a0Sblueswir1 	abi_long	target_st_atime;
14455f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
1446992f48a0Sblueswir1 	abi_long	target_st_mtime;
14475f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
1448992f48a0Sblueswir1 	abi_long	target_st_ctime;
14495f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
1450992f48a0Sblueswir1 	abi_long	st_blksize;
1451992f48a0Sblueswir1 	abi_long	st_blocks;
14525f992db6SChen-Yu Tsai 	abi_ulong	__unused1[2];
14533bfd9da1Sbellard };
14543bfd9da1Sbellard 
145520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14563bfd9da1Sbellard struct target_stat64 {
14573bfd9da1Sbellard 	unsigned char	__pad0[6];
14583bfd9da1Sbellard 	unsigned short	st_dev;
14593bfd9da1Sbellard 
14603bfd9da1Sbellard 	uint64_t st_ino;
14613bfd9da1Sbellard 
14623bfd9da1Sbellard 	unsigned int	st_mode;
14633bfd9da1Sbellard 	unsigned int	st_nlink;
14643bfd9da1Sbellard 
14653bfd9da1Sbellard 	unsigned int	st_uid;
14663bfd9da1Sbellard 	unsigned int	st_gid;
14673bfd9da1Sbellard 
14683bfd9da1Sbellard 	unsigned char	__pad2[6];
14693bfd9da1Sbellard 	unsigned short	st_rdev;
14703bfd9da1Sbellard 
14713bfd9da1Sbellard 	unsigned char	__pad3[8];
14723bfd9da1Sbellard 
14733bfd9da1Sbellard         int64_t	st_size;
14743bfd9da1Sbellard 	unsigned int	st_blksize;
14753bfd9da1Sbellard 
14763bfd9da1Sbellard 	unsigned char	__pad4[8];
14773bfd9da1Sbellard 	unsigned int	st_blocks;
14783bfd9da1Sbellard 
14793bfd9da1Sbellard 	unsigned int	target_st_atime;
14805f992db6SChen-Yu Tsai 	unsigned int	target_st_atime_nsec;
14813bfd9da1Sbellard 
14823bfd9da1Sbellard 	unsigned int	target_st_mtime;
14835f992db6SChen-Yu Tsai 	unsigned int	target_st_mtime_nsec;
14843bfd9da1Sbellard 
14853bfd9da1Sbellard 	unsigned int	target_st_ctime;
14865f992db6SChen-Yu Tsai 	unsigned int	target_st_ctime_nsec;
14873bfd9da1Sbellard 
14885f992db6SChen-Yu Tsai 	unsigned int	__unused1;
14895f992db6SChen-Yu Tsai 	unsigned int	__unused2;
14903bfd9da1Sbellard };
14913bfd9da1Sbellard 
149267867308Sbellard #elif defined(TARGET_PPC)
149367867308Sbellard 
14945f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
149567867308Sbellard struct target_stat {
1496e32448e0Sj_mayer 	abi_ulong st_dev;
1497992f48a0Sblueswir1 	abi_ulong st_ino;
1498325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1499e32448e0Sj_mayer 	abi_ulong st_nlink;
1500325e651fSj_mayer 	unsigned int st_mode;
1501325e651fSj_mayer #else
150267867308Sbellard 	unsigned int st_mode;
150367867308Sbellard 	unsigned short st_nlink;
1504325e651fSj_mayer #endif
150567867308Sbellard 	unsigned int st_uid;
150667867308Sbellard 	unsigned int st_gid;
1507e32448e0Sj_mayer 	abi_ulong  st_rdev;
1508992f48a0Sblueswir1 	abi_ulong  st_size;
1509992f48a0Sblueswir1 	abi_ulong  st_blksize;
1510992f48a0Sblueswir1 	abi_ulong  st_blocks;
1511992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1512e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1513992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1514e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1515992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1516e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1517992f48a0Sblueswir1 	abi_ulong  __unused4;
1518992f48a0Sblueswir1 	abi_ulong  __unused5;
1519325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1520325e651fSj_mayer 	abi_ulong  __unused6;
1521325e651fSj_mayer #endif
152267867308Sbellard };
152367867308Sbellard 
152420d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
152520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1526541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
152767867308Sbellard 	unsigned long long st_dev;
152867867308Sbellard         unsigned long long st_ino;
152967867308Sbellard 	unsigned int st_mode;
153067867308Sbellard 	unsigned int st_nlink;
153167867308Sbellard 	unsigned int st_uid;
153267867308Sbellard 	unsigned int st_gid;
153367867308Sbellard 	unsigned long long st_rdev;
1534e1ce5e40Saurel32 	unsigned long long __pad0;
153567867308Sbellard 	long long      st_size;
1536e32448e0Sj_mayer 	int	       st_blksize;
1537e1ce5e40Saurel32 	unsigned int   __pad1;
153861322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1539e32448e0Sj_mayer 	int	       target_st_atime;
1540e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1541e32448e0Sj_mayer 	int	       target_st_mtime;
1542e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1543e32448e0Sj_mayer 	int            target_st_ctime;
1544e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1545e32448e0Sj_mayer         unsigned int   __unused4;
1546e32448e0Sj_mayer         unsigned int   __unused5;
154767867308Sbellard };
154820d155bcSStefan Weil #endif
154967867308Sbellard 
1550b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1551b779e29eSEdgar E. Iglesias 
15525f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1553b779e29eSEdgar E. Iglesias struct target_stat {
1554b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1555b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1556b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1557b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1558b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1559b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1560b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1561b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1562b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1563b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1564b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1565b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1566b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1567b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1568b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1569b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1570b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1571b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1572b779e29eSEdgar E. Iglesias };
1573b779e29eSEdgar E. Iglesias 
1574b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
157520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1576541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1577b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1578a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1579a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1580a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1581a523eb06SEdgar E. Iglesias 
1582b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1583b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1584b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1585b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1586b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
158721ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1588b779e29eSEdgar E. Iglesias 
1589b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1590b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
159121ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1592b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1593b779e29eSEdgar E. Iglesias 
1594b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1595b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1596b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1597b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1598b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1599b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1600a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1601b779e29eSEdgar E. Iglesias };
1602b779e29eSEdgar E. Iglesias 
1603e6e5906bSpbrook #elif defined(TARGET_M68K)
1604e6e5906bSpbrook 
1605e6e5906bSpbrook struct target_stat {
1606e6e5906bSpbrook 	unsigned short st_dev;
1607e6e5906bSpbrook 	unsigned short __pad1;
1608992f48a0Sblueswir1 	abi_ulong st_ino;
1609e6e5906bSpbrook 	unsigned short st_mode;
1610e6e5906bSpbrook 	unsigned short st_nlink;
1611e6e5906bSpbrook 	unsigned short st_uid;
1612e6e5906bSpbrook 	unsigned short st_gid;
1613e6e5906bSpbrook 	unsigned short st_rdev;
1614e6e5906bSpbrook 	unsigned short __pad2;
1615992f48a0Sblueswir1 	abi_ulong  st_size;
1616992f48a0Sblueswir1 	abi_ulong  st_blksize;
1617992f48a0Sblueswir1 	abi_ulong  st_blocks;
1618992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1619992f48a0Sblueswir1 	abi_ulong  __unused1;
1620992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1621992f48a0Sblueswir1 	abi_ulong  __unused2;
1622992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1623992f48a0Sblueswir1 	abi_ulong  __unused3;
1624992f48a0Sblueswir1 	abi_ulong  __unused4;
1625992f48a0Sblueswir1 	abi_ulong  __unused5;
1626e6e5906bSpbrook };
1627e6e5906bSpbrook 
1628e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1629e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1630e6e5906bSpbrook  */
163120d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1632e6e5906bSpbrook struct target_stat64 {
1633e6e5906bSpbrook 	unsigned long long	st_dev;
1634e6e5906bSpbrook 	unsigned char	__pad1[2];
1635e6e5906bSpbrook 
1636e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1637992f48a0Sblueswir1 	abi_ulong	__st_ino;
1638e6e5906bSpbrook 
1639e6e5906bSpbrook 	unsigned int	st_mode;
1640e6e5906bSpbrook 	unsigned int	st_nlink;
1641e6e5906bSpbrook 
1642992f48a0Sblueswir1 	abi_ulong	st_uid;
1643992f48a0Sblueswir1 	abi_ulong	st_gid;
1644e6e5906bSpbrook 
1645e6e5906bSpbrook 	unsigned long long	st_rdev;
1646e6e5906bSpbrook 	unsigned char	__pad3[2];
1647e6e5906bSpbrook 
1648e6e5906bSpbrook 	long long	st_size;
1649992f48a0Sblueswir1 	abi_ulong	st_blksize;
1650e6e5906bSpbrook 
1651992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1652992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1653e6e5906bSpbrook 
1654992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1655992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1656e6e5906bSpbrook 
1657992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1658992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1659e6e5906bSpbrook 
1660992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1661992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1662e6e5906bSpbrook 
1663e6e5906bSpbrook 	unsigned long long	st_ino;
1664541dc0d4SStefan Weil } QEMU_PACKED;
1665e6e5906bSpbrook 
1666d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1667540635baSths 
16685f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1669540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1670540635baSths struct target_stat {
1671540635baSths 	unsigned int		st_dev;
1672540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1673540635baSths 
1674992f48a0Sblueswir1 	abi_ulong		st_ino;
1675540635baSths 
1676540635baSths 	unsigned int		st_mode;
1677540635baSths 	unsigned int		st_nlink;
1678540635baSths 
1679540635baSths 	int			st_uid;
1680540635baSths 	int			st_gid;
1681540635baSths 
1682540635baSths 	unsigned int		st_rdev;
1683540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1684540635baSths 
1685992f48a0Sblueswir1 	abi_ulong		st_size;
1686540635baSths 
1687540635baSths 	/*
1688540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1689540635baSths 	 * but we don't have it under Linux.
1690540635baSths 	 */
1691540635baSths 	unsigned int		target_st_atime;
1692540635baSths 	unsigned int		target_st_atime_nsec;
1693540635baSths 
1694540635baSths 	unsigned int		target_st_mtime;
1695540635baSths 	unsigned int		target_st_mtime_nsec;
1696540635baSths 
1697540635baSths 	unsigned int		target_st_ctime;
1698540635baSths 	unsigned int		target_st_ctime_nsec;
1699540635baSths 
1700540635baSths 	unsigned int		st_blksize;
1701540635baSths 	unsigned int		st_pad2;
1702540635baSths 
1703992f48a0Sblueswir1 	abi_ulong		st_blocks;
1704540635baSths };
1705540635baSths 
1706d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1707540635baSths 
17085f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1709540635baSths struct target_stat {
17101ab2aea2SLeon Alrae         abi_ulong    st_dev;
17111ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
17121ab2aea2SLeon Alrae         uint64_t     st_ino;
1713540635baSths         unsigned int st_mode;
1714540635baSths         unsigned int st_nlink;
1715540635baSths         int          st_uid;
1716540635baSths         int          st_gid;
17171ab2aea2SLeon Alrae         abi_ulong    st_rdev;
17181ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
17191ab2aea2SLeon Alrae         int64_t      st_size;
17201ab2aea2SLeon Alrae         abi_long     target_st_atime;
17211ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
17221ab2aea2SLeon Alrae         abi_long     target_st_mtime;
17231ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
17241ab2aea2SLeon Alrae         abi_long     target_st_ctime;
17251ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
17261ab2aea2SLeon Alrae         abi_ulong    st_blksize;
17271ab2aea2SLeon Alrae         abi_ulong    st_pad2;
17281ab2aea2SLeon Alrae         int64_t      st_blocks;
1729540635baSths };
1730540635baSths 
1731d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1732048f6b4dSbellard 
17335f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1734048f6b4dSbellard struct target_stat {
1735048f6b4dSbellard 	unsigned	st_dev;
1736992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1737992f48a0Sblueswir1 	abi_ulong	st_ino;
1738048f6b4dSbellard 	unsigned int	st_mode;
1739048f6b4dSbellard 	unsigned int	st_nlink;
1740048f6b4dSbellard 	int		st_uid;
1741048f6b4dSbellard 	int		st_gid;
1742048f6b4dSbellard 	unsigned 	st_rdev;
1743992f48a0Sblueswir1 	abi_long	st_pad2[2];
1744992f48a0Sblueswir1 	abi_long	st_size;
1745992f48a0Sblueswir1 	abi_long	st_pad3;
1746048f6b4dSbellard 	/*
1747048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1748048f6b4dSbellard 	 * but we don't have it under Linux.
1749048f6b4dSbellard 	 */
1750992f48a0Sblueswir1 	abi_long		target_st_atime;
1751992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1752992f48a0Sblueswir1 	abi_long		target_st_mtime;
1753992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1754992f48a0Sblueswir1 	abi_long		target_st_ctime;
1755992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1756992f48a0Sblueswir1 	abi_long		st_blksize;
1757992f48a0Sblueswir1 	abi_long		st_blocks;
1758992f48a0Sblueswir1 	abi_long		st_pad4[14];
1759048f6b4dSbellard };
1760048f6b4dSbellard 
1761048f6b4dSbellard /*
1762048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1763048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1764048f6b4dSbellard  * struct stat of the 64-bit kernel.
1765048f6b4dSbellard  */
1766048f6b4dSbellard 
176720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1768048f6b4dSbellard struct target_stat64 {
1769992f48a0Sblueswir1 	abi_ulong	st_dev;
1770992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1771048f6b4dSbellard 
1772048f6b4dSbellard 	uint64_t	st_ino;
1773048f6b4dSbellard 
1774048f6b4dSbellard         unsigned int	st_mode;
1775048f6b4dSbellard         unsigned int	st_nlink;
1776048f6b4dSbellard 
1777048f6b4dSbellard 	int		st_uid;
1778048f6b4dSbellard 	int		st_gid;
1779048f6b4dSbellard 
1780992f48a0Sblueswir1 	abi_ulong	st_rdev;
1781992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1782048f6b4dSbellard 
1783048f6b4dSbellard 	int64_t 	st_size;
1784048f6b4dSbellard 
1785048f6b4dSbellard 	/*
1786048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1787048f6b4dSbellard 	 * but we don't have it under Linux.
1788048f6b4dSbellard 	 */
1789992f48a0Sblueswir1 	abi_long	target_st_atime;
1790992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1791048f6b4dSbellard 
1792992f48a0Sblueswir1 	abi_long	target_st_mtime;
1793992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1794048f6b4dSbellard 
1795992f48a0Sblueswir1 	abi_long	target_st_ctime;
1796992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1797048f6b4dSbellard 
1798992f48a0Sblueswir1 	abi_ulong	st_blksize;
1799992f48a0Sblueswir1 	abi_ulong	st_pad2;
1800048f6b4dSbellard 
1801048f6b4dSbellard 	int64_t  	st_blocks;
1802048f6b4dSbellard };
18037a3148a9Sj_mayer 
18047a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
18057a3148a9Sj_mayer 
18067a3148a9Sj_mayer struct target_stat {
18077a3148a9Sj_mayer        unsigned int    st_dev;
18087a3148a9Sj_mayer        unsigned int    st_ino;
18097a3148a9Sj_mayer        unsigned int    st_mode;
18107a3148a9Sj_mayer        unsigned int    st_nlink;
18117a3148a9Sj_mayer        unsigned int    st_uid;
18127a3148a9Sj_mayer        unsigned int    st_gid;
18137a3148a9Sj_mayer        unsigned int    st_rdev;
1814992f48a0Sblueswir1        abi_long     st_size;
1815992f48a0Sblueswir1        abi_ulong    target_st_atime;
1816992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1817992f48a0Sblueswir1        abi_ulong    target_st_ctime;
18187a3148a9Sj_mayer        unsigned int    st_blksize;
18197a3148a9Sj_mayer        unsigned int    st_blocks;
18207a3148a9Sj_mayer        unsigned int    st_flags;
18217a3148a9Sj_mayer        unsigned int    st_gen;
18227a3148a9Sj_mayer };
18237a3148a9Sj_mayer 
182420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
18257a3148a9Sj_mayer struct target_stat64 {
1826992f48a0Sblueswir1        abi_ulong    st_dev;
1827992f48a0Sblueswir1        abi_ulong    st_ino;
1828992f48a0Sblueswir1        abi_ulong    st_rdev;
1829992f48a0Sblueswir1        abi_long     st_size;
1830992f48a0Sblueswir1        abi_ulong    st_blocks;
18317a3148a9Sj_mayer 
18327a3148a9Sj_mayer        unsigned int    st_mode;
18337a3148a9Sj_mayer        unsigned int    st_uid;
18347a3148a9Sj_mayer        unsigned int    st_gid;
18357a3148a9Sj_mayer        unsigned int    st_blksize;
18367a3148a9Sj_mayer        unsigned int    st_nlink;
18377a3148a9Sj_mayer        unsigned int    __pad0;
18387a3148a9Sj_mayer 
1839992f48a0Sblueswir1        abi_ulong    target_st_atime;
1840992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1841992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1842992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1843992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1844992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1845992f48a0Sblueswir1        abi_long     __unused[3];
18467a3148a9Sj_mayer };
18477a3148a9Sj_mayer 
18486db45e65Sths #elif defined(TARGET_SH4)
18496db45e65Sths 
18505f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
18516db45e65Sths struct target_stat {
1852992f48a0Sblueswir1 	abi_ulong  st_dev;
1853992f48a0Sblueswir1 	abi_ulong  st_ino;
18546db45e65Sths 	unsigned short st_mode;
18556db45e65Sths 	unsigned short st_nlink;
18566db45e65Sths 	unsigned short st_uid;
18576db45e65Sths 	unsigned short st_gid;
1858992f48a0Sblueswir1 	abi_ulong  st_rdev;
1859992f48a0Sblueswir1 	abi_ulong  st_size;
1860992f48a0Sblueswir1 	abi_ulong  st_blksize;
1861992f48a0Sblueswir1 	abi_ulong  st_blocks;
1862992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1863992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1864992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1865992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1866992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1867992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1868992f48a0Sblueswir1 	abi_ulong  __unused4;
1869992f48a0Sblueswir1 	abi_ulong  __unused5;
18706db45e65Sths };
18716db45e65Sths 
18726db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
18736db45e65Sths  * insane amounts of padding around dev_t's.
18746db45e65Sths  */
187520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1876541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
18776db45e65Sths 	unsigned long long	st_dev;
18786db45e65Sths 	unsigned char	__pad0[4];
18796db45e65Sths 
18806db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1881992f48a0Sblueswir1 	abi_ulong	__st_ino;
18826db45e65Sths 
18836db45e65Sths 	unsigned int	st_mode;
18846db45e65Sths 	unsigned int	st_nlink;
18856db45e65Sths 
1886992f48a0Sblueswir1 	abi_ulong	st_uid;
1887992f48a0Sblueswir1 	abi_ulong	st_gid;
18886db45e65Sths 
18896db45e65Sths 	unsigned long long	st_rdev;
18906db45e65Sths 	unsigned char	__pad3[4];
18916db45e65Sths 
18926db45e65Sths 	long long	st_size;
1893992f48a0Sblueswir1 	abi_ulong	st_blksize;
18946db45e65Sths 
18956db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
18966db45e65Sths 
1897992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1898992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
18996db45e65Sths 
1900992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1901992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
19026db45e65Sths 
1903992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1904992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
19056db45e65Sths 
19066db45e65Sths 	unsigned long long	st_ino;
19076db45e65Sths };
19086db45e65Sths 
1909d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
19105f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1911d2fd1af7Sbellard struct target_stat {
1912d2fd1af7Sbellard 	abi_ulong	st_dev;
1913d2fd1af7Sbellard 	abi_ulong	st_ino;
1914d2fd1af7Sbellard 	abi_ulong	st_nlink;
1915d2fd1af7Sbellard 
1916d2fd1af7Sbellard 	unsigned int	st_mode;
1917d2fd1af7Sbellard 	unsigned int	st_uid;
1918d2fd1af7Sbellard 	unsigned int	st_gid;
1919d2fd1af7Sbellard 	unsigned int	__pad0;
1920d2fd1af7Sbellard 	abi_ulong	st_rdev;
1921d2fd1af7Sbellard 	abi_long	st_size;
1922d2fd1af7Sbellard 	abi_long	st_blksize;
1923d2fd1af7Sbellard 	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1924d2fd1af7Sbellard 
1925d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1926d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1927d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1928d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1929d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1930d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1931d2fd1af7Sbellard 
1932d2fd1af7Sbellard 	abi_long	__unused[3];
1933d2fd1af7Sbellard };
1934a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1935a4c075f1SUlrich Hecht struct target_stat {
1936a4c075f1SUlrich Hecht     abi_ulong  st_dev;
1937a4c075f1SUlrich Hecht     abi_ulong  st_ino;
1938a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
1939a4c075f1SUlrich Hecht     unsigned int   st_mode;
1940a4c075f1SUlrich Hecht     unsigned int   st_uid;
1941a4c075f1SUlrich Hecht     unsigned int   st_gid;
1942a4c075f1SUlrich Hecht     unsigned int   __pad1;
1943a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
1944a4c075f1SUlrich Hecht     abi_ulong  st_size;
1945a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
1946a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
1947a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
1948a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
1949a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
1950a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
1951a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
1952a4c075f1SUlrich Hecht     abi_long       st_blocks;
1953a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
1954a4c075f1SUlrich Hecht };
195509701199SAlexander Graf #elif defined(TARGET_AARCH64)
19565f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
195709701199SAlexander Graf struct target_stat {
195809701199SAlexander Graf     abi_ulong  st_dev;
195909701199SAlexander Graf     abi_ulong  st_ino;
196009701199SAlexander Graf     unsigned int st_mode;
196109701199SAlexander Graf     unsigned int st_nlink;
196209701199SAlexander Graf     unsigned int   st_uid;
196309701199SAlexander Graf     unsigned int   st_gid;
196409701199SAlexander Graf     abi_ulong  st_rdev;
196509701199SAlexander Graf     abi_ulong  _pad1;
196609701199SAlexander Graf     abi_long  st_size;
196709701199SAlexander Graf     int        st_blksize;
196809701199SAlexander Graf     int        __pad2;
196909701199SAlexander Graf     abi_long   st_blocks;
197009701199SAlexander Graf     abi_long  target_st_atime;
197109701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
197209701199SAlexander Graf     abi_long  target_st_mtime;
197309701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
197409701199SAlexander Graf     abi_long  target_st_ctime;
197509701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
197609701199SAlexander Graf     unsigned int __unused[2];
197709701199SAlexander Graf };
1978ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
19795f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1980ba7651fbSMax Filippov struct target_stat {
1981ba7651fbSMax Filippov     abi_ulong       st_dev;
1982ba7651fbSMax Filippov     abi_ulong       st_ino;
1983ba7651fbSMax Filippov     unsigned int    st_mode;
1984ba7651fbSMax Filippov     unsigned int    st_nlink;
1985ba7651fbSMax Filippov     unsigned int    st_uid;
1986ba7651fbSMax Filippov     unsigned int    st_gid;
1987ba7651fbSMax Filippov     abi_ulong       st_rdev;
1988ba7651fbSMax Filippov     abi_long        st_size;
1989ba7651fbSMax Filippov     abi_ulong       st_blksize;
1990ba7651fbSMax Filippov     abi_ulong       st_blocks;
1991ba7651fbSMax Filippov     abi_ulong       target_st_atime;
1992ba7651fbSMax Filippov     abi_ulong       target_st_atime_nsec;
1993ba7651fbSMax Filippov     abi_ulong       target_st_mtime;
1994ba7651fbSMax Filippov     abi_ulong       target_st_mtime_nsec;
1995ba7651fbSMax Filippov     abi_ulong       target_st_ctime;
1996ba7651fbSMax Filippov     abi_ulong       target_st_ctime_nsec;
1997ba7651fbSMax Filippov     abi_ulong       __unused4;
1998ba7651fbSMax Filippov     abi_ulong       __unused5;
1999ba7651fbSMax Filippov };
2000ba7651fbSMax Filippov 
2001ba7651fbSMax Filippov #define TARGET_HAS_STRUCT_STAT64
2002ba7651fbSMax Filippov struct target_stat64  {
2003ba7651fbSMax Filippov     uint64_t st_dev;            /* Device */
2004ba7651fbSMax Filippov     uint64_t st_ino;            /* File serial number */
2005ba7651fbSMax Filippov     unsigned int  st_mode;      /* File mode. */
2006ba7651fbSMax Filippov     unsigned int  st_nlink;     /* Link count. */
2007ba7651fbSMax Filippov     unsigned int  st_uid;       /* User ID of the file's owner. */
2008ba7651fbSMax Filippov     unsigned int  st_gid;       /* Group ID of the file's group. */
2009ba7651fbSMax Filippov     uint64_t st_rdev;           /* Device number, if device. */
2010ba7651fbSMax Filippov     int64_t st_size;            /* Size of file, in bytes. */
2011ba7651fbSMax Filippov     abi_ulong st_blksize;       /* Optimal block size for I/O. */
2012ba7651fbSMax Filippov     abi_ulong __unused2;
2013ba7651fbSMax Filippov     uint64_t st_blocks;         /* Number 512-byte blocks allocated. */
2014ba7651fbSMax Filippov     abi_ulong target_st_atime;  /* Time of last access. */
2015ba7651fbSMax Filippov     abi_ulong target_st_atime_nsec;
2016ba7651fbSMax Filippov     abi_ulong target_st_mtime;  /* Time of last modification. */
2017ba7651fbSMax Filippov     abi_ulong target_st_mtime_nsec;
2018ba7651fbSMax Filippov     abi_ulong target_st_ctime;  /* Time of last status change. */
2019ba7651fbSMax Filippov     abi_ulong target_st_ctime_nsec;
2020ba7651fbSMax Filippov     abi_ulong __unused4;
2021ba7651fbSMax Filippov     abi_ulong __unused5;
2022ba7651fbSMax Filippov };
2023ba7651fbSMax Filippov 
2024a0a839b6SMarek Vasut #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
202547ae93cdSMichael Clark       defined(TARGET_NIOS2) || defined(TARGET_RISCV)
2026c7819dfbSPeter Maydell 
2027c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
2028c7819dfbSPeter Maydell 
20295f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2030d962783eSJia Liu struct target_stat {
2031d962783eSJia Liu     abi_ulong st_dev;
2032d962783eSJia Liu     abi_ulong st_ino;
2033d962783eSJia Liu     unsigned int st_mode;
2034c7819dfbSPeter Maydell     unsigned int st_nlink;
2035d962783eSJia Liu     unsigned int st_uid;
2036d962783eSJia Liu     unsigned int st_gid;
2037d962783eSJia Liu     abi_ulong st_rdev;
2038c7819dfbSPeter Maydell     abi_ulong __pad1;
2039d962783eSJia Liu     abi_long st_size;
2040c7819dfbSPeter Maydell     int st_blksize;
2041c7819dfbSPeter Maydell     int __pad2;
2042c7819dfbSPeter Maydell     abi_long st_blocks;
2043c7819dfbSPeter Maydell     abi_long target_st_atime;
2044d962783eSJia Liu     abi_ulong target_st_atime_nsec;
2045c7819dfbSPeter Maydell     abi_long target_st_mtime;
2046d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
2047c7819dfbSPeter Maydell     abi_long target_st_ctime;
2048d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
2049c7819dfbSPeter Maydell     unsigned int __unused4;
2050c7819dfbSPeter Maydell     unsigned int __unused5;
2051d962783eSJia Liu };
2052c7819dfbSPeter Maydell 
205347ae93cdSMichael Clark #if !defined(TARGET_RISCV64)
205420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
2055c7819dfbSPeter Maydell struct target_stat64 {
2056c7819dfbSPeter Maydell     uint64_t st_dev;
2057c7819dfbSPeter Maydell     uint64_t st_ino;
2058c7819dfbSPeter Maydell     unsigned int st_mode;
2059c7819dfbSPeter Maydell     unsigned int st_nlink;
2060c7819dfbSPeter Maydell     unsigned int st_uid;
2061c7819dfbSPeter Maydell     unsigned int st_gid;
2062c7819dfbSPeter Maydell     uint64_t st_rdev;
2063c7819dfbSPeter Maydell     uint64_t __pad1;
2064c7819dfbSPeter Maydell     int64_t st_size;
2065c7819dfbSPeter Maydell     int st_blksize;
2066c7819dfbSPeter Maydell     int __pad2;
2067c7819dfbSPeter Maydell     int64_t st_blocks;
2068c7819dfbSPeter Maydell     int target_st_atime;
2069c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
2070c7819dfbSPeter Maydell     int target_st_mtime;
2071c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
2072c7819dfbSPeter Maydell     int target_st_ctime;
2073c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
2074c7819dfbSPeter Maydell     unsigned int __unused4;
2075c7819dfbSPeter Maydell     unsigned int __unused5;
2076c7819dfbSPeter Maydell };
207747ae93cdSMichael Clark #endif
2078c7819dfbSPeter Maydell 
2079a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2080a10d1e50SRichard Henderson 
20815f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2082a10d1e50SRichard Henderson struct target_stat {
2083a10d1e50SRichard Henderson     abi_uint   st_dev;
2084a10d1e50SRichard Henderson     abi_uint   st_ino;
2085a10d1e50SRichard Henderson     abi_ushort st_mode;
2086a10d1e50SRichard Henderson     abi_ushort st_nlink;
2087a10d1e50SRichard Henderson     abi_ushort _res1;
2088a10d1e50SRichard Henderson     abi_ushort _res2;
2089a10d1e50SRichard Henderson     abi_uint   st_rdev;
2090a10d1e50SRichard Henderson     abi_int    st_size;
2091a10d1e50SRichard Henderson     abi_int    target_st_atime;
2092a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2093a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2094a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2095a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2096a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2097a10d1e50SRichard Henderson     abi_int    st_blksize;
2098a10d1e50SRichard Henderson     abi_int    st_blocks;
2099a10d1e50SRichard Henderson     abi_uint   _unused1;
2100a10d1e50SRichard Henderson     abi_uint   _unused2;
2101a10d1e50SRichard Henderson     abi_uint   _unused3;
2102a10d1e50SRichard Henderson     abi_uint   _unused4;
2103a10d1e50SRichard Henderson     abi_ushort _unused5;
2104a10d1e50SRichard Henderson     abi_short  st_fstype;
2105a10d1e50SRichard Henderson     abi_uint   st_realdev;
2106a10d1e50SRichard Henderson     abi_ushort st_basemode;
2107a10d1e50SRichard Henderson     abi_ushort _unused6;
2108a10d1e50SRichard Henderson     abi_uint   st_uid;
2109a10d1e50SRichard Henderson     abi_uint   st_gid;
2110a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2111a10d1e50SRichard Henderson };
2112a10d1e50SRichard Henderson 
2113a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2114a10d1e50SRichard Henderson struct target_stat64 {
2115a10d1e50SRichard Henderson     uint64_t   st_dev;
2116a10d1e50SRichard Henderson     abi_uint   _pad1;
2117a10d1e50SRichard Henderson     abi_uint   _res1;
2118a10d1e50SRichard Henderson     abi_uint   st_mode;
2119a10d1e50SRichard Henderson     abi_uint   st_nlink;
2120a10d1e50SRichard Henderson     abi_uint   st_uid;
2121a10d1e50SRichard Henderson     abi_uint   st_gid;
2122a10d1e50SRichard Henderson     uint64_t   st_rdev;
2123a10d1e50SRichard Henderson     abi_uint   _pad2;
2124a10d1e50SRichard Henderson     int64_t    st_size;
2125a10d1e50SRichard Henderson     abi_int    st_blksize;
2126a10d1e50SRichard Henderson     int64_t    st_blocks;
2127a10d1e50SRichard Henderson     abi_int    target_st_atime;
2128a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2129a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2130a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2131a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2132a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2133a10d1e50SRichard Henderson     uint64_t   st_ino;
2134a10d1e50SRichard Henderson };
2135a10d1e50SRichard Henderson 
2136048f6b4dSbellard #else
2137048f6b4dSbellard #error unsupported CPU
2138048f6b4dSbellard #endif
21392521d698Sbellard 
21404ce6f8deSths typedef struct {
21414ce6f8deSths         int     val[2];
2142c227f099SAnthony Liguori } target_fsid_t;
21434ce6f8deSths 
214456c8f68fSbellard #ifdef TARGET_MIPS
2145d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2146540635baSths struct target_statfs {
2147540635baSths 	int32_t			f_type;
2148540635baSths 	int32_t			f_bsize;
2149540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2150540635baSths 	int32_t			f_blocks;
2151540635baSths 	int32_t			f_bfree;
2152540635baSths 	int32_t			f_files;
2153540635baSths 	int32_t			f_ffree;
2154540635baSths 	int32_t			f_bavail;
2155540635baSths 
2156540635baSths 	/* Linux specials */
2157c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2158540635baSths 	int32_t			f_namelen;
2159d4247ec2SShea Levy 	int32_t			f_flags;
2160d4247ec2SShea Levy 	int32_t			f_spare[5];
2161540635baSths };
2162540635baSths #else
216356c8f68fSbellard struct target_statfs {
2164992f48a0Sblueswir1 	abi_long		f_type;
2165992f48a0Sblueswir1 	abi_long		f_bsize;
2166992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2167992f48a0Sblueswir1 	abi_long		f_blocks;
2168992f48a0Sblueswir1 	abi_long		f_bfree;
2169992f48a0Sblueswir1 	abi_long		f_files;
2170992f48a0Sblueswir1 	abi_long		f_ffree;
2171992f48a0Sblueswir1 	abi_long		f_bavail;
217256c8f68fSbellard 
217356c8f68fSbellard 	/* Linux specials */
2174c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2175992f48a0Sblueswir1 	abi_long		f_namelen;
2176d4247ec2SShea Levy 	abi_long		f_flags;
2177d4247ec2SShea Levy 	abi_long		f_spare[5];
217856c8f68fSbellard };
2179540635baSths #endif
218056c8f68fSbellard 
218156c8f68fSbellard struct target_statfs64 {
218256c8f68fSbellard 	uint32_t	f_type;
218356c8f68fSbellard 	uint32_t	f_bsize;
218456c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
218556c8f68fSbellard 	uint32_t	__pad;
218656c8f68fSbellard 	uint64_t	f_blocks;
218756c8f68fSbellard 	uint64_t	f_bfree;
218856c8f68fSbellard 	uint64_t	f_files;
218956c8f68fSbellard 	uint64_t	f_ffree;
219056c8f68fSbellard 	uint64_t	f_bavail;
2191c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
219256c8f68fSbellard 	uint32_t	f_namelen;
2193d4247ec2SShea Levy 	uint32_t	f_flags;
2194d4247ec2SShea Levy 	uint32_t	f_spare[5];
219556c8f68fSbellard };
2196c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
219747ae93cdSMichael Clark        defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
219847ae93cdSMichael Clark        defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2199325e651fSj_mayer struct target_statfs {
2200325e651fSj_mayer 	abi_long f_type;
2201325e651fSj_mayer 	abi_long f_bsize;
2202325e651fSj_mayer 	abi_long f_blocks;
2203325e651fSj_mayer 	abi_long f_bfree;
2204325e651fSj_mayer 	abi_long f_bavail;
2205325e651fSj_mayer 	abi_long f_files;
2206325e651fSj_mayer 	abi_long f_ffree;
2207c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2208325e651fSj_mayer 	abi_long f_namelen;
2209325e651fSj_mayer 	abi_long f_frsize;
2210d4247ec2SShea Levy 	abi_long f_flags;
2211d4247ec2SShea Levy 	abi_long f_spare[4];
2212325e651fSj_mayer };
2213325e651fSj_mayer 
2214325e651fSj_mayer struct target_statfs64 {
2215325e651fSj_mayer 	abi_long f_type;
2216325e651fSj_mayer 	abi_long f_bsize;
2217325e651fSj_mayer 	abi_long f_blocks;
2218325e651fSj_mayer 	abi_long f_bfree;
2219325e651fSj_mayer 	abi_long f_bavail;
2220325e651fSj_mayer 	abi_long f_files;
2221325e651fSj_mayer 	abi_long f_ffree;
2222c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2223325e651fSj_mayer 	abi_long f_namelen;
2224325e651fSj_mayer 	abi_long f_frsize;
2225d4247ec2SShea Levy 	abi_long f_flags;
2226d4247ec2SShea Levy 	abi_long f_spare[4];
2227325e651fSj_mayer };
2228a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2229a4c075f1SUlrich Hecht struct target_statfs {
2230a4c075f1SUlrich Hecht     int32_t  f_type;
2231a4c075f1SUlrich Hecht     int32_t  f_bsize;
2232a4c075f1SUlrich Hecht     abi_long f_blocks;
2233a4c075f1SUlrich Hecht     abi_long f_bfree;
2234a4c075f1SUlrich Hecht     abi_long f_bavail;
2235a4c075f1SUlrich Hecht     abi_long f_files;
2236a4c075f1SUlrich Hecht     abi_long f_ffree;
2237a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2238a4c075f1SUlrich Hecht     int32_t  f_namelen;
2239a4c075f1SUlrich Hecht     int32_t  f_frsize;
2240d4247ec2SShea Levy     int32_t  f_flags;
2241d4247ec2SShea Levy     int32_t  f_spare[4];
2242d4247ec2SShea Levy 
2243a4c075f1SUlrich Hecht };
2244a4c075f1SUlrich Hecht 
2245a4c075f1SUlrich Hecht struct target_statfs64 {
2246a4c075f1SUlrich Hecht     int32_t  f_type;
2247a4c075f1SUlrich Hecht     int32_t  f_bsize;
2248a4c075f1SUlrich Hecht     abi_long f_blocks;
2249a4c075f1SUlrich Hecht     abi_long f_bfree;
2250a4c075f1SUlrich Hecht     abi_long f_bavail;
2251a4c075f1SUlrich Hecht     abi_long f_files;
2252a4c075f1SUlrich Hecht     abi_long f_ffree;
2253a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2254a4c075f1SUlrich Hecht     int32_t  f_namelen;
2255a4c075f1SUlrich Hecht     int32_t  f_frsize;
2256d4247ec2SShea Levy     int32_t  f_flags;
2257d4247ec2SShea Levy     int32_t  f_spare[4];
2258a4c075f1SUlrich Hecht };
225956c8f68fSbellard #else
226056c8f68fSbellard struct target_statfs {
226156c8f68fSbellard 	uint32_t f_type;
226256c8f68fSbellard 	uint32_t f_bsize;
226356c8f68fSbellard 	uint32_t f_blocks;
226456c8f68fSbellard 	uint32_t f_bfree;
226556c8f68fSbellard 	uint32_t f_bavail;
226656c8f68fSbellard 	uint32_t f_files;
226756c8f68fSbellard 	uint32_t f_ffree;
2268c227f099SAnthony Liguori 	target_fsid_t f_fsid;
226956c8f68fSbellard 	uint32_t f_namelen;
227056c8f68fSbellard 	uint32_t f_frsize;
2271d4247ec2SShea Levy 	uint32_t f_flags;
2272d4247ec2SShea Levy 	uint32_t f_spare[4];
227356c8f68fSbellard };
227456c8f68fSbellard 
227556c8f68fSbellard struct target_statfs64 {
227656c8f68fSbellard 	uint32_t f_type;
227756c8f68fSbellard 	uint32_t f_bsize;
227856c8f68fSbellard 	uint64_t f_blocks;
227956c8f68fSbellard 	uint64_t f_bfree;
228056c8f68fSbellard 	uint64_t f_bavail;
228156c8f68fSbellard 	uint64_t f_files;
228256c8f68fSbellard 	uint64_t f_ffree;
2283c227f099SAnthony Liguori 	target_fsid_t f_fsid;
228456c8f68fSbellard         uint32_t f_namelen;
228556c8f68fSbellard 	uint32_t f_frsize;
2286d4247ec2SShea Levy 	uint32_t f_flags;
2287d4247ec2SShea Levy 	uint32_t f_spare[4];
228856c8f68fSbellard };
228956c8f68fSbellard #endif
229056c8f68fSbellard 
22917e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
22927e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
22937e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
22947e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
22957e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
22967e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
22977e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
22987e22e546SUlrich Hecht 
22995de7706eSLaurent Vivier #include "target_fcntl.h"
23008d5d3004SAndreas Schwab 
23012521d698Sbellard /* soundcard defines */
230267cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
23032521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
23042521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
23052521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
23062521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
23072521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
23082521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
23092521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
23102521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
23112521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
23122521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
23132521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
23142521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
23152521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
23162521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
23172521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
23182521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
23192521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
23202521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
23212521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
23222521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
23232521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
23242521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
23252521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
23262521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
23272521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
23282521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
23292521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
23302521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
23315f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
23325f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
23332521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
23342521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
23352521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
23362521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
23372521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
23382521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
23392521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
23402521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
23412521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
23422521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
23432521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
23442521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
23452521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
23462521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
23472521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
23482521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
23492521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
23502521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
23512521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
23522521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
23532521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
23542521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
23552521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
23562521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
23572521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
23582521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
23592521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
23602521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
23612521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
23622521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
23632521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
23642521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
23652521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
23662521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
23672521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
23682521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
23692521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
23702521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
23712521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
23722521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
23732521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
23742521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
23752521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
23762521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
23772521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
23782521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
23792521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
23802521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
23812521d698Sbellard 
23822521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
23832521d698Sbellard 
23842521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
23852521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
23862521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
23872521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
23882521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
23892521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
23902521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
23912521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
23922521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
23932521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
23942521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
23952521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
23962521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
23972521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
23982521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
23992521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
24002521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
24012521d698Sbellard 
24022521d698Sbellard /* Obsolete macros */
24032521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
24042521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
24052521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
24062521d698Sbellard 
24072521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
24082521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
24092521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
24102521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
24112521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
24122521d698Sbellard 
24132521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
24142521d698Sbellard 
24152521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
24162521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
24172521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
24182521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
24192521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
24202521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
24212521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
24222521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
24232521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
24242521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
24252521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
24262521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
24272521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
24282521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
24292521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
24302521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
24312521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
24322521d698Sbellard 
24332521d698Sbellard /* Obsolete macros */
24342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
24352521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
24362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
24372521d698Sbellard 
24382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
24392521d698Sbellard 
2440*1c4c6fcdSFilip Bozuta /* alsa timer ioctls */
2441*1c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PVERSION     TARGET_IOR('T', 0x00, int)
2442*1c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE  TARGET_IOWR('T', 0x01,           \
2443*1c4c6fcdSFilip Bozuta                                                 struct snd_timer_id)
2444*1c4c6fcdSFilip Bozuta 
24452521d698Sbellard /* vfat ioctls */
24462521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
24472521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2448a5448a7dSbellard 
2449f443e396SPeter Maydell struct target_mtop {
2450f443e396SPeter Maydell     abi_short mt_op;
2451f443e396SPeter Maydell     abi_int mt_count;
2452f443e396SPeter Maydell };
2453f443e396SPeter Maydell 
2454f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2455f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2456f443e396SPeter Maydell #else
2457f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2458f443e396SPeter Maydell #endif
2459f443e396SPeter Maydell 
2460f443e396SPeter Maydell struct target_mtget {
2461f443e396SPeter Maydell     abi_long mt_type;
2462f443e396SPeter Maydell     abi_long mt_resid;
2463f443e396SPeter Maydell     abi_long mt_dsreg;
2464f443e396SPeter Maydell     abi_long mt_gstat;
2465f443e396SPeter Maydell     abi_long mt_erreg;
2466f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2467f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2468f443e396SPeter Maydell };
2469f443e396SPeter Maydell 
2470f443e396SPeter Maydell struct target_mtpos {
2471f443e396SPeter Maydell     abi_long mt_blkno;
2472f443e396SPeter Maydell };
2473f443e396SPeter Maydell 
2474f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2475f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2476f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
24778fbd6b52Sbalrog 
2478bd27e675SAleksandar Markovic /* kcov ioctls */
2479bd27e675SAleksandar Markovic #define TARGET_KCOV_ENABLE     TARGET_IO('c', 100)
2480bd27e675SAleksandar Markovic #define TARGET_KCOV_DISABLE    TARGET_IO('c', 101)
2481f7dbd8feSAleksandar Markovic #define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
2482bd27e675SAleksandar Markovic 
2483a5448a7dSbellard struct target_sysinfo {
2484992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2485992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2486992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2487992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2488992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2489992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2490992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2491992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2492a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2493a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2494992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2495992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2496a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2497992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2498a5448a7dSbellard };
24993532fa74Sbellard 
25006556a833Saurel32 struct linux_dirent {
25016556a833Saurel32     long            d_ino;
25026556a833Saurel32     unsigned long   d_off;
25036556a833Saurel32     unsigned short  d_reclen;
25046556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
25056556a833Saurel32 };
25066556a833Saurel32 
25076556a833Saurel32 struct linux_dirent64 {
25086556a833Saurel32     uint64_t        d_ino;
25096556a833Saurel32     int64_t         d_off;
25106556a833Saurel32     unsigned short  d_reclen;
25116556a833Saurel32     unsigned char   d_type;
25126556a833Saurel32     char            d_name[256];
25136556a833Saurel32 };
25146556a833Saurel32 
251524e1003aSaurel32 struct target_mq_attr {
251624e1003aSaurel32     abi_long mq_flags;
251724e1003aSaurel32     abi_long mq_maxmsg;
251824e1003aSaurel32     abi_long mq_msgsize;
251924e1003aSaurel32     abi_long mq_curmsgs;
252024e1003aSaurel32 };
252124e1003aSaurel32 
25223532fa74Sbellard #include "socket.h"
2523637947f1Sths 
2524637947f1Sths #include "errno_defs.h"
252503dfe9f8SRiku Voipio 
252603dfe9f8SRiku Voipio #define FUTEX_WAIT              0
252703dfe9f8SRiku Voipio #define FUTEX_WAKE              1
252803dfe9f8SRiku Voipio #define FUTEX_FD                2
252903dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
253003dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
253103dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
253203dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
253303dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
253403dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
253503dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
253603dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
253703dfe9f8SRiku Voipio 
253803dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
253903dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
254003dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
254103dfe9f8SRiku Voipio 
25423b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2543928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2544928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2545928bed6aSLaurent Vivier #else
2546928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2547928bed6aSLaurent Vivier #endif
2548928bed6aSLaurent Vivier 
25493b6edd16SPeter Maydell typedef union target_epoll_data {
25503b6edd16SPeter Maydell     abi_ulong ptr;
2551928bed6aSLaurent Vivier     abi_int fd;
2552928bed6aSLaurent Vivier     abi_uint u32;
2553928bed6aSLaurent Vivier     abi_ullong u64;
25543b6edd16SPeter Maydell } target_epoll_data_t;
25553b6edd16SPeter Maydell 
25563b6edd16SPeter Maydell struct target_epoll_event {
2557928bed6aSLaurent Vivier     abi_uint events;
25583b6edd16SPeter Maydell     target_epoll_data_t data;
2559928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
25602ba7fae3SPeter Maydell 
25612ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
25622ba7fae3SPeter Maydell 
25633b6edd16SPeter Maydell #endif
2564163a05a8SPeter Maydell struct target_rlimit64 {
2565163a05a8SPeter Maydell     uint64_t rlim_cur;
2566163a05a8SPeter Maydell     uint64_t rlim_max;
2567163a05a8SPeter Maydell };
2568583359a6SAkos PASZTORY 
2569583359a6SAkos PASZTORY struct target_ucred {
2570583359a6SAkos PASZTORY     uint32_t pid;
2571583359a6SAkos PASZTORY     uint32_t uid;
2572583359a6SAkos PASZTORY     uint32_t gid;
2573583359a6SAkos PASZTORY };
2574cb9c377fSPaolo Bonzini 
2575aecc8861SAlexander Graf typedef int32_t target_timer_t;
2576905bba13SErik de Castro Lopo 
257734d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
257834d60862SNatanael Copa 
257934d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
258034d60862SNatanael Copa #ifdef TARGET_MIPS
258134d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
258234d60862SNatanael Copa #else
258334d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
258434d60862SNatanael Copa                                     + sizeof(target_sigval_t))
258534d60862SNatanael Copa #endif
258634d60862SNatanael Copa 
258734d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
258834d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
258934d60862SNatanael Copa                                / sizeof(int32_t))
259034d60862SNatanael Copa 
2591905bba13SErik de Castro Lopo struct target_sigevent {
2592905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
259317351c3fSPeter Maydell     abi_int sigev_signo;
259417351c3fSPeter Maydell     abi_int sigev_notify;
2595905bba13SErik de Castro Lopo     union {
259617351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
259717351c3fSPeter Maydell         abi_int _tid;
2598905bba13SErik de Castro Lopo 
259917351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
260017351c3fSPeter Maydell          * they're only used as part of the ABI between a
260117351c3fSPeter Maydell          * userspace program and libc.
260217351c3fSPeter Maydell          */
2603905bba13SErik de Castro Lopo         struct {
260417351c3fSPeter Maydell             abi_ulong _function;
260517351c3fSPeter Maydell             abi_ulong _attribute;
2606905bba13SErik de Castro Lopo         } _sigev_thread;
2607905bba13SErik de Castro Lopo     } _sigev_un;
2608905bba13SErik de Castro Lopo };
2609e0eb210eSPeter Maydell 
2610e0eb210eSPeter Maydell struct target_user_cap_header {
2611e0eb210eSPeter Maydell     uint32_t version;
2612e0eb210eSPeter Maydell     int pid;
2613e0eb210eSPeter Maydell };
2614e0eb210eSPeter Maydell 
2615e0eb210eSPeter Maydell struct target_user_cap_data {
2616e0eb210eSPeter Maydell     uint32_t effective;
2617e0eb210eSPeter Maydell     uint32_t permitted;
2618e0eb210eSPeter Maydell     uint32_t inheritable;
2619e0eb210eSPeter Maydell };
26201b3c4fdfSMarkus Armbruster 
2621da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2622da2c8ad7SAleksandar Markovic 
2623da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2624da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2625da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2626da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2627da2c8ad7SAleksandar Markovic /* Read from the log. */
2628da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2629da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2630da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2631da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2632da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2633da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2634da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2635da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2636da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2637da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2638da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2639da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2640da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2641da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2642da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2643da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2644da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2645da2c8ad7SAleksandar Markovic 
2646efa92184SAleksandar Rikalo struct target_statx_timestamp {
2647efa92184SAleksandar Rikalo    int64_t tv_sec;
2648efa92184SAleksandar Rikalo    uint32_t tv_nsec;
2649efa92184SAleksandar Rikalo    int32_t __reserved;
2650efa92184SAleksandar Rikalo };
2651efa92184SAleksandar Rikalo 
2652efa92184SAleksandar Rikalo struct target_statx {
2653efa92184SAleksandar Rikalo    /* 0x00 */
2654efa92184SAleksandar Rikalo    uint32_t stx_mask;       /* What results were written [uncond] */
2655efa92184SAleksandar Rikalo    uint32_t stx_blksize;    /* Preferred general I/O size [uncond] */
2656efa92184SAleksandar Rikalo    uint64_t stx_attributes; /* Flags conveying information about the file */
2657efa92184SAleksandar Rikalo    /* 0x10 */
2658efa92184SAleksandar Rikalo    uint32_t stx_nlink;      /* Number of hard links */
2659efa92184SAleksandar Rikalo    uint32_t stx_uid;        /* User ID of owner */
2660efa92184SAleksandar Rikalo    uint32_t stx_gid;        /* Group ID of owner */
2661efa92184SAleksandar Rikalo    uint16_t stx_mode;       /* File mode */
2662efa92184SAleksandar Rikalo    uint16_t __spare0[1];
2663efa92184SAleksandar Rikalo    /* 0x20 */
2664efa92184SAleksandar Rikalo    uint64_t stx_ino;        /* Inode number */
2665efa92184SAleksandar Rikalo    uint64_t stx_size;       /* File size */
2666efa92184SAleksandar Rikalo    uint64_t stx_blocks;     /* Number of 512-byte blocks allocated */
2667efa92184SAleksandar Rikalo    uint64_t stx_attributes_mask; /* Mask to show what is supported */
2668efa92184SAleksandar Rikalo    /* 0x40 */
2669efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_atime;  /* Last access time */
2670efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_btime;  /* File creation time */
2671efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_ctime;  /* Last attribute change time */
2672efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_mtime;  /* Last data modification time */
2673efa92184SAleksandar Rikalo    /* 0x80 */
2674efa92184SAleksandar Rikalo    uint32_t stx_rdev_major;   /* Device ID of special file [if bdev/cdev] */
2675efa92184SAleksandar Rikalo    uint32_t stx_rdev_minor;
2676efa92184SAleksandar Rikalo    uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2677efa92184SAleksandar Rikalo    uint32_t stx_dev_minor;
2678efa92184SAleksandar Rikalo    /* 0x90 */
2679efa92184SAleksandar Rikalo    uint64_t __spare2[14];  /* Spare space for future expansion */
2680efa92184SAleksandar Rikalo    /* 0x100 */
2681efa92184SAleksandar Rikalo };
2682efa92184SAleksandar Rikalo 
26831b3c4fdfSMarkus Armbruster #endif
2684