]> git.proxmox.com Git - mirror_qemu.git/blame - linux-user/syscall_defs.h
linux-user: support the KDSIGACCEPT ioctl
[mirror_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
PB
7#ifndef SYSCALL_DEFS_H
8#define SYSCALL_DEFS_H 1
9
10
6180a181 11#include "syscall_nr.h"
2521d698 12
31e31b8a
FB
13#define SOCKOP_socket 1
14#define SOCKOP_bind 2
15#define SOCKOP_connect 3
16#define SOCKOP_listen 4
17#define SOCKOP_accept 5
18#define SOCKOP_getsockname 6
19#define SOCKOP_getpeername 7
20#define SOCKOP_socketpair 8
21#define SOCKOP_send 9
22#define SOCKOP_recv 10
23#define SOCKOP_sendto 11
24#define SOCKOP_recvfrom 12
25#define SOCKOP_shutdown 13
26#define SOCKOP_setsockopt 14
27#define SOCKOP_getsockopt 15
28#define SOCKOP_sendmsg 16
29#define SOCKOP_recvmsg 17
b9d36eb2 30#define SOCKOP_accept4 18
31e31b8a 31
8853f86e
FB
32#define IPCOP_semop 1
33#define IPCOP_semget 2
34#define IPCOP_semctl 3
35#define IPCOP_semtimedop 4
36#define IPCOP_msgsnd 11
37#define IPCOP_msgrcv 12
38#define IPCOP_msgget 13
39#define IPCOP_msgctl 14
40#define IPCOP_shmat 21
41#define IPCOP_shmdt 22
42#define IPCOP_shmget 23
43#define IPCOP_shmctl 24
44
2521d698
FB
45/*
46 * The following is for compatibility across the various Linux
47 * platforms. The i386 ioctl numbering scheme doesn't really enforce
48 * a type field. De facto, however, the top 8 bits of the lower 16
49 * bits are indeed used as a type field, so we might just as well make
50 * this explicit here. Please be sure to use the decoding macros
51 * below from now on.
52 */
53#define TARGET_IOC_NRBITS 8
54#define TARGET_IOC_TYPEBITS 8
55
cd98d390
AS
56#if defined(TARGET_I386) || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
57 || defined(TARGET_SPARC) \
0c866a7e 58 || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
74d753ac
MW
59 /* 16 bit uid wrappers emulation */
60#define USE_UID16
0c866a7e
RV
61#define target_id uint16_t
62#else
63#define target_id uint32_t
74d753ac
MW
64#endif
65
e6e5906b 66#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
a4c075f1 67 || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \
d962783e 68 || defined(TARGET_S390X) || defined(TARGET_OPENRISC)
2521d698
FB
69
70#define TARGET_IOC_SIZEBITS 14
71#define TARGET_IOC_DIRBITS 2
72
73#define TARGET_IOC_NONE 0U
74#define TARGET_IOC_WRITE 1U
75#define TARGET_IOC_READ 2U
76
048f6b4d 77#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
b779e29e
EI
78 defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
79 defined(TARGET_MIPS)
2521d698
FB
80
81#define TARGET_IOC_SIZEBITS 13
82#define TARGET_IOC_DIRBITS 3
83
84#define TARGET_IOC_NONE 1U
85#define TARGET_IOC_READ 2U
86#define TARGET_IOC_WRITE 4U
87
88#else
89#error unsupported CPU
90#endif
91
92#define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
93#define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
94#define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
95#define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
96
97#define TARGET_IOC_NRSHIFT 0
98#define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
99#define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
100#define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
101
102#define TARGET_IOC(dir,type,nr,size) \
103 (((dir) << TARGET_IOC_DIRSHIFT) | \
104 ((type) << TARGET_IOC_TYPESHIFT) | \
105 ((nr) << TARGET_IOC_NRSHIFT) | \
106 ((size) << TARGET_IOC_SIZESHIFT))
107
108/* used to create numbers */
109#define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
110#define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
111#define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
112#define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
113
114/* the size is automatically computed for these defines */
115#define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
116#define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
117#define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
118
7854b056
FB
119struct target_sockaddr {
120 uint16_t sa_family;
121 uint8_t sa_data[14];
122};
123
f57d4192
LV
124struct target_sock_filter {
125 abi_ushort code;
126 uint8_t jt;
127 uint8_t jf;
128 abi_uint k;
129};
130
131struct target_sock_fprog {
132 abi_ushort len;
133 abi_ulong filter;
134};
135
b975b83b
LL
136struct target_in_addr {
137 uint32_t s_addr; /* big endian */
138};
139
140struct target_ip_mreq {
141 struct target_in_addr imr_multiaddr;
142 struct target_in_addr imr_address;
143};
144
145struct target_ip_mreqn {
146 struct target_in_addr imr_multiaddr;
147 struct target_in_addr imr_address;
148 abi_long imr_ifindex;
149};
150
6e3cb58f
LL
151struct target_ip_mreq_source {
152 /* big endian */
153 uint32_t imr_multiaddr;
154 uint32_t imr_interface;
155 uint32_t imr_sourceaddr;
156};
157
31e31b8a 158struct target_timeval {
992f48a0
BS
159 abi_long tv_sec;
160 abi_long tv_usec;
31e31b8a
FB
161};
162
1b6b029e 163struct target_timespec {
992f48a0
BS
164 abi_long tv_sec;
165 abi_long tv_nsec;
1b6b029e
FB
166};
167
ef4467e9
PB
168struct target_timezone {
169 abi_int tz_minuteswest;
170 abi_int tz_dsttime;
171};
172
66fb9763
FB
173struct target_itimerval {
174 struct target_timeval it_interval;
175 struct target_timeval it_value;
176};
177
905bba13
ECL
178struct target_itimerspec {
179 struct target_timespec it_interval;
180 struct target_timespec it_value;
181};
182
c227f099 183typedef abi_long target_clock_t;
32f36bce 184
c596ed17
FB
185#define TARGET_HZ 100
186
32f36bce 187struct target_tms {
c227f099
AL
188 target_clock_t tms_utime;
189 target_clock_t tms_stime;
190 target_clock_t tms_cutime;
191 target_clock_t tms_cstime;
32f36bce
FB
192};
193
6180a181 194struct target_utimbuf {
992f48a0
BS
195 abi_long actime;
196 abi_long modtime;
6180a181
FB
197};
198
f2674e31 199struct target_sel_arg_struct {
992f48a0
BS
200 abi_long n;
201 abi_long inp, outp, exp;
202 abi_long tvp;
f2674e31
FB
203};
204
31e31b8a 205struct target_iovec {
992f48a0
BS
206 abi_long iov_base; /* Starting address */
207 abi_long iov_len; /* Number of bytes */
31e31b8a
FB
208};
209
1a9353d2 210struct target_msghdr {
992f48a0
BS
211 abi_long msg_name; /* Socket name */
212 int msg_namelen; /* Length of name */
213 abi_long msg_iov; /* Data blocks */
214 abi_long msg_iovlen; /* Number of blocks */
215 abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
216 abi_long msg_controllen; /* Length of cmsg list */
1a9353d2
FB
217 unsigned int msg_flags;
218};
219
7854b056 220struct target_cmsghdr {
992f48a0 221 abi_long cmsg_len;
7854b056
FB
222 int cmsg_level;
223 int cmsg_type;
224};
225
226#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
227#define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
992f48a0
BS
228#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
229 & (size_t) ~(sizeof (abi_long) - 1))
7854b056
FB
230#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
231 + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
232#define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
233
234static __inline__ struct target_cmsghdr *
235__target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
236{
2b8bdefc
TS
237 struct target_cmsghdr *__ptr;
238
239 __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
cbb21eed
MB
240 + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
241 if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control))
242 > tswapal(__mhdr->msg_controllen))
7854b056 243 /* No more entries. */
2b8bdefc 244 return (struct target_cmsghdr *)0;
7854b056
FB
245 return __cmsg;
246}
247
f19e00d7
AG
248struct target_mmsghdr {
249 struct target_msghdr msg_hdr; /* Message header */
250 unsigned int msg_len; /* Number of bytes transmitted */
251};
7854b056 252
31e31b8a
FB
253struct target_rusage {
254 struct target_timeval ru_utime; /* user time used */
255 struct target_timeval ru_stime; /* system time used */
992f48a0
BS
256 abi_long ru_maxrss; /* maximum resident set size */
257 abi_long ru_ixrss; /* integral shared memory size */
258 abi_long ru_idrss; /* integral unshared data size */
259 abi_long ru_isrss; /* integral unshared stack size */
260 abi_long ru_minflt; /* page reclaims */
261 abi_long ru_majflt; /* page faults */
262 abi_long ru_nswap; /* swaps */
263 abi_long ru_inblock; /* block input operations */
264 abi_long ru_oublock; /* block output operations */
265 abi_long ru_msgsnd; /* messages sent */
266 abi_long ru_msgrcv; /* messages received */
267 abi_long ru_nsignals; /* signals received */
268 abi_long ru_nvcsw; /* voluntary context switches */
269 abi_long ru_nivcsw; /* involuntary " */
31e31b8a
FB
270};
271
272typedef struct {
273 int val[2];
c227f099 274} kernel_fsid_t;
31e31b8a 275
72f03900 276struct kernel_statfs {
31e31b8a
FB
277 int f_type;
278 int f_bsize;
279 int f_blocks;
280 int f_bfree;
281 int f_bavail;
282 int f_files;
283 int f_ffree;
c227f099 284 kernel_fsid_t f_fsid;
31e31b8a
FB
285 int f_namelen;
286 int f_spare[6];
287};
288
dab2ed99 289struct target_dirent {
333858b7
DL
290 abi_long d_ino;
291 abi_long d_off;
292 unsigned short d_reclen;
293 char d_name[];
dab2ed99
FB
294};
295
296struct target_dirent64 {
297 uint64_t d_ino;
298 int64_t d_off;
299 unsigned short d_reclen;
300 unsigned char d_type;
301 char d_name[256];
302};
303
304
31e31b8a 305/* mostly generic signal stuff */
992f48a0
BS
306#define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
307#define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
308#define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
31e31b8a
FB
309
310#ifdef TARGET_MIPS
311#define TARGET_NSIG 128
312#else
313#define TARGET_NSIG 64
314#endif
992f48a0 315#define TARGET_NSIG_BPW TARGET_ABI_BITS
31e31b8a
FB
316#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
317
318typedef struct {
992f48a0 319 abi_ulong sig[TARGET_NSIG_WORDS];
c227f099 320} target_sigset_t;
31e31b8a 321
66fb9763 322#ifdef BSWAP_NEEDED
c227f099 323static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
324{
325 int i;
326 for(i = 0;i < TARGET_NSIG_WORDS; i++)
cbb21eed 327 d->sig[i] = tswapal(s->sig[i]);
66fb9763
FB
328}
329#else
c227f099 330static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
66fb9763
FB
331{
332 *d = *s;
333}
334#endif
335
c227f099 336static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
66fb9763
FB
337{
338 int i;
339 d->sig[0] = set;
340 for(i = 1;i < TARGET_NSIG_WORDS; i++)
341 d->sig[i] = 0;
342}
343
c227f099
AL
344void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
345void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
992f48a0 346void host_to_target_old_sigset(abi_ulong *old_sigset,
66fb9763 347 const sigset_t *sigset);
5fafdf24 348void target_to_host_old_sigset(sigset_t *sigset,
992f48a0 349 const abi_ulong *old_sigset);
66fb9763
FB
350struct target_sigaction;
351int do_sigaction(int sig, const struct target_sigaction *act,
352 struct target_sigaction *oact);
353
d2fbca94
GX
354#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
355 || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
356 || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
a4c075f1 357 || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
d962783e 358 || defined(TARGET_S390X) || defined(TARGET_OPENRISC)
2521d698 359
048f6b4d
FB
360#if defined(TARGET_SPARC)
361#define TARGET_SA_NOCLDSTOP 8u
362#define TARGET_SA_NOCLDWAIT 0x100u
363#define TARGET_SA_SIGINFO 0x200u
364#define TARGET_SA_ONSTACK 1u
365#define TARGET_SA_RESTART 2u
366#define TARGET_SA_NODEFER 0x20u
367#define TARGET_SA_RESETHAND 4u
368#elif defined(TARGET_MIPS)
369#define TARGET_SA_NOCLDSTOP 0x00000001
370#define TARGET_SA_NOCLDWAIT 0x00010000
371#define TARGET_SA_SIGINFO 0x00000008
372#define TARGET_SA_ONSTACK 0x08000000
373#define TARGET_SA_NODEFER 0x40000000
374#define TARGET_SA_RESTART 0x10000000
375#define TARGET_SA_RESETHAND 0x80000000
d26bc211
TS
376#if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
377#define TARGET_SA_RESTORER 0x04000000 /* Only for O32 */
540635ba 378#endif
d962783e
JL
379#elif defined(TARGET_OPENRISC)
380#define TARGET_SA_NOCLDSTOP 0x00000001
381#define TARGET_SA_NOCLDWAIT 0x00000002
382#define TARGET_SA_SIGINFO 0x00000004
383#define TARGET_SA_ONSTACK 0x08000000
384#define TARGET_SA_RESTART 0x10000000
385#define TARGET_SA_NODEFER 0x40000000
386#define TARGET_SA_RESETHAND 0x80000000
57f18a95
RH
387#elif defined(TARGET_ALPHA)
388#define TARGET_SA_ONSTACK 0x00000001
389#define TARGET_SA_RESTART 0x00000002
390#define TARGET_SA_NOCLDSTOP 0x00000004
391#define TARGET_SA_NODEFER 0x00000008
392#define TARGET_SA_RESETHAND 0x00000010
393#define TARGET_SA_NOCLDWAIT 0x00000020 /* not supported yet */
394#define TARGET_SA_SIGINFO 0x00000040
048f6b4d 395#else
2521d698
FB
396#define TARGET_SA_NOCLDSTOP 0x00000001
397#define TARGET_SA_NOCLDWAIT 0x00000002 /* not supported yet */
398#define TARGET_SA_SIGINFO 0x00000004
399#define TARGET_SA_ONSTACK 0x08000000
400#define TARGET_SA_RESTART 0x10000000
401#define TARGET_SA_NODEFER 0x40000000
402#define TARGET_SA_RESETHAND 0x80000000
403#define TARGET_SA_RESTORER 0x04000000
6d5e216d
FB
404#endif
405
d0f20495
RH
406#if defined(TARGET_ALPHA)
407
408#define TARGET_SIGHUP 1
409#define TARGET_SIGINT 2
410#define TARGET_SIGQUIT 3
411#define TARGET_SIGILL 4
412#define TARGET_SIGTRAP 5
413#define TARGET_SIGABRT 6
414#define TARGET_SIGSTKFLT 7 /* actually SIGEMT */
415#define TARGET_SIGFPE 8
416#define TARGET_SIGKILL 9
417#define TARGET_SIGBUS 10
418#define TARGET_SIGSEGV 11
419#define TARGET_SIGSYS 12
420#define TARGET_SIGPIPE 13
421#define TARGET_SIGALRM 14
422#define TARGET_SIGTERM 15
423#define TARGET_SIGURG 16
424#define TARGET_SIGSTOP 17
425#define TARGET_SIGTSTP 18
426#define TARGET_SIGCONT 19
427#define TARGET_SIGCHLD 20
428#define TARGET_SIGTTIN 21
429#define TARGET_SIGTTOU 22
430#define TARGET_SIGIO 23
431#define TARGET_SIGXCPU 24
432#define TARGET_SIGXFSZ 25
433#define TARGET_SIGVTALRM 26
434#define TARGET_SIGPROF 27
435#define TARGET_SIGWINCH 28
436#define TARGET_SIGPWR 29 /* actually SIGINFO */
437#define TARGET_SIGUSR1 30
438#define TARGET_SIGUSR2 31
439#define TARGET_SIGRTMIN 32
440
441#define TARGET_SIG_BLOCK 1
442#define TARGET_SIG_UNBLOCK 2
443#define TARGET_SIG_SETMASK 3
444
445#elif defined(TARGET_SPARC)
6d5e216d
FB
446
447#define TARGET_SIGHUP 1
448#define TARGET_SIGINT 2
449#define TARGET_SIGQUIT 3
450#define TARGET_SIGILL 4
451#define TARGET_SIGTRAP 5
452#define TARGET_SIGABRT 6
453#define TARGET_SIGIOT 6
454#define TARGET_SIGSTKFLT 7 /* actually EMT */
455#define TARGET_SIGFPE 8
456#define TARGET_SIGKILL 9
457#define TARGET_SIGBUS 10
458#define TARGET_SIGSEGV 11
459#define TARGET_SIGSYS 12
460#define TARGET_SIGPIPE 13
461#define TARGET_SIGALRM 14
462#define TARGET_SIGTERM 15
463#define TARGET_SIGURG 16
464#define TARGET_SIGSTOP 17
465#define TARGET_SIGTSTP 18
466#define TARGET_SIGCONT 19
467#define TARGET_SIGCHLD 20
468#define TARGET_SIGTTIN 21
469#define TARGET_SIGTTOU 22
470#define TARGET_SIGIO 23
471#define TARGET_SIGXCPU 24
472#define TARGET_SIGXFSZ 25
473#define TARGET_SIGVTALRM 26
474#define TARGET_SIGPROF 27
475#define TARGET_SIGWINCH 28
476#define TARGET_SIGPWR 29
477#define TARGET_SIGUSR1 30
478#define TARGET_SIGUSR2 31
479#define TARGET_SIGRTMIN 32
480
481#define TARGET_SIG_BLOCK 0x01 /* for blocking signals */
482#define TARGET_SIG_UNBLOCK 0x02 /* for unblocking signals */
483#define TARGET_SIG_SETMASK 0x04 /* for setting the signal mask */
484
048f6b4d
FB
485#elif defined(TARGET_MIPS)
486
487#define TARGET_SIGHUP 1 /* Hangup (POSIX). */
488#define TARGET_SIGINT 2 /* Interrupt (ANSI). */
489#define TARGET_SIGQUIT 3 /* Quit (POSIX). */
490#define TARGET_SIGILL 4 /* Illegal instruction (ANSI). */
491#define TARGET_SIGTRAP 5 /* Trace trap (POSIX). */
492#define TARGET_SIGIOT 6 /* IOT trap (4.2 BSD). */
493#define TARGET_SIGABRT TARGET_SIGIOT /* Abort (ANSI). */
494#define TARGET_SIGEMT 7
495#define TARGET_SIGSTKFLT 7 /* XXX: incorrect */
496#define TARGET_SIGFPE 8 /* Floating-point exception (ANSI). */
497#define TARGET_SIGKILL 9 /* Kill, unblockable (POSIX). */
498#define TARGET_SIGBUS 10 /* BUS error (4.2 BSD). */
499#define TARGET_SIGSEGV 11 /* Segmentation violation (ANSI). */
500#define TARGET_SIGSYS 12
501#define TARGET_SIGPIPE 13 /* Broken pipe (POSIX). */
502#define TARGET_SIGALRM 14 /* Alarm clock (POSIX). */
503#define TARGET_SIGTERM 15 /* Termination (ANSI). */
504#define TARGET_SIGUSR1 16 /* User-defined signal 1 (POSIX). */
505#define TARGET_SIGUSR2 17 /* User-defined signal 2 (POSIX). */
506#define TARGET_SIGCHLD 18 /* Child status has changed (POSIX). */
507#define TARGET_SIGCLD TARGET_SIGCHLD /* Same as TARGET_SIGCHLD (System V). */
508#define TARGET_SIGPWR 19 /* Power failure restart (System V). */
509#define TARGET_SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
510#define TARGET_SIGURG 21 /* Urgent condition on socket (4.2 BSD). */
511#define TARGET_SIGIO 22 /* I/O now possible (4.2 BSD). */
512#define TARGET_SIGPOLL TARGET_SIGIO /* Pollable event occurred (System V). */
513#define TARGET_SIGSTOP 23 /* Stop, unblockable (POSIX). */
514#define TARGET_SIGTSTP 24 /* Keyboard stop (POSIX). */
515#define TARGET_SIGCONT 25 /* Continue (POSIX). */
516#define TARGET_SIGTTIN 26 /* Background read from tty (POSIX). */
517#define TARGET_SIGTTOU 27 /* Background write to tty (POSIX). */
518#define TARGET_SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
519#define TARGET_SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
520#define TARGET_SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
521#define TARGET_SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
522#define TARGET_SIGRTMIN 32
523
524#define TARGET_SIG_BLOCK 1 /* for blocking signals */
525#define TARGET_SIG_UNBLOCK 2 /* for unblocking signals */
526#define TARGET_SIG_SETMASK 3 /* for setting the signal mask */
527
6d5e216d 528#else
2521d698 529
d962783e 530/* OpenRISC Using the general signals */
2521d698
FB
531#define TARGET_SIGHUP 1
532#define TARGET_SIGINT 2
533#define TARGET_SIGQUIT 3
534#define TARGET_SIGILL 4
535#define TARGET_SIGTRAP 5
536#define TARGET_SIGABRT 6
537#define TARGET_SIGIOT 6
538#define TARGET_SIGBUS 7
539#define TARGET_SIGFPE 8
540#define TARGET_SIGKILL 9
541#define TARGET_SIGUSR1 10
542#define TARGET_SIGSEGV 11
543#define TARGET_SIGUSR2 12
544#define TARGET_SIGPIPE 13
545#define TARGET_SIGALRM 14
546#define TARGET_SIGTERM 15
547#define TARGET_SIGSTKFLT 16
548#define TARGET_SIGCHLD 17
549#define TARGET_SIGCONT 18
550#define TARGET_SIGSTOP 19
551#define TARGET_SIGTSTP 20
552#define TARGET_SIGTTIN 21
553#define TARGET_SIGTTOU 22
554#define TARGET_SIGURG 23
555#define TARGET_SIGXCPU 24
556#define TARGET_SIGXFSZ 25
557#define TARGET_SIGVTALRM 26
558#define TARGET_SIGPROF 27
559#define TARGET_SIGWINCH 28
560#define TARGET_SIGIO 29
c596ed17
FB
561#define TARGET_SIGPWR 30
562#define TARGET_SIGSYS 31
2521d698
FB
563#define TARGET_SIGRTMIN 32
564
565#define TARGET_SIG_BLOCK 0 /* for blocking signals */
566#define TARGET_SIG_UNBLOCK 1 /* for unblocking signals */
567#define TARGET_SIG_SETMASK 2 /* for setting the signal mask */
568
6d5e216d
FB
569#endif
570
6049f4f8
RH
571#if defined(TARGET_ALPHA)
572struct target_old_sigaction {
573 abi_ulong _sa_handler;
574 abi_ulong sa_mask;
d2565875 575 int32_t sa_flags;
6049f4f8
RH
576};
577
578struct target_rt_sigaction {
579 abi_ulong _sa_handler;
580 abi_ulong sa_flags;
581 target_sigset_t sa_mask;
582};
106ec879 583
6049f4f8
RH
584/* This is the struct used inside the kernel. The ka_restorer
585 field comes from the 5th argument to sys_rt_sigaction. */
586struct target_sigaction {
587 abi_ulong _sa_handler;
588 abi_ulong sa_flags;
589 target_sigset_t sa_mask;
590 abi_ulong sa_restorer;
591};
592#elif defined(TARGET_MIPS)
106ec879 593struct target_sigaction {
540635ba 594 uint32_t sa_flags;
d26bc211 595#if defined(TARGET_ABI_MIPSN32)
540635ba
TS
596 uint32_t _sa_handler;
597#else
992f48a0 598 abi_ulong _sa_handler;
540635ba 599#endif
c227f099 600 target_sigset_t sa_mask;
106ec879 601};
106ec879 602#else
2521d698 603struct target_old_sigaction {
992f48a0
BS
604 abi_ulong _sa_handler;
605 abi_ulong sa_mask;
606 abi_ulong sa_flags;
607 abi_ulong sa_restorer;
2521d698
FB
608};
609
610struct target_sigaction {
992f48a0
BS
611 abi_ulong _sa_handler;
612 abi_ulong sa_flags;
613 abi_ulong sa_restorer;
c227f099 614 target_sigset_t sa_mask;
2521d698 615};
106ec879 616#endif
2521d698
FB
617
618typedef union target_sigval {
619 int sival_int;
992f48a0 620 abi_ulong sival_ptr;
c227f099 621} target_sigval_t;
6d5e216d
FB
622#if 0
623#if defined (TARGET_SPARC)
624typedef struct {
625 struct {
992f48a0
BS
626 abi_ulong psr;
627 abi_ulong pc;
628 abi_ulong npc;
629 abi_ulong y;
630 abi_ulong u_regs[16]; /* globals and ins */
6d5e216d
FB
631 } si_regs;
632 int si_mask;
633} __siginfo_t;
634
635typedef struct {
636 unsigned long si_float_regs [32];
637 unsigned long si_fsr;
638 unsigned long si_fpqdepth;
639 struct {
640 unsigned long *insn_addr;
641 unsigned long insn;
642 } si_fpqueue [16];
643} __siginfo_fpu_t;
644#endif
645#endif
2521d698
FB
646
647#define TARGET_SI_MAX_SIZE 128
648#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
649
650typedef struct target_siginfo {
3f53d546
PB
651#ifdef TARGET_MIPS
652 int si_signo;
653 int si_code;
654 int si_errno;
655#else
2521d698
FB
656 int si_signo;
657 int si_errno;
658 int si_code;
3f53d546 659#endif
2521d698
FB
660
661 union {
662 int _pad[TARGET_SI_PAD_SIZE];
663
664 /* kill() */
665 struct {
666 pid_t _pid; /* sender's pid */
667 uid_t _uid; /* sender's uid */
668 } _kill;
669
670 /* POSIX.1b timers */
671 struct {
672 unsigned int _timer1;
673 unsigned int _timer2;
674 } _timer;
675
676 /* POSIX.1b signals */
677 struct {
678 pid_t _pid; /* sender's pid */
679 uid_t _uid; /* sender's uid */
c227f099 680 target_sigval_t _sigval;
2521d698
FB
681 } _rt;
682
683 /* SIGCHLD */
684 struct {
685 pid_t _pid; /* which child */
686 uid_t _uid; /* sender's uid */
687 int _status; /* exit code */
c227f099
AL
688 target_clock_t _utime;
689 target_clock_t _stime;
2521d698
FB
690 } _sigchld;
691
692 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
693 struct {
992f48a0 694 abi_ulong _addr; /* faulting insn/memory ref. */
2521d698
FB
695 } _sigfault;
696
697 /* SIGPOLL */
698 struct {
699 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
700 int _fd;
701 } _sigpoll;
702 } _sifields;
c227f099 703} target_siginfo_t;
2521d698
FB
704
705/*
706 * si_code values
707 * Digital reserves positive values for kernel-generated signals.
708 */
709#define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
710#define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
711#define TARGET_SI_QUEUE -1 /* sent by sigqueue */
712#define TARGET_SI_TIMER -2 /* sent by timer expiration */
713#define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
714#define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
715#define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
716
717/*
718 * SIGILL si_codes
719 */
ffa65c3b 720#define TARGET_ILL_ILLOPC (1) /* illegal opcode */
2521d698 721#define TARGET_ILL_ILLOPN (2) /* illegal operand */
ffa65c3b
FB
722#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
723#define TARGET_ILL_ILLTRP (4) /* illegal trap */
724#define TARGET_ILL_PRVOPC (5) /* privileged opcode */
725#define TARGET_ILL_PRVREG (6) /* privileged register */
726#define TARGET_ILL_COPROC (7) /* coprocessor error */
727#define TARGET_ILL_BADSTK (8) /* internal stack error */
2521d698
FB
728
729/*
730 * SIGFPE si_codes
731 */
732#define TARGET_FPE_INTDIV (1) /* integer divide by zero */
733#define TARGET_FPE_INTOVF (2) /* integer overflow */
734#define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
735#define TARGET_FPE_FLTOVF (4) /* floating point overflow */
736#define TARGET_FPE_FLTUND (5) /* floating point underflow */
737#define TARGET_FPE_FLTRES (6) /* floating point inexact result */
738#define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
739#define TARGET_FPE_FLTSUB (8) /* subscript out of range */
740#define TARGET_NSIGFPE 8
741
742/*
743 * SIGSEGV si_codes
744 */
745#define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
746#define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
747
ffa65c3b
FB
748/*
749 * SIGBUS si_codes
750 */
751#define TARGET_BUS_ADRALN (1) /* invalid address alignment */
b4916d7b 752#define TARGET_BUS_ADRERR (2) /* non-existent physical address */
ffa65c3b
FB
753#define TARGET_BUS_OBJERR (3) /* object specific hardware error */
754
2521d698
FB
755/*
756 * SIGTRAP si_codes
757 */
758#define TARGET_TRAP_BRKPT (1) /* process breakpoint */
759#define TARGET_TRAP_TRACE (2) /* process trace trap */
760
761#endif /* defined(TARGET_I386) || defined(TARGET_ARM) */
762
9de5e440 763struct target_rlimit {
992f48a0
BS
764 abi_ulong rlim_cur;
765 abi_ulong rlim_max;
9de5e440
FB
766};
767
81bbe906 768#if defined(TARGET_ALPHA)
e476492e 769#define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
6cafd027 770#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
81bbe906
TY
771#define TARGET_RLIM_INFINITY 0x7fffffffUL
772#else
26b746db 773#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
81bbe906
TY
774#endif
775
e22b7015
WT
776#if defined(TARGET_MIPS)
777#define TARGET_RLIMIT_CPU 0
778#define TARGET_RLIMIT_FSIZE 1
779#define TARGET_RLIMIT_DATA 2
780#define TARGET_RLIMIT_STACK 3
781#define TARGET_RLIMIT_CORE 4
782#define TARGET_RLIMIT_RSS 7
783#define TARGET_RLIMIT_NPROC 8
784#define TARGET_RLIMIT_NOFILE 5
785#define TARGET_RLIMIT_MEMLOCK 9
786#define TARGET_RLIMIT_AS 6
787#define TARGET_RLIMIT_LOCKS 10
788#define TARGET_RLIMIT_SIGPENDING 11
789#define TARGET_RLIMIT_MSGQUEUE 12
790#define TARGET_RLIMIT_NICE 13
791#define TARGET_RLIMIT_RTPRIO 14
792#else
793#define TARGET_RLIMIT_CPU 0
794#define TARGET_RLIMIT_FSIZE 1
795#define TARGET_RLIMIT_DATA 2
796#define TARGET_RLIMIT_STACK 3
797#define TARGET_RLIMIT_CORE 4
798#define TARGET_RLIMIT_RSS 5
6cafd027
MB
799#if defined(TARGET_SPARC)
800#define TARGET_RLIMIT_NOFILE 6
801#define TARGET_RLIMIT_NPROC 7
802#else
e22b7015
WT
803#define TARGET_RLIMIT_NPROC 6
804#define TARGET_RLIMIT_NOFILE 7
6cafd027 805#endif
e22b7015
WT
806#define TARGET_RLIMIT_MEMLOCK 8
807#define TARGET_RLIMIT_AS 9
808#define TARGET_RLIMIT_LOCKS 10
809#define TARGET_RLIMIT_SIGPENDING 11
810#define TARGET_RLIMIT_MSGQUEUE 12
811#define TARGET_RLIMIT_NICE 13
812#define TARGET_RLIMIT_RTPRIO 14
813#endif
814
9de5e440
FB
815struct target_pollfd {
816 int fd; /* file descriptor */
817 short events; /* requested events */
818 short revents; /* returned events */
819};
820
8e5a0667 821/* virtual terminal ioctls */
0221cfcd
FB
822#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
823#define TARGET_KDMKTONE 0x4B30 /* generate tone */
8e5a0667 824#define TARGET_KDGKBTYPE 0x4b33
f7680a55
UH
825#define TARGET_KDSETMODE 0x4b3a
826#define TARGET_KDGKBMODE 0x4b44
827#define TARGET_KDSKBMODE 0x4b45
0221cfcd
FB
828#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
829#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
e6fe18fb
CV
830#define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
831#define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
832#define TARGET_KDGETLED 0x4B31 /* return current led state */
833#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
ca56f5b5 834#define TARGET_KDSIGACCEPT 0x4B4E
8e5a0667 835
2521d698
FB
836#define TARGET_SIOCATMARK 0x8905
837
31e31b8a
FB
838/* Networking ioctls */
839#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
840#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
841#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
842#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
843#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
844#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
845#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
846#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
847#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
848#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
849#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
850#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
851#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
852#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
853#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
854#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
855#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
856#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
857#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
858#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
859#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
860#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
861#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
862#define TARGET_SIOCSIFENCAP 0x8926
863#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
864#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
865#define TARGET_SIOCSIFSLAVE 0x8930
866#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
867#define TARGET_SIOCDELMULTI 0x8932
868
869/* Bridging control calls */
870#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
871#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
872
873#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
874#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
875
876/* ARP cache control calls. */
877#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
878#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
879#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
880#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
881#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
882#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
883
884/* RARP cache control calls. */
885#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
886#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
887#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
888
889/* Driver configuration calls */
890#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
891#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
892
893/* DLCI configuration calls */
894#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
895#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
896
86fcd946
LV
897/* From <linux/wireless.h> */
898
899#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
31e31b8a
FB
900
901/* From <linux/fs.h> */
902
903#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
904#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
905#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
906#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
907#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
908#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
909#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
910#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
911#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
912#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
913#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
914#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
fff8c539 915#define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
31e31b8a 916/* A jump here: 108-111 have been used for various private purposes. */
c8b0bf54
PM
917#define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
918#define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
edafea13
AG
919#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
920 /* return device size in bytes
921 (u64 *arg) */
31e31b8a
FB
922#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
923#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
285da2b9 924#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
31e31b8a
FB
925
926/* cdrom commands */
5fafdf24 927#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
31e31b8a
FB
928#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
929#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
5fafdf24 930#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
31e31b8a 931 (struct cdrom_ti) */
5fafdf24 932#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
31e31b8a 933 (struct cdrom_tochdr) */
5fafdf24 934#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
31e31b8a
FB
935 (struct cdrom_tocentry) */
936#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
937#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
938#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
5fafdf24 939#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
31e31b8a 940 (struct cdrom_volctrl) */
5fafdf24 941#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
31e31b8a 942 (struct cdrom_subchnl) */
5fafdf24 943#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
31e31b8a
FB
944 (struct cdrom_read) */
945#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
946 (struct cdrom_read) */
947#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
948#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
5fafdf24
TS
949#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
950 address of multi session disks
31e31b8a 951 (struct cdrom_multisession) */
5fafdf24 952#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
31e31b8a 953 if available (struct cdrom_mcn) */
5fafdf24 954#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is depricated,
b4916d7b 955 but here anyway for compatibility */
31e31b8a 956#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
5fafdf24 957#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
31e31b8a
FB
958 (struct cdrom_volctrl) */
959#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
960 (struct cdrom_read) */
5fafdf24 961/*
31e31b8a
FB
962 * These ioctls are used only used in aztcd.c and optcd.c
963 */
964#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
965#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
3b46e624 966
31e31b8a 967/*
3b46e624 968 * This ioctl is only used by the scsi-cd driver.
31e31b8a
FB
969 It is for playing audio in logical block addressing mode.
970 */
971#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
972
5fafdf24 973/*
31e31b8a
FB
974 * These ioctls are only used in optcd.c
975 */
976#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
977
5fafdf24
TS
978/*
979 * These ioctls are (now) only in ide-cd.c for controlling
31e31b8a
FB
980 * drive spindown time. They should be implemented in the
981 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
982 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
983 * -Erik
984 */
985#define TARGET_CDROMGETSPINDOWN 0x531d
986#define TARGET_CDROMSETSPINDOWN 0x531e
987
5fafdf24 988/*
31e31b8a
FB
989 * These ioctls are implemented through the uniform CD-ROM driver
990 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
991 * drivers are eventually ported to the uniform CD-ROM driver interface.
992 */
993#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
994#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
995#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
996#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
997#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
998#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
999#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
1000#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
1001#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
1002#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
1003#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
1004#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
1005
1006/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
1007 * Future CDROM ioctls should be kept below 0x537F
1008 */
1009
1010/* This ioctl is only used by sbpcd at the moment */
1011#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
1012 /* conflict with SCSI_IOCTL_GET_IDLUN */
1013
1014/* DVD-ROM Specific ioctls */
1015#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
1016#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
1017#define TARGET_DVD_AUTH 0x5392 /* Authentication */
1018
1019#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
1020#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
1021#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
1022
1023/* HD commands */
1024
1025/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
1026#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
1027#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
1028#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
31e31b8a
FB
1029#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
1030#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
1031#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
1032#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
2521d698 1033#define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
31e31b8a
FB
1034#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
1035
1036/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
1037#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
1038#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
1039#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
1040#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
1041#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
1042#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
1043#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
2521d698 1044
b8005914
AZ
1045/* loop ioctls */
1046#define TARGET_LOOP_SET_FD 0x4C00
1047#define TARGET_LOOP_CLR_FD 0x4C01
1048#define TARGET_LOOP_SET_STATUS 0x4C02
1049#define TARGET_LOOP_GET_STATUS 0x4C03
1050#define TARGET_LOOP_SET_STATUS64 0x4C04
1051#define TARGET_LOOP_GET_STATUS64 0x4C05
1052#define TARGET_LOOP_CHANGE_FD 0x4C06
2521d698 1053
f7680a55
UH
1054/* fb ioctls */
1055#define TARGET_FBIOGET_VSCREENINFO 0x4600
1056#define TARGET_FBIOPUT_VSCREENINFO 0x4601
1057#define TARGET_FBIOGET_FSCREENINFO 0x4602
12b81b71
CV
1058#define TARGET_FBIOGETCMAP 0x4604
1059#define TARGET_FBIOPUTCMAP 0x4605
1060#define TARGET_FBIOPAN_DISPLAY 0x4606
1061#define TARGET_FBIOGET_CON2FBMAP 0x460F
1062#define TARGET_FBIOPUT_CON2FBMAP 0x4610
f7680a55
UH
1063
1064/* vt ioctls */
1065#define TARGET_VT_OPENQRY 0x5600
1066#define TARGET_VT_GETSTATE 0x5603
1067#define TARGET_VT_ACTIVATE 0x5606
1068#define TARGET_VT_WAITACTIVE 0x5607
1069#define TARGET_VT_LOCKSWITCH 0x560b
1070#define TARGET_VT_UNLOCKSWITCH 0x560c
774750c0
CV
1071#define TARGET_VT_GETMODE 0x5601
1072#define TARGET_VT_SETMODE 0x5602
1073#define TARGET_VT_RELDISP 0x5605
1074#define TARGET_VT_DISALLOCATE 0x5608
f7680a55 1075
56e904ec
AG
1076/* device mapper */
1077#define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
1078#define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
1079#define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
1080#define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
1081#define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
1082#define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
1083#define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
1084#define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
1085#define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
1086#define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
1087#define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
1088#define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
1089#define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
1090#define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
1091#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
1092#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
1093
2521d698
FB
1094/* from asm/termbits.h */
1095
3bfd9da1
FB
1096#define TARGET_NCC 8
1097struct target_termio {
1098 unsigned short c_iflag; /* input mode flags */
1099 unsigned short c_oflag; /* output mode flags */
1100 unsigned short c_cflag; /* control mode flags */
1101 unsigned short c_lflag; /* local mode flags */
1102 unsigned char c_line; /* line discipline */
1103 unsigned char c_cc[TARGET_NCC]; /* control characters */
1104};
2521d698 1105
3bfd9da1
FB
1106struct target_winsize {
1107 unsigned short ws_row;
1108 unsigned short ws_col;
1109 unsigned short ws_xpixel;
1110 unsigned short ws_ypixel;
2521d698
FB
1111};
1112
3bfd9da1 1113#include "termbits.h"
2521d698 1114
9e0b74a4
PB
1115#if defined(TARGET_MIPS)
1116#define TARGET_PROT_SEM 0x10
1117#else
1118#define TARGET_PROT_SEM 0x08
1119#endif
1120
e44a3e79 1121/* Common */
2521d698
FB
1122#define TARGET_MAP_SHARED 0x01 /* Share changes */
1123#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
e44a3e79
AJ
1124#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
1125
1126/* Target specific */
048f6b4d 1127#if defined(TARGET_MIPS)
e44a3e79 1128#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
048f6b4d
FB
1129#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1130#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1131#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1132#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1133#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1134#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
540635ba
TS
1135#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1136#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
e44a3e79
AJ
1137#elif defined(TARGET_PPC)
1138#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
2521d698 1139#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
2521d698
FB
1140#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1141#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1142#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
7ec93196
JM
1143#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
1144#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
e44a3e79
AJ
1145#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1146#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
1147#elif defined(TARGET_ALPHA)
1148#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1149#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
1150#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
1151#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
1152#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
1153#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
1154#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
1155#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
1156#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
7ec93196 1157#else
e44a3e79
AJ
1158#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1159#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
1160#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1161#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1162#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
2521d698
FB
1163#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
1164#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
540635ba
TS
1165#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1166#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
906c1b8e 1167#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
7ec93196 1168#endif
2521d698 1169
09701199
AG
1170#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
1171 || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
c7819dfb 1172 || defined(TARGET_CRIS) || defined(TARGET_UNICORE32)
2521d698
FB
1173struct target_stat {
1174 unsigned short st_dev;
1175 unsigned short __pad1;
992f48a0 1176 abi_ulong st_ino;
2521d698
FB
1177 unsigned short st_mode;
1178 unsigned short st_nlink;
1179 unsigned short st_uid;
1180 unsigned short st_gid;
1181 unsigned short st_rdev;
1182 unsigned short __pad2;
992f48a0
BS
1183 abi_ulong st_size;
1184 abi_ulong st_blksize;
1185 abi_ulong st_blocks;
1186 abi_ulong target_st_atime;
1187 abi_ulong __unused1;
1188 abi_ulong target_st_mtime;
1189 abi_ulong __unused2;
1190 abi_ulong target_st_ctime;
1191 abi_ulong __unused3;
1192 abi_ulong __unused4;
1193 abi_ulong __unused5;
2521d698
FB
1194};
1195
1196/* This matches struct stat64 in glibc2.1, hence the absolutely
1197 * insane amounts of padding around dev_t's.
1198 */
20d155bc 1199#define TARGET_HAS_STRUCT_STAT64
2521d698
FB
1200struct target_stat64 {
1201 unsigned short st_dev;
1202 unsigned char __pad0[10];
1203
1204#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1205 abi_ulong __st_ino;
2521d698
FB
1206
1207 unsigned int st_mode;
1208 unsigned int st_nlink;
1209
992f48a0
BS
1210 abi_ulong st_uid;
1211 abi_ulong st_gid;
2521d698
FB
1212
1213 unsigned short st_rdev;
1214 unsigned char __pad3[10];
1215
1216 long long st_size;
992f48a0 1217 abi_ulong st_blksize;
2521d698 1218
992f48a0
BS
1219 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
1220 abi_ulong __pad4; /* future possible st_blocks high bits */
2521d698 1221
992f48a0
BS
1222 abi_ulong target_st_atime;
1223 abi_ulong __pad5;
2521d698 1224
992f48a0
BS
1225 abi_ulong target_st_mtime;
1226 abi_ulong __pad6;
2521d698 1227
992f48a0
BS
1228 abi_ulong target_st_ctime;
1229 abi_ulong __pad7; /* will be high 32 bits of ctime someday */
2521d698
FB
1230
1231 unsigned long long st_ino;
541dc0d4 1232} QEMU_PACKED;
2521d698 1233
ce4defa0 1234#ifdef TARGET_ARM
20d155bc 1235#define TARGET_HAS_STRUCT_STAT64
ce4defa0
PB
1236struct target_eabi_stat64 {
1237 unsigned long long st_dev;
1238 unsigned int __pad1;
992f48a0 1239 abi_ulong __st_ino;
ce4defa0
PB
1240 unsigned int st_mode;
1241 unsigned int st_nlink;
1242
992f48a0
BS
1243 abi_ulong st_uid;
1244 abi_ulong st_gid;
ce4defa0
PB
1245
1246 unsigned long long st_rdev;
1247 unsigned int __pad2[2];
1248
1249 long long st_size;
992f48a0 1250 abi_ulong st_blksize;
ce4defa0
PB
1251 unsigned int __pad3;
1252 unsigned long long st_blocks;
1253
992f48a0
BS
1254 abi_ulong target_st_atime;
1255 abi_ulong target_st_atime_nsec;
ce4defa0 1256
992f48a0
BS
1257 abi_ulong target_st_mtime;
1258 abi_ulong target_st_mtime_nsec;
ce4defa0 1259
992f48a0
BS
1260 abi_ulong target_st_ctime;
1261 abi_ulong target_st_ctime_nsec;
ce4defa0
PB
1262
1263 unsigned long long st_ino;
541dc0d4 1264} QEMU_PACKED;
ce4defa0
PB
1265#endif
1266
992f48a0 1267#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
1b8dd648
BS
1268struct target_stat {
1269 unsigned int st_dev;
992f48a0 1270 abi_ulong st_ino;
1b8dd648
BS
1271 unsigned int st_mode;
1272 unsigned int st_nlink;
1273 unsigned int st_uid;
1274 unsigned int st_gid;
1275 unsigned int st_rdev;
992f48a0
BS
1276 abi_long st_size;
1277 abi_long target_st_atime;
1278 abi_long target_st_mtime;
1279 abi_long target_st_ctime;
1280 abi_long st_blksize;
1281 abi_long st_blocks;
1282 abi_ulong __unused4[2];
1b8dd648
BS
1283};
1284
20d155bc 1285#define TARGET_HAS_STRUCT_STAT64
1b8dd648
BS
1286struct target_stat64 {
1287 unsigned char __pad0[6];
1288 unsigned short st_dev;
1289
1290 uint64_t st_ino;
1291 uint64_t st_nlink;
1292
1293 unsigned int st_mode;
1294
1295 unsigned int st_uid;
1296 unsigned int st_gid;
1297
1298 unsigned char __pad2[6];
1299 unsigned short st_rdev;
1300
1301 int64_t st_size;
1302 int64_t st_blksize;
1303
1304 unsigned char __pad4[4];
1305 unsigned int st_blocks;
1306
992f48a0
BS
1307 abi_ulong target_st_atime;
1308 abi_ulong __unused1;
1b8dd648 1309
992f48a0
BS
1310 abi_ulong target_st_mtime;
1311 abi_ulong __unused2;
1b8dd648 1312
992f48a0
BS
1313 abi_ulong target_st_ctime;
1314 abi_ulong __unused3;
1b8dd648 1315
992f48a0 1316 abi_ulong __unused4[3];
1b8dd648
BS
1317};
1318
3bfd9da1
FB
1319#elif defined(TARGET_SPARC)
1320
1321struct target_stat {
1322 unsigned short st_dev;
992f48a0 1323 abi_ulong st_ino;
3bfd9da1
FB
1324 unsigned short st_mode;
1325 short st_nlink;
1326 unsigned short st_uid;
1327 unsigned short st_gid;
1328 unsigned short st_rdev;
992f48a0
BS
1329 abi_long st_size;
1330 abi_long target_st_atime;
1331 abi_ulong __unused1;
1332 abi_long target_st_mtime;
1333 abi_ulong __unused2;
1334 abi_long target_st_ctime;
1335 abi_ulong __unused3;
1336 abi_long st_blksize;
1337 abi_long st_blocks;
1338 abi_ulong __unused4[2];
3bfd9da1
FB
1339};
1340
20d155bc 1341#define TARGET_HAS_STRUCT_STAT64
3bfd9da1
FB
1342struct target_stat64 {
1343 unsigned char __pad0[6];
1344 unsigned short st_dev;
1345
1346 uint64_t st_ino;
1347
1348 unsigned int st_mode;
1349 unsigned int st_nlink;
1350
1351 unsigned int st_uid;
1352 unsigned int st_gid;
1353
1354 unsigned char __pad2[6];
1355 unsigned short st_rdev;
1356
1357 unsigned char __pad3[8];
1358
1359 int64_t st_size;
1360 unsigned int st_blksize;
1361
1362 unsigned char __pad4[8];
1363 unsigned int st_blocks;
1364
1365 unsigned int target_st_atime;
1366 unsigned int __unused1;
1367
1368 unsigned int target_st_mtime;
1369 unsigned int __unused2;
1370
1371 unsigned int target_st_ctime;
1372 unsigned int __unused3;
1373
1374 unsigned int __unused4;
1375 unsigned int __unused5;
1376};
1377
67867308
FB
1378#elif defined(TARGET_PPC)
1379
1380struct target_stat {
e32448e0 1381 abi_ulong st_dev;
992f48a0 1382 abi_ulong st_ino;
325e651f 1383#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
e32448e0 1384 abi_ulong st_nlink;
325e651f
JM
1385 unsigned int st_mode;
1386#else
67867308
FB
1387 unsigned int st_mode;
1388 unsigned short st_nlink;
325e651f 1389#endif
67867308
FB
1390 unsigned int st_uid;
1391 unsigned int st_gid;
e32448e0 1392 abi_ulong st_rdev;
992f48a0
BS
1393 abi_ulong st_size;
1394 abi_ulong st_blksize;
1395 abi_ulong st_blocks;
1396 abi_ulong target_st_atime;
e32448e0 1397 abi_ulong target_st_atime_nsec;
992f48a0 1398 abi_ulong target_st_mtime;
e32448e0 1399 abi_ulong target_st_mtime_nsec;
992f48a0 1400 abi_ulong target_st_ctime;
e32448e0 1401 abi_ulong target_st_ctime_nsec;
992f48a0
BS
1402 abi_ulong __unused4;
1403 abi_ulong __unused5;
325e651f
JM
1404#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1405 abi_ulong __unused6;
1406#endif
67867308
FB
1407};
1408
20d155bc
SW
1409#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
1410#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1411struct QEMU_PACKED target_stat64 {
67867308 1412 unsigned long long st_dev;
67867308 1413 unsigned long long st_ino;
3bfd9da1
FB
1414 unsigned int st_mode;
1415 unsigned int st_nlink;
67867308
FB
1416 unsigned int st_uid;
1417 unsigned int st_gid;
3bfd9da1 1418 unsigned long long st_rdev;
e1ce5e40 1419 unsigned long long __pad0;
e32448e0
JM
1420 long long st_size;
1421 int st_blksize;
e1ce5e40 1422 unsigned int __pad1;
61322e91 1423 long long st_blocks; /* Number 512-byte blocks allocated. */
e32448e0
JM
1424 int target_st_atime;
1425 unsigned int target_st_atime_nsec;
1426 int target_st_mtime;
1427 unsigned int target_st_mtime_nsec;
1428 int target_st_ctime;
1429 unsigned int target_st_ctime_nsec;
1430 unsigned int __unused4;
1431 unsigned int __unused5;
67867308 1432};
20d155bc 1433#endif
67867308 1434
b779e29e
EI
1435#elif defined(TARGET_MICROBLAZE)
1436
1437struct target_stat {
1438 abi_ulong st_dev;
1439 abi_ulong st_ino;
1440 unsigned int st_mode;
1441 unsigned short st_nlink;
1442 unsigned int st_uid;
1443 unsigned int st_gid;
1444 abi_ulong st_rdev;
1445 abi_ulong st_size;
1446 abi_ulong st_blksize;
1447 abi_ulong st_blocks;
1448 abi_ulong target_st_atime;
1449 abi_ulong target_st_atime_nsec;
1450 abi_ulong target_st_mtime;
1451 abi_ulong target_st_mtime_nsec;
1452 abi_ulong target_st_ctime;
1453 abi_ulong target_st_ctime_nsec;
1454 abi_ulong __unused4;
1455 abi_ulong __unused5;
1456};
1457
1458/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
20d155bc 1459#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1460struct QEMU_PACKED target_stat64 {
b779e29e 1461 uint64_t st_dev;
a523eb06
EI
1462#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1463 uint32_t pad0;
1464 uint32_t __st_ino;
1465
b779e29e
EI
1466 uint32_t st_mode;
1467 uint32_t st_nlink;
1468 uint32_t st_uid;
1469 uint32_t st_gid;
1470 uint64_t st_rdev;
21ebeb23 1471 uint64_t __pad1;
b779e29e
EI
1472
1473 int64_t st_size;
21ebeb23
EI
1474 int32_t st_blksize;
1475 uint32_t __pad2;
b779e29e
EI
1476 int64_t st_blocks; /* Number 512-byte blocks allocated. */
1477
1478 int target_st_atime;
a523eb06 1479 unsigned int target_st_atime_nsec;
b779e29e 1480 int target_st_mtime;
a523eb06 1481 unsigned int target_st_mtime_nsec;
b779e29e 1482 int target_st_ctime;
a523eb06
EI
1483 unsigned int target_st_ctime_nsec;
1484 uint64_t st_ino;
b779e29e
EI
1485};
1486
e6e5906b
PB
1487#elif defined(TARGET_M68K)
1488
1489struct target_stat {
1490 unsigned short st_dev;
1491 unsigned short __pad1;
992f48a0 1492 abi_ulong st_ino;
e6e5906b
PB
1493 unsigned short st_mode;
1494 unsigned short st_nlink;
1495 unsigned short st_uid;
1496 unsigned short st_gid;
1497 unsigned short st_rdev;
1498 unsigned short __pad2;
992f48a0
BS
1499 abi_ulong st_size;
1500 abi_ulong st_blksize;
1501 abi_ulong st_blocks;
1502 abi_ulong target_st_atime;
1503 abi_ulong __unused1;
1504 abi_ulong target_st_mtime;
1505 abi_ulong __unused2;
1506 abi_ulong target_st_ctime;
1507 abi_ulong __unused3;
1508 abi_ulong __unused4;
1509 abi_ulong __unused5;
e6e5906b
PB
1510};
1511
1512/* This matches struct stat64 in glibc2.1, hence the absolutely
1513 * insane amounts of padding around dev_t's.
1514 */
20d155bc 1515#define TARGET_HAS_STRUCT_STAT64
e6e5906b
PB
1516struct target_stat64 {
1517 unsigned long long st_dev;
1518 unsigned char __pad1[2];
1519
1520#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1521 abi_ulong __st_ino;
e6e5906b
PB
1522
1523 unsigned int st_mode;
1524 unsigned int st_nlink;
1525
992f48a0
BS
1526 abi_ulong st_uid;
1527 abi_ulong st_gid;
e6e5906b
PB
1528
1529 unsigned long long st_rdev;
1530 unsigned char __pad3[2];
1531
1532 long long st_size;
992f48a0 1533 abi_ulong st_blksize;
e6e5906b 1534
992f48a0
BS
1535 abi_ulong __pad4; /* future possible st_blocks high bits */
1536 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
e6e5906b 1537
992f48a0
BS
1538 abi_ulong target_st_atime;
1539 abi_ulong target_st_atime_nsec;
e6e5906b 1540
992f48a0
BS
1541 abi_ulong target_st_mtime;
1542 abi_ulong target_st_mtime_nsec;
e6e5906b 1543
992f48a0
BS
1544 abi_ulong target_st_ctime;
1545 abi_ulong target_st_ctime_nsec;
e6e5906b
PB
1546
1547 unsigned long long st_ino;
541dc0d4 1548} QEMU_PACKED;
e6e5906b 1549
d26bc211 1550#elif defined(TARGET_ABI_MIPSN64)
540635ba
TS
1551
1552/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
1553struct target_stat {
1554 unsigned int st_dev;
1555 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1556
992f48a0 1557 abi_ulong st_ino;
540635ba
TS
1558
1559 unsigned int st_mode;
1560 unsigned int st_nlink;
1561
1562 int st_uid;
1563 int st_gid;
1564
1565 unsigned int st_rdev;
1566 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1567
992f48a0 1568 abi_ulong st_size;
540635ba
TS
1569
1570 /*
1571 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1572 * but we don't have it under Linux.
1573 */
1574 unsigned int target_st_atime;
1575 unsigned int target_st_atime_nsec;
1576
1577 unsigned int target_st_mtime;
1578 unsigned int target_st_mtime_nsec;
1579
1580 unsigned int target_st_ctime;
1581 unsigned int target_st_ctime_nsec;
1582
1583 unsigned int st_blksize;
1584 unsigned int st_pad2;
1585
992f48a0 1586 abi_ulong st_blocks;
540635ba
TS
1587};
1588
d26bc211 1589#elif defined(TARGET_ABI_MIPSN32)
540635ba
TS
1590
1591struct target_stat {
1592 unsigned st_dev;
1593 int st_pad1[3]; /* Reserved for network id */
1594 unsigned int st_ino;
1595 unsigned int st_mode;
1596 unsigned int st_nlink;
1597 int st_uid;
1598 int st_gid;
1599 unsigned st_rdev;
1600 unsigned int st_pad2[2];
1601 unsigned int st_size;
1602 unsigned int st_pad3;
1603 /*
1604 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1605 * but we don't have it under Linux.
1606 */
1607 unsigned int target_st_atime;
1608 unsigned int target_st_atime_nsec;
1609 unsigned int target_st_mtime;
1610 unsigned int target_st_mtime_nsec;
1611 unsigned int target_st_ctime;
1612 unsigned int target_st_ctime_nsec;
1613 unsigned int st_blksize;
1614 unsigned int st_blocks;
1615 unsigned int st_pad4[14];
1616};
1617
1618/*
1619 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1620 * amounts of padding around dev_t's. The memory layout is the same as of
1621 * struct stat of the 64-bit kernel.
1622 */
1623
20d155bc 1624#define TARGET_HAS_STRUCT_STAT64
540635ba
TS
1625struct target_stat64 {
1626 unsigned int st_dev;
1627 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1628
1629 target_ulong st_ino;
1630
1631 unsigned int st_mode;
1632 unsigned int st_nlink;
1633
1634 int st_uid;
1635 int st_gid;
1636
1637 unsigned int st_rdev;
1638 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1639
1640 int st_size;
1641
1642 /*
1643 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1644 * but we don't have it under Linux.
1645 */
1646 int target_st_atime;
1647 unsigned int target_st_atime_nsec; /* Reserved for st_atime expansion */
1648
1649 int target_st_mtime;
1650 unsigned int target_st_mtime_nsec; /* Reserved for st_mtime expansion */
1651
1652 int target_st_ctime;
1653 unsigned int target_st_ctime_nsec; /* Reserved for st_ctime expansion */
1654
1655 unsigned int st_blksize;
1656 unsigned int st_pad2;
1657
1658 int st_blocks;
1659};
1660
d26bc211 1661#elif defined(TARGET_ABI_MIPSO32)
048f6b4d
FB
1662
1663struct target_stat {
1664 unsigned st_dev;
992f48a0
BS
1665 abi_long st_pad1[3]; /* Reserved for network id */
1666 abi_ulong st_ino;
048f6b4d
FB
1667 unsigned int st_mode;
1668 unsigned int st_nlink;
1669 int st_uid;
1670 int st_gid;
1671 unsigned st_rdev;
992f48a0
BS
1672 abi_long st_pad2[2];
1673 abi_long st_size;
1674 abi_long st_pad3;
048f6b4d
FB
1675 /*
1676 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1677 * but we don't have it under Linux.
1678 */
992f48a0
BS
1679 abi_long target_st_atime;
1680 abi_long target_st_atime_nsec;
1681 abi_long target_st_mtime;
1682 abi_long target_st_mtime_nsec;
1683 abi_long target_st_ctime;
1684 abi_long target_st_ctime_nsec;
1685 abi_long st_blksize;
1686 abi_long st_blocks;
1687 abi_long st_pad4[14];
048f6b4d
FB
1688};
1689
1690/*
1691 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1692 * amounts of padding around dev_t's. The memory layout is the same as of
1693 * struct stat of the 64-bit kernel.
1694 */
1695
20d155bc 1696#define TARGET_HAS_STRUCT_STAT64
048f6b4d 1697struct target_stat64 {
992f48a0
BS
1698 abi_ulong st_dev;
1699 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
048f6b4d
FB
1700
1701 uint64_t st_ino;
1702
1703 unsigned int st_mode;
1704 unsigned int st_nlink;
1705
1706 int st_uid;
1707 int st_gid;
1708
992f48a0
BS
1709 abi_ulong st_rdev;
1710 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
048f6b4d
FB
1711
1712 int64_t st_size;
1713
1714 /*
1715 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1716 * but we don't have it under Linux.
1717 */
992f48a0
BS
1718 abi_long target_st_atime;
1719 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
048f6b4d 1720
992f48a0
BS
1721 abi_long target_st_mtime;
1722 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
048f6b4d 1723
992f48a0
BS
1724 abi_long target_st_ctime;
1725 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
048f6b4d 1726
992f48a0
BS
1727 abi_ulong st_blksize;
1728 abi_ulong st_pad2;
048f6b4d
FB
1729
1730 int64_t st_blocks;
1731};
7a3148a9
JM
1732
1733#elif defined(TARGET_ALPHA)
1734
1735struct target_stat {
1736 unsigned int st_dev;
1737 unsigned int st_ino;
1738 unsigned int st_mode;
1739 unsigned int st_nlink;
1740 unsigned int st_uid;
1741 unsigned int st_gid;
1742 unsigned int st_rdev;
992f48a0
BS
1743 abi_long st_size;
1744 abi_ulong target_st_atime;
1745 abi_ulong target_st_mtime;
1746 abi_ulong target_st_ctime;
7a3148a9
JM
1747 unsigned int st_blksize;
1748 unsigned int st_blocks;
1749 unsigned int st_flags;
1750 unsigned int st_gen;
1751};
1752
20d155bc 1753#define TARGET_HAS_STRUCT_STAT64
7a3148a9 1754struct target_stat64 {
992f48a0
BS
1755 abi_ulong st_dev;
1756 abi_ulong st_ino;
1757 abi_ulong st_rdev;
1758 abi_long st_size;
1759 abi_ulong st_blocks;
7a3148a9
JM
1760
1761 unsigned int st_mode;
1762 unsigned int st_uid;
1763 unsigned int st_gid;
1764 unsigned int st_blksize;
1765 unsigned int st_nlink;
1766 unsigned int __pad0;
1767
992f48a0
BS
1768 abi_ulong target_st_atime;
1769 abi_ulong target_st_atime_nsec;
1770 abi_ulong target_st_mtime;
1771 abi_ulong target_st_mtime_nsec;
1772 abi_ulong target_st_ctime;
1773 abi_ulong target_st_ctime_nsec;
1774 abi_long __unused[3];
7a3148a9
JM
1775};
1776
6db45e65
TS
1777#elif defined(TARGET_SH4)
1778
1779struct target_stat {
992f48a0
BS
1780 abi_ulong st_dev;
1781 abi_ulong st_ino;
6db45e65
TS
1782 unsigned short st_mode;
1783 unsigned short st_nlink;
1784 unsigned short st_uid;
1785 unsigned short st_gid;
992f48a0
BS
1786 abi_ulong st_rdev;
1787 abi_ulong st_size;
1788 abi_ulong st_blksize;
1789 abi_ulong st_blocks;
1790 abi_ulong target_st_atime;
1791 abi_ulong target_st_atime_nsec;
1792 abi_ulong target_st_mtime;
1793 abi_ulong target_st_mtime_nsec;
1794 abi_ulong target_st_ctime;
1795 abi_ulong target_st_ctime_nsec;
1796 abi_ulong __unused4;
1797 abi_ulong __unused5;
6db45e65
TS
1798};
1799
1800/* This matches struct stat64 in glibc2.1, hence the absolutely
1801 * insane amounts of padding around dev_t's.
1802 */
20d155bc 1803#define TARGET_HAS_STRUCT_STAT64
541dc0d4 1804struct QEMU_PACKED target_stat64 {
6db45e65
TS
1805 unsigned long long st_dev;
1806 unsigned char __pad0[4];
1807
1808#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
992f48a0 1809 abi_ulong __st_ino;
6db45e65
TS
1810
1811 unsigned int st_mode;
1812 unsigned int st_nlink;
1813
992f48a0
BS
1814 abi_ulong st_uid;
1815 abi_ulong st_gid;
6db45e65
TS
1816
1817 unsigned long long st_rdev;
1818 unsigned char __pad3[4];
1819
1820 long long st_size;
992f48a0 1821 abi_ulong st_blksize;
6db45e65
TS
1822
1823 unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
1824
992f48a0
BS
1825 abi_ulong target_st_atime;
1826 abi_ulong target_st_atime_nsec;
6db45e65 1827
992f48a0
BS
1828 abi_ulong target_st_mtime;
1829 abi_ulong target_st_mtime_nsec;
6db45e65 1830
992f48a0
BS
1831 abi_ulong target_st_ctime;
1832 abi_ulong target_st_ctime_nsec;
6db45e65
TS
1833
1834 unsigned long long st_ino;
1835};
1836
d2fd1af7
FB
1837#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1838struct target_stat {
1839 abi_ulong st_dev;
1840 abi_ulong st_ino;
1841 abi_ulong st_nlink;
1842
1843 unsigned int st_mode;
1844 unsigned int st_uid;
1845 unsigned int st_gid;
1846 unsigned int __pad0;
1847 abi_ulong st_rdev;
1848 abi_long st_size;
1849 abi_long st_blksize;
1850 abi_long st_blocks; /* Number 512-byte blocks allocated. */
1851
1852 abi_ulong target_st_atime;
1853 abi_ulong target_st_atime_nsec;
1854 abi_ulong target_st_mtime;
1855 abi_ulong target_st_mtime_nsec;
1856 abi_ulong target_st_ctime;
1857 abi_ulong target_st_ctime_nsec;
1858
1859 abi_long __unused[3];
1860};
a4c075f1
UH
1861#elif defined(TARGET_S390X)
1862struct target_stat {
1863 abi_ulong st_dev;
1864 abi_ulong st_ino;
1865 abi_ulong st_nlink;
1866 unsigned int st_mode;
1867 unsigned int st_uid;
1868 unsigned int st_gid;
1869 unsigned int __pad1;
1870 abi_ulong st_rdev;
1871 abi_ulong st_size;
1872 abi_ulong target_st_atime;
1873 abi_ulong target_st_atime_nsec;
1874 abi_ulong target_st_mtime;
1875 abi_ulong target_st_mtime_nsec;
1876 abi_ulong target_st_ctime;
1877 abi_ulong target_st_ctime_nsec;
1878 abi_ulong st_blksize;
1879 abi_long st_blocks;
1880 abi_ulong __unused[3];
1881};
09701199
AG
1882#elif defined(TARGET_AARCH64)
1883struct target_stat {
1884 abi_ulong st_dev;
1885 abi_ulong st_ino;
1886 unsigned int st_mode;
1887 unsigned int st_nlink;
1888 unsigned int st_uid;
1889 unsigned int st_gid;
1890 abi_ulong st_rdev;
1891 abi_ulong _pad1;
1892 abi_long st_size;
1893 int st_blksize;
1894 int __pad2;
1895 abi_long st_blocks;
1896 abi_long target_st_atime;
1897 abi_ulong target_st_atime_nsec;
1898 abi_long target_st_mtime;
1899 abi_ulong target_st_mtime_nsec;
1900 abi_long target_st_ctime;
1901 abi_ulong target_st_ctime_nsec;
1902 unsigned int __unused[2];
1903};
d962783e 1904#elif defined(TARGET_OPENRISC)
c7819dfb
PM
1905
1906/* These are the asm-generic versions of the stat and stat64 structures */
1907
d962783e
JL
1908struct target_stat {
1909 abi_ulong st_dev;
1910 abi_ulong st_ino;
d962783e 1911 unsigned int st_mode;
c7819dfb 1912 unsigned int st_nlink;
d962783e
JL
1913 unsigned int st_uid;
1914 unsigned int st_gid;
d962783e 1915 abi_ulong st_rdev;
c7819dfb 1916 abi_ulong __pad1;
d962783e 1917 abi_long st_size;
c7819dfb
PM
1918 int st_blksize;
1919 int __pad2;
1920 abi_long st_blocks;
1921 abi_long target_st_atime;
d962783e 1922 abi_ulong target_st_atime_nsec;
c7819dfb 1923 abi_long target_st_mtime;
d962783e 1924 abi_ulong target_st_mtime_nsec;
c7819dfb 1925 abi_long target_st_ctime;
d962783e 1926 abi_ulong target_st_ctime_nsec;
c7819dfb
PM
1927 unsigned int __unused4;
1928 unsigned int __unused5;
1929};
d962783e 1930
20d155bc 1931#define TARGET_HAS_STRUCT_STAT64
c7819dfb
PM
1932struct target_stat64 {
1933 uint64_t st_dev;
1934 uint64_t st_ino;
1935 unsigned int st_mode;
1936 unsigned int st_nlink;
1937 unsigned int st_uid;
1938 unsigned int st_gid;
1939 uint64_t st_rdev;
1940 uint64_t __pad1;
1941 int64_t st_size;
1942 int st_blksize;
1943 int __pad2;
1944 int64_t st_blocks;
1945 int target_st_atime;
1946 unsigned int target_st_atime_nsec;
1947 int target_st_mtime;
1948 unsigned int target_st_mtime_nsec;
1949 int target_st_ctime;
1950 unsigned int target_st_ctime_nsec;
1951 unsigned int __unused4;
1952 unsigned int __unused5;
d962783e 1953};
c7819dfb 1954
048f6b4d
FB
1955#else
1956#error unsupported CPU
1957#endif
2521d698 1958
4ce6f8de
TS
1959typedef struct {
1960 int val[2];
c227f099 1961} target_fsid_t;
4ce6f8de 1962
56c8f68f 1963#ifdef TARGET_MIPS
d26bc211 1964#ifdef TARGET_ABI_MIPSN32
540635ba
TS
1965struct target_statfs {
1966 int32_t f_type;
1967 int32_t f_bsize;
1968 int32_t f_frsize; /* Fragment size - unsupported */
1969 int32_t f_blocks;
1970 int32_t f_bfree;
1971 int32_t f_files;
1972 int32_t f_ffree;
1973 int32_t f_bavail;
1974
1975 /* Linux specials */
c227f099 1976 target_fsid_t f_fsid;
540635ba
TS
1977 int32_t f_namelen;
1978 int32_t f_spare[6];
1979};
1980#else
56c8f68f 1981struct target_statfs {
992f48a0
BS
1982 abi_long f_type;
1983 abi_long f_bsize;
1984 abi_long f_frsize; /* Fragment size - unsupported */
1985 abi_long f_blocks;
1986 abi_long f_bfree;
1987 abi_long f_files;
1988 abi_long f_ffree;
1989 abi_long f_bavail;
56c8f68f
FB
1990
1991 /* Linux specials */
c227f099 1992 target_fsid_t f_fsid;
992f48a0
BS
1993 abi_long f_namelen;
1994 abi_long f_spare[6];
56c8f68f 1995};
540635ba 1996#endif
56c8f68f
FB
1997
1998struct target_statfs64 {
1999 uint32_t f_type;
2000 uint32_t f_bsize;
2001 uint32_t f_frsize; /* Fragment size - unsupported */
2002 uint32_t __pad;
2003 uint64_t f_blocks;
2004 uint64_t f_bfree;
2005 uint64_t f_files;
2006 uint64_t f_ffree;
2007 uint64_t f_bavail;
c227f099 2008 target_fsid_t f_fsid;
56c8f68f
FB
2009 uint32_t f_namelen;
2010 uint32_t f_spare[6];
2011};
c4d10628 2012#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
09701199
AG
2013 defined(TARGET_SPARC64) || defined(TARGET_AARCH64)) && \
2014 !defined(TARGET_ABI32)
325e651f
JM
2015struct target_statfs {
2016 abi_long f_type;
2017 abi_long f_bsize;
2018 abi_long f_blocks;
2019 abi_long f_bfree;
2020 abi_long f_bavail;
2021 abi_long f_files;
2022 abi_long f_ffree;
c227f099 2023 target_fsid_t f_fsid;
325e651f
JM
2024 abi_long f_namelen;
2025 abi_long f_frsize;
2026 abi_long f_spare[5];
2027};
2028
2029struct target_statfs64 {
2030 abi_long f_type;
2031 abi_long f_bsize;
2032 abi_long f_blocks;
2033 abi_long f_bfree;
2034 abi_long f_bavail;
2035 abi_long f_files;
2036 abi_long f_ffree;
c227f099 2037 target_fsid_t f_fsid;
325e651f
JM
2038 abi_long f_namelen;
2039 abi_long f_frsize;
2040 abi_long f_spare[5];
2041};
a4c075f1
UH
2042#elif defined(TARGET_S390X)
2043struct target_statfs {
2044 int32_t f_type;
2045 int32_t f_bsize;
2046 abi_long f_blocks;
2047 abi_long f_bfree;
2048 abi_long f_bavail;
2049 abi_long f_files;
2050 abi_long f_ffree;
2051 kernel_fsid_t f_fsid;
2052 int32_t f_namelen;
2053 int32_t f_frsize;
2054 int32_t f_spare[5];
2055};
2056
2057struct target_statfs64 {
2058 int32_t f_type;
2059 int32_t f_bsize;
2060 abi_long f_blocks;
2061 abi_long f_bfree;
2062 abi_long f_bavail;
2063 abi_long f_files;
2064 abi_long f_ffree;
2065 kernel_fsid_t f_fsid;
2066 int32_t f_namelen;
2067 int32_t f_frsize;
2068 int32_t f_spare[5];
2069};
56c8f68f
FB
2070#else
2071struct target_statfs {
2072 uint32_t f_type;
2073 uint32_t f_bsize;
2074 uint32_t f_blocks;
2075 uint32_t f_bfree;
2076 uint32_t f_bavail;
2077 uint32_t f_files;
2078 uint32_t f_ffree;
c227f099 2079 target_fsid_t f_fsid;
56c8f68f
FB
2080 uint32_t f_namelen;
2081 uint32_t f_frsize;
2082 uint32_t f_spare[5];
2083};
2084
2085struct target_statfs64 {
2086 uint32_t f_type;
2087 uint32_t f_bsize;
2088 uint64_t f_blocks;
2089 uint64_t f_bfree;
2090 uint64_t f_bavail;
2091 uint64_t f_files;
2092 uint64_t f_ffree;
c227f099 2093 target_fsid_t f_fsid;
56c8f68f
FB
2094 uint32_t f_namelen;
2095 uint32_t f_frsize;
2096 uint32_t f_spare[5];
2097};
2098#endif
2099
2100
2521d698
FB
2101#define TARGET_F_DUPFD 0 /* dup */
2102#define TARGET_F_GETFD 1 /* get close_on_exec */
2103#define TARGET_F_SETFD 2 /* set/clear close_on_exec */
2104#define TARGET_F_GETFL 3 /* get file->f_flags */
2105#define TARGET_F_SETFL 4 /* set file->f_flags */
2106
2107#if defined(TARGET_ALPHA)
2108#define TARGET_F_GETLK 7
2109#define TARGET_F_SETLK 8
2110#define TARGET_F_SETLKW 9
2111#define TARGET_F_SETOWN 5 /* for sockets. */
2112#define TARGET_F_GETOWN 6 /* for sockets. */
2ba7f730
LV
2113
2114#define TARGET_F_RDLCK 1
2115#define TARGET_F_WRLCK 2
2116#define TARGET_F_UNLCK 8
2117#define TARGET_F_EXLCK 16
2118#define TARGET_F_SHLCK 32
5f106811
APR
2119#elif defined(TARGET_MIPS)
2120#define TARGET_F_GETLK 14
2121#define TARGET_F_SETLK 6
2122#define TARGET_F_SETLKW 7
2123#define TARGET_F_SETOWN 24 /* for sockets. */
2124#define TARGET_F_GETOWN 25 /* for sockets. */
2521d698
FB
2125#else
2126#define TARGET_F_GETLK 5
2127#define TARGET_F_SETLK 6
2128#define TARGET_F_SETLKW 7
2129#define TARGET_F_SETOWN 8 /* for sockets. */
2130#define TARGET_F_GETOWN 9 /* for sockets. */
2131#endif
8d5d3004
AS
2132#define TARGET_F_SETOWN_EX 15
2133#define TARGET_F_GETOWN_EX 16
2521d698 2134
2ba7f730
LV
2135#ifndef TARGET_F_RDLCK
2136#define TARGET_F_RDLCK 0
2137#define TARGET_F_WRLCK 1
2138#define TARGET_F_UNLCK 2
2139#endif
2140
2141#ifndef TARGET_F_EXLCK
2142#define TARGET_F_EXLCK 4
2143#define TARGET_F_SHLCK 8
2144#endif
2145
2146
2521d698
FB
2147#define TARGET_F_SETSIG 10 /* for sockets. */
2148#define TARGET_F_GETSIG 11 /* for sockets. */
2149
5f106811
APR
2150#if defined(TARGET_MIPS)
2151#define TARGET_F_GETLK64 33 /* using 'struct flock64' */
2152#define TARGET_F_SETLK64 34
2153#define TARGET_F_SETLKW64 35
2154#else
2521d698
FB
2155#define TARGET_F_GETLK64 12 /* using 'struct flock64' */
2156#define TARGET_F_SETLK64 13
2157#define TARGET_F_SETLKW64 14
5f106811 2158#endif
7e22e546
UH
2159
2160#define TARGET_F_LINUX_SPECIFIC_BASE 1024
2161#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
2162#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
2163#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
2164#define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
2165
4eeea4f3
RH
2166#if defined(TARGET_ALPHA)
2167#define TARGET_O_NONBLOCK 04
2168#define TARGET_O_APPEND 010
2169#define TARGET_O_CREAT 01000 /* not fcntl */
2170#define TARGET_O_TRUNC 02000 /* not fcntl */
2171#define TARGET_O_EXCL 04000 /* not fcntl */
2172#define TARGET_O_NOCTTY 010000 /* not fcntl */
2173#define TARGET_O_DSYNC 040000
2174#define TARGET_O_LARGEFILE 0 /* not necessary, always 64-bit */
2175#define TARGET_O_DIRECTORY 0100000 /* must be a directory */
2176#define TARGET_O_NOFOLLOW 0200000 /* don't follow links */
2177#define TARGET_O_DIRECT 02000000 /* direct disk access hint */
2178#define TARGET_O_NOATIME 04000000
2179#define TARGET_O_CLOEXEC 010000000
2180#define TARGET___O_SYNC 020000000
2181#define TARGET_O_PATH 040000000
2182#elif defined(TARGET_ARM) || defined(TARGET_M68K)
f09936ac
FB
2183#define TARGET_O_DIRECTORY 040000 /* must be a directory */
2184#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */
2185#define TARGET_O_DIRECT 0200000 /* direct disk access hint */
2186#define TARGET_O_LARGEFILE 0400000
4eeea4f3
RH
2187#elif defined(TARGET_MIPS)
2188#define TARGET_O_APPEND 0x0008
2189#define TARGET_O_DSYNC 0x0010
2190#define TARGET_O_NONBLOCK 0x0080
2191#define TARGET_O_CREAT 0x0100 /* not fcntl */
2192#define TARGET_O_TRUNC 0x0200 /* not fcntl */
2193#define TARGET_O_EXCL 0x0400 /* not fcntl */
2194#define TARGET_O_NOCTTY 0x0800 /* not fcntl */
2195#define TARGET_FASYNC 0x1000 /* fcntl, for BSD compatibility */
2196#define TARGET_O_LARGEFILE 0x2000 /* allow large file opens */
2197#define TARGET___O_SYNC 0x4000
2198#define TARGET_O_DIRECT 0x8000 /* direct disk access hint */
f09936ac 2199#elif defined (TARGET_PPC)
b779e29e
EI
2200#define TARGET_O_DIRECTORY 040000 /* must be a directory */
2201#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */
2202#define TARGET_O_LARGEFILE 0200000
2203#define TARGET_O_DIRECT 0400000 /* direct disk access hint */
6d5e216d 2204#elif defined (TARGET_SPARC)
4eeea4f3
RH
2205#define TARGET_O_APPEND 0x0008
2206#define TARGET_FASYNC 0x0040 /* fcntl, for BSD compatibility */
2207#define TARGET_O_CREAT 0x0200 /* not fcntl */
2208#define TARGET_O_TRUNC 0x0400 /* not fcntl */
2209#define TARGET_O_EXCL 0x0800 /* not fcntl */
2210#define TARGET_O_DSYNC 0x2000
2211#define TARGET_O_NONBLOCK 0x4000
2212# ifdef TARGET_SPARC64
2213# define TARGET_O_NDELAY 0x0004
2214# else
2215# define TARGET_O_NDELAY (0x0004 | TARGET_O_NONBLOCK)
2216# endif
2217#define TARGET_O_NOCTTY 0x8000 /* not fcntl */
6d5e216d 2218#define TARGET_O_LARGEFILE 0x40000
4eeea4f3
RH
2219#define TARGET_O_DIRECT 0x100000 /* direct disk access hint */
2220#define TARGET_O_NOATIME 0x200000
2221#define TARGET_O_CLOEXEC 0x400000
2222#define TARGET___O_SYNC 0x800000
2223#define TARGET_O_PATH 0x1000000
2224#endif
2225
2226/* <asm-generic/fcntl.h> values follow. */
ffa65c3b
FB
2227#define TARGET_O_ACCMODE 0003
2228#define TARGET_O_RDONLY 00
2229#define TARGET_O_WRONLY 01
2230#define TARGET_O_RDWR 02
4eeea4f3 2231#ifndef TARGET_O_CREAT
ffa65c3b 2232#define TARGET_O_CREAT 0100 /* not fcntl */
4eeea4f3
RH
2233#endif
2234#ifndef TARGET_O_EXCL
ffa65c3b 2235#define TARGET_O_EXCL 0200 /* not fcntl */
4eeea4f3
RH
2236#endif
2237#ifndef TARGET_O_NOCTTY
ffa65c3b 2238#define TARGET_O_NOCTTY 0400 /* not fcntl */
4eeea4f3
RH
2239#endif
2240#ifndef TARGET_O_TRUNC
ffa65c3b 2241#define TARGET_O_TRUNC 01000 /* not fcntl */
4eeea4f3
RH
2242#endif
2243#ifndef TARGET_O_APPEND
ffa65c3b 2244#define TARGET_O_APPEND 02000
4eeea4f3
RH
2245#endif
2246#ifndef TARGET_O_NONBLOCK
ffa65c3b 2247#define TARGET_O_NONBLOCK 04000
4eeea4f3
RH
2248#endif
2249#ifndef TARGET_O_DSYNC
2250#define TARGET_O_DSYNC 010000
2251#endif
2252#ifndef TARGET_FASYNC
ffa65c3b 2253#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
4eeea4f3
RH
2254#endif
2255#ifndef TARGET_O_DIRECT
ffa65c3b 2256#define TARGET_O_DIRECT 040000 /* direct disk access hint */
4eeea4f3
RH
2257#endif
2258#ifndef TARGET_O_LARGEFILE
ffa65c3b 2259#define TARGET_O_LARGEFILE 0100000
4eeea4f3
RH
2260#endif
2261#ifndef TARGET_O_DIRECTORY
ffa65c3b 2262#define TARGET_O_DIRECTORY 0200000 /* must be a directory */
4eeea4f3
RH
2263#endif
2264#ifndef TARGET_O_NOFOLLOW
ffa65c3b
FB
2265#define TARGET_O_NOFOLLOW 0400000 /* don't follow links */
2266#endif
4eeea4f3
RH
2267#ifndef TARGET_O_NOATIME
2268#define TARGET_O_NOATIME 01000000
2269#endif
2270#ifndef TARGET_O_CLOEXEC
2271#define TARGET_O_CLOEXEC 02000000
2272#endif
2273#ifndef TARGET___O_SYNC
2274#define TARGET___O_SYNC 04000000
2275#endif
2276#ifndef TARGET_O_PATH
2277#define TARGET_O_PATH 010000000
2278#endif
2279#ifndef TARGET_O_NDELAY
2280#define TARGET_O_NDELAY TARGET_O_NONBLOCK
2281#endif
2282#ifndef TARGET_O_SYNC
2283#define TARGET_O_SYNC (TARGET___O_SYNC | TARGET_O_DSYNC)
2284#endif
ffa65c3b 2285
2521d698
FB
2286struct target_flock {
2287 short l_type;
2288 short l_whence;
992f48a0
BS
2289 abi_ulong l_start;
2290 abi_ulong l_len;
2521d698
FB
2291 int l_pid;
2292};
2293
2294struct target_flock64 {
2295 short l_type;
2296 short l_whence;
b779e29e 2297#if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) || defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined (TARGET_MICROBLAZE)
ce3f0e2f
AJ
2298 int __pad;
2299#endif
2521d698
FB
2300 unsigned long long l_start;
2301 unsigned long long l_len;
2302 int l_pid;
541dc0d4 2303} QEMU_PACKED;
2521d698 2304
ce4defa0
PB
2305#ifdef TARGET_ARM
2306struct target_eabi_flock64 {
2307 short l_type;
2308 short l_whence;
2309 int __pad;
2310 unsigned long long l_start;
2311 unsigned long long l_len;
2312 int l_pid;
541dc0d4 2313} QEMU_PACKED;
ce4defa0 2314#endif
2521d698 2315
8d5d3004
AS
2316struct target_f_owner_ex {
2317 int type; /* Owner type of ID. */
2318 int pid; /* ID of owner. */
2319};
2320
2521d698
FB
2321/* soundcard defines */
2322/* XXX: convert them all to arch indepedent entries */
2323#define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
2324#define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
2325#define TARGET_SNDCTL_COPR_RCODE 0xc0144303
2326#define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
2327#define TARGET_SNDCTL_COPR_RDATA 0xc0144302
2328#define TARGET_SNDCTL_COPR_RESET 0x00004300
2329#define TARGET_SNDCTL_COPR_RUN 0xc0144306
2330#define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
2331#define TARGET_SNDCTL_COPR_WCODE 0x40144305
2332#define TARGET_SNDCTL_COPR_WDATA 0x40144304
2333#define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
2334#define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
2335#define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
2336#define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
2337#define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
2338#define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
2339#define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
2340#define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
2341#define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
2342#define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
2343#define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
2344#define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
2345#define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
2346#define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
2347#define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
2348#define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
2349#define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
2350#define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
5f72307d
PM
2351#define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
2352#define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
2521d698
FB
2353#define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
2354#define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
2355#define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
2356#define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
2357#define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
2358#define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
2359#define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
2360#define TARGET_SNDCTL_MIDI_INFO 0xc074510c
2361#define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
2362#define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
2363#define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
2364#define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
2365#define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
2366#define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
2367#define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
2368#define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
2369#define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
2370#define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
2371#define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
2372#define TARGET_SNDCTL_SEQ_PANIC 0x00005111
2373#define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
2374#define TARGET_SNDCTL_SEQ_RESET 0x00005100
2375#define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
2376#define TARGET_SNDCTL_SEQ_SYNC 0x00005101
2377#define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
2378#define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
2379#define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
2380#define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
2381#define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
2382#define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
2383#define TARGET_SNDCTL_TMR_METRONOME 0x40045407
2384#define TARGET_SNDCTL_TMR_SELECT 0x40045408
2385#define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
2386#define TARGET_SNDCTL_TMR_START 0x00005402
2387#define TARGET_SNDCTL_TMR_STOP 0x00005403
2388#define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
2389#define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
2390#define TARGET_SOUND_PCM_READ_RATE 0x80045002
2391#define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
2392#define TARGET_SOUND_PCM_READ_BITS 0x80045005
2393#define TARGET_SOUND_PCM_READ_FILTER 0x80045007
2394#define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
2395#define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
2396#define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
2397#define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
2398#define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
2399#define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
2400#define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
2401
2402#define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
2403
2404#define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
2405#define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
2406#define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
2407#define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
2408#define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
2409#define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
2410#define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
2411#define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
2412#define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
2413#define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
2414#define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
2415#define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
2416#define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
2417#define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
2418#define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
2419#define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
2420#define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
2421
2422/* Obsolete macros */
2423#define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
2424#define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
2425#define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
2426
2427#define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
2428#define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
2429#define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
2430#define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
2431#define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
2432
2433#define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
2434
2435#define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
2436#define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
2437#define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
2438#define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
2439#define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
2440#define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
2441#define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
2442#define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
2443#define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
2444#define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
2445#define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
2446#define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
2447#define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
2448#define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
2449#define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
2450#define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
2451#define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
2452
2453/* Obsolete macros */
2454#define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
2455#define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
2456#define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
2457
2458#define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
2459
2460/* vfat ioctls */
2461#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
2462#define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
a5448a7d 2463
8fbd6b52
AZ
2464#define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct mtop)
2465#define TARGET_MTIOCGET TARGET_IOR('m', 2, struct mtget)
2466#define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct mtpos)
2467
a5448a7d 2468struct target_sysinfo {
992f48a0
BS
2469 abi_long uptime; /* Seconds since boot */
2470 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
2471 abi_ulong totalram; /* Total usable main memory size */
2472 abi_ulong freeram; /* Available memory size */
2473 abi_ulong sharedram; /* Amount of shared memory */
2474 abi_ulong bufferram; /* Memory used by buffers */
2475 abi_ulong totalswap; /* Total swap space size */
2476 abi_ulong freeswap; /* swap space still available */
a5448a7d
FB
2477 unsigned short procs; /* Number of current processes */
2478 unsigned short pad; /* explicit padding for m68k */
992f48a0
BS
2479 abi_ulong totalhigh; /* Total high memory size */
2480 abi_ulong freehigh; /* Available high memory size */
a5448a7d 2481 unsigned int mem_unit; /* Memory unit size in bytes */
992f48a0 2482 char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
a5448a7d 2483};
3532fa74 2484
6556a833
AJ
2485struct linux_dirent {
2486 long d_ino;
2487 unsigned long d_off;
2488 unsigned short d_reclen;
2489 char d_name[256]; /* We must not include limits.h! */
2490};
2491
2492struct linux_dirent64 {
2493 uint64_t d_ino;
2494 int64_t d_off;
2495 unsigned short d_reclen;
2496 unsigned char d_type;
2497 char d_name[256];
2498};
2499
24e1003a
AJ
2500struct target_mq_attr {
2501 abi_long mq_flags;
2502 abi_long mq_maxmsg;
2503 abi_long mq_msgsize;
2504 abi_long mq_curmsgs;
2505};
2506
3532fa74 2507#include "socket.h"
637947f1
TS
2508
2509#include "errno_defs.h"
03dfe9f8
RV
2510
2511#define FUTEX_WAIT 0
2512#define FUTEX_WAKE 1
2513#define FUTEX_FD 2
2514#define FUTEX_REQUEUE 3
2515#define FUTEX_CMP_REQUEUE 4
2516#define FUTEX_WAKE_OP 5
2517#define FUTEX_LOCK_PI 6
2518#define FUTEX_UNLOCK_PI 7
2519#define FUTEX_TRYLOCK_PI 8
2520#define FUTEX_WAIT_BITSET 9
2521#define FUTEX_WAKE_BITSET 10
2522
2523#define FUTEX_PRIVATE_FLAG 128
2524#define FUTEX_CLOCK_REALTIME 256
2525#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2526
3b6edd16
PM
2527#ifdef CONFIG_EPOLL
2528typedef union target_epoll_data {
2529 abi_ulong ptr;
2530 abi_ulong fd;
2531 uint32_t u32;
2532 uint64_t u64;
2533} target_epoll_data_t;
2534
2535struct target_epoll_event {
2536 uint32_t events;
fd767832 2537#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_MIPS64)
ddaa7e5a
AG
2538 uint32_t __pad;
2539#endif
3b6edd16 2540 target_epoll_data_t data;
ddaa7e5a 2541} QEMU_PACKED;
3b6edd16 2542#endif
163a05a8
PM
2543struct target_rlimit64 {
2544 uint64_t rlim_cur;
2545 uint64_t rlim_max;
2546};
583359a6
AP
2547
2548struct target_ucred {
2549 uint32_t pid;
2550 uint32_t uid;
2551 uint32_t gid;
2552};
cb9c377f
PB
2553
2554#endif
905bba13
ECL
2555
2556
2557struct target_timer_t {
2558 abi_ulong ptr;
2559};
2560
34d60862
NC
2561#define TARGET_SIGEV_MAX_SIZE 64
2562
2563/* This is architecture-specific but most architectures use the default */
2564#ifdef TARGET_MIPS
2565#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
2566#else
2567#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
2568 + sizeof(target_sigval_t))
2569#endif
2570
2571#define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
2572 - TARGET_SIGEV_PREAMBLE_SIZE) \
2573 / sizeof(int32_t))
2574
905bba13
ECL
2575struct target_sigevent {
2576 target_sigval_t sigev_value;
2577 int32_t sigev_signo;
2578 int32_t sigev_notify;
2579 union {
34d60862 2580 int32_t _pad[TARGET_SIGEV_PAD_SIZE];
905bba13
ECL
2581 int32_t _tid;
2582
2583 struct {
2584 void (*_function)(sigval_t);
2585 void *_attribute;
2586 } _sigev_thread;
2587 } _sigev_un;
2588};
e0eb210e
PM
2589
2590struct target_user_cap_header {
2591 uint32_t version;
2592 int pid;
2593};
2594
2595struct target_user_cap_data {
2596 uint32_t effective;
2597 uint32_t permitted;
2598 uint32_t inheritable;
2599};