]> Git Repo - qemu.git/blame - linux-user/syscall_defs.h
target/microblaze: Convert brk and brki to decodetree
[qemu.git] / linux-user / syscall_defs.h
CommitLineData
31e31b8a
FB
1/* common syscall defines for all architectures */
2
2521d698 3/* Note: although the syscall numbers change between architectures,
b4916d7b 4 most of them stay the same, so we handle it by putting ifdefs if
2521d698
FB
5 necessary */
6
cb9c377f 7#ifndef SYSCALL_DEFS_H
1b3c4fdf 8#define SYSCALL_DEFS_H
cb9c377f 9
6180a181 10#include "syscall_nr.h"
2521d698 11
ff71a454
AM
12
13/* socket operations for socketcall() */
14#define TARGET_SYS_SOCKET 1 /* socket() */
15#define TARGET_SYS_BIND 2 /* bind() */
16#define TARGET_SYS_CONNECT 3 /* connect() */
17#define TARGET_SYS_LISTEN 4 /* listen() */
18#define TARGET_SYS_ACCEPT 5 /* accept() */
19#define TARGET_SYS_GETSOCKNAME 6 /* getsockname() */
20#define TARGET_SYS_GETPEERNAME 7 /* getpeername() */
21#define TARGET_SYS_SOCKETPAIR 8 /* socketpair() */
22#define TARGET_SYS_SEND 9 /* send() */
23#define TARGET_SYS_RECV 10 /* recv() */
24#define TARGET_SYS_SENDTO 11 /* sendto() */
25#define TARGET_SYS_RECVFROM 12 /* recvfrom() */
26#define TARGET_SYS_SHUTDOWN 13 /* shutdown() */
27#define TARGET_SYS_SETSOCKOPT 14 /* setsockopt() */
28#define TARGET_SYS_GETSOCKOPT 15 /* getsockopt() */
29#define TARGET_SYS_SENDMSG 16 /* sendmsg() */
30#define TARGET_SYS_RECVMSG 17 /* recvmsg() */
31#define TARGET_SYS_ACCEPT4 18 /* accept4() */
32#define TARGET_SYS_RECVMMSG 19 /* recvmmsg() */
33#define TARGET_SYS_SENDMMSG 20 /* sendmmsg() */
31e31b8a 34
524fa340 35#define IPCOP_CALL(VERSION, OP) ((VERSION) << 16 | (OP))
8853f86e
FB
36#define IPCOP_semop 1
37#define IPCOP_semget 2
38#define IPCOP_semctl 3
39#define IPCOP_semtimedop 4
40#define IPCOP_msgsnd 11
41#define IPCOP_msgrcv 12
42#define IPCOP_msgget 13
43#define IPCOP_msgctl 14
44#define IPCOP_shmat 21
45#define IPCOP_shmdt 22
46#define IPCOP_shmget 23
47#define IPCOP_shmctl 24
48
0a7ec849
FB
49#define TARGET_SEMOPM 500
50
2521d698
FB
51/*
52 * The following is for compatibility across the various Linux
53 * platforms. The i386 ioctl numbering scheme doesn't really enforce
54 * a type field. De facto, however, the top 8 bits of the lower 16
55 * bits are indeed used as a type field, so we might just as well make
56 * this explicit here. Please be sure to use the decoding macros
57 * below from now on.
58 */
59#define TARGET_IOC_NRBITS 8
60#define TARGET_IOC_TYPEBITS 8
61
716f3fbe
PM
62#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
63 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
cd98d390 64 || defined(TARGET_SPARC) \
0c866a7e 65 || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
74d753ac
MW
66 /* 16 bit uid wrappers emulation */
67#define USE_UID16
0c866a7e
RV
68#define target_id uint16_t
69#else
70#define target_id uint32_t
74d753ac
MW
71#endif
72
e6e5906b 73#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
b16189b2 74 || defined(TARGET_M68K) || defined(TARGET_CRIS) \
daa4374a 75 || defined(TARGET_S390X) \
a0a839b6 76 || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
ba7651fb
MF
77 || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
78 || defined(TARGET_XTENSA)
2521d698
FB
79
80#define TARGET_IOC_SIZEBITS 14
81#define TARGET_IOC_DIRBITS 2
82
83#define TARGET_IOC_NONE 0U
84#define TARGET_IOC_WRITE 1U
85#define TARGET_IOC_READ 2U
86
048f6b4d 87#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
b779e29e
EI
88 defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
89 defined(TARGET_MIPS)
2521d698
FB
90
91#define TARGET_IOC_SIZEBITS 13
92#define TARGET_IOC_DIRBITS 3
93
94#define TARGET_IOC_NONE 1U
95#define TARGET_IOC_READ 2U
96#define TARGET_IOC_WRITE 4U
97
a10d1e50
RH
98#elif defined(TARGET_HPPA)
99
100#define TARGET_IOC_SIZEBITS 14
101#define TARGET_IOC_DIRBITS 2
102
103#define TARGET_IOC_NONE 0U
104#define TARGET_IOC_WRITE 2U
105#define TARGET_IOC_READ 1U
106
2521d698
FB
107#else
108#error unsupported CPU
109#endif
110
111#define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
112#define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
113#define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
114#define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
115
116#define TARGET_IOC_NRSHIFT 0
117#define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
118#define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
119#define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
120
121#define TARGET_IOC(dir,type,nr,size) \
122 (((dir) << TARGET_IOC_DIRSHIFT) | \
123 ((type) << TARGET_IOC_TYPESHIFT) | \
124 ((nr) << TARGET_IOC_NRSHIFT) | \
125 ((size) << TARGET_IOC_SIZESHIFT))
126
127/* used to create numbers */
128#define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
129#define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
130#define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
131#define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
132
133/* the size is automatically computed for these defines */
134#define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
135#define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
136#define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
137
7854b056 138struct target_sockaddr {
9a68960d 139 abi_ushort sa_family;
7854b056
FB
140 uint8_t sa_data[14];
141};
142
33a29b51 143struct target_sockaddr_ll {
9a68960d
PMD
144 abi_ushort sll_family; /* Always AF_PACKET */
145 abi_ushort sll_protocol; /* Physical layer protocol */
146 abi_int sll_ifindex; /* Interface number */
147 abi_ushort sll_hatype; /* ARP hardware type */
148 uint8_t sll_pkttype; /* Packet type */
149 uint8_t sll_halen; /* Length of address */
150 uint8_t sll_addr[8]; /* Physical layer address */
33a29b51
JT
151};
152
fb3aabf3 153struct target_sockaddr_un {
9a68960d 154 abi_ushort su_family;
fb3aabf3
LV
155 uint8_t sun_path[108];
156};
157
a47401bc
PMD
158struct target_sockaddr_nl {
159 abi_ushort nl_family; /* AF_NETLINK */
160 abi_ushort __pad;
161 abi_uint nl_pid;
162 abi_uint nl_groups;
163};
164
fb3aabf3 165struct target_in_addr {
9a68960d 166 abi_uint s_addr; /* big endian */
fb3aabf3
LV
167};
168
169struct target_sockaddr_in {
9a68960d
PMD
170 abi_ushort sin_family;
171 abi_short sin_port; /* big endian */
fb3aabf3
LV
172 struct target_in_addr sin_addr;
173 uint8_t __pad[sizeof(struct target_sockaddr) -
9a68960d 174 sizeof(abi_ushort) - sizeof(abi_short) -
fb3aabf3
LV
175 sizeof(struct target_in_addr)];
176};
177
ee1ac3a1 178struct target_sockaddr_in6 {
9a68960d
PMD
179 abi_ushort sin6_family;
180 abi_ushort sin6_port; /* big endian */
181 abi_uint sin6_flowinfo; /* big endian */
ee1ac3a1 182 struct in6_addr sin6_addr; /* IPv6 address, big endian */
9a68960d 183 abi_uint sin6_scope_id;
ee1ac3a1
HD
184};
185
f57d4192
LV
186struct target_sock_filter {
187 abi_ushort code;
188 uint8_t jt;
189 uint8_t jf;
190 abi_uint k;
191};
192
193struct target_sock_fprog {
194 abi_ushort len;
195 abi_ulong filter;
196};
197
b975b83b
LL
198struct target_ip_mreq {
199 struct target_in_addr imr_multiaddr;
200 struct target_in_addr imr_address;
201};
202
203struct target_ip_mreqn {
204 struct target_in_addr imr_multiaddr;
205 struct target_in_addr imr_address;
206 abi_long imr_ifindex;
207};
208
6e3cb58f
LL
209struct target_ip_mreq_source {
210 /* big endian */
211 uint32_t imr_multiaddr;
212 uint32_t imr_interface;
213 uint32_t imr_sourceaddr;
214};
215
83eb6e50
CMAB
216struct target_linger {
217 abi_int l_onoff; /* Linger active */
218 abi_int l_linger; /* How long to linger for */
219};
220
6d5d5dde
DB
221#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
222struct target_timeval {
223 abi_long tv_sec;
224 abi_int tv_usec;
225};
226#define target__kernel_sock_timeval target_timeval
227#else
31e31b8a 228struct target_timeval {
992f48a0
BS
229 abi_long tv_sec;
230 abi_long tv_usec;
31e31b8a
FB
231};
232
6d5d5dde
DB
233struct target__kernel_sock_timeval {
234 abi_llong tv_sec;
235 abi_llong tv_usec;
236};
237#endif
238
1b6b029e 239struct target_timespec {
992f48a0
BS
240 abi_long tv_sec;
241 abi_long tv_nsec;
1b6b029e
FB
242};
243
6d5d5dde
DB
244struct target__kernel_timespec {
245 abi_llong tv_sec;
246 abi_llong tv_nsec;
247};
248
ef4467e9
PB
249struct target_timezone {
250 abi_int tz_minuteswest;
251 abi_int tz_dsttime;
252};
253
66fb9763
FB
254struct target_itimerval {
255 struct target_timeval it_interval;
256 struct target_timeval it_value;
257};
258
905bba13
ECL
259struct target_itimerspec {
260 struct target_timespec it_interval;
261 struct target_timespec it_value;
262};
263
828cb3a1
FB
264struct target__kernel_itimerspec {
265 struct target__kernel_timespec it_interval;
266 struct target__kernel_timespec it_value;
267};
268
19f59bce
AM
269struct target_timex {
270 abi_uint modes; /* Mode selector */
271 abi_long offset; /* Time offset */
272 abi_long freq; /* Frequency offset */
273 abi_long maxerror; /* Maximum error (microseconds) */
274 abi_long esterror; /* Estimated error (microseconds) */
275 abi_int status; /* Clock command/status */
276 abi_long constant; /* PLL (phase-locked loop) time constant */
277 abi_long precision; /* Clock precision (microseconds, ro) */
278 abi_long tolerance; /* Clock freq. tolerance (ppm, ro) */
279 struct target_timeval time; /* Current time */
280 abi_long tick; /* Microseconds between clock ticks */
281 abi_long ppsfreq; /* PPS (pulse per second) frequency */
282 abi_long jitter; /* PPS jitter (ro); nanoseconds */
283 abi_int shift; /* PPS interval duration (seconds) */
284 abi_long stabil; /* PPS stability */
285 abi_long jitcnt; /* PPS jitter limit exceeded (ro) */
286 abi_long calcnt; /* PPS calibration intervals */
287 abi_long errcnt; /* PPS calibration errors */
288 abi_long stbcnt; /* PPS stability limit exceeded */
289 abi_int tai; /* TAI offset */
290
291 /* Further padding bytes to allow for future expansion */
292 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
293 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
294 abi_int:32; abi_int:32; abi_int:32;
295};
296
6ac03b2c
FB
297struct target__kernel_timex {
298 abi_uint modes; /* Mode selector */
299 abi_int: 32; /* pad */
300 abi_llong offset; /* Time offset */
301 abi_llong freq; /* Frequency offset */
302 abi_llong maxerror; /* Maximum error (microseconds) */
303 abi_llong esterror; /* Estimated error (microseconds) */
304 abi_int status; /* Clock command/status */
305 abi_int: 32; /* pad */
306 abi_llong constant; /* PLL (phase-locked loop) time constant */
307 abi_llong precision; /* Clock precision (microseconds, ro) */
308 abi_llong tolerance; /* Clock freq. tolerance (ppm, ro) */
309 struct target__kernel_sock_timeval time; /* Current time */
310 abi_llong tick; /* Microseconds between clock ticks */
311 abi_llong ppsfreq; /* PPS (pulse per second) frequency */
312 abi_llong jitter; /* PPS jitter (ro); nanoseconds */
313 abi_int shift; /* PPS interval duration (seconds) */
314 abi_int: 32; /* pad */
315 abi_llong stabil; /* PPS stability */
316 abi_llong jitcnt; /* PPS jitter limit exceeded (ro) */
317 abi_llong calcnt; /* PPS calibration intervals */
318 abi_llong errcnt; /* PPS calibration errors */
319 abi_llong stbcnt; /* PPS stability limit exceeded */
320 abi_int tai; /* TAI offset */
321
322 /* Further padding bytes to allow for future expansion */
323 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
324 abi_int:32; abi_int:32; abi_int:32; abi_int:32;
325 abi_int:32; abi_int:32; abi_int:32;
326};
327
c227f099 328typedef abi_long target_clock_t;
32f36bce 329
c596ed17
FB
330#define TARGET_HZ 100
331
32f36bce 332struct target_tms {
c227f099
AL
333 target_clock_t tms_utime;
334 target_clock_t tms_stime;
335 target_clock_t tms_cutime;
336 target_clock_t tms_cstime;
32f36bce
FB
337};
338
6180a181 339struct target_utimbuf {
992f48a0
BS
340 abi_long actime;
341 abi_long modtime;
6180a181
FB
342};
343
f2674e31 344struct target_sel_arg_struct {
992f48a0
BS
345 abi_long n;
346 abi_long inp, outp, exp;
347 abi_long tvp;
f2674e31
FB
348};
349
31e31b8a 350struct target_iovec {
992f48a0
BS
351 abi_long iov_base; /* Starting address */
352 abi_long iov_len; /* Number of bytes */
31e31b8a
FB
353};
354
1a9353d2 355struct target_msghdr {
992f48a0
BS
356 abi_long msg_name; /* Socket name */
357 int msg_namelen; /* Length of name */
358 abi_long msg_iov; /* Data blocks */
359 abi_long msg_iovlen; /* Number of blocks */
360 abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
361 abi_long msg_controllen; /* Length of cmsg list */
1a9353d2
FB
362 unsigned int msg_flags;
363};
364
7854b056 365struct target_cmsghdr {
992f48a0 366 abi_long cmsg_len;
7854b056
FB
367 int cmsg_level;
368 int cmsg_type;
369};
370
371#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
ee104587
JN
372#define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
373 __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
992f48a0
BS
374#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
375 & (size_t) ~(sizeof (abi_long) - 1))
ad762b99
PM
376#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
377 TARGET_CMSG_ALIGN(len))
378#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
7854b056
FB
379
380static __inline__ struct target_cmsghdr *
ee104587
JN
381__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
382 struct target_cmsghdr *__cmsg,
383 struct target_cmsghdr *__cmsg_start)
7854b056 384{
2b8bdefc
TS
385 struct target_cmsghdr *__ptr;
386
387 __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
cbb21eed 388 + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
ee104587
JN
389 if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
390 > tswapal(__mhdr->msg_controllen)) {
7854b056 391 /* No more entries. */
2b8bdefc 392 return (struct target_cmsghdr *)0;
ee104587
JN
393 }
394 return __ptr;
7854b056
FB
395}
396
f19e00d7
AG
397struct target_mmsghdr {
398 struct target_msghdr msg_hdr; /* Message header */
399 unsigned int msg_len; /* Number of bytes transmitted */
400};
7854b056 401
31e31b8a
FB
402struct target_rusage {
403 struct target_timeval ru_utime; /* user time used */
404 struct target_timeval ru_stime; /* system time used */
992f48a0
BS
405 abi_long ru_maxrss; /* maximum resident set size */
406 abi_long ru_ixrss; /* integral shared memory size */
407 abi_long ru_idrss; /* integral unshared data size */
408 abi_long ru_isrss; /* integral unshared stack size */
409 abi_long ru_minflt; /* page reclaims */
410 abi_long ru_majflt; /* page faults */
411 abi_long ru_nswap; /* swaps */
412 abi_long ru_inblock; /* block input operations */
413 abi_long ru_oublock; /* block output operations */
414 abi_long ru_msgsnd; /* messages sent */
415 abi_long ru_msgrcv; /* messages received */
416 abi_long ru_nsignals; /* signals received */
417 abi_long ru_nvcsw; /* voluntary context switches */
418 abi_long ru_nivcsw; /* involuntary " */
31e31b8a
FB
419};
420
421typedef struct {
422 int val[2];
c227f099 423} kernel_fsid_t;
31e31b8a 424
dab2ed99 425struct target_dirent {
333858b7
DL
426 abi_long d_ino;
427 abi_long d_off;
428 unsigned short d_reclen;
429 char d_name[];
dab2ed99
FB
430};
431
432struct target_dirent64 {
433 uint64_t d_ino;
434 int64_t d_off;
435 unsigned short d_reclen;
436 unsigned char d_type;
437 char d_name[256];
438};
439
440
31e31b8a 441/* mostly generic signal stuff */
992f48a0
BS
442#define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
443#define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
444#define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
31e31b8a
FB
445
446#ifdef TARGET_MIPS
447#define TARGET_NSIG 128
448#else
449#define TARGET_NSIG 64
450#endif
992f48a0 451#define TARGET_NSIG_BPW TARGET_ABI_BITS
31e31b8a
FB
452#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
453
454typedef struct {
992f48a0 455 abi_ulong sig[TARGET_NSIG_WORDS];
c227f099 456} target_sigset_t;
31e31b8a 457
66fb9763 458#ifdef BSWAP_NEEDED
c227f099 459static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
460{
461 int i;
462 for(i = 0;i < TARGET_NSIG_WORDS; i++)
cbb21eed 463 d->sig[i] = tswapal(s->sig[i]);
66fb9763
FB
464}
465#else
c227f099 466static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
467{
468 *d = *s;
469}
470#endif
471
c227f099 472static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
66fb9763
FB
473{
474 int i;
475 d->sig[0] = set;
476 for(i = 1;i < TARGET_NSIG_WORDS; i++)
477 d->sig[i] = 0;
478}
479
c227f099
AL
480void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
481void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
992f48a0 482void host_to_target_old_sigset(abi_ulong *old_sigset,
66fb9763 483 const sigset_t *sigset);
5fafdf24 484void target_to_host_old_sigset(sigset_t *sigset,
992f48a0 485 const abi_ulong *old_sigset);
66fb9763
FB
486struct target_sigaction;
487int do_sigaction(int sig, const struct target_sigaction *act,
488 struct target_sigaction *oact);
489
9850f9f6
LV
490#include "target_signal.h"
491
7f047de1
RH
492#ifdef TARGET_SA_RESTORER
493#define TARGET_ARCH_HAS_SA_RESTORER 1
494#endif
495
6049f4f8
RH
496#if defined(TARGET_ALPHA)
497struct target_old_sigaction {
498 abi_ulong _sa_handler;
499 abi_ulong sa_mask;
d2565875 500 int32_t sa_flags;
6049f4f8
RH
501};
502
503struct target_rt_sigaction {
504 abi_ulong _sa_handler;
505 abi_ulong sa_flags;
506 target_sigset_t sa_mask;
507};
106ec879 508
6049f4f8
RH
509/* This is the struct used inside the kernel. The ka_restorer
510 field comes from the 5th argument to sys_rt_sigaction. */
511struct target_sigaction {
512 abi_ulong _sa_handler;
513 abi_ulong sa_flags;
514 target_sigset_t sa_mask;
515 abi_ulong sa_restorer;
516};
517#elif defined(TARGET_MIPS)
106ec879 518struct target_sigaction {
540635ba 519 uint32_t sa_flags;
d26bc211 520#if defined(TARGET_ABI_MIPSN32)
540635ba
TS
521 uint32_t _sa_handler;
522#else
992f48a0 523 abi_ulong _sa_handler;
540635ba 524#endif
c227f099 525 target_sigset_t sa_mask;
7f047de1
RH
526#ifdef TARGET_ARCH_HAS_SA_RESTORER
527 /* ??? This is always present, but ignored unless O32. */
528 abi_ulong sa_restorer;
529#endif
106ec879 530};
106ec879 531#else
2521d698 532struct target_old_sigaction {
992f48a0
BS
533 abi_ulong _sa_handler;
534 abi_ulong sa_mask;
535 abi_ulong sa_flags;
7f047de1 536#ifdef TARGET_ARCH_HAS_SA_RESTORER
992f48a0 537 abi_ulong sa_restorer;
7f047de1 538#endif
2521d698
FB
539};
540
541struct target_sigaction {
992f48a0
BS
542 abi_ulong _sa_handler;
543 abi_ulong sa_flags;
7f047de1 544#ifdef TARGET_ARCH_HAS_SA_RESTORER
992f48a0 545 abi_ulong sa_restorer;
7f047de1 546#endif
c227f099 547 target_sigset_t sa_mask;
5de154e8
LV
548#ifdef TARGET_ARCH_HAS_KA_RESTORER
549 abi_ulong ka_restorer;
550#endif
2521d698 551};
106ec879 552#endif
2521d698
FB
553
554typedef union target_sigval {
555 int sival_int;
992f48a0 556 abi_ulong sival_ptr;
c227f099 557} target_sigval_t;
6d5e216d
FB
558#if 0
559#if defined (TARGET_SPARC)
560typedef struct {
561 struct {
992f48a0
BS
562 abi_ulong psr;
563 abi_ulong pc;
564 abi_ulong npc;
565 abi_ulong y;
566 abi_ulong u_regs[16]; /* globals and ins */
6d5e216d
FB
567 } si_regs;
568 int si_mask;
569} __siginfo_t;
570
571typedef struct {
572 unsigned long si_float_regs [32];
573 unsigned long si_fsr;
574 unsigned long si_fpqdepth;
575 struct {
576 unsigned long *insn_addr;
577 unsigned long insn;
578 } si_fpqueue [16];
579} __siginfo_fpu_t;
580#endif
581#endif
2521d698
FB
582
583#define TARGET_SI_MAX_SIZE 128
aa5e03d2
MO
584
585#if TARGET_ABI_BITS == 32
586#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
587#else
588#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
589#endif
590
591#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
2521d698 592
a70dadc7
PM
593/* Within QEMU the top 16 bits of si_code indicate which of the parts of
594 * the union in target_siginfo is valid. This only applies between
595 * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
596 * appear either within host siginfo_t or in target_siginfo structures
597 * which we get from the guest userspace program. (The Linux kernel
598 * does a similar thing with using the top bits for its own internal
599 * purposes but not letting them be visible to userspace.)
600 */
601#define QEMU_SI_KILL 0
602#define QEMU_SI_TIMER 1
603#define QEMU_SI_POLL 2
604#define QEMU_SI_FAULT 3
605#define QEMU_SI_CHLD 4
606#define QEMU_SI_RT 5
607
2521d698 608typedef struct target_siginfo {
3f53d546
PB
609#ifdef TARGET_MIPS
610 int si_signo;
611 int si_code;
612 int si_errno;
613#else
2521d698
FB
614 int si_signo;
615 int si_errno;
616 int si_code;
3f53d546 617#endif
2521d698
FB
618
619 union {
620 int _pad[TARGET_SI_PAD_SIZE];
621
622 /* kill() */
623 struct {
624 pid_t _pid; /* sender's pid */
625 uid_t _uid; /* sender's uid */
626 } _kill;
627
628 /* POSIX.1b timers */
629 struct {
630 unsigned int _timer1;
631 unsigned int _timer2;
632 } _timer;
633
634 /* POSIX.1b signals */
635 struct {
636 pid_t _pid; /* sender's pid */
637 uid_t _uid; /* sender's uid */
c227f099 638 target_sigval_t _sigval;
2521d698
FB
639 } _rt;
640
641 /* SIGCHLD */
642 struct {
643 pid_t _pid; /* which child */
644 uid_t _uid; /* sender's uid */
645 int _status; /* exit code */
c227f099
AL
646 target_clock_t _utime;
647 target_clock_t _stime;
2521d698
FB
648 } _sigchld;
649
650 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
651 struct {
992f48a0 652 abi_ulong _addr; /* faulting insn/memory ref. */
2521d698
FB
653 } _sigfault;
654
655 /* SIGPOLL */
656 struct {
657 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
658 int _fd;
659 } _sigpoll;
660 } _sifields;
c227f099 661} target_siginfo_t;
2521d698
FB
662
663/*
664 * si_code values
665 * Digital reserves positive values for kernel-generated signals.
666 */
667#define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
668#define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
669#define TARGET_SI_QUEUE -1 /* sent by sigqueue */
670#define TARGET_SI_TIMER -2 /* sent by timer expiration */
671#define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
672#define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
673#define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
674
675/*
676 * SIGILL si_codes
677 */
ffa65c3b 678#define TARGET_ILL_ILLOPC (1) /* illegal opcode */
2521d698 679#define TARGET_ILL_ILLOPN (2) /* illegal operand */
ffa65c3b
FB
680#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
681#define TARGET_ILL_ILLTRP (4) /* illegal trap */
682#define TARGET_ILL_PRVOPC (5) /* privileged opcode */
683#define TARGET_ILL_PRVREG (6) /* privileged register */
684#define TARGET_ILL_COPROC (7) /* coprocessor error */
685#define TARGET_ILL_BADSTK (8) /* internal stack error */
de2fdd56
CG
686#ifdef TARGET_TILEGX
687#define TARGET_ILL_DBLFLT (9) /* double fault */
688#define TARGET_ILL_HARDWALL (10) /* user networks hardwall violation */
689#endif
2521d698
FB
690
691/*
692 * SIGFPE si_codes
693 */
694#define TARGET_FPE_INTDIV (1) /* integer divide by zero */
695#define TARGET_FPE_INTOVF (2) /* integer overflow */
696#define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
697#define TARGET_FPE_FLTOVF (4) /* floating point overflow */
698#define TARGET_FPE_FLTUND (5) /* floating point underflow */
699#define TARGET_FPE_FLTRES (6) /* floating point inexact result */
700#define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
701#define TARGET_FPE_FLTSUB (8) /* subscript out of range */
21ba8564
RH
702#define TARGET_FPE_FLTUNK (14) /* undiagnosed fp exception */
703#define TARGET_NSIGFPE 15
2521d698
FB
704
705/*
706 * SIGSEGV si_codes
707 */
708#define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
709#define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
de2fdd56 710#define TARGET_SEGV_BNDERR (3) /* failed address bound checks */
2521d698 711
ffa65c3b
FB
712/*
713 * SIGBUS si_codes
714 */
715#define TARGET_BUS_ADRALN (1) /* invalid address alignment */
b4916d7b 716#define TARGET_BUS_ADRERR (2) /* non-existent physical address */
ffa65c3b 717#define TARGET_BUS_OBJERR (3) /* object specific hardware error */
de2fdd56
CG
718/* hardware memory error consumed on a machine check: action required */
719#define TARGET_BUS_MCEERR_AR (4)
720/* hardware memory error detected in process but not consumed: action optional*/
721#define TARGET_BUS_MCEERR_AO (5)
ffa65c3b 722
2521d698
FB
723/*
724 * SIGTRAP si_codes
725 */
726#define TARGET_TRAP_BRKPT (1) /* process breakpoint */
727#define TARGET_TRAP_TRACE (2) /* process trace trap */
de2fdd56
CG
728#define TARGET_TRAP_BRANCH (3) /* process taken branch trap */
729#define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint */
2521d698 730
9de5e440 731struct target_rlimit {
992f48a0
BS
732 abi_ulong rlim_cur;
733 abi_ulong rlim_max;
9de5e440
FB
734};
735
81bbe906 736#if defined(TARGET_ALPHA)
e476492e 737#define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
6cafd027 738#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
81bbe906
TY
739#define TARGET_RLIM_INFINITY 0x7fffffffUL
740#else
26b746db 741#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
81bbe906
TY
742#endif
743
e22b7015
WT
744#if defined(TARGET_MIPS)
745#define TARGET_RLIMIT_CPU 0
746#define TARGET_RLIMIT_FSIZE 1
747#define TARGET_RLIMIT_DATA 2
748#define TARGET_RLIMIT_STACK 3
749#define TARGET_RLIMIT_CORE 4
750#define TARGET_RLIMIT_RSS 7
751#define TARGET_RLIMIT_NPROC 8
752#define TARGET_RLIMIT_NOFILE 5
753#define TARGET_RLIMIT_MEMLOCK 9
754#define TARGET_RLIMIT_AS 6
755#define TARGET_RLIMIT_LOCKS 10
756#define TARGET_RLIMIT_SIGPENDING 11
757#define TARGET_RLIMIT_MSGQUEUE 12
758#define TARGET_RLIMIT_NICE 13
759#define TARGET_RLIMIT_RTPRIO 14
760#else
761#define TARGET_RLIMIT_CPU 0
762#define TARGET_RLIMIT_FSIZE 1
763#define TARGET_RLIMIT_DATA 2
764#define TARGET_RLIMIT_STACK 3
765#define TARGET_RLIMIT_CORE 4
766#define TARGET_RLIMIT_RSS 5
6cafd027
MB
767#if defined(TARGET_SPARC)
768#define TARGET_RLIMIT_NOFILE 6
769#define TARGET_RLIMIT_NPROC 7
770#else
e22b7015
WT
771#define TARGET_RLIMIT_NPROC 6
772#define TARGET_RLIMIT_NOFILE 7
6cafd027 773#endif
e22b7015
WT
774#define TARGET_RLIMIT_MEMLOCK 8
775#define TARGET_RLIMIT_AS 9
776#define TARGET_RLIMIT_LOCKS 10
777#define TARGET_RLIMIT_SIGPENDING 11
778#define TARGET_RLIMIT_MSGQUEUE 12
779#define TARGET_RLIMIT_NICE 13
780#define TARGET_RLIMIT_RTPRIO 14
781#endif
782
9de5e440
FB
783struct target_pollfd {
784 int fd; /* file descriptor */
785 short events; /* requested events */
786 short revents; /* returned events */
787};
788
8e5a0667 789/* virtual terminal ioctls */
0221cfcd
FB
790#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
791#define TARGET_KDMKTONE 0x4B30 /* generate tone */
8e5a0667 792#define TARGET_KDGKBTYPE 0x4b33
f7680a55
UH
793#define TARGET_KDSETMODE 0x4b3a
794#define TARGET_KDGKBMODE 0x4b44
795#define TARGET_KDSKBMODE 0x4b45
0221cfcd
FB
796#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
797#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
e6fe18fb
CV
798#define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
799#define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
800#define TARGET_KDGETLED 0x4B31 /* return current led state */
801#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
ca56f5b5 802#define TARGET_KDSIGACCEPT 0x4B4E
8e5a0667 803
373b067f
FB
804struct target_rtc_pll_info {
805 int pll_ctrl;
806 int pll_value;
807 int pll_max;
808 int pll_min;
809 int pll_posmult;
810 int pll_negmult;
811 abi_long pll_clock;
812};
813
68365f96
FB
814/* real time clock ioctls */
815#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01)
816#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02)
817#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03)
818#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04)
819#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05)
820#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06)
821#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f)
822#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10)
178b14a0
FB
823#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time)
824#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time)
825#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time)
826#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time)
fa857eb5
FB
827#define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong)
828#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong)
829#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong)
830#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
abc81bf6
FB
831#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm)
832#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
373b067f
FB
833#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \
834 struct target_rtc_pll_info)
835#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \
836 struct target_rtc_pll_info)
a7b09746
FB
837#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int)
838#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14)
68365f96 839
d14eabbe
AM
840#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
841 defined(TARGET_XTENSA)
4e4b173f
AM
842#define TARGET_FIOGETOWN TARGET_IOR('f', 123, int)
843#define TARGET_FIOSETOWN TARGET_IOW('f', 124, int)
e1be1606 844#define TARGET_SIOCATMARK TARGET_IOR('s', 7, int)
c495a793 845#define TARGET_SIOCSPGRP TARGET_IOW('s', 8, pid_t)
405b4915 846#define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)
e1be1606 847#else
4e4b173f
AM
848#define TARGET_FIOGETOWN 0x8903
849#define TARGET_FIOSETOWN 0x8901
2521d698 850#define TARGET_SIOCATMARK 0x8905
c495a793 851#define TARGET_SIOCSPGRP 0x8902
405b4915 852#define TARGET_SIOCGPGRP 0x8904
e1be1606 853#endif
c495a793 854
6d5d5dde
DB
855#if defined(TARGET_SH4)
856#define TARGET_SIOCGSTAMP_OLD TARGET_IOR('s', 100, struct target_timeval)
857#define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
858#else
859#define TARGET_SIOCGSTAMP_OLD 0x8906
860#define TARGET_SIOCGSTAMPNS_OLD 0x8907
861#endif
862
863#define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2])
864#define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
2521d698 865
31e31b8a
FB
866/* Networking ioctls */
867#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
868#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
869#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
870#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
871#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
872#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
873#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
874#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
875#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
876#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
877#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
878#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
879#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
880#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
881#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
882#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
883#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
884#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
885#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
886#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
887#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
888#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
889#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
890#define TARGET_SIOCSIFENCAP 0x8926
891#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
892#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
893#define TARGET_SIOCSIFSLAVE 0x8930
894#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
895#define TARGET_SIOCDELMULTI 0x8932
f63eb01a 896#define TARGET_SIOCGIFINDEX 0x8933
4bdcd79e
NC
897#define TARGET_SIOCSIFPFLAGS 0x8934 /* set extended flags */
898#define TARGET_SIOCGIFPFLAGS 0x8935 /* get extended flags */
31e31b8a
FB
899
900/* Bridging control calls */
901#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
902#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
903
904#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
905#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
906
907/* ARP cache control calls. */
908#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
909#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
910#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
911#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
912#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
913#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
914
915/* RARP cache control calls. */
916#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
917#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
918#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
919
920/* Driver configuration calls */
921#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
922#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
923
924/* DLCI configuration calls */
925#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
926#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
927
86fcd946
LV
928/* From <linux/wireless.h> */
929
930#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
31e31b8a 931
d6d6d6fe
MB
932/* From <linux/random.h> */
933
934#define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
935#define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
936#define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
937#define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
92c096f0 938#define TARGET_RNDRESEEDCRNG TARGET_IO('R', 0x07)
d6d6d6fe 939
31e31b8a
FB
940/* From <linux/fs.h> */
941
942#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
943#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
944#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
945#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
946#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
947#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
948#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
949#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
950#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
951#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
952#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
953#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
fff8c539 954#define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
31e31b8a 955/* A jump here: 108-111 have been used for various private purposes. */
c8b0bf54
PM
956#define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
957#define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
edafea13
AG
958#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
959 /* return device size in bytes
960 (u64 *arg) */
4715856a
PM
961
962#define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
963#define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
964#define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
965#define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
966#define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
967#define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
968#define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
969#define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
970#define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
971
ab22b4dd
YS
972/* From <linux/fd.h> */
973
7e35fc8b
AM
974#define TARGET_FDMSGON TARGET_IO(2, 0x45)
975#define TARGET_FDMSGOFF TARGET_IO(2, 0x46)
08e3ce59
AM
976#define TARGET_FDFMTBEG TARGET_IO(2, 0x47)
977#define TARGET_FDFMTTRK TARGET_IOW(2, 0x48, struct format_descr)
978#define TARGET_FDFMTEND TARGET_IO(2, 0x49)
81eb1a36 979#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
ab22b4dd 980#define TARGET_FDFLUSH TARGET_IO(2, 0x4b)
81eb1a36
AM
981#define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors)
982#define TARGET_FDGETMAXERRS TARGET_IOR(2, 0x0e, struct floppy_max_errors)
5eea9429
AM
983#define TARGET_FDRESET TARGET_IO(2, 0x54)
984#define TARGET_FDRAWCMD TARGET_IO(2, 0x58)
985#define TARGET_FDTWADDLE TARGET_IO(2, 0x59)
986#define TARGET_FDEJECT TARGET_IO(2, 0x5a)
ab22b4dd 987
31e31b8a
FB
988#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
989#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
21992cb6
HD
990
991#define TARGET_FICLONE TARGET_IOW(0x94, 9, int)
992#define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
993
5ae774a9
AM
994/*
995 * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
996 * claim type "long" but the actual type used by the kernel is "int".
60807231 997 */
1847b7ba
PM
998#define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
999#define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
5ae774a9
AM
1000#define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
1001#define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
285da2b9 1002#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
0b471ba6
AM
1003#define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
1004#define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
0d899cd6
AM
1005#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
1006#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
31e31b8a 1007
6c753a63
CT
1008/* usb ioctls */
1009#define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
1010#define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
1011#define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
1012#define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
1013#define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U', 5)
1014#define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
a133367e
CT
1015#define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
1016#define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
1017#define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
1018#define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
6c753a63
CT
1019#define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
1020#define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
1021#define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
1022#define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
1023#define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
1024#define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
1025#define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
1026#define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
1027#define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
1028#define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
1029#define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
1030#define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
1031#define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
1032#define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
1033#define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
1034#define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
1035
31e31b8a 1036/* cdrom commands */
5fafdf24 1037#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
31e31b8a
FB
1038#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
1039#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
5fafdf24 1040#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
31e31b8a 1041 (struct cdrom_ti) */
5fafdf24 1042#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
31e31b8a 1043 (struct cdrom_tochdr) */
5fafdf24 1044#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
31e31b8a
FB
1045 (struct cdrom_tocentry) */
1046#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
1047#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
1048#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
5fafdf24 1049#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
31e31b8a 1050 (struct cdrom_volctrl) */
5fafdf24 1051#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
31e31b8a 1052 (struct cdrom_subchnl) */
5fafdf24 1053#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
31e31b8a
FB
1054 (struct cdrom_read) */
1055#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
1056 (struct cdrom_read) */
1057#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
1058#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
5fafdf24
TS
1059#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
1060 address of multi session disks
31e31b8a 1061 (struct cdrom_multisession) */
5fafdf24 1062#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
31e31b8a 1063 if available (struct cdrom_mcn) */
67cc32eb 1064#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is deprecated,
b4916d7b 1065 but here anyway for compatibility */
31e31b8a 1066#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
5fafdf24 1067#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
31e31b8a
FB
1068 (struct cdrom_volctrl) */
1069#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
1070 (struct cdrom_read) */
5fafdf24 1071/*
31e31b8a
FB
1072 * These ioctls are used only used in aztcd.c and optcd.c
1073 */
1074#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
1075#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
3b46e624 1076
31e31b8a 1077/*
3b46e624 1078 * This ioctl is only used by the scsi-cd driver.
31e31b8a
FB
1079 It is for playing audio in logical block addressing mode.
1080 */
1081#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
1082
5fafdf24 1083/*
31e31b8a
FB
1084 * These ioctls are only used in optcd.c
1085 */
1086#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
1087
5fafdf24
TS
1088/*
1089 * These ioctls are (now) only in ide-cd.c for controlling
31e31b8a
FB
1090 * drive spindown time. They should be implemented in the
1091 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
1092 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
1093 * -Erik
1094 */
1095#define TARGET_CDROMGETSPINDOWN 0x531d
1096#define TARGET_CDROMSETSPINDOWN 0x531e
1097
5fafdf24 1098/*
31e31b8a
FB
1099 * These ioctls are implemented through the uniform CD-ROM driver
1100 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
1101 * drivers are eventually ported to the uniform CD-ROM driver interface.
1102 */
1103#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
1104#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
1105#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
1106#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
1107#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
1108#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
1109#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
1110#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
1111#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
1112#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
1113#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
1114#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
1115
1116/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
1117 * Future CDROM ioctls should be kept below 0x537F
1118 */
1119
1120/* This ioctl is only used by sbpcd at the moment */
1121#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
1122 /* conflict with SCSI_IOCTL_GET_IDLUN */
1123
1124/* DVD-ROM Specific ioctls */
1125#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
1126#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
1127#define TARGET_DVD_AUTH 0x5392 /* Authentication */
1128
1129#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
1130#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
1131#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
1132
1133/* HD commands */
1134
1135/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
1136#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
1137#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
1138#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
31e31b8a
FB
1139#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
1140#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
1141#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
1142#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
2521d698 1143#define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
31e31b8a
FB
1144#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
1145
1146/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
1147#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
1148#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
1149#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
1150#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
1151#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
1152#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
1153#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
2521d698 1154
b8005914
AZ
1155/* loop ioctls */
1156#define TARGET_LOOP_SET_FD 0x4C00
1157#define TARGET_LOOP_CLR_FD 0x4C01
1158#define TARGET_LOOP_SET_STATUS 0x4C02
1159#define TARGET_LOOP_GET_STATUS 0x4C03
1160#define TARGET_LOOP_SET_STATUS64 0x4C04
1161#define TARGET_LOOP_GET_STATUS64 0x4C05
1162#define TARGET_LOOP_CHANGE_FD 0x4C06
2521d698 1163
884cdc48
PM
1164#define TARGET_LOOP_CTL_ADD 0x4C80
1165#define TARGET_LOOP_CTL_REMOVE 0x4C81
1166#define TARGET_LOOP_CTL_GET_FREE 0x4C82
1167
f7680a55
UH
1168/* fb ioctls */
1169#define TARGET_FBIOGET_VSCREENINFO 0x4600
1170#define TARGET_FBIOPUT_VSCREENINFO 0x4601
1171#define TARGET_FBIOGET_FSCREENINFO 0x4602
12b81b71
CV
1172#define TARGET_FBIOGETCMAP 0x4604
1173#define TARGET_FBIOPUTCMAP 0x4605
1174#define TARGET_FBIOPAN_DISPLAY 0x4606
1175#define TARGET_FBIOGET_CON2FBMAP 0x460F
1176#define TARGET_FBIOPUT_CON2FBMAP 0x4610
f7680a55
UH
1177
1178/* vt ioctls */
1179#define TARGET_VT_OPENQRY 0x5600
1180#define TARGET_VT_GETSTATE 0x5603
1181#define TARGET_VT_ACTIVATE 0x5606
1182#define TARGET_VT_WAITACTIVE 0x5607
1183#define TARGET_VT_LOCKSWITCH 0x560b
1184#define TARGET_VT_UNLOCKSWITCH 0x560c
774750c0
CV
1185#define TARGET_VT_GETMODE 0x5601
1186#define TARGET_VT_SETMODE 0x5602
1187#define TARGET_VT_RELDISP 0x5605
1188#define TARGET_VT_DISALLOCATE 0x5608
f7680a55 1189
56e904ec
AG
1190/* device mapper */
1191#define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
1192#define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
1193#define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
1194#define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
1195#define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
1196#define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
1197#define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
1198#define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
1199#define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
1200#define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
1201#define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
1202#define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
1203#define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
1204#define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
1205#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
1206#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
1207
e865b97f
CG
1208/* drm ioctls */
1209#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00)
1210
913b03c2
CG
1211/* drm i915 ioctls */
1212#define TARGET_DRM_IOCTL_I915_GETPARAM TARGET_IOWRU('d', 0x46)
1213
2521d698
FB
1214/* from asm/termbits.h */
1215
3bfd9da1
FB
1216#define TARGET_NCC 8
1217struct target_termio {
1218 unsigned short c_iflag; /* input mode flags */
1219 unsigned short c_oflag; /* output mode flags */
1220 unsigned short c_cflag; /* control mode flags */
1221 unsigned short c_lflag; /* local mode flags */
1222 unsigned char c_line; /* line discipline */
1223 unsigned char c_cc[TARGET_NCC]; /* control characters */
1224};
2521d698 1225
3bfd9da1
FB
1226struct target_winsize {
1227 unsigned short ws_row;
1228 unsigned short ws_col;
1229 unsigned short ws_xpixel;
1230 unsigned short ws_ypixel;
2521d698
FB
1231};
1232
3bfd9da1 1233#include "termbits.h"
2521d698 1234
9e0b74a4
PB
1235#if defined(TARGET_MIPS)
1236#define TARGET_PROT_SEM 0x10
1237#else
1238#define TARGET_PROT_SEM 0x08
1239#endif
1240
e44a3e79 1241/* Common */
2521d698
FB
1242#define TARGET_MAP_SHARED 0x01 /* Share changes */
1243#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
e65be6a7
HD
1244#if defined(TARGET_HPPA)
1245#define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
1246#else
1247#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
1248#endif
e44a3e79
AJ
1249
1250/* Target specific */
048f6b4d 1251#if defined(TARGET_MIPS)
e44a3e79 1252#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
048f6b4d
FB
1253#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1254#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1255#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1256#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1257#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1258#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
540635ba
TS
1259#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1260#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
541e1690
HD
1261#define TARGET_MAP_STACK 0x40000 /* ignored */
1262#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
e44a3e79
AJ
1263#elif defined(TARGET_PPC)
1264#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
2521d698 1265#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
2521d698
FB
1266#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1267#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1268#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
7ec93196
JM
1269#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
1270#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
e44a3e79
AJ
1271#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1272#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
541e1690
HD
1273#define TARGET_MAP_STACK 0x20000 /* ignored */
1274#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
e44a3e79
AJ
1275#elif defined(TARGET_ALPHA)
1276#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1277#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
1278#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
1279#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
1280#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
1281#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
1282#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
1283#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
1284#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
541e1690
HD
1285#define TARGET_MAP_STACK 0x80000 /* ignored */
1286#define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
a10d1e50
RH
1287#elif defined(TARGET_HPPA)
1288#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1289#define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
1290#define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */
1291#define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */
1292#define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */
1293#define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */
1294#define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
1295#define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
1296#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
541e1690
HD
1297#define TARGET_MAP_STACK 0x40000 /* ignored */
1298#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
ba7651fb
MF
1299#elif defined(TARGET_XTENSA)
1300#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1301#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1302#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1303#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1304#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1305#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1306#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
1307#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1308#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
1309#define TARGET_MAP_STACK 0x40000
1310#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
7ec93196 1311#else
e44a3e79
AJ
1312#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1313#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
1314#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1315#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1316#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
2521d698
FB
1317#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
1318#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
540635ba
TS
1319#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1320#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
541e1690
HD
1321#define TARGET_MAP_STACK 0x20000 /* ignored */
1322#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
906c1b8e 1323#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
7ec93196 1324#endif
2521d698 1325
09701199
AG
1326#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
1327 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
daa4374a 1328 || defined(TARGET_CRIS)
5f992db6 1329#define TARGET_STAT_HAVE_NSEC
2521d698
FB
1330struct target_stat {
1331 unsigned short st_dev;
1332 unsigned short __pad1;
992f48a0 1333 abi_ulong st_ino;
2521d698
FB
1334 unsigned short st_mode;
1335 unsigned short st_nlink;
1336 unsigned short st_uid;
1337 unsigned short st_gid;
1338 unsigned short st_rdev;
1339 unsigned short __pad2;
992f48a0
BS
1340 abi_ulong st_size;
1341 abi_ulong st_blksize;
1342 abi_ulong st_blocks;
1343 abi_ulong target_st_atime;
5f992db6 1344 abi_ulong target_st_atime_nsec;
992f48a0 1345 abi_ulong target_st_mtime;
5f992db6 1346 abi_ulong target_st_mtime_nsec;
992f48a0 1347 abi_ulong target_st_ctime;
5f992db6 1348 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1349 abi_ulong __unused4;
1350 abi_ulong __unused5;
2521d698
FB
1351};
1352
1353/* This matches struct stat64 in glibc2.1, hence the absolutely
1354 * insane amounts of padding around dev_t's.
1355 */
20d155bc 1356#define TARGET_HAS_STRUCT_STAT64
2521d698
FB
1357struct target_stat64 {
1358 unsigned short st_dev;
1359 unsigned char __pad0[10];
1360
1361#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1362 abi_ulong __st_ino;
2521d698
FB
1363
1364 unsigned int st_mode;
1365 unsigned int st_nlink;
1366
992f48a0
BS
1367 abi_ulong st_uid;
1368 abi_ulong st_gid;
2521d698
FB
1369
1370 unsigned short st_rdev;
1371 unsigned char __pad3[10];
1372
1373 long long st_size;
992f48a0 1374 abi_ulong st_blksize;
2521d698 1375
992f48a0
BS
1376 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
1377 abi_ulong __pad4; /* future possible st_blocks high bits */
2521d698 1378
992f48a0 1379 abi_ulong target_st_atime;
5f992db6 1380 abi_ulong target_st_atime_nsec;
2521d698 1381
992f48a0 1382 abi_ulong target_st_mtime;
5f992db6 1383 abi_ulong target_st_mtime_nsec;
2521d698 1384
992f48a0 1385 abi_ulong target_st_ctime;
5f992db6 1386 abi_ulong target_st_ctime_nsec;
2521d698
FB
1387
1388 unsigned long long st_ino;
541dc0d4 1389} QEMU_PACKED;
2521d698 1390
ce4defa0 1391#ifdef TARGET_ARM
20d155bc 1392#define TARGET_HAS_STRUCT_STAT64
ce4defa0
PB
1393struct target_eabi_stat64 {
1394 unsigned long long st_dev;
1395 unsigned int __pad1;
992f48a0 1396 abi_ulong __st_ino;
ce4defa0
PB
1397 unsigned int st_mode;
1398 unsigned int st_nlink;
1399
992f48a0
BS
1400 abi_ulong st_uid;
1401 abi_ulong st_gid;
ce4defa0
PB
1402
1403 unsigned long long st_rdev;
1404 unsigned int __pad2[2];
1405
1406 long long st_size;
992f48a0 1407 abi_ulong st_blksize;
ce4defa0
PB
1408 unsigned int __pad3;
1409 unsigned long long st_blocks;
1410
992f48a0
BS
1411 abi_ulong target_st_atime;
1412 abi_ulong target_st_atime_nsec;
ce4defa0 1413
992f48a0
BS
1414 abi_ulong target_st_mtime;
1415 abi_ulong target_st_mtime_nsec;
ce4defa0 1416
992f48a0
BS
1417 abi_ulong target_st_ctime;
1418 abi_ulong target_st_ctime_nsec;
ce4defa0
PB
1419
1420 unsigned long long st_ino;
541dc0d4 1421} QEMU_PACKED;
ce4defa0
PB
1422#endif
1423
992f48a0 1424#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
1b8dd648
BS
1425struct target_stat {
1426 unsigned int st_dev;
992f48a0 1427 abi_ulong st_ino;
1b8dd648
BS
1428 unsigned int st_mode;
1429 unsigned int st_nlink;
1430 unsigned int st_uid;
1431 unsigned int st_gid;
1432 unsigned int st_rdev;
992f48a0
BS
1433 abi_long st_size;
1434 abi_long target_st_atime;
1435 abi_long target_st_mtime;
1436 abi_long target_st_ctime;
1437 abi_long st_blksize;
1438 abi_long st_blocks;
1439 abi_ulong __unused4[2];
1b8dd648
BS
1440};
1441
20d155bc 1442#define TARGET_HAS_STRUCT_STAT64
1b8dd648
BS
1443struct target_stat64 {
1444 unsigned char __pad0[6];
1445 unsigned short st_dev;
1446
1447 uint64_t st_ino;
1448 uint64_t st_nlink;
1449
1450 unsigned int st_mode;
1451
1452 unsigned int st_uid;
1453 unsigned int st_gid;
1454
1455 unsigned char __pad2[6];
1456 unsigned short st_rdev;
1457
1458 int64_t st_size;
1459 int64_t st_blksize;
1460
1461 unsigned char __pad4[4];
1462 unsigned int st_blocks;
1463
992f48a0 1464 abi_ulong target_st_atime;
5f992db6 1465 abi_ulong target_st_atime_nsec;
1b8dd648 1466
992f48a0 1467 abi_ulong target_st_mtime;
5f992db6 1468 abi_ulong target_st_mtime_nsec;
1b8dd648 1469
992f48a0 1470 abi_ulong target_st_ctime;
5f992db6 1471 abi_ulong target_st_ctime_nsec;
1b8dd648 1472
992f48a0 1473 abi_ulong __unused4[3];
1b8dd648
BS
1474};
1475
3bfd9da1
FB
1476#elif defined(TARGET_SPARC)
1477
5f992db6 1478#define TARGET_STAT_HAVE_NSEC
3bfd9da1
FB
1479struct target_stat {
1480 unsigned short st_dev;
992f48a0 1481 abi_ulong st_ino;
3bfd9da1
FB
1482 unsigned short st_mode;
1483 short st_nlink;
1484 unsigned short st_uid;
1485 unsigned short st_gid;
1486 unsigned short st_rdev;
992f48a0
BS
1487 abi_long st_size;
1488 abi_long target_st_atime;
5f992db6 1489 abi_ulong target_st_atime_nsec;
992f48a0 1490 abi_long target_st_mtime;
5f992db6 1491 abi_ulong target_st_mtime_nsec;
992f48a0 1492 abi_long target_st_ctime;
5f992db6 1493 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1494 abi_long st_blksize;
1495 abi_long st_blocks;
5f992db6 1496 abi_ulong __unused1[2];
3bfd9da1
FB
1497};
1498
20d155bc 1499#define TARGET_HAS_STRUCT_STAT64
3bfd9da1
FB
1500struct target_stat64 {
1501 unsigned char __pad0[6];
1502 unsigned short st_dev;
1503
1504 uint64_t st_ino;
1505
1506 unsigned int st_mode;
1507 unsigned int st_nlink;
1508
1509 unsigned int st_uid;
1510 unsigned int st_gid;
1511
1512 unsigned char __pad2[6];
1513 unsigned short st_rdev;
1514
1515 unsigned char __pad3[8];
1516
1517 int64_t st_size;
1518 unsigned int st_blksize;
1519
1520 unsigned char __pad4[8];
1521 unsigned int st_blocks;
1522
1523 unsigned int target_st_atime;
5f992db6 1524 unsigned int target_st_atime_nsec;
3bfd9da1
FB
1525
1526 unsigned int target_st_mtime;
5f992db6 1527 unsigned int target_st_mtime_nsec;
3bfd9da1
FB
1528
1529 unsigned int target_st_ctime;
5f992db6 1530 unsigned int target_st_ctime_nsec;
3bfd9da1 1531
5f992db6
CYT
1532 unsigned int __unused1;
1533 unsigned int __unused2;
3bfd9da1
FB
1534};
1535
67867308
FB
1536#elif defined(TARGET_PPC)
1537
5f992db6 1538#define TARGET_STAT_HAVE_NSEC
67867308 1539struct target_stat {
e32448e0 1540 abi_ulong st_dev;
992f48a0 1541 abi_ulong st_ino;
325e651f 1542#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
e32448e0 1543 abi_ulong st_nlink;
325e651f
JM
1544 unsigned int st_mode;
1545#else
67867308
FB
1546 unsigned int st_mode;
1547 unsigned short st_nlink;
325e651f 1548#endif
67867308
FB
1549 unsigned int st_uid;
1550 unsigned int st_gid;
e32448e0 1551 abi_ulong st_rdev;
992f48a0
BS
1552 abi_ulong st_size;
1553 abi_ulong st_blksize;
1554 abi_ulong st_blocks;
1555 abi_ulong target_st_atime;
e32448e0 1556 abi_ulong target_st_atime_nsec;
992f48a0 1557 abi_ulong target_st_mtime;
e32448e0 1558 abi_ulong target_st_mtime_nsec;
992f48a0 1559 abi_ulong target_st_ctime;
e32448e0 1560 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1561 abi_ulong __unused4;
1562 abi_ulong __unused5;
325e651f
JM
1563#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1564 abi_ulong __unused6;
1565#endif
67867308
FB
1566};
1567
20d155bc
SW
1568#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
1569#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1570struct QEMU_PACKED target_stat64 {
67867308 1571 unsigned long long st_dev;
67867308 1572 unsigned long long st_ino;
3bfd9da1
FB
1573 unsigned int st_mode;
1574 unsigned int st_nlink;
67867308
FB
1575 unsigned int st_uid;
1576 unsigned int st_gid;
3bfd9da1 1577 unsigned long long st_rdev;
e1ce5e40 1578 unsigned long long __pad0;
e32448e0
JM
1579 long long st_size;
1580 int st_blksize;
e1ce5e40 1581 unsigned int __pad1;
61322e91 1582 long long st_blocks; /* Number 512-byte blocks allocated. */
e32448e0
JM
1583 int target_st_atime;
1584 unsigned int target_st_atime_nsec;
1585 int target_st_mtime;
1586 unsigned int target_st_mtime_nsec;
1587 int target_st_ctime;
1588 unsigned int target_st_ctime_nsec;
1589 unsigned int __unused4;
1590 unsigned int __unused5;
67867308 1591};
20d155bc 1592#endif
67867308 1593
b779e29e
EI
1594#elif defined(TARGET_MICROBLAZE)
1595
5f992db6 1596#define TARGET_STAT_HAVE_NSEC
b779e29e
EI
1597struct target_stat {
1598 abi_ulong st_dev;
1599 abi_ulong st_ino;
1600 unsigned int st_mode;
1601 unsigned short st_nlink;
1602 unsigned int st_uid;
1603 unsigned int st_gid;
1604 abi_ulong st_rdev;
1605 abi_ulong st_size;
1606 abi_ulong st_blksize;
1607 abi_ulong st_blocks;
1608 abi_ulong target_st_atime;
1609 abi_ulong target_st_atime_nsec;
1610 abi_ulong target_st_mtime;
1611 abi_ulong target_st_mtime_nsec;
1612 abi_ulong target_st_ctime;
1613 abi_ulong target_st_ctime_nsec;
1614 abi_ulong __unused4;
1615 abi_ulong __unused5;
1616};
1617
1618/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
20d155bc 1619#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1620struct QEMU_PACKED target_stat64 {
b779e29e 1621 uint64_t st_dev;
a523eb06
EI
1622#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1623 uint32_t pad0;
1624 uint32_t __st_ino;
1625
b779e29e
EI
1626 uint32_t st_mode;
1627 uint32_t st_nlink;
1628 uint32_t st_uid;
1629 uint32_t st_gid;
1630 uint64_t st_rdev;
21ebeb23 1631 uint64_t __pad1;
b779e29e
EI
1632
1633 int64_t st_size;
21ebeb23
EI
1634 int32_t st_blksize;
1635 uint32_t __pad2;
b779e29e
EI
1636 int64_t st_blocks; /* Number 512-byte blocks allocated. */
1637
1638 int target_st_atime;
a523eb06 1639 unsigned int target_st_atime_nsec;
b779e29e 1640 int target_st_mtime;
a523eb06 1641 unsigned int target_st_mtime_nsec;
b779e29e 1642 int target_st_ctime;
a523eb06
EI
1643 unsigned int target_st_ctime_nsec;
1644 uint64_t st_ino;
b779e29e
EI
1645};
1646
e6e5906b
PB
1647#elif defined(TARGET_M68K)
1648
1649struct target_stat {
1650 unsigned short st_dev;
1651 unsigned short __pad1;
992f48a0 1652 abi_ulong st_ino;
e6e5906b
PB
1653 unsigned short st_mode;
1654 unsigned short st_nlink;
1655 unsigned short st_uid;
1656 unsigned short st_gid;
1657 unsigned short st_rdev;
1658 unsigned short __pad2;
992f48a0
BS
1659 abi_ulong st_size;
1660 abi_ulong st_blksize;
1661 abi_ulong st_blocks;
1662 abi_ulong target_st_atime;
1663 abi_ulong __unused1;
1664 abi_ulong target_st_mtime;
1665 abi_ulong __unused2;
1666 abi_ulong target_st_ctime;
1667 abi_ulong __unused3;
1668 abi_ulong __unused4;
1669 abi_ulong __unused5;
e6e5906b
PB
1670};
1671
1672/* This matches struct stat64 in glibc2.1, hence the absolutely
1673 * insane amounts of padding around dev_t's.
1674 */
20d155bc 1675#define TARGET_HAS_STRUCT_STAT64
e6e5906b
PB
1676struct target_stat64 {
1677 unsigned long long st_dev;
1678 unsigned char __pad1[2];
1679
1680#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1681 abi_ulong __st_ino;
e6e5906b
PB
1682
1683 unsigned int st_mode;
1684 unsigned int st_nlink;
1685
992f48a0
BS
1686 abi_ulong st_uid;
1687 abi_ulong st_gid;
e6e5906b
PB
1688
1689 unsigned long long st_rdev;
1690 unsigned char __pad3[2];
1691
1692 long long st_size;
992f48a0 1693 abi_ulong st_blksize;
e6e5906b 1694
992f48a0
BS
1695 abi_ulong __pad4; /* future possible st_blocks high bits */
1696 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
e6e5906b 1697
992f48a0
BS
1698 abi_ulong target_st_atime;
1699 abi_ulong target_st_atime_nsec;
e6e5906b 1700
992f48a0
BS
1701 abi_ulong target_st_mtime;
1702 abi_ulong target_st_mtime_nsec;
e6e5906b 1703
992f48a0
BS
1704 abi_ulong target_st_ctime;
1705 abi_ulong target_st_ctime_nsec;
e6e5906b
PB
1706
1707 unsigned long long st_ino;
541dc0d4 1708} QEMU_PACKED;
e6e5906b 1709
d26bc211 1710#elif defined(TARGET_ABI_MIPSN64)
540635ba 1711
5f992db6 1712#define TARGET_STAT_HAVE_NSEC
540635ba
TS
1713/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
1714struct target_stat {
1715 unsigned int st_dev;
1716 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1717
992f48a0 1718 abi_ulong st_ino;
540635ba
TS
1719
1720 unsigned int st_mode;
1721 unsigned int st_nlink;
1722
1723 int st_uid;
1724 int st_gid;
1725
1726 unsigned int st_rdev;
1727 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1728
992f48a0 1729 abi_ulong st_size;
540635ba
TS
1730
1731 /*
1732 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1733 * but we don't have it under Linux.
1734 */
1735 unsigned int target_st_atime;
1736 unsigned int target_st_atime_nsec;
1737
1738 unsigned int target_st_mtime;
1739 unsigned int target_st_mtime_nsec;
1740
1741 unsigned int target_st_ctime;
1742 unsigned int target_st_ctime_nsec;
1743
1744 unsigned int st_blksize;
1745 unsigned int st_pad2;
1746
992f48a0 1747 abi_ulong st_blocks;
540635ba
TS
1748};
1749
d26bc211 1750#elif defined(TARGET_ABI_MIPSN32)
540635ba 1751
5f992db6 1752#define TARGET_STAT_HAVE_NSEC
540635ba 1753struct target_stat {
1ab2aea2
LA
1754 abi_ulong st_dev;
1755 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
1756 uint64_t st_ino;
1757 unsigned int st_mode;
1758 unsigned int st_nlink;
1759 int st_uid;
1760 int st_gid;
1761 abi_ulong st_rdev;
1762 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
1763 int64_t st_size;
1764 abi_long target_st_atime;
1765 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
1766 abi_long target_st_mtime;
1767 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
1768 abi_long target_st_ctime;
1769 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
1770 abi_ulong st_blksize;
1771 abi_ulong st_pad2;
1772 int64_t st_blocks;
540635ba
TS
1773};
1774
d26bc211 1775#elif defined(TARGET_ABI_MIPSO32)
048f6b4d 1776
5f992db6 1777#define TARGET_STAT_HAVE_NSEC
048f6b4d
FB
1778struct target_stat {
1779 unsigned st_dev;
992f48a0
BS
1780 abi_long st_pad1[3]; /* Reserved for network id */
1781 abi_ulong st_ino;
048f6b4d
FB
1782 unsigned int st_mode;
1783 unsigned int st_nlink;
1784 int st_uid;
1785 int st_gid;
1786 unsigned st_rdev;
992f48a0
BS
1787 abi_long st_pad2[2];
1788 abi_long st_size;
1789 abi_long st_pad3;
048f6b4d
FB
1790 /*
1791 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1792 * but we don't have it under Linux.
1793 */
992f48a0
BS
1794 abi_long target_st_atime;
1795 abi_long target_st_atime_nsec;
1796 abi_long target_st_mtime;
1797 abi_long target_st_mtime_nsec;
1798 abi_long target_st_ctime;
1799 abi_long target_st_ctime_nsec;
1800 abi_long st_blksize;
1801 abi_long st_blocks;
1802 abi_long st_pad4[14];
048f6b4d
FB
1803};
1804
1805/*
1806 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1807 * amounts of padding around dev_t's. The memory layout is the same as of
1808 * struct stat of the 64-bit kernel.
1809 */
1810
20d155bc 1811#define TARGET_HAS_STRUCT_STAT64
048f6b4d 1812struct target_stat64 {
992f48a0
BS
1813 abi_ulong st_dev;
1814 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
048f6b4d
FB
1815
1816 uint64_t st_ino;
1817
1818 unsigned int st_mode;
1819 unsigned int st_nlink;
1820
1821 int st_uid;
1822 int st_gid;
1823
992f48a0
BS
1824 abi_ulong st_rdev;
1825 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
048f6b4d
FB
1826
1827 int64_t st_size;
1828
1829 /*
1830 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1831 * but we don't have it under Linux.
1832 */
992f48a0
BS
1833 abi_long target_st_atime;
1834 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
048f6b4d 1835
992f48a0
BS
1836 abi_long target_st_mtime;
1837 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
048f6b4d 1838
992f48a0
BS
1839 abi_long target_st_ctime;
1840 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
048f6b4d 1841
992f48a0
BS
1842 abi_ulong st_blksize;
1843 abi_ulong st_pad2;
048f6b4d
FB
1844
1845 int64_t st_blocks;
1846};
7a3148a9
JM
1847
1848#elif defined(TARGET_ALPHA)
1849
1850struct target_stat {
1851 unsigned int st_dev;
1852 unsigned int st_ino;
1853 unsigned int st_mode;
1854 unsigned int st_nlink;
1855 unsigned int st_uid;
1856 unsigned int st_gid;
1857 unsigned int st_rdev;
992f48a0
BS
1858 abi_long st_size;
1859 abi_ulong target_st_atime;
1860 abi_ulong target_st_mtime;
1861 abi_ulong target_st_ctime;
7a3148a9
JM
1862 unsigned int st_blksize;
1863 unsigned int st_blocks;
1864 unsigned int st_flags;
1865 unsigned int st_gen;
1866};
1867
20d155bc 1868#define TARGET_HAS_STRUCT_STAT64
7a3148a9 1869struct target_stat64 {
992f48a0
BS
1870 abi_ulong st_dev;
1871 abi_ulong st_ino;
1872 abi_ulong st_rdev;
1873 abi_long st_size;
1874 abi_ulong st_blocks;
7a3148a9
JM
1875
1876 unsigned int st_mode;
1877 unsigned int st_uid;
1878 unsigned int st_gid;
1879 unsigned int st_blksize;
1880 unsigned int st_nlink;
1881 unsigned int __pad0;
1882
992f48a0
BS
1883 abi_ulong target_st_atime;
1884 abi_ulong target_st_atime_nsec;
1885 abi_ulong target_st_mtime;
1886 abi_ulong target_st_mtime_nsec;
1887 abi_ulong target_st_ctime;
1888 abi_ulong target_st_ctime_nsec;
1889 abi_long __unused[3];
7a3148a9
JM
1890};
1891
6db45e65
TS
1892#elif defined(TARGET_SH4)
1893
5f992db6 1894#define TARGET_STAT_HAVE_NSEC
6db45e65 1895struct target_stat {
992f48a0
BS
1896 abi_ulong st_dev;
1897 abi_ulong st_ino;
6db45e65
TS
1898 unsigned short st_mode;
1899 unsigned short st_nlink;
1900 unsigned short st_uid;
1901 unsigned short st_gid;
992f48a0
BS
1902 abi_ulong st_rdev;
1903 abi_ulong st_size;
1904 abi_ulong st_blksize;
1905 abi_ulong st_blocks;
1906 abi_ulong target_st_atime;
1907 abi_ulong target_st_atime_nsec;
1908 abi_ulong target_st_mtime;
1909 abi_ulong target_st_mtime_nsec;
1910 abi_ulong target_st_ctime;
1911 abi_ulong target_st_ctime_nsec;
1912 abi_ulong __unused4;
1913 abi_ulong __unused5;
6db45e65
TS
1914};
1915
1916/* This matches struct stat64 in glibc2.1, hence the absolutely
1917 * insane amounts of padding around dev_t's.
1918 */
20d155bc 1919#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1920struct QEMU_PACKED target_stat64 {
6db45e65
TS
1921 unsigned long long st_dev;
1922 unsigned char __pad0[4];
1923
1924#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1925 abi_ulong __st_ino;
6db45e65
TS
1926
1927 unsigned int st_mode;
1928 unsigned int st_nlink;
1929
992f48a0
BS
1930 abi_ulong st_uid;
1931 abi_ulong st_gid;
6db45e65
TS
1932
1933 unsigned long long st_rdev;
1934 unsigned char __pad3[4];
1935
1936 long long st_size;
992f48a0 1937 abi_ulong st_blksize;
6db45e65
TS
1938
1939 unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
1940
992f48a0
BS
1941 abi_ulong target_st_atime;
1942 abi_ulong target_st_atime_nsec;
6db45e65 1943
992f48a0
BS
1944 abi_ulong target_st_mtime;
1945 abi_ulong target_st_mtime_nsec;
6db45e65 1946
992f48a0
BS
1947 abi_ulong target_st_ctime;
1948 abi_ulong target_st_ctime_nsec;
6db45e65
TS
1949
1950 unsigned long long st_ino;
1951};
1952
d2fd1af7 1953#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
5f992db6 1954#define TARGET_STAT_HAVE_NSEC
d2fd1af7
FB
1955struct target_stat {
1956 abi_ulong st_dev;
1957 abi_ulong st_ino;
1958 abi_ulong st_nlink;
1959
1960 unsigned int st_mode;
1961 unsigned int st_uid;
1962 unsigned int st_gid;
1963 unsigned int __pad0;
1964 abi_ulong st_rdev;
1965 abi_long st_size;
1966 abi_long st_blksize;
72e21db7 1967 abi_long st_blocks; /* Number 512-byte blocks allocated. */
d2fd1af7
FB
1968
1969 abi_ulong target_st_atime;
1970 abi_ulong target_st_atime_nsec;
1971 abi_ulong target_st_mtime;
1972 abi_ulong target_st_mtime_nsec;
1973 abi_ulong target_st_ctime;
1974 abi_ulong target_st_ctime_nsec;
1975
72e21db7 1976 abi_long __unused[3];
d2fd1af7 1977};
a4c075f1
UH
1978#elif defined(TARGET_S390X)
1979struct target_stat {
1980 abi_ulong st_dev;
1981 abi_ulong st_ino;
1982 abi_ulong st_nlink;
1983 unsigned int st_mode;
1984 unsigned int st_uid;
1985 unsigned int st_gid;
1986 unsigned int __pad1;
1987 abi_ulong st_rdev;
1988 abi_ulong st_size;
1989 abi_ulong target_st_atime;
1990 abi_ulong target_st_atime_nsec;
1991 abi_ulong target_st_mtime;
1992 abi_ulong target_st_mtime_nsec;
1993 abi_ulong target_st_ctime;
1994 abi_ulong target_st_ctime_nsec;
1995 abi_ulong st_blksize;
1996 abi_long st_blocks;
1997 abi_ulong __unused[3];
1998};
09701199 1999#elif defined(TARGET_AARCH64)
5f992db6 2000#define TARGET_STAT_HAVE_NSEC
09701199
AG
2001struct target_stat {
2002 abi_ulong st_dev;
2003 abi_ulong st_ino;
2004 unsigned int st_mode;
2005 unsigned int st_nlink;
2006 unsigned int st_uid;
2007 unsigned int st_gid;
2008 abi_ulong st_rdev;
2009 abi_ulong _pad1;
2010 abi_long st_size;
2011 int st_blksize;
2012 int __pad2;
2013 abi_long st_blocks;
2014 abi_long target_st_atime;
2015 abi_ulong target_st_atime_nsec;
2016 abi_long target_st_mtime;
2017 abi_ulong target_st_mtime_nsec;
2018 abi_long target_st_ctime;
2019 abi_ulong target_st_ctime_nsec;
2020 unsigned int __unused[2];
2021};
ba7651fb 2022#elif defined(TARGET_XTENSA)
5f992db6 2023#define TARGET_STAT_HAVE_NSEC
ba7651fb
MF
2024struct target_stat {
2025 abi_ulong st_dev;
2026 abi_ulong st_ino;
2027 unsigned int st_mode;
2028 unsigned int st_nlink;
2029 unsigned int st_uid;
2030 unsigned int st_gid;
2031 abi_ulong st_rdev;
2032 abi_long st_size;
2033 abi_ulong st_blksize;
2034 abi_ulong st_blocks;
2035 abi_ulong target_st_atime;
2036 abi_ulong target_st_atime_nsec;
2037 abi_ulong target_st_mtime;
2038 abi_ulong target_st_mtime_nsec;
2039 abi_ulong target_st_ctime;
2040 abi_ulong target_st_ctime_nsec;
2041 abi_ulong __unused4;
2042 abi_ulong __unused5;
2043};
2044
2045#define TARGET_HAS_STRUCT_STAT64
2046struct target_stat64 {
2047 uint64_t st_dev; /* Device */
2048 uint64_t st_ino; /* File serial number */
2049 unsigned int st_mode; /* File mode. */
2050 unsigned int st_nlink; /* Link count. */
2051 unsigned int st_uid; /* User ID of the file's owner. */
2052 unsigned int st_gid; /* Group ID of the file's group. */
2053 uint64_t st_rdev; /* Device number, if device. */
2054 int64_t st_size; /* Size of file, in bytes. */
2055 abi_ulong st_blksize; /* Optimal block size for I/O. */
2056 abi_ulong __unused2;
2057 uint64_t st_blocks; /* Number 512-byte blocks allocated. */
2058 abi_ulong target_st_atime; /* Time of last access. */
2059 abi_ulong target_st_atime_nsec;
2060 abi_ulong target_st_mtime; /* Time of last modification. */
2061 abi_ulong target_st_mtime_nsec;
2062 abi_ulong target_st_ctime; /* Time of last status change. */
2063 abi_ulong target_st_ctime_nsec;
2064 abi_ulong __unused4;
2065 abi_ulong __unused5;
2066};
2067
a0a839b6 2068#elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
47ae93cd 2069 defined(TARGET_NIOS2) || defined(TARGET_RISCV)
c7819dfb
PM
2070
2071/* These are the asm-generic versions of the stat and stat64 structures */
2072
5f992db6 2073#define TARGET_STAT_HAVE_NSEC
d962783e
JL
2074struct target_stat {
2075 abi_ulong st_dev;
2076 abi_ulong st_ino;
d962783e 2077 unsigned int st_mode;
c7819dfb 2078 unsigned int st_nlink;
d962783e
JL
2079 unsigned int st_uid;
2080 unsigned int st_gid;
d962783e 2081 abi_ulong st_rdev;
c7819dfb 2082 abi_ulong __pad1;
d962783e 2083 abi_long st_size;
c7819dfb
PM
2084 int st_blksize;
2085 int __pad2;
2086 abi_long st_blocks;
2087 abi_long target_st_atime;
d962783e 2088 abi_ulong target_st_atime_nsec;
c7819dfb 2089 abi_long target_st_mtime;
d962783e 2090 abi_ulong target_st_mtime_nsec;
c7819dfb 2091 abi_long target_st_ctime;
d962783e 2092 abi_ulong target_st_ctime_nsec;
c7819dfb
PM
2093 unsigned int __unused4;
2094 unsigned int __unused5;
2095};
d962783e 2096
47ae93cd 2097#if !defined(TARGET_RISCV64)
20d155bc 2098#define TARGET_HAS_STRUCT_STAT64
c7819dfb
PM
2099struct target_stat64 {
2100 uint64_t st_dev;
2101 uint64_t st_ino;
2102 unsigned int st_mode;
2103 unsigned int st_nlink;
2104 unsigned int st_uid;
2105 unsigned int st_gid;
2106 uint64_t st_rdev;
2107 uint64_t __pad1;
2108 int64_t st_size;
2109 int st_blksize;
2110 int __pad2;
2111 int64_t st_blocks;
2112 int target_st_atime;
2113 unsigned int target_st_atime_nsec;
2114 int target_st_mtime;
2115 unsigned int target_st_mtime_nsec;
2116 int target_st_ctime;
2117 unsigned int target_st_ctime_nsec;
2118 unsigned int __unused4;
2119 unsigned int __unused5;
d962783e 2120};
47ae93cd 2121#endif
c7819dfb 2122
a10d1e50
RH
2123#elif defined(TARGET_HPPA)
2124
5f992db6 2125#define TARGET_STAT_HAVE_NSEC
a10d1e50
RH
2126struct target_stat {
2127 abi_uint st_dev;
2128 abi_uint st_ino;
2129 abi_ushort st_mode;
2130 abi_ushort st_nlink;
2131 abi_ushort _res1;
2132 abi_ushort _res2;
2133 abi_uint st_rdev;
2134 abi_int st_size;
2135 abi_int target_st_atime;
2136 abi_uint target_st_atime_nsec;
2137 abi_int target_st_mtime;
2138 abi_uint target_st_mtime_nsec;
2139 abi_int target_st_ctime;
2140 abi_uint target_st_ctime_nsec;
2141 abi_int st_blksize;
2142 abi_int st_blocks;
2143 abi_uint _unused1;
2144 abi_uint _unused2;
2145 abi_uint _unused3;
2146 abi_uint _unused4;
2147 abi_ushort _unused5;
2148 abi_short st_fstype;
2149 abi_uint st_realdev;
2150 abi_ushort st_basemode;
2151 abi_ushort _unused6;
2152 abi_uint st_uid;
2153 abi_uint st_gid;
2154 abi_uint _unused7[3];
2155};
2156
2157#define TARGET_HAS_STRUCT_STAT64
2158struct target_stat64 {
2159 uint64_t st_dev;
2160 abi_uint _pad1;
2161 abi_uint _res1;
2162 abi_uint st_mode;
2163 abi_uint st_nlink;
2164 abi_uint st_uid;
2165 abi_uint st_gid;
2166 uint64_t st_rdev;
2167 abi_uint _pad2;
2168 int64_t st_size;
2169 abi_int st_blksize;
2170 int64_t st_blocks;
2171 abi_int target_st_atime;
2172 abi_uint target_st_atime_nsec;
2173 abi_int target_st_mtime;
2174 abi_uint target_st_mtime_nsec;
2175 abi_int target_st_ctime;
2176 abi_uint target_st_ctime_nsec;
2177 uint64_t st_ino;
2178};
2179
048f6b4d
FB
2180#else
2181#error unsupported CPU
2182#endif
2521d698 2183
4ce6f8de
TS
2184typedef struct {
2185 int val[2];
c227f099 2186} target_fsid_t;
4ce6f8de 2187
56c8f68f 2188#ifdef TARGET_MIPS
d26bc211 2189#ifdef TARGET_ABI_MIPSN32
540635ba
TS
2190struct target_statfs {
2191 int32_t f_type;
2192 int32_t f_bsize;
2193 int32_t f_frsize; /* Fragment size - unsupported */
2194 int32_t f_blocks;
2195 int32_t f_bfree;
2196 int32_t f_files;
2197 int32_t f_ffree;
2198 int32_t f_bavail;
2199
2200 /* Linux specials */
c227f099 2201 target_fsid_t f_fsid;
540635ba 2202 int32_t f_namelen;
d4247ec2
SL
2203 int32_t f_flags;
2204 int32_t f_spare[5];
540635ba
TS
2205};
2206#else
56c8f68f 2207struct target_statfs {
992f48a0
BS
2208 abi_long f_type;
2209 abi_long f_bsize;
2210 abi_long f_frsize; /* Fragment size - unsupported */
2211 abi_long f_blocks;
2212 abi_long f_bfree;
2213 abi_long f_files;
2214 abi_long f_ffree;
2215 abi_long f_bavail;
56c8f68f
FB
2216
2217 /* Linux specials */
c227f099 2218 target_fsid_t f_fsid;
992f48a0 2219 abi_long f_namelen;
d4247ec2
SL
2220 abi_long f_flags;
2221 abi_long f_spare[5];
56c8f68f 2222};
540635ba 2223#endif
56c8f68f
FB
2224
2225struct target_statfs64 {
2226 uint32_t f_type;
2227 uint32_t f_bsize;
2228 uint32_t f_frsize; /* Fragment size - unsupported */
2229 uint32_t __pad;
2230 uint64_t f_blocks;
2231 uint64_t f_bfree;
2232 uint64_t f_files;
2233 uint64_t f_ffree;
2234 uint64_t f_bavail;
c227f099 2235 target_fsid_t f_fsid;
56c8f68f 2236 uint32_t f_namelen;
d4247ec2
SL
2237 uint32_t f_flags;
2238 uint32_t f_spare[5];
56c8f68f 2239};
c4d10628 2240#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
47ae93cd
MC
2241 defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
2242 defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
325e651f
JM
2243struct target_statfs {
2244 abi_long f_type;
2245 abi_long f_bsize;
2246 abi_long f_blocks;
2247 abi_long f_bfree;
2248 abi_long f_bavail;
2249 abi_long f_files;
2250 abi_long f_ffree;
c227f099 2251 target_fsid_t f_fsid;
325e651f
JM
2252 abi_long f_namelen;
2253 abi_long f_frsize;
d4247ec2
SL
2254 abi_long f_flags;
2255 abi_long f_spare[4];
325e651f
JM
2256};
2257
2258struct target_statfs64 {
2259 abi_long f_type;
2260 abi_long f_bsize;
2261 abi_long f_blocks;
2262 abi_long f_bfree;
2263 abi_long f_bavail;
2264 abi_long f_files;
2265 abi_long f_ffree;
c227f099 2266 target_fsid_t f_fsid;
325e651f
JM
2267 abi_long f_namelen;
2268 abi_long f_frsize;
d4247ec2
SL
2269 abi_long f_flags;
2270 abi_long f_spare[4];
325e651f 2271};
a4c075f1
UH
2272#elif defined(TARGET_S390X)
2273struct target_statfs {
2274 int32_t f_type;
2275 int32_t f_bsize;
2276 abi_long f_blocks;
2277 abi_long f_bfree;
2278 abi_long f_bavail;
2279 abi_long f_files;
2280 abi_long f_ffree;
2281 kernel_fsid_t f_fsid;
2282 int32_t f_namelen;
2283 int32_t f_frsize;
d4247ec2
SL
2284 int32_t f_flags;
2285 int32_t f_spare[4];
2286
a4c075f1
UH
2287};
2288
2289struct target_statfs64 {
2290 int32_t f_type;
2291 int32_t f_bsize;
2292 abi_long f_blocks;
2293 abi_long f_bfree;
2294 abi_long f_bavail;
2295 abi_long f_files;
2296 abi_long f_ffree;
2297 kernel_fsid_t f_fsid;
2298 int32_t f_namelen;
2299 int32_t f_frsize;
d4247ec2
SL
2300 int32_t f_flags;
2301 int32_t f_spare[4];
a4c075f1 2302};
56c8f68f
FB
2303#else
2304struct target_statfs {
2305 uint32_t f_type;
2306 uint32_t f_bsize;
2307 uint32_t f_blocks;
2308 uint32_t f_bfree;
2309 uint32_t f_bavail;
2310 uint32_t f_files;
2311 uint32_t f_ffree;
c227f099 2312 target_fsid_t f_fsid;
56c8f68f
FB
2313 uint32_t f_namelen;
2314 uint32_t f_frsize;
d4247ec2
SL
2315 uint32_t f_flags;
2316 uint32_t f_spare[4];
56c8f68f
FB
2317};
2318
2319struct target_statfs64 {
2320 uint32_t f_type;
2321 uint32_t f_bsize;
2322 uint64_t f_blocks;
2323 uint64_t f_bfree;
2324 uint64_t f_bavail;
2325 uint64_t f_files;
2326 uint64_t f_ffree;
c227f099 2327 target_fsid_t f_fsid;
56c8f68f
FB
2328 uint32_t f_namelen;
2329 uint32_t f_frsize;
d4247ec2
SL
2330 uint32_t f_flags;
2331 uint32_t f_spare[4];
56c8f68f
FB
2332};
2333#endif
2334
7e22e546
UH
2335#define TARGET_F_LINUX_SPECIFIC_BASE 1024
2336#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
2337#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
2338#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
7e3b92ec
PM
2339#define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
2340#define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
7e22e546
UH
2341#define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
2342
5de7706e 2343#include "target_fcntl.h"
8d5d3004 2344
2521d698 2345/* soundcard defines */
67cc32eb 2346/* XXX: convert them all to arch independent entries */
2521d698
FB
2347#define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
2348#define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
2349#define TARGET_SNDCTL_COPR_RCODE 0xc0144303
2350#define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
2351#define TARGET_SNDCTL_COPR_RDATA 0xc0144302
2352#define TARGET_SNDCTL_COPR_RESET 0x00004300
2353#define TARGET_SNDCTL_COPR_RUN 0xc0144306
2354#define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
2355#define TARGET_SNDCTL_COPR_WCODE 0x40144305
2356#define TARGET_SNDCTL_COPR_WDATA 0x40144304
2357#define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
2358#define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
2359#define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
2360#define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
2361#define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
2362#define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
2363#define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
2364#define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
2365#define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
2366#define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
2367#define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
2368#define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
2369#define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
2370#define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
2371#define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
2372#define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
2373#define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
2374#define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
5f72307d
PM
2375#define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
2376#define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
2521d698
FB
2377#define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
2378#define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
2379#define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
2380#define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
2381#define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
2382#define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
2383#define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
2384#define TARGET_SNDCTL_MIDI_INFO 0xc074510c
2385#define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
2386#define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
2387#define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
2388#define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
2389#define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
2390#define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
2391#define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
2392#define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
2393#define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
2394#define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
2395#define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
2396#define TARGET_SNDCTL_SEQ_PANIC 0x00005111
2397#define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
2398#define TARGET_SNDCTL_SEQ_RESET 0x00005100
2399#define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
2400#define TARGET_SNDCTL_SEQ_SYNC 0x00005101
2401#define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
2402#define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
2403#define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
2404#define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
2405#define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
2406#define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
2407#define TARGET_SNDCTL_TMR_METRONOME 0x40045407
2408#define TARGET_SNDCTL_TMR_SELECT 0x40045408
2409#define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
2410#define TARGET_SNDCTL_TMR_START 0x00005402
2411#define TARGET_SNDCTL_TMR_STOP 0x00005403
2412#define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
2413#define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
2414#define TARGET_SOUND_PCM_READ_RATE 0x80045002
2415#define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
2416#define TARGET_SOUND_PCM_READ_BITS 0x80045005
2417#define TARGET_SOUND_PCM_READ_FILTER 0x80045007
2418#define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
2419#define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
2420#define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
2421#define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
2422#define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
2423#define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
2424#define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
2425
2426#define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
2427
2428#define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
2429#define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
2430#define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
2431#define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
2432#define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
2433#define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
2434#define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
2435#define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
2436#define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
2437#define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
2438#define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
2439#define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
2440#define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
2441#define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
2442#define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
2443#define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
2444#define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
2445
2446/* Obsolete macros */
2447#define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
2448#define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
2449#define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
2450
2451#define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
2452#define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
2453#define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
2454#define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
2455#define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
2456
2457#define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
2458
2459#define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
2460#define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
2461#define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
2462#define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
2463#define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
2464#define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
2465#define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
2466#define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
2467#define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
2468#define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
2469#define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
2470#define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
2471#define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
2472#define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
2473#define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
2474#define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
2475#define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
2476
2477/* Obsolete macros */
2478#define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
2479#define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
2480#define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
2481
2482#define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
2483
aca7708e
FB
2484struct target_snd_timer_id {
2485 int dev_class;
2486 int dev_sclass;
2487 int card;
2488 int device;
2489 int subdevice;
2490};
2491
2492struct target_snd_timer_ginfo {
2493 struct target_snd_timer_id tid;
2494 unsigned int flags;
2495 int card;
2496 unsigned char id[64];
2497 unsigned char name[80];
2498 abi_ulong reserved0;
2499 abi_ulong resolution;
2500 abi_ulong resolution_min;
2501 abi_ulong resolution_max;
2502 unsigned int clients;
2503 unsigned char reserved[32];
2504};
2505
2506struct target_snd_timer_gparams {
2507 struct target_snd_timer_id tid;
2508 abi_ulong period_num;
2509 abi_ulong period_den;
2510 unsigned char reserved[32];
2511};
2512
2513struct target_snd_timer_gstatus {
2514 struct target_snd_timer_id tid;
2515 abi_ulong resolution;
2516 abi_ulong resolution_num;
2517 abi_ulong resolution_den;
2518 unsigned char reserved[32];
2519};
2520
d22edf0a
FB
2521struct target_snd_timer_select {
2522 struct target_snd_timer_id id;
2523 unsigned char reserved[32];
2524};
2525
fe333025
FB
2526struct target_snd_timer_info {
2527 unsigned int flags;
2528 int card;
2529 unsigned char id[64];
2530 unsigned char name[80];
2531 abi_ulong reserved0;
2532 abi_ulong resolution;
2533 unsigned char reserved[64];
2534};
2535
2536struct target_snd_timer_status {
2537 struct target_timespec tstamp;
2538 unsigned int resolution;
2539 unsigned int lost;
2540 unsigned int overrun;
2541 unsigned int queue;
2542 unsigned char reserved[64];
2543};
2544
1c4c6fcd
FB
2545/* alsa timer ioctls */
2546#define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int)
2547#define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \
2548 struct snd_timer_id)
aca7708e
FB
2549#define TARGET_SNDRV_TIMER_IOCTL_GINFO TARGET_IOWR('T', 0x03, \
2550 struct target_snd_timer_ginfo)
2551#define TARGET_SNDRV_TIMER_IOCTL_GPARAMS TARGET_IOW('T', 0x04, \
2552 struct target_snd_timer_gparams)
2553#define TARGET_SNDRV_TIMER_IOCTL_GSTATUS TARGET_IOWR('T', 0x05, \
2554 struct target_snd_timer_gstatus)
d22edf0a
FB
2555#define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10, \
2556 struct target_snd_timer_select)
fe333025
FB
2557#define TARGET_SNDRV_TIMER_IOCTL_INFO TARGET_IOR('T', 0x11, \
2558 struct target_snd_timer_info)
2559#define TARGET_SNDRV_TIMER_IOCTL_PARAMS TARGET_IOW('T', 0x12, \
2560 struct snd_timer_params)
2561#define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14, \
2562 struct target_snd_timer_status)
045823a9
FB
2563#define TARGET_SNDRV_TIMER_IOCTL_START TARGET_IO('T', 0xa0)
2564#define TARGET_SNDRV_TIMER_IOCTL_STOP TARGET_IO('T', 0xa1)
2565#define TARGET_SNDRV_TIMER_IOCTL_CONTINUE TARGET_IO('T', 0xa2)
2566#define TARGET_SNDRV_TIMER_IOCTL_PAUSE TARGET_IO('T', 0xa3)
1c4c6fcd 2567
2521d698
FB
2568/* vfat ioctls */
2569#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
2570#define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
a5448a7d 2571
f443e396
PM
2572struct target_mtop {
2573 abi_short mt_op;
2574 abi_int mt_count;
2575};
2576
2577#if defined(TARGET_SPARC) || defined(TARGET_MIPS)
2578typedef abi_long target_kernel_daddr_t;
2579#else
2580typedef abi_int target_kernel_daddr_t;
2581#endif
2582
2583struct target_mtget {
2584 abi_long mt_type;
2585 abi_long mt_resid;
2586 abi_long mt_dsreg;
2587 abi_long mt_gstat;
2588 abi_long mt_erreg;
2589 target_kernel_daddr_t mt_fileno;
2590 target_kernel_daddr_t mt_blkno;
2591};
2592
2593struct target_mtpos {
2594 abi_long mt_blkno;
2595};
2596
2597#define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct target_mtop)
2598#define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget)
2599#define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos)
8fbd6b52 2600
bd27e675
AM
2601/* kcov ioctls */
2602#define TARGET_KCOV_ENABLE TARGET_IO('c', 100)
2603#define TARGET_KCOV_DISABLE TARGET_IO('c', 101)
f7dbd8fe 2604#define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
bd27e675 2605
a5448a7d 2606struct target_sysinfo {
992f48a0
BS
2607 abi_long uptime; /* Seconds since boot */
2608 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
2609 abi_ulong totalram; /* Total usable main memory size */
2610 abi_ulong freeram; /* Available memory size */
2611 abi_ulong sharedram; /* Amount of shared memory */
2612 abi_ulong bufferram; /* Memory used by buffers */
2613 abi_ulong totalswap; /* Total swap space size */
2614 abi_ulong freeswap; /* swap space still available */
a5448a7d
FB
2615 unsigned short procs; /* Number of current processes */
2616 unsigned short pad; /* explicit padding for m68k */
992f48a0
BS
2617 abi_ulong totalhigh; /* Total high memory size */
2618 abi_ulong freehigh; /* Available high memory size */
a5448a7d 2619 unsigned int mem_unit; /* Memory unit size in bytes */
992f48a0 2620 char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
a5448a7d 2621};
3532fa74 2622
6556a833
AJ
2623struct linux_dirent {
2624 long d_ino;
2625 unsigned long d_off;
2626 unsigned short d_reclen;
2627 char d_name[256]; /* We must not include limits.h! */
2628};
2629
2630struct linux_dirent64 {
2631 uint64_t d_ino;
2632 int64_t d_off;
2633 unsigned short d_reclen;
2634 unsigned char d_type;
2635 char d_name[256];
2636};
2637
24e1003a
AJ
2638struct target_mq_attr {
2639 abi_long mq_flags;
2640 abi_long mq_maxmsg;
2641 abi_long mq_msgsize;
2642 abi_long mq_curmsgs;
2643};
2644
e865b97f
CG
2645struct target_drm_version {
2646 int version_major;
2647 int version_minor;
2648 int version_patchlevel;
2649 abi_ulong name_len;
2650 abi_ulong name;
2651 abi_ulong date_len;
2652 abi_ulong date;
2653 abi_ulong desc_len;
2654 abi_ulong desc;
2655};
2656
913b03c2
CG
2657struct target_drm_i915_getparam {
2658 int param;
2659 abi_ulong value;
2660};
2661
3532fa74 2662#include "socket.h"
637947f1
TS
2663
2664#include "errno_defs.h"
03dfe9f8
RV
2665
2666#define FUTEX_WAIT 0
2667#define FUTEX_WAKE 1
2668#define FUTEX_FD 2
2669#define FUTEX_REQUEUE 3
2670#define FUTEX_CMP_REQUEUE 4
2671#define FUTEX_WAKE_OP 5
2672#define FUTEX_LOCK_PI 6
2673#define FUTEX_UNLOCK_PI 7
2674#define FUTEX_TRYLOCK_PI 8
2675#define FUTEX_WAIT_BITSET 9
2676#define FUTEX_WAKE_BITSET 10
2677
2678#define FUTEX_PRIVATE_FLAG 128
2679#define FUTEX_CLOCK_REALTIME 256
2680#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2681
3b6edd16 2682#ifdef CONFIG_EPOLL
928bed6a
LV
2683#if defined(TARGET_X86_64)
2684#define TARGET_EPOLL_PACKED QEMU_PACKED
2685#else
2686#define TARGET_EPOLL_PACKED
2687#endif
2688
3b6edd16
PM
2689typedef union target_epoll_data {
2690 abi_ulong ptr;
928bed6a
LV
2691 abi_int fd;
2692 abi_uint u32;
2693 abi_ullong u64;
3b6edd16
PM
2694} target_epoll_data_t;
2695
2696struct target_epoll_event {
928bed6a 2697 abi_uint events;
3b6edd16 2698 target_epoll_data_t data;
928bed6a 2699} TARGET_EPOLL_PACKED;
2ba7fae3
PM
2700
2701#define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
2702
3b6edd16 2703#endif
163a05a8
PM
2704struct target_rlimit64 {
2705 uint64_t rlim_cur;
2706 uint64_t rlim_max;
2707};
583359a6
AP
2708
2709struct target_ucred {
2710 uint32_t pid;
2711 uint32_t uid;
2712 uint32_t gid;
2713};
cb9c377f 2714
aecc8861 2715typedef int32_t target_timer_t;
905bba13 2716
34d60862
NC
2717#define TARGET_SIGEV_MAX_SIZE 64
2718
2719/* This is architecture-specific but most architectures use the default */
2720#ifdef TARGET_MIPS
2721#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
2722#else
2723#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
2724 + sizeof(target_sigval_t))
2725#endif
2726
2727#define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
2728 - TARGET_SIGEV_PREAMBLE_SIZE) \
2729 / sizeof(int32_t))
2730
905bba13
ECL
2731struct target_sigevent {
2732 target_sigval_t sigev_value;
17351c3f
PM
2733 abi_int sigev_signo;
2734 abi_int sigev_notify;
905bba13 2735 union {
17351c3f
PM
2736 abi_int _pad[TARGET_SIGEV_PAD_SIZE];
2737 abi_int _tid;
905bba13 2738
17351c3f
PM
2739 /* The kernel (and thus QEMU) never looks at these;
2740 * they're only used as part of the ABI between a
2741 * userspace program and libc.
2742 */
905bba13 2743 struct {
17351c3f
PM
2744 abi_ulong _function;
2745 abi_ulong _attribute;
905bba13
ECL
2746 } _sigev_thread;
2747 } _sigev_un;
2748};
e0eb210e
PM
2749
2750struct target_user_cap_header {
2751 uint32_t version;
2752 int pid;
2753};
2754
2755struct target_user_cap_data {
2756 uint32_t effective;
2757 uint32_t permitted;
2758 uint32_t inheritable;
2759};
1b3c4fdf 2760
da2c8ad7
AM
2761/* from kernel's include/linux/syslog.h */
2762
2763/* Close the log. Currently a NOP. */
2764#define TARGET_SYSLOG_ACTION_CLOSE 0
2765/* Open the log. Currently a NOP. */
2766#define TARGET_SYSLOG_ACTION_OPEN 1
2767/* Read from the log. */
2768#define TARGET_SYSLOG_ACTION_READ 2
2769/* Read all messages remaining in the ring buffer. */
2770#define TARGET_SYSLOG_ACTION_READ_ALL 3
2771/* Read and clear all messages remaining in the ring buffer */
2772#define TARGET_SYSLOG_ACTION_READ_CLEAR 4
2773/* Clear ring buffer. */
2774#define TARGET_SYSLOG_ACTION_CLEAR 5
2775/* Disable printk's to console */
2776#define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6
2777/* Enable printk's to console */
2778#define TARGET_SYSLOG_ACTION_CONSOLE_ON 7
2779/* Set level of messages printed to console */
2780#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8
2781/* Return number of unread characters in the log buffer */
2782#define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9
2783/* Return size of the log buffer */
2784#define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10
2785
efa92184
AR
2786struct target_statx_timestamp {
2787 int64_t tv_sec;
2788 uint32_t tv_nsec;
2789 int32_t __reserved;
2790};
2791
2792struct target_statx {
2793 /* 0x00 */
2794 uint32_t stx_mask; /* What results were written [uncond] */
2795 uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
2796 uint64_t stx_attributes; /* Flags conveying information about the file */
2797 /* 0x10 */
2798 uint32_t stx_nlink; /* Number of hard links */
2799 uint32_t stx_uid; /* User ID of owner */
2800 uint32_t stx_gid; /* Group ID of owner */
2801 uint16_t stx_mode; /* File mode */
2802 uint16_t __spare0[1];
2803 /* 0x20 */
2804 uint64_t stx_ino; /* Inode number */
2805 uint64_t stx_size; /* File size */
2806 uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
2807 uint64_t stx_attributes_mask; /* Mask to show what is supported */
2808 /* 0x40 */
2809 struct target_statx_timestamp stx_atime; /* Last access time */
2810 struct target_statx_timestamp stx_btime; /* File creation time */
2811 struct target_statx_timestamp stx_ctime; /* Last attribute change time */
2812 struct target_statx_timestamp stx_mtime; /* Last data modification time */
2813 /* 0x80 */
2814 uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
2815 uint32_t stx_rdev_minor;
2816 uint32_t stx_dev_major; /* ID of device containing file [uncond] */
2817 uint32_t stx_dev_minor;
2818 /* 0x90 */
2819 uint64_t __spare2[14]; /* Spare space for future expansion */
2820 /* 0x100 */
2821};
2822
1b3c4fdf 2823#endif
This page took 1.407064 seconds and 4 git commands to generate.