xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 828cb3a1a89e3ed4b1284c085eeabff39313ddfc)
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 
262*828cb3a1SFilip Bozuta struct target__kernel_itimerspec {
263*828cb3a1SFilip Bozuta     struct target__kernel_timespec it_interval;
264*828cb3a1SFilip Bozuta     struct target__kernel_timespec it_value;
265*828cb3a1SFilip Bozuta };
266*828cb3a1SFilip Bozuta 
26719f59bceSAleksandar Markovic struct target_timex {
26819f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
26919f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
27019f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
27119f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
27219f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
27319f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
27419f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
27519f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
27619f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
27719f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
27819f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
27919f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
28019f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
28119f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
28219f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
28319f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
28419f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
28519f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
28619f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
28719f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
28819f59bceSAleksandar Markovic 
28919f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
29019f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
29119f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
29219f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
29319f59bceSAleksandar Markovic };
29419f59bceSAleksandar Markovic 
295c227f099SAnthony Liguori typedef abi_long target_clock_t;
29632f36bceSbellard 
297c596ed17Sbellard #define TARGET_HZ 100
298c596ed17Sbellard 
29932f36bceSbellard struct target_tms {
300c227f099SAnthony Liguori     target_clock_t tms_utime;
301c227f099SAnthony Liguori     target_clock_t tms_stime;
302c227f099SAnthony Liguori     target_clock_t tms_cutime;
303c227f099SAnthony Liguori     target_clock_t tms_cstime;
30432f36bceSbellard };
30532f36bceSbellard 
3066180a181Sbellard struct target_utimbuf {
307992f48a0Sblueswir1     abi_long actime;
308992f48a0Sblueswir1     abi_long modtime;
3096180a181Sbellard };
3106180a181Sbellard 
311f2674e31Sbellard struct target_sel_arg_struct {
312992f48a0Sblueswir1     abi_long n;
313992f48a0Sblueswir1     abi_long inp, outp, exp;
314992f48a0Sblueswir1     abi_long tvp;
315f2674e31Sbellard };
316f2674e31Sbellard 
31731e31b8aSbellard struct target_iovec {
318992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
319992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
32031e31b8aSbellard };
32131e31b8aSbellard 
3221a9353d2Sbellard struct target_msghdr {
323992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
3241a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
325992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
326992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
327992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
328992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
3291a9353d2Sbellard     unsigned int msg_flags;
3301a9353d2Sbellard };
3311a9353d2Sbellard 
3327854b056Sbellard struct target_cmsghdr {
333992f48a0Sblueswir1     abi_long     cmsg_len;
3347854b056Sbellard     int          cmsg_level;
3357854b056Sbellard     int          cmsg_type;
3367854b056Sbellard };
3377854b056Sbellard 
3387854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
339ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
340ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
341992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
342992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
343ad762b99SPeter Maydell #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
344ad762b99SPeter Maydell                                 TARGET_CMSG_ALIGN(len))
345ad762b99SPeter Maydell #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
3467854b056Sbellard 
3477854b056Sbellard static __inline__ struct target_cmsghdr *
348ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
349ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
350ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3517854b056Sbellard {
3522b8bdefcSths   struct target_cmsghdr *__ptr;
3537854b056Sbellard 
3542b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
355cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
356ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
357ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3587854b056Sbellard     /* No more entries.  */
3592b8bdefcSths     return (struct target_cmsghdr *)0;
360ee104587SJonathan Neuschäfer   }
361ee104587SJonathan Neuschäfer   return __ptr;
3627854b056Sbellard }
3637854b056Sbellard 
364f19e00d7SAlexander Graf struct target_mmsghdr {
365f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
366f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
367f19e00d7SAlexander Graf };
3687854b056Sbellard 
36931e31b8aSbellard struct  target_rusage {
37031e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
37131e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
372992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
373992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
374992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
375992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
376992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
377992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
378992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
379992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
380992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
381992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
382992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
383992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
384992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
385992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
38631e31b8aSbellard };
38731e31b8aSbellard 
38831e31b8aSbellard typedef struct {
38931e31b8aSbellard         int     val[2];
390c227f099SAnthony Liguori } kernel_fsid_t;
39131e31b8aSbellard 
392dab2ed99Sbellard struct target_dirent {
393992f48a0Sblueswir1         abi_long        d_ino;
394992f48a0Sblueswir1         abi_long        d_off;
395dab2ed99Sbellard         unsigned short  d_reclen;
396333858b7SDmitry V. Levin         char            d_name[];
397dab2ed99Sbellard };
398dab2ed99Sbellard 
399dab2ed99Sbellard struct target_dirent64 {
400dab2ed99Sbellard 	uint64_t	d_ino;
401dab2ed99Sbellard 	int64_t		d_off;
402dab2ed99Sbellard 	unsigned short	d_reclen;
403dab2ed99Sbellard 	unsigned char	d_type;
404dab2ed99Sbellard 	char		d_name[256];
405dab2ed99Sbellard };
406dab2ed99Sbellard 
407dab2ed99Sbellard 
40831e31b8aSbellard /* mostly generic signal stuff */
409992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
410992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
411992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
41231e31b8aSbellard 
41331e31b8aSbellard #ifdef TARGET_MIPS
41431e31b8aSbellard #define TARGET_NSIG	   128
41531e31b8aSbellard #else
41631e31b8aSbellard #define TARGET_NSIG	   64
41731e31b8aSbellard #endif
418992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
41931e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
42031e31b8aSbellard 
42131e31b8aSbellard typedef struct {
422992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
423c227f099SAnthony Liguori } target_sigset_t;
42431e31b8aSbellard 
42566fb9763Sbellard #ifdef BSWAP_NEEDED
426c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
42766fb9763Sbellard {
42866fb9763Sbellard     int i;
42966fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
430cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
43166fb9763Sbellard }
43266fb9763Sbellard #else
433c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
43466fb9763Sbellard {
43566fb9763Sbellard     *d = *s;
43666fb9763Sbellard }
43766fb9763Sbellard #endif
43866fb9763Sbellard 
439c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
44066fb9763Sbellard {
44166fb9763Sbellard     int i;
44266fb9763Sbellard     d->sig[0] = set;
44366fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
44466fb9763Sbellard         d->sig[i] = 0;
44566fb9763Sbellard }
44666fb9763Sbellard 
447c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
448c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
449992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
45066fb9763Sbellard                                const sigset_t *sigset);
45166fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
452992f48a0Sblueswir1                                const abi_ulong *old_sigset);
45366fb9763Sbellard struct target_sigaction;
45466fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
45566fb9763Sbellard                  struct target_sigaction *oact);
45666fb9763Sbellard 
4579850f9f6SLaurent Vivier #include "target_signal.h"
4589850f9f6SLaurent Vivier 
4597f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
4607f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
4617f047de1SRichard Henderson #endif
4627f047de1SRichard Henderson 
4636049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
4646049f4f8SRichard Henderson struct target_old_sigaction {
4656049f4f8SRichard Henderson     abi_ulong _sa_handler;
4666049f4f8SRichard Henderson     abi_ulong sa_mask;
467d2565875SRichard Henderson     int32_t sa_flags;
4686049f4f8SRichard Henderson };
469106ec879Sbellard 
4706049f4f8SRichard Henderson struct target_rt_sigaction {
4716049f4f8SRichard Henderson     abi_ulong _sa_handler;
4726049f4f8SRichard Henderson     abi_ulong sa_flags;
4736049f4f8SRichard Henderson     target_sigset_t sa_mask;
4746049f4f8SRichard Henderson };
4756049f4f8SRichard Henderson 
4766049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
4776049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
4786049f4f8SRichard Henderson struct target_sigaction {
4796049f4f8SRichard Henderson     abi_ulong _sa_handler;
4806049f4f8SRichard Henderson     abi_ulong sa_flags;
4816049f4f8SRichard Henderson     target_sigset_t sa_mask;
4826049f4f8SRichard Henderson     abi_ulong sa_restorer;
4836049f4f8SRichard Henderson };
4846049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
485106ec879Sbellard struct target_sigaction {
486540635baSths 	uint32_t	sa_flags;
487d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
488540635baSths 	uint32_t	_sa_handler;
489540635baSths #else
490992f48a0Sblueswir1 	abi_ulong	_sa_handler;
491540635baSths #endif
492c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
4937f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
4947f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
4957f047de1SRichard Henderson         abi_ulong sa_restorer;
4967f047de1SRichard Henderson #endif
497106ec879Sbellard };
498106ec879Sbellard #else
4992521d698Sbellard struct target_old_sigaction {
500992f48a0Sblueswir1         abi_ulong _sa_handler;
501992f48a0Sblueswir1         abi_ulong sa_mask;
502992f48a0Sblueswir1         abi_ulong sa_flags;
5037f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
504992f48a0Sblueswir1         abi_ulong sa_restorer;
5057f047de1SRichard Henderson #endif
5062521d698Sbellard };
5072521d698Sbellard 
5082521d698Sbellard struct target_sigaction {
509992f48a0Sblueswir1         abi_ulong _sa_handler;
510992f48a0Sblueswir1         abi_ulong sa_flags;
5117f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
512992f48a0Sblueswir1         abi_ulong sa_restorer;
5137f047de1SRichard Henderson #endif
514c227f099SAnthony Liguori         target_sigset_t sa_mask;
5155de154e8SLaurent Vivier #ifdef TARGET_ARCH_HAS_KA_RESTORER
5165de154e8SLaurent Vivier         abi_ulong ka_restorer;
5175de154e8SLaurent Vivier #endif
5182521d698Sbellard };
519106ec879Sbellard #endif
5202521d698Sbellard 
5212521d698Sbellard typedef union target_sigval {
5222521d698Sbellard 	int sival_int;
523992f48a0Sblueswir1         abi_ulong sival_ptr;
524c227f099SAnthony Liguori } target_sigval_t;
5256d5e216dSbellard #if 0
5266d5e216dSbellard #if defined (TARGET_SPARC)
5276d5e216dSbellard typedef struct {
5286d5e216dSbellard 	struct {
529992f48a0Sblueswir1 		abi_ulong psr;
530992f48a0Sblueswir1 		abi_ulong pc;
531992f48a0Sblueswir1 		abi_ulong npc;
532992f48a0Sblueswir1 		abi_ulong y;
533992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5346d5e216dSbellard 	}		si_regs;
5356d5e216dSbellard 	int		si_mask;
5366d5e216dSbellard } __siginfo_t;
5376d5e216dSbellard 
5386d5e216dSbellard typedef struct {
5396d5e216dSbellard 	unsigned   long si_float_regs [32];
5406d5e216dSbellard 	unsigned   long si_fsr;
5416d5e216dSbellard 	unsigned   long si_fpqdepth;
5426d5e216dSbellard 	struct {
5436d5e216dSbellard 		unsigned long *insn_addr;
5446d5e216dSbellard 		unsigned long insn;
5456d5e216dSbellard 	} si_fpqueue [16];
5466d5e216dSbellard } __siginfo_fpu_t;
5476d5e216dSbellard #endif
5486d5e216dSbellard #endif
5492521d698Sbellard 
5502521d698Sbellard #define TARGET_SI_MAX_SIZE	128
551aa5e03d2SMaxim Ostapenko 
552aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
553aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
554aa5e03d2SMaxim Ostapenko #else
555aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
556aa5e03d2SMaxim Ostapenko #endif
557aa5e03d2SMaxim Ostapenko 
558aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
5592521d698Sbellard 
560a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
561a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
562a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
563a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
564a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
565a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
566a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
567a70dadc7SPeter Maydell  */
568a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
569a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
570a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
571a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
572a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
573a70dadc7SPeter Maydell #define QEMU_SI_RT 5
574a70dadc7SPeter Maydell 
5752521d698Sbellard typedef struct target_siginfo {
5763f53d546Spbrook #ifdef TARGET_MIPS
5773f53d546Spbrook 	int si_signo;
5783f53d546Spbrook 	int si_code;
5793f53d546Spbrook 	int si_errno;
5803f53d546Spbrook #else
5812521d698Sbellard 	int si_signo;
5822521d698Sbellard 	int si_errno;
5832521d698Sbellard 	int si_code;
5843f53d546Spbrook #endif
5852521d698Sbellard 
5862521d698Sbellard 	union {
5872521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
5882521d698Sbellard 
5892521d698Sbellard 		/* kill() */
5902521d698Sbellard 		struct {
5912521d698Sbellard 			pid_t _pid;		/* sender's pid */
5922521d698Sbellard 			uid_t _uid;		/* sender's uid */
5932521d698Sbellard 		} _kill;
5942521d698Sbellard 
5952521d698Sbellard 		/* POSIX.1b timers */
5962521d698Sbellard 		struct {
5972521d698Sbellard 			unsigned int _timer1;
5982521d698Sbellard 			unsigned int _timer2;
5992521d698Sbellard 		} _timer;
6002521d698Sbellard 
6012521d698Sbellard 		/* POSIX.1b signals */
6022521d698Sbellard 		struct {
6032521d698Sbellard 			pid_t _pid;		/* sender's pid */
6042521d698Sbellard 			uid_t _uid;		/* sender's uid */
605c227f099SAnthony Liguori 			target_sigval_t _sigval;
6062521d698Sbellard 		} _rt;
6072521d698Sbellard 
6082521d698Sbellard 		/* SIGCHLD */
6092521d698Sbellard 		struct {
6102521d698Sbellard 			pid_t _pid;		/* which child */
6112521d698Sbellard 			uid_t _uid;		/* sender's uid */
6122521d698Sbellard 			int _status;		/* exit code */
613c227f099SAnthony Liguori 			target_clock_t _utime;
614c227f099SAnthony Liguori                         target_clock_t _stime;
6152521d698Sbellard 		} _sigchld;
6162521d698Sbellard 
6172521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
6182521d698Sbellard 		struct {
619992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
6202521d698Sbellard 		} _sigfault;
6212521d698Sbellard 
6222521d698Sbellard 		/* SIGPOLL */
6232521d698Sbellard 		struct {
6242521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
6252521d698Sbellard 			int _fd;
6262521d698Sbellard 		} _sigpoll;
6272521d698Sbellard 	} _sifields;
628c227f099SAnthony Liguori } target_siginfo_t;
6292521d698Sbellard 
6302521d698Sbellard /*
6312521d698Sbellard  * si_code values
6322521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6332521d698Sbellard  */
6342521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6352521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6362521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6372521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6382521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6392521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6402521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6412521d698Sbellard 
6422521d698Sbellard /*
6432521d698Sbellard  * SIGILL si_codes
6442521d698Sbellard  */
645ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6462521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
647ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
648ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
649ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
650ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
651ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
652ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
653de2fdd56SChen Gang #ifdef TARGET_TILEGX
654de2fdd56SChen Gang #define TARGET_ILL_DBLFLT       (9)     /* double fault */
655de2fdd56SChen Gang #define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
656de2fdd56SChen Gang #endif
6572521d698Sbellard 
6582521d698Sbellard /*
6592521d698Sbellard  * SIGFPE si_codes
6602521d698Sbellard  */
6612521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
6622521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
6632521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
6642521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
6652521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
6662521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
6672521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
6682521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
66921ba8564SRichard Henderson #define TARGET_FPE_FLTUNK      (14) /* undiagnosed fp exception */
67021ba8564SRichard Henderson #define TARGET_NSIGFPE         15
6712521d698Sbellard 
6722521d698Sbellard /*
6732521d698Sbellard  * SIGSEGV si_codes
6742521d698Sbellard  */
6752521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
6762521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
677de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
6782521d698Sbellard 
6792521d698Sbellard /*
680ffa65c3bSbellard  * SIGBUS si_codes
681ffa65c3bSbellard  */
682ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
683b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
684ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
685de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
686de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
687de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
688de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
689ffa65c3bSbellard 
690ffa65c3bSbellard /*
6912521d698Sbellard  * SIGTRAP si_codes
6922521d698Sbellard  */
6932521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
6942521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
695de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
696de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
6972521d698Sbellard 
6989de5e440Sbellard struct target_rlimit {
699992f48a0Sblueswir1         abi_ulong   rlim_cur;
700992f48a0Sblueswir1         abi_ulong   rlim_max;
7019de5e440Sbellard };
7029de5e440Sbellard 
70381bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
704e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
7056cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
70681bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
70781bbe906Stakasi-y@ops.dti.ne.jp #else
70826b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
70981bbe906Stakasi-y@ops.dti.ne.jp #endif
71081bbe906Stakasi-y@ops.dti.ne.jp 
711e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
712e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
713e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
714e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
715e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
716e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
717e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
718e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
719e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
720e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
721e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
722e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
723e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
724e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
725e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
726e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
727e22b7015SWesley W. Terpstra #else
728e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
729e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
730e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
731e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
732e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
733e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7346cafd027SMatthias Braun #if defined(TARGET_SPARC)
7356cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7366cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7376cafd027SMatthias Braun #else
738e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
739e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7406cafd027SMatthias Braun #endif
741e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
742e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
743e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
744e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
745e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
746e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
747e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
748e22b7015SWesley W. Terpstra #endif
749e22b7015SWesley W. Terpstra 
7509de5e440Sbellard struct target_pollfd {
7519de5e440Sbellard     int fd;           /* file descriptor */
7529de5e440Sbellard     short events;     /* requested events */
7539de5e440Sbellard     short revents;    /* returned events */
7549de5e440Sbellard };
7559de5e440Sbellard 
7568e5a0667Sbellard /* virtual terminal ioctls */
7570221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7580221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7598e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
760f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
761f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
762f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7630221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7640221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
765e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
766e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
767e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
768e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
769ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
7708e5a0667Sbellard 
771373b067fSFilip Bozuta struct target_rtc_pll_info {
772373b067fSFilip Bozuta     int pll_ctrl;
773373b067fSFilip Bozuta     int pll_value;
774373b067fSFilip Bozuta     int pll_max;
775373b067fSFilip Bozuta     int pll_min;
776373b067fSFilip Bozuta     int pll_posmult;
777373b067fSFilip Bozuta     int pll_negmult;
778373b067fSFilip Bozuta     abi_long pll_clock;
779373b067fSFilip Bozuta };
780373b067fSFilip Bozuta 
78168365f96SFilip Bozuta /* real time clock ioctls */
78268365f96SFilip Bozuta #define TARGET_RTC_AIE_ON           TARGET_IO('p', 0x01)
78368365f96SFilip Bozuta #define TARGET_RTC_AIE_OFF          TARGET_IO('p', 0x02)
78468365f96SFilip Bozuta #define TARGET_RTC_UIE_ON           TARGET_IO('p', 0x03)
78568365f96SFilip Bozuta #define TARGET_RTC_UIE_OFF          TARGET_IO('p', 0x04)
78668365f96SFilip Bozuta #define TARGET_RTC_PIE_ON           TARGET_IO('p', 0x05)
78768365f96SFilip Bozuta #define TARGET_RTC_PIE_OFF          TARGET_IO('p', 0x06)
78868365f96SFilip Bozuta #define TARGET_RTC_WIE_ON           TARGET_IO('p', 0x0f)
78968365f96SFilip Bozuta #define TARGET_RTC_WIE_OFF          TARGET_IO('p', 0x10)
790178b14a0SFilip Bozuta #define TARGET_RTC_ALM_READ         TARGET_IOR('p', 0x08, struct rtc_time)
791178b14a0SFilip Bozuta #define TARGET_RTC_ALM_SET          TARGET_IOW('p', 0x07, struct rtc_time)
792178b14a0SFilip Bozuta #define TARGET_RTC_RD_TIME          TARGET_IOR('p', 0x09, struct rtc_time)
793178b14a0SFilip Bozuta #define TARGET_RTC_SET_TIME         TARGET_IOW('p', 0x0a, struct rtc_time)
794fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_READ        TARGET_IOR('p', 0x0b, abi_ulong)
795fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_SET         TARGET_IOW('p', 0x0c, abi_ulong)
796fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_READ       TARGET_IOR('p', 0x0d, abi_ulong)
797fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_SET        TARGET_IOW('p', 0x0e, abi_ulong)
798abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_RD         TARGET_IOR('p', 0x10, struct rtc_wkalrm)
799abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_SET        TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
800373b067fSFilip Bozuta #define TARGET_RTC_PLL_GET          TARGET_IOR('p', 0x11,                      \
801373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
802373b067fSFilip Bozuta #define TARGET_RTC_PLL_SET          TARGET_IOW('p', 0x12,                      \
803373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
804a7b09746SFilip Bozuta #define TARGET_RTC_VL_READ          TARGET_IOR('p', 0x13, int)
805a7b09746SFilip Bozuta #define TARGET_RTC_VL_CLR           TARGET_IO('p', 0x14)
80668365f96SFilip Bozuta 
807d14eabbeSAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
808d14eabbeSAleksandar Markovic        defined(TARGET_XTENSA)
8094e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       TARGET_IOR('f', 123, int)
8104e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       TARGET_IOW('f', 124, int)
811e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
812c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
813405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
814e1be1606SAleksandar Markovic #else
8154e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       0x8903
8164e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       0x8901
8172521d698Sbellard #define TARGET_SIOCATMARK      0x8905
818c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       0x8902
819405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
820e1be1606SAleksandar Markovic #endif
821c495a793SAleksandar Markovic 
8226d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SH4)
8236d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   TARGET_IOR('s', 100, struct target_timeval)
8246d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
8256d5d5ddeSDaniel P. Berrangé #else
8266d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   0x8906
8276d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD 0x8907
8286d5d5ddeSDaniel P. Berrangé #endif
8296d5d5ddeSDaniel P. Berrangé 
8306d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_NEW   TARGET_IOR(0x89, 0x06, abi_llong[2])
8316d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
8322521d698Sbellard 
83331e31b8aSbellard /* Networking ioctls */
83431e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
83531e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
83631e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
83731e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
83831e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
83931e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
84031e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
84131e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
84231e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
84331e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
84431e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
84531e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
84631e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
84731e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
84831e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
84931e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
85031e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
85131e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
85231e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
85331e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
85431e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
85531e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
85631e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
85731e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
85831e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
85931e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
86031e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
86131e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
86231e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
863f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
8644bdcd79eSNeng Chen #define TARGET_SIOCSIFPFLAGS   0x8934          /* set extended flags          */
8654bdcd79eSNeng Chen #define TARGET_SIOCGIFPFLAGS   0x8935          /* get extended flags          */
86631e31b8aSbellard 
86731e31b8aSbellard /* Bridging control calls */
86831e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
86931e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
87031e31b8aSbellard 
87131e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
87231e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
87331e31b8aSbellard 
87431e31b8aSbellard /* ARP cache control calls. */
87531e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
87631e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
87731e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
87831e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
87931e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
88031e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
88131e31b8aSbellard 
88231e31b8aSbellard /* RARP cache control calls. */
88331e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
88431e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
88531e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
88631e31b8aSbellard 
88731e31b8aSbellard /* Driver configuration calls */
88831e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
88931e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
89031e31b8aSbellard 
89131e31b8aSbellard /* DLCI configuration calls */
89231e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
89331e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
89431e31b8aSbellard 
89586fcd946SLaurent Vivier /* From <linux/wireless.h> */
89686fcd946SLaurent Vivier 
89786fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
89831e31b8aSbellard 
899d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
900d6d6d6feSMarco A L Barbosa 
901d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
902d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
903d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
904d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
90592c096f0SAleksandar Markovic #define TARGET_RNDRESEEDCRNG   TARGET_IO('R', 0x07)
906d6d6d6feSMarco A L Barbosa 
90731e31b8aSbellard /* From <linux/fs.h> */
90831e31b8aSbellard 
90931e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
91031e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
91131e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
91231e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
91331e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
91431e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
91531e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
91631e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
91731e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
91831e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
91931e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
92031e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
921fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
92231e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
923c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
924c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
925edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
926edafea13SAlexander Graf                                              /* return device size in bytes
927edafea13SAlexander Graf                                                 (u64 *arg) */
9284715856aSPeter Maydell 
9294715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
9304715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
9314715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
9324715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
9334715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
9344715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
9354715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
9364715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
9374715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
9384715856aSPeter Maydell 
939ab22b4ddSYunqiang Su /* From <linux/fd.h> */
940ab22b4ddSYunqiang Su 
9417e35fc8bSAleksandar Markovic #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
9427e35fc8bSAleksandar Markovic #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
94308e3ce59SAleksandar Markovic #define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
94408e3ce59SAleksandar Markovic #define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct format_descr)
94508e3ce59SAleksandar Markovic #define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
94681eb1a36SAleksandar Markovic #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
947ab22b4ddSYunqiang Su #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
94881eb1a36SAleksandar Markovic #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
94981eb1a36SAleksandar Markovic #define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
9505eea9429SAleksandar Markovic #define TARGET_FDRESET        TARGET_IO(2, 0x54)
9515eea9429SAleksandar Markovic #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
9525eea9429SAleksandar Markovic #define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
9535eea9429SAleksandar Markovic #define TARGET_FDEJECT        TARGET_IO(2, 0x5a)
954ab22b4ddSYunqiang Su 
95531e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
95631e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
95721992cb6SHelge Deller 
95821992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
95921992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
96021992cb6SHelge Deller 
9615ae774a9SAleksandar Markovic /*
9625ae774a9SAleksandar Markovic  * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
9635ae774a9SAleksandar Markovic  * claim type "long" but the actual type used by the kernel is "int".
96460807231SPeter Maydell  */
9651847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
9661847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
9675ae774a9SAleksandar Markovic #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
9685ae774a9SAleksandar Markovic #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
969285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
9700b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
9710b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
9720d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
9730d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
97431e31b8aSbellard 
9756c753a63SCortland Tölva /* usb ioctls */
9766c753a63SCortland Tölva #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
9776c753a63SCortland Tölva #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
9786c753a63SCortland Tölva #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
9796c753a63SCortland Tölva #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
9806c753a63SCortland Tölva #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U',  5)
9816c753a63SCortland Tölva #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
982a133367eSCortland Tölva #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
983a133367eSCortland Tölva #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
984a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
985a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
9866c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
9876c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
9886c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
9896c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
9906c753a63SCortland Tölva #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
9916c753a63SCortland Tölva #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
9926c753a63SCortland Tölva #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
9936c753a63SCortland Tölva #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
9946c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
9956c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
9966c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
9976c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
9986c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
9996c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
10006c753a63SCortland Tölva #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
10016c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
10026c753a63SCortland Tölva 
100331e31b8aSbellard /* cdrom commands */
100431e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
100531e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
100631e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
100731e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
100831e31b8aSbellard                                            (struct cdrom_ti) */
100931e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
101031e31b8aSbellard                                            (struct cdrom_tochdr) */
101131e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
101231e31b8aSbellard                                            (struct cdrom_tocentry) */
101331e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
101431e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
101531e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
101631e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
101731e31b8aSbellard                                            (struct cdrom_volctrl) */
101831e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
101931e31b8aSbellard                                            (struct cdrom_subchnl) */
102031e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
102131e31b8aSbellard                                            (struct cdrom_read) */
102231e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
102331e31b8aSbellard                                            (struct cdrom_read) */
102431e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
102531e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
102631e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
102731e31b8aSbellard                                            address of multi session disks
102831e31b8aSbellard                                            (struct cdrom_multisession) */
102931e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
103031e31b8aSbellard                                            if available (struct cdrom_mcn) */
103167cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
1032b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
103331e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
103431e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
103531e31b8aSbellard                                           (struct cdrom_volctrl) */
103631e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
103731e31b8aSbellard                                            (struct cdrom_read) */
103831e31b8aSbellard /*
103931e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
104031e31b8aSbellard  */
104131e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
104231e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
104331e31b8aSbellard 
104431e31b8aSbellard /*
104531e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
104631e31b8aSbellard    It is for playing audio in logical block addressing mode.
104731e31b8aSbellard  */
104831e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
104931e31b8aSbellard 
105031e31b8aSbellard /*
105131e31b8aSbellard  * These ioctls are only used in optcd.c
105231e31b8aSbellard  */
105331e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
105431e31b8aSbellard 
105531e31b8aSbellard /*
105631e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
105731e31b8aSbellard  * drive spindown time.  They should be implemented in the
105831e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
105931e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
106031e31b8aSbellard  *  -Erik
106131e31b8aSbellard  */
106231e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
106331e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
106431e31b8aSbellard 
106531e31b8aSbellard /*
106631e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
106731e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
106831e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
106931e31b8aSbellard  */
107031e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
107131e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
107231e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
107331e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
107431e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
107531e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
107631e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
107731e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
107831e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
107931e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
108031e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
108131e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
108231e31b8aSbellard 
108331e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
108431e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
108531e31b8aSbellard  */
108631e31b8aSbellard 
108731e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
108831e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
108931e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
109031e31b8aSbellard 
109131e31b8aSbellard /* DVD-ROM Specific ioctls */
109231e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
109331e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
109431e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
109531e31b8aSbellard 
109631e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
109731e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
109831e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
109931e31b8aSbellard 
110031e31b8aSbellard /* HD commands */
110131e31b8aSbellard 
110231e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
110331e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
110431e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
110531e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
110631e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
110731e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
110831e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
110931e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
11102521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
111131e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
111231e31b8aSbellard 
111331e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
111431e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
111531e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
111631e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
111731e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
111831e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
111931e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
112031e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
11212521d698Sbellard 
1122b8005914Sbalrog /* loop ioctls */
1123b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1124b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1125b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1126b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1127b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1128b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1129b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
11302521d698Sbellard 
1131884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1132884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1133884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1134884cdc48SPeter Maydell 
1135f7680a55SUlrich Hecht /* fb ioctls */
1136f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1137f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1138f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
113912b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
114012b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
114112b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
114212b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
114312b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1144f7680a55SUlrich Hecht 
1145f7680a55SUlrich Hecht /* vt ioctls */
1146f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1147f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1148f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1149f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1150f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1151f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1152774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1153774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1154774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1155774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1156f7680a55SUlrich Hecht 
115756e904ecSAlexander Graf /* device mapper */
115856e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
115956e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
116056e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
116156e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
116256e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
116356e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
116456e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
116556e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
116656e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
116756e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
116856e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
116956e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
117056e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
117156e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
117256e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
117356e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
117456e904ecSAlexander Graf 
1175e865b97fSChen Gang /* drm ioctls */
1176e865b97fSChen Gang #define TARGET_DRM_IOCTL_VERSION      TARGET_IOWRU('d', 0x00)
1177e865b97fSChen Gang 
11782521d698Sbellard /* from asm/termbits.h */
11792521d698Sbellard 
11803bfd9da1Sbellard #define TARGET_NCC 8
11813bfd9da1Sbellard struct target_termio {
11823bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
11833bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
11843bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
11853bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
11862521d698Sbellard 	unsigned char c_line;		/* line discipline */
11873bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
11882521d698Sbellard };
11892521d698Sbellard 
11903bfd9da1Sbellard struct target_winsize {
11913bfd9da1Sbellard 	unsigned short ws_row;
11923bfd9da1Sbellard 	unsigned short ws_col;
11933bfd9da1Sbellard 	unsigned short ws_xpixel;
11943bfd9da1Sbellard 	unsigned short ws_ypixel;
11953bfd9da1Sbellard };
11962521d698Sbellard 
11973bfd9da1Sbellard #include "termbits.h"
11982521d698Sbellard 
11999e0b74a4SPaul Brook #if defined(TARGET_MIPS)
12009e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
12019e0b74a4SPaul Brook #else
12029e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
12039e0b74a4SPaul Brook #endif
12049e0b74a4SPaul Brook 
1205e44a3e79Saurel32 /* Common */
12062521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
12072521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1208e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1209e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1210e65be6a7SHelge Deller #else
12112521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1212e65be6a7SHelge Deller #endif
1213e44a3e79Saurel32 
1214e44a3e79Saurel32 /* Target specific */
1215048f6b4dSbellard #if defined(TARGET_MIPS)
1216e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1217048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1218048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1219048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1220048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1221048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1222048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1223540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1224540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1225541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1226541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1227e44a3e79Saurel32 #elif defined(TARGET_PPC)
1228e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
12292521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
12302521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
12312521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
12322521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
12337ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
12347ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1235e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1236e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1237541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1238541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1239e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1240e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1241e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1242e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1243e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1244e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1245e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1246e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1247e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1248e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1249541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1250541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1251a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1252a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1253a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1254a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1255a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1256a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1257a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1258a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1259a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1260a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1261541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1262541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1263ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1264ba7651fbSMax Filippov #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1265ba7651fbSMax Filippov #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1266ba7651fbSMax Filippov #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1267ba7651fbSMax Filippov #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1268ba7651fbSMax Filippov #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1269ba7651fbSMax Filippov #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1270ba7651fbSMax Filippov #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1271ba7651fbSMax Filippov #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1272ba7651fbSMax Filippov #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1273ba7651fbSMax Filippov #define TARGET_MAP_STACK	0x40000
1274ba7651fbSMax Filippov #define TARGET_MAP_HUGETLB  0x80000         /* create a huge page mapping */
12757ec93196Sj_mayer #else
1276e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1277e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1278e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1279e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1280e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
12812521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
12822521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1283540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1284540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1285541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1286541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1287906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
12887ec93196Sj_mayer #endif
12892521d698Sbellard 
129009701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
129109701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1292daa4374aSPeter Maydell     || defined(TARGET_CRIS)
12935f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
12942521d698Sbellard struct target_stat {
12952521d698Sbellard 	unsigned short st_dev;
12962521d698Sbellard 	unsigned short __pad1;
1297992f48a0Sblueswir1 	abi_ulong st_ino;
12982521d698Sbellard 	unsigned short st_mode;
12992521d698Sbellard 	unsigned short st_nlink;
13002521d698Sbellard 	unsigned short st_uid;
13012521d698Sbellard 	unsigned short st_gid;
13022521d698Sbellard 	unsigned short st_rdev;
13032521d698Sbellard 	unsigned short __pad2;
1304992f48a0Sblueswir1 	abi_ulong  st_size;
1305992f48a0Sblueswir1 	abi_ulong  st_blksize;
1306992f48a0Sblueswir1 	abi_ulong  st_blocks;
1307992f48a0Sblueswir1 	abi_ulong  target_st_atime;
13085f992db6SChen-Yu Tsai 	abi_ulong  target_st_atime_nsec;
1309992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
13105f992db6SChen-Yu Tsai 	abi_ulong  target_st_mtime_nsec;
1311992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
13125f992db6SChen-Yu Tsai 	abi_ulong  target_st_ctime_nsec;
1313992f48a0Sblueswir1 	abi_ulong  __unused4;
1314992f48a0Sblueswir1 	abi_ulong  __unused5;
13152521d698Sbellard };
13162521d698Sbellard 
13172521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
13182521d698Sbellard  * insane amounts of padding around dev_t's.
13192521d698Sbellard  */
132020d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13212521d698Sbellard struct target_stat64 {
13222521d698Sbellard 	unsigned short	st_dev;
13232521d698Sbellard 	unsigned char	__pad0[10];
13242521d698Sbellard 
13252521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1326992f48a0Sblueswir1 	abi_ulong	__st_ino;
13272521d698Sbellard 
13282521d698Sbellard 	unsigned int	st_mode;
13292521d698Sbellard 	unsigned int	st_nlink;
13302521d698Sbellard 
1331992f48a0Sblueswir1 	abi_ulong	st_uid;
1332992f48a0Sblueswir1 	abi_ulong	st_gid;
13332521d698Sbellard 
13342521d698Sbellard 	unsigned short	st_rdev;
13352521d698Sbellard 	unsigned char	__pad3[10];
13362521d698Sbellard 
13372521d698Sbellard 	long long	st_size;
1338992f48a0Sblueswir1 	abi_ulong	st_blksize;
13392521d698Sbellard 
1340992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1341992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
13422521d698Sbellard 
1343992f48a0Sblueswir1 	abi_ulong	target_st_atime;
13445f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
13452521d698Sbellard 
1346992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
13475f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
13482521d698Sbellard 
1349992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
13505f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
13512521d698Sbellard 
13522521d698Sbellard 	unsigned long long	st_ino;
1353541dc0d4SStefan Weil } QEMU_PACKED;
13542521d698Sbellard 
1355ce4defa0Spbrook #ifdef TARGET_ARM
135620d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1357ce4defa0Spbrook struct target_eabi_stat64 {
1358ce4defa0Spbrook         unsigned long long st_dev;
1359ce4defa0Spbrook         unsigned int    __pad1;
1360992f48a0Sblueswir1         abi_ulong    __st_ino;
1361ce4defa0Spbrook         unsigned int    st_mode;
1362ce4defa0Spbrook         unsigned int    st_nlink;
1363ce4defa0Spbrook 
1364992f48a0Sblueswir1         abi_ulong    st_uid;
1365992f48a0Sblueswir1         abi_ulong    st_gid;
1366ce4defa0Spbrook 
1367ce4defa0Spbrook         unsigned long long st_rdev;
1368ce4defa0Spbrook         unsigned int    __pad2[2];
1369ce4defa0Spbrook 
1370ce4defa0Spbrook         long long       st_size;
1371992f48a0Sblueswir1         abi_ulong    st_blksize;
1372ce4defa0Spbrook         unsigned int    __pad3;
1373ce4defa0Spbrook         unsigned long long st_blocks;
1374ce4defa0Spbrook 
1375992f48a0Sblueswir1         abi_ulong    target_st_atime;
1376992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1377ce4defa0Spbrook 
1378992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1379992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1380ce4defa0Spbrook 
1381992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1382992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1383ce4defa0Spbrook 
1384ce4defa0Spbrook         unsigned long long st_ino;
1385541dc0d4SStefan Weil } QEMU_PACKED;
1386ce4defa0Spbrook #endif
1387ce4defa0Spbrook 
1388992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
13891b8dd648Sblueswir1 struct target_stat {
13901b8dd648Sblueswir1 	unsigned int	st_dev;
1391992f48a0Sblueswir1 	abi_ulong	st_ino;
13921b8dd648Sblueswir1 	unsigned int	st_mode;
13931b8dd648Sblueswir1 	unsigned int	st_nlink;
13941b8dd648Sblueswir1 	unsigned int	st_uid;
13951b8dd648Sblueswir1 	unsigned int	st_gid;
13961b8dd648Sblueswir1 	unsigned int	st_rdev;
1397992f48a0Sblueswir1 	abi_long	st_size;
1398992f48a0Sblueswir1 	abi_long	target_st_atime;
1399992f48a0Sblueswir1 	abi_long	target_st_mtime;
1400992f48a0Sblueswir1 	abi_long	target_st_ctime;
1401992f48a0Sblueswir1 	abi_long	st_blksize;
1402992f48a0Sblueswir1 	abi_long	st_blocks;
1403992f48a0Sblueswir1 	abi_ulong	__unused4[2];
14041b8dd648Sblueswir1 };
14051b8dd648Sblueswir1 
140620d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14071b8dd648Sblueswir1 struct target_stat64 {
14081b8dd648Sblueswir1 	unsigned char	__pad0[6];
14091b8dd648Sblueswir1 	unsigned short	st_dev;
14101b8dd648Sblueswir1 
14111b8dd648Sblueswir1 	uint64_t	st_ino;
14121b8dd648Sblueswir1 	uint64_t	st_nlink;
14131b8dd648Sblueswir1 
14141b8dd648Sblueswir1 	unsigned int	st_mode;
14151b8dd648Sblueswir1 
14161b8dd648Sblueswir1 	unsigned int	st_uid;
14171b8dd648Sblueswir1 	unsigned int	st_gid;
14181b8dd648Sblueswir1 
14191b8dd648Sblueswir1 	unsigned char	__pad2[6];
14201b8dd648Sblueswir1 	unsigned short	st_rdev;
14211b8dd648Sblueswir1 
14221b8dd648Sblueswir1         int64_t		st_size;
14231b8dd648Sblueswir1 	int64_t		st_blksize;
14241b8dd648Sblueswir1 
14251b8dd648Sblueswir1 	unsigned char	__pad4[4];
14261b8dd648Sblueswir1 	unsigned int	st_blocks;
14271b8dd648Sblueswir1 
1428992f48a0Sblueswir1 	abi_ulong	target_st_atime;
14295f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
14301b8dd648Sblueswir1 
1431992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
14325f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
14331b8dd648Sblueswir1 
1434992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
14355f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
14361b8dd648Sblueswir1 
1437992f48a0Sblueswir1 	abi_ulong	__unused4[3];
14381b8dd648Sblueswir1 };
14391b8dd648Sblueswir1 
14403bfd9da1Sbellard #elif defined(TARGET_SPARC)
14413bfd9da1Sbellard 
14425f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
14433bfd9da1Sbellard struct target_stat {
14443bfd9da1Sbellard 	unsigned short	st_dev;
1445992f48a0Sblueswir1 	abi_ulong	st_ino;
14463bfd9da1Sbellard 	unsigned short	st_mode;
14473bfd9da1Sbellard 	short		st_nlink;
14483bfd9da1Sbellard 	unsigned short	st_uid;
14493bfd9da1Sbellard 	unsigned short	st_gid;
14503bfd9da1Sbellard 	unsigned short	st_rdev;
1451992f48a0Sblueswir1 	abi_long	st_size;
1452992f48a0Sblueswir1 	abi_long	target_st_atime;
14535f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
1454992f48a0Sblueswir1 	abi_long	target_st_mtime;
14555f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
1456992f48a0Sblueswir1 	abi_long	target_st_ctime;
14575f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
1458992f48a0Sblueswir1 	abi_long	st_blksize;
1459992f48a0Sblueswir1 	abi_long	st_blocks;
14605f992db6SChen-Yu Tsai 	abi_ulong	__unused1[2];
14613bfd9da1Sbellard };
14623bfd9da1Sbellard 
146320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14643bfd9da1Sbellard struct target_stat64 {
14653bfd9da1Sbellard 	unsigned char	__pad0[6];
14663bfd9da1Sbellard 	unsigned short	st_dev;
14673bfd9da1Sbellard 
14683bfd9da1Sbellard 	uint64_t st_ino;
14693bfd9da1Sbellard 
14703bfd9da1Sbellard 	unsigned int	st_mode;
14713bfd9da1Sbellard 	unsigned int	st_nlink;
14723bfd9da1Sbellard 
14733bfd9da1Sbellard 	unsigned int	st_uid;
14743bfd9da1Sbellard 	unsigned int	st_gid;
14753bfd9da1Sbellard 
14763bfd9da1Sbellard 	unsigned char	__pad2[6];
14773bfd9da1Sbellard 	unsigned short	st_rdev;
14783bfd9da1Sbellard 
14793bfd9da1Sbellard 	unsigned char	__pad3[8];
14803bfd9da1Sbellard 
14813bfd9da1Sbellard         int64_t	st_size;
14823bfd9da1Sbellard 	unsigned int	st_blksize;
14833bfd9da1Sbellard 
14843bfd9da1Sbellard 	unsigned char	__pad4[8];
14853bfd9da1Sbellard 	unsigned int	st_blocks;
14863bfd9da1Sbellard 
14873bfd9da1Sbellard 	unsigned int	target_st_atime;
14885f992db6SChen-Yu Tsai 	unsigned int	target_st_atime_nsec;
14893bfd9da1Sbellard 
14903bfd9da1Sbellard 	unsigned int	target_st_mtime;
14915f992db6SChen-Yu Tsai 	unsigned int	target_st_mtime_nsec;
14923bfd9da1Sbellard 
14933bfd9da1Sbellard 	unsigned int	target_st_ctime;
14945f992db6SChen-Yu Tsai 	unsigned int	target_st_ctime_nsec;
14953bfd9da1Sbellard 
14965f992db6SChen-Yu Tsai 	unsigned int	__unused1;
14975f992db6SChen-Yu Tsai 	unsigned int	__unused2;
14983bfd9da1Sbellard };
14993bfd9da1Sbellard 
150067867308Sbellard #elif defined(TARGET_PPC)
150167867308Sbellard 
15025f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
150367867308Sbellard struct target_stat {
1504e32448e0Sj_mayer 	abi_ulong st_dev;
1505992f48a0Sblueswir1 	abi_ulong st_ino;
1506325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1507e32448e0Sj_mayer 	abi_ulong st_nlink;
1508325e651fSj_mayer 	unsigned int st_mode;
1509325e651fSj_mayer #else
151067867308Sbellard 	unsigned int st_mode;
151167867308Sbellard 	unsigned short st_nlink;
1512325e651fSj_mayer #endif
151367867308Sbellard 	unsigned int st_uid;
151467867308Sbellard 	unsigned int st_gid;
1515e32448e0Sj_mayer 	abi_ulong  st_rdev;
1516992f48a0Sblueswir1 	abi_ulong  st_size;
1517992f48a0Sblueswir1 	abi_ulong  st_blksize;
1518992f48a0Sblueswir1 	abi_ulong  st_blocks;
1519992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1520e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1521992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1522e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1523992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1524e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1525992f48a0Sblueswir1 	abi_ulong  __unused4;
1526992f48a0Sblueswir1 	abi_ulong  __unused5;
1527325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1528325e651fSj_mayer 	abi_ulong  __unused6;
1529325e651fSj_mayer #endif
153067867308Sbellard };
153167867308Sbellard 
153220d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
153320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1534541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
153567867308Sbellard 	unsigned long long st_dev;
153667867308Sbellard         unsigned long long st_ino;
153767867308Sbellard 	unsigned int st_mode;
153867867308Sbellard 	unsigned int st_nlink;
153967867308Sbellard 	unsigned int st_uid;
154067867308Sbellard 	unsigned int st_gid;
154167867308Sbellard 	unsigned long long st_rdev;
1542e1ce5e40Saurel32 	unsigned long long __pad0;
154367867308Sbellard 	long long      st_size;
1544e32448e0Sj_mayer 	int	       st_blksize;
1545e1ce5e40Saurel32 	unsigned int   __pad1;
154661322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1547e32448e0Sj_mayer 	int	       target_st_atime;
1548e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1549e32448e0Sj_mayer 	int	       target_st_mtime;
1550e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1551e32448e0Sj_mayer 	int            target_st_ctime;
1552e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1553e32448e0Sj_mayer         unsigned int   __unused4;
1554e32448e0Sj_mayer         unsigned int   __unused5;
155567867308Sbellard };
155620d155bcSStefan Weil #endif
155767867308Sbellard 
1558b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1559b779e29eSEdgar E. Iglesias 
15605f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1561b779e29eSEdgar E. Iglesias struct target_stat {
1562b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1563b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1564b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1565b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1566b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1567b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1568b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1569b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1570b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1571b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1572b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1573b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1574b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1575b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1576b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1577b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1578b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1579b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1580b779e29eSEdgar E. Iglesias };
1581b779e29eSEdgar E. Iglesias 
1582b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
158320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1584541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1585b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1586a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1587a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1588a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1589a523eb06SEdgar E. Iglesias 
1590b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1591b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1592b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1593b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1594b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
159521ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1596b779e29eSEdgar E. Iglesias 
1597b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1598b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
159921ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1600b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1601b779e29eSEdgar E. Iglesias 
1602b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1603b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1604b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1605b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1606b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1607b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1608a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1609b779e29eSEdgar E. Iglesias };
1610b779e29eSEdgar E. Iglesias 
1611e6e5906bSpbrook #elif defined(TARGET_M68K)
1612e6e5906bSpbrook 
1613e6e5906bSpbrook struct target_stat {
1614e6e5906bSpbrook 	unsigned short st_dev;
1615e6e5906bSpbrook 	unsigned short __pad1;
1616992f48a0Sblueswir1 	abi_ulong st_ino;
1617e6e5906bSpbrook 	unsigned short st_mode;
1618e6e5906bSpbrook 	unsigned short st_nlink;
1619e6e5906bSpbrook 	unsigned short st_uid;
1620e6e5906bSpbrook 	unsigned short st_gid;
1621e6e5906bSpbrook 	unsigned short st_rdev;
1622e6e5906bSpbrook 	unsigned short __pad2;
1623992f48a0Sblueswir1 	abi_ulong  st_size;
1624992f48a0Sblueswir1 	abi_ulong  st_blksize;
1625992f48a0Sblueswir1 	abi_ulong  st_blocks;
1626992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1627992f48a0Sblueswir1 	abi_ulong  __unused1;
1628992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1629992f48a0Sblueswir1 	abi_ulong  __unused2;
1630992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1631992f48a0Sblueswir1 	abi_ulong  __unused3;
1632992f48a0Sblueswir1 	abi_ulong  __unused4;
1633992f48a0Sblueswir1 	abi_ulong  __unused5;
1634e6e5906bSpbrook };
1635e6e5906bSpbrook 
1636e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1637e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1638e6e5906bSpbrook  */
163920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1640e6e5906bSpbrook struct target_stat64 {
1641e6e5906bSpbrook 	unsigned long long	st_dev;
1642e6e5906bSpbrook 	unsigned char	__pad1[2];
1643e6e5906bSpbrook 
1644e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1645992f48a0Sblueswir1 	abi_ulong	__st_ino;
1646e6e5906bSpbrook 
1647e6e5906bSpbrook 	unsigned int	st_mode;
1648e6e5906bSpbrook 	unsigned int	st_nlink;
1649e6e5906bSpbrook 
1650992f48a0Sblueswir1 	abi_ulong	st_uid;
1651992f48a0Sblueswir1 	abi_ulong	st_gid;
1652e6e5906bSpbrook 
1653e6e5906bSpbrook 	unsigned long long	st_rdev;
1654e6e5906bSpbrook 	unsigned char	__pad3[2];
1655e6e5906bSpbrook 
1656e6e5906bSpbrook 	long long	st_size;
1657992f48a0Sblueswir1 	abi_ulong	st_blksize;
1658e6e5906bSpbrook 
1659992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1660992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1661e6e5906bSpbrook 
1662992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1663992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1664e6e5906bSpbrook 
1665992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1666992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1667e6e5906bSpbrook 
1668992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1669992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1670e6e5906bSpbrook 
1671e6e5906bSpbrook 	unsigned long long	st_ino;
1672541dc0d4SStefan Weil } QEMU_PACKED;
1673e6e5906bSpbrook 
1674d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1675540635baSths 
16765f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1677540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1678540635baSths struct target_stat {
1679540635baSths 	unsigned int		st_dev;
1680540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1681540635baSths 
1682992f48a0Sblueswir1 	abi_ulong		st_ino;
1683540635baSths 
1684540635baSths 	unsigned int		st_mode;
1685540635baSths 	unsigned int		st_nlink;
1686540635baSths 
1687540635baSths 	int			st_uid;
1688540635baSths 	int			st_gid;
1689540635baSths 
1690540635baSths 	unsigned int		st_rdev;
1691540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1692540635baSths 
1693992f48a0Sblueswir1 	abi_ulong		st_size;
1694540635baSths 
1695540635baSths 	/*
1696540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1697540635baSths 	 * but we don't have it under Linux.
1698540635baSths 	 */
1699540635baSths 	unsigned int		target_st_atime;
1700540635baSths 	unsigned int		target_st_atime_nsec;
1701540635baSths 
1702540635baSths 	unsigned int		target_st_mtime;
1703540635baSths 	unsigned int		target_st_mtime_nsec;
1704540635baSths 
1705540635baSths 	unsigned int		target_st_ctime;
1706540635baSths 	unsigned int		target_st_ctime_nsec;
1707540635baSths 
1708540635baSths 	unsigned int		st_blksize;
1709540635baSths 	unsigned int		st_pad2;
1710540635baSths 
1711992f48a0Sblueswir1 	abi_ulong		st_blocks;
1712540635baSths };
1713540635baSths 
1714d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1715540635baSths 
17165f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1717540635baSths struct target_stat {
17181ab2aea2SLeon Alrae         abi_ulong    st_dev;
17191ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
17201ab2aea2SLeon Alrae         uint64_t     st_ino;
1721540635baSths         unsigned int st_mode;
1722540635baSths         unsigned int st_nlink;
1723540635baSths         int          st_uid;
1724540635baSths         int          st_gid;
17251ab2aea2SLeon Alrae         abi_ulong    st_rdev;
17261ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
17271ab2aea2SLeon Alrae         int64_t      st_size;
17281ab2aea2SLeon Alrae         abi_long     target_st_atime;
17291ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
17301ab2aea2SLeon Alrae         abi_long     target_st_mtime;
17311ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
17321ab2aea2SLeon Alrae         abi_long     target_st_ctime;
17331ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
17341ab2aea2SLeon Alrae         abi_ulong    st_blksize;
17351ab2aea2SLeon Alrae         abi_ulong    st_pad2;
17361ab2aea2SLeon Alrae         int64_t      st_blocks;
1737540635baSths };
1738540635baSths 
1739d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1740048f6b4dSbellard 
17415f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1742048f6b4dSbellard struct target_stat {
1743048f6b4dSbellard 	unsigned	st_dev;
1744992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1745992f48a0Sblueswir1 	abi_ulong	st_ino;
1746048f6b4dSbellard 	unsigned int	st_mode;
1747048f6b4dSbellard 	unsigned int	st_nlink;
1748048f6b4dSbellard 	int		st_uid;
1749048f6b4dSbellard 	int		st_gid;
1750048f6b4dSbellard 	unsigned 	st_rdev;
1751992f48a0Sblueswir1 	abi_long	st_pad2[2];
1752992f48a0Sblueswir1 	abi_long	st_size;
1753992f48a0Sblueswir1 	abi_long	st_pad3;
1754048f6b4dSbellard 	/*
1755048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1756048f6b4dSbellard 	 * but we don't have it under Linux.
1757048f6b4dSbellard 	 */
1758992f48a0Sblueswir1 	abi_long		target_st_atime;
1759992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1760992f48a0Sblueswir1 	abi_long		target_st_mtime;
1761992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1762992f48a0Sblueswir1 	abi_long		target_st_ctime;
1763992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1764992f48a0Sblueswir1 	abi_long		st_blksize;
1765992f48a0Sblueswir1 	abi_long		st_blocks;
1766992f48a0Sblueswir1 	abi_long		st_pad4[14];
1767048f6b4dSbellard };
1768048f6b4dSbellard 
1769048f6b4dSbellard /*
1770048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1771048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1772048f6b4dSbellard  * struct stat of the 64-bit kernel.
1773048f6b4dSbellard  */
1774048f6b4dSbellard 
177520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1776048f6b4dSbellard struct target_stat64 {
1777992f48a0Sblueswir1 	abi_ulong	st_dev;
1778992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1779048f6b4dSbellard 
1780048f6b4dSbellard 	uint64_t	st_ino;
1781048f6b4dSbellard 
1782048f6b4dSbellard         unsigned int	st_mode;
1783048f6b4dSbellard         unsigned int	st_nlink;
1784048f6b4dSbellard 
1785048f6b4dSbellard 	int		st_uid;
1786048f6b4dSbellard 	int		st_gid;
1787048f6b4dSbellard 
1788992f48a0Sblueswir1 	abi_ulong	st_rdev;
1789992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1790048f6b4dSbellard 
1791048f6b4dSbellard 	int64_t 	st_size;
1792048f6b4dSbellard 
1793048f6b4dSbellard 	/*
1794048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1795048f6b4dSbellard 	 * but we don't have it under Linux.
1796048f6b4dSbellard 	 */
1797992f48a0Sblueswir1 	abi_long	target_st_atime;
1798992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1799048f6b4dSbellard 
1800992f48a0Sblueswir1 	abi_long	target_st_mtime;
1801992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1802048f6b4dSbellard 
1803992f48a0Sblueswir1 	abi_long	target_st_ctime;
1804992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1805048f6b4dSbellard 
1806992f48a0Sblueswir1 	abi_ulong	st_blksize;
1807992f48a0Sblueswir1 	abi_ulong	st_pad2;
1808048f6b4dSbellard 
1809048f6b4dSbellard 	int64_t  	st_blocks;
1810048f6b4dSbellard };
18117a3148a9Sj_mayer 
18127a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
18137a3148a9Sj_mayer 
18147a3148a9Sj_mayer struct target_stat {
18157a3148a9Sj_mayer        unsigned int    st_dev;
18167a3148a9Sj_mayer        unsigned int    st_ino;
18177a3148a9Sj_mayer        unsigned int    st_mode;
18187a3148a9Sj_mayer        unsigned int    st_nlink;
18197a3148a9Sj_mayer        unsigned int    st_uid;
18207a3148a9Sj_mayer        unsigned int    st_gid;
18217a3148a9Sj_mayer        unsigned int    st_rdev;
1822992f48a0Sblueswir1        abi_long     st_size;
1823992f48a0Sblueswir1        abi_ulong    target_st_atime;
1824992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1825992f48a0Sblueswir1        abi_ulong    target_st_ctime;
18267a3148a9Sj_mayer        unsigned int    st_blksize;
18277a3148a9Sj_mayer        unsigned int    st_blocks;
18287a3148a9Sj_mayer        unsigned int    st_flags;
18297a3148a9Sj_mayer        unsigned int    st_gen;
18307a3148a9Sj_mayer };
18317a3148a9Sj_mayer 
183220d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
18337a3148a9Sj_mayer struct target_stat64 {
1834992f48a0Sblueswir1        abi_ulong    st_dev;
1835992f48a0Sblueswir1        abi_ulong    st_ino;
1836992f48a0Sblueswir1        abi_ulong    st_rdev;
1837992f48a0Sblueswir1        abi_long     st_size;
1838992f48a0Sblueswir1        abi_ulong    st_blocks;
18397a3148a9Sj_mayer 
18407a3148a9Sj_mayer        unsigned int    st_mode;
18417a3148a9Sj_mayer        unsigned int    st_uid;
18427a3148a9Sj_mayer        unsigned int    st_gid;
18437a3148a9Sj_mayer        unsigned int    st_blksize;
18447a3148a9Sj_mayer        unsigned int    st_nlink;
18457a3148a9Sj_mayer        unsigned int    __pad0;
18467a3148a9Sj_mayer 
1847992f48a0Sblueswir1        abi_ulong    target_st_atime;
1848992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1849992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1850992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1851992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1852992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1853992f48a0Sblueswir1        abi_long     __unused[3];
18547a3148a9Sj_mayer };
18557a3148a9Sj_mayer 
18566db45e65Sths #elif defined(TARGET_SH4)
18576db45e65Sths 
18585f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
18596db45e65Sths struct target_stat {
1860992f48a0Sblueswir1 	abi_ulong  st_dev;
1861992f48a0Sblueswir1 	abi_ulong  st_ino;
18626db45e65Sths 	unsigned short st_mode;
18636db45e65Sths 	unsigned short st_nlink;
18646db45e65Sths 	unsigned short st_uid;
18656db45e65Sths 	unsigned short st_gid;
1866992f48a0Sblueswir1 	abi_ulong  st_rdev;
1867992f48a0Sblueswir1 	abi_ulong  st_size;
1868992f48a0Sblueswir1 	abi_ulong  st_blksize;
1869992f48a0Sblueswir1 	abi_ulong  st_blocks;
1870992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1871992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1872992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1873992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1874992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1875992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1876992f48a0Sblueswir1 	abi_ulong  __unused4;
1877992f48a0Sblueswir1 	abi_ulong  __unused5;
18786db45e65Sths };
18796db45e65Sths 
18806db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
18816db45e65Sths  * insane amounts of padding around dev_t's.
18826db45e65Sths  */
188320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1884541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
18856db45e65Sths 	unsigned long long	st_dev;
18866db45e65Sths 	unsigned char	__pad0[4];
18876db45e65Sths 
18886db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1889992f48a0Sblueswir1 	abi_ulong	__st_ino;
18906db45e65Sths 
18916db45e65Sths 	unsigned int	st_mode;
18926db45e65Sths 	unsigned int	st_nlink;
18936db45e65Sths 
1894992f48a0Sblueswir1 	abi_ulong	st_uid;
1895992f48a0Sblueswir1 	abi_ulong	st_gid;
18966db45e65Sths 
18976db45e65Sths 	unsigned long long	st_rdev;
18986db45e65Sths 	unsigned char	__pad3[4];
18996db45e65Sths 
19006db45e65Sths 	long long	st_size;
1901992f48a0Sblueswir1 	abi_ulong	st_blksize;
19026db45e65Sths 
19036db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
19046db45e65Sths 
1905992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1906992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
19076db45e65Sths 
1908992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1909992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
19106db45e65Sths 
1911992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1912992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
19136db45e65Sths 
19146db45e65Sths 	unsigned long long	st_ino;
19156db45e65Sths };
19166db45e65Sths 
1917d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
19185f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1919d2fd1af7Sbellard struct target_stat {
1920d2fd1af7Sbellard 	abi_ulong	st_dev;
1921d2fd1af7Sbellard 	abi_ulong	st_ino;
1922d2fd1af7Sbellard 	abi_ulong	st_nlink;
1923d2fd1af7Sbellard 
1924d2fd1af7Sbellard 	unsigned int	st_mode;
1925d2fd1af7Sbellard 	unsigned int	st_uid;
1926d2fd1af7Sbellard 	unsigned int	st_gid;
1927d2fd1af7Sbellard 	unsigned int	__pad0;
1928d2fd1af7Sbellard 	abi_ulong	st_rdev;
1929d2fd1af7Sbellard 	abi_long	st_size;
1930d2fd1af7Sbellard 	abi_long	st_blksize;
1931d2fd1af7Sbellard 	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1932d2fd1af7Sbellard 
1933d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1934d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1935d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1936d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1937d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1938d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1939d2fd1af7Sbellard 
1940d2fd1af7Sbellard 	abi_long	__unused[3];
1941d2fd1af7Sbellard };
1942a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1943a4c075f1SUlrich Hecht struct target_stat {
1944a4c075f1SUlrich Hecht     abi_ulong  st_dev;
1945a4c075f1SUlrich Hecht     abi_ulong  st_ino;
1946a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
1947a4c075f1SUlrich Hecht     unsigned int   st_mode;
1948a4c075f1SUlrich Hecht     unsigned int   st_uid;
1949a4c075f1SUlrich Hecht     unsigned int   st_gid;
1950a4c075f1SUlrich Hecht     unsigned int   __pad1;
1951a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
1952a4c075f1SUlrich Hecht     abi_ulong  st_size;
1953a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
1954a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
1955a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
1956a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
1957a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
1958a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
1959a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
1960a4c075f1SUlrich Hecht     abi_long       st_blocks;
1961a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
1962a4c075f1SUlrich Hecht };
196309701199SAlexander Graf #elif defined(TARGET_AARCH64)
19645f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
196509701199SAlexander Graf struct target_stat {
196609701199SAlexander Graf     abi_ulong  st_dev;
196709701199SAlexander Graf     abi_ulong  st_ino;
196809701199SAlexander Graf     unsigned int st_mode;
196909701199SAlexander Graf     unsigned int st_nlink;
197009701199SAlexander Graf     unsigned int   st_uid;
197109701199SAlexander Graf     unsigned int   st_gid;
197209701199SAlexander Graf     abi_ulong  st_rdev;
197309701199SAlexander Graf     abi_ulong  _pad1;
197409701199SAlexander Graf     abi_long  st_size;
197509701199SAlexander Graf     int        st_blksize;
197609701199SAlexander Graf     int        __pad2;
197709701199SAlexander Graf     abi_long   st_blocks;
197809701199SAlexander Graf     abi_long  target_st_atime;
197909701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
198009701199SAlexander Graf     abi_long  target_st_mtime;
198109701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
198209701199SAlexander Graf     abi_long  target_st_ctime;
198309701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
198409701199SAlexander Graf     unsigned int __unused[2];
198509701199SAlexander Graf };
1986ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
19875f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1988ba7651fbSMax Filippov struct target_stat {
1989ba7651fbSMax Filippov     abi_ulong       st_dev;
1990ba7651fbSMax Filippov     abi_ulong       st_ino;
1991ba7651fbSMax Filippov     unsigned int    st_mode;
1992ba7651fbSMax Filippov     unsigned int    st_nlink;
1993ba7651fbSMax Filippov     unsigned int    st_uid;
1994ba7651fbSMax Filippov     unsigned int    st_gid;
1995ba7651fbSMax Filippov     abi_ulong       st_rdev;
1996ba7651fbSMax Filippov     abi_long        st_size;
1997ba7651fbSMax Filippov     abi_ulong       st_blksize;
1998ba7651fbSMax Filippov     abi_ulong       st_blocks;
1999ba7651fbSMax Filippov     abi_ulong       target_st_atime;
2000ba7651fbSMax Filippov     abi_ulong       target_st_atime_nsec;
2001ba7651fbSMax Filippov     abi_ulong       target_st_mtime;
2002ba7651fbSMax Filippov     abi_ulong       target_st_mtime_nsec;
2003ba7651fbSMax Filippov     abi_ulong       target_st_ctime;
2004ba7651fbSMax Filippov     abi_ulong       target_st_ctime_nsec;
2005ba7651fbSMax Filippov     abi_ulong       __unused4;
2006ba7651fbSMax Filippov     abi_ulong       __unused5;
2007ba7651fbSMax Filippov };
2008ba7651fbSMax Filippov 
2009ba7651fbSMax Filippov #define TARGET_HAS_STRUCT_STAT64
2010ba7651fbSMax Filippov struct target_stat64  {
2011ba7651fbSMax Filippov     uint64_t st_dev;            /* Device */
2012ba7651fbSMax Filippov     uint64_t st_ino;            /* File serial number */
2013ba7651fbSMax Filippov     unsigned int  st_mode;      /* File mode. */
2014ba7651fbSMax Filippov     unsigned int  st_nlink;     /* Link count. */
2015ba7651fbSMax Filippov     unsigned int  st_uid;       /* User ID of the file's owner. */
2016ba7651fbSMax Filippov     unsigned int  st_gid;       /* Group ID of the file's group. */
2017ba7651fbSMax Filippov     uint64_t st_rdev;           /* Device number, if device. */
2018ba7651fbSMax Filippov     int64_t st_size;            /* Size of file, in bytes. */
2019ba7651fbSMax Filippov     abi_ulong st_blksize;       /* Optimal block size for I/O. */
2020ba7651fbSMax Filippov     abi_ulong __unused2;
2021ba7651fbSMax Filippov     uint64_t st_blocks;         /* Number 512-byte blocks allocated. */
2022ba7651fbSMax Filippov     abi_ulong target_st_atime;  /* Time of last access. */
2023ba7651fbSMax Filippov     abi_ulong target_st_atime_nsec;
2024ba7651fbSMax Filippov     abi_ulong target_st_mtime;  /* Time of last modification. */
2025ba7651fbSMax Filippov     abi_ulong target_st_mtime_nsec;
2026ba7651fbSMax Filippov     abi_ulong target_st_ctime;  /* Time of last status change. */
2027ba7651fbSMax Filippov     abi_ulong target_st_ctime_nsec;
2028ba7651fbSMax Filippov     abi_ulong __unused4;
2029ba7651fbSMax Filippov     abi_ulong __unused5;
2030ba7651fbSMax Filippov };
2031ba7651fbSMax Filippov 
2032a0a839b6SMarek Vasut #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
203347ae93cdSMichael Clark       defined(TARGET_NIOS2) || defined(TARGET_RISCV)
2034c7819dfbSPeter Maydell 
2035c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
2036c7819dfbSPeter Maydell 
20375f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2038d962783eSJia Liu struct target_stat {
2039d962783eSJia Liu     abi_ulong st_dev;
2040d962783eSJia Liu     abi_ulong st_ino;
2041d962783eSJia Liu     unsigned int st_mode;
2042c7819dfbSPeter Maydell     unsigned int st_nlink;
2043d962783eSJia Liu     unsigned int st_uid;
2044d962783eSJia Liu     unsigned int st_gid;
2045d962783eSJia Liu     abi_ulong st_rdev;
2046c7819dfbSPeter Maydell     abi_ulong __pad1;
2047d962783eSJia Liu     abi_long st_size;
2048c7819dfbSPeter Maydell     int st_blksize;
2049c7819dfbSPeter Maydell     int __pad2;
2050c7819dfbSPeter Maydell     abi_long st_blocks;
2051c7819dfbSPeter Maydell     abi_long target_st_atime;
2052d962783eSJia Liu     abi_ulong target_st_atime_nsec;
2053c7819dfbSPeter Maydell     abi_long target_st_mtime;
2054d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
2055c7819dfbSPeter Maydell     abi_long target_st_ctime;
2056d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
2057c7819dfbSPeter Maydell     unsigned int __unused4;
2058c7819dfbSPeter Maydell     unsigned int __unused5;
2059d962783eSJia Liu };
2060c7819dfbSPeter Maydell 
206147ae93cdSMichael Clark #if !defined(TARGET_RISCV64)
206220d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
2063c7819dfbSPeter Maydell struct target_stat64 {
2064c7819dfbSPeter Maydell     uint64_t st_dev;
2065c7819dfbSPeter Maydell     uint64_t st_ino;
2066c7819dfbSPeter Maydell     unsigned int st_mode;
2067c7819dfbSPeter Maydell     unsigned int st_nlink;
2068c7819dfbSPeter Maydell     unsigned int st_uid;
2069c7819dfbSPeter Maydell     unsigned int st_gid;
2070c7819dfbSPeter Maydell     uint64_t st_rdev;
2071c7819dfbSPeter Maydell     uint64_t __pad1;
2072c7819dfbSPeter Maydell     int64_t st_size;
2073c7819dfbSPeter Maydell     int st_blksize;
2074c7819dfbSPeter Maydell     int __pad2;
2075c7819dfbSPeter Maydell     int64_t st_blocks;
2076c7819dfbSPeter Maydell     int target_st_atime;
2077c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
2078c7819dfbSPeter Maydell     int target_st_mtime;
2079c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
2080c7819dfbSPeter Maydell     int target_st_ctime;
2081c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
2082c7819dfbSPeter Maydell     unsigned int __unused4;
2083c7819dfbSPeter Maydell     unsigned int __unused5;
2084c7819dfbSPeter Maydell };
208547ae93cdSMichael Clark #endif
2086c7819dfbSPeter Maydell 
2087a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2088a10d1e50SRichard Henderson 
20895f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2090a10d1e50SRichard Henderson struct target_stat {
2091a10d1e50SRichard Henderson     abi_uint   st_dev;
2092a10d1e50SRichard Henderson     abi_uint   st_ino;
2093a10d1e50SRichard Henderson     abi_ushort st_mode;
2094a10d1e50SRichard Henderson     abi_ushort st_nlink;
2095a10d1e50SRichard Henderson     abi_ushort _res1;
2096a10d1e50SRichard Henderson     abi_ushort _res2;
2097a10d1e50SRichard Henderson     abi_uint   st_rdev;
2098a10d1e50SRichard Henderson     abi_int    st_size;
2099a10d1e50SRichard Henderson     abi_int    target_st_atime;
2100a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2101a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2102a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2103a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2104a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2105a10d1e50SRichard Henderson     abi_int    st_blksize;
2106a10d1e50SRichard Henderson     abi_int    st_blocks;
2107a10d1e50SRichard Henderson     abi_uint   _unused1;
2108a10d1e50SRichard Henderson     abi_uint   _unused2;
2109a10d1e50SRichard Henderson     abi_uint   _unused3;
2110a10d1e50SRichard Henderson     abi_uint   _unused4;
2111a10d1e50SRichard Henderson     abi_ushort _unused5;
2112a10d1e50SRichard Henderson     abi_short  st_fstype;
2113a10d1e50SRichard Henderson     abi_uint   st_realdev;
2114a10d1e50SRichard Henderson     abi_ushort st_basemode;
2115a10d1e50SRichard Henderson     abi_ushort _unused6;
2116a10d1e50SRichard Henderson     abi_uint   st_uid;
2117a10d1e50SRichard Henderson     abi_uint   st_gid;
2118a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2119a10d1e50SRichard Henderson };
2120a10d1e50SRichard Henderson 
2121a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2122a10d1e50SRichard Henderson struct target_stat64 {
2123a10d1e50SRichard Henderson     uint64_t   st_dev;
2124a10d1e50SRichard Henderson     abi_uint   _pad1;
2125a10d1e50SRichard Henderson     abi_uint   _res1;
2126a10d1e50SRichard Henderson     abi_uint   st_mode;
2127a10d1e50SRichard Henderson     abi_uint   st_nlink;
2128a10d1e50SRichard Henderson     abi_uint   st_uid;
2129a10d1e50SRichard Henderson     abi_uint   st_gid;
2130a10d1e50SRichard Henderson     uint64_t   st_rdev;
2131a10d1e50SRichard Henderson     abi_uint   _pad2;
2132a10d1e50SRichard Henderson     int64_t    st_size;
2133a10d1e50SRichard Henderson     abi_int    st_blksize;
2134a10d1e50SRichard Henderson     int64_t    st_blocks;
2135a10d1e50SRichard Henderson     abi_int    target_st_atime;
2136a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2137a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2138a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2139a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2140a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2141a10d1e50SRichard Henderson     uint64_t   st_ino;
2142a10d1e50SRichard Henderson };
2143a10d1e50SRichard Henderson 
2144048f6b4dSbellard #else
2145048f6b4dSbellard #error unsupported CPU
2146048f6b4dSbellard #endif
21472521d698Sbellard 
21484ce6f8deSths typedef struct {
21494ce6f8deSths         int     val[2];
2150c227f099SAnthony Liguori } target_fsid_t;
21514ce6f8deSths 
215256c8f68fSbellard #ifdef TARGET_MIPS
2153d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2154540635baSths struct target_statfs {
2155540635baSths 	int32_t			f_type;
2156540635baSths 	int32_t			f_bsize;
2157540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2158540635baSths 	int32_t			f_blocks;
2159540635baSths 	int32_t			f_bfree;
2160540635baSths 	int32_t			f_files;
2161540635baSths 	int32_t			f_ffree;
2162540635baSths 	int32_t			f_bavail;
2163540635baSths 
2164540635baSths 	/* Linux specials */
2165c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2166540635baSths 	int32_t			f_namelen;
2167d4247ec2SShea Levy 	int32_t			f_flags;
2168d4247ec2SShea Levy 	int32_t			f_spare[5];
2169540635baSths };
2170540635baSths #else
217156c8f68fSbellard struct target_statfs {
2172992f48a0Sblueswir1 	abi_long		f_type;
2173992f48a0Sblueswir1 	abi_long		f_bsize;
2174992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2175992f48a0Sblueswir1 	abi_long		f_blocks;
2176992f48a0Sblueswir1 	abi_long		f_bfree;
2177992f48a0Sblueswir1 	abi_long		f_files;
2178992f48a0Sblueswir1 	abi_long		f_ffree;
2179992f48a0Sblueswir1 	abi_long		f_bavail;
218056c8f68fSbellard 
218156c8f68fSbellard 	/* Linux specials */
2182c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2183992f48a0Sblueswir1 	abi_long		f_namelen;
2184d4247ec2SShea Levy 	abi_long		f_flags;
2185d4247ec2SShea Levy 	abi_long		f_spare[5];
218656c8f68fSbellard };
2187540635baSths #endif
218856c8f68fSbellard 
218956c8f68fSbellard struct target_statfs64 {
219056c8f68fSbellard 	uint32_t	f_type;
219156c8f68fSbellard 	uint32_t	f_bsize;
219256c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
219356c8f68fSbellard 	uint32_t	__pad;
219456c8f68fSbellard 	uint64_t	f_blocks;
219556c8f68fSbellard 	uint64_t	f_bfree;
219656c8f68fSbellard 	uint64_t	f_files;
219756c8f68fSbellard 	uint64_t	f_ffree;
219856c8f68fSbellard 	uint64_t	f_bavail;
2199c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
220056c8f68fSbellard 	uint32_t	f_namelen;
2201d4247ec2SShea Levy 	uint32_t	f_flags;
2202d4247ec2SShea Levy 	uint32_t	f_spare[5];
220356c8f68fSbellard };
2204c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
220547ae93cdSMichael Clark        defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
220647ae93cdSMichael Clark        defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2207325e651fSj_mayer struct target_statfs {
2208325e651fSj_mayer 	abi_long f_type;
2209325e651fSj_mayer 	abi_long f_bsize;
2210325e651fSj_mayer 	abi_long f_blocks;
2211325e651fSj_mayer 	abi_long f_bfree;
2212325e651fSj_mayer 	abi_long f_bavail;
2213325e651fSj_mayer 	abi_long f_files;
2214325e651fSj_mayer 	abi_long f_ffree;
2215c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2216325e651fSj_mayer 	abi_long f_namelen;
2217325e651fSj_mayer 	abi_long f_frsize;
2218d4247ec2SShea Levy 	abi_long f_flags;
2219d4247ec2SShea Levy 	abi_long f_spare[4];
2220325e651fSj_mayer };
2221325e651fSj_mayer 
2222325e651fSj_mayer struct target_statfs64 {
2223325e651fSj_mayer 	abi_long f_type;
2224325e651fSj_mayer 	abi_long f_bsize;
2225325e651fSj_mayer 	abi_long f_blocks;
2226325e651fSj_mayer 	abi_long f_bfree;
2227325e651fSj_mayer 	abi_long f_bavail;
2228325e651fSj_mayer 	abi_long f_files;
2229325e651fSj_mayer 	abi_long f_ffree;
2230c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2231325e651fSj_mayer 	abi_long f_namelen;
2232325e651fSj_mayer 	abi_long f_frsize;
2233d4247ec2SShea Levy 	abi_long f_flags;
2234d4247ec2SShea Levy 	abi_long f_spare[4];
2235325e651fSj_mayer };
2236a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2237a4c075f1SUlrich Hecht struct target_statfs {
2238a4c075f1SUlrich Hecht     int32_t  f_type;
2239a4c075f1SUlrich Hecht     int32_t  f_bsize;
2240a4c075f1SUlrich Hecht     abi_long f_blocks;
2241a4c075f1SUlrich Hecht     abi_long f_bfree;
2242a4c075f1SUlrich Hecht     abi_long f_bavail;
2243a4c075f1SUlrich Hecht     abi_long f_files;
2244a4c075f1SUlrich Hecht     abi_long f_ffree;
2245a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2246a4c075f1SUlrich Hecht     int32_t  f_namelen;
2247a4c075f1SUlrich Hecht     int32_t  f_frsize;
2248d4247ec2SShea Levy     int32_t  f_flags;
2249d4247ec2SShea Levy     int32_t  f_spare[4];
2250d4247ec2SShea Levy 
2251a4c075f1SUlrich Hecht };
2252a4c075f1SUlrich Hecht 
2253a4c075f1SUlrich Hecht struct target_statfs64 {
2254a4c075f1SUlrich Hecht     int32_t  f_type;
2255a4c075f1SUlrich Hecht     int32_t  f_bsize;
2256a4c075f1SUlrich Hecht     abi_long f_blocks;
2257a4c075f1SUlrich Hecht     abi_long f_bfree;
2258a4c075f1SUlrich Hecht     abi_long f_bavail;
2259a4c075f1SUlrich Hecht     abi_long f_files;
2260a4c075f1SUlrich Hecht     abi_long f_ffree;
2261a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2262a4c075f1SUlrich Hecht     int32_t  f_namelen;
2263a4c075f1SUlrich Hecht     int32_t  f_frsize;
2264d4247ec2SShea Levy     int32_t  f_flags;
2265d4247ec2SShea Levy     int32_t  f_spare[4];
2266a4c075f1SUlrich Hecht };
226756c8f68fSbellard #else
226856c8f68fSbellard struct target_statfs {
226956c8f68fSbellard 	uint32_t f_type;
227056c8f68fSbellard 	uint32_t f_bsize;
227156c8f68fSbellard 	uint32_t f_blocks;
227256c8f68fSbellard 	uint32_t f_bfree;
227356c8f68fSbellard 	uint32_t f_bavail;
227456c8f68fSbellard 	uint32_t f_files;
227556c8f68fSbellard 	uint32_t f_ffree;
2276c227f099SAnthony Liguori 	target_fsid_t f_fsid;
227756c8f68fSbellard 	uint32_t f_namelen;
227856c8f68fSbellard 	uint32_t f_frsize;
2279d4247ec2SShea Levy 	uint32_t f_flags;
2280d4247ec2SShea Levy 	uint32_t f_spare[4];
228156c8f68fSbellard };
228256c8f68fSbellard 
228356c8f68fSbellard struct target_statfs64 {
228456c8f68fSbellard 	uint32_t f_type;
228556c8f68fSbellard 	uint32_t f_bsize;
228656c8f68fSbellard 	uint64_t f_blocks;
228756c8f68fSbellard 	uint64_t f_bfree;
228856c8f68fSbellard 	uint64_t f_bavail;
228956c8f68fSbellard 	uint64_t f_files;
229056c8f68fSbellard 	uint64_t f_ffree;
2291c227f099SAnthony Liguori 	target_fsid_t f_fsid;
229256c8f68fSbellard         uint32_t f_namelen;
229356c8f68fSbellard 	uint32_t f_frsize;
2294d4247ec2SShea Levy 	uint32_t f_flags;
2295d4247ec2SShea Levy 	uint32_t f_spare[4];
229656c8f68fSbellard };
229756c8f68fSbellard #endif
229856c8f68fSbellard 
22997e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
23007e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
23017e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
23027e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
23037e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
23047e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
23057e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
23067e22e546SUlrich Hecht 
23075de7706eSLaurent Vivier #include "target_fcntl.h"
23088d5d3004SAndreas Schwab 
23092521d698Sbellard /* soundcard defines */
231067cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
23112521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
23122521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
23132521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
23142521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
23152521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
23162521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
23172521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
23182521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
23192521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
23202521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
23212521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
23222521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
23232521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
23242521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
23252521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
23262521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
23272521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
23282521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
23292521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
23302521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
23312521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
23322521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
23332521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
23342521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
23352521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
23362521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
23372521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
23382521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
23395f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
23405f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
23412521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
23422521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
23432521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
23442521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
23452521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
23462521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
23472521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
23482521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
23492521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
23502521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
23512521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
23522521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
23532521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
23542521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
23552521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
23562521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
23572521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
23582521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
23592521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
23602521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
23612521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
23622521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
23632521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
23642521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
23652521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
23662521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
23672521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
23682521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
23692521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
23702521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
23712521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
23722521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
23732521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
23742521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
23752521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
23762521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
23772521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
23782521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
23792521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
23802521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
23812521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
23822521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
23832521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
23842521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
23852521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
23862521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
23872521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
23882521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
23892521d698Sbellard 
23902521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
23912521d698Sbellard 
23922521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
23932521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
23942521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
23952521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
23962521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
23972521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
23982521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
23992521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
24002521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
24012521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
24022521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
24032521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
24042521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
24052521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
24062521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
24072521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
24082521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
24092521d698Sbellard 
24102521d698Sbellard /* Obsolete macros */
24112521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
24122521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
24132521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
24142521d698Sbellard 
24152521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
24162521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
24172521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
24182521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
24192521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
24202521d698Sbellard 
24212521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
24222521d698Sbellard 
24232521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
24242521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
24252521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
24262521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
24272521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
24282521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
24292521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
24302521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
24312521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
24322521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
24332521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
24342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
24352521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
24362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
24372521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
24382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
24392521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
24402521d698Sbellard 
24412521d698Sbellard /* Obsolete macros */
24422521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
24432521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
24442521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
24452521d698Sbellard 
24462521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
24472521d698Sbellard 
2448aca7708eSFilip Bozuta struct target_snd_timer_id {
2449aca7708eSFilip Bozuta     int dev_class;
2450aca7708eSFilip Bozuta     int dev_sclass;
2451aca7708eSFilip Bozuta     int card;
2452aca7708eSFilip Bozuta     int device;
2453aca7708eSFilip Bozuta     int subdevice;
2454aca7708eSFilip Bozuta };
2455aca7708eSFilip Bozuta 
2456aca7708eSFilip Bozuta struct target_snd_timer_ginfo {
2457aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2458aca7708eSFilip Bozuta     unsigned int flags;
2459aca7708eSFilip Bozuta     int card;
2460aca7708eSFilip Bozuta     unsigned char id[64];
2461aca7708eSFilip Bozuta     unsigned char name[80];
2462aca7708eSFilip Bozuta     abi_ulong reserved0;
2463aca7708eSFilip Bozuta     abi_ulong resolution;
2464aca7708eSFilip Bozuta     abi_ulong resolution_min;
2465aca7708eSFilip Bozuta     abi_ulong resolution_max;
2466aca7708eSFilip Bozuta     unsigned int clients;
2467aca7708eSFilip Bozuta     unsigned char reserved[32];
2468aca7708eSFilip Bozuta };
2469aca7708eSFilip Bozuta 
2470aca7708eSFilip Bozuta struct target_snd_timer_gparams {
2471aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2472aca7708eSFilip Bozuta     abi_ulong period_num;
2473aca7708eSFilip Bozuta     abi_ulong period_den;
2474aca7708eSFilip Bozuta     unsigned char reserved[32];
2475aca7708eSFilip Bozuta };
2476aca7708eSFilip Bozuta 
2477aca7708eSFilip Bozuta struct target_snd_timer_gstatus {
2478aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2479aca7708eSFilip Bozuta     abi_ulong resolution;
2480aca7708eSFilip Bozuta     abi_ulong resolution_num;
2481aca7708eSFilip Bozuta     abi_ulong resolution_den;
2482aca7708eSFilip Bozuta     unsigned char reserved[32];
2483aca7708eSFilip Bozuta };
2484aca7708eSFilip Bozuta 
2485d22edf0aSFilip Bozuta struct target_snd_timer_select {
2486d22edf0aSFilip Bozuta     struct target_snd_timer_id id;
2487d22edf0aSFilip Bozuta     unsigned char reserved[32];
2488d22edf0aSFilip Bozuta };
2489d22edf0aSFilip Bozuta 
2490fe333025SFilip Bozuta struct target_snd_timer_info {
2491fe333025SFilip Bozuta     unsigned int flags;
2492fe333025SFilip Bozuta     int card;
2493fe333025SFilip Bozuta     unsigned char id[64];
2494fe333025SFilip Bozuta     unsigned char name[80];
2495fe333025SFilip Bozuta     abi_ulong reserved0;
2496fe333025SFilip Bozuta     abi_ulong resolution;
2497fe333025SFilip Bozuta     unsigned char reserved[64];
2498fe333025SFilip Bozuta };
2499fe333025SFilip Bozuta 
2500fe333025SFilip Bozuta struct target_snd_timer_status {
2501fe333025SFilip Bozuta     struct target_timespec tstamp;
2502fe333025SFilip Bozuta     unsigned int resolution;
2503fe333025SFilip Bozuta     unsigned int lost;
2504fe333025SFilip Bozuta     unsigned int overrun;
2505fe333025SFilip Bozuta     unsigned int queue;
2506fe333025SFilip Bozuta     unsigned char reserved[64];
2507fe333025SFilip Bozuta };
2508fe333025SFilip Bozuta 
25091c4c6fcdSFilip Bozuta /* alsa timer ioctls */
25101c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PVERSION     TARGET_IOR('T', 0x00, int)
25111c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE  TARGET_IOWR('T', 0x01,           \
25121c4c6fcdSFilip Bozuta                                                 struct snd_timer_id)
2513aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GINFO        TARGET_IOWR('T', 0x03,           \
2514aca7708eSFilip Bozuta                                                 struct target_snd_timer_ginfo)
2515aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GPARAMS      TARGET_IOW('T', 0x04,            \
2516aca7708eSFilip Bozuta                                                 struct target_snd_timer_gparams)
2517aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GSTATUS      TARGET_IOWR('T', 0x05,           \
2518aca7708eSFilip Bozuta                                                 struct target_snd_timer_gstatus)
2519d22edf0aSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_SELECT       TARGET_IOW('T', 0x10,            \
2520d22edf0aSFilip Bozuta                                                 struct target_snd_timer_select)
2521fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_INFO         TARGET_IOR('T', 0x11,            \
2522fe333025SFilip Bozuta                                                 struct target_snd_timer_info)
2523fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PARAMS       TARGET_IOW('T', 0x12,            \
2524fe333025SFilip Bozuta                                                 struct snd_timer_params)
2525fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_STATUS       TARGET_IOR('T', 0x14,            \
2526fe333025SFilip Bozuta                                                 struct target_snd_timer_status)
2527045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_START        TARGET_IO('T', 0xa0)
2528045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_STOP         TARGET_IO('T', 0xa1)
2529045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_CONTINUE     TARGET_IO('T', 0xa2)
2530045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PAUSE        TARGET_IO('T', 0xa3)
25311c4c6fcdSFilip Bozuta 
25322521d698Sbellard /* vfat ioctls */
25332521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
25342521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2535a5448a7dSbellard 
2536f443e396SPeter Maydell struct target_mtop {
2537f443e396SPeter Maydell     abi_short mt_op;
2538f443e396SPeter Maydell     abi_int mt_count;
2539f443e396SPeter Maydell };
2540f443e396SPeter Maydell 
2541f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2542f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2543f443e396SPeter Maydell #else
2544f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2545f443e396SPeter Maydell #endif
2546f443e396SPeter Maydell 
2547f443e396SPeter Maydell struct target_mtget {
2548f443e396SPeter Maydell     abi_long mt_type;
2549f443e396SPeter Maydell     abi_long mt_resid;
2550f443e396SPeter Maydell     abi_long mt_dsreg;
2551f443e396SPeter Maydell     abi_long mt_gstat;
2552f443e396SPeter Maydell     abi_long mt_erreg;
2553f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2554f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2555f443e396SPeter Maydell };
2556f443e396SPeter Maydell 
2557f443e396SPeter Maydell struct target_mtpos {
2558f443e396SPeter Maydell     abi_long mt_blkno;
2559f443e396SPeter Maydell };
2560f443e396SPeter Maydell 
2561f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2562f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2563f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
25648fbd6b52Sbalrog 
2565bd27e675SAleksandar Markovic /* kcov ioctls */
2566bd27e675SAleksandar Markovic #define TARGET_KCOV_ENABLE     TARGET_IO('c', 100)
2567bd27e675SAleksandar Markovic #define TARGET_KCOV_DISABLE    TARGET_IO('c', 101)
2568f7dbd8feSAleksandar Markovic #define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
2569bd27e675SAleksandar Markovic 
2570a5448a7dSbellard struct target_sysinfo {
2571992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2572992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2573992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2574992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2575992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2576992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2577992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2578992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2579a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2580a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2581992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2582992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2583a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2584992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2585a5448a7dSbellard };
25863532fa74Sbellard 
25876556a833Saurel32 struct linux_dirent {
25886556a833Saurel32     long            d_ino;
25896556a833Saurel32     unsigned long   d_off;
25906556a833Saurel32     unsigned short  d_reclen;
25916556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
25926556a833Saurel32 };
25936556a833Saurel32 
25946556a833Saurel32 struct linux_dirent64 {
25956556a833Saurel32     uint64_t        d_ino;
25966556a833Saurel32     int64_t         d_off;
25976556a833Saurel32     unsigned short  d_reclen;
25986556a833Saurel32     unsigned char   d_type;
25996556a833Saurel32     char            d_name[256];
26006556a833Saurel32 };
26016556a833Saurel32 
260224e1003aSaurel32 struct target_mq_attr {
260324e1003aSaurel32     abi_long mq_flags;
260424e1003aSaurel32     abi_long mq_maxmsg;
260524e1003aSaurel32     abi_long mq_msgsize;
260624e1003aSaurel32     abi_long mq_curmsgs;
260724e1003aSaurel32 };
260824e1003aSaurel32 
2609e865b97fSChen Gang struct target_drm_version {
2610e865b97fSChen Gang     int version_major;
2611e865b97fSChen Gang     int version_minor;
2612e865b97fSChen Gang     int version_patchlevel;
2613e865b97fSChen Gang     abi_ulong name_len;
2614e865b97fSChen Gang     abi_ulong name;
2615e865b97fSChen Gang     abi_ulong date_len;
2616e865b97fSChen Gang     abi_ulong date;
2617e865b97fSChen Gang     abi_ulong desc_len;
2618e865b97fSChen Gang     abi_ulong desc;
2619e865b97fSChen Gang };
2620e865b97fSChen Gang 
26213532fa74Sbellard #include "socket.h"
2622637947f1Sths 
2623637947f1Sths #include "errno_defs.h"
262403dfe9f8SRiku Voipio 
262503dfe9f8SRiku Voipio #define FUTEX_WAIT              0
262603dfe9f8SRiku Voipio #define FUTEX_WAKE              1
262703dfe9f8SRiku Voipio #define FUTEX_FD                2
262803dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
262903dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
263003dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
263103dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
263203dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
263303dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
263403dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
263503dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
263603dfe9f8SRiku Voipio 
263703dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
263803dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
263903dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
264003dfe9f8SRiku Voipio 
26413b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2642928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2643928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2644928bed6aSLaurent Vivier #else
2645928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2646928bed6aSLaurent Vivier #endif
2647928bed6aSLaurent Vivier 
26483b6edd16SPeter Maydell typedef union target_epoll_data {
26493b6edd16SPeter Maydell     abi_ulong ptr;
2650928bed6aSLaurent Vivier     abi_int fd;
2651928bed6aSLaurent Vivier     abi_uint u32;
2652928bed6aSLaurent Vivier     abi_ullong u64;
26533b6edd16SPeter Maydell } target_epoll_data_t;
26543b6edd16SPeter Maydell 
26553b6edd16SPeter Maydell struct target_epoll_event {
2656928bed6aSLaurent Vivier     abi_uint events;
26573b6edd16SPeter Maydell     target_epoll_data_t data;
2658928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
26592ba7fae3SPeter Maydell 
26602ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
26612ba7fae3SPeter Maydell 
26623b6edd16SPeter Maydell #endif
2663163a05a8SPeter Maydell struct target_rlimit64 {
2664163a05a8SPeter Maydell     uint64_t rlim_cur;
2665163a05a8SPeter Maydell     uint64_t rlim_max;
2666163a05a8SPeter Maydell };
2667583359a6SAkos PASZTORY 
2668583359a6SAkos PASZTORY struct target_ucred {
2669583359a6SAkos PASZTORY     uint32_t pid;
2670583359a6SAkos PASZTORY     uint32_t uid;
2671583359a6SAkos PASZTORY     uint32_t gid;
2672583359a6SAkos PASZTORY };
2673cb9c377fSPaolo Bonzini 
2674aecc8861SAlexander Graf typedef int32_t target_timer_t;
2675905bba13SErik de Castro Lopo 
267634d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
267734d60862SNatanael Copa 
267834d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
267934d60862SNatanael Copa #ifdef TARGET_MIPS
268034d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
268134d60862SNatanael Copa #else
268234d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
268334d60862SNatanael Copa                                     + sizeof(target_sigval_t))
268434d60862SNatanael Copa #endif
268534d60862SNatanael Copa 
268634d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
268734d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
268834d60862SNatanael Copa                                / sizeof(int32_t))
268934d60862SNatanael Copa 
2690905bba13SErik de Castro Lopo struct target_sigevent {
2691905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
269217351c3fSPeter Maydell     abi_int sigev_signo;
269317351c3fSPeter Maydell     abi_int sigev_notify;
2694905bba13SErik de Castro Lopo     union {
269517351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
269617351c3fSPeter Maydell         abi_int _tid;
2697905bba13SErik de Castro Lopo 
269817351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
269917351c3fSPeter Maydell          * they're only used as part of the ABI between a
270017351c3fSPeter Maydell          * userspace program and libc.
270117351c3fSPeter Maydell          */
2702905bba13SErik de Castro Lopo         struct {
270317351c3fSPeter Maydell             abi_ulong _function;
270417351c3fSPeter Maydell             abi_ulong _attribute;
2705905bba13SErik de Castro Lopo         } _sigev_thread;
2706905bba13SErik de Castro Lopo     } _sigev_un;
2707905bba13SErik de Castro Lopo };
2708e0eb210eSPeter Maydell 
2709e0eb210eSPeter Maydell struct target_user_cap_header {
2710e0eb210eSPeter Maydell     uint32_t version;
2711e0eb210eSPeter Maydell     int pid;
2712e0eb210eSPeter Maydell };
2713e0eb210eSPeter Maydell 
2714e0eb210eSPeter Maydell struct target_user_cap_data {
2715e0eb210eSPeter Maydell     uint32_t effective;
2716e0eb210eSPeter Maydell     uint32_t permitted;
2717e0eb210eSPeter Maydell     uint32_t inheritable;
2718e0eb210eSPeter Maydell };
27191b3c4fdfSMarkus Armbruster 
2720da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2721da2c8ad7SAleksandar Markovic 
2722da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2723da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2724da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2725da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2726da2c8ad7SAleksandar Markovic /* Read from the log. */
2727da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2728da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2729da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2730da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2731da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2732da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2733da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2734da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2735da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2736da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2737da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2738da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2739da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2740da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2741da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2742da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2743da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2744da2c8ad7SAleksandar Markovic 
2745efa92184SAleksandar Rikalo struct target_statx_timestamp {
2746efa92184SAleksandar Rikalo    int64_t tv_sec;
2747efa92184SAleksandar Rikalo    uint32_t tv_nsec;
2748efa92184SAleksandar Rikalo    int32_t __reserved;
2749efa92184SAleksandar Rikalo };
2750efa92184SAleksandar Rikalo 
2751efa92184SAleksandar Rikalo struct target_statx {
2752efa92184SAleksandar Rikalo    /* 0x00 */
2753efa92184SAleksandar Rikalo    uint32_t stx_mask;       /* What results were written [uncond] */
2754efa92184SAleksandar Rikalo    uint32_t stx_blksize;    /* Preferred general I/O size [uncond] */
2755efa92184SAleksandar Rikalo    uint64_t stx_attributes; /* Flags conveying information about the file */
2756efa92184SAleksandar Rikalo    /* 0x10 */
2757efa92184SAleksandar Rikalo    uint32_t stx_nlink;      /* Number of hard links */
2758efa92184SAleksandar Rikalo    uint32_t stx_uid;        /* User ID of owner */
2759efa92184SAleksandar Rikalo    uint32_t stx_gid;        /* Group ID of owner */
2760efa92184SAleksandar Rikalo    uint16_t stx_mode;       /* File mode */
2761efa92184SAleksandar Rikalo    uint16_t __spare0[1];
2762efa92184SAleksandar Rikalo    /* 0x20 */
2763efa92184SAleksandar Rikalo    uint64_t stx_ino;        /* Inode number */
2764efa92184SAleksandar Rikalo    uint64_t stx_size;       /* File size */
2765efa92184SAleksandar Rikalo    uint64_t stx_blocks;     /* Number of 512-byte blocks allocated */
2766efa92184SAleksandar Rikalo    uint64_t stx_attributes_mask; /* Mask to show what is supported */
2767efa92184SAleksandar Rikalo    /* 0x40 */
2768efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_atime;  /* Last access time */
2769efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_btime;  /* File creation time */
2770efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_ctime;  /* Last attribute change time */
2771efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_mtime;  /* Last data modification time */
2772efa92184SAleksandar Rikalo    /* 0x80 */
2773efa92184SAleksandar Rikalo    uint32_t stx_rdev_major;   /* Device ID of special file [if bdev/cdev] */
2774efa92184SAleksandar Rikalo    uint32_t stx_rdev_minor;
2775efa92184SAleksandar Rikalo    uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2776efa92184SAleksandar Rikalo    uint32_t stx_dev_minor;
2777efa92184SAleksandar Rikalo    /* 0x90 */
2778efa92184SAleksandar Rikalo    uint64_t __spare2[14];  /* Spare space for future expansion */
2779efa92184SAleksandar Rikalo    /* 0x100 */
2780efa92184SAleksandar Rikalo };
2781efa92184SAleksandar Rikalo 
27821b3c4fdfSMarkus Armbruster #endif
2783