xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 45ad761c27dfb571d9a1ab3af80e8034d36d1b59)
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 
490a7ec849SFilip Bozuta #define TARGET_SEMOPM     500
500a7ec849SFilip Bozuta 
512521d698Sbellard /*
522521d698Sbellard  * The following is for compatibility across the various Linux
532521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
542521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
552521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
562521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
572521d698Sbellard  * below from now on.
582521d698Sbellard  */
592521d698Sbellard #define TARGET_IOC_NRBITS	8
602521d698Sbellard #define TARGET_IOC_TYPEBITS	8
612521d698Sbellard 
62716f3fbeSPeter Maydell #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
63716f3fbeSPeter Maydell     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
64cd98d390SAndreas Schwab     || defined(TARGET_SPARC) \
650c866a7eSRiku Voipio     || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
6674d753acSMika Westerberg     /* 16 bit uid wrappers emulation */
6774d753acSMika Westerberg #define USE_UID16
680c866a7eSRiku Voipio #define target_id uint16_t
690c866a7eSRiku Voipio #else
700c866a7eSRiku Voipio #define target_id uint32_t
7174d753acSMika Westerberg #endif
7274d753acSMika Westerberg 
73e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
74b16189b2SChen Gang     || defined(TARGET_M68K) || defined(TARGET_CRIS) \
752cc1a901SThomas Huth     || defined(TARGET_S390X) || defined(TARGET_OPENRISC) \
76ba7651fbSMax Filippov     || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
77ba7651fbSMax Filippov     || defined(TARGET_XTENSA)
782521d698Sbellard 
792521d698Sbellard #define TARGET_IOC_SIZEBITS	14
802521d698Sbellard #define TARGET_IOC_DIRBITS	2
812521d698Sbellard 
822521d698Sbellard #define TARGET_IOC_NONE	  0U
832521d698Sbellard #define TARGET_IOC_WRITE  1U
842521d698Sbellard #define TARGET_IOC_READ	  2U
852521d698Sbellard 
86048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
87b779e29eSEdgar E. Iglesias       defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
88b779e29eSEdgar E. Iglesias       defined(TARGET_MIPS)
892521d698Sbellard 
902521d698Sbellard #define TARGET_IOC_SIZEBITS	13
912521d698Sbellard #define TARGET_IOC_DIRBITS	3
922521d698Sbellard 
932521d698Sbellard #define TARGET_IOC_NONE	  1U
942521d698Sbellard #define TARGET_IOC_READ	  2U
952521d698Sbellard #define TARGET_IOC_WRITE  4U
962521d698Sbellard 
97a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
98a10d1e50SRichard Henderson 
99a10d1e50SRichard Henderson #define TARGET_IOC_SIZEBITS  14
100a10d1e50SRichard Henderson #define TARGET_IOC_DIRBITS    2
101a10d1e50SRichard Henderson 
102a10d1e50SRichard Henderson #define TARGET_IOC_NONE   0U
103a10d1e50SRichard Henderson #define TARGET_IOC_WRITE  2U
104a10d1e50SRichard Henderson #define TARGET_IOC_READ   1U
105a10d1e50SRichard Henderson 
106d2a56bd2STaylor Simpson #elif defined(TARGET_HEXAGON)
107d2a56bd2STaylor Simpson 
108d2a56bd2STaylor Simpson #define TARGET_IOC_SIZEBITS     14
109d2a56bd2STaylor Simpson 
110d2a56bd2STaylor Simpson #define TARGET_IOC_NONE   0U
111d2a56bd2STaylor Simpson #define TARGET_IOC_WRITE  1U
112d2a56bd2STaylor Simpson #define TARGET_IOC_READ          2U
113d2a56bd2STaylor Simpson 
1142521d698Sbellard #else
1152521d698Sbellard #error unsupported CPU
1162521d698Sbellard #endif
1172521d698Sbellard 
1182521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
1192521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
1202521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
1212521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
1222521d698Sbellard 
1232521d698Sbellard #define TARGET_IOC_NRSHIFT	0
1242521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
1252521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
1262521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
1272521d698Sbellard 
1282521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
1292521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
1302521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
1312521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
1322521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
1332521d698Sbellard 
1342521d698Sbellard /* used to create numbers */
1352521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
1362521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
1372521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1382521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
1392521d698Sbellard 
1402521d698Sbellard /* the size is automatically computed for these defines */
1412521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
1422521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1432521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1442521d698Sbellard 
1457854b056Sbellard struct target_sockaddr {
1469a68960dSPhilippe Mathieu-Daudé     abi_ushort sa_family;
1477854b056Sbellard     uint8_t sa_data[14];
1487854b056Sbellard };
1497854b056Sbellard 
15033a29b51SJoakim Tjernlund struct target_sockaddr_ll {
1519a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_family;   /* Always AF_PACKET */
1529a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_protocol; /* Physical layer protocol */
1539a68960dSPhilippe Mathieu-Daudé     abi_int    sll_ifindex;  /* Interface number */
1549a68960dSPhilippe Mathieu-Daudé     abi_ushort sll_hatype;   /* ARP hardware type */
15533a29b51SJoakim Tjernlund     uint8_t    sll_pkttype;  /* Packet type */
15633a29b51SJoakim Tjernlund     uint8_t    sll_halen;    /* Length of address */
15733a29b51SJoakim Tjernlund     uint8_t    sll_addr[8];  /* Physical layer address */
15833a29b51SJoakim Tjernlund };
15933a29b51SJoakim Tjernlund 
160fb3aabf3SLaurent Vivier struct target_sockaddr_un {
1619a68960dSPhilippe Mathieu-Daudé     abi_ushort su_family;
162fb3aabf3SLaurent Vivier     uint8_t sun_path[108];
163fb3aabf3SLaurent Vivier };
164fb3aabf3SLaurent Vivier 
165a47401bcSPhilippe Mathieu-Daudé struct target_sockaddr_nl {
166a47401bcSPhilippe Mathieu-Daudé     abi_ushort nl_family;   /* AF_NETLINK */
167a47401bcSPhilippe Mathieu-Daudé     abi_ushort __pad;
168a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_pid;
169a47401bcSPhilippe Mathieu-Daudé     abi_uint nl_groups;
170a47401bcSPhilippe Mathieu-Daudé };
171a47401bcSPhilippe Mathieu-Daudé 
172fb3aabf3SLaurent Vivier struct target_in_addr {
1739a68960dSPhilippe Mathieu-Daudé     abi_uint s_addr; /* big endian */
174fb3aabf3SLaurent Vivier };
175fb3aabf3SLaurent Vivier 
176fb3aabf3SLaurent Vivier struct target_sockaddr_in {
1779a68960dSPhilippe Mathieu-Daudé   abi_ushort sin_family;
1789a68960dSPhilippe Mathieu-Daudé   abi_short sin_port; /* big endian */
179fb3aabf3SLaurent Vivier   struct target_in_addr sin_addr;
180fb3aabf3SLaurent Vivier   uint8_t __pad[sizeof(struct target_sockaddr) -
1819a68960dSPhilippe Mathieu-Daudé                 sizeof(abi_ushort) - sizeof(abi_short) -
182fb3aabf3SLaurent Vivier                 sizeof(struct target_in_addr)];
183fb3aabf3SLaurent Vivier };
184fb3aabf3SLaurent Vivier 
185ee1ac3a1SHelge Deller struct target_sockaddr_in6 {
1869a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_family;
1879a68960dSPhilippe Mathieu-Daudé     abi_ushort sin6_port; /* big endian */
1889a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_flowinfo; /* big endian */
189ee1ac3a1SHelge Deller     struct in6_addr sin6_addr; /* IPv6 address, big endian */
1909a68960dSPhilippe Mathieu-Daudé     abi_uint sin6_scope_id;
191ee1ac3a1SHelge Deller };
192ee1ac3a1SHelge Deller 
193f57d4192SLaurent Vivier struct target_sock_filter {
194f57d4192SLaurent Vivier     abi_ushort code;
195f57d4192SLaurent Vivier     uint8_t jt;
196f57d4192SLaurent Vivier     uint8_t jf;
197f57d4192SLaurent Vivier     abi_uint k;
198f57d4192SLaurent Vivier };
199f57d4192SLaurent Vivier 
200f57d4192SLaurent Vivier struct target_sock_fprog {
201f57d4192SLaurent Vivier     abi_ushort len;
202f57d4192SLaurent Vivier     abi_ulong filter;
203f57d4192SLaurent Vivier };
204f57d4192SLaurent Vivier 
205b975b83bSLionel Landwerlin struct target_ip_mreq {
206b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
207b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
208b975b83bSLionel Landwerlin };
209b975b83bSLionel Landwerlin 
210b975b83bSLionel Landwerlin struct target_ip_mreqn {
211b975b83bSLionel Landwerlin     struct target_in_addr imr_multiaddr;
212b975b83bSLionel Landwerlin     struct target_in_addr imr_address;
213b975b83bSLionel Landwerlin     abi_long imr_ifindex;
214b975b83bSLionel Landwerlin };
215b975b83bSLionel Landwerlin 
2166e3cb58fSLionel Landwerlin struct target_ip_mreq_source {
2176e3cb58fSLionel Landwerlin     /* big endian */
2186e3cb58fSLionel Landwerlin     uint32_t imr_multiaddr;
2196e3cb58fSLionel Landwerlin     uint32_t imr_interface;
2206e3cb58fSLionel Landwerlin     uint32_t imr_sourceaddr;
2216e3cb58fSLionel Landwerlin };
2226e3cb58fSLionel Landwerlin 
22383eb6e50SCarlo Marcelo Arenas Belón struct target_linger {
22483eb6e50SCarlo Marcelo Arenas Belón     abi_int l_onoff;        /* Linger active                */
22583eb6e50SCarlo Marcelo Arenas Belón     abi_int l_linger;       /* How long to linger for       */
22683eb6e50SCarlo Marcelo Arenas Belón };
22783eb6e50SCarlo Marcelo Arenas Belón 
2286d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
2296d5d5ddeSDaniel P. Berrangé struct target_timeval {
2306d5d5ddeSDaniel P. Berrangé     abi_long tv_sec;
2316d5d5ddeSDaniel P. Berrangé     abi_int tv_usec;
2326d5d5ddeSDaniel P. Berrangé };
2336d5d5ddeSDaniel P. Berrangé #define target__kernel_sock_timeval target_timeval
2346d5d5ddeSDaniel P. Berrangé #else
23531e31b8aSbellard struct target_timeval {
236992f48a0Sblueswir1     abi_long tv_sec;
237992f48a0Sblueswir1     abi_long tv_usec;
23831e31b8aSbellard };
23931e31b8aSbellard 
2406d5d5ddeSDaniel P. Berrangé struct target__kernel_sock_timeval {
2416d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2426d5d5ddeSDaniel P. Berrangé     abi_llong tv_usec;
2436d5d5ddeSDaniel P. Berrangé };
2446d5d5ddeSDaniel P. Berrangé #endif
2456d5d5ddeSDaniel P. Berrangé 
2461b6b029eSbellard struct target_timespec {
247992f48a0Sblueswir1     abi_long tv_sec;
248992f48a0Sblueswir1     abi_long tv_nsec;
2491b6b029eSbellard };
2501b6b029eSbellard 
2516d5d5ddeSDaniel P. Berrangé struct target__kernel_timespec {
2526d5d5ddeSDaniel P. Berrangé     abi_llong tv_sec;
2536d5d5ddeSDaniel P. Berrangé     abi_llong tv_nsec;
2546d5d5ddeSDaniel P. Berrangé };
2556d5d5ddeSDaniel P. Berrangé 
256ef4467e9SPaul Burton struct target_timezone {
257ef4467e9SPaul Burton     abi_int tz_minuteswest;
258ef4467e9SPaul Burton     abi_int tz_dsttime;
259ef4467e9SPaul Burton };
260ef4467e9SPaul Burton 
26166fb9763Sbellard struct target_itimerval {
26266fb9763Sbellard     struct target_timeval it_interval;
26366fb9763Sbellard     struct target_timeval it_value;
26466fb9763Sbellard };
26566fb9763Sbellard 
266905bba13SErik de Castro Lopo struct target_itimerspec {
267905bba13SErik de Castro Lopo     struct target_timespec it_interval;
268905bba13SErik de Castro Lopo     struct target_timespec it_value;
269905bba13SErik de Castro Lopo };
270905bba13SErik de Castro Lopo 
271828cb3a1SFilip Bozuta struct target__kernel_itimerspec {
272828cb3a1SFilip Bozuta     struct target__kernel_timespec it_interval;
273828cb3a1SFilip Bozuta     struct target__kernel_timespec it_value;
274828cb3a1SFilip Bozuta };
275828cb3a1SFilip Bozuta 
27619f59bceSAleksandar Markovic struct target_timex {
27719f59bceSAleksandar Markovic     abi_uint modes;              /* Mode selector */
27819f59bceSAleksandar Markovic     abi_long offset;             /* Time offset */
27919f59bceSAleksandar Markovic     abi_long freq;               /* Frequency offset */
28019f59bceSAleksandar Markovic     abi_long maxerror;           /* Maximum error (microseconds) */
28119f59bceSAleksandar Markovic     abi_long esterror;           /* Estimated error (microseconds) */
28219f59bceSAleksandar Markovic     abi_int status;              /* Clock command/status */
28319f59bceSAleksandar Markovic     abi_long constant;           /* PLL (phase-locked loop) time constant */
28419f59bceSAleksandar Markovic     abi_long precision;          /* Clock precision (microseconds, ro) */
28519f59bceSAleksandar Markovic     abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
28619f59bceSAleksandar Markovic     struct target_timeval time;  /* Current time */
28719f59bceSAleksandar Markovic     abi_long tick;               /* Microseconds between clock ticks */
28819f59bceSAleksandar Markovic     abi_long ppsfreq;            /* PPS (pulse per second) frequency */
28919f59bceSAleksandar Markovic     abi_long jitter;             /* PPS jitter (ro); nanoseconds */
29019f59bceSAleksandar Markovic     abi_int shift;               /* PPS interval duration (seconds) */
29119f59bceSAleksandar Markovic     abi_long stabil;             /* PPS stability */
29219f59bceSAleksandar Markovic     abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
29319f59bceSAleksandar Markovic     abi_long calcnt;             /* PPS calibration intervals */
29419f59bceSAleksandar Markovic     abi_long errcnt;             /* PPS calibration errors */
29519f59bceSAleksandar Markovic     abi_long stbcnt;             /* PPS stability limit exceeded */
29619f59bceSAleksandar Markovic     abi_int tai;                 /* TAI offset */
29719f59bceSAleksandar Markovic 
29819f59bceSAleksandar Markovic     /* Further padding bytes to allow for future expansion */
29919f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
30019f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
30119f59bceSAleksandar Markovic     abi_int:32; abi_int:32; abi_int:32;
30219f59bceSAleksandar Markovic };
30319f59bceSAleksandar Markovic 
3046ac03b2cSFilip Bozuta struct target__kernel_timex {
3056ac03b2cSFilip Bozuta     abi_uint modes;               /* Mode selector */
3066ac03b2cSFilip Bozuta     abi_int: 32;                  /* pad */
3076ac03b2cSFilip Bozuta     abi_llong offset;             /* Time offset */
3086ac03b2cSFilip Bozuta     abi_llong freq;               /* Frequency offset */
3096ac03b2cSFilip Bozuta     abi_llong maxerror;           /* Maximum error (microseconds) */
3106ac03b2cSFilip Bozuta     abi_llong esterror;           /* Estimated error (microseconds) */
3116ac03b2cSFilip Bozuta     abi_int status;               /* Clock command/status */
3126ac03b2cSFilip Bozuta     abi_int: 32;                  /* pad */
3136ac03b2cSFilip Bozuta     abi_llong constant;           /* PLL (phase-locked loop) time constant */
3146ac03b2cSFilip Bozuta     abi_llong precision;          /* Clock precision (microseconds, ro) */
3156ac03b2cSFilip Bozuta     abi_llong tolerance;          /* Clock freq. tolerance (ppm, ro) */
3166ac03b2cSFilip Bozuta     struct target__kernel_sock_timeval time;  /* Current time */
3176ac03b2cSFilip Bozuta     abi_llong tick;               /* Microseconds between clock ticks */
3186ac03b2cSFilip Bozuta     abi_llong ppsfreq;            /* PPS (pulse per second) frequency */
3196ac03b2cSFilip Bozuta     abi_llong jitter;             /* PPS jitter (ro); nanoseconds */
3206ac03b2cSFilip Bozuta     abi_int shift;                /* PPS interval duration (seconds) */
3216ac03b2cSFilip Bozuta     abi_int: 32;                  /* pad */
3226ac03b2cSFilip Bozuta     abi_llong stabil;             /* PPS stability */
3236ac03b2cSFilip Bozuta     abi_llong jitcnt;             /* PPS jitter limit exceeded (ro) */
3246ac03b2cSFilip Bozuta     abi_llong calcnt;             /* PPS calibration intervals */
3256ac03b2cSFilip Bozuta     abi_llong errcnt;             /* PPS calibration errors */
3266ac03b2cSFilip Bozuta     abi_llong stbcnt;             /* PPS stability limit exceeded */
3276ac03b2cSFilip Bozuta     abi_int tai;                  /* TAI offset */
3286ac03b2cSFilip Bozuta 
3296ac03b2cSFilip Bozuta     /* Further padding bytes to allow for future expansion */
3306ac03b2cSFilip Bozuta     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
3316ac03b2cSFilip Bozuta     abi_int:32; abi_int:32; abi_int:32; abi_int:32;
3326ac03b2cSFilip Bozuta     abi_int:32; abi_int:32; abi_int:32;
3336ac03b2cSFilip Bozuta };
3346ac03b2cSFilip Bozuta 
335c227f099SAnthony Liguori typedef abi_long target_clock_t;
33632f36bceSbellard 
337c596ed17Sbellard #define TARGET_HZ 100
338c596ed17Sbellard 
33932f36bceSbellard struct target_tms {
340c227f099SAnthony Liguori     target_clock_t tms_utime;
341c227f099SAnthony Liguori     target_clock_t tms_stime;
342c227f099SAnthony Liguori     target_clock_t tms_cutime;
343c227f099SAnthony Liguori     target_clock_t tms_cstime;
34432f36bceSbellard };
34532f36bceSbellard 
3466180a181Sbellard struct target_utimbuf {
347992f48a0Sblueswir1     abi_long actime;
348992f48a0Sblueswir1     abi_long modtime;
3496180a181Sbellard };
3506180a181Sbellard 
351f2674e31Sbellard struct target_sel_arg_struct {
352992f48a0Sblueswir1     abi_long n;
353992f48a0Sblueswir1     abi_long inp, outp, exp;
354992f48a0Sblueswir1     abi_long tvp;
355f2674e31Sbellard };
356f2674e31Sbellard 
35731e31b8aSbellard struct target_iovec {
358992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
359992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
36031e31b8aSbellard };
36131e31b8aSbellard 
3621a9353d2Sbellard struct target_msghdr {
363992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
3641a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
365992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
366992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
367992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
368992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
3691a9353d2Sbellard     unsigned int msg_flags;
3701a9353d2Sbellard };
3711a9353d2Sbellard 
3727854b056Sbellard struct target_cmsghdr {
373992f48a0Sblueswir1     abi_long     cmsg_len;
3747854b056Sbellard     int          cmsg_level;
3757854b056Sbellard     int          cmsg_type;
3767854b056Sbellard };
3777854b056Sbellard 
3787854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
379ee104587SJonathan Neuschäfer #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
380ee104587SJonathan Neuschäfer                                __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
381992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
382992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
383ad762b99SPeter Maydell #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
384ad762b99SPeter Maydell                                 TARGET_CMSG_ALIGN(len))
385ad762b99SPeter Maydell #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
3867854b056Sbellard 
3877854b056Sbellard static __inline__ struct target_cmsghdr *
388ee104587SJonathan Neuschäfer __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
389ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg,
390ee104587SJonathan Neuschäfer                      struct target_cmsghdr *__cmsg_start)
3917854b056Sbellard {
3922b8bdefcSths   struct target_cmsghdr *__ptr;
3937854b056Sbellard 
3942b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
395cbb21eedSMatthias Braun                                     + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
396ee104587SJonathan Neuschäfer   if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
397ee104587SJonathan Neuschäfer       > tswapal(__mhdr->msg_controllen)) {
3987854b056Sbellard     /* No more entries.  */
3992b8bdefcSths     return (struct target_cmsghdr *)0;
400ee104587SJonathan Neuschäfer   }
401ee104587SJonathan Neuschäfer   return __ptr;
4027854b056Sbellard }
4037854b056Sbellard 
404f19e00d7SAlexander Graf struct target_mmsghdr {
405f19e00d7SAlexander Graf     struct target_msghdr msg_hdr;              /* Message header */
406f19e00d7SAlexander Graf     unsigned int         msg_len;              /* Number of bytes transmitted */
407f19e00d7SAlexander Graf };
4087854b056Sbellard 
40931e31b8aSbellard struct  target_rusage {
41031e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
41131e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
412992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
413992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
414992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
415992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
416992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
417992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
418992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
419992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
420992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
421992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
422992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
423992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
424992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
425992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
42631e31b8aSbellard };
42731e31b8aSbellard 
42831e31b8aSbellard typedef struct {
42931e31b8aSbellard         int     val[2];
430c227f099SAnthony Liguori } kernel_fsid_t;
43131e31b8aSbellard 
432dab2ed99Sbellard struct target_dirent {
433992f48a0Sblueswir1         abi_long        d_ino;
434992f48a0Sblueswir1         abi_long        d_off;
435dab2ed99Sbellard         unsigned short  d_reclen;
436333858b7SDmitry V. Levin         char            d_name[];
437dab2ed99Sbellard };
438dab2ed99Sbellard 
439dab2ed99Sbellard struct target_dirent64 {
4401962cb00SRichard Henderson 	abi_ullong      d_ino;
4411962cb00SRichard Henderson 	abi_llong       d_off;
4421962cb00SRichard Henderson 	abi_ushort      d_reclen;
443dab2ed99Sbellard 	unsigned char	d_type;
444540a736fSRichard Henderson 	char		d_name[];
445dab2ed99Sbellard };
446dab2ed99Sbellard 
447dab2ed99Sbellard 
44831e31b8aSbellard /* mostly generic signal stuff */
449992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
450992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
451992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
45231e31b8aSbellard 
45331e31b8aSbellard #ifdef TARGET_MIPS
45431e31b8aSbellard #define TARGET_NSIG	   128
45531e31b8aSbellard #else
45631e31b8aSbellard #define TARGET_NSIG	   64
45731e31b8aSbellard #endif
458992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
45931e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
46031e31b8aSbellard 
46131e31b8aSbellard typedef struct {
462992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
463c227f099SAnthony Liguori } target_sigset_t;
46431e31b8aSbellard 
46566fb9763Sbellard #ifdef BSWAP_NEEDED
466c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
46766fb9763Sbellard {
46866fb9763Sbellard     int i;
46966fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
470cbb21eedSMatthias Braun         d->sig[i] = tswapal(s->sig[i]);
47166fb9763Sbellard }
47266fb9763Sbellard #else
473c227f099SAnthony Liguori static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
47466fb9763Sbellard {
47566fb9763Sbellard     *d = *s;
47666fb9763Sbellard }
47766fb9763Sbellard #endif
47866fb9763Sbellard 
479c227f099SAnthony Liguori static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
48066fb9763Sbellard {
48166fb9763Sbellard     int i;
48266fb9763Sbellard     d->sig[0] = set;
48366fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
48466fb9763Sbellard         d->sig[i] = 0;
48566fb9763Sbellard }
48666fb9763Sbellard 
487c227f099SAnthony Liguori void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
488c227f099SAnthony Liguori void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
489992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
49066fb9763Sbellard                                const sigset_t *sigset);
49166fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
492992f48a0Sblueswir1                                const abi_ulong *old_sigset);
49366fb9763Sbellard struct target_sigaction;
49466fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
49502fb28e8SRichard Henderson                  struct target_sigaction *oact, abi_ulong ka_restorer);
49666fb9763Sbellard 
4979850f9f6SLaurent Vivier #include "target_signal.h"
4989850f9f6SLaurent Vivier 
4997f047de1SRichard Henderson #ifdef TARGET_SA_RESTORER
5007f047de1SRichard Henderson #define TARGET_ARCH_HAS_SA_RESTORER 1
5017f047de1SRichard Henderson #endif
5027f047de1SRichard Henderson 
5036049f4f8SRichard Henderson #if defined(TARGET_ALPHA)
50402d0de10SRichard Henderson typedef int32_t target_old_sa_flags;
50502d0de10SRichard Henderson #else
50602d0de10SRichard Henderson typedef abi_ulong target_old_sa_flags;
50702d0de10SRichard Henderson #endif
508106ec879Sbellard 
50902d0de10SRichard Henderson #if defined(TARGET_MIPS)
510106ec879Sbellard struct target_sigaction {
511540635baSths 	uint32_t	sa_flags;
512d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
513540635baSths 	uint32_t	_sa_handler;
514540635baSths #else
515992f48a0Sblueswir1 	abi_ulong	_sa_handler;
516540635baSths #endif
517c227f099SAnthony Liguori 	target_sigset_t	sa_mask;
5187f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
5197f047de1SRichard Henderson         /* ??? This is always present, but ignored unless O32.  */
5207f047de1SRichard Henderson         abi_ulong sa_restorer;
5217f047de1SRichard Henderson #endif
522106ec879Sbellard };
523106ec879Sbellard #else
5242521d698Sbellard struct target_old_sigaction {
525992f48a0Sblueswir1         abi_ulong _sa_handler;
526992f48a0Sblueswir1         abi_ulong sa_mask;
52702d0de10SRichard Henderson         target_old_sa_flags sa_flags;
5287f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
529992f48a0Sblueswir1         abi_ulong sa_restorer;
5307f047de1SRichard Henderson #endif
5312521d698Sbellard };
5322521d698Sbellard 
5332521d698Sbellard struct target_sigaction {
534992f48a0Sblueswir1         abi_ulong _sa_handler;
535992f48a0Sblueswir1         abi_ulong sa_flags;
5367f047de1SRichard Henderson #ifdef TARGET_ARCH_HAS_SA_RESTORER
537992f48a0Sblueswir1         abi_ulong sa_restorer;
5387f047de1SRichard Henderson #endif
539c227f099SAnthony Liguori         target_sigset_t sa_mask;
5405de154e8SLaurent Vivier #ifdef TARGET_ARCH_HAS_KA_RESTORER
5415de154e8SLaurent Vivier         abi_ulong ka_restorer;
5425de154e8SLaurent Vivier #endif
5432521d698Sbellard };
544106ec879Sbellard #endif
5452521d698Sbellard 
5462521d698Sbellard typedef union target_sigval {
5472521d698Sbellard 	int sival_int;
548992f48a0Sblueswir1         abi_ulong sival_ptr;
549c227f099SAnthony Liguori } target_sigval_t;
5506d5e216dSbellard #if 0
5516d5e216dSbellard #if defined (TARGET_SPARC)
5526d5e216dSbellard typedef struct {
5536d5e216dSbellard 	struct {
554992f48a0Sblueswir1 		abi_ulong psr;
555992f48a0Sblueswir1 		abi_ulong pc;
556992f48a0Sblueswir1 		abi_ulong npc;
557992f48a0Sblueswir1 		abi_ulong y;
558992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
5596d5e216dSbellard 	}		si_regs;
5606d5e216dSbellard 	int		si_mask;
5616d5e216dSbellard } __siginfo_t;
5626d5e216dSbellard 
5636d5e216dSbellard typedef struct {
5646d5e216dSbellard 	unsigned   long si_float_regs [32];
5656d5e216dSbellard 	unsigned   long si_fsr;
5666d5e216dSbellard 	unsigned   long si_fpqdepth;
5676d5e216dSbellard 	struct {
5686d5e216dSbellard 		unsigned long *insn_addr;
5696d5e216dSbellard 		unsigned long insn;
5706d5e216dSbellard 	} si_fpqueue [16];
5716d5e216dSbellard } __siginfo_fpu_t;
5726d5e216dSbellard #endif
5736d5e216dSbellard #endif
5742521d698Sbellard 
5752521d698Sbellard #define TARGET_SI_MAX_SIZE	128
576aa5e03d2SMaxim Ostapenko 
577aa5e03d2SMaxim Ostapenko #if TARGET_ABI_BITS == 32
578aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
579aa5e03d2SMaxim Ostapenko #else
580aa5e03d2SMaxim Ostapenko #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
581aa5e03d2SMaxim Ostapenko #endif
582aa5e03d2SMaxim Ostapenko 
583aa5e03d2SMaxim Ostapenko #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
5842521d698Sbellard 
585a70dadc7SPeter Maydell /* Within QEMU the top 16 bits of si_code indicate which of the parts of
586a70dadc7SPeter Maydell  * the union in target_siginfo is valid. This only applies between
587a70dadc7SPeter Maydell  * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
588a70dadc7SPeter Maydell  * appear either within host siginfo_t or in target_siginfo structures
589a70dadc7SPeter Maydell  * which we get from the guest userspace program. (The Linux kernel
590a70dadc7SPeter Maydell  * does a similar thing with using the top bits for its own internal
591a70dadc7SPeter Maydell  * purposes but not letting them be visible to userspace.)
592a70dadc7SPeter Maydell  */
593a70dadc7SPeter Maydell #define QEMU_SI_KILL 0
594a70dadc7SPeter Maydell #define QEMU_SI_TIMER 1
595a70dadc7SPeter Maydell #define QEMU_SI_POLL 2
596a70dadc7SPeter Maydell #define QEMU_SI_FAULT 3
597a70dadc7SPeter Maydell #define QEMU_SI_CHLD 4
598a70dadc7SPeter Maydell #define QEMU_SI_RT 5
599a70dadc7SPeter Maydell 
6002521d698Sbellard typedef struct target_siginfo {
6013f53d546Spbrook #ifdef TARGET_MIPS
6023f53d546Spbrook 	int si_signo;
6033f53d546Spbrook 	int si_code;
6043f53d546Spbrook 	int si_errno;
6053f53d546Spbrook #else
6062521d698Sbellard 	int si_signo;
6072521d698Sbellard 	int si_errno;
6082521d698Sbellard 	int si_code;
6093f53d546Spbrook #endif
6102521d698Sbellard 
6112521d698Sbellard 	union {
6122521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
6132521d698Sbellard 
6142521d698Sbellard 		/* kill() */
6152521d698Sbellard 		struct {
6162521d698Sbellard 			pid_t _pid;		/* sender's pid */
6172521d698Sbellard 			uid_t _uid;		/* sender's uid */
6182521d698Sbellard 		} _kill;
6192521d698Sbellard 
6202521d698Sbellard 		/* POSIX.1b timers */
6212521d698Sbellard 		struct {
6222521d698Sbellard 			unsigned int _timer1;
6232521d698Sbellard 			unsigned int _timer2;
6242521d698Sbellard 		} _timer;
6252521d698Sbellard 
6262521d698Sbellard 		/* POSIX.1b signals */
6272521d698Sbellard 		struct {
6282521d698Sbellard 			pid_t _pid;		/* sender's pid */
6292521d698Sbellard 			uid_t _uid;		/* sender's uid */
630c227f099SAnthony Liguori 			target_sigval_t _sigval;
6312521d698Sbellard 		} _rt;
6322521d698Sbellard 
6332521d698Sbellard 		/* SIGCHLD */
6342521d698Sbellard 		struct {
6352521d698Sbellard 			pid_t _pid;		/* which child */
6362521d698Sbellard 			uid_t _uid;		/* sender's uid */
6372521d698Sbellard 			int _status;		/* exit code */
638c227f099SAnthony Liguori 			target_clock_t _utime;
639c227f099SAnthony Liguori                         target_clock_t _stime;
6402521d698Sbellard 		} _sigchld;
6412521d698Sbellard 
6422521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
6432521d698Sbellard 		struct {
644992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
6452521d698Sbellard 		} _sigfault;
6462521d698Sbellard 
6472521d698Sbellard 		/* SIGPOLL */
6482521d698Sbellard 		struct {
6492521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
6502521d698Sbellard 			int _fd;
6512521d698Sbellard 		} _sigpoll;
6522521d698Sbellard 	} _sifields;
653c227f099SAnthony Liguori } target_siginfo_t;
6542521d698Sbellard 
6552521d698Sbellard /*
6562521d698Sbellard  * si_code values
6572521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
6582521d698Sbellard  */
6592521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
6602521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
6612521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
6622521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
6632521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
6642521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
6652521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
6662521d698Sbellard 
6672521d698Sbellard /*
6682521d698Sbellard  * SIGILL si_codes
6692521d698Sbellard  */
670ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
6712521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
672ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
673ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
674ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
675ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
676ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
677ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
6782521d698Sbellard 
6792521d698Sbellard /*
6802521d698Sbellard  * SIGFPE si_codes
6812521d698Sbellard  */
6822521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
6832521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
6842521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
6852521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
6862521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
6872521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
6882521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
6892521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
69021ba8564SRichard Henderson #define TARGET_FPE_FLTUNK      (14) /* undiagnosed fp exception */
69121ba8564SRichard Henderson #define TARGET_NSIGFPE         15
6922521d698Sbellard 
6932521d698Sbellard /*
6942521d698Sbellard  * SIGSEGV si_codes
6952521d698Sbellard  */
6962521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
6972521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
698de2fdd56SChen Gang #define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
6992521d698Sbellard 
7002521d698Sbellard /*
701ffa65c3bSbellard  * SIGBUS si_codes
702ffa65c3bSbellard  */
703ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
704b4916d7bSDong Xu Wang #define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
705ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
706de2fdd56SChen Gang /* hardware memory error consumed on a machine check: action required */
707de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AR    (4)
708de2fdd56SChen Gang /* hardware memory error detected in process but not consumed: action optional*/
709de2fdd56SChen Gang #define TARGET_BUS_MCEERR_AO    (5)
710ffa65c3bSbellard 
711ffa65c3bSbellard /*
7122521d698Sbellard  * SIGTRAP si_codes
7132521d698Sbellard  */
7142521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
7152521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
716de2fdd56SChen Gang #define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
717de2fdd56SChen Gang #define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
7182521d698Sbellard 
7199de5e440Sbellard struct target_rlimit {
720992f48a0Sblueswir1         abi_ulong   rlim_cur;
721992f48a0Sblueswir1         abi_ulong   rlim_max;
7229de5e440Sbellard };
7239de5e440Sbellard 
72481bbe906Stakasi-y@ops.dti.ne.jp #if defined(TARGET_ALPHA)
725e476492eSAurelien Jarno #define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
7266cafd027SMatthias Braun #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
72781bbe906Stakasi-y@ops.dti.ne.jp #define TARGET_RLIM_INFINITY	0x7fffffffUL
72881bbe906Stakasi-y@ops.dti.ne.jp #else
72926b746dbSMatthias Braun #define TARGET_RLIM_INFINITY	((abi_ulong)-1)
73081bbe906Stakasi-y@ops.dti.ne.jp #endif
73181bbe906Stakasi-y@ops.dti.ne.jp 
732e22b7015SWesley W. Terpstra #if defined(TARGET_MIPS)
733e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
734e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
735e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
736e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
737e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
738e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		7
739e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		8
740e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		5
741e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		9
742e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		6
743e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
744e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
745e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
746e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
747e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
748e22b7015SWesley W. Terpstra #else
749e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CPU		0
750e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_FSIZE		1
751e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_DATA		2
752e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_STACK		3
753e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_CORE		4
754e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RSS		5
7556cafd027SMatthias Braun #if defined(TARGET_SPARC)
7566cafd027SMatthias Braun #define TARGET_RLIMIT_NOFILE		6
7576cafd027SMatthias Braun #define TARGET_RLIMIT_NPROC		7
7586cafd027SMatthias Braun #else
759e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NPROC		6
760e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NOFILE		7
7616cafd027SMatthias Braun #endif
762e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MEMLOCK		8
763e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_AS		9
764e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_LOCKS		10
765e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_SIGPENDING	11
766e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_MSGQUEUE		12
767e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_NICE		13
768e22b7015SWesley W. Terpstra #define TARGET_RLIMIT_RTPRIO		14
769e22b7015SWesley W. Terpstra #endif
770e22b7015SWesley W. Terpstra 
7719de5e440Sbellard struct target_pollfd {
7729de5e440Sbellard     int fd;           /* file descriptor */
7739de5e440Sbellard     short events;     /* requested events */
7749de5e440Sbellard     short revents;    /* returned events */
7759de5e440Sbellard };
7769de5e440Sbellard 
7778e5a0667Sbellard /* virtual terminal ioctls */
7780221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
7790221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
7808e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
781f7680a55SUlrich Hecht #define TARGET_KDSETMODE       0x4b3a
782f7680a55SUlrich Hecht #define TARGET_KDGKBMODE       0x4b44
783f7680a55SUlrich Hecht #define TARGET_KDSKBMODE       0x4b45
7840221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
7850221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
786e6fe18fbSCédric VINCENT #define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
787e6fe18fbSCédric VINCENT #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
788e6fe18fbSCédric VINCENT #define TARGET_KDGETLED        0x4B31	/* return current led state */
789e6fe18fbSCédric VINCENT #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
790ca56f5b5SPaul Burton #define TARGET_KDSIGACCEPT     0x4B4E
7918e5a0667Sbellard 
792373b067fSFilip Bozuta struct target_rtc_pll_info {
793373b067fSFilip Bozuta     int pll_ctrl;
794373b067fSFilip Bozuta     int pll_value;
795373b067fSFilip Bozuta     int pll_max;
796373b067fSFilip Bozuta     int pll_min;
797373b067fSFilip Bozuta     int pll_posmult;
798373b067fSFilip Bozuta     int pll_negmult;
799373b067fSFilip Bozuta     abi_long pll_clock;
800373b067fSFilip Bozuta };
801373b067fSFilip Bozuta 
80268365f96SFilip Bozuta /* real time clock ioctls */
80368365f96SFilip Bozuta #define TARGET_RTC_AIE_ON           TARGET_IO('p', 0x01)
80468365f96SFilip Bozuta #define TARGET_RTC_AIE_OFF          TARGET_IO('p', 0x02)
80568365f96SFilip Bozuta #define TARGET_RTC_UIE_ON           TARGET_IO('p', 0x03)
80668365f96SFilip Bozuta #define TARGET_RTC_UIE_OFF          TARGET_IO('p', 0x04)
80768365f96SFilip Bozuta #define TARGET_RTC_PIE_ON           TARGET_IO('p', 0x05)
80868365f96SFilip Bozuta #define TARGET_RTC_PIE_OFF          TARGET_IO('p', 0x06)
80968365f96SFilip Bozuta #define TARGET_RTC_WIE_ON           TARGET_IO('p', 0x0f)
81068365f96SFilip Bozuta #define TARGET_RTC_WIE_OFF          TARGET_IO('p', 0x10)
811178b14a0SFilip Bozuta #define TARGET_RTC_ALM_READ         TARGET_IOR('p', 0x08, struct rtc_time)
812178b14a0SFilip Bozuta #define TARGET_RTC_ALM_SET          TARGET_IOW('p', 0x07, struct rtc_time)
813178b14a0SFilip Bozuta #define TARGET_RTC_RD_TIME          TARGET_IOR('p', 0x09, struct rtc_time)
814178b14a0SFilip Bozuta #define TARGET_RTC_SET_TIME         TARGET_IOW('p', 0x0a, struct rtc_time)
815fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_READ        TARGET_IOR('p', 0x0b, abi_ulong)
816fa857eb5SFilip Bozuta #define TARGET_RTC_IRQP_SET         TARGET_IOW('p', 0x0c, abi_ulong)
817fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_READ       TARGET_IOR('p', 0x0d, abi_ulong)
818fa857eb5SFilip Bozuta #define TARGET_RTC_EPOCH_SET        TARGET_IOW('p', 0x0e, abi_ulong)
819abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_RD         TARGET_IOR('p', 0x10, struct rtc_wkalrm)
820abc81bf6SFilip Bozuta #define TARGET_RTC_WKALM_SET        TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
821373b067fSFilip Bozuta #define TARGET_RTC_PLL_GET          TARGET_IOR('p', 0x11,                      \
822373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
823373b067fSFilip Bozuta #define TARGET_RTC_PLL_SET          TARGET_IOW('p', 0x12,                      \
824373b067fSFilip Bozuta                                                struct target_rtc_pll_info)
825a7b09746SFilip Bozuta #define TARGET_RTC_VL_READ          TARGET_IOR('p', 0x13, int)
826a7b09746SFilip Bozuta #define TARGET_RTC_VL_CLR           TARGET_IO('p', 0x14)
82768365f96SFilip Bozuta 
828d14eabbeSAleksandar Markovic #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
829d14eabbeSAleksandar Markovic        defined(TARGET_XTENSA)
8304e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       TARGET_IOR('f', 123, int)
8314e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       TARGET_IOW('f', 124, int)
832e1be1606SAleksandar Markovic #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
833c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
834405b4915SHelge Deller #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
835e1be1606SAleksandar Markovic #else
8364e4b173fSAleksandar Markovic #define TARGET_FIOGETOWN       0x8903
8374e4b173fSAleksandar Markovic #define TARGET_FIOSETOWN       0x8901
8382521d698Sbellard #define TARGET_SIOCATMARK      0x8905
839c495a793SAleksandar Markovic #define TARGET_SIOCSPGRP       0x8902
840405b4915SHelge Deller #define TARGET_SIOCGPGRP       0x8904
841e1be1606SAleksandar Markovic #endif
842c495a793SAleksandar Markovic 
8436d5d5ddeSDaniel P. Berrangé #if defined(TARGET_SH4)
8446d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   TARGET_IOR('s', 100, struct target_timeval)
8456d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
8466d5d5ddeSDaniel P. Berrangé #else
8476d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_OLD   0x8906
8486d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_OLD 0x8907
8496d5d5ddeSDaniel P. Berrangé #endif
8506d5d5ddeSDaniel P. Berrangé 
8516d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMP_NEW   TARGET_IOR(0x89, 0x06, abi_llong[2])
8526d5d5ddeSDaniel P. Berrangé #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
8532521d698Sbellard 
85431e31b8aSbellard /* Networking ioctls */
85531e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
85631e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
85731e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
85831e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
85931e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
86031e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
86131e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
86231e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
86331e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
86431e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
86531e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
86631e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
86731e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
86831e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
86931e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
87031e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
87131e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
87231e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
87331e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
87431e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
87531e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
87631e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
87731e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
87831e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
87931e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
88031e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
88131e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
88231e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
88331e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
884f63eb01aSPaul Burton #define TARGET_SIOCGIFINDEX    0x8933
8854bdcd79eSNeng Chen #define TARGET_SIOCSIFPFLAGS   0x8934          /* set extended flags          */
8864bdcd79eSNeng Chen #define TARGET_SIOCGIFPFLAGS   0x8935          /* get extended flags          */
88731e31b8aSbellard 
88831e31b8aSbellard /* Bridging control calls */
88931e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
89031e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
89131e31b8aSbellard 
89231e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
89331e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
89431e31b8aSbellard 
89531e31b8aSbellard /* ARP cache control calls. */
89631e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
89731e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
89831e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
89931e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
90031e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
90131e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
90231e31b8aSbellard 
90331e31b8aSbellard /* RARP cache control calls. */
90431e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
90531e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
90631e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
90731e31b8aSbellard 
90831e31b8aSbellard /* Driver configuration calls */
90931e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
91031e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
91131e31b8aSbellard 
91231e31b8aSbellard /* DLCI configuration calls */
91331e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
91431e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
91531e31b8aSbellard 
91686fcd946SLaurent Vivier /* From <linux/wireless.h> */
91786fcd946SLaurent Vivier 
91886fcd946SLaurent Vivier #define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
91931e31b8aSbellard 
9206addf06aSShu-Chun Weng /* From <linux/if_tun.h> */
9216addf06aSShu-Chun Weng 
9226addf06aSShu-Chun Weng #define TARGET_TUNSETDEBUG        TARGET_IOW('T', 201, int)
9236addf06aSShu-Chun Weng #define TARGET_TUNSETIFF          TARGET_IOW('T', 202, int)
9246addf06aSShu-Chun Weng #define TARGET_TUNSETPERSIST      TARGET_IOW('T', 203, int)
9256addf06aSShu-Chun Weng #define TARGET_TUNSETOWNER        TARGET_IOW('T', 204, int)
9266addf06aSShu-Chun Weng #define TARGET_TUNSETLINK         TARGET_IOW('T', 205, int)
9276addf06aSShu-Chun Weng #define TARGET_TUNSETGROUP        TARGET_IOW('T', 206, int)
9286addf06aSShu-Chun Weng #define TARGET_TUNGETFEATURES     TARGET_IOR('T', 207, unsigned int)
9296addf06aSShu-Chun Weng #define TARGET_TUNSETOFFLOAD      TARGET_IOW('T', 208, unsigned int)
9306addf06aSShu-Chun Weng #define TARGET_TUNSETTXFILTER     TARGET_IOW('T', 209, unsigned int)
9316addf06aSShu-Chun Weng #define TARGET_TUNGETIFF          TARGET_IOR('T', 210, unsigned int)
9326addf06aSShu-Chun Weng #define TARGET_TUNGETSNDBUF       TARGET_IOR('T', 211, int)
9336addf06aSShu-Chun Weng #define TARGET_TUNSETSNDBUF       TARGET_IOW('T', 212, int)
9346addf06aSShu-Chun Weng /*
9356addf06aSShu-Chun Weng  * TUNATTACHFILTER and TUNDETACHFILTER are not supported. Linux kernel keeps a
9366addf06aSShu-Chun Weng  * user pointer in TUNATTACHFILTER, which we are not able to correctly handle.
9376addf06aSShu-Chun Weng  */
9386addf06aSShu-Chun Weng #define TARGET_TUNGETVNETHDRSZ    TARGET_IOR('T', 215, int)
9396addf06aSShu-Chun Weng #define TARGET_TUNSETVNETHDRSZ    TARGET_IOW('T', 216, int)
9406addf06aSShu-Chun Weng #define TARGET_TUNSETQUEUE        TARGET_IOW('T', 217, int)
9416addf06aSShu-Chun Weng #define TARGET_TUNSETIFINDEX      TARGET_IOW('T', 218, unsigned int)
9426addf06aSShu-Chun Weng /* TUNGETFILTER is not supported: see TUNATTACHFILTER. */
9436addf06aSShu-Chun Weng #define TARGET_TUNSETVNETLE       TARGET_IOW('T', 220, int)
9446addf06aSShu-Chun Weng #define TARGET_TUNGETVNETLE       TARGET_IOR('T', 221, int)
9456addf06aSShu-Chun Weng #define TARGET_TUNSETVNETBE       TARGET_IOW('T', 222, int)
9466addf06aSShu-Chun Weng #define TARGET_TUNGETVNETBE       TARGET_IOR('T', 223, int)
9476addf06aSShu-Chun Weng #define TARGET_TUNSETSTEERINGEBPF TARGET_IOR('T', 224, int)
9486addf06aSShu-Chun Weng #define TARGET_TUNSETFILTEREBPF   TARGET_IOR('T', 225, int)
9496addf06aSShu-Chun Weng #define TARGET_TUNSETCARRIER      TARGET_IOW('T', 226, int)
9506addf06aSShu-Chun Weng #define TARGET_TUNGETDEVNETNS     TARGET_IO('T', 227)
9516addf06aSShu-Chun Weng 
952d6d6d6feSMarco A L Barbosa /* From <linux/random.h> */
953d6d6d6feSMarco A L Barbosa 
954d6d6d6feSMarco A L Barbosa #define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
955d6d6d6feSMarco A L Barbosa #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
956d6d6d6feSMarco A L Barbosa #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
957d6d6d6feSMarco A L Barbosa #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
95892c096f0SAleksandar Markovic #define TARGET_RNDRESEEDCRNG   TARGET_IO('R', 0x07)
959d6d6d6feSMarco A L Barbosa 
96031e31b8aSbellard /* From <linux/fs.h> */
96131e31b8aSbellard 
96231e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
96331e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
96431e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
96531e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
96631e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
96731e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
96831e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
96931e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
97031e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
97131e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
97231e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
97331e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
974fff8c539SAndreas Färber #define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
97531e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
976c8b0bf54SPeter Maydell #define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
977c8b0bf54SPeter Maydell #define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
978edafea13SAlexander Graf #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
979edafea13SAlexander Graf                                              /* return device size in bytes
980edafea13SAlexander Graf                                                 (u64 *arg) */
9814715856aSPeter Maydell 
9824715856aSPeter Maydell #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
9834715856aSPeter Maydell #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
9844715856aSPeter Maydell #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
9854715856aSPeter Maydell #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
9864715856aSPeter Maydell #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
9874715856aSPeter Maydell #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
9884715856aSPeter Maydell #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
9894715856aSPeter Maydell #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
9904715856aSPeter Maydell #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
9914715856aSPeter Maydell 
992ab22b4ddSYunqiang Su /* From <linux/fd.h> */
993ab22b4ddSYunqiang Su 
9947e35fc8bSAleksandar Markovic #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
9957e35fc8bSAleksandar Markovic #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
99608e3ce59SAleksandar Markovic #define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
99708e3ce59SAleksandar Markovic #define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct format_descr)
99808e3ce59SAleksandar Markovic #define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
99981eb1a36SAleksandar Markovic #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
1000ab22b4ddSYunqiang Su #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
100181eb1a36SAleksandar Markovic #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
100281eb1a36SAleksandar Markovic #define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
10035eea9429SAleksandar Markovic #define TARGET_FDRESET        TARGET_IO(2, 0x54)
10045eea9429SAleksandar Markovic #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
10055eea9429SAleksandar Markovic #define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
10065eea9429SAleksandar Markovic #define TARGET_FDEJECT        TARGET_IO(2, 0x5a)
1007ab22b4ddSYunqiang Su 
100831e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
100931e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
101021992cb6SHelge Deller 
101121992cb6SHelge Deller #define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
101221992cb6SHelge Deller #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
101321992cb6SHelge Deller 
10145ae774a9SAleksandar Markovic /*
10155ae774a9SAleksandar Markovic  * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
10165ae774a9SAleksandar Markovic  * claim type "long" but the actual type used by the kernel is "int".
101760807231SPeter Maydell  */
10181847b7baSPeter Maydell #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
10191847b7baSPeter Maydell #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
10205ae774a9SAleksandar Markovic #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
10215ae774a9SAleksandar Markovic #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
1022285da2b9SPeter Maydell #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
10230b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
10240b471ba6SAleksandar Markovic #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
10250d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
10260d899cd6SAleksandar Markovic #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
102731e31b8aSbellard 
1028d6092e08SFilip Bozuta /* btrfs ioctls */
102948f670ecSThomas Huth #ifdef HAVE_BTRFS_H
1030527e8d8fSFilip Bozuta #define TARGET_BTRFS_IOC_SNAP_CREATE            TARGET_IOWU(BTRFS_IOCTL_MAGIC, 1)
10319bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_SCAN_DEV               TARGET_IOWU(BTRFS_IOCTL_MAGIC, 4)
10329bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_FORGET_DEV             TARGET_IOWU(BTRFS_IOCTL_MAGIC, 5)
10339bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_ADD_DEV                TARGET_IOWU(BTRFS_IOCTL_MAGIC, 10)
10349bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_RM_DEV                 TARGET_IOWU(BTRFS_IOCTL_MAGIC, 11)
1035d6092e08SFilip Bozuta #define TARGET_BTRFS_IOC_SUBVOL_CREATE          TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14)
1036527e8d8fSFilip Bozuta #define TARGET_BTRFS_IOC_SNAP_DESTROY           TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15)
10370ff496a0SFilip Bozuta #define TARGET_BTRFS_IOC_INO_LOOKUP             TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18)
1038784c08c8SFilip Bozuta #define TARGET_BTRFS_IOC_DEFAULT_SUBVOL         TARGET_IOW(BTRFS_IOCTL_MAGIC, 19,\
1039784c08c8SFilip Bozuta                                                            abi_ullong)
1040d6092e08SFilip Bozuta #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS        TARGET_IOR(BTRFS_IOCTL_MAGIC, 25,\
1041d6092e08SFilip Bozuta                                                            abi_ullong)
1042d6092e08SFilip Bozuta #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS        TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\
1043d6092e08SFilip Bozuta                                                            abi_ullong)
10449a5a5a05SFilip Bozuta #define TARGET_BTRFS_IOC_SCRUB                  TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 27)
10459a5a5a05SFilip Bozuta #define TARGET_BTRFS_IOC_SCRUB_CANCEL           TARGET_IO(BTRFS_IOCTL_MAGIC, 28)
10469a5a5a05SFilip Bozuta #define TARGET_BTRFS_IOC_SCRUB_PROGRESS         TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 29)
10479bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_DEV_INFO               TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
10480ff496a0SFilip Bozuta #define TARGET_BTRFS_IOC_INO_PATHS              TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 35)
10490ff496a0SFilip Bozuta #define TARGET_BTRFS_IOC_LOGICAL_INO            TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 36)
105053906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QUOTA_CTL              TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 40)
105153906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QGROUP_ASSIGN          TARGET_IOWU(BTRFS_IOCTL_MAGIC, 41)
105253906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QGROUP_CREATE          TARGET_IOWU(BTRFS_IOCTL_MAGIC, 42)
105353906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QGROUP_LIMIT           TARGET_IORU(BTRFS_IOCTL_MAGIC, 43)
105453906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QUOTA_RESCAN           TARGET_IOWU(BTRFS_IOCTL_MAGIC, 44)
105553906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS    TARGET_IORU(BTRFS_IOCTL_MAGIC, 45)
105653906f68SFilip Bozuta #define TARGET_BTRFS_IOC_QUOTA_RESCAN_WAIT      TARGET_IO(BTRFS_IOCTL_MAGIC, 46)
10579bbd60e7SFilip Bozuta #define TARGET_BTRFS_IOC_GET_DEV_STATS          TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52)
105849b422a8SFilip Bozuta #define TARGET_BTRFS_IOC_GET_FEATURES           TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
105949b422a8SFilip Bozuta #define TARGET_BTRFS_IOC_SET_FEATURES           TARGET_IOWU(BTRFS_IOCTL_MAGIC, 57)
106049b422a8SFilip Bozuta #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
10610ff496a0SFilip Bozuta #define TARGET_BTRFS_IOC_LOGICAL_INO_V2         TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59)
1062d6092e08SFilip Bozuta #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO        TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
1063784c08c8SFilip Bozuta #define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF     TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 61)
10640ff496a0SFilip Bozuta #define TARGET_BTRFS_IOC_INO_LOOKUP_USER        TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62)
10655d5d1752SFilip Bozuta #endif
1066d6092e08SFilip Bozuta 
10676c753a63SCortland Tölva /* usb ioctls */
10686c753a63SCortland Tölva #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
10696c753a63SCortland Tölva #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
10706c753a63SCortland Tölva #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
10716c753a63SCortland Tölva #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
10726c753a63SCortland Tölva #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U',  5)
10736c753a63SCortland Tölva #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
1074a133367eSCortland Tölva #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
1075a133367eSCortland Tölva #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
1076a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
1077a133367eSCortland Tölva #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
10786c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
10796c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
10806c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
10816c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
10826c753a63SCortland Tölva #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
10836c753a63SCortland Tölva #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
10846c753a63SCortland Tölva #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
10856c753a63SCortland Tölva #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
10866c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
10876c753a63SCortland Tölva #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
10886c753a63SCortland Tölva #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
10896c753a63SCortland Tölva #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
10906c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
10916c753a63SCortland Tölva #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
10926c753a63SCortland Tölva #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
10936c753a63SCortland Tölva #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
10946c753a63SCortland Tölva 
109531e31b8aSbellard /* cdrom commands */
109631e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
109731e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
109831e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
109931e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
110031e31b8aSbellard                                            (struct cdrom_ti) */
110131e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
110231e31b8aSbellard                                            (struct cdrom_tochdr) */
110331e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
110431e31b8aSbellard                                            (struct cdrom_tocentry) */
110531e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
110631e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
110731e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
110831e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
110931e31b8aSbellard                                            (struct cdrom_volctrl) */
111031e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
111131e31b8aSbellard                                            (struct cdrom_subchnl) */
111231e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
111331e31b8aSbellard                                            (struct cdrom_read) */
111431e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
111531e31b8aSbellard                                            (struct cdrom_read) */
111631e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
111731e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
111831e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
111931e31b8aSbellard                                            address of multi session disks
112031e31b8aSbellard                                            (struct cdrom_multisession) */
112131e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
112231e31b8aSbellard                                            if available (struct cdrom_mcn) */
112367cc32ebSVeres Lajos #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
1124b4916d7bSDong Xu Wang                                           but here anyway for compatibility */
112531e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
112631e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
112731e31b8aSbellard                                           (struct cdrom_volctrl) */
112831e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
112931e31b8aSbellard                                            (struct cdrom_read) */
113031e31b8aSbellard /*
113131e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
113231e31b8aSbellard  */
113331e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
113431e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
113531e31b8aSbellard 
113631e31b8aSbellard /*
113731e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
113831e31b8aSbellard    It is for playing audio in logical block addressing mode.
113931e31b8aSbellard  */
114031e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
114131e31b8aSbellard 
114231e31b8aSbellard /*
114331e31b8aSbellard  * These ioctls are only used in optcd.c
114431e31b8aSbellard  */
114531e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
114631e31b8aSbellard 
114731e31b8aSbellard /*
114831e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
114931e31b8aSbellard  * drive spindown time.  They should be implemented in the
115031e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
115131e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
115231e31b8aSbellard  *  -Erik
115331e31b8aSbellard  */
115431e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
115531e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
115631e31b8aSbellard 
115731e31b8aSbellard /*
115831e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
115931e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
116031e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
116131e31b8aSbellard  */
116231e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
116331e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
116431e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
116531e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
116631e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
116731e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
116831e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
116931e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
117031e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
117131e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
117231e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
117331e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
117431e31b8aSbellard 
117531e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
117631e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
117731e31b8aSbellard  */
117831e31b8aSbellard 
117931e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
118031e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
118131e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
118231e31b8aSbellard 
118331e31b8aSbellard /* DVD-ROM Specific ioctls */
118431e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
118531e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
118631e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
118731e31b8aSbellard 
118831e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
118931e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
119031e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
119131e31b8aSbellard 
119231e31b8aSbellard /* HD commands */
119331e31b8aSbellard 
119431e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
119531e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
119631e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
119731e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
119831e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
119931e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
120031e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
120131e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
12022521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
120331e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
120431e31b8aSbellard 
120531e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
120631e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
120731e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
120831e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
120931e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
121031e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
121131e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
121231e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
12132521d698Sbellard 
1214b8005914Sbalrog /* loop ioctls */
1215b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
1216b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
1217b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
1218b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
1219b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
1220b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
1221b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
12220a761ce3SAndreas Schwab #define TARGET_LOOP_SET_CAPACITY      0x4C07
12230a761ce3SAndreas Schwab #define TARGET_LOOP_SET_DIRECT_IO     0x4C08
12240a761ce3SAndreas Schwab #define TARGET_LOOP_SET_BLOCK_SIZE    0x4C09
12250a761ce3SAndreas Schwab #define TARGET_LOOP_CONFIGURE         0x4C0A
12262521d698Sbellard 
1227884cdc48SPeter Maydell #define TARGET_LOOP_CTL_ADD           0x4C80
1228884cdc48SPeter Maydell #define TARGET_LOOP_CTL_REMOVE        0x4C81
1229884cdc48SPeter Maydell #define TARGET_LOOP_CTL_GET_FREE      0x4C82
1230884cdc48SPeter Maydell 
1231f7680a55SUlrich Hecht /* fb ioctls */
1232f7680a55SUlrich Hecht #define TARGET_FBIOGET_VSCREENINFO    0x4600
1233f7680a55SUlrich Hecht #define TARGET_FBIOPUT_VSCREENINFO    0x4601
1234f7680a55SUlrich Hecht #define TARGET_FBIOGET_FSCREENINFO    0x4602
123512b81b71SCédric VINCENT #define TARGET_FBIOGETCMAP            0x4604
123612b81b71SCédric VINCENT #define TARGET_FBIOPUTCMAP            0x4605
123712b81b71SCédric VINCENT #define TARGET_FBIOPAN_DISPLAY        0x4606
123812b81b71SCédric VINCENT #define TARGET_FBIOGET_CON2FBMAP      0x460F
123912b81b71SCédric VINCENT #define TARGET_FBIOPUT_CON2FBMAP      0x4610
1240f7680a55SUlrich Hecht 
1241f7680a55SUlrich Hecht /* vt ioctls */
1242f7680a55SUlrich Hecht #define TARGET_VT_OPENQRY             0x5600
1243f7680a55SUlrich Hecht #define TARGET_VT_GETSTATE            0x5603
1244f7680a55SUlrich Hecht #define TARGET_VT_ACTIVATE            0x5606
1245f7680a55SUlrich Hecht #define TARGET_VT_WAITACTIVE          0x5607
1246f7680a55SUlrich Hecht #define TARGET_VT_LOCKSWITCH          0x560b
1247f7680a55SUlrich Hecht #define TARGET_VT_UNLOCKSWITCH        0x560c
1248774750c0SCédric VINCENT #define TARGET_VT_GETMODE             0x5601
1249774750c0SCédric VINCENT #define TARGET_VT_SETMODE             0x5602
1250774750c0SCédric VINCENT #define TARGET_VT_RELDISP             0x5605
1251774750c0SCédric VINCENT #define TARGET_VT_DISALLOCATE         0x5608
1252f7680a55SUlrich Hecht 
125356e904ecSAlexander Graf /* device mapper */
125456e904ecSAlexander Graf #define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
125556e904ecSAlexander Graf #define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
125656e904ecSAlexander Graf #define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
125756e904ecSAlexander Graf #define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
125856e904ecSAlexander Graf #define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
125956e904ecSAlexander Graf #define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
126056e904ecSAlexander Graf #define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
126156e904ecSAlexander Graf #define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
126256e904ecSAlexander Graf #define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
126356e904ecSAlexander Graf #define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
126456e904ecSAlexander Graf #define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
126556e904ecSAlexander Graf #define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
126656e904ecSAlexander Graf #define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
126756e904ecSAlexander Graf #define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
126856e904ecSAlexander Graf #define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
126956e904ecSAlexander Graf #define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)
127056e904ecSAlexander Graf 
1271e865b97fSChen Gang /* drm ioctls */
1272e865b97fSChen Gang #define TARGET_DRM_IOCTL_VERSION      TARGET_IOWRU('d', 0x00)
1273e865b97fSChen Gang 
1274913b03c2SChen Gang /* drm i915 ioctls */
1275913b03c2SChen Gang #define TARGET_DRM_IOCTL_I915_GETPARAM              TARGET_IOWRU('d', 0x46)
1276913b03c2SChen Gang 
12772521d698Sbellard /* from asm/termbits.h */
12782521d698Sbellard 
12793bfd9da1Sbellard #define TARGET_NCC 8
12803bfd9da1Sbellard struct target_termio {
12813bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
12823bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
12833bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
12843bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
12852521d698Sbellard 	unsigned char c_line;		/* line discipline */
12863bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
12872521d698Sbellard };
12882521d698Sbellard 
12893bfd9da1Sbellard struct target_winsize {
12903bfd9da1Sbellard 	unsigned short ws_row;
12913bfd9da1Sbellard 	unsigned short ws_col;
12923bfd9da1Sbellard 	unsigned short ws_xpixel;
12933bfd9da1Sbellard 	unsigned short ws_ypixel;
12943bfd9da1Sbellard };
12952521d698Sbellard 
12963bfd9da1Sbellard #include "termbits.h"
12972521d698Sbellard 
12989e0b74a4SPaul Brook #if defined(TARGET_MIPS)
12999e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x10
13009e0b74a4SPaul Brook #else
13019e0b74a4SPaul Brook #define TARGET_PROT_SEM         0x08
13029e0b74a4SPaul Brook #endif
13039e0b74a4SPaul Brook 
1304be5d6f48SRichard Henderson #ifdef TARGET_AARCH64
1305be5d6f48SRichard Henderson #define TARGET_PROT_BTI         0x10
1306d109b46dSRichard Henderson #define TARGET_PROT_MTE         0x20
1307be5d6f48SRichard Henderson #endif
1308be5d6f48SRichard Henderson 
1309e44a3e79Saurel32 /* Common */
13102521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
13112521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1312e65be6a7SHelge Deller #if defined(TARGET_HPPA)
1313e65be6a7SHelge Deller #define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
1314e65be6a7SHelge Deller #else
13152521d698Sbellard #define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
1316e65be6a7SHelge Deller #endif
1317e44a3e79Saurel32 
1318e44a3e79Saurel32 /* Target specific */
1319048f6b4dSbellard #if defined(TARGET_MIPS)
1320e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1321048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1322048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1323048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1324048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1325048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1326048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1327540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1328540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1329541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1330541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1331e44a3e79Saurel32 #elif defined(TARGET_PPC)
1332e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
13332521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
13342521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
13352521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
13362521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
13377ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
13387ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1339e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1340e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1341541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1342541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1343e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
1344e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1345e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
1346e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
1347e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
1348e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
1349e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
1350e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
1351e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
1352e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1353541e1690SHelge Deller #define TARGET_MAP_STACK        0x80000         /* ignored */
1354541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1355a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
1356a10d1e50SRichard Henderson #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
1357a10d1e50SRichard Henderson #define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
1358a10d1e50SRichard Henderson #define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
1359a10d1e50SRichard Henderson #define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
1360a10d1e50SRichard Henderson #define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
1361a10d1e50SRichard Henderson #define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
1362a10d1e50SRichard Henderson #define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
1363a10d1e50SRichard Henderson #define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
1364a10d1e50SRichard Henderson #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1365541e1690SHelge Deller #define TARGET_MAP_STACK        0x40000         /* ignored */
1366541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1367ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
1368ba7651fbSMax Filippov #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1369ba7651fbSMax Filippov #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
1370ba7651fbSMax Filippov #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
1371ba7651fbSMax Filippov #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
1372ba7651fbSMax Filippov #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
1373ba7651fbSMax Filippov #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
1374ba7651fbSMax Filippov #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1375ba7651fbSMax Filippov #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
1376ba7651fbSMax Filippov #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1377ba7651fbSMax Filippov #define TARGET_MAP_STACK	0x40000
1378ba7651fbSMax Filippov #define TARGET_MAP_HUGETLB  0x80000         /* create a huge page mapping */
13797ec93196Sj_mayer #else
1380e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1381e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
1382e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
1383e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
1384e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
13852521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
13862521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1387540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
1388540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1389541e1690SHelge Deller #define TARGET_MAP_STACK        0x20000         /* ignored */
1390541e1690SHelge Deller #define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1391906c1b8eSMike Frysinger #define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
13927ec93196Sj_mayer #endif
13932521d698Sbellard 
139409701199SAlexander Graf #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
139509701199SAlexander Graf     || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1396daa4374aSPeter Maydell     || defined(TARGET_CRIS)
13975f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
13982521d698Sbellard struct target_stat {
13992521d698Sbellard 	unsigned short st_dev;
14002521d698Sbellard 	unsigned short __pad1;
1401992f48a0Sblueswir1 	abi_ulong st_ino;
14022521d698Sbellard 	unsigned short st_mode;
14032521d698Sbellard 	unsigned short st_nlink;
14042521d698Sbellard 	unsigned short st_uid;
14052521d698Sbellard 	unsigned short st_gid;
14062521d698Sbellard 	unsigned short st_rdev;
14072521d698Sbellard 	unsigned short __pad2;
1408992f48a0Sblueswir1 	abi_ulong  st_size;
1409992f48a0Sblueswir1 	abi_ulong  st_blksize;
1410992f48a0Sblueswir1 	abi_ulong  st_blocks;
1411992f48a0Sblueswir1 	abi_ulong  target_st_atime;
14125f992db6SChen-Yu Tsai 	abi_ulong  target_st_atime_nsec;
1413992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
14145f992db6SChen-Yu Tsai 	abi_ulong  target_st_mtime_nsec;
1415992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
14165f992db6SChen-Yu Tsai 	abi_ulong  target_st_ctime_nsec;
1417992f48a0Sblueswir1 	abi_ulong  __unused4;
1418992f48a0Sblueswir1 	abi_ulong  __unused5;
14192521d698Sbellard };
14202521d698Sbellard 
14212521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
14222521d698Sbellard  * insane amounts of padding around dev_t's.
14232521d698Sbellard  */
142420d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
14252521d698Sbellard struct target_stat64 {
14262521d698Sbellard 	unsigned short	st_dev;
14272521d698Sbellard 	unsigned char	__pad0[10];
14282521d698Sbellard 
14292521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1430992f48a0Sblueswir1 	abi_ulong	__st_ino;
14312521d698Sbellard 
14322521d698Sbellard 	unsigned int	st_mode;
14332521d698Sbellard 	unsigned int	st_nlink;
14342521d698Sbellard 
1435992f48a0Sblueswir1 	abi_ulong	st_uid;
1436992f48a0Sblueswir1 	abi_ulong	st_gid;
14372521d698Sbellard 
14382521d698Sbellard 	unsigned short	st_rdev;
14392521d698Sbellard 	unsigned char	__pad3[10];
14402521d698Sbellard 
14412521d698Sbellard 	long long	st_size;
1442992f48a0Sblueswir1 	abi_ulong	st_blksize;
14432521d698Sbellard 
1444992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1445992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
14462521d698Sbellard 
1447992f48a0Sblueswir1 	abi_ulong	target_st_atime;
14485f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
14492521d698Sbellard 
1450992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
14515f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
14522521d698Sbellard 
1453992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
14545f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
14552521d698Sbellard 
14562521d698Sbellard 	unsigned long long	st_ino;
1457541dc0d4SStefan Weil } QEMU_PACKED;
14582521d698Sbellard 
1459ce4defa0Spbrook #ifdef TARGET_ARM
146020d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1461ce4defa0Spbrook struct target_eabi_stat64 {
1462ce4defa0Spbrook         unsigned long long st_dev;
1463ce4defa0Spbrook         unsigned int    __pad1;
1464992f48a0Sblueswir1         abi_ulong    __st_ino;
1465ce4defa0Spbrook         unsigned int    st_mode;
1466ce4defa0Spbrook         unsigned int    st_nlink;
1467ce4defa0Spbrook 
1468992f48a0Sblueswir1         abi_ulong    st_uid;
1469992f48a0Sblueswir1         abi_ulong    st_gid;
1470ce4defa0Spbrook 
1471ce4defa0Spbrook         unsigned long long st_rdev;
1472ce4defa0Spbrook         unsigned int    __pad2[2];
1473ce4defa0Spbrook 
1474ce4defa0Spbrook         long long       st_size;
1475992f48a0Sblueswir1         abi_ulong    st_blksize;
1476ce4defa0Spbrook         unsigned int    __pad3;
1477ce4defa0Spbrook         unsigned long long st_blocks;
1478ce4defa0Spbrook 
1479992f48a0Sblueswir1         abi_ulong    target_st_atime;
1480992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
1481ce4defa0Spbrook 
1482992f48a0Sblueswir1         abi_ulong    target_st_mtime;
1483992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
1484ce4defa0Spbrook 
1485992f48a0Sblueswir1         abi_ulong    target_st_ctime;
1486992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
1487ce4defa0Spbrook 
1488ce4defa0Spbrook         unsigned long long st_ino;
1489541dc0d4SStefan Weil } QEMU_PACKED;
1490ce4defa0Spbrook #endif
1491ce4defa0Spbrook 
1492992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
14931b8dd648Sblueswir1 struct target_stat {
14941b8dd648Sblueswir1 	unsigned int	st_dev;
1495992f48a0Sblueswir1 	abi_ulong	st_ino;
14961b8dd648Sblueswir1 	unsigned int	st_mode;
14971b8dd648Sblueswir1 	unsigned int	st_nlink;
14981b8dd648Sblueswir1 	unsigned int	st_uid;
14991b8dd648Sblueswir1 	unsigned int	st_gid;
15001b8dd648Sblueswir1 	unsigned int	st_rdev;
1501992f48a0Sblueswir1 	abi_long	st_size;
1502992f48a0Sblueswir1 	abi_long	target_st_atime;
1503992f48a0Sblueswir1 	abi_long	target_st_mtime;
1504992f48a0Sblueswir1 	abi_long	target_st_ctime;
1505992f48a0Sblueswir1 	abi_long	st_blksize;
1506992f48a0Sblueswir1 	abi_long	st_blocks;
1507992f48a0Sblueswir1 	abi_ulong	__unused4[2];
15081b8dd648Sblueswir1 };
15091b8dd648Sblueswir1 
151020d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
15111b8dd648Sblueswir1 struct target_stat64 {
15121b8dd648Sblueswir1 	unsigned char	__pad0[6];
15131b8dd648Sblueswir1 	unsigned short	st_dev;
15141b8dd648Sblueswir1 
15151b8dd648Sblueswir1 	uint64_t	st_ino;
15161b8dd648Sblueswir1 	uint64_t	st_nlink;
15171b8dd648Sblueswir1 
15181b8dd648Sblueswir1 	unsigned int	st_mode;
15191b8dd648Sblueswir1 
15201b8dd648Sblueswir1 	unsigned int	st_uid;
15211b8dd648Sblueswir1 	unsigned int	st_gid;
15221b8dd648Sblueswir1 
15231b8dd648Sblueswir1 	unsigned char	__pad2[6];
15241b8dd648Sblueswir1 	unsigned short	st_rdev;
15251b8dd648Sblueswir1 
15261b8dd648Sblueswir1         int64_t		st_size;
15271b8dd648Sblueswir1 	int64_t		st_blksize;
15281b8dd648Sblueswir1 
15291b8dd648Sblueswir1 	unsigned char	__pad4[4];
15301b8dd648Sblueswir1 	unsigned int	st_blocks;
15311b8dd648Sblueswir1 
1532992f48a0Sblueswir1 	abi_ulong	target_st_atime;
15335f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
15341b8dd648Sblueswir1 
1535992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
15365f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
15371b8dd648Sblueswir1 
1538992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
15395f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
15401b8dd648Sblueswir1 
1541992f48a0Sblueswir1 	abi_ulong	__unused4[3];
15421b8dd648Sblueswir1 };
15431b8dd648Sblueswir1 
15443bfd9da1Sbellard #elif defined(TARGET_SPARC)
15453bfd9da1Sbellard 
15465f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
15473bfd9da1Sbellard struct target_stat {
15483bfd9da1Sbellard 	unsigned short	st_dev;
1549992f48a0Sblueswir1 	abi_ulong	st_ino;
15503bfd9da1Sbellard 	unsigned short	st_mode;
15513bfd9da1Sbellard 	short		st_nlink;
15523bfd9da1Sbellard 	unsigned short	st_uid;
15533bfd9da1Sbellard 	unsigned short	st_gid;
15543bfd9da1Sbellard 	unsigned short	st_rdev;
1555992f48a0Sblueswir1 	abi_long	st_size;
1556992f48a0Sblueswir1 	abi_long	target_st_atime;
15575f992db6SChen-Yu Tsai 	abi_ulong	target_st_atime_nsec;
1558992f48a0Sblueswir1 	abi_long	target_st_mtime;
15595f992db6SChen-Yu Tsai 	abi_ulong	target_st_mtime_nsec;
1560992f48a0Sblueswir1 	abi_long	target_st_ctime;
15615f992db6SChen-Yu Tsai 	abi_ulong	target_st_ctime_nsec;
1562992f48a0Sblueswir1 	abi_long	st_blksize;
1563992f48a0Sblueswir1 	abi_long	st_blocks;
15645f992db6SChen-Yu Tsai 	abi_ulong	__unused1[2];
15653bfd9da1Sbellard };
15663bfd9da1Sbellard 
156720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
15683bfd9da1Sbellard struct target_stat64 {
15693bfd9da1Sbellard 	unsigned char	__pad0[6];
15703bfd9da1Sbellard 	unsigned short	st_dev;
15713bfd9da1Sbellard 
15723bfd9da1Sbellard 	uint64_t st_ino;
15733bfd9da1Sbellard 
15743bfd9da1Sbellard 	unsigned int	st_mode;
15753bfd9da1Sbellard 	unsigned int	st_nlink;
15763bfd9da1Sbellard 
15773bfd9da1Sbellard 	unsigned int	st_uid;
15783bfd9da1Sbellard 	unsigned int	st_gid;
15793bfd9da1Sbellard 
15803bfd9da1Sbellard 	unsigned char	__pad2[6];
15813bfd9da1Sbellard 	unsigned short	st_rdev;
15823bfd9da1Sbellard 
15833bfd9da1Sbellard 	unsigned char	__pad3[8];
15843bfd9da1Sbellard 
15853bfd9da1Sbellard         int64_t	st_size;
15863bfd9da1Sbellard 	unsigned int	st_blksize;
15873bfd9da1Sbellard 
15883bfd9da1Sbellard 	unsigned char	__pad4[8];
15893bfd9da1Sbellard 	unsigned int	st_blocks;
15903bfd9da1Sbellard 
15913bfd9da1Sbellard 	unsigned int	target_st_atime;
15925f992db6SChen-Yu Tsai 	unsigned int	target_st_atime_nsec;
15933bfd9da1Sbellard 
15943bfd9da1Sbellard 	unsigned int	target_st_mtime;
15955f992db6SChen-Yu Tsai 	unsigned int	target_st_mtime_nsec;
15963bfd9da1Sbellard 
15973bfd9da1Sbellard 	unsigned int	target_st_ctime;
15985f992db6SChen-Yu Tsai 	unsigned int	target_st_ctime_nsec;
15993bfd9da1Sbellard 
16005f992db6SChen-Yu Tsai 	unsigned int	__unused1;
16015f992db6SChen-Yu Tsai 	unsigned int	__unused2;
16023bfd9da1Sbellard };
16033bfd9da1Sbellard 
160467867308Sbellard #elif defined(TARGET_PPC)
160567867308Sbellard 
16065f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
160767867308Sbellard struct target_stat {
1608e32448e0Sj_mayer 	abi_ulong st_dev;
1609992f48a0Sblueswir1 	abi_ulong st_ino;
1610325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1611e32448e0Sj_mayer 	abi_ulong st_nlink;
1612325e651fSj_mayer 	unsigned int st_mode;
1613325e651fSj_mayer #else
161467867308Sbellard 	unsigned int st_mode;
161567867308Sbellard 	unsigned short st_nlink;
1616325e651fSj_mayer #endif
161767867308Sbellard 	unsigned int st_uid;
161867867308Sbellard 	unsigned int st_gid;
1619e32448e0Sj_mayer 	abi_ulong  st_rdev;
1620992f48a0Sblueswir1 	abi_ulong  st_size;
1621992f48a0Sblueswir1 	abi_ulong  st_blksize;
1622992f48a0Sblueswir1 	abi_ulong  st_blocks;
1623992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1624e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1625992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1626e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1627992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1628e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1629992f48a0Sblueswir1 	abi_ulong  __unused4;
1630992f48a0Sblueswir1 	abi_ulong  __unused5;
1631325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1632325e651fSj_mayer 	abi_ulong  __unused6;
1633325e651fSj_mayer #endif
163467867308Sbellard };
163567867308Sbellard 
163620d155bcSStefan Weil #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
163720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1638541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
163967867308Sbellard 	unsigned long long st_dev;
164067867308Sbellard         unsigned long long st_ino;
164167867308Sbellard 	unsigned int st_mode;
164267867308Sbellard 	unsigned int st_nlink;
164367867308Sbellard 	unsigned int st_uid;
164467867308Sbellard 	unsigned int st_gid;
164567867308Sbellard 	unsigned long long st_rdev;
1646e1ce5e40Saurel32 	unsigned long long __pad0;
164767867308Sbellard 	long long      st_size;
1648e32448e0Sj_mayer 	int	       st_blksize;
1649e1ce5e40Saurel32 	unsigned int   __pad1;
165061322e91SMax Filippov 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1651e32448e0Sj_mayer 	int	       target_st_atime;
1652e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1653e32448e0Sj_mayer 	int	       target_st_mtime;
1654e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1655e32448e0Sj_mayer 	int            target_st_ctime;
1656e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1657e32448e0Sj_mayer         unsigned int   __unused4;
1658e32448e0Sj_mayer         unsigned int   __unused5;
165967867308Sbellard };
166020d155bcSStefan Weil #endif
166167867308Sbellard 
1662b779e29eSEdgar E. Iglesias #elif defined(TARGET_MICROBLAZE)
1663b779e29eSEdgar E. Iglesias 
16645f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1665b779e29eSEdgar E. Iglesias struct target_stat {
1666b779e29eSEdgar E. Iglesias 	abi_ulong st_dev;
1667b779e29eSEdgar E. Iglesias 	abi_ulong st_ino;
1668b779e29eSEdgar E. Iglesias 	unsigned int st_mode;
1669b779e29eSEdgar E. Iglesias 	unsigned short st_nlink;
1670b779e29eSEdgar E. Iglesias 	unsigned int st_uid;
1671b779e29eSEdgar E. Iglesias 	unsigned int st_gid;
1672b779e29eSEdgar E. Iglesias 	abi_ulong  st_rdev;
1673b779e29eSEdgar E. Iglesias 	abi_ulong  st_size;
1674b779e29eSEdgar E. Iglesias 	abi_ulong  st_blksize;
1675b779e29eSEdgar E. Iglesias 	abi_ulong  st_blocks;
1676b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime;
1677b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_atime_nsec;
1678b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime;
1679b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_mtime_nsec;
1680b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime;
1681b779e29eSEdgar E. Iglesias 	abi_ulong  target_st_ctime_nsec;
1682b779e29eSEdgar E. Iglesias 	abi_ulong  __unused4;
1683b779e29eSEdgar E. Iglesias 	abi_ulong  __unused5;
1684b779e29eSEdgar E. Iglesias };
1685b779e29eSEdgar E. Iglesias 
1686b779e29eSEdgar E. Iglesias /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
168720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1688541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
1689b779e29eSEdgar E. Iglesias 	uint64_t st_dev;
1690a523eb06SEdgar E. Iglesias #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1691a523eb06SEdgar E. Iglesias 	uint32_t pad0;
1692a523eb06SEdgar E. Iglesias 	uint32_t __st_ino;
1693a523eb06SEdgar E. Iglesias 
1694b779e29eSEdgar E. Iglesias 	uint32_t st_mode;
1695b779e29eSEdgar E. Iglesias 	uint32_t st_nlink;
1696b779e29eSEdgar E. Iglesias 	uint32_t st_uid;
1697b779e29eSEdgar E. Iglesias 	uint32_t st_gid;
1698b779e29eSEdgar E. Iglesias 	uint64_t st_rdev;
169921ebeb23SEdgar E. Iglesias 	uint64_t __pad1;
1700b779e29eSEdgar E. Iglesias 
1701b779e29eSEdgar E. Iglesias 	int64_t  st_size;
1702b779e29eSEdgar E. Iglesias 	int32_t  st_blksize;
170321ebeb23SEdgar E. Iglesias 	uint32_t __pad2;
1704b779e29eSEdgar E. Iglesias 	int64_t st_blocks;	/* Number 512-byte blocks allocated. */
1705b779e29eSEdgar E. Iglesias 
1706b779e29eSEdgar E. Iglesias 	int	       target_st_atime;
1707b779e29eSEdgar E. Iglesias 	unsigned int   target_st_atime_nsec;
1708b779e29eSEdgar E. Iglesias 	int	       target_st_mtime;
1709b779e29eSEdgar E. Iglesias 	unsigned int   target_st_mtime_nsec;
1710b779e29eSEdgar E. Iglesias 	int            target_st_ctime;
1711b779e29eSEdgar E. Iglesias 	unsigned int   target_st_ctime_nsec;
1712a523eb06SEdgar E. Iglesias 	uint64_t st_ino;
1713b779e29eSEdgar E. Iglesias };
1714b779e29eSEdgar E. Iglesias 
1715e6e5906bSpbrook #elif defined(TARGET_M68K)
1716e6e5906bSpbrook 
1717e6e5906bSpbrook struct target_stat {
1718e6e5906bSpbrook 	unsigned short st_dev;
1719e6e5906bSpbrook 	unsigned short __pad1;
1720992f48a0Sblueswir1 	abi_ulong st_ino;
1721e6e5906bSpbrook 	unsigned short st_mode;
1722e6e5906bSpbrook 	unsigned short st_nlink;
1723e6e5906bSpbrook 	unsigned short st_uid;
1724e6e5906bSpbrook 	unsigned short st_gid;
1725e6e5906bSpbrook 	unsigned short st_rdev;
1726e6e5906bSpbrook 	unsigned short __pad2;
1727992f48a0Sblueswir1 	abi_ulong  st_size;
1728992f48a0Sblueswir1 	abi_ulong  st_blksize;
1729992f48a0Sblueswir1 	abi_ulong  st_blocks;
1730992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1731992f48a0Sblueswir1 	abi_ulong  __unused1;
1732992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1733992f48a0Sblueswir1 	abi_ulong  __unused2;
1734992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1735992f48a0Sblueswir1 	abi_ulong  __unused3;
1736992f48a0Sblueswir1 	abi_ulong  __unused4;
1737992f48a0Sblueswir1 	abi_ulong  __unused5;
1738e6e5906bSpbrook };
1739e6e5906bSpbrook 
1740e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1741e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1742e6e5906bSpbrook  */
174320d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1744e6e5906bSpbrook struct target_stat64 {
1745e6e5906bSpbrook 	unsigned long long	st_dev;
1746e6e5906bSpbrook 	unsigned char	__pad1[2];
1747e6e5906bSpbrook 
1748e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1749992f48a0Sblueswir1 	abi_ulong	__st_ino;
1750e6e5906bSpbrook 
1751e6e5906bSpbrook 	unsigned int	st_mode;
1752e6e5906bSpbrook 	unsigned int	st_nlink;
1753e6e5906bSpbrook 
1754992f48a0Sblueswir1 	abi_ulong	st_uid;
1755992f48a0Sblueswir1 	abi_ulong	st_gid;
1756e6e5906bSpbrook 
1757e6e5906bSpbrook 	unsigned long long	st_rdev;
1758e6e5906bSpbrook 	unsigned char	__pad3[2];
1759e6e5906bSpbrook 
1760e6e5906bSpbrook 	long long	st_size;
1761992f48a0Sblueswir1 	abi_ulong	st_blksize;
1762e6e5906bSpbrook 
1763992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1764992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1765e6e5906bSpbrook 
1766992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1767992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1768e6e5906bSpbrook 
1769992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1770992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1771e6e5906bSpbrook 
1772992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1773992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1774e6e5906bSpbrook 
1775e6e5906bSpbrook 	unsigned long long	st_ino;
1776541dc0d4SStefan Weil } QEMU_PACKED;
1777e6e5906bSpbrook 
1778d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1779540635baSths 
17805f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1781540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1782540635baSths struct target_stat {
1783540635baSths 	unsigned int		st_dev;
1784540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1785540635baSths 
1786992f48a0Sblueswir1 	abi_ulong		st_ino;
1787540635baSths 
1788540635baSths 	unsigned int		st_mode;
1789540635baSths 	unsigned int		st_nlink;
1790540635baSths 
1791540635baSths 	int			st_uid;
1792540635baSths 	int			st_gid;
1793540635baSths 
1794540635baSths 	unsigned int		st_rdev;
1795540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1796540635baSths 
1797992f48a0Sblueswir1 	abi_ulong		st_size;
1798540635baSths 
1799540635baSths 	/*
1800540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1801540635baSths 	 * but we don't have it under Linux.
1802540635baSths 	 */
1803540635baSths 	unsigned int		target_st_atime;
1804540635baSths 	unsigned int		target_st_atime_nsec;
1805540635baSths 
1806540635baSths 	unsigned int		target_st_mtime;
1807540635baSths 	unsigned int		target_st_mtime_nsec;
1808540635baSths 
1809540635baSths 	unsigned int		target_st_ctime;
1810540635baSths 	unsigned int		target_st_ctime_nsec;
1811540635baSths 
1812540635baSths 	unsigned int		st_blksize;
1813540635baSths 	unsigned int		st_pad2;
1814540635baSths 
1815992f48a0Sblueswir1 	abi_ulong		st_blocks;
1816540635baSths };
1817540635baSths 
1818d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1819540635baSths 
18205f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1821540635baSths struct target_stat {
18221ab2aea2SLeon Alrae         abi_ulong    st_dev;
18231ab2aea2SLeon Alrae         abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
18241ab2aea2SLeon Alrae         uint64_t     st_ino;
1825540635baSths         unsigned int st_mode;
1826540635baSths         unsigned int st_nlink;
1827540635baSths         int          st_uid;
1828540635baSths         int          st_gid;
18291ab2aea2SLeon Alrae         abi_ulong    st_rdev;
18301ab2aea2SLeon Alrae         abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
18311ab2aea2SLeon Alrae         int64_t      st_size;
18321ab2aea2SLeon Alrae         abi_long     target_st_atime;
18331ab2aea2SLeon Alrae         abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
18341ab2aea2SLeon Alrae         abi_long     target_st_mtime;
18351ab2aea2SLeon Alrae         abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
18361ab2aea2SLeon Alrae         abi_long     target_st_ctime;
18371ab2aea2SLeon Alrae         abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
18381ab2aea2SLeon Alrae         abi_ulong    st_blksize;
18391ab2aea2SLeon Alrae         abi_ulong    st_pad2;
18401ab2aea2SLeon Alrae         int64_t      st_blocks;
1841540635baSths };
1842540635baSths 
1843d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1844048f6b4dSbellard 
18455f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
1846048f6b4dSbellard struct target_stat {
1847048f6b4dSbellard 	unsigned	st_dev;
1848992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1849992f48a0Sblueswir1 	abi_ulong	st_ino;
1850048f6b4dSbellard 	unsigned int	st_mode;
1851048f6b4dSbellard 	unsigned int	st_nlink;
1852048f6b4dSbellard 	int		st_uid;
1853048f6b4dSbellard 	int		st_gid;
1854048f6b4dSbellard 	unsigned 	st_rdev;
1855992f48a0Sblueswir1 	abi_long	st_pad2[2];
1856992f48a0Sblueswir1 	abi_long	st_size;
1857992f48a0Sblueswir1 	abi_long	st_pad3;
1858048f6b4dSbellard 	/*
1859048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1860048f6b4dSbellard 	 * but we don't have it under Linux.
1861048f6b4dSbellard 	 */
1862992f48a0Sblueswir1 	abi_long		target_st_atime;
1863992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1864992f48a0Sblueswir1 	abi_long		target_st_mtime;
1865992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1866992f48a0Sblueswir1 	abi_long		target_st_ctime;
1867992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1868992f48a0Sblueswir1 	abi_long		st_blksize;
1869992f48a0Sblueswir1 	abi_long		st_blocks;
1870992f48a0Sblueswir1 	abi_long		st_pad4[14];
1871048f6b4dSbellard };
1872048f6b4dSbellard 
1873048f6b4dSbellard /*
1874048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1875048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1876048f6b4dSbellard  * struct stat of the 64-bit kernel.
1877048f6b4dSbellard  */
1878048f6b4dSbellard 
187920d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1880048f6b4dSbellard struct target_stat64 {
1881992f48a0Sblueswir1 	abi_ulong	st_dev;
1882992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1883048f6b4dSbellard 
1884048f6b4dSbellard 	uint64_t	st_ino;
1885048f6b4dSbellard 
1886048f6b4dSbellard         unsigned int	st_mode;
1887048f6b4dSbellard         unsigned int	st_nlink;
1888048f6b4dSbellard 
1889048f6b4dSbellard 	int		st_uid;
1890048f6b4dSbellard 	int		st_gid;
1891048f6b4dSbellard 
1892992f48a0Sblueswir1 	abi_ulong	st_rdev;
1893992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1894048f6b4dSbellard 
1895048f6b4dSbellard 	int64_t 	st_size;
1896048f6b4dSbellard 
1897048f6b4dSbellard 	/*
1898048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1899048f6b4dSbellard 	 * but we don't have it under Linux.
1900048f6b4dSbellard 	 */
1901992f48a0Sblueswir1 	abi_long	target_st_atime;
1902992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1903048f6b4dSbellard 
1904992f48a0Sblueswir1 	abi_long	target_st_mtime;
1905992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1906048f6b4dSbellard 
1907992f48a0Sblueswir1 	abi_long	target_st_ctime;
1908992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1909048f6b4dSbellard 
1910992f48a0Sblueswir1 	abi_ulong	st_blksize;
1911992f48a0Sblueswir1 	abi_ulong	st_pad2;
1912048f6b4dSbellard 
1913048f6b4dSbellard 	int64_t  	st_blocks;
1914048f6b4dSbellard };
19157a3148a9Sj_mayer 
19167a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
19177a3148a9Sj_mayer 
19187a3148a9Sj_mayer struct target_stat {
19197a3148a9Sj_mayer        unsigned int    st_dev;
19207a3148a9Sj_mayer        unsigned int    st_ino;
19217a3148a9Sj_mayer        unsigned int    st_mode;
19227a3148a9Sj_mayer        unsigned int    st_nlink;
19237a3148a9Sj_mayer        unsigned int    st_uid;
19247a3148a9Sj_mayer        unsigned int    st_gid;
19257a3148a9Sj_mayer        unsigned int    st_rdev;
1926992f48a0Sblueswir1        abi_long     st_size;
1927992f48a0Sblueswir1        abi_ulong    target_st_atime;
1928992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1929992f48a0Sblueswir1        abi_ulong    target_st_ctime;
19307a3148a9Sj_mayer        unsigned int    st_blksize;
19317a3148a9Sj_mayer        unsigned int    st_blocks;
19327a3148a9Sj_mayer        unsigned int    st_flags;
19337a3148a9Sj_mayer        unsigned int    st_gen;
19347a3148a9Sj_mayer };
19357a3148a9Sj_mayer 
193620d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
19377a3148a9Sj_mayer struct target_stat64 {
1938992f48a0Sblueswir1        abi_ulong    st_dev;
1939992f48a0Sblueswir1        abi_ulong    st_ino;
1940992f48a0Sblueswir1        abi_ulong    st_rdev;
1941992f48a0Sblueswir1        abi_long     st_size;
1942992f48a0Sblueswir1        abi_ulong    st_blocks;
19437a3148a9Sj_mayer 
19447a3148a9Sj_mayer        unsigned int    st_mode;
19457a3148a9Sj_mayer        unsigned int    st_uid;
19467a3148a9Sj_mayer        unsigned int    st_gid;
19477a3148a9Sj_mayer        unsigned int    st_blksize;
19487a3148a9Sj_mayer        unsigned int    st_nlink;
19497a3148a9Sj_mayer        unsigned int    __pad0;
19507a3148a9Sj_mayer 
1951992f48a0Sblueswir1        abi_ulong    target_st_atime;
1952992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1953992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1954992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1955992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1956992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1957992f48a0Sblueswir1        abi_long     __unused[3];
19587a3148a9Sj_mayer };
19597a3148a9Sj_mayer 
19606db45e65Sths #elif defined(TARGET_SH4)
19616db45e65Sths 
19625f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
19636db45e65Sths struct target_stat {
1964992f48a0Sblueswir1 	abi_ulong  st_dev;
1965992f48a0Sblueswir1 	abi_ulong  st_ino;
19666db45e65Sths 	unsigned short st_mode;
19676db45e65Sths 	unsigned short st_nlink;
19686db45e65Sths 	unsigned short st_uid;
19696db45e65Sths 	unsigned short st_gid;
1970992f48a0Sblueswir1 	abi_ulong  st_rdev;
1971992f48a0Sblueswir1 	abi_ulong  st_size;
1972992f48a0Sblueswir1 	abi_ulong  st_blksize;
1973992f48a0Sblueswir1 	abi_ulong  st_blocks;
1974992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1975992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1976992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1977992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1978992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1979992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1980992f48a0Sblueswir1 	abi_ulong  __unused4;
1981992f48a0Sblueswir1 	abi_ulong  __unused5;
19826db45e65Sths };
19836db45e65Sths 
19846db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
19856db45e65Sths  * insane amounts of padding around dev_t's.
19866db45e65Sths  */
198720d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
1988541dc0d4SStefan Weil struct QEMU_PACKED target_stat64 {
19896db45e65Sths 	unsigned long long	st_dev;
19906db45e65Sths 	unsigned char	__pad0[4];
19916db45e65Sths 
19926db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1993992f48a0Sblueswir1 	abi_ulong	__st_ino;
19946db45e65Sths 
19956db45e65Sths 	unsigned int	st_mode;
19966db45e65Sths 	unsigned int	st_nlink;
19976db45e65Sths 
1998992f48a0Sblueswir1 	abi_ulong	st_uid;
1999992f48a0Sblueswir1 	abi_ulong	st_gid;
20006db45e65Sths 
20016db45e65Sths 	unsigned long long	st_rdev;
20026db45e65Sths 	unsigned char	__pad3[4];
20036db45e65Sths 
20046db45e65Sths 	long long	st_size;
2005992f48a0Sblueswir1 	abi_ulong	st_blksize;
20066db45e65Sths 
20076db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
20086db45e65Sths 
2009992f48a0Sblueswir1 	abi_ulong	target_st_atime;
2010992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
20116db45e65Sths 
2012992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
2013992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
20146db45e65Sths 
2015992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
2016992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
20176db45e65Sths 
20186db45e65Sths 	unsigned long long	st_ino;
20196db45e65Sths };
20206db45e65Sths 
2021d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
20225f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2023d2fd1af7Sbellard struct target_stat {
2024d2fd1af7Sbellard 	abi_ulong	st_dev;
2025d2fd1af7Sbellard 	abi_ulong	st_ino;
2026d2fd1af7Sbellard 	abi_ulong	st_nlink;
2027d2fd1af7Sbellard 
2028d2fd1af7Sbellard 	unsigned int	st_mode;
2029d2fd1af7Sbellard 	unsigned int	st_uid;
2030d2fd1af7Sbellard 	unsigned int	st_gid;
2031d2fd1af7Sbellard 	unsigned int	__pad0;
2032d2fd1af7Sbellard 	abi_ulong	st_rdev;
2033d2fd1af7Sbellard 	abi_long	st_size;
2034d2fd1af7Sbellard 	abi_long	st_blksize;
2035d2fd1af7Sbellard 	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
2036d2fd1af7Sbellard 
2037d2fd1af7Sbellard 	abi_ulong	target_st_atime;
2038d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
2039d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
2040d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
2041d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
2042d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
2043d2fd1af7Sbellard 
2044d2fd1af7Sbellard 	abi_long	__unused[3];
2045d2fd1af7Sbellard };
2046a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2047a4c075f1SUlrich Hecht struct target_stat {
2048a4c075f1SUlrich Hecht     abi_ulong  st_dev;
2049a4c075f1SUlrich Hecht     abi_ulong  st_ino;
2050a4c075f1SUlrich Hecht     abi_ulong  st_nlink;
2051a4c075f1SUlrich Hecht     unsigned int   st_mode;
2052a4c075f1SUlrich Hecht     unsigned int   st_uid;
2053a4c075f1SUlrich Hecht     unsigned int   st_gid;
2054a4c075f1SUlrich Hecht     unsigned int   __pad1;
2055a4c075f1SUlrich Hecht     abi_ulong  st_rdev;
2056a4c075f1SUlrich Hecht     abi_ulong  st_size;
2057a4c075f1SUlrich Hecht     abi_ulong  target_st_atime;
2058a4c075f1SUlrich Hecht     abi_ulong  target_st_atime_nsec;
2059a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime;
2060a4c075f1SUlrich Hecht     abi_ulong  target_st_mtime_nsec;
2061a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime;
2062a4c075f1SUlrich Hecht     abi_ulong  target_st_ctime_nsec;
2063a4c075f1SUlrich Hecht     abi_ulong  st_blksize;
2064a4c075f1SUlrich Hecht     abi_long       st_blocks;
2065a4c075f1SUlrich Hecht     abi_ulong  __unused[3];
2066a4c075f1SUlrich Hecht };
206709701199SAlexander Graf #elif defined(TARGET_AARCH64)
20685f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
206909701199SAlexander Graf struct target_stat {
207009701199SAlexander Graf     abi_ulong  st_dev;
207109701199SAlexander Graf     abi_ulong  st_ino;
207209701199SAlexander Graf     unsigned int st_mode;
207309701199SAlexander Graf     unsigned int st_nlink;
207409701199SAlexander Graf     unsigned int   st_uid;
207509701199SAlexander Graf     unsigned int   st_gid;
207609701199SAlexander Graf     abi_ulong  st_rdev;
207709701199SAlexander Graf     abi_ulong  _pad1;
207809701199SAlexander Graf     abi_long  st_size;
207909701199SAlexander Graf     int        st_blksize;
208009701199SAlexander Graf     int        __pad2;
208109701199SAlexander Graf     abi_long   st_blocks;
208209701199SAlexander Graf     abi_long  target_st_atime;
208309701199SAlexander Graf     abi_ulong  target_st_atime_nsec;
208409701199SAlexander Graf     abi_long  target_st_mtime;
208509701199SAlexander Graf     abi_ulong  target_st_mtime_nsec;
208609701199SAlexander Graf     abi_long  target_st_ctime;
208709701199SAlexander Graf     abi_ulong  target_st_ctime_nsec;
208809701199SAlexander Graf     unsigned int __unused[2];
208909701199SAlexander Graf };
2090ba7651fbSMax Filippov #elif defined(TARGET_XTENSA)
20915f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2092ba7651fbSMax Filippov struct target_stat {
2093ba7651fbSMax Filippov     abi_ulong       st_dev;
2094ba7651fbSMax Filippov     abi_ulong       st_ino;
2095ba7651fbSMax Filippov     unsigned int    st_mode;
2096ba7651fbSMax Filippov     unsigned int    st_nlink;
2097ba7651fbSMax Filippov     unsigned int    st_uid;
2098ba7651fbSMax Filippov     unsigned int    st_gid;
2099ba7651fbSMax Filippov     abi_ulong       st_rdev;
2100ba7651fbSMax Filippov     abi_long        st_size;
2101ba7651fbSMax Filippov     abi_ulong       st_blksize;
2102ba7651fbSMax Filippov     abi_ulong       st_blocks;
2103ba7651fbSMax Filippov     abi_ulong       target_st_atime;
2104ba7651fbSMax Filippov     abi_ulong       target_st_atime_nsec;
2105ba7651fbSMax Filippov     abi_ulong       target_st_mtime;
2106ba7651fbSMax Filippov     abi_ulong       target_st_mtime_nsec;
2107ba7651fbSMax Filippov     abi_ulong       target_st_ctime;
2108ba7651fbSMax Filippov     abi_ulong       target_st_ctime_nsec;
2109ba7651fbSMax Filippov     abi_ulong       __unused4;
2110ba7651fbSMax Filippov     abi_ulong       __unused5;
2111ba7651fbSMax Filippov };
2112ba7651fbSMax Filippov 
2113ba7651fbSMax Filippov #define TARGET_HAS_STRUCT_STAT64
2114ba7651fbSMax Filippov struct target_stat64  {
2115ba7651fbSMax Filippov     uint64_t st_dev;            /* Device */
2116ba7651fbSMax Filippov     uint64_t st_ino;            /* File serial number */
2117ba7651fbSMax Filippov     unsigned int  st_mode;      /* File mode. */
2118ba7651fbSMax Filippov     unsigned int  st_nlink;     /* Link count. */
2119ba7651fbSMax Filippov     unsigned int  st_uid;       /* User ID of the file's owner. */
2120ba7651fbSMax Filippov     unsigned int  st_gid;       /* Group ID of the file's group. */
2121ba7651fbSMax Filippov     uint64_t st_rdev;           /* Device number, if device. */
2122ba7651fbSMax Filippov     int64_t st_size;            /* Size of file, in bytes. */
2123ba7651fbSMax Filippov     abi_ulong st_blksize;       /* Optimal block size for I/O. */
2124ba7651fbSMax Filippov     abi_ulong __unused2;
2125ba7651fbSMax Filippov     uint64_t st_blocks;         /* Number 512-byte blocks allocated. */
2126ba7651fbSMax Filippov     abi_ulong target_st_atime;  /* Time of last access. */
2127ba7651fbSMax Filippov     abi_ulong target_st_atime_nsec;
2128ba7651fbSMax Filippov     abi_ulong target_st_mtime;  /* Time of last modification. */
2129ba7651fbSMax Filippov     abi_ulong target_st_mtime_nsec;
2130ba7651fbSMax Filippov     abi_ulong target_st_ctime;  /* Time of last status change. */
2131ba7651fbSMax Filippov     abi_ulong target_st_ctime_nsec;
2132ba7651fbSMax Filippov     abi_ulong __unused4;
2133ba7651fbSMax Filippov     abi_ulong __unused5;
2134ba7651fbSMax Filippov };
2135ba7651fbSMax Filippov 
2136be23b0ebSPhilippe Mathieu-Daudé #elif defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) \
2137be23b0ebSPhilippe Mathieu-Daudé         || defined(TARGET_RISCV) || defined(TARGET_HEXAGON)
2138c7819dfbSPeter Maydell 
2139c7819dfbSPeter Maydell /* These are the asm-generic versions of the stat and stat64 structures */
2140c7819dfbSPeter Maydell 
21415f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2142d962783eSJia Liu struct target_stat {
2143d962783eSJia Liu     abi_ulong st_dev;
2144d962783eSJia Liu     abi_ulong st_ino;
2145d962783eSJia Liu     unsigned int st_mode;
2146c7819dfbSPeter Maydell     unsigned int st_nlink;
2147d962783eSJia Liu     unsigned int st_uid;
2148d962783eSJia Liu     unsigned int st_gid;
2149d962783eSJia Liu     abi_ulong st_rdev;
2150c7819dfbSPeter Maydell     abi_ulong __pad1;
2151d962783eSJia Liu     abi_long st_size;
2152c7819dfbSPeter Maydell     int st_blksize;
2153c7819dfbSPeter Maydell     int __pad2;
2154c7819dfbSPeter Maydell     abi_long st_blocks;
2155c7819dfbSPeter Maydell     abi_long target_st_atime;
2156d962783eSJia Liu     abi_ulong target_st_atime_nsec;
2157c7819dfbSPeter Maydell     abi_long target_st_mtime;
2158d962783eSJia Liu     abi_ulong target_st_mtime_nsec;
2159c7819dfbSPeter Maydell     abi_long target_st_ctime;
2160d962783eSJia Liu     abi_ulong target_st_ctime_nsec;
2161c7819dfbSPeter Maydell     unsigned int __unused4;
2162c7819dfbSPeter Maydell     unsigned int __unused5;
2163d962783eSJia Liu };
2164c7819dfbSPeter Maydell 
216547ae93cdSMichael Clark #if !defined(TARGET_RISCV64)
216620d155bcSStefan Weil #define TARGET_HAS_STRUCT_STAT64
2167c7819dfbSPeter Maydell struct target_stat64 {
2168c7819dfbSPeter Maydell     uint64_t st_dev;
2169c7819dfbSPeter Maydell     uint64_t st_ino;
2170c7819dfbSPeter Maydell     unsigned int st_mode;
2171c7819dfbSPeter Maydell     unsigned int st_nlink;
2172c7819dfbSPeter Maydell     unsigned int st_uid;
2173c7819dfbSPeter Maydell     unsigned int st_gid;
2174c7819dfbSPeter Maydell     uint64_t st_rdev;
2175c7819dfbSPeter Maydell     uint64_t __pad1;
2176c7819dfbSPeter Maydell     int64_t st_size;
2177c7819dfbSPeter Maydell     int st_blksize;
2178c7819dfbSPeter Maydell     int __pad2;
2179c7819dfbSPeter Maydell     int64_t st_blocks;
2180c7819dfbSPeter Maydell     int target_st_atime;
2181c7819dfbSPeter Maydell     unsigned int target_st_atime_nsec;
2182c7819dfbSPeter Maydell     int target_st_mtime;
2183c7819dfbSPeter Maydell     unsigned int target_st_mtime_nsec;
2184c7819dfbSPeter Maydell     int target_st_ctime;
2185c7819dfbSPeter Maydell     unsigned int target_st_ctime_nsec;
2186c7819dfbSPeter Maydell     unsigned int __unused4;
2187c7819dfbSPeter Maydell     unsigned int __unused5;
2188c7819dfbSPeter Maydell };
218947ae93cdSMichael Clark #endif
2190c7819dfbSPeter Maydell 
2191a10d1e50SRichard Henderson #elif defined(TARGET_HPPA)
2192a10d1e50SRichard Henderson 
21935f992db6SChen-Yu Tsai #define TARGET_STAT_HAVE_NSEC
2194a10d1e50SRichard Henderson struct target_stat {
2195a10d1e50SRichard Henderson     abi_uint   st_dev;
2196a10d1e50SRichard Henderson     abi_uint   st_ino;
2197a10d1e50SRichard Henderson     abi_ushort st_mode;
2198a10d1e50SRichard Henderson     abi_ushort st_nlink;
2199a10d1e50SRichard Henderson     abi_ushort _res1;
2200a10d1e50SRichard Henderson     abi_ushort _res2;
2201a10d1e50SRichard Henderson     abi_uint   st_rdev;
2202a10d1e50SRichard Henderson     abi_int    st_size;
2203a10d1e50SRichard Henderson     abi_int    target_st_atime;
2204a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2205a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2206a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2207a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2208a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2209a10d1e50SRichard Henderson     abi_int    st_blksize;
2210a10d1e50SRichard Henderson     abi_int    st_blocks;
2211a10d1e50SRichard Henderson     abi_uint   _unused1;
2212a10d1e50SRichard Henderson     abi_uint   _unused2;
2213a10d1e50SRichard Henderson     abi_uint   _unused3;
2214a10d1e50SRichard Henderson     abi_uint   _unused4;
2215a10d1e50SRichard Henderson     abi_ushort _unused5;
2216a10d1e50SRichard Henderson     abi_short  st_fstype;
2217a10d1e50SRichard Henderson     abi_uint   st_realdev;
2218a10d1e50SRichard Henderson     abi_ushort st_basemode;
2219a10d1e50SRichard Henderson     abi_ushort _unused6;
2220a10d1e50SRichard Henderson     abi_uint   st_uid;
2221a10d1e50SRichard Henderson     abi_uint   st_gid;
2222a10d1e50SRichard Henderson     abi_uint   _unused7[3];
2223a10d1e50SRichard Henderson };
2224a10d1e50SRichard Henderson 
2225a10d1e50SRichard Henderson #define TARGET_HAS_STRUCT_STAT64
2226a10d1e50SRichard Henderson struct target_stat64 {
2227a10d1e50SRichard Henderson     uint64_t   st_dev;
2228a10d1e50SRichard Henderson     abi_uint   _pad1;
2229a10d1e50SRichard Henderson     abi_uint   _res1;
2230a10d1e50SRichard Henderson     abi_uint   st_mode;
2231a10d1e50SRichard Henderson     abi_uint   st_nlink;
2232a10d1e50SRichard Henderson     abi_uint   st_uid;
2233a10d1e50SRichard Henderson     abi_uint   st_gid;
2234a10d1e50SRichard Henderson     uint64_t   st_rdev;
2235a10d1e50SRichard Henderson     abi_uint   _pad2;
2236a10d1e50SRichard Henderson     int64_t    st_size;
2237a10d1e50SRichard Henderson     abi_int    st_blksize;
2238a10d1e50SRichard Henderson     int64_t    st_blocks;
2239a10d1e50SRichard Henderson     abi_int    target_st_atime;
2240a10d1e50SRichard Henderson     abi_uint   target_st_atime_nsec;
2241a10d1e50SRichard Henderson     abi_int    target_st_mtime;
2242a10d1e50SRichard Henderson     abi_uint   target_st_mtime_nsec;
2243a10d1e50SRichard Henderson     abi_int    target_st_ctime;
2244a10d1e50SRichard Henderson     abi_uint   target_st_ctime_nsec;
2245a10d1e50SRichard Henderson     uint64_t   st_ino;
2246a10d1e50SRichard Henderson };
2247a10d1e50SRichard Henderson 
2248048f6b4dSbellard #else
2249048f6b4dSbellard #error unsupported CPU
2250048f6b4dSbellard #endif
22512521d698Sbellard 
22524ce6f8deSths typedef struct {
22534ce6f8deSths         int     val[2];
2254c227f099SAnthony Liguori } target_fsid_t;
22554ce6f8deSths 
225656c8f68fSbellard #ifdef TARGET_MIPS
2257d26bc211Sths #ifdef TARGET_ABI_MIPSN32
2258540635baSths struct target_statfs {
2259540635baSths 	int32_t			f_type;
2260540635baSths 	int32_t			f_bsize;
2261540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
2262540635baSths 	int32_t			f_blocks;
2263540635baSths 	int32_t			f_bfree;
2264540635baSths 	int32_t			f_files;
2265540635baSths 	int32_t			f_ffree;
2266540635baSths 	int32_t			f_bavail;
2267540635baSths 
2268540635baSths 	/* Linux specials */
2269c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2270540635baSths 	int32_t			f_namelen;
2271d4247ec2SShea Levy 	int32_t			f_flags;
2272d4247ec2SShea Levy 	int32_t			f_spare[5];
2273540635baSths };
2274540635baSths #else
227556c8f68fSbellard struct target_statfs {
2276992f48a0Sblueswir1 	abi_long		f_type;
2277992f48a0Sblueswir1 	abi_long		f_bsize;
2278992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
2279992f48a0Sblueswir1 	abi_long		f_blocks;
2280992f48a0Sblueswir1 	abi_long		f_bfree;
2281992f48a0Sblueswir1 	abi_long		f_files;
2282992f48a0Sblueswir1 	abi_long		f_ffree;
2283992f48a0Sblueswir1 	abi_long		f_bavail;
228456c8f68fSbellard 
228556c8f68fSbellard 	/* Linux specials */
2286c227f099SAnthony Liguori 	target_fsid_t		f_fsid;
2287992f48a0Sblueswir1 	abi_long		f_namelen;
2288d4247ec2SShea Levy 	abi_long		f_flags;
2289d4247ec2SShea Levy 	abi_long		f_spare[5];
229056c8f68fSbellard };
2291540635baSths #endif
229256c8f68fSbellard 
229356c8f68fSbellard struct target_statfs64 {
229456c8f68fSbellard 	uint32_t	f_type;
229556c8f68fSbellard 	uint32_t	f_bsize;
229656c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
229756c8f68fSbellard 	uint32_t	__pad;
229856c8f68fSbellard 	uint64_t	f_blocks;
229956c8f68fSbellard 	uint64_t	f_bfree;
230056c8f68fSbellard 	uint64_t	f_files;
230156c8f68fSbellard 	uint64_t	f_ffree;
230256c8f68fSbellard 	uint64_t	f_bavail;
2303c227f099SAnthony Liguori 	target_fsid_t	f_fsid;
230456c8f68fSbellard 	uint32_t	f_namelen;
2305d4247ec2SShea Levy 	uint32_t	f_flags;
2306d4247ec2SShea Levy 	uint32_t	f_spare[5];
230756c8f68fSbellard };
2308c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
230947ae93cdSMichael Clark        defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
231047ae93cdSMichael Clark        defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2311325e651fSj_mayer struct target_statfs {
2312325e651fSj_mayer 	abi_long f_type;
2313325e651fSj_mayer 	abi_long f_bsize;
2314325e651fSj_mayer 	abi_long f_blocks;
2315325e651fSj_mayer 	abi_long f_bfree;
2316325e651fSj_mayer 	abi_long f_bavail;
2317325e651fSj_mayer 	abi_long f_files;
2318325e651fSj_mayer 	abi_long f_ffree;
2319c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2320325e651fSj_mayer 	abi_long f_namelen;
2321325e651fSj_mayer 	abi_long f_frsize;
2322d4247ec2SShea Levy 	abi_long f_flags;
2323d4247ec2SShea Levy 	abi_long f_spare[4];
2324325e651fSj_mayer };
2325325e651fSj_mayer 
2326325e651fSj_mayer struct target_statfs64 {
2327325e651fSj_mayer 	abi_long f_type;
2328325e651fSj_mayer 	abi_long f_bsize;
2329325e651fSj_mayer 	abi_long f_blocks;
2330325e651fSj_mayer 	abi_long f_bfree;
2331325e651fSj_mayer 	abi_long f_bavail;
2332325e651fSj_mayer 	abi_long f_files;
2333325e651fSj_mayer 	abi_long f_ffree;
2334c227f099SAnthony Liguori 	target_fsid_t f_fsid;
2335325e651fSj_mayer 	abi_long f_namelen;
2336325e651fSj_mayer 	abi_long f_frsize;
2337d4247ec2SShea Levy 	abi_long f_flags;
2338d4247ec2SShea Levy 	abi_long f_spare[4];
2339325e651fSj_mayer };
2340a4c075f1SUlrich Hecht #elif defined(TARGET_S390X)
2341a4c075f1SUlrich Hecht struct target_statfs {
2342a4c075f1SUlrich Hecht     int32_t  f_type;
2343a4c075f1SUlrich Hecht     int32_t  f_bsize;
2344a4c075f1SUlrich Hecht     abi_long f_blocks;
2345a4c075f1SUlrich Hecht     abi_long f_bfree;
2346a4c075f1SUlrich Hecht     abi_long f_bavail;
2347a4c075f1SUlrich Hecht     abi_long f_files;
2348a4c075f1SUlrich Hecht     abi_long f_ffree;
2349a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2350a4c075f1SUlrich Hecht     int32_t  f_namelen;
2351a4c075f1SUlrich Hecht     int32_t  f_frsize;
2352d4247ec2SShea Levy     int32_t  f_flags;
2353d4247ec2SShea Levy     int32_t  f_spare[4];
2354d4247ec2SShea Levy 
2355a4c075f1SUlrich Hecht };
2356a4c075f1SUlrich Hecht 
2357a4c075f1SUlrich Hecht struct target_statfs64 {
2358a4c075f1SUlrich Hecht     int32_t  f_type;
2359a4c075f1SUlrich Hecht     int32_t  f_bsize;
2360a4c075f1SUlrich Hecht     abi_long f_blocks;
2361a4c075f1SUlrich Hecht     abi_long f_bfree;
2362a4c075f1SUlrich Hecht     abi_long f_bavail;
2363a4c075f1SUlrich Hecht     abi_long f_files;
2364a4c075f1SUlrich Hecht     abi_long f_ffree;
2365a4c075f1SUlrich Hecht     kernel_fsid_t f_fsid;
2366a4c075f1SUlrich Hecht     int32_t  f_namelen;
2367a4c075f1SUlrich Hecht     int32_t  f_frsize;
2368d4247ec2SShea Levy     int32_t  f_flags;
2369d4247ec2SShea Levy     int32_t  f_spare[4];
2370a4c075f1SUlrich Hecht };
237156c8f68fSbellard #else
237256c8f68fSbellard struct target_statfs {
237356c8f68fSbellard 	uint32_t f_type;
237456c8f68fSbellard 	uint32_t f_bsize;
237556c8f68fSbellard 	uint32_t f_blocks;
237656c8f68fSbellard 	uint32_t f_bfree;
237756c8f68fSbellard 	uint32_t f_bavail;
237856c8f68fSbellard 	uint32_t f_files;
237956c8f68fSbellard 	uint32_t f_ffree;
2380c227f099SAnthony Liguori 	target_fsid_t f_fsid;
238156c8f68fSbellard 	uint32_t f_namelen;
238256c8f68fSbellard 	uint32_t f_frsize;
2383d4247ec2SShea Levy 	uint32_t f_flags;
2384d4247ec2SShea Levy 	uint32_t f_spare[4];
238556c8f68fSbellard };
238656c8f68fSbellard 
238756c8f68fSbellard struct target_statfs64 {
238856c8f68fSbellard 	uint32_t f_type;
238956c8f68fSbellard 	uint32_t f_bsize;
239056c8f68fSbellard 	uint64_t f_blocks;
239156c8f68fSbellard 	uint64_t f_bfree;
239256c8f68fSbellard 	uint64_t f_bavail;
239356c8f68fSbellard 	uint64_t f_files;
239456c8f68fSbellard 	uint64_t f_ffree;
2395c227f099SAnthony Liguori 	target_fsid_t f_fsid;
239656c8f68fSbellard         uint32_t f_namelen;
239756c8f68fSbellard 	uint32_t f_frsize;
2398d4247ec2SShea Levy 	uint32_t f_flags;
2399d4247ec2SShea Levy 	uint32_t f_spare[4];
240056c8f68fSbellard };
240156c8f68fSbellard #endif
240256c8f68fSbellard 
24037e22e546SUlrich Hecht #define TARGET_F_LINUX_SPECIFIC_BASE 1024
24047e22e546SUlrich Hecht #define TARGET_F_SETLEASE            (TARGET_F_LINUX_SPECIFIC_BASE + 0)
24057e22e546SUlrich Hecht #define TARGET_F_GETLEASE            (TARGET_F_LINUX_SPECIFIC_BASE + 1)
24067e22e546SUlrich Hecht #define TARGET_F_DUPFD_CLOEXEC       (TARGET_F_LINUX_SPECIFIC_BASE + 6)
24072bb963ffSShu-Chun Weng #define TARGET_F_NOTIFY              (TARGET_F_LINUX_SPECIFIC_BASE + 2)
24087e3b92ecSPeter Maydell #define TARGET_F_SETPIPE_SZ          (TARGET_F_LINUX_SPECIFIC_BASE + 7)
24097e3b92ecSPeter Maydell #define TARGET_F_GETPIPE_SZ          (TARGET_F_LINUX_SPECIFIC_BASE + 8)
24102bb963ffSShu-Chun Weng #define TARGET_F_ADD_SEALS           (TARGET_F_LINUX_SPECIFIC_BASE + 9)
24112bb963ffSShu-Chun Weng #define TARGET_F_GET_SEALS           (TARGET_F_LINUX_SPECIFIC_BASE + 10)
24127e22e546SUlrich Hecht 
24135de7706eSLaurent Vivier #include "target_fcntl.h"
24148d5d3004SAndreas Schwab 
24152521d698Sbellard /* soundcard defines */
241667cc32ebSVeres Lajos /* XXX: convert them all to arch independent entries */
24172521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
24182521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
24192521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
24202521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
24212521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
24222521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
24232521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
24242521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
24252521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
24262521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
24272521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
24282521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
24292521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
24302521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
24312521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
24322521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
24332521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
24342521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
24352521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
24362521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
24372521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
24382521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
24392521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
24402521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
24412521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
24422521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
24432521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
24442521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
24455f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
24465f72307dSPeter Maydell #define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
24472521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
24482521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
24492521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
24502521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
24512521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
24522521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
24532521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
24542521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
24552521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
24562521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
24572521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
24582521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
24592521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
24602521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
24612521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
24622521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
24632521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
24642521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
24652521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
24662521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
24672521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
24682521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
24692521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
24702521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
24712521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
24722521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
24732521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
24742521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
24752521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
24762521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
24772521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
24782521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
24792521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
24802521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
24812521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
24822521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
24832521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
24842521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
24852521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
24862521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
24872521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
24882521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
24892521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
24902521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
24912521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
24922521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
24932521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
24942521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
24952521d698Sbellard 
24962521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
24972521d698Sbellard 
24982521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
24992521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
25002521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
25012521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
25022521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
25032521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
25042521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
25052521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
25062521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
25072521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
25082521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
25092521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
25102521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
25112521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
25122521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
25132521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
25142521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
25152521d698Sbellard 
25162521d698Sbellard /* Obsolete macros */
25172521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
25182521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
25192521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
25202521d698Sbellard 
25212521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
25222521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
25232521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
25242521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
25252521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
25262521d698Sbellard 
25272521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
25282521d698Sbellard 
25292521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
25302521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
25312521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
25322521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
25332521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
25342521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
25352521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
25362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
25372521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
25382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
25392521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
25402521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
25412521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
25422521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
25432521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
25442521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
25452521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
25462521d698Sbellard 
25472521d698Sbellard /* Obsolete macros */
25482521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
25492521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
25502521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
25512521d698Sbellard 
25522521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
25532521d698Sbellard 
2554aca7708eSFilip Bozuta struct target_snd_timer_id {
2555aca7708eSFilip Bozuta     int dev_class;
2556aca7708eSFilip Bozuta     int dev_sclass;
2557aca7708eSFilip Bozuta     int card;
2558aca7708eSFilip Bozuta     int device;
2559aca7708eSFilip Bozuta     int subdevice;
2560aca7708eSFilip Bozuta };
2561aca7708eSFilip Bozuta 
2562aca7708eSFilip Bozuta struct target_snd_timer_ginfo {
2563aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2564aca7708eSFilip Bozuta     unsigned int flags;
2565aca7708eSFilip Bozuta     int card;
2566aca7708eSFilip Bozuta     unsigned char id[64];
2567aca7708eSFilip Bozuta     unsigned char name[80];
2568aca7708eSFilip Bozuta     abi_ulong reserved0;
2569aca7708eSFilip Bozuta     abi_ulong resolution;
2570aca7708eSFilip Bozuta     abi_ulong resolution_min;
2571aca7708eSFilip Bozuta     abi_ulong resolution_max;
2572aca7708eSFilip Bozuta     unsigned int clients;
2573aca7708eSFilip Bozuta     unsigned char reserved[32];
2574aca7708eSFilip Bozuta };
2575aca7708eSFilip Bozuta 
2576aca7708eSFilip Bozuta struct target_snd_timer_gparams {
2577aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2578aca7708eSFilip Bozuta     abi_ulong period_num;
2579aca7708eSFilip Bozuta     abi_ulong period_den;
2580aca7708eSFilip Bozuta     unsigned char reserved[32];
2581aca7708eSFilip Bozuta };
2582aca7708eSFilip Bozuta 
2583aca7708eSFilip Bozuta struct target_snd_timer_gstatus {
2584aca7708eSFilip Bozuta     struct target_snd_timer_id tid;
2585aca7708eSFilip Bozuta     abi_ulong resolution;
2586aca7708eSFilip Bozuta     abi_ulong resolution_num;
2587aca7708eSFilip Bozuta     abi_ulong resolution_den;
2588aca7708eSFilip Bozuta     unsigned char reserved[32];
2589aca7708eSFilip Bozuta };
2590aca7708eSFilip Bozuta 
2591d22edf0aSFilip Bozuta struct target_snd_timer_select {
2592d22edf0aSFilip Bozuta     struct target_snd_timer_id id;
2593d22edf0aSFilip Bozuta     unsigned char reserved[32];
2594d22edf0aSFilip Bozuta };
2595d22edf0aSFilip Bozuta 
2596fe333025SFilip Bozuta struct target_snd_timer_info {
2597fe333025SFilip Bozuta     unsigned int flags;
2598fe333025SFilip Bozuta     int card;
2599fe333025SFilip Bozuta     unsigned char id[64];
2600fe333025SFilip Bozuta     unsigned char name[80];
2601fe333025SFilip Bozuta     abi_ulong reserved0;
2602fe333025SFilip Bozuta     abi_ulong resolution;
2603fe333025SFilip Bozuta     unsigned char reserved[64];
2604fe333025SFilip Bozuta };
2605fe333025SFilip Bozuta 
2606fe333025SFilip Bozuta struct target_snd_timer_status {
2607fe333025SFilip Bozuta     struct target_timespec tstamp;
2608fe333025SFilip Bozuta     unsigned int resolution;
2609fe333025SFilip Bozuta     unsigned int lost;
2610fe333025SFilip Bozuta     unsigned int overrun;
2611fe333025SFilip Bozuta     unsigned int queue;
2612fe333025SFilip Bozuta     unsigned char reserved[64];
2613fe333025SFilip Bozuta };
2614fe333025SFilip Bozuta 
26151c4c6fcdSFilip Bozuta /* alsa timer ioctls */
26161c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PVERSION     TARGET_IOR('T', 0x00, int)
26171c4c6fcdSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE  TARGET_IOWR('T', 0x01,           \
26181c4c6fcdSFilip Bozuta                                                 struct snd_timer_id)
2619aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GINFO        TARGET_IOWR('T', 0x03,           \
2620aca7708eSFilip Bozuta                                                 struct target_snd_timer_ginfo)
2621aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GPARAMS      TARGET_IOW('T', 0x04,            \
2622aca7708eSFilip Bozuta                                                 struct target_snd_timer_gparams)
2623aca7708eSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_GSTATUS      TARGET_IOWR('T', 0x05,           \
2624aca7708eSFilip Bozuta                                                 struct target_snd_timer_gstatus)
2625d22edf0aSFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_SELECT       TARGET_IOW('T', 0x10,            \
2626d22edf0aSFilip Bozuta                                                 struct target_snd_timer_select)
2627fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_INFO         TARGET_IOR('T', 0x11,            \
2628fe333025SFilip Bozuta                                                 struct target_snd_timer_info)
2629fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PARAMS       TARGET_IOW('T', 0x12,            \
2630fe333025SFilip Bozuta                                                 struct snd_timer_params)
2631fe333025SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_STATUS       TARGET_IOR('T', 0x14,            \
2632fe333025SFilip Bozuta                                                 struct target_snd_timer_status)
2633045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_START        TARGET_IO('T', 0xa0)
2634045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_STOP         TARGET_IO('T', 0xa1)
2635045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_CONTINUE     TARGET_IO('T', 0xa2)
2636045823a9SFilip Bozuta #define TARGET_SNDRV_TIMER_IOCTL_PAUSE        TARGET_IO('T', 0xa3)
26371c4c6fcdSFilip Bozuta 
26382521d698Sbellard /* vfat ioctls */
26392521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
26402521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
2641a5448a7dSbellard 
2642f443e396SPeter Maydell struct target_mtop {
2643f443e396SPeter Maydell     abi_short mt_op;
2644f443e396SPeter Maydell     abi_int mt_count;
2645f443e396SPeter Maydell };
2646f443e396SPeter Maydell 
2647f443e396SPeter Maydell #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2648f443e396SPeter Maydell typedef abi_long target_kernel_daddr_t;
2649f443e396SPeter Maydell #else
2650f443e396SPeter Maydell typedef abi_int target_kernel_daddr_t;
2651f443e396SPeter Maydell #endif
2652f443e396SPeter Maydell 
2653f443e396SPeter Maydell struct target_mtget {
2654f443e396SPeter Maydell     abi_long mt_type;
2655f443e396SPeter Maydell     abi_long mt_resid;
2656f443e396SPeter Maydell     abi_long mt_dsreg;
2657f443e396SPeter Maydell     abi_long mt_gstat;
2658f443e396SPeter Maydell     abi_long mt_erreg;
2659f443e396SPeter Maydell     target_kernel_daddr_t mt_fileno;
2660f443e396SPeter Maydell     target_kernel_daddr_t mt_blkno;
2661f443e396SPeter Maydell };
2662f443e396SPeter Maydell 
2663f443e396SPeter Maydell struct target_mtpos {
2664f443e396SPeter Maydell     abi_long mt_blkno;
2665f443e396SPeter Maydell };
2666f443e396SPeter Maydell 
2667f443e396SPeter Maydell #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
2668f443e396SPeter Maydell #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
2669f443e396SPeter Maydell #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
26708fbd6b52Sbalrog 
2671bd27e675SAleksandar Markovic /* kcov ioctls */
2672bd27e675SAleksandar Markovic #define TARGET_KCOV_ENABLE     TARGET_IO('c', 100)
2673bd27e675SAleksandar Markovic #define TARGET_KCOV_DISABLE    TARGET_IO('c', 101)
2674f7dbd8feSAleksandar Markovic #define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
2675bd27e675SAleksandar Markovic 
2676a5448a7dSbellard struct target_sysinfo {
2677992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
2678992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
2679992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
2680992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
2681992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
2682992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
2683992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
2684992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
2685a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
2686a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
2687992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
2688992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
2689a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
2690992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
2691a5448a7dSbellard };
26923532fa74Sbellard 
26936556a833Saurel32 struct linux_dirent {
26946556a833Saurel32     long            d_ino;
26956556a833Saurel32     unsigned long   d_off;
26966556a833Saurel32     unsigned short  d_reclen;
2697540a736fSRichard Henderson     char            d_name[];
26986556a833Saurel32 };
26996556a833Saurel32 
27006556a833Saurel32 struct linux_dirent64 {
27016556a833Saurel32     uint64_t        d_ino;
27026556a833Saurel32     int64_t         d_off;
27036556a833Saurel32     unsigned short  d_reclen;
27046556a833Saurel32     unsigned char   d_type;
2705540a736fSRichard Henderson     char            d_name[];
27066556a833Saurel32 };
27076556a833Saurel32 
270824e1003aSaurel32 struct target_mq_attr {
270924e1003aSaurel32     abi_long mq_flags;
271024e1003aSaurel32     abi_long mq_maxmsg;
271124e1003aSaurel32     abi_long mq_msgsize;
271224e1003aSaurel32     abi_long mq_curmsgs;
271324e1003aSaurel32 };
271424e1003aSaurel32 
2715e865b97fSChen Gang struct target_drm_version {
2716e865b97fSChen Gang     int version_major;
2717e865b97fSChen Gang     int version_minor;
2718e865b97fSChen Gang     int version_patchlevel;
2719e865b97fSChen Gang     abi_ulong name_len;
2720e865b97fSChen Gang     abi_ulong name;
2721e865b97fSChen Gang     abi_ulong date_len;
2722e865b97fSChen Gang     abi_ulong date;
2723e865b97fSChen Gang     abi_ulong desc_len;
2724e865b97fSChen Gang     abi_ulong desc;
2725e865b97fSChen Gang };
2726e865b97fSChen Gang 
2727913b03c2SChen Gang struct target_drm_i915_getparam {
2728913b03c2SChen Gang     int param;
2729913b03c2SChen Gang     abi_ulong value;
2730913b03c2SChen Gang };
2731913b03c2SChen Gang 
27323532fa74Sbellard #include "socket.h"
2733637947f1Sths 
27348f968b6aSPhilippe Mathieu-Daudé #include "target_errno_defs.h"
273503dfe9f8SRiku Voipio 
273603dfe9f8SRiku Voipio #define FUTEX_WAIT              0
273703dfe9f8SRiku Voipio #define FUTEX_WAKE              1
273803dfe9f8SRiku Voipio #define FUTEX_FD                2
273903dfe9f8SRiku Voipio #define FUTEX_REQUEUE           3
274003dfe9f8SRiku Voipio #define FUTEX_CMP_REQUEUE       4
274103dfe9f8SRiku Voipio #define FUTEX_WAKE_OP           5
274203dfe9f8SRiku Voipio #define FUTEX_LOCK_PI           6
274303dfe9f8SRiku Voipio #define FUTEX_UNLOCK_PI         7
274403dfe9f8SRiku Voipio #define FUTEX_TRYLOCK_PI        8
274503dfe9f8SRiku Voipio #define FUTEX_WAIT_BITSET       9
274603dfe9f8SRiku Voipio #define FUTEX_WAKE_BITSET       10
274703dfe9f8SRiku Voipio 
274803dfe9f8SRiku Voipio #define FUTEX_PRIVATE_FLAG      128
274903dfe9f8SRiku Voipio #define FUTEX_CLOCK_REALTIME    256
275003dfe9f8SRiku Voipio #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
275103dfe9f8SRiku Voipio 
27523b6edd16SPeter Maydell #ifdef CONFIG_EPOLL
2753928bed6aSLaurent Vivier #if defined(TARGET_X86_64)
2754928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED QEMU_PACKED
2755928bed6aSLaurent Vivier #else
2756928bed6aSLaurent Vivier #define TARGET_EPOLL_PACKED
2757928bed6aSLaurent Vivier #endif
2758928bed6aSLaurent Vivier 
27593b6edd16SPeter Maydell typedef union target_epoll_data {
27603b6edd16SPeter Maydell     abi_ulong ptr;
2761928bed6aSLaurent Vivier     abi_int fd;
2762928bed6aSLaurent Vivier     abi_uint u32;
2763928bed6aSLaurent Vivier     abi_ullong u64;
27643b6edd16SPeter Maydell } target_epoll_data_t;
27653b6edd16SPeter Maydell 
27663b6edd16SPeter Maydell struct target_epoll_event {
2767928bed6aSLaurent Vivier     abi_uint events;
27683b6edd16SPeter Maydell     target_epoll_data_t data;
2769928bed6aSLaurent Vivier } TARGET_EPOLL_PACKED;
27702ba7fae3SPeter Maydell 
27712ba7fae3SPeter Maydell #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
27722ba7fae3SPeter Maydell 
27733b6edd16SPeter Maydell #endif
2774163a05a8SPeter Maydell struct target_rlimit64 {
2775163a05a8SPeter Maydell     uint64_t rlim_cur;
2776163a05a8SPeter Maydell     uint64_t rlim_max;
2777163a05a8SPeter Maydell };
2778583359a6SAkos PASZTORY 
2779583359a6SAkos PASZTORY struct target_ucred {
2780583359a6SAkos PASZTORY     uint32_t pid;
2781583359a6SAkos PASZTORY     uint32_t uid;
2782583359a6SAkos PASZTORY     uint32_t gid;
2783583359a6SAkos PASZTORY };
2784cb9c377fSPaolo Bonzini 
2785aecc8861SAlexander Graf typedef int32_t target_timer_t;
2786905bba13SErik de Castro Lopo 
278734d60862SNatanael Copa #define TARGET_SIGEV_MAX_SIZE 64
278834d60862SNatanael Copa 
278934d60862SNatanael Copa /* This is architecture-specific but most architectures use the default */
279034d60862SNatanael Copa #ifdef TARGET_MIPS
279134d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
279234d60862SNatanael Copa #else
279334d60862SNatanael Copa #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
279434d60862SNatanael Copa                                     + sizeof(target_sigval_t))
279534d60862SNatanael Copa #endif
279634d60862SNatanael Copa 
279734d60862SNatanael Copa #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
279834d60862SNatanael Copa                                 - TARGET_SIGEV_PREAMBLE_SIZE) \
279934d60862SNatanael Copa                                / sizeof(int32_t))
280034d60862SNatanael Copa 
2801905bba13SErik de Castro Lopo struct target_sigevent {
2802905bba13SErik de Castro Lopo     target_sigval_t sigev_value;
280317351c3fSPeter Maydell     abi_int sigev_signo;
280417351c3fSPeter Maydell     abi_int sigev_notify;
2805905bba13SErik de Castro Lopo     union {
280617351c3fSPeter Maydell         abi_int _pad[TARGET_SIGEV_PAD_SIZE];
280717351c3fSPeter Maydell         abi_int _tid;
2808905bba13SErik de Castro Lopo 
280917351c3fSPeter Maydell         /* The kernel (and thus QEMU) never looks at these;
281017351c3fSPeter Maydell          * they're only used as part of the ABI between a
281117351c3fSPeter Maydell          * userspace program and libc.
281217351c3fSPeter Maydell          */
2813905bba13SErik de Castro Lopo         struct {
281417351c3fSPeter Maydell             abi_ulong _function;
281517351c3fSPeter Maydell             abi_ulong _attribute;
2816905bba13SErik de Castro Lopo         } _sigev_thread;
2817905bba13SErik de Castro Lopo     } _sigev_un;
2818905bba13SErik de Castro Lopo };
2819e0eb210eSPeter Maydell 
2820e0eb210eSPeter Maydell struct target_user_cap_header {
2821e0eb210eSPeter Maydell     uint32_t version;
2822e0eb210eSPeter Maydell     int pid;
2823e0eb210eSPeter Maydell };
2824e0eb210eSPeter Maydell 
2825e0eb210eSPeter Maydell struct target_user_cap_data {
2826e0eb210eSPeter Maydell     uint32_t effective;
2827e0eb210eSPeter Maydell     uint32_t permitted;
2828e0eb210eSPeter Maydell     uint32_t inheritable;
2829e0eb210eSPeter Maydell };
28301b3c4fdfSMarkus Armbruster 
2831da2c8ad7SAleksandar Markovic /* from kernel's include/linux/syslog.h */
2832da2c8ad7SAleksandar Markovic 
2833da2c8ad7SAleksandar Markovic /* Close the log.  Currently a NOP. */
2834da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLOSE          0
2835da2c8ad7SAleksandar Markovic /* Open the log. Currently a NOP. */
2836da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_OPEN           1
2837da2c8ad7SAleksandar Markovic /* Read from the log. */
2838da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ           2
2839da2c8ad7SAleksandar Markovic /* Read all messages remaining in the ring buffer. */
2840da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_ALL       3
2841da2c8ad7SAleksandar Markovic /* Read and clear all messages remaining in the ring buffer */
2842da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_READ_CLEAR     4
2843da2c8ad7SAleksandar Markovic /* Clear ring buffer. */
2844da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CLEAR          5
2845da2c8ad7SAleksandar Markovic /* Disable printk's to console */
2846da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
2847da2c8ad7SAleksandar Markovic /* Enable printk's to console */
2848da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
2849da2c8ad7SAleksandar Markovic /* Set level of messages printed to console */
2850da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
2851da2c8ad7SAleksandar Markovic /* Return number of unread characters in the log buffer */
2852da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
2853da2c8ad7SAleksandar Markovic /* Return size of the log buffer */
2854da2c8ad7SAleksandar Markovic #define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10
2855da2c8ad7SAleksandar Markovic 
2856efa92184SAleksandar Rikalo struct target_statx_timestamp {
2857efa92184SAleksandar Rikalo    int64_t tv_sec;
2858efa92184SAleksandar Rikalo    uint32_t tv_nsec;
2859efa92184SAleksandar Rikalo    int32_t __reserved;
2860efa92184SAleksandar Rikalo };
2861efa92184SAleksandar Rikalo 
2862efa92184SAleksandar Rikalo struct target_statx {
2863efa92184SAleksandar Rikalo    /* 0x00 */
2864efa92184SAleksandar Rikalo    uint32_t stx_mask;       /* What results were written [uncond] */
2865efa92184SAleksandar Rikalo    uint32_t stx_blksize;    /* Preferred general I/O size [uncond] */
2866efa92184SAleksandar Rikalo    uint64_t stx_attributes; /* Flags conveying information about the file */
2867efa92184SAleksandar Rikalo    /* 0x10 */
2868efa92184SAleksandar Rikalo    uint32_t stx_nlink;      /* Number of hard links */
2869efa92184SAleksandar Rikalo    uint32_t stx_uid;        /* User ID of owner */
2870efa92184SAleksandar Rikalo    uint32_t stx_gid;        /* Group ID of owner */
2871efa92184SAleksandar Rikalo    uint16_t stx_mode;       /* File mode */
2872efa92184SAleksandar Rikalo    uint16_t __spare0[1];
2873efa92184SAleksandar Rikalo    /* 0x20 */
2874efa92184SAleksandar Rikalo    uint64_t stx_ino;        /* Inode number */
2875efa92184SAleksandar Rikalo    uint64_t stx_size;       /* File size */
2876efa92184SAleksandar Rikalo    uint64_t stx_blocks;     /* Number of 512-byte blocks allocated */
2877efa92184SAleksandar Rikalo    uint64_t stx_attributes_mask; /* Mask to show what is supported */
2878efa92184SAleksandar Rikalo    /* 0x40 */
2879efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_atime;  /* Last access time */
2880efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_btime;  /* File creation time */
2881efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_ctime;  /* Last attribute change time */
2882efa92184SAleksandar Rikalo    struct target_statx_timestamp  stx_mtime;  /* Last data modification time */
2883efa92184SAleksandar Rikalo    /* 0x80 */
2884efa92184SAleksandar Rikalo    uint32_t stx_rdev_major;   /* Device ID of special file [if bdev/cdev] */
2885efa92184SAleksandar Rikalo    uint32_t stx_rdev_minor;
2886efa92184SAleksandar Rikalo    uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2887efa92184SAleksandar Rikalo    uint32_t stx_dev_minor;
2888efa92184SAleksandar Rikalo    /* 0x90 */
2889efa92184SAleksandar Rikalo    uint64_t __spare2[14];  /* Spare space for future expansion */
2890efa92184SAleksandar Rikalo    /* 0x100 */
2891efa92184SAleksandar Rikalo };
2892efa92184SAleksandar Rikalo 
2893*45ad761cSTonis Tiigi /* from kernel's include/linux/sched/types.h */
2894*45ad761cSTonis Tiigi struct target_sched_attr {
2895*45ad761cSTonis Tiigi     abi_uint size;
2896*45ad761cSTonis Tiigi     abi_uint sched_policy;
2897*45ad761cSTonis Tiigi     abi_ullong sched_flags;
2898*45ad761cSTonis Tiigi     abi_int sched_nice;
2899*45ad761cSTonis Tiigi     abi_uint sched_priority;
2900*45ad761cSTonis Tiigi     abi_ullong sched_runtime;
2901*45ad761cSTonis Tiigi     abi_ullong sched_deadline;
2902*45ad761cSTonis Tiigi     abi_ullong sched_period;
2903*45ad761cSTonis Tiigi     abi_uint sched_util_min;
2904*45ad761cSTonis Tiigi     abi_uint sched_util_max;
2905*45ad761cSTonis Tiigi };
2906*45ad761cSTonis Tiigi 
29071b3c4fdfSMarkus Armbruster #endif
2908