xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 08e3ce59fcf4a83c5be078e9783161310c769c20)
131e31b8aSbellard /* common syscall defines for all architectures */
231e31b8aSbellard 
32521d698Sbellard /* Note: although the syscall numbers change between architectures,
4b4916d7bSDong Xu Wang    most of them stay the same, so we handle it by putting ifdefs if
52521d698Sbellard    necessary */
62521d698Sbellard 
7cb9c377fSPaolo Bonzini #ifndef SYSCALL_DEFS_H
81b3c4fdfSMarkus Armbruster #define SYSCALL_DEFS_H
9cb9c377fSPaolo Bonzini 
106180a181Sbellard #include "syscall_nr.h"
112521d698Sbellard 
12ff71a454SAleksandar Markovic 
13ff71a454SAleksandar Markovic /* socket operations for socketcall() */
14ff71a454SAleksandar Markovic #define TARGET_SYS_SOCKET       1         /* socket()              */
15ff71a454SAleksandar Markovic #define TARGET_SYS_BIND         2         /* bind()                */
16ff71a454SAleksandar Markovic #define TARGET_SYS_CONNECT      3         /* connect()             */
17ff71a454SAleksandar Markovic #define TARGET_SYS_LISTEN       4         /* listen()              */
18ff71a454SAleksandar Markovic #define TARGET_SYS_ACCEPT       5         /* accept()              */
19ff71a454SAleksandar Markovic #define TARGET_SYS_GETSOCKNAME  6         /* getsockname()         */
20ff71a454SAleksandar Markovic #define TARGET_SYS_GETPEERNAME  7         /* getpeername()         */
21ff71a454SAleksandar Markovic #define TARGET_SYS_SOCKETPAIR   8         /* socketpair()          */
22ff71a454SAleksandar Markovic #define TARGET_SYS_SEND         9         /* send()                */
23ff71a454SAleksandar Markovic #define TARGET_SYS_RECV         10        /* recv()                */
24ff71a454SAleksandar Markovic #define TARGET_SYS_SENDTO       11        /* sendto()              */
25ff71a454SAleksandar Markovic #define TARGET_SYS_RECVFROM     12        /* recvfrom()            */
26ff71a454SAleksandar Markovic #define TARGET_SYS_SHUTDOWN     13        /* shutdown()            */
27ff71a454SAleksandar Markovic #define TARGET_SYS_SETSOCKOPT   14        /* setsockopt()          */
28ff71a454SAleksandar Markovic #define TARGET_SYS_GETSOCKOPT   15        /* getsockopt()          */
29ff71a454SAleksandar Markovic #define TARGET_SYS_SENDMSG      16        /* sendmsg()             */
30ff71a454SAleksandar Markovic #define TARGET_SYS_RECVMSG      17        /* recvmsg()             */
31ff71a454SAleksandar Markovic #define TARGET_SYS_ACCEPT4      18        /* accept4()             */
32ff71a454SAleksandar Markovic #define TARGET_SYS_RECVMMSG     19        /* recvmmsg()            */
33ff71a454SAleksandar Markovic #define TARGET_SYS_SENDMMSG     20        /* sendmmsg()            */
3431e31b8aSbellard 
35524fa340SLaurent Vivier #define IPCOP_CALL(VERSION, OP) ((VERSION) << 16 | (OP))
368853f86eSbellard #define IPCOP_semop		1
378853f86eSbellard #define IPCOP_semget		2
388853f86eSbellard #define IPCOP_semctl		3
398853f86eSbellard #define IPCOP_semtimedop	4
408853f86eSbellard #define IPCOP_msgsnd		11
418853f86eSbellard #define IPCOP_msgrcv		12
428853f86eSbellard #define IPCOP_msgget		13
438853f86eSbellard #define IPCOP_msgctl		14
448853f86eSbellard #define IPCOP_shmat		21
458853f86eSbellard #define IPCOP_shmdt		22
468853f86eSbellard #define IPCOP_shmget		23
478853f86eSbellard #define IPCOP_shmctl		24
488853f86eSbellard 
492521d698Sbellard /*
502521d698Sbellard  * The following is for compatibility across the various Linux
512521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
522521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
532521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
542521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
552521d698Sbellard  * below from now on.
562521d698Sbellard  */
572521d698Sbellard #define TARGET_IOC_NRBITS	8
582521d698Sbellard #define TARGET_IOC_TYPEBITS	8
592521d698Sbellard 
60716f3fbeSPeter Maydell #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
61716f3fbeSPeter Maydell     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
62cd98d390SAndreas Schwab     || defined(TARGET_SPARC) \
630c866a7eSRiku Voipio     || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
6474d753acSMika Westerberg     /* 16 bit uid wrappers emulation */
6574d753acSMika Westerberg #define USE_UID16
660c866a7eSRiku Voipio #define target_id uint16_t
670c866a7eSRiku Voipio #else
680c866a7eSRiku Voipio #define target_id uint32_t
6974d753acSMika Westerberg #endif
7074d753acSMika Westerberg 
71e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
72b16189b2SChen Gang     || defined(TARGET_M68K) || defined(TARGET_CRIS) \
73daa4374aSPeter Maydell     || defined(TARGET_S390X) \
74a0a839b6SMarek Vasut     || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
75ba7651fbSMax Filippov     || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
76ba7651fbSMax Filippov     || defined(TARGET_XTENSA)
772521d698Sbellard 
782521d698Sbellard #define TARGET_IOC_SIZEBITS	14
792521d698Sbellard #define TARGET_IOC_DIRBITS	2
802521d698Sbellard 
812521d698Sbellard #define TARGET_IOC_NONE	  0U
822521d698Sbellard #define TARGET_IOC_WRITE  1U
832521d698Sbellard #define TARGET_IOC_READ	  2U
842521d698Sbellard 
85048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
86b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
87b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
882521d698Sbellard 
892521d698Sbellard #define TARGET_IOC_SIZEBITS	13
902521d698Sbellard #define TARGET_IOC_DIRBITS	3
912521d698Sbellard 
922521d698Sbellard #define TARGET_IOC_NONE	  1U
932521d698Sbellard #define TARGET_IOC_READ	  2U
942521d698Sbellard #define TARGET_IOC_WRITE  4U
952521d698Sbellard 
96a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
97a10d1e50SRichard Henderson 
98a10d1e50SRichard Henderson #define TARGET_IOC_SIZEBITS  14
99a10d1e50SRichard Henderson #define TARGET_IOC_DIRBITS    2
100a10d1e50SRichard Henderson 
101a10d1e50SRichard Henderson #define TARGET_IOC_NONE   0U
102a10d1e50SRichard Henderson #define TARGET_IOC_WRITE  2U
103a10d1e50SRichard Henderson #define TARGET_IOC_READ   1U
104a10d1e50SRichard Henderson 
1052521d698Sbellard #else
1062521d698Sbellard #error unsupported CPU
1072521d698Sbellard #endif
1082521d698Sbellard 
1092521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
1102521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
1112521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
1122521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
1132521d698Sbellard 
1142521d698Sbellard #define TARGET_IOC_NRSHIFT	0
1152521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
1162521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
1172521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
1182521d698Sbellard 
1192521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
1202521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
1212521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
1222521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1232521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1242521d698Sbellard 
1252521d698Sbellard /* used to create numbers */
1262521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1272521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1282521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1292521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1302521d698Sbellard 
1312521d698Sbellard /* the size is automatically computed for these defines */
1322521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1332521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1342521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1352521d698Sbellard 
1367854b056Sbellard struct target_sockaddr {
1379a68960dSPhilippe Mathieu-Daudé     abi_ushort sa_family;
1387854b056Sbellard     uint8_t sa_data[14];
1397854b056Sbellard };
1407854b056Sbellard 
14133a29b51SJoakim Tjernlund struct target_sockaddr_ll {
1429a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_family;   /* Always AF_PACKET */
1439a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_protocol; /* Physical layer protocol */
1449a68960dSPhilippe Mathieu-Daudé     abi_int    sll_ifindex;  /* Interface number */
1459a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_hatype;   /* ARP hardware type */
14633a29b51SJoakim Tjernlund     uint8_t    sll_pkttype;  /* Packet type */
14733a29b51SJoakim Tjernlund     uint8_t    sll_halen;    /* Length of address */
14833a29b51SJoakim Tjernlund     uint8_t    sll_addr[8];  /* Physical layer address */
14933a29b51SJoakim Tjernlund };
15033a29b51SJoakim Tjernlund 
151fb3aabf3SLaurent Vivier struct target_sockaddr_un {
1529a68960dSPhilippe Mathieu-Daudé     abi_ushort su_family;
153fb3aabf3SLaurent Vivier     uint8_t sun_path[108];
154fb3aabf3SLaurent Vivier };
155fb3aabf3SLaurent Vivier 
156a47401bcSPhilippe Mathieu-Daudé struct target_sockaddr_nl {
157a47401bcSPhilippe Mathieu-Daudé     abi_ushort nl_family;   /* AF_NETLINK */
158a47401bcSPhilippe Mathieu-Daudé     abi_ushort __pad;
159a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_pid;
160a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_groups;
161a47401bcSPhilippe Mathieu-Daudé };
162a47401bcSPhilippe Mathieu-Daudé 
163fb3aabf3SLaurent Vivier struct target_in_addr {
1649a68960dSPhilippe Mathieu-Daudé     abi_uint s_addr; /* big endian */
165fb3aabf3SLaurent Vivier };
166fb3aabf3SLaurent Vivier 
167fb3aabf3SLaurent Vivier struct target_sockaddr_in {
1689a68960dSPhilippe Mathieu-Daudé   abi_ushort sin_family;
1699a68960dSPhilippe Mathieu-Daudé   abi_short sin_port; /* big endian */
170fb3aabf3SLaurent Vivier   struct target_in_addr sin_addr;
171fb3aabf3SLaurent Vivier   uint8_t __pad[sizeof(struct target_sockaddr) -
1729a68960dSPhilippe Mathieu-Daudé                 sizeof(abi_ushort) - sizeof(abi_short) -
173fb3aabf3SLaurent Vivier                 sizeof(struct target_in_addr)];
174fb3aabf3SLaurent Vivier };
175fb3aabf3SLaurent Vivier 
176ee1ac3a1SHelge Deller struct target_sockaddr_in6 {
1779a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_family;
1789a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_port; /* big endian */
1799a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_flowinfo; /* big endian */
180ee1ac3a1SHelge Deller     struct in6_addr sin6_addr; /* IPv6 address, big endian */
1819a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_scope_id;
182ee1ac3a1SHelge Deller };
183ee1ac3a1SHelge Deller 
184f57d4192SLaurent Vivier struct target_sock_filter {
185f57d4192SLaurent Vivier     abi_ushort code;
186f57d4192SLaurent Vivier     uint8_t jt;
187f57d4192SLaurent Vivier     uint8_t jf;
188f57d4192SLaurent Vivier     abi_uint k;
189f57d4192SLaurent Vivier };
190f57d4192SLaurent Vivier 
191f57d4192SLaurent Vivier struct target_sock_fprog {
192f57d4192SLaurent Vivier     abi_ushort len;
193f57d4192SLaurent Vivier     abi_ulong filter;
194f57d4192SLaurent Vivier };
195f57d4192SLaurent Vivier 
196b975b83bSLionel Landwerlin struct target_ip_mreq {
197b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
198b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
199b975b83bSLionel Landwerlin };
200b975b83bSLionel Landwerlin 
201b975b83bSLionel Landwerlin struct target_ip_mreqn {
202b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
203b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
204b975b83bSLionel Landwerlin     abi_long imr_ifindex;
205b975b83bSLionel Landwerlin };
206b975b83bSLionel Landwerlin 
2076e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
2086e3cb58fSLionel Landwerlin     /* big endian */
2096e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
2106e3cb58fSLionel Landwerlin     uint32_t imr_interface;
2116e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
2126e3cb58fSLionel Landwerlin };
2136e3cb58fSLionel Landwerlin 
21483eb6e50SCarlo Marcelo Arenas Belón struct target_linger {
21583eb6e50SCarlo Marcelo Arenas Belón     abi_int l_onoff;        /* Linger active                */
21683eb6e50SCarlo Marcelo Arenas Belón     abi_int l_linger;       /* How long to linger for       */
21783eb6e50SCarlo Marcelo Arenas Belón };
21883eb6e50SCarlo Marcelo Arenas Belón 
2196d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
2206d5d5ddeSDaniel P. Berrangé struct target_timeval {
2216d5d5ddeSDaniel P. Berrangé     abi_long tv_sec;
2226d5d5ddeSDaniel P. Berrangé     abi_int tv_usec;
2236d5d5ddeSDaniel P. Berrangé };
2246d5d5ddeSDaniel P. Berrangé #define target__kernel_sock_timeval target_timeval
2256d5d5ddeSDaniel P. Berrangé #else
22631e31b8aSbellard struct target_timeval {
227992f48a0Sblueswir1     abi_long tv_sec;
228992f48a0Sblueswir1     abi_long tv_usec;
22931e31b8aSbellard };
23031e31b8aSbellard 
2316d5d5ddeSDaniel P. Berrangé struct target__kernel_sock_timeval {
2326d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2336d5d5ddeSDaniel P. Berrangé     abi_llong tv_usec;
2346d5d5ddeSDaniel P. Berrangé };
2356d5d5ddeSDaniel P. Berrangé #endif
2366d5d5ddeSDaniel P. Berrangé 
2371b6b029eSbellard struct target_timespec {
238992f48a0Sblueswir1     abi_long tv_sec;
239992f48a0Sblueswir1     abi_long tv_nsec;
2401b6b029eSbellard };
2411b6b029eSbellard 
2426d5d5ddeSDaniel P. Berrangé struct target__kernel_timespec {
2436d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2446d5d5ddeSDaniel P. Berrangé     abi_llong tv_nsec;
2456d5d5ddeSDaniel P. Berrangé };
2466d5d5ddeSDaniel P. Berrangé 
247ef4467e9SPaul Burton struct target_timezone {
248ef4467e9SPaul Burton     abi_int tz_minuteswest;
249ef4467e9SPaul Burton     abi_int tz_dsttime;
250ef4467e9SPaul Burton };
251ef4467e9SPaul Burton 
25266fb9763Sbellard struct target_itimerval {
25366fb9763Sbellard     struct target_timeval it_interval;
25466fb9763Sbellard     struct target_timeval it_value;
25566fb9763Sbellard };
25666fb9763Sbellard 
257905bba13SErik de Castro Lopo struct target_itimerspec {
258905bba13SErik de Castro Lopo     struct target_timespec it_interval;
259905bba13SErik de Castro Lopo     struct target_timespec it_value;
260905bba13SErik de Castro Lopo };
261905bba13SErik de Castro Lopo 
26219f59bceSAleksandar Markovic struct target_timex {
26319f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
26419f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
26519f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
26619f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
26719f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
26819f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
26919f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
27019f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
27119f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
27219f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
27319f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
27419f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
27519f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
27619f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
27719f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
27819f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
27919f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
28019f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
28119f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
28219f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
28319f59bceSAleksandar Markovic 
28419f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
28519f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
28619f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
28719f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
28819f59bceSAleksandar Markovic };
28919f59bceSAleksandar Markovic 
290c227f099SAnthony Liguori typedef abi_long target_clock_t;
29132f36bceSbellard 
292c596ed17Sbellard #define TARGET_HZ 100
293c596ed17Sbellard 
29432f36bceSbellard struct target_tms {
295c227f099SAnthony Liguori     target_clock_t tms_utime;
296c227f099SAnthony Liguori     target_clock_t tms_stime;
297c227f099SAnthony Liguori     target_clock_t tms_cutime;
298c227f099SAnthony Liguori     target_clock_t tms_cstime;
29932f36bceSbellard };
30032f36bceSbellard 
3016180a181Sbellard struct target_utimbuf {
302992f48a0Sblueswir1     abi_long actime;
303992f48a0Sblueswir1     abi_long modtime;
3046180a181Sbellard };
3056180a181Sbellard 
306f2674e31Sbellard struct target_sel_arg_struct {
307992f48a0Sblueswir1     abi_long n;
308992f48a0Sblueswir1     abi_long inp, outp, exp;
309992f48a0Sblueswir1     abi_long tvp;
310f2674e31Sbellard };
311f2674e31Sbellard 
31231e31b8aSbellard struct target_iovec {
313992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
314992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
31531e31b8aSbellard };
31631e31b8aSbellard 
3171a9353d2Sbellard struct target_msghdr {
318992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
3191a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
320992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
321992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
322992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
323992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
3241a9353d2Sbellard     unsigned int msg_flags;
3251a9353d2Sbellard };
3261a9353d2Sbellard 
3277854b056Sbellard struct target_cmsghdr {
328992f48a0Sblueswir1     abi_long     cmsg_len;
3297854b056Sbellard     int          cmsg_level;
3307854b056Sbellard     int          cmsg_type;
3317854b056Sbellard };
3327854b056Sbellard 
3337854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
334ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
335ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
336992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
337992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
338ad762b99SPeter Maydell #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
339ad762b99SPeter Maydell                                 TARGET_CMSG_ALIGN(len))
340ad762b99SPeter Maydell #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
3417854b056Sbellard 
3427854b056Sbellard static __inline__ struct target_cmsghdr *
343ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
344ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
345ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3467854b056Sbellard {
3472b8bdefcSths   struct target_cmsghdr *__ptr;
3487854b056Sbellard 
3492b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
350cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
351ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
352ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3537854b056Sbellard     /* No more entries.  */
3542b8bdefcSths     return (struct target_cmsghdr *)0;
355ee104587SJonathan Neuschäfer   }
356ee104587SJonathan Neuschäfer   return __ptr;
3577854b056Sbellard }
3587854b056Sbellard 
359f19e00d7SAlexander Graf struct target_mmsghdr {
360f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
361f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
362f19e00d7SAlexander Graf };
3637854b056Sbellard 
36431e31b8aSbellard struct  target_rusage {
36531e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
36631e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
367992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
368992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
369992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
370992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
371992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
372992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
373992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
374992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
375992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
376992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
377992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
378992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
379992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
380992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
38131e31b8aSbellard };
38231e31b8aSbellard 
38331e31b8aSbellard typedef struct {
38431e31b8aSbellard         int     val[2];
385c227f099SAnthony Liguori } kernel_fsid_t;
38631e31b8aSbellard 
387dab2ed99Sbellard struct target_dirent {
388992f48a0Sblueswir1         abi_long        d_ino;
389992f48a0Sblueswir1         abi_long        d_off;
390dab2ed99Sbellard         unsigned short  d_reclen;
391333858b7SDmitry V. Levin         char            d_name[];
392dab2ed99Sbellard };
393dab2ed99Sbellard 
394dab2ed99Sbellard struct target_dirent64 {
395dab2ed99Sbellard 	uint64_t	d_ino;
396dab2ed99Sbellard 	int64_t		d_off;
397dab2ed99Sbellard 	unsigned short	d_reclen;
398dab2ed99Sbellard 	unsigned char	d_type;
399dab2ed99Sbellard 	char		d_name[256];
400dab2ed99Sbellard };
401dab2ed99Sbellard 
402dab2ed99Sbellard 
40331e31b8aSbellard /* mostly generic signal stuff */
404992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
405992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
406992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
40731e31b8aSbellard 
40831e31b8aSbellard #ifdef TARGET_MIPS
40931e31b8aSbellard #define TARGET_NSIG	   128
41031e31b8aSbellard #else
41131e31b8aSbellard #define TARGET_NSIG	   64
41231e31b8aSbellard #endif
413992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
41431e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
41531e31b8aSbellard 
41631e31b8aSbellard typedef struct {
417992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
418c227f099SAnthony Liguori } target_sigset_t;
41931e31b8aSbellard 
42066fb9763Sbellard #ifdef BSWAP_NEEDED
421c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
42266fb9763Sbellard {
42366fb9763Sbellard     int i;
42466fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
425cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
42666fb9763Sbellard }
42766fb9763Sbellard #else
428c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
42966fb9763Sbellard {
43066fb9763Sbellard     *d = *s;
43166fb9763Sbellard }
43266fb9763Sbellard #endif
43366fb9763Sbellard 
434c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
43566fb9763Sbellard {
43666fb9763Sbellard     int i;
43766fb9763Sbellard     d->sig[0] = set;
43866fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
43966fb9763Sbellard         d->sig[i] = 0;
44066fb9763Sbellard }
44166fb9763Sbellard 
442c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
443c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
444992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
44566fb9763Sbellard                                const sigset_t *sigset);
44666fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
447992f48a0Sblueswir1                                const abi_ulong *old_sigset);
44866fb9763Sbellard struct target_sigaction;
44966fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
45066fb9763Sbellard                  struct target_sigaction *oact);
45166fb9763Sbellard 
4529850f9f6SLaurent Vivier #include "target_signal.h"
4539850f9f6SLaurent Vivier 
4547f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
4557f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
4567f047de1SRichard Henderson #endif
4577f047de1SRichard Henderson 
4586049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
4596049f4f8SRichard Henderson struct target_old_sigaction {
4606049f4f8SRichard Henderson     abi_ulong _sa_handler;
4616049f4f8SRichard Henderson     abi_ulong sa_mask;
462d2565875SRichard Henderson     int32_t sa_flags;
4636049f4f8SRichard Henderson };
464106ec879Sbellard 
4656049f4f8SRichard Henderson struct target_rt_sigaction {
4666049f4f8SRichard Henderson     abi_ulong _sa_handler;
4676049f4f8SRichard Henderson     abi_ulong sa_flags;
4686049f4f8SRichard Henderson     target_sigset_t sa_mask;
4696049f4f8SRichard Henderson };
4706049f4f8SRichard Henderson 
4716049f4f8SRichard Henderson /* This is the struct used inside the kernel.  The ka_restorer
4726049f4f8SRichard Henderson    field comes from the 5th argument to sys_rt_sigaction.  */
4736049f4f8SRichard Henderson struct target_sigaction {
4746049f4f8SRichard Henderson     abi_ulong _sa_handler;
4756049f4f8SRichard Henderson     abi_ulong sa_flags;
4766049f4f8SRichard Henderson     target_sigset_t sa_mask;
4776049f4f8SRichard Henderson     abi_ulong sa_restorer;
4786049f4f8SRichard Henderson };
4796049f4f8SRichard Henderson #elif defined(TARGET_MIPS)
480106ec879Sbellard struct target_sigaction {
481540635baSths 	uint32_t	sa_flags;
482d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
483540635baSths 	uint32_t	_sa_handler;
484540635baSths #else
485992f48a0Sblueswir1 	abi_ulong	_sa_handler;
486540635baSths #endif
487c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
4887f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
4897f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
4907f047de1SRichard Henderson         abi_ulong sa_restorer;
4917f047de1SRichard Henderson #endif
492106ec879Sbellard };
493106ec879Sbellard #else
4942521d698Sbellard struct target_old_sigaction {
495992f48a0Sblueswir1         abi_ulong _sa_handler;
496992f48a0Sblueswir1         abi_ulong sa_mask;
497992f48a0Sblueswir1         abi_ulong sa_flags;
4987f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
499992f48a0Sblueswir1         abi_ulong sa_restorer;
5007f047de1SRichard Henderson #endif
5012521d698Sbellard };
5022521d698Sbellard 
5032521d698Sbellard struct target_sigaction {
504992f48a0Sblueswir1         abi_ulong _sa_handler;
505992f48a0Sblueswir1         abi_ulong sa_flags;
5067f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
507992f48a0Sblueswir1         abi_ulong sa_restorer;
5087f047de1SRichard Henderson #endif
509c227f099SAnthony Liguori         target_sigset_t sa_mask;
5105de154e8SLaurent Vivier #ifdef TARGET_ARCH_HAS_KA_RESTORER
5115de154e8SLaurent Vivier         abi_ulong ka_restorer;
5125de154e8SLaurent Vivier #endif
5132521d698Sbellard };
514106ec879Sbellard #endif
5152521d698Sbellard 
5162521d698Sbellard typedef union target_sigval {
5172521d698Sbellard 	int sival_int;
518992f48a0Sblueswir1         abi_ulong sival_ptr;
519c227f099SAnthony Liguori } target_sigval_t;
5206d5e216dSbellard #if 0
5216d5e216dSbellard #if defined (TARGET_SPARC)
5226d5e216dSbellard typedef struct {
5236d5e216dSbellard 	struct {
524992f48a0Sblueswir1 		abi_ulong psr;
525992f48a0Sblueswir1 		abi_ulong pc;
526992f48a0Sblueswir1 		abi_ulong npc;
527992f48a0Sblueswir1 		abi_ulong y;
528992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5296d5e216dSbellard 	}		si_regs;
5306d5e216dSbellard 	int		si_mask;
5316d5e216dSbellard } __siginfo_t;
5326d5e216dSbellard 
5336d5e216dSbellard typedef struct {
5346d5e216dSbellard 	unsigned   long si_float_regs [32];
5356d5e216dSbellard 	unsigned   long si_fsr;
5366d5e216dSbellard 	unsigned   long si_fpqdepth;
5376d5e216dSbellard 	struct {
5386d5e216dSbellard 		unsigned long *insn_addr;
5396d5e216dSbellard 		unsigned long insn;
5406d5e216dSbellard 	} si_fpqueue [16];
5416d5e216dSbellard } __siginfo_fpu_t;
5426d5e216dSbellard #endif
5436d5e216dSbellard #endif
5442521d698Sbellard 
5452521d698Sbellard #define TARGET_SI_MAX_SIZE	128
546aa5e03d2SMaxim Ostapenko 
547aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
548aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
549aa5e03d2SMaxim Ostapenko #else
550aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
551aa5e03d2SMaxim Ostapenko #endif
552aa5e03d2SMaxim Ostapenko 
553aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
5542521d698Sbellard 
555a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
556a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
557a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
558a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
559a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
560a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
561a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
562a70dadc7SPeter Maydell  */
563a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
564a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
565a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
566a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
567a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
568a70dadc7SPeter Maydell #define QEMU_SI_RT 5
569a70dadc7SPeter Maydell 
5702521d698Sbellard typedef struct target_siginfo {
5713f53d546Spbrook #ifdef TARGET_MIPS
5723f53d546Spbrook 	int si_signo;
5733f53d546Spbrook 	int si_code;
5743f53d546Spbrook 	int si_errno;
5753f53d546Spbrook #else
5762521d698Sbellard 	int si_signo;
5772521d698Sbellard 	int si_errno;
5782521d698Sbellard 	int si_code;
5793f53d546Spbrook #endif
5802521d698Sbellard 
5812521d698Sbellard 	union {
5822521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
5832521d698Sbellard 
5842521d698Sbellard 		/* kill() */
5852521d698Sbellard 		struct {
5862521d698Sbellard 			pid_t _pid;		/* sender's pid */
5872521d698Sbellard 			uid_t _uid;		/* sender's uid */
5882521d698Sbellard 		} _kill;
5892521d698Sbellard 
5902521d698Sbellard 		/* POSIX.1b timers */
5912521d698Sbellard 		struct {
5922521d698Sbellard 			unsigned int _timer1;
5932521d698Sbellard 			unsigned int _timer2;
5942521d698Sbellard 		} _timer;
5952521d698Sbellard 
5962521d698Sbellard 		/* POSIX.1b signals */
5972521d698Sbellard 		struct {
5982521d698Sbellard 			pid_t _pid;		/* sender's pid */
5992521d698Sbellard 			uid_t _uid;		/* sender's uid */
600c227f099SAnthony Liguori 			target_sigval_t _sigval;
6012521d698Sbellard 		} _rt;
6022521d698Sbellard 
6032521d698Sbellard 		/* SIGCHLD */
6042521d698Sbellard 		struct {
6052521d698Sbellard 			pid_t _pid;		/* which child */
6062521d698Sbellard 			uid_t _uid;		/* sender's uid */
6072521d698Sbellard 			int _status;		/* exit code */
608c227f099SAnthony Liguori 			target_clock_t _utime;
609c227f099SAnthony Liguori                         target_clock_t _stime;
6102521d698Sbellard 		} _sigchld;
6112521d698Sbellard 
6122521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
6132521d698Sbellard 		struct {
614992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
6152521d698Sbellard 		} _sigfault;
6162521d698Sbellard 
6172521d698Sbellard 		/* SIGPOLL */
6182521d698Sbellard 		struct {
6192521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
6202521d698Sbellard 			int _fd;
6212521d698Sbellard 		} _sigpoll;
6222521d698Sbellard 	} _sifields;
623c227f099SAnthony Liguori } target_siginfo_t;
6242521d698Sbellard 
6252521d698Sbellard /*
6262521d698Sbellard  * si_code values
6272521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6282521d698Sbellard  */
6292521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6302521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6312521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6322521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6332521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6342521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6352521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6362521d698Sbellard 
6372521d698Sbellard /*
6382521d698Sbellard  * SIGILL si_codes
6392521d698Sbellard  */
640ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6412521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
642ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
643ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
644ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
645ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
646ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
647ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
648de2fdd56SChen Gang #ifdef TARGET_TILEGX
649de2fdd56SChen Gang #define TARGET_ILL_DBLFLT       (9)     /* double fault */
650de2fdd56SChen Gang #define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
651de2fdd56SChen Gang #endif
6522521d698Sbellard 
6532521d698Sbellard /*
6542521d698Sbellard  * SIGFPE si_codes
6552521d698Sbellard  */
6562521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
6572521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
6582521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
6592521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
6602521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
6612521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
6622521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
6632521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
66421ba8564SRichard Henderson #define TARGET_FPE_FLTUNK      (14) /* undiagnosed fp exception */
66521ba8564SRichard Henderson #define TARGET_NSIGFPE         15
6662521d698Sbellard 
6672521d698Sbellard /*
6682521d698Sbellard  * SIGSEGV si_codes
6692521d698Sbellard  */
6702521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
6712521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
672de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
6732521d698Sbellard 
6742521d698Sbellard /*
675ffa65c3bSbellard  * SIGBUS si_codes
676ffa65c3bSbellard  */
677ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
678b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
679ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
680de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
681de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
682de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
683de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
684ffa65c3bSbellard 
685ffa65c3bSbellard /*
6862521d698Sbellard  * SIGTRAP si_codes
6872521d698Sbellard  */
6882521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
6892521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
690de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
691de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
6922521d698Sbellard 
6939de5e440Sbellard struct target_rlimit {
694992f48a0Sblueswir1         abi_ulong   rlim_cur;
695992f48a0Sblueswir1         abi_ulong   rlim_max;
6969de5e440Sbellard };
6979de5e440Sbellard 
69881bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
699e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
7006cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
70181bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
70281bbe906Stakasi-y@ops.dti.ne.jp #else
70326b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
70481bbe906Stakasi-y@ops.dti.ne.jp #endif
70581bbe906Stakasi-y@ops.dti.ne.jp 
706e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
707e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
708e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
709e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
710e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
711e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
712e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
713e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
714e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
715e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
716e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
717e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
718e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
719e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
720e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
721e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
722e22b7015SWesley W. Terpstra #else
723e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
724e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
725e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
726e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
727e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
728e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7296cafd027SMatthias Braun #if defined(TARGET_SPARC)
7306cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7316cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7326cafd027SMatthias Braun #else
733e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
734e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7356cafd027SMatthias Braun #endif
736e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
737e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
738e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
739e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
740e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
741e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
742e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
743e22b7015SWesley W. Terpstra #endif
744e22b7015SWesley W. Terpstra 
7459de5e440Sbellard struct target_pollfd {
7469de5e440Sbellard     int fd;           /* file descriptor */
7479de5e440Sbellard     short events;     /* requested events */
7489de5e440Sbellard     short revents;    /* returned events */
7499de5e440Sbellard };
7509de5e440Sbellard 
7518e5a0667Sbellard /* virtual terminal ioctls */
7520221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7530221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7548e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
755f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
756f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
757f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7580221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7590221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
760e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
761e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
762e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
763e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
764ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
7658e5a0667Sbellard 
766d14eabbeSAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
767d14eabbeSAleksandar Markovic        defined(TARGET_XTENSA)
7684e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       TARGET_IOR('f', 123, int)
7694e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       TARGET_IOW('f', 124, int)
770e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
771c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
772405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
773e1be1606SAleksandar Markovic #else
7744e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       0x8903
7754e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       0x8901
7762521d698Sbellard #define TARGET_SIOCATMARK      0x8905
777c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       0x8902
778405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
779e1be1606SAleksandar Markovic #endif
780c495a793SAleksandar Markovic 
7816d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SH4)
7826d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   TARGET_IOR('s', 100, struct target_timeval)
7836d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
7846d5d5ddeSDaniel P. Berrangé #else
7856d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   0x8906
7866d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD 0x8907
7876d5d5ddeSDaniel P. Berrangé #endif
7886d5d5ddeSDaniel P. Berrangé 
7896d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_NEW   TARGET_IOR(0x89, 0x06, abi_llong[2])
7906d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
7912521d698Sbellard 
79231e31b8aSbellard /* Networking ioctls */
79331e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
79431e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
79531e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
79631e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
79731e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
79831e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
79931e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
80031e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
80131e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
80231e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
80331e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
80431e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
80531e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
80631e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
80731e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
80831e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
80931e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
81031e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
81131e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
81231e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
81331e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
81431e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
81531e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
81631e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
81731e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
81831e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
81931e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
82031e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
82131e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
822f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
8234bdcd79eSNeng Chen #define TARGET_SIOCSIFPFLAGS   0x8934          /* set extended flags          */
8244bdcd79eSNeng Chen #define TARGET_SIOCGIFPFLAGS   0x8935          /* get extended flags          */
82531e31b8aSbellard 
82631e31b8aSbellard /* Bridging control calls */
82731e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
82831e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
82931e31b8aSbellard 
83031e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
83131e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
83231e31b8aSbellard 
83331e31b8aSbellard /* ARP cache control calls. */
83431e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
83531e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
83631e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
83731e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
83831e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
83931e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
84031e31b8aSbellard 
84131e31b8aSbellard /* RARP cache control calls. */
84231e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
84331e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
84431e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
84531e31b8aSbellard 
84631e31b8aSbellard /* Driver configuration calls */
84731e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
84831e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
84931e31b8aSbellard 
85031e31b8aSbellard /* DLCI configuration calls */
85131e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
85231e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
85331e31b8aSbellard 
85486fcd946SLaurent Vivier /* From <linux/wireless.h> */
85586fcd946SLaurent Vivier 
85686fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
85731e31b8aSbellard 
858d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
859d6d6d6feSMarco A L Barbosa 
860d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
861d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
862d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
863d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
86492c096f0SAleksandar Markovic #define TARGET_RNDRESEEDCRNG   TARGET_IO('R', 0x07)
865d6d6d6feSMarco A L Barbosa 
86631e31b8aSbellard /* From <linux/fs.h> */
86731e31b8aSbellard 
86831e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
86931e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
87031e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
87131e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
87231e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
87331e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
87431e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
87531e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
87631e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
87731e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
87831e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
87931e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
880fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
88131e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
882c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
883c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
884edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
885edafea13SAlexander Graf                                              /* return device size in bytes
886edafea13SAlexander Graf                                                 (u64 *arg) */
8874715856aSPeter Maydell 
8884715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
8894715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
8904715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
8914715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
8924715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
8934715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
8944715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
8954715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
8964715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
8974715856aSPeter Maydell 
898ab22b4ddSYunqiang Su /* From <linux/fd.h> */
899ab22b4ddSYunqiang Su 
9007e35fc8bSAleksandar Markovic #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
9017e35fc8bSAleksandar Markovic #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
902*08e3ce59SAleksandar Markovic #define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
903*08e3ce59SAleksandar Markovic #define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct format_descr)
904*08e3ce59SAleksandar Markovic #define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
90581eb1a36SAleksandar Markovic #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
906ab22b4ddSYunqiang Su #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
90781eb1a36SAleksandar Markovic #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
90881eb1a36SAleksandar Markovic #define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
9095eea9429SAleksandar Markovic #define TARGET_FDRESET        TARGET_IO(2, 0x54)
9105eea9429SAleksandar Markovic #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
9115eea9429SAleksandar Markovic #define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
9125eea9429SAleksandar Markovic #define TARGET_FDEJECT        TARGET_IO(2, 0x5a)
913ab22b4ddSYunqiang Su 
91431e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
91531e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
91621992cb6SHelge Deller 
91721992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
91821992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
91921992cb6SHelge Deller 
9205ae774a9SAleksandar Markovic /*
9215ae774a9SAleksandar Markovic  * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
9225ae774a9SAleksandar Markovic  * claim type "long" but the actual type used by the kernel is "int".
92360807231SPeter Maydell  */
9241847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
9251847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
9265ae774a9SAleksandar Markovic #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
9275ae774a9SAleksandar Markovic #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
928285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
9290b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
9300b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
9310d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
9320d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
93331e31b8aSbellard 
9346c753a63SCortland Tölva /* usb ioctls */
9356c753a63SCortland Tölva #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
9366c753a63SCortland Tölva #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
9376c753a63SCortland Tölva #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
9386c753a63SCortland Tölva #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
9396c753a63SCortland Tölva #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U',  5)
9406c753a63SCortland Tölva #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
941a133367eSCortland Tölva #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
942a133367eSCortland Tölva #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
943a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
944a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
9456c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
9466c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
9476c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
9486c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
9496c753a63SCortland Tölva #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
9506c753a63SCortland Tölva #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
9516c753a63SCortland Tölva #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
9526c753a63SCortland Tölva #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
9536c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
9546c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
9556c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
9566c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
9576c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
9586c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
9596c753a63SCortland Tölva #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
9606c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
9616c753a63SCortland Tölva 
96231e31b8aSbellard /* cdrom commands */
96331e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
96431e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
96531e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
96631e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
96731e31b8aSbellard                                            (struct cdrom_ti) */
96831e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
96931e31b8aSbellard                                            (struct cdrom_tochdr) */
97031e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
97131e31b8aSbellard                                            (struct cdrom_tocentry) */
97231e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
97331e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
97431e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
97531e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
97631e31b8aSbellard                                            (struct cdrom_volctrl) */
97731e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
97831e31b8aSbellard                                            (struct cdrom_subchnl) */
97931e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
98031e31b8aSbellard                                            (struct cdrom_read) */
98131e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
98231e31b8aSbellard                                            (struct cdrom_read) */
98331e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
98431e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
98531e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
98631e31b8aSbellard                                            address of multi session disks
98731e31b8aSbellard                                            (struct cdrom_multisession) */
98831e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
98931e31b8aSbellard                                            if available (struct cdrom_mcn) */
99067cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
991b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
99231e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
99331e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
99431e31b8aSbellard                                           (struct cdrom_volctrl) */
99531e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
99631e31b8aSbellard                                            (struct cdrom_read) */
99731e31b8aSbellard /*
99831e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
99931e31b8aSbellard  */
100031e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
100131e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
100231e31b8aSbellard 
100331e31b8aSbellard /*
100431e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
100531e31b8aSbellard    It is for playing audio in logical block addressing mode.
100631e31b8aSbellard  */
100731e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
100831e31b8aSbellard 
100931e31b8aSbellard /*
101031e31b8aSbellard  * These ioctls are only used in optcd.c
101131e31b8aSbellard  */
101231e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
101331e31b8aSbellard 
101431e31b8aSbellard /*
101531e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
101631e31b8aSbellard  * drive spindown time.  They should be implemented in the
101731e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
101831e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
101931e31b8aSbellard  *  -Erik
102031e31b8aSbellard  */
102131e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
102231e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
102331e31b8aSbellard 
102431e31b8aSbellard /*
102531e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
102631e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
102731e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
102831e31b8aSbellard  */
102931e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
103031e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
103131e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
103231e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
103331e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
103431e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
103531e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
103631e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
103731e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
103831e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
103931e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
104031e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
104131e31b8aSbellard 
104231e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
104331e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
104431e31b8aSbellard  */
104531e31b8aSbellard 
104631e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
104731e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
104831e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
104931e31b8aSbellard 
105031e31b8aSbellard /* DVD-ROM Specific ioctls */
105131e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
105231e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
105331e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
105431e31b8aSbellard 
105531e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
105631e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
105731e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
105831e31b8aSbellard 
105931e31b8aSbellard /* HD commands */
106031e31b8aSbellard 
106131e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
106231e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
106331e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
106431e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
106531e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
106631e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
106731e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
106831e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
10692521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
107031e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
107131e31b8aSbellard 
107231e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
107331e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
107431e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
107531e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
107631e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
107731e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
107831e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
107931e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
10802521d698Sbellard 
1081b8005914Sbalrog /* loop ioctls */
1082b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1083b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1084b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1085b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1086b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1087b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1088b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
10892521d698Sbellard 
1090884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1091884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1092884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1093884cdc48SPeter Maydell 
1094f7680a55SUlrich Hecht /* fb ioctls */
1095f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1096f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1097f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
109812b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
109912b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
110012b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
110112b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
110212b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1103f7680a55SUlrich Hecht 
1104f7680a55SUlrich Hecht /* vt ioctls */
1105f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1106f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1107f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1108f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1109f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1110f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1111774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1112774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1113774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1114774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1115f7680a55SUlrich Hecht 
111656e904ecSAlexander Graf /* device mapper */
111756e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
111856e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
111956e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
112056e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
112156e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
112256e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
112356e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
112456e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
112556e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
112656e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
112756e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
112856e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
112956e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
113056e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
113156e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
113256e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
113356e904ecSAlexander Graf 
11342521d698Sbellard /* from asm/termbits.h */
11352521d698Sbellard 
11363bfd9da1Sbellard #define TARGET_NCC 8
11373bfd9da1Sbellard struct target_termio {
11383bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
11393bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
11403bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
11413bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
11422521d698Sbellard 	unsigned char c_line;		/* line discipline */
11433bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
11442521d698Sbellard };
11452521d698Sbellard 
11463bfd9da1Sbellard struct target_winsize {
11473bfd9da1Sbellard 	unsigned short ws_row;
11483bfd9da1Sbellard 	unsigned short ws_col;
11493bfd9da1Sbellard 	unsigned short ws_xpixel;
11503bfd9da1Sbellard 	unsigned short ws_ypixel;
11513bfd9da1Sbellard };
11522521d698Sbellard 
11533bfd9da1Sbellard #include "termbits.h"
11542521d698Sbellard 
11559e0b74a4SPaul Brook #if defined(TARGET_MIPS)
11569e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
11579e0b74a4SPaul Brook #else
11589e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
11599e0b74a4SPaul Brook #endif
11609e0b74a4SPaul Brook 
1161e44a3e79Saurel32 /* Common */
11622521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
11632521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1164e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1165e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1166e65be6a7SHelge Deller #else
11672521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1168e65be6a7SHelge Deller #endif
1169e44a3e79Saurel32 
1170e44a3e79Saurel32 /* Target specific */
1171048f6b4dSbellard #if defined(TARGET_MIPS)
1172e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1173048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1174048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1175048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1176048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1177048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1178048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1179540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1180540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1181541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1182541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1183e44a3e79Saurel32 #elif defined(TARGET_PPC)
1184e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
11852521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
11862521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
11872521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
11882521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
11897ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
11907ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1191e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1192e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1193541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1194541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1195e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1196e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1197e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1198e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1199e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1200e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1201e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1202e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1203e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1204e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1205541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1206541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1207a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1208a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1209a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1210a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1211a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1212a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1213a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1214a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1215a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1216a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1217541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1218541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1219ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1220ba7651fbSMax Filippov #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1221ba7651fbSMax Filippov #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1222ba7651fbSMax Filippov #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1223ba7651fbSMax Filippov #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1224ba7651fbSMax Filippov #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1225ba7651fbSMax Filippov #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1226ba7651fbSMax Filippov #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1227ba7651fbSMax Filippov #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1228ba7651fbSMax Filippov #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1229ba7651fbSMax Filippov #define TARGET_MAP_STACK	0x40000
1230ba7651fbSMax Filippov #define TARGET_MAP_HUGETLB  0x80000         /* create a huge page mapping */
12317ec93196Sj_mayer #else
1232e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1233e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1234e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1235e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1236e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
12372521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
12382521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1239540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1240540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1241541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1242541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1243906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
12447ec93196Sj_mayer #endif
12452521d698Sbellard 
124609701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
124709701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1248daa4374aSPeter Maydell     || defined(TARGET_CRIS)
12495f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
12502521d698Sbellard struct target_stat {
12512521d698Sbellard 	unsigned short st_dev;
12522521d698Sbellard 	unsigned short __pad1;
1253992f48a0Sblueswir1 	abi_ulong st_ino;
12542521d698Sbellard 	unsigned short st_mode;
12552521d698Sbellard 	unsigned short st_nlink;
12562521d698Sbellard 	unsigned short st_uid;
12572521d698Sbellard 	unsigned short st_gid;
12582521d698Sbellard 	unsigned short st_rdev;
12592521d698Sbellard 	unsigned short __pad2;
1260992f48a0Sblueswir1 	abi_ulong  st_size;
1261992f48a0Sblueswir1 	abi_ulong  st_blksize;
1262992f48a0Sblueswir1 	abi_ulong  st_blocks;
1263992f48a0Sblueswir1 	abi_ulong  target_st_atime;
12645f992db6SChen-Yu Tsai 	abi_ulong  target_st_atime_nsec;
1265992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
12665f992db6SChen-Yu Tsai 	abi_ulong  target_st_mtime_nsec;
1267992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
12685f992db6SChen-Yu Tsai 	abi_ulong  target_st_ctime_nsec;
1269992f48a0Sblueswir1 	abi_ulong  __unused4;
1270992f48a0Sblueswir1 	abi_ulong  __unused5;
12712521d698Sbellard };
12722521d698Sbellard 
12732521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
12742521d698Sbellard  * insane amounts of padding around dev_t's.
12752521d698Sbellard  */
127620d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
12772521d698Sbellard struct target_stat64 {
12782521d698Sbellard 	unsigned short	st_dev;
12792521d698Sbellard 	unsigned char	__pad0[10];
12802521d698Sbellard 
12812521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1282992f48a0Sblueswir1 	abi_ulong	__st_ino;
12832521d698Sbellard 
12842521d698Sbellard 	unsigned int	st_mode;
12852521d698Sbellard 	unsigned int	st_nlink;
12862521d698Sbellard 
1287992f48a0Sblueswir1 	abi_ulong	st_uid;
1288992f48a0Sblueswir1 	abi_ulong	st_gid;
12892521d698Sbellard 
12902521d698Sbellard 	unsigned short	st_rdev;
12912521d698Sbellard 	unsigned char	__pad3[10];
12922521d698Sbellard 
12932521d698Sbellard 	long long	st_size;
1294992f48a0Sblueswir1 	abi_ulong	st_blksize;
12952521d698Sbellard 
1296992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1297992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
12982521d698Sbellard 
1299992f48a0Sblueswir1 	abi_ulong	target_st_atime;
13005f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
13012521d698Sbellard 
1302992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
13035f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
13042521d698Sbellard 
1305992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
13065f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
13072521d698Sbellard 
13082521d698Sbellard 	unsigned long long	st_ino;
1309541dc0d4SStefan Weil } QEMU_PACKED;
13102521d698Sbellard 
1311ce4defa0Spbrook #ifdef TARGET_ARM
131220d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1313ce4defa0Spbrook struct target_eabi_stat64 {
1314ce4defa0Spbrook         unsigned long long st_dev;
1315ce4defa0Spbrook         unsigned int    __pad1;
1316992f48a0Sblueswir1         abi_ulong    __st_ino;
1317ce4defa0Spbrook         unsigned int    st_mode;
1318ce4defa0Spbrook         unsigned int    st_nlink;
1319ce4defa0Spbrook 
1320992f48a0Sblueswir1         abi_ulong    st_uid;
1321992f48a0Sblueswir1         abi_ulong    st_gid;
1322ce4defa0Spbrook 
1323ce4defa0Spbrook         unsigned long long st_rdev;
1324ce4defa0Spbrook         unsigned int    __pad2[2];
1325ce4defa0Spbrook 
1326ce4defa0Spbrook         long long       st_size;
1327992f48a0Sblueswir1         abi_ulong    st_blksize;
1328ce4defa0Spbrook         unsigned int    __pad3;
1329ce4defa0Spbrook         unsigned long long st_blocks;
1330ce4defa0Spbrook 
1331992f48a0Sblueswir1         abi_ulong    target_st_atime;
1332992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1333ce4defa0Spbrook 
1334992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1335992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1336ce4defa0Spbrook 
1337992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1338992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1339ce4defa0Spbrook 
1340ce4defa0Spbrook         unsigned long long st_ino;
1341541dc0d4SStefan Weil } QEMU_PACKED;
1342ce4defa0Spbrook #endif
1343ce4defa0Spbrook 
1344992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
13451b8dd648Sblueswir1 struct target_stat {
13461b8dd648Sblueswir1 	unsigned int	st_dev;
1347992f48a0Sblueswir1 	abi_ulong	st_ino;
13481b8dd648Sblueswir1 	unsigned int	st_mode;
13491b8dd648Sblueswir1 	unsigned int	st_nlink;
13501b8dd648Sblueswir1 	unsigned int	st_uid;
13511b8dd648Sblueswir1 	unsigned int	st_gid;
13521b8dd648Sblueswir1 	unsigned int	st_rdev;
1353992f48a0Sblueswir1 	abi_long	st_size;
1354992f48a0Sblueswir1 	abi_long	target_st_atime;
1355992f48a0Sblueswir1 	abi_long	target_st_mtime;
1356992f48a0Sblueswir1 	abi_long	target_st_ctime;
1357992f48a0Sblueswir1 	abi_long	st_blksize;
1358992f48a0Sblueswir1 	abi_long	st_blocks;
1359992f48a0Sblueswir1 	abi_ulong	__unused4[2];
13601b8dd648Sblueswir1 };
13611b8dd648Sblueswir1 
136220d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
13631b8dd648Sblueswir1 struct target_stat64 {
13641b8dd648Sblueswir1 	unsigned char	__pad0[6];
13651b8dd648Sblueswir1 	unsigned short	st_dev;
13661b8dd648Sblueswir1 
13671b8dd648Sblueswir1 	uint64_t	st_ino;
13681b8dd648Sblueswir1 	uint64_t	st_nlink;
13691b8dd648Sblueswir1 
13701b8dd648Sblueswir1 	unsigned int	st_mode;
13711b8dd648Sblueswir1 
13721b8dd648Sblueswir1 	unsigned int	st_uid;
13731b8dd648Sblueswir1 	unsigned int	st_gid;
13741b8dd648Sblueswir1 
13751b8dd648Sblueswir1 	unsigned char	__pad2[6];
13761b8dd648Sblueswir1 	unsigned short	st_rdev;
13771b8dd648Sblueswir1 
13781b8dd648Sblueswir1         int64_t		st_size;
13791b8dd648Sblueswir1 	int64_t		st_blksize;
13801b8dd648Sblueswir1 
13811b8dd648Sblueswir1 	unsigned char	__pad4[4];
13821b8dd648Sblueswir1 	unsigned int	st_blocks;
13831b8dd648Sblueswir1 
1384992f48a0Sblueswir1 	abi_ulong	target_st_atime;
13855f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
13861b8dd648Sblueswir1 
1387992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
13885f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
13891b8dd648Sblueswir1 
1390992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
13915f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
13921b8dd648Sblueswir1 
1393992f48a0Sblueswir1 	abi_ulong	__unused4[3];
13941b8dd648Sblueswir1 };
13951b8dd648Sblueswir1 
13963bfd9da1Sbellard #elif defined(TARGET_SPARC)
13973bfd9da1Sbellard 
13985f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
13993bfd9da1Sbellard struct target_stat {
14003bfd9da1Sbellard 	unsigned short	st_dev;
1401992f48a0Sblueswir1 	abi_ulong	st_ino;
14023bfd9da1Sbellard 	unsigned short	st_mode;
14033bfd9da1Sbellard 	short		st_nlink;
14043bfd9da1Sbellard 	unsigned short	st_uid;
14053bfd9da1Sbellard 	unsigned short	st_gid;
14063bfd9da1Sbellard 	unsigned short	st_rdev;
1407992f48a0Sblueswir1 	abi_long	st_size;
1408992f48a0Sblueswir1 	abi_long	target_st_atime;
14095f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
1410992f48a0Sblueswir1 	abi_long	target_st_mtime;
14115f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
1412992f48a0Sblueswir1 	abi_long	target_st_ctime;
14135f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
1414992f48a0Sblueswir1 	abi_long	st_blksize;
1415992f48a0Sblueswir1 	abi_long	st_blocks;
14165f992db6SChen-Yu Tsai 	abi_ulong	__unused1[2];
14173bfd9da1Sbellard };
14183bfd9da1Sbellard 
141920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14203bfd9da1Sbellard struct target_stat64 {
14213bfd9da1Sbellard 	unsigned char	__pad0[6];
14223bfd9da1Sbellard 	unsigned short	st_dev;
14233bfd9da1Sbellard 
14243bfd9da1Sbellard 	uint64_t st_ino;
14253bfd9da1Sbellard 
14263bfd9da1Sbellard 	unsigned int	st_mode;
14273bfd9da1Sbellard 	unsigned int	st_nlink;
14283bfd9da1Sbellard 
14293bfd9da1Sbellard 	unsigned int	st_uid;
14303bfd9da1Sbellard 	unsigned int	st_gid;
14313bfd9da1Sbellard 
14323bfd9da1Sbellard 	unsigned char	__pad2[6];
14333bfd9da1Sbellard 	unsigned short	st_rdev;
14343bfd9da1Sbellard 
14353bfd9da1Sbellard 	unsigned char	__pad3[8];
14363bfd9da1Sbellard 
14373bfd9da1Sbellard         int64_t	st_size;
14383bfd9da1Sbellard 	unsigned int	st_blksize;
14393bfd9da1Sbellard 
14403bfd9da1Sbellard 	unsigned char	__pad4[8];
14413bfd9da1Sbellard 	unsigned int	st_blocks;
14423bfd9da1Sbellard 
14433bfd9da1Sbellard 	unsigned int	target_st_atime;
14445f992db6SChen-Yu Tsai 	unsigned int	target_st_atime_nsec;
14453bfd9da1Sbellard 
14463bfd9da1Sbellard 	unsigned int	target_st_mtime;
14475f992db6SChen-Yu Tsai 	unsigned int	target_st_mtime_nsec;
14483bfd9da1Sbellard 
14493bfd9da1Sbellard 	unsigned int	target_st_ctime;
14505f992db6SChen-Yu Tsai 	unsigned int	target_st_ctime_nsec;
14513bfd9da1Sbellard 
14525f992db6SChen-Yu Tsai 	unsigned int	__unused1;
14535f992db6SChen-Yu Tsai 	unsigned int	__unused2;
14543bfd9da1Sbellard };
14553bfd9da1Sbellard 
145667867308Sbellard #elif defined(TARGET_PPC)
145767867308Sbellard 
14585f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
145967867308Sbellard struct target_stat {
1460e32448e0Sj_mayer 	abi_ulong st_dev;
1461992f48a0Sblueswir1 	abi_ulong st_ino;
1462325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1463e32448e0Sj_mayer 	abi_ulong st_nlink;
1464325e651fSj_mayer 	unsigned int st_mode;
1465325e651fSj_mayer #else
146667867308Sbellard 	unsigned int st_mode;
146767867308Sbellard 	unsigned short st_nlink;
1468325e651fSj_mayer #endif
146967867308Sbellard 	unsigned int st_uid;
147067867308Sbellard 	unsigned int st_gid;
1471e32448e0Sj_mayer 	abi_ulong  st_rdev;
1472992f48a0Sblueswir1 	abi_ulong  st_size;
1473992f48a0Sblueswir1 	abi_ulong  st_blksize;
1474992f48a0Sblueswir1 	abi_ulong  st_blocks;
1475992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1476e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1477992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1478e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1479992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1480e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1481992f48a0Sblueswir1 	abi_ulong  __unused4;
1482992f48a0Sblueswir1 	abi_ulong  __unused5;
1483325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1484325e651fSj_mayer 	abi_ulong  __unused6;
1485325e651fSj_mayer #endif
148667867308Sbellard };
148767867308Sbellard 
148820d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
148920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1490541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
149167867308Sbellard 	unsigned long long st_dev;
149267867308Sbellard         unsigned long long st_ino;
149367867308Sbellard 	unsigned int st_mode;
149467867308Sbellard 	unsigned int st_nlink;
149567867308Sbellard 	unsigned int st_uid;
149667867308Sbellard 	unsigned int st_gid;
149767867308Sbellard 	unsigned long long st_rdev;
1498e1ce5e40Saurel32 	unsigned long long __pad0;
149967867308Sbellard 	long long      st_size;
1500e32448e0Sj_mayer 	int	       st_blksize;
1501e1ce5e40Saurel32 	unsigned int   __pad1;
150261322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1503e32448e0Sj_mayer 	int	       target_st_atime;
1504e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1505e32448e0Sj_mayer 	int	       target_st_mtime;
1506e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1507e32448e0Sj_mayer 	int            target_st_ctime;
1508e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1509e32448e0Sj_mayer         unsigned int   __unused4;
1510e32448e0Sj_mayer         unsigned int   __unused5;
151167867308Sbellard };
151220d155bcSStefan Weil #endif
151367867308Sbellard 
1514b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1515b779e29eSEdgar E. Iglesias 
15165f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1517b779e29eSEdgar E. Iglesias struct target_stat {
1518b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1519b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1520b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1521b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1522b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1523b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1524b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1525b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1526b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1527b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1528b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1529b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1530b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1531b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1532b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1533b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1534b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1535b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1536b779e29eSEdgar E. Iglesias };
1537b779e29eSEdgar E. Iglesias 
1538b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
153920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1540541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1541b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1542a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1543a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1544a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1545a523eb06SEdgar E. Iglesias 
1546b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1547b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1548b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1549b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1550b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
155121ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1552b779e29eSEdgar E. Iglesias 
1553b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1554b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
155521ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1556b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1557b779e29eSEdgar E. Iglesias 
1558b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1559b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1560b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1561b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1562b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1563b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1564a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1565b779e29eSEdgar E. Iglesias };
1566b779e29eSEdgar E. Iglesias 
1567e6e5906bSpbrook #elif defined(TARGET_M68K)
1568e6e5906bSpbrook 
1569e6e5906bSpbrook struct target_stat {
1570e6e5906bSpbrook 	unsigned short st_dev;
1571e6e5906bSpbrook 	unsigned short __pad1;
1572992f48a0Sblueswir1 	abi_ulong st_ino;
1573e6e5906bSpbrook 	unsigned short st_mode;
1574e6e5906bSpbrook 	unsigned short st_nlink;
1575e6e5906bSpbrook 	unsigned short st_uid;
1576e6e5906bSpbrook 	unsigned short st_gid;
1577e6e5906bSpbrook 	unsigned short st_rdev;
1578e6e5906bSpbrook 	unsigned short __pad2;
1579992f48a0Sblueswir1 	abi_ulong  st_size;
1580992f48a0Sblueswir1 	abi_ulong  st_blksize;
1581992f48a0Sblueswir1 	abi_ulong  st_blocks;
1582992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1583992f48a0Sblueswir1 	abi_ulong  __unused1;
1584992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1585992f48a0Sblueswir1 	abi_ulong  __unused2;
1586992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1587992f48a0Sblueswir1 	abi_ulong  __unused3;
1588992f48a0Sblueswir1 	abi_ulong  __unused4;
1589992f48a0Sblueswir1 	abi_ulong  __unused5;
1590e6e5906bSpbrook };
1591e6e5906bSpbrook 
1592e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1593e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1594e6e5906bSpbrook  */
159520d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1596e6e5906bSpbrook struct target_stat64 {
1597e6e5906bSpbrook 	unsigned long long	st_dev;
1598e6e5906bSpbrook 	unsigned char	__pad1[2];
1599e6e5906bSpbrook 
1600e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1601992f48a0Sblueswir1 	abi_ulong	__st_ino;
1602e6e5906bSpbrook 
1603e6e5906bSpbrook 	unsigned int	st_mode;
1604e6e5906bSpbrook 	unsigned int	st_nlink;
1605e6e5906bSpbrook 
1606992f48a0Sblueswir1 	abi_ulong	st_uid;
1607992f48a0Sblueswir1 	abi_ulong	st_gid;
1608e6e5906bSpbrook 
1609e6e5906bSpbrook 	unsigned long long	st_rdev;
1610e6e5906bSpbrook 	unsigned char	__pad3[2];
1611e6e5906bSpbrook 
1612e6e5906bSpbrook 	long long	st_size;
1613992f48a0Sblueswir1 	abi_ulong	st_blksize;
1614e6e5906bSpbrook 
1615992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1616992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1617e6e5906bSpbrook 
1618992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1619992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1620e6e5906bSpbrook 
1621992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1622992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1623e6e5906bSpbrook 
1624992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1625992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1626e6e5906bSpbrook 
1627e6e5906bSpbrook 	unsigned long long	st_ino;
1628541dc0d4SStefan Weil } QEMU_PACKED;
1629e6e5906bSpbrook 
1630d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1631540635baSths 
16325f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1633540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1634540635baSths struct target_stat {
1635540635baSths 	unsigned int		st_dev;
1636540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1637540635baSths 
1638992f48a0Sblueswir1 	abi_ulong		st_ino;
1639540635baSths 
1640540635baSths 	unsigned int		st_mode;
1641540635baSths 	unsigned int		st_nlink;
1642540635baSths 
1643540635baSths 	int			st_uid;
1644540635baSths 	int			st_gid;
1645540635baSths 
1646540635baSths 	unsigned int		st_rdev;
1647540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1648540635baSths 
1649992f48a0Sblueswir1 	abi_ulong		st_size;
1650540635baSths 
1651540635baSths 	/*
1652540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1653540635baSths 	 * but we don't have it under Linux.
1654540635baSths 	 */
1655540635baSths 	unsigned int		target_st_atime;
1656540635baSths 	unsigned int		target_st_atime_nsec;
1657540635baSths 
1658540635baSths 	unsigned int		target_st_mtime;
1659540635baSths 	unsigned int		target_st_mtime_nsec;
1660540635baSths 
1661540635baSths 	unsigned int		target_st_ctime;
1662540635baSths 	unsigned int		target_st_ctime_nsec;
1663540635baSths 
1664540635baSths 	unsigned int		st_blksize;
1665540635baSths 	unsigned int		st_pad2;
1666540635baSths 
1667992f48a0Sblueswir1 	abi_ulong		st_blocks;
1668540635baSths };
1669540635baSths 
1670d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1671540635baSths 
16725f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1673540635baSths struct target_stat {
16741ab2aea2SLeon Alrae         abi_ulong    st_dev;
16751ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
16761ab2aea2SLeon Alrae         uint64_t     st_ino;
1677540635baSths         unsigned int st_mode;
1678540635baSths         unsigned int st_nlink;
1679540635baSths         int          st_uid;
1680540635baSths         int          st_gid;
16811ab2aea2SLeon Alrae         abi_ulong    st_rdev;
16821ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
16831ab2aea2SLeon Alrae         int64_t      st_size;
16841ab2aea2SLeon Alrae         abi_long     target_st_atime;
16851ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
16861ab2aea2SLeon Alrae         abi_long     target_st_mtime;
16871ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
16881ab2aea2SLeon Alrae         abi_long     target_st_ctime;
16891ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
16901ab2aea2SLeon Alrae         abi_ulong    st_blksize;
16911ab2aea2SLeon Alrae         abi_ulong    st_pad2;
16921ab2aea2SLeon Alrae         int64_t      st_blocks;
1693540635baSths };
1694540635baSths 
1695d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1696048f6b4dSbellard 
16975f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1698048f6b4dSbellard struct target_stat {
1699048f6b4dSbellard 	unsigned	st_dev;
1700992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1701992f48a0Sblueswir1 	abi_ulong	st_ino;
1702048f6b4dSbellard 	unsigned int	st_mode;
1703048f6b4dSbellard 	unsigned int	st_nlink;
1704048f6b4dSbellard 	int		st_uid;
1705048f6b4dSbellard 	int		st_gid;
1706048f6b4dSbellard 	unsigned 	st_rdev;
1707992f48a0Sblueswir1 	abi_long	st_pad2[2];
1708992f48a0Sblueswir1 	abi_long	st_size;
1709992f48a0Sblueswir1 	abi_long	st_pad3;
1710048f6b4dSbellard 	/*
1711048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1712048f6b4dSbellard 	 * but we don't have it under Linux.
1713048f6b4dSbellard 	 */
1714992f48a0Sblueswir1 	abi_long		target_st_atime;
1715992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1716992f48a0Sblueswir1 	abi_long		target_st_mtime;
1717992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1718992f48a0Sblueswir1 	abi_long		target_st_ctime;
1719992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1720992f48a0Sblueswir1 	abi_long		st_blksize;
1721992f48a0Sblueswir1 	abi_long		st_blocks;
1722992f48a0Sblueswir1 	abi_long		st_pad4[14];
1723048f6b4dSbellard };
1724048f6b4dSbellard 
1725048f6b4dSbellard /*
1726048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1727048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1728048f6b4dSbellard  * struct stat of the 64-bit kernel.
1729048f6b4dSbellard  */
1730048f6b4dSbellard 
173120d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1732048f6b4dSbellard struct target_stat64 {
1733992f48a0Sblueswir1 	abi_ulong	st_dev;
1734992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1735048f6b4dSbellard 
1736048f6b4dSbellard 	uint64_t	st_ino;
1737048f6b4dSbellard 
1738048f6b4dSbellard         unsigned int	st_mode;
1739048f6b4dSbellard         unsigned int	st_nlink;
1740048f6b4dSbellard 
1741048f6b4dSbellard 	int		st_uid;
1742048f6b4dSbellard 	int		st_gid;
1743048f6b4dSbellard 
1744992f48a0Sblueswir1 	abi_ulong	st_rdev;
1745992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1746048f6b4dSbellard 
1747048f6b4dSbellard 	int64_t 	st_size;
1748048f6b4dSbellard 
1749048f6b4dSbellard 	/*
1750048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1751048f6b4dSbellard 	 * but we don't have it under Linux.
1752048f6b4dSbellard 	 */
1753992f48a0Sblueswir1 	abi_long	target_st_atime;
1754992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1755048f6b4dSbellard 
1756992f48a0Sblueswir1 	abi_long	target_st_mtime;
1757992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1758048f6b4dSbellard 
1759992f48a0Sblueswir1 	abi_long	target_st_ctime;
1760992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1761048f6b4dSbellard 
1762992f48a0Sblueswir1 	abi_ulong	st_blksize;
1763992f48a0Sblueswir1 	abi_ulong	st_pad2;
1764048f6b4dSbellard 
1765048f6b4dSbellard 	int64_t  	st_blocks;
1766048f6b4dSbellard };
17677a3148a9Sj_mayer 
17687a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
17697a3148a9Sj_mayer 
17707a3148a9Sj_mayer struct target_stat {
17717a3148a9Sj_mayer        unsigned int    st_dev;
17727a3148a9Sj_mayer        unsigned int    st_ino;
17737a3148a9Sj_mayer        unsigned int    st_mode;
17747a3148a9Sj_mayer        unsigned int    st_nlink;
17757a3148a9Sj_mayer        unsigned int    st_uid;
17767a3148a9Sj_mayer        unsigned int    st_gid;
17777a3148a9Sj_mayer        unsigned int    st_rdev;
1778992f48a0Sblueswir1        abi_long     st_size;
1779992f48a0Sblueswir1        abi_ulong    target_st_atime;
1780992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1781992f48a0Sblueswir1        abi_ulong    target_st_ctime;
17827a3148a9Sj_mayer        unsigned int    st_blksize;
17837a3148a9Sj_mayer        unsigned int    st_blocks;
17847a3148a9Sj_mayer        unsigned int    st_flags;
17857a3148a9Sj_mayer        unsigned int    st_gen;
17867a3148a9Sj_mayer };
17877a3148a9Sj_mayer 
178820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
17897a3148a9Sj_mayer struct target_stat64 {
1790992f48a0Sblueswir1        abi_ulong    st_dev;
1791992f48a0Sblueswir1        abi_ulong    st_ino;
1792992f48a0Sblueswir1        abi_ulong    st_rdev;
1793992f48a0Sblueswir1        abi_long     st_size;
1794992f48a0Sblueswir1        abi_ulong    st_blocks;
17957a3148a9Sj_mayer 
17967a3148a9Sj_mayer        unsigned int    st_mode;
17977a3148a9Sj_mayer        unsigned int    st_uid;
17987a3148a9Sj_mayer        unsigned int    st_gid;
17997a3148a9Sj_mayer        unsigned int    st_blksize;
18007a3148a9Sj_mayer        unsigned int    st_nlink;
18017a3148a9Sj_mayer        unsigned int    __pad0;
18027a3148a9Sj_mayer 
1803992f48a0Sblueswir1        abi_ulong    target_st_atime;
1804992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1805992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1806992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1807992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1808992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1809992f48a0Sblueswir1        abi_long     __unused[3];
18107a3148a9Sj_mayer };
18117a3148a9Sj_mayer 
18126db45e65Sths #elif defined(TARGET_SH4)
18136db45e65Sths 
18145f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
18156db45e65Sths struct target_stat {
1816992f48a0Sblueswir1 	abi_ulong  st_dev;
1817992f48a0Sblueswir1 	abi_ulong  st_ino;
18186db45e65Sths 	unsigned short st_mode;
18196db45e65Sths 	unsigned short st_nlink;
18206db45e65Sths 	unsigned short st_uid;
18216db45e65Sths 	unsigned short st_gid;
1822992f48a0Sblueswir1 	abi_ulong  st_rdev;
1823992f48a0Sblueswir1 	abi_ulong  st_size;
1824992f48a0Sblueswir1 	abi_ulong  st_blksize;
1825992f48a0Sblueswir1 	abi_ulong  st_blocks;
1826992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1827992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1828992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1829992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1830992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1831992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1832992f48a0Sblueswir1 	abi_ulong  __unused4;
1833992f48a0Sblueswir1 	abi_ulong  __unused5;
18346db45e65Sths };
18356db45e65Sths 
18366db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
18376db45e65Sths  * insane amounts of padding around dev_t's.
18386db45e65Sths  */
183920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1840541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
18416db45e65Sths 	unsigned long long	st_dev;
18426db45e65Sths 	unsigned char	__pad0[4];
18436db45e65Sths 
18446db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1845992f48a0Sblueswir1 	abi_ulong	__st_ino;
18466db45e65Sths 
18476db45e65Sths 	unsigned int	st_mode;
18486db45e65Sths 	unsigned int	st_nlink;
18496db45e65Sths 
1850992f48a0Sblueswir1 	abi_ulong	st_uid;
1851992f48a0Sblueswir1 	abi_ulong	st_gid;
18526db45e65Sths 
18536db45e65Sths 	unsigned long long	st_rdev;
18546db45e65Sths 	unsigned char	__pad3[4];
18556db45e65Sths 
18566db45e65Sths 	long long	st_size;
1857992f48a0Sblueswir1 	abi_ulong	st_blksize;
18586db45e65Sths 
18596db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
18606db45e65Sths 
1861992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1862992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
18636db45e65Sths 
1864992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1865992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
18666db45e65Sths 
1867992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1868992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
18696db45e65Sths 
18706db45e65Sths 	unsigned long long	st_ino;
18716db45e65Sths };
18726db45e65Sths 
1873d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
18745f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1875d2fd1af7Sbellard struct target_stat {
1876d2fd1af7Sbellard 	abi_ulong	st_dev;
1877d2fd1af7Sbellard 	abi_ulong	st_ino;
1878d2fd1af7Sbellard 	abi_ulong	st_nlink;
1879d2fd1af7Sbellard 
1880d2fd1af7Sbellard 	unsigned int	st_mode;
1881d2fd1af7Sbellard 	unsigned int	st_uid;
1882d2fd1af7Sbellard 	unsigned int	st_gid;
1883d2fd1af7Sbellard 	unsigned int	__pad0;
1884d2fd1af7Sbellard 	abi_ulong	st_rdev;
1885d2fd1af7Sbellard 	abi_long	st_size;
1886d2fd1af7Sbellard 	abi_long	st_blksize;
1887d2fd1af7Sbellard 	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1888d2fd1af7Sbellard 
1889d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1890d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1891d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1892d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1893d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1894d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1895d2fd1af7Sbellard 
1896d2fd1af7Sbellard 	abi_long	__unused[3];
1897d2fd1af7Sbellard };
1898a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
1899a4c075f1SUlrich Hecht struct target_stat {
1900a4c075f1SUlrich Hecht     abi_ulong  st_dev;
1901a4c075f1SUlrich Hecht     abi_ulong  st_ino;
1902a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
1903a4c075f1SUlrich Hecht     unsigned int   st_mode;
1904a4c075f1SUlrich Hecht     unsigned int   st_uid;
1905a4c075f1SUlrich Hecht     unsigned int   st_gid;
1906a4c075f1SUlrich Hecht     unsigned int   __pad1;
1907a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
1908a4c075f1SUlrich Hecht     abi_ulong  st_size;
1909a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
1910a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
1911a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
1912a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
1913a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
1914a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
1915a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
1916a4c075f1SUlrich Hecht     abi_long       st_blocks;
1917a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
1918a4c075f1SUlrich Hecht };
191909701199SAlexander Graf #elif defined(TARGET_AARCH64)
19205f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
192109701199SAlexander Graf struct target_stat {
192209701199SAlexander Graf     abi_ulong  st_dev;
192309701199SAlexander Graf     abi_ulong  st_ino;
192409701199SAlexander Graf     unsigned int st_mode;
192509701199SAlexander Graf     unsigned int st_nlink;
192609701199SAlexander Graf     unsigned int   st_uid;
192709701199SAlexander Graf     unsigned int   st_gid;
192809701199SAlexander Graf     abi_ulong  st_rdev;
192909701199SAlexander Graf     abi_ulong  _pad1;
193009701199SAlexander Graf     abi_long  st_size;
193109701199SAlexander Graf     int        st_blksize;
193209701199SAlexander Graf     int        __pad2;
193309701199SAlexander Graf     abi_long   st_blocks;
193409701199SAlexander Graf     abi_long  target_st_atime;
193509701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
193609701199SAlexander Graf     abi_long  target_st_mtime;
193709701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
193809701199SAlexander Graf     abi_long  target_st_ctime;
193909701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
194009701199SAlexander Graf     unsigned int __unused[2];
194109701199SAlexander Graf };
1942ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
19435f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1944ba7651fbSMax Filippov struct target_stat {
1945ba7651fbSMax Filippov     abi_ulong       st_dev;
1946ba7651fbSMax Filippov     abi_ulong       st_ino;
1947ba7651fbSMax Filippov     unsigned int    st_mode;
1948ba7651fbSMax Filippov     unsigned int    st_nlink;
1949ba7651fbSMax Filippov     unsigned int    st_uid;
1950ba7651fbSMax Filippov     unsigned int    st_gid;
1951ba7651fbSMax Filippov     abi_ulong       st_rdev;
1952ba7651fbSMax Filippov     abi_long        st_size;
1953ba7651fbSMax Filippov     abi_ulong       st_blksize;
1954ba7651fbSMax Filippov     abi_ulong       st_blocks;
1955ba7651fbSMax Filippov     abi_ulong       target_st_atime;
1956ba7651fbSMax Filippov     abi_ulong       target_st_atime_nsec;
1957ba7651fbSMax Filippov     abi_ulong       target_st_mtime;
1958ba7651fbSMax Filippov     abi_ulong       target_st_mtime_nsec;
1959ba7651fbSMax Filippov     abi_ulong       target_st_ctime;
1960ba7651fbSMax Filippov     abi_ulong       target_st_ctime_nsec;
1961ba7651fbSMax Filippov     abi_ulong       __unused4;
1962ba7651fbSMax Filippov     abi_ulong       __unused5;
1963ba7651fbSMax Filippov };
1964ba7651fbSMax Filippov 
1965ba7651fbSMax Filippov #define TARGET_HAS_STRUCT_STAT64
1966ba7651fbSMax Filippov struct target_stat64  {
1967ba7651fbSMax Filippov     uint64_t st_dev;            /* Device */
1968ba7651fbSMax Filippov     uint64_t st_ino;            /* File serial number */
1969ba7651fbSMax Filippov     unsigned int  st_mode;      /* File mode. */
1970ba7651fbSMax Filippov     unsigned int  st_nlink;     /* Link count. */
1971ba7651fbSMax Filippov     unsigned int  st_uid;       /* User ID of the file's owner. */
1972ba7651fbSMax Filippov     unsigned int  st_gid;       /* Group ID of the file's group. */
1973ba7651fbSMax Filippov     uint64_t st_rdev;           /* Device number, if device. */
1974ba7651fbSMax Filippov     int64_t st_size;            /* Size of file, in bytes. */
1975ba7651fbSMax Filippov     abi_ulong st_blksize;       /* Optimal block size for I/O. */
1976ba7651fbSMax Filippov     abi_ulong __unused2;
1977ba7651fbSMax Filippov     uint64_t st_blocks;         /* Number 512-byte blocks allocated. */
1978ba7651fbSMax Filippov     abi_ulong target_st_atime;  /* Time of last access. */
1979ba7651fbSMax Filippov     abi_ulong target_st_atime_nsec;
1980ba7651fbSMax Filippov     abi_ulong target_st_mtime;  /* Time of last modification. */
1981ba7651fbSMax Filippov     abi_ulong target_st_mtime_nsec;
1982ba7651fbSMax Filippov     abi_ulong target_st_ctime;  /* Time of last status change. */
1983ba7651fbSMax Filippov     abi_ulong target_st_ctime_nsec;
1984ba7651fbSMax Filippov     abi_ulong __unused4;
1985ba7651fbSMax Filippov     abi_ulong __unused5;
1986ba7651fbSMax Filippov };
1987ba7651fbSMax Filippov 
1988a0a839b6SMarek Vasut #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
198947ae93cdSMichael Clark       defined(TARGET_NIOS2) || defined(TARGET_RISCV)
1990c7819dfbSPeter Maydell 
1991c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
1992c7819dfbSPeter Maydell 
19935f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1994d962783eSJia Liu struct target_stat {
1995d962783eSJia Liu     abi_ulong st_dev;
1996d962783eSJia Liu     abi_ulong st_ino;
1997d962783eSJia Liu     unsigned int st_mode;
1998c7819dfbSPeter Maydell     unsigned int st_nlink;
1999d962783eSJia Liu     unsigned int st_uid;
2000d962783eSJia Liu     unsigned int st_gid;
2001d962783eSJia Liu     abi_ulong st_rdev;
2002c7819dfbSPeter Maydell     abi_ulong __pad1;
2003d962783eSJia Liu     abi_long st_size;
2004c7819dfbSPeter Maydell     int st_blksize;
2005c7819dfbSPeter Maydell     int __pad2;
2006c7819dfbSPeter Maydell     abi_long st_blocks;
2007c7819dfbSPeter Maydell     abi_long target_st_atime;
2008d962783eSJia Liu     abi_ulong target_st_atime_nsec;
2009c7819dfbSPeter Maydell     abi_long target_st_mtime;
2010d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
2011c7819dfbSPeter Maydell     abi_long target_st_ctime;
2012d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
2013c7819dfbSPeter Maydell     unsigned int __unused4;
2014c7819dfbSPeter Maydell     unsigned int __unused5;
2015d962783eSJia Liu };
2016c7819dfbSPeter Maydell 
201747ae93cdSMichael Clark #if !defined(TARGET_RISCV64)
201820d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
2019c7819dfbSPeter Maydell struct target_stat64 {
2020c7819dfbSPeter Maydell     uint64_t st_dev;
2021c7819dfbSPeter Maydell     uint64_t st_ino;
2022c7819dfbSPeter Maydell     unsigned int st_mode;
2023c7819dfbSPeter Maydell     unsigned int st_nlink;
2024c7819dfbSPeter Maydell     unsigned int st_uid;
2025c7819dfbSPeter Maydell     unsigned int st_gid;
2026c7819dfbSPeter Maydell     uint64_t st_rdev;
2027c7819dfbSPeter Maydell     uint64_t __pad1;
2028c7819dfbSPeter Maydell     int64_t st_size;
2029c7819dfbSPeter Maydell     int st_blksize;
2030c7819dfbSPeter Maydell     int __pad2;
2031c7819dfbSPeter Maydell     int64_t st_blocks;
2032c7819dfbSPeter Maydell     int target_st_atime;
2033c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
2034c7819dfbSPeter Maydell     int target_st_mtime;
2035c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
2036c7819dfbSPeter Maydell     int target_st_ctime;
2037c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
2038c7819dfbSPeter Maydell     unsigned int __unused4;
2039c7819dfbSPeter Maydell     unsigned int __unused5;
2040c7819dfbSPeter Maydell };
204147ae93cdSMichael Clark #endif
2042c7819dfbSPeter Maydell 
2043a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2044a10d1e50SRichard Henderson 
20455f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2046a10d1e50SRichard Henderson struct target_stat {
2047a10d1e50SRichard Henderson     abi_uint   st_dev;
2048a10d1e50SRichard Henderson     abi_uint   st_ino;
2049a10d1e50SRichard Henderson     abi_ushort st_mode;
2050a10d1e50SRichard Henderson     abi_ushort st_nlink;
2051a10d1e50SRichard Henderson     abi_ushort _res1;
2052a10d1e50SRichard Henderson     abi_ushort _res2;
2053a10d1e50SRichard Henderson     abi_uint   st_rdev;
2054a10d1e50SRichard Henderson     abi_int    st_size;
2055a10d1e50SRichard Henderson     abi_int    target_st_atime;
2056a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2057a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2058a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2059a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2060a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2061a10d1e50SRichard Henderson     abi_int    st_blksize;
2062a10d1e50SRichard Henderson     abi_int    st_blocks;
2063a10d1e50SRichard Henderson     abi_uint   _unused1;
2064a10d1e50SRichard Henderson     abi_uint   _unused2;
2065a10d1e50SRichard Henderson     abi_uint   _unused3;
2066a10d1e50SRichard Henderson     abi_uint   _unused4;
2067a10d1e50SRichard Henderson     abi_ushort _unused5;
2068a10d1e50SRichard Henderson     abi_short  st_fstype;
2069a10d1e50SRichard Henderson     abi_uint   st_realdev;
2070a10d1e50SRichard Henderson     abi_ushort st_basemode;
2071a10d1e50SRichard Henderson     abi_ushort _unused6;
2072a10d1e50SRichard Henderson     abi_uint   st_uid;
2073a10d1e50SRichard Henderson     abi_uint   st_gid;
2074a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2075a10d1e50SRichard Henderson };
2076a10d1e50SRichard Henderson 
2077a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2078a10d1e50SRichard Henderson struct target_stat64 {
2079a10d1e50SRichard Henderson     uint64_t   st_dev;
2080a10d1e50SRichard Henderson     abi_uint   _pad1;
2081a10d1e50SRichard Henderson     abi_uint   _res1;
2082a10d1e50SRichard Henderson     abi_uint   st_mode;
2083a10d1e50SRichard Henderson     abi_uint   st_nlink;
2084a10d1e50SRichard Henderson     abi_uint   st_uid;
2085a10d1e50SRichard Henderson     abi_uint   st_gid;
2086a10d1e50SRichard Henderson     uint64_t   st_rdev;
2087a10d1e50SRichard Henderson     abi_uint   _pad2;
2088a10d1e50SRichard Henderson     int64_t    st_size;
2089a10d1e50SRichard Henderson     abi_int    st_blksize;
2090a10d1e50SRichard Henderson     int64_t    st_blocks;
2091a10d1e50SRichard Henderson     abi_int    target_st_atime;
2092a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2093a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2094a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2095a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2096a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2097a10d1e50SRichard Henderson     uint64_t   st_ino;
2098a10d1e50SRichard Henderson };
2099a10d1e50SRichard Henderson 
2100048f6b4dSbellard #else
2101048f6b4dSbellard #error unsupported CPU
2102048f6b4dSbellard #endif
21032521d698Sbellard 
21044ce6f8deSths typedef struct {
21054ce6f8deSths         int     val[2];
2106c227f099SAnthony Liguori } target_fsid_t;
21074ce6f8deSths 
210856c8f68fSbellard #ifdef TARGET_MIPS
2109d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2110540635baSths struct target_statfs {
2111540635baSths 	int32_t			f_type;
2112540635baSths 	int32_t			f_bsize;
2113540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2114540635baSths 	int32_t			f_blocks;
2115540635baSths 	int32_t			f_bfree;
2116540635baSths 	int32_t			f_files;
2117540635baSths 	int32_t			f_ffree;
2118540635baSths 	int32_t			f_bavail;
2119540635baSths 
2120540635baSths 	/* Linux specials */
2121c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2122540635baSths 	int32_t			f_namelen;
2123d4247ec2SShea Levy 	int32_t			f_flags;
2124d4247ec2SShea Levy 	int32_t			f_spare[5];
2125540635baSths };
2126540635baSths #else
212756c8f68fSbellard struct target_statfs {
2128992f48a0Sblueswir1 	abi_long		f_type;
2129992f48a0Sblueswir1 	abi_long		f_bsize;
2130992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2131992f48a0Sblueswir1 	abi_long		f_blocks;
2132992f48a0Sblueswir1 	abi_long		f_bfree;
2133992f48a0Sblueswir1 	abi_long		f_files;
2134992f48a0Sblueswir1 	abi_long		f_ffree;
2135992f48a0Sblueswir1 	abi_long		f_bavail;
213656c8f68fSbellard 
213756c8f68fSbellard 	/* Linux specials */
2138c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2139992f48a0Sblueswir1 	abi_long		f_namelen;
2140d4247ec2SShea Levy 	abi_long		f_flags;
2141d4247ec2SShea Levy 	abi_long		f_spare[5];
214256c8f68fSbellard };
2143540635baSths #endif
214456c8f68fSbellard 
214556c8f68fSbellard struct target_statfs64 {
214656c8f68fSbellard 	uint32_t	f_type;
214756c8f68fSbellard 	uint32_t	f_bsize;
214856c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
214956c8f68fSbellard 	uint32_t	__pad;
215056c8f68fSbellard 	uint64_t	f_blocks;
215156c8f68fSbellard 	uint64_t	f_bfree;
215256c8f68fSbellard 	uint64_t	f_files;
215356c8f68fSbellard 	uint64_t	f_ffree;
215456c8f68fSbellard 	uint64_t	f_bavail;
2155c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
215656c8f68fSbellard 	uint32_t	f_namelen;
2157d4247ec2SShea Levy 	uint32_t	f_flags;
2158d4247ec2SShea Levy 	uint32_t	f_spare[5];
215956c8f68fSbellard };
2160c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
216147ae93cdSMichael Clark        defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
216247ae93cdSMichael Clark        defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2163325e651fSj_mayer struct target_statfs {
2164325e651fSj_mayer 	abi_long f_type;
2165325e651fSj_mayer 	abi_long f_bsize;
2166325e651fSj_mayer 	abi_long f_blocks;
2167325e651fSj_mayer 	abi_long f_bfree;
2168325e651fSj_mayer 	abi_long f_bavail;
2169325e651fSj_mayer 	abi_long f_files;
2170325e651fSj_mayer 	abi_long f_ffree;
2171c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2172325e651fSj_mayer 	abi_long f_namelen;
2173325e651fSj_mayer 	abi_long f_frsize;
2174d4247ec2SShea Levy 	abi_long f_flags;
2175d4247ec2SShea Levy 	abi_long f_spare[4];
2176325e651fSj_mayer };
2177325e651fSj_mayer 
2178325e651fSj_mayer struct target_statfs64 {
2179325e651fSj_mayer 	abi_long f_type;
2180325e651fSj_mayer 	abi_long f_bsize;
2181325e651fSj_mayer 	abi_long f_blocks;
2182325e651fSj_mayer 	abi_long f_bfree;
2183325e651fSj_mayer 	abi_long f_bavail;
2184325e651fSj_mayer 	abi_long f_files;
2185325e651fSj_mayer 	abi_long f_ffree;
2186c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2187325e651fSj_mayer 	abi_long f_namelen;
2188325e651fSj_mayer 	abi_long f_frsize;
2189d4247ec2SShea Levy 	abi_long f_flags;
2190d4247ec2SShea Levy 	abi_long f_spare[4];
2191325e651fSj_mayer };
2192a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2193a4c075f1SUlrich Hecht struct target_statfs {
2194a4c075f1SUlrich Hecht     int32_t  f_type;
2195a4c075f1SUlrich Hecht     int32_t  f_bsize;
2196a4c075f1SUlrich Hecht     abi_long f_blocks;
2197a4c075f1SUlrich Hecht     abi_long f_bfree;
2198a4c075f1SUlrich Hecht     abi_long f_bavail;
2199a4c075f1SUlrich Hecht     abi_long f_files;
2200a4c075f1SUlrich Hecht     abi_long f_ffree;
2201a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2202a4c075f1SUlrich Hecht     int32_t  f_namelen;
2203a4c075f1SUlrich Hecht     int32_t  f_frsize;
2204d4247ec2SShea Levy     int32_t  f_flags;
2205d4247ec2SShea Levy     int32_t  f_spare[4];
2206d4247ec2SShea Levy 
2207a4c075f1SUlrich Hecht };
2208a4c075f1SUlrich Hecht 
2209a4c075f1SUlrich Hecht struct target_statfs64 {
2210a4c075f1SUlrich Hecht     int32_t  f_type;
2211a4c075f1SUlrich Hecht     int32_t  f_bsize;
2212a4c075f1SUlrich Hecht     abi_long f_blocks;
2213a4c075f1SUlrich Hecht     abi_long f_bfree;
2214a4c075f1SUlrich Hecht     abi_long f_bavail;
2215a4c075f1SUlrich Hecht     abi_long f_files;
2216a4c075f1SUlrich Hecht     abi_long f_ffree;
2217a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2218a4c075f1SUlrich Hecht     int32_t  f_namelen;
2219a4c075f1SUlrich Hecht     int32_t  f_frsize;
2220d4247ec2SShea Levy     int32_t  f_flags;
2221d4247ec2SShea Levy     int32_t  f_spare[4];
2222a4c075f1SUlrich Hecht };
222356c8f68fSbellard #else
222456c8f68fSbellard struct target_statfs {
222556c8f68fSbellard 	uint32_t f_type;
222656c8f68fSbellard 	uint32_t f_bsize;
222756c8f68fSbellard 	uint32_t f_blocks;
222856c8f68fSbellard 	uint32_t f_bfree;
222956c8f68fSbellard 	uint32_t f_bavail;
223056c8f68fSbellard 	uint32_t f_files;
223156c8f68fSbellard 	uint32_t f_ffree;
2232c227f099SAnthony Liguori 	target_fsid_t f_fsid;
223356c8f68fSbellard 	uint32_t f_namelen;
223456c8f68fSbellard 	uint32_t f_frsize;
2235d4247ec2SShea Levy 	uint32_t f_flags;
2236d4247ec2SShea Levy 	uint32_t f_spare[4];
223756c8f68fSbellard };
223856c8f68fSbellard 
223956c8f68fSbellard struct target_statfs64 {
224056c8f68fSbellard 	uint32_t f_type;
224156c8f68fSbellard 	uint32_t f_bsize;
224256c8f68fSbellard 	uint64_t f_blocks;
224356c8f68fSbellard 	uint64_t f_bfree;
224456c8f68fSbellard 	uint64_t f_bavail;
224556c8f68fSbellard 	uint64_t f_files;
224656c8f68fSbellard 	uint64_t f_ffree;
2247c227f099SAnthony Liguori 	target_fsid_t f_fsid;
224856c8f68fSbellard         uint32_t f_namelen;
224956c8f68fSbellard 	uint32_t f_frsize;
2250d4247ec2SShea Levy 	uint32_t f_flags;
2251d4247ec2SShea Levy 	uint32_t f_spare[4];
225256c8f68fSbellard };
225356c8f68fSbellard #endif
225456c8f68fSbellard 
22557e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
22567e22e546SUlrich Hecht #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
22577e22e546SUlrich Hecht #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
22587e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
22597e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
22607e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
22617e22e546SUlrich Hecht #define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)
22627e22e546SUlrich Hecht 
22635de7706eSLaurent Vivier #include "target_fcntl.h"
22648d5d3004SAndreas Schwab 
22652521d698Sbellard /* soundcard defines */
226667cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
22672521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
22682521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
22692521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
22702521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
22712521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
22722521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
22732521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
22742521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
22752521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
22762521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
22772521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
22782521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
22792521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
22802521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
22812521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
22822521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
22832521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
22842521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
22852521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
22862521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
22872521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
22882521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
22892521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
22902521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
22912521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
22922521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
22932521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
22942521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
22955f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
22965f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
22972521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
22982521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
22992521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
23002521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
23012521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
23022521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
23032521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
23042521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
23052521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
23062521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
23072521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
23082521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
23092521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
23102521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
23112521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
23122521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
23132521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
23142521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
23152521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
23162521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
23172521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
23182521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
23192521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
23202521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
23212521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
23222521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
23232521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
23242521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
23252521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
23262521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
23272521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
23282521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
23292521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
23302521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
23312521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
23322521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
23332521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
23342521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
23352521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
23362521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
23372521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
23382521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
23392521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
23402521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
23412521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
23422521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
23432521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
23442521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
23452521d698Sbellard 
23462521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
23472521d698Sbellard 
23482521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
23492521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
23502521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
23512521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
23522521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
23532521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
23542521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
23552521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
23562521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
23572521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
23582521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
23592521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
23602521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
23612521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
23622521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
23632521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
23642521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
23652521d698Sbellard 
23662521d698Sbellard /* Obsolete macros */
23672521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
23682521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
23692521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
23702521d698Sbellard 
23712521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
23722521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
23732521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
23742521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
23752521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
23762521d698Sbellard 
23772521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
23782521d698Sbellard 
23792521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
23802521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
23812521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
23822521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
23832521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
23842521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
23852521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
23862521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
23872521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
23882521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
23892521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
23902521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
23912521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
23922521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
23932521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
23942521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
23952521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
23962521d698Sbellard 
23972521d698Sbellard /* Obsolete macros */
23982521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
23992521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
24002521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
24012521d698Sbellard 
24022521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
24032521d698Sbellard 
24042521d698Sbellard /* vfat ioctls */
24052521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
24062521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2407a5448a7dSbellard 
2408f443e396SPeter Maydell struct target_mtop {
2409f443e396SPeter Maydell     abi_short mt_op;
2410f443e396SPeter Maydell     abi_int mt_count;
2411f443e396SPeter Maydell };
2412f443e396SPeter Maydell 
2413f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2414f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2415f443e396SPeter Maydell #else
2416f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2417f443e396SPeter Maydell #endif
2418f443e396SPeter Maydell 
2419f443e396SPeter Maydell struct target_mtget {
2420f443e396SPeter Maydell     abi_long mt_type;
2421f443e396SPeter Maydell     abi_long mt_resid;
2422f443e396SPeter Maydell     abi_long mt_dsreg;
2423f443e396SPeter Maydell     abi_long mt_gstat;
2424f443e396SPeter Maydell     abi_long mt_erreg;
2425f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2426f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2427f443e396SPeter Maydell };
2428f443e396SPeter Maydell 
2429f443e396SPeter Maydell struct target_mtpos {
2430f443e396SPeter Maydell     abi_long mt_blkno;
2431f443e396SPeter Maydell };
2432f443e396SPeter Maydell 
2433f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2434f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2435f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
24368fbd6b52Sbalrog 
2437a5448a7dSbellard struct target_sysinfo {
2438992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2439992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2440992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2441992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2442992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2443992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2444992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2445992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2446a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2447a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2448992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2449992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2450a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2451992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2452a5448a7dSbellard };
24533532fa74Sbellard 
24546556a833Saurel32 struct linux_dirent {
24556556a833Saurel32     long            d_ino;
24566556a833Saurel32     unsigned long   d_off;
24576556a833Saurel32     unsigned short  d_reclen;
24586556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
24596556a833Saurel32 };
24606556a833Saurel32 
24616556a833Saurel32 struct linux_dirent64 {
24626556a833Saurel32     uint64_t        d_ino;
24636556a833Saurel32     int64_t         d_off;
24646556a833Saurel32     unsigned short  d_reclen;
24656556a833Saurel32     unsigned char   d_type;
24666556a833Saurel32     char            d_name[256];
24676556a833Saurel32 };
24686556a833Saurel32 
246924e1003aSaurel32 struct target_mq_attr {
247024e1003aSaurel32     abi_long mq_flags;
247124e1003aSaurel32     abi_long mq_maxmsg;
247224e1003aSaurel32     abi_long mq_msgsize;
247324e1003aSaurel32     abi_long mq_curmsgs;
247424e1003aSaurel32 };
247524e1003aSaurel32 
24763532fa74Sbellard #include "socket.h"
2477637947f1Sths 
2478637947f1Sths #include "errno_defs.h"
247903dfe9f8SRiku Voipio 
248003dfe9f8SRiku Voipio #define FUTEX_WAIT              0
248103dfe9f8SRiku Voipio #define FUTEX_WAKE              1
248203dfe9f8SRiku Voipio #define FUTEX_FD                2
248303dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
248403dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
248503dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
248603dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
248703dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
248803dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
248903dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
249003dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
249103dfe9f8SRiku Voipio 
249203dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
249303dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
249403dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
249503dfe9f8SRiku Voipio 
24963b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2497928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2498928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2499928bed6aSLaurent Vivier #else
2500928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2501928bed6aSLaurent Vivier #endif
2502928bed6aSLaurent Vivier 
25033b6edd16SPeter Maydell typedef union target_epoll_data {
25043b6edd16SPeter Maydell     abi_ulong ptr;
2505928bed6aSLaurent Vivier     abi_int fd;
2506928bed6aSLaurent Vivier     abi_uint u32;
2507928bed6aSLaurent Vivier     abi_ullong u64;
25083b6edd16SPeter Maydell } target_epoll_data_t;
25093b6edd16SPeter Maydell 
25103b6edd16SPeter Maydell struct target_epoll_event {
2511928bed6aSLaurent Vivier     abi_uint events;
25123b6edd16SPeter Maydell     target_epoll_data_t data;
2513928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
25142ba7fae3SPeter Maydell 
25152ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
25162ba7fae3SPeter Maydell 
25173b6edd16SPeter Maydell #endif
2518163a05a8SPeter Maydell struct target_rlimit64 {
2519163a05a8SPeter Maydell     uint64_t rlim_cur;
2520163a05a8SPeter Maydell     uint64_t rlim_max;
2521163a05a8SPeter Maydell };
2522583359a6SAkos PASZTORY 
2523583359a6SAkos PASZTORY struct target_ucred {
2524583359a6SAkos PASZTORY     uint32_t pid;
2525583359a6SAkos PASZTORY     uint32_t uid;
2526583359a6SAkos PASZTORY     uint32_t gid;
2527583359a6SAkos PASZTORY };
2528cb9c377fSPaolo Bonzini 
2529aecc8861SAlexander Graf typedef int32_t target_timer_t;
2530905bba13SErik de Castro Lopo 
253134d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
253234d60862SNatanael Copa 
253334d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
253434d60862SNatanael Copa #ifdef TARGET_MIPS
253534d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
253634d60862SNatanael Copa #else
253734d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
253834d60862SNatanael Copa                                     + sizeof(target_sigval_t))
253934d60862SNatanael Copa #endif
254034d60862SNatanael Copa 
254134d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
254234d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
254334d60862SNatanael Copa                                / sizeof(int32_t))
254434d60862SNatanael Copa 
2545905bba13SErik de Castro Lopo struct target_sigevent {
2546905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
254717351c3fSPeter Maydell     abi_int sigev_signo;
254817351c3fSPeter Maydell     abi_int sigev_notify;
2549905bba13SErik de Castro Lopo     union {
255017351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
255117351c3fSPeter Maydell         abi_int _tid;
2552905bba13SErik de Castro Lopo 
255317351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
255417351c3fSPeter Maydell          * they're only used as part of the ABI between a
255517351c3fSPeter Maydell          * userspace program and libc.
255617351c3fSPeter Maydell          */
2557905bba13SErik de Castro Lopo         struct {
255817351c3fSPeter Maydell             abi_ulong _function;
255917351c3fSPeter Maydell             abi_ulong _attribute;
2560905bba13SErik de Castro Lopo         } _sigev_thread;
2561905bba13SErik de Castro Lopo     } _sigev_un;
2562905bba13SErik de Castro Lopo };
2563e0eb210eSPeter Maydell 
2564e0eb210eSPeter Maydell struct target_user_cap_header {
2565e0eb210eSPeter Maydell     uint32_t version;
2566e0eb210eSPeter Maydell     int pid;
2567e0eb210eSPeter Maydell };
2568e0eb210eSPeter Maydell 
2569e0eb210eSPeter Maydell struct target_user_cap_data {
2570e0eb210eSPeter Maydell     uint32_t effective;
2571e0eb210eSPeter Maydell     uint32_t permitted;
2572e0eb210eSPeter Maydell     uint32_t inheritable;
2573e0eb210eSPeter Maydell };
25741b3c4fdfSMarkus Armbruster 
2575da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2576da2c8ad7SAleksandar Markovic 
2577da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2578da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2579da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2580da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2581da2c8ad7SAleksandar Markovic /* Read from the log. */
2582da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2583da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2584da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2585da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2586da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2587da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2588da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2589da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2590da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2591da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2592da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2593da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2594da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2595da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2596da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2597da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2598da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2599da2c8ad7SAleksandar Markovic 
2600efa92184SAleksandar Rikalo struct target_statx_timestamp {
2601efa92184SAleksandar Rikalo    int64_t tv_sec;
2602efa92184SAleksandar Rikalo    uint32_t tv_nsec;
2603efa92184SAleksandar Rikalo    int32_t __reserved;
2604efa92184SAleksandar Rikalo };
2605efa92184SAleksandar Rikalo 
2606efa92184SAleksandar Rikalo struct target_statx {
2607efa92184SAleksandar Rikalo    /* 0x00 */
2608efa92184SAleksandar Rikalo    uint32_t stx_mask;       /* What results were written [uncond] */
2609efa92184SAleksandar Rikalo    uint32_t stx_blksize;    /* Preferred general I/O size [uncond] */
2610efa92184SAleksandar Rikalo    uint64_t stx_attributes; /* Flags conveying information about the file */
2611efa92184SAleksandar Rikalo    /* 0x10 */
2612efa92184SAleksandar Rikalo    uint32_t stx_nlink;      /* Number of hard links */
2613efa92184SAleksandar Rikalo    uint32_t stx_uid;        /* User ID of owner */
2614efa92184SAleksandar Rikalo    uint32_t stx_gid;        /* Group ID of owner */
2615efa92184SAleksandar Rikalo    uint16_t stx_mode;       /* File mode */
2616efa92184SAleksandar Rikalo    uint16_t __spare0[1];
2617efa92184SAleksandar Rikalo    /* 0x20 */
2618efa92184SAleksandar Rikalo    uint64_t stx_ino;        /* Inode number */
2619efa92184SAleksandar Rikalo    uint64_t stx_size;       /* File size */
2620efa92184SAleksandar Rikalo    uint64_t stx_blocks;     /* Number of 512-byte blocks allocated */
2621efa92184SAleksandar Rikalo    uint64_t stx_attributes_mask; /* Mask to show what is supported */
2622efa92184SAleksandar Rikalo    /* 0x40 */
2623efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_atime;  /* Last access time */
2624efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_btime;  /* File creation time */
2625efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_ctime;  /* Last attribute change time */
2626efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_mtime;  /* Last data modification time */
2627efa92184SAleksandar Rikalo    /* 0x80 */
2628efa92184SAleksandar Rikalo    uint32_t stx_rdev_major;   /* Device ID of special file [if bdev/cdev] */
2629efa92184SAleksandar Rikalo    uint32_t stx_rdev_minor;
2630efa92184SAleksandar Rikalo    uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2631efa92184SAleksandar Rikalo    uint32_t stx_dev_minor;
2632efa92184SAleksandar Rikalo    /* 0x90 */
2633efa92184SAleksandar Rikalo    uint64_t __spare2[14];  /* Spare space for future expansion */
2634efa92184SAleksandar Rikalo    /* 0x100 */
2635efa92184SAleksandar Rikalo };
2636efa92184SAleksandar Rikalo 
26371b3c4fdfSMarkus Armbruster #endif
2638