blob: 2857805e1635e48291fc6aaacb798ca96737b34d [file] [log] [blame]
bellard31e31b82003-02-18 22:55:36 +00001/* common syscall defines for all architectures */
2
bellard2521d692003-06-15 19:58:13 +00003/* Note: although the syscall numbers change between architectures,
Dong Xu Wangb4916d72011-11-22 18:06:17 +08004 most of them stay the same, so we handle it by putting ifdefs if
bellard2521d692003-06-15 19:58:13 +00005 necessary */
6
bellard6180a182003-09-30 21:04:53 +00007#include "syscall_nr.h"
bellard2521d692003-06-15 19:58:13 +00008
bellard31e31b82003-02-18 22:55:36 +00009#define SOCKOP_socket 1
10#define SOCKOP_bind 2
11#define SOCKOP_connect 3
12#define SOCKOP_listen 4
13#define SOCKOP_accept 5
14#define SOCKOP_getsockname 6
15#define SOCKOP_getpeername 7
16#define SOCKOP_socketpair 8
17#define SOCKOP_send 9
18#define SOCKOP_recv 10
19#define SOCKOP_sendto 11
20#define SOCKOP_recvfrom 12
21#define SOCKOP_shutdown 13
22#define SOCKOP_setsockopt 14
23#define SOCKOP_getsockopt 15
24#define SOCKOP_sendmsg 16
25#define SOCKOP_recvmsg 17
26
bellard8853f862004-02-22 14:57:26 +000027#define IPCOP_semop 1
28#define IPCOP_semget 2
29#define IPCOP_semctl 3
30#define IPCOP_semtimedop 4
31#define IPCOP_msgsnd 11
32#define IPCOP_msgrcv 12
33#define IPCOP_msgget 13
34#define IPCOP_msgctl 14
35#define IPCOP_shmat 21
36#define IPCOP_shmdt 22
37#define IPCOP_shmget 23
38#define IPCOP_shmctl 24
39
bellard2521d692003-06-15 19:58:13 +000040/*
41 * The following is for compatibility across the various Linux
42 * platforms. The i386 ioctl numbering scheme doesn't really enforce
43 * a type field. De facto, however, the top 8 bits of the lower 16
44 * bits are indeed used as a type field, so we might just as well make
45 * this explicit here. Please be sure to use the decoding macros
46 * below from now on.
47 */
48#define TARGET_IOC_NRBITS 8
49#define TARGET_IOC_TYPEBITS 8
50
Mika Westerberg74d753a2009-04-07 16:57:29 +030051#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
Riku Voipio0c866a72011-04-18 15:23:06 +030052 || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
Mika Westerberg74d753a2009-04-07 16:57:29 +030053 /* 16 bit uid wrappers emulation */
54#define USE_UID16
Riku Voipio0c866a72011-04-18 15:23:06 +030055#define target_id uint16_t
56#else
57#define target_id uint32_t
Mika Westerberg74d753a2009-04-07 16:57:29 +030058#endif
59
pbrooke6e59062006-10-22 00:18:54 +000060#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
Ulrich Hechta4c075f2009-07-24 16:57:31 +020061 || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \
62 || defined(TARGET_S390X)
bellard2521d692003-06-15 19:58:13 +000063
64#define TARGET_IOC_SIZEBITS 14
65#define TARGET_IOC_DIRBITS 2
66
67#define TARGET_IOC_NONE 0U
68#define TARGET_IOC_WRITE 1U
69#define TARGET_IOC_READ 2U
70
bellard048f6b42005-11-26 18:47:20 +000071#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +020072 defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
73 defined(TARGET_MIPS)
bellard2521d692003-06-15 19:58:13 +000074
75#define TARGET_IOC_SIZEBITS 13
76#define TARGET_IOC_DIRBITS 3
77
78#define TARGET_IOC_NONE 1U
79#define TARGET_IOC_READ 2U
80#define TARGET_IOC_WRITE 4U
81
82#else
83#error unsupported CPU
84#endif
85
86#define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
87#define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
88#define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
89#define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
90
91#define TARGET_IOC_NRSHIFT 0
92#define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
93#define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
94#define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
95
96#define TARGET_IOC(dir,type,nr,size) \
97 (((dir) << TARGET_IOC_DIRSHIFT) | \
98 ((type) << TARGET_IOC_TYPESHIFT) | \
99 ((nr) << TARGET_IOC_NRSHIFT) | \
100 ((size) << TARGET_IOC_SIZESHIFT))
101
102/* used to create numbers */
103#define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
104#define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
105#define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
106#define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
107
108/* the size is automatically computed for these defines */
109#define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
110#define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
111#define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
112
bellard7854b052003-03-29 17:22:23 +0000113struct target_sockaddr {
114 uint16_t sa_family;
115 uint8_t sa_data[14];
116};
117
Lionel Landwerlinb975b832009-04-25 23:30:19 +0200118struct target_in_addr {
119 uint32_t s_addr; /* big endian */
120};
121
122struct target_ip_mreq {
123 struct target_in_addr imr_multiaddr;
124 struct target_in_addr imr_address;
125};
126
127struct target_ip_mreqn {
128 struct target_in_addr imr_multiaddr;
129 struct target_in_addr imr_address;
130 abi_long imr_ifindex;
131};
132
Lionel Landwerlin6e3cb582009-04-25 23:31:18 +0200133struct target_ip_mreq_source {
134 /* big endian */
135 uint32_t imr_multiaddr;
136 uint32_t imr_interface;
137 uint32_t imr_sourceaddr;
138};
139
bellard31e31b82003-02-18 22:55:36 +0000140struct target_timeval {
blueswir1992f48a2007-10-14 16:27:31 +0000141 abi_long tv_sec;
142 abi_long tv_usec;
bellard31e31b82003-02-18 22:55:36 +0000143};
144
bellard1b6b0292003-03-22 17:31:38 +0000145struct target_timespec {
blueswir1992f48a2007-10-14 16:27:31 +0000146 abi_long tv_sec;
147 abi_long tv_nsec;
bellard1b6b0292003-03-22 17:31:38 +0000148};
149
bellard66fb9762003-03-23 01:06:05 +0000150struct target_itimerval {
151 struct target_timeval it_interval;
152 struct target_timeval it_value;
153};
154
Anthony Liguoric227f092009-10-01 16:12:16 -0500155typedef abi_long target_clock_t;
bellard32f36bc2003-03-30 21:29:48 +0000156
bellardc596ed12003-07-13 17:32:31 +0000157#define TARGET_HZ 100
158
bellard32f36bc2003-03-30 21:29:48 +0000159struct target_tms {
Anthony Liguoric227f092009-10-01 16:12:16 -0500160 target_clock_t tms_utime;
161 target_clock_t tms_stime;
162 target_clock_t tms_cutime;
163 target_clock_t tms_cstime;
bellard32f36bc2003-03-30 21:29:48 +0000164};
165
bellard6180a182003-09-30 21:04:53 +0000166struct target_utimbuf {
blueswir1992f48a2007-10-14 16:27:31 +0000167 abi_long actime;
168 abi_long modtime;
bellard6180a182003-09-30 21:04:53 +0000169};
170
bellardf2674e32003-07-09 12:26:09 +0000171struct target_sel_arg_struct {
blueswir1992f48a2007-10-14 16:27:31 +0000172 abi_long n;
173 abi_long inp, outp, exp;
174 abi_long tvp;
bellardf2674e32003-07-09 12:26:09 +0000175};
176
bellard31e31b82003-02-18 22:55:36 +0000177struct target_iovec {
blueswir1992f48a2007-10-14 16:27:31 +0000178 abi_long iov_base; /* Starting address */
179 abi_long iov_len; /* Number of bytes */
bellard31e31b82003-02-18 22:55:36 +0000180};
181
bellard1a9353d2003-03-16 20:28:50 +0000182struct target_msghdr {
blueswir1992f48a2007-10-14 16:27:31 +0000183 abi_long msg_name; /* Socket name */
184 int msg_namelen; /* Length of name */
185 abi_long msg_iov; /* Data blocks */
186 abi_long msg_iovlen; /* Number of blocks */
187 abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
188 abi_long msg_controllen; /* Length of cmsg list */
bellard1a9353d2003-03-16 20:28:50 +0000189 unsigned int msg_flags;
190};
191
bellard7854b052003-03-29 17:22:23 +0000192struct target_cmsghdr {
blueswir1992f48a2007-10-14 16:27:31 +0000193 abi_long cmsg_len;
bellard7854b052003-03-29 17:22:23 +0000194 int cmsg_level;
195 int cmsg_type;
196};
197
198#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
199#define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
blueswir1992f48a2007-10-14 16:27:31 +0000200#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
201 & (size_t) ~(sizeof (abi_long) - 1))
bellard7854b052003-03-29 17:22:23 +0000202#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
203 + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
204#define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
205
206static __inline__ struct target_cmsghdr *
207__target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
208{
ths2b8bdef2007-05-28 21:35:23 +0000209 struct target_cmsghdr *__ptr;
bellard7854b052003-03-29 17:22:23 +0000210
ths2b8bdef2007-05-28 21:35:23 +0000211 __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
Matthias Brauncbb21ee2011-08-12 19:57:41 +0200212 + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
213 if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control))
214 > tswapal(__mhdr->msg_controllen))
bellard7854b052003-03-29 17:22:23 +0000215 /* No more entries. */
ths2b8bdef2007-05-28 21:35:23 +0000216 return (struct target_cmsghdr *)0;
bellard7854b052003-03-29 17:22:23 +0000217 return __cmsg;
218}
219
220
bellard31e31b82003-02-18 22:55:36 +0000221struct target_rusage {
222 struct target_timeval ru_utime; /* user time used */
223 struct target_timeval ru_stime; /* system time used */
blueswir1992f48a2007-10-14 16:27:31 +0000224 abi_long ru_maxrss; /* maximum resident set size */
225 abi_long ru_ixrss; /* integral shared memory size */
226 abi_long ru_idrss; /* integral unshared data size */
227 abi_long ru_isrss; /* integral unshared stack size */
228 abi_long ru_minflt; /* page reclaims */
229 abi_long ru_majflt; /* page faults */
230 abi_long ru_nswap; /* swaps */
231 abi_long ru_inblock; /* block input operations */
232 abi_long ru_oublock; /* block output operations */
233 abi_long ru_msgsnd; /* messages sent */
234 abi_long ru_msgrcv; /* messages received */
235 abi_long ru_nsignals; /* signals received */
236 abi_long ru_nvcsw; /* voluntary context switches */
237 abi_long ru_nivcsw; /* involuntary " */
bellard31e31b82003-02-18 22:55:36 +0000238};
239
240typedef struct {
241 int val[2];
Anthony Liguoric227f092009-10-01 16:12:16 -0500242} kernel_fsid_t;
bellard31e31b82003-02-18 22:55:36 +0000243
bellard72f03902003-02-18 23:33:18 +0000244struct kernel_statfs {
bellard31e31b82003-02-18 22:55:36 +0000245 int f_type;
246 int f_bsize;
247 int f_blocks;
248 int f_bfree;
249 int f_bavail;
250 int f_files;
251 int f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -0500252 kernel_fsid_t f_fsid;
bellard31e31b82003-02-18 22:55:36 +0000253 int f_namelen;
254 int f_spare[6];
255};
256
bellarddab2ed92003-03-22 15:23:14 +0000257struct target_dirent {
blueswir1992f48a2007-10-14 16:27:31 +0000258 abi_long d_ino;
259 abi_long d_off;
bellarddab2ed92003-03-22 15:23:14 +0000260 unsigned short d_reclen;
261 char d_name[256]; /* We must not include limits.h! */
262};
263
264struct target_dirent64 {
265 uint64_t d_ino;
266 int64_t d_off;
267 unsigned short d_reclen;
268 unsigned char d_type;
269 char d_name[256];
270};
271
272
bellard31e31b82003-02-18 22:55:36 +0000273/* mostly generic signal stuff */
blueswir1992f48a2007-10-14 16:27:31 +0000274#define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
275#define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
276#define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
bellard31e31b82003-02-18 22:55:36 +0000277
278#ifdef TARGET_MIPS
279#define TARGET_NSIG 128
280#else
281#define TARGET_NSIG 64
282#endif
blueswir1992f48a2007-10-14 16:27:31 +0000283#define TARGET_NSIG_BPW TARGET_ABI_BITS
bellard31e31b82003-02-18 22:55:36 +0000284#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
285
286typedef struct {
blueswir1992f48a2007-10-14 16:27:31 +0000287 abi_ulong sig[TARGET_NSIG_WORDS];
Anthony Liguoric227f092009-10-01 16:12:16 -0500288} target_sigset_t;
bellard31e31b82003-02-18 22:55:36 +0000289
bellard66fb9762003-03-23 01:06:05 +0000290#ifdef BSWAP_NEEDED
Anthony Liguoric227f092009-10-01 16:12:16 -0500291static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
bellard66fb9762003-03-23 01:06:05 +0000292{
293 int i;
294 for(i = 0;i < TARGET_NSIG_WORDS; i++)
Matthias Brauncbb21ee2011-08-12 19:57:41 +0200295 d->sig[i] = tswapal(s->sig[i]);
bellard66fb9762003-03-23 01:06:05 +0000296}
297#else
Anthony Liguoric227f092009-10-01 16:12:16 -0500298static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
bellard66fb9762003-03-23 01:06:05 +0000299{
300 *d = *s;
301}
302#endif
303
Anthony Liguoric227f092009-10-01 16:12:16 -0500304static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
bellard66fb9762003-03-23 01:06:05 +0000305{
306 int i;
307 d->sig[0] = set;
308 for(i = 1;i < TARGET_NSIG_WORDS; i++)
309 d->sig[i] = 0;
310}
311
Anthony Liguoric227f092009-10-01 16:12:16 -0500312void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
313void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
blueswir1992f48a2007-10-14 16:27:31 +0000314void host_to_target_old_sigset(abi_ulong *old_sigset,
bellard66fb9762003-03-23 01:06:05 +0000315 const sigset_t *sigset);
ths5fafdf22007-09-16 21:08:06 +0000316void target_to_host_old_sigset(sigset_t *sigset,
blueswir1992f48a2007-10-14 16:27:31 +0000317 const abi_ulong *old_sigset);
bellard66fb9762003-03-23 01:06:05 +0000318struct target_sigaction;
319int do_sigaction(int sig, const struct target_sigaction *act,
320 struct target_sigaction *oact);
321
Guan Xuetaod2fbca92011-04-12 16:27:03 +0800322#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
323 || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
324 || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
Ulrich Hechta4c075f2009-07-24 16:57:31 +0200325 || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
326 || defined(TARGET_S390X)
bellard2521d692003-06-15 19:58:13 +0000327
bellard048f6b42005-11-26 18:47:20 +0000328#if defined(TARGET_SPARC)
329#define TARGET_SA_NOCLDSTOP 8u
330#define TARGET_SA_NOCLDWAIT 0x100u
331#define TARGET_SA_SIGINFO 0x200u
332#define TARGET_SA_ONSTACK 1u
333#define TARGET_SA_RESTART 2u
334#define TARGET_SA_NODEFER 0x20u
335#define TARGET_SA_RESETHAND 4u
336#elif defined(TARGET_MIPS)
337#define TARGET_SA_NOCLDSTOP 0x00000001
338#define TARGET_SA_NOCLDWAIT 0x00010000
339#define TARGET_SA_SIGINFO 0x00000008
340#define TARGET_SA_ONSTACK 0x08000000
341#define TARGET_SA_NODEFER 0x40000000
342#define TARGET_SA_RESTART 0x10000000
343#define TARGET_SA_RESETHAND 0x80000000
thsd26bc212007-11-08 18:05:37 +0000344#if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
345#define TARGET_SA_RESTORER 0x04000000 /* Only for O32 */
ths540635b2007-09-30 01:58:33 +0000346#endif
Richard Henderson57f18a92010-05-03 10:07:51 -0700347#elif defined(TARGET_ALPHA)
348#define TARGET_SA_ONSTACK 0x00000001
349#define TARGET_SA_RESTART 0x00000002
350#define TARGET_SA_NOCLDSTOP 0x00000004
351#define TARGET_SA_NODEFER 0x00000008
352#define TARGET_SA_RESETHAND 0x00000010
353#define TARGET_SA_NOCLDWAIT 0x00000020 /* not supported yet */
354#define TARGET_SA_SIGINFO 0x00000040
bellard048f6b42005-11-26 18:47:20 +0000355#else
bellard2521d692003-06-15 19:58:13 +0000356#define TARGET_SA_NOCLDSTOP 0x00000001
357#define TARGET_SA_NOCLDWAIT 0x00000002 /* not supported yet */
358#define TARGET_SA_SIGINFO 0x00000004
359#define TARGET_SA_ONSTACK 0x08000000
360#define TARGET_SA_RESTART 0x10000000
361#define TARGET_SA_NODEFER 0x40000000
362#define TARGET_SA_RESETHAND 0x80000000
363#define TARGET_SA_RESTORER 0x04000000
bellard6d5e2162004-09-30 22:04:13 +0000364#endif
365
366#if defined(TARGET_SPARC)
367
368#define TARGET_SIGHUP 1
369#define TARGET_SIGINT 2
370#define TARGET_SIGQUIT 3
371#define TARGET_SIGILL 4
372#define TARGET_SIGTRAP 5
373#define TARGET_SIGABRT 6
374#define TARGET_SIGIOT 6
375#define TARGET_SIGSTKFLT 7 /* actually EMT */
376#define TARGET_SIGFPE 8
377#define TARGET_SIGKILL 9
378#define TARGET_SIGBUS 10
379#define TARGET_SIGSEGV 11
380#define TARGET_SIGSYS 12
381#define TARGET_SIGPIPE 13
382#define TARGET_SIGALRM 14
383#define TARGET_SIGTERM 15
384#define TARGET_SIGURG 16
385#define TARGET_SIGSTOP 17
386#define TARGET_SIGTSTP 18
387#define TARGET_SIGCONT 19
388#define TARGET_SIGCHLD 20
389#define TARGET_SIGTTIN 21
390#define TARGET_SIGTTOU 22
391#define TARGET_SIGIO 23
392#define TARGET_SIGXCPU 24
393#define TARGET_SIGXFSZ 25
394#define TARGET_SIGVTALRM 26
395#define TARGET_SIGPROF 27
396#define TARGET_SIGWINCH 28
397#define TARGET_SIGPWR 29
398#define TARGET_SIGUSR1 30
399#define TARGET_SIGUSR2 31
400#define TARGET_SIGRTMIN 32
401
402#define TARGET_SIG_BLOCK 0x01 /* for blocking signals */
403#define TARGET_SIG_UNBLOCK 0x02 /* for unblocking signals */
404#define TARGET_SIG_SETMASK 0x04 /* for setting the signal mask */
405
bellard048f6b42005-11-26 18:47:20 +0000406#elif defined(TARGET_MIPS)
407
408#define TARGET_SIGHUP 1 /* Hangup (POSIX). */
409#define TARGET_SIGINT 2 /* Interrupt (ANSI). */
410#define TARGET_SIGQUIT 3 /* Quit (POSIX). */
411#define TARGET_SIGILL 4 /* Illegal instruction (ANSI). */
412#define TARGET_SIGTRAP 5 /* Trace trap (POSIX). */
413#define TARGET_SIGIOT 6 /* IOT trap (4.2 BSD). */
414#define TARGET_SIGABRT TARGET_SIGIOT /* Abort (ANSI). */
415#define TARGET_SIGEMT 7
416#define TARGET_SIGSTKFLT 7 /* XXX: incorrect */
417#define TARGET_SIGFPE 8 /* Floating-point exception (ANSI). */
418#define TARGET_SIGKILL 9 /* Kill, unblockable (POSIX). */
419#define TARGET_SIGBUS 10 /* BUS error (4.2 BSD). */
420#define TARGET_SIGSEGV 11 /* Segmentation violation (ANSI). */
421#define TARGET_SIGSYS 12
422#define TARGET_SIGPIPE 13 /* Broken pipe (POSIX). */
423#define TARGET_SIGALRM 14 /* Alarm clock (POSIX). */
424#define TARGET_SIGTERM 15 /* Termination (ANSI). */
425#define TARGET_SIGUSR1 16 /* User-defined signal 1 (POSIX). */
426#define TARGET_SIGUSR2 17 /* User-defined signal 2 (POSIX). */
427#define TARGET_SIGCHLD 18 /* Child status has changed (POSIX). */
428#define TARGET_SIGCLD TARGET_SIGCHLD /* Same as TARGET_SIGCHLD (System V). */
429#define TARGET_SIGPWR 19 /* Power failure restart (System V). */
430#define TARGET_SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
431#define TARGET_SIGURG 21 /* Urgent condition on socket (4.2 BSD). */
432#define TARGET_SIGIO 22 /* I/O now possible (4.2 BSD). */
433#define TARGET_SIGPOLL TARGET_SIGIO /* Pollable event occurred (System V). */
434#define TARGET_SIGSTOP 23 /* Stop, unblockable (POSIX). */
435#define TARGET_SIGTSTP 24 /* Keyboard stop (POSIX). */
436#define TARGET_SIGCONT 25 /* Continue (POSIX). */
437#define TARGET_SIGTTIN 26 /* Background read from tty (POSIX). */
438#define TARGET_SIGTTOU 27 /* Background write to tty (POSIX). */
439#define TARGET_SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
440#define TARGET_SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
441#define TARGET_SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
442#define TARGET_SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
443#define TARGET_SIGRTMIN 32
444
445#define TARGET_SIG_BLOCK 1 /* for blocking signals */
446#define TARGET_SIG_UNBLOCK 2 /* for unblocking signals */
447#define TARGET_SIG_SETMASK 3 /* for setting the signal mask */
448
bellard6d5e2162004-09-30 22:04:13 +0000449#else
bellard2521d692003-06-15 19:58:13 +0000450
451#define TARGET_SIGHUP 1
452#define TARGET_SIGINT 2
453#define TARGET_SIGQUIT 3
454#define TARGET_SIGILL 4
455#define TARGET_SIGTRAP 5
456#define TARGET_SIGABRT 6
457#define TARGET_SIGIOT 6
458#define TARGET_SIGBUS 7
459#define TARGET_SIGFPE 8
460#define TARGET_SIGKILL 9
461#define TARGET_SIGUSR1 10
462#define TARGET_SIGSEGV 11
463#define TARGET_SIGUSR2 12
464#define TARGET_SIGPIPE 13
465#define TARGET_SIGALRM 14
466#define TARGET_SIGTERM 15
467#define TARGET_SIGSTKFLT 16
468#define TARGET_SIGCHLD 17
469#define TARGET_SIGCONT 18
470#define TARGET_SIGSTOP 19
471#define TARGET_SIGTSTP 20
472#define TARGET_SIGTTIN 21
473#define TARGET_SIGTTOU 22
474#define TARGET_SIGURG 23
475#define TARGET_SIGXCPU 24
476#define TARGET_SIGXFSZ 25
477#define TARGET_SIGVTALRM 26
478#define TARGET_SIGPROF 27
479#define TARGET_SIGWINCH 28
480#define TARGET_SIGIO 29
bellardc596ed12003-07-13 17:32:31 +0000481#define TARGET_SIGPWR 30
482#define TARGET_SIGSYS 31
bellard2521d692003-06-15 19:58:13 +0000483#define TARGET_SIGRTMIN 32
484
485#define TARGET_SIG_BLOCK 0 /* for blocking signals */
486#define TARGET_SIG_UNBLOCK 1 /* for unblocking signals */
487#define TARGET_SIG_SETMASK 2 /* for setting the signal mask */
488
bellard6d5e2162004-09-30 22:04:13 +0000489#endif
490
Richard Henderson6049f4f2009-12-27 18:30:03 -0800491#if defined(TARGET_ALPHA)
492struct target_old_sigaction {
493 abi_ulong _sa_handler;
494 abi_ulong sa_mask;
495 abi_ulong sa_flags;
496};
bellard106ec872006-06-27 21:08:10 +0000497
Richard Henderson6049f4f2009-12-27 18:30:03 -0800498struct target_rt_sigaction {
499 abi_ulong _sa_handler;
500 abi_ulong sa_flags;
501 target_sigset_t sa_mask;
502};
503
504/* This is the struct used inside the kernel. The ka_restorer
505 field comes from the 5th argument to sys_rt_sigaction. */
506struct target_sigaction {
507 abi_ulong _sa_handler;
508 abi_ulong sa_flags;
509 target_sigset_t sa_mask;
510 abi_ulong sa_restorer;
511};
512#elif defined(TARGET_MIPS)
bellard106ec872006-06-27 21:08:10 +0000513struct target_sigaction {
ths540635b2007-09-30 01:58:33 +0000514 uint32_t sa_flags;
thsd26bc212007-11-08 18:05:37 +0000515#if defined(TARGET_ABI_MIPSN32)
ths540635b2007-09-30 01:58:33 +0000516 uint32_t _sa_handler;
517#else
blueswir1992f48a2007-10-14 16:27:31 +0000518 abi_ulong _sa_handler;
ths540635b2007-09-30 01:58:33 +0000519#endif
Anthony Liguoric227f092009-10-01 16:12:16 -0500520 target_sigset_t sa_mask;
bellard106ec872006-06-27 21:08:10 +0000521};
bellard106ec872006-06-27 21:08:10 +0000522#else
bellard2521d692003-06-15 19:58:13 +0000523struct target_old_sigaction {
blueswir1992f48a2007-10-14 16:27:31 +0000524 abi_ulong _sa_handler;
525 abi_ulong sa_mask;
526 abi_ulong sa_flags;
527 abi_ulong sa_restorer;
bellard2521d692003-06-15 19:58:13 +0000528};
529
530struct target_sigaction {
blueswir1992f48a2007-10-14 16:27:31 +0000531 abi_ulong _sa_handler;
532 abi_ulong sa_flags;
533 abi_ulong sa_restorer;
Anthony Liguoric227f092009-10-01 16:12:16 -0500534 target_sigset_t sa_mask;
bellard2521d692003-06-15 19:58:13 +0000535};
bellard106ec872006-06-27 21:08:10 +0000536#endif
bellard2521d692003-06-15 19:58:13 +0000537
538typedef union target_sigval {
539 int sival_int;
blueswir1992f48a2007-10-14 16:27:31 +0000540 abi_ulong sival_ptr;
Anthony Liguoric227f092009-10-01 16:12:16 -0500541} target_sigval_t;
bellard6d5e2162004-09-30 22:04:13 +0000542#if 0
543#if defined (TARGET_SPARC)
544typedef struct {
545 struct {
blueswir1992f48a2007-10-14 16:27:31 +0000546 abi_ulong psr;
547 abi_ulong pc;
548 abi_ulong npc;
549 abi_ulong y;
550 abi_ulong u_regs[16]; /* globals and ins */
bellard6d5e2162004-09-30 22:04:13 +0000551 } si_regs;
552 int si_mask;
553} __siginfo_t;
554
555typedef struct {
556 unsigned long si_float_regs [32];
557 unsigned long si_fsr;
558 unsigned long si_fpqdepth;
559 struct {
560 unsigned long *insn_addr;
561 unsigned long insn;
562 } si_fpqueue [16];
563} __siginfo_fpu_t;
564#endif
565#endif
bellard2521d692003-06-15 19:58:13 +0000566
567#define TARGET_SI_MAX_SIZE 128
568#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
569
570typedef struct target_siginfo {
pbrook3f53d542009-04-21 00:59:40 +0000571#ifdef TARGET_MIPS
572 int si_signo;
573 int si_code;
574 int si_errno;
575#else
bellard2521d692003-06-15 19:58:13 +0000576 int si_signo;
577 int si_errno;
578 int si_code;
pbrook3f53d542009-04-21 00:59:40 +0000579#endif
bellard2521d692003-06-15 19:58:13 +0000580
581 union {
582 int _pad[TARGET_SI_PAD_SIZE];
583
584 /* kill() */
585 struct {
586 pid_t _pid; /* sender's pid */
587 uid_t _uid; /* sender's uid */
588 } _kill;
589
590 /* POSIX.1b timers */
591 struct {
592 unsigned int _timer1;
593 unsigned int _timer2;
594 } _timer;
595
596 /* POSIX.1b signals */
597 struct {
598 pid_t _pid; /* sender's pid */
599 uid_t _uid; /* sender's uid */
Anthony Liguoric227f092009-10-01 16:12:16 -0500600 target_sigval_t _sigval;
bellard2521d692003-06-15 19:58:13 +0000601 } _rt;
602
603 /* SIGCHLD */
604 struct {
605 pid_t _pid; /* which child */
606 uid_t _uid; /* sender's uid */
607 int _status; /* exit code */
Anthony Liguoric227f092009-10-01 16:12:16 -0500608 target_clock_t _utime;
609 target_clock_t _stime;
bellard2521d692003-06-15 19:58:13 +0000610 } _sigchld;
611
612 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
613 struct {
blueswir1992f48a2007-10-14 16:27:31 +0000614 abi_ulong _addr; /* faulting insn/memory ref. */
bellard2521d692003-06-15 19:58:13 +0000615 } _sigfault;
616
617 /* SIGPOLL */
618 struct {
619 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
620 int _fd;
621 } _sigpoll;
622 } _sifields;
Anthony Liguoric227f092009-10-01 16:12:16 -0500623} target_siginfo_t;
bellard2521d692003-06-15 19:58:13 +0000624
625/*
626 * si_code values
627 * Digital reserves positive values for kernel-generated signals.
628 */
629#define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
630#define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
631#define TARGET_SI_QUEUE -1 /* sent by sigqueue */
632#define TARGET_SI_TIMER -2 /* sent by timer expiration */
633#define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
634#define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
635#define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
636
637/*
638 * SIGILL si_codes
639 */
bellardffa65c32004-01-04 23:57:22 +0000640#define TARGET_ILL_ILLOPC (1) /* illegal opcode */
bellard2521d692003-06-15 19:58:13 +0000641#define TARGET_ILL_ILLOPN (2) /* illegal operand */
bellardffa65c32004-01-04 23:57:22 +0000642#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
643#define TARGET_ILL_ILLTRP (4) /* illegal trap */
644#define TARGET_ILL_PRVOPC (5) /* privileged opcode */
645#define TARGET_ILL_PRVREG (6) /* privileged register */
646#define TARGET_ILL_COPROC (7) /* coprocessor error */
647#define TARGET_ILL_BADSTK (8) /* internal stack error */
bellard2521d692003-06-15 19:58:13 +0000648
649/*
650 * SIGFPE si_codes
651 */
652#define TARGET_FPE_INTDIV (1) /* integer divide by zero */
653#define TARGET_FPE_INTOVF (2) /* integer overflow */
654#define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
655#define TARGET_FPE_FLTOVF (4) /* floating point overflow */
656#define TARGET_FPE_FLTUND (5) /* floating point underflow */
657#define TARGET_FPE_FLTRES (6) /* floating point inexact result */
658#define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
659#define TARGET_FPE_FLTSUB (8) /* subscript out of range */
660#define TARGET_NSIGFPE 8
661
662/*
663 * SIGSEGV si_codes
664 */
665#define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
666#define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
667
668/*
bellardffa65c32004-01-04 23:57:22 +0000669 * SIGBUS si_codes
670 */
671#define TARGET_BUS_ADRALN (1) /* invalid address alignment */
Dong Xu Wangb4916d72011-11-22 18:06:17 +0800672#define TARGET_BUS_ADRERR (2) /* non-existent physical address */
bellardffa65c32004-01-04 23:57:22 +0000673#define TARGET_BUS_OBJERR (3) /* object specific hardware error */
674
675/*
bellard2521d692003-06-15 19:58:13 +0000676 * SIGTRAP si_codes
677 */
678#define TARGET_TRAP_BRKPT (1) /* process breakpoint */
679#define TARGET_TRAP_TRACE (2) /* process trace trap */
680
681#endif /* defined(TARGET_I386) || defined(TARGET_ARM) */
682
bellard9de5e442003-03-23 16:49:39 +0000683struct target_rlimit {
blueswir1992f48a2007-10-14 16:27:31 +0000684 abi_ulong rlim_cur;
685 abi_ulong rlim_max;
bellard9de5e442003-03-23 16:49:39 +0000686};
687
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900688#if defined(TARGET_ALPHA)
Aurelien Jarnoe4764922010-05-19 18:30:53 +0200689#define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
Matthias Braun6cafd022011-09-09 19:30:25 +0200690#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900691#define TARGET_RLIM_INFINITY 0x7fffffffUL
692#else
Matthias Braun26b746d2011-09-09 19:31:17 +0200693#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
takasi-y@ops.dti.ne.jp81bbe902010-04-12 04:07:35 +0900694#endif
695
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300696#if defined(TARGET_MIPS)
697#define TARGET_RLIMIT_CPU 0
698#define TARGET_RLIMIT_FSIZE 1
699#define TARGET_RLIMIT_DATA 2
700#define TARGET_RLIMIT_STACK 3
701#define TARGET_RLIMIT_CORE 4
702#define TARGET_RLIMIT_RSS 7
703#define TARGET_RLIMIT_NPROC 8
704#define TARGET_RLIMIT_NOFILE 5
705#define TARGET_RLIMIT_MEMLOCK 9
706#define TARGET_RLIMIT_AS 6
707#define TARGET_RLIMIT_LOCKS 10
708#define TARGET_RLIMIT_SIGPENDING 11
709#define TARGET_RLIMIT_MSGQUEUE 12
710#define TARGET_RLIMIT_NICE 13
711#define TARGET_RLIMIT_RTPRIO 14
712#else
713#define TARGET_RLIMIT_CPU 0
714#define TARGET_RLIMIT_FSIZE 1
715#define TARGET_RLIMIT_DATA 2
716#define TARGET_RLIMIT_STACK 3
717#define TARGET_RLIMIT_CORE 4
718#define TARGET_RLIMIT_RSS 5
Matthias Braun6cafd022011-09-09 19:30:25 +0200719#if defined(TARGET_SPARC)
720#define TARGET_RLIMIT_NOFILE 6
721#define TARGET_RLIMIT_NPROC 7
722#else
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300723#define TARGET_RLIMIT_NPROC 6
724#define TARGET_RLIMIT_NOFILE 7
Matthias Braun6cafd022011-09-09 19:30:25 +0200725#endif
Wesley W. Terpstrae22b7012011-07-12 14:42:00 +0300726#define TARGET_RLIMIT_MEMLOCK 8
727#define TARGET_RLIMIT_AS 9
728#define TARGET_RLIMIT_LOCKS 10
729#define TARGET_RLIMIT_SIGPENDING 11
730#define TARGET_RLIMIT_MSGQUEUE 12
731#define TARGET_RLIMIT_NICE 13
732#define TARGET_RLIMIT_RTPRIO 14
733#endif
734
bellard9de5e442003-03-23 16:49:39 +0000735struct target_pollfd {
736 int fd; /* file descriptor */
737 short events; /* requested events */
738 short revents; /* returned events */
739};
740
bellard8e5a0662003-05-08 15:42:10 +0000741/* virtual terminal ioctls */
bellard0221cfc2003-05-10 12:38:16 +0000742#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
743#define TARGET_KDMKTONE 0x4B30 /* generate tone */
bellard8e5a0662003-05-08 15:42:10 +0000744#define TARGET_KDGKBTYPE 0x4b33
Ulrich Hechtf7680a52009-10-16 17:00:44 +0200745#define TARGET_KDSETMODE 0x4b3a
746#define TARGET_KDGKBMODE 0x4b44
747#define TARGET_KDSKBMODE 0x4b45
bellard0221cfc2003-05-10 12:38:16 +0000748#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
749#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
Cédric VINCENTe6fe18f2011-06-29 15:09:09 +0200750#define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
751#define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
752#define TARGET_KDGETLED 0x4B31 /* return current led state */
753#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
bellard8e5a0662003-05-08 15:42:10 +0000754
bellard2521d692003-06-15 19:58:13 +0000755#define TARGET_SIOCATMARK 0x8905
756
bellard31e31b82003-02-18 22:55:36 +0000757/* Networking ioctls */
758#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
759#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
760#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
761#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
762#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
763#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
764#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
765#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
766#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
767#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
768#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
769#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
770#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
771#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
772#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
773#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
774#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
775#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
776#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
777#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
778#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
779#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
780#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
781#define TARGET_SIOCSIFENCAP 0x8926
782#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
783#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
784#define TARGET_SIOCSIFSLAVE 0x8930
785#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
786#define TARGET_SIOCDELMULTI 0x8932
787
788/* Bridging control calls */
789#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
790#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
791
792#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
793#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
794
795/* ARP cache control calls. */
796#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
797#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
798#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
799#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
800#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
801#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
802
803/* RARP cache control calls. */
804#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
805#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
806#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
807
808/* Driver configuration calls */
809#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
810#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
811
812/* DLCI configuration calls */
813#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
814#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
815
Laurent Vivier86fcd942011-03-30 01:35:23 +0200816/* From <linux/wireless.h> */
817
818#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
bellard31e31b82003-02-18 22:55:36 +0000819
820/* From <linux/fs.h> */
821
822#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
823#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
824#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
825#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
826#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
827#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
828#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
829#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
830#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
831#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
832#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
833#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
834/* A jump here: 108-111 have been used for various private purposes. */
835#define TARGET_BLKBSZGET TARGET_IOR(0x12,112,sizeof(int))
836#define TARGET_BLKBSZSET TARGET_IOW(0x12,113,sizeof(int))
837#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
838#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
839#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
Peter Maydell285da2b2011-01-06 15:04:18 +0000840#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
bellard31e31b82003-02-18 22:55:36 +0000841
842/* cdrom commands */
ths5fafdf22007-09-16 21:08:06 +0000843#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
bellard31e31b82003-02-18 22:55:36 +0000844#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
845#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
ths5fafdf22007-09-16 21:08:06 +0000846#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
bellard31e31b82003-02-18 22:55:36 +0000847 (struct cdrom_ti) */
ths5fafdf22007-09-16 21:08:06 +0000848#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
bellard31e31b82003-02-18 22:55:36 +0000849 (struct cdrom_tochdr) */
ths5fafdf22007-09-16 21:08:06 +0000850#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
bellard31e31b82003-02-18 22:55:36 +0000851 (struct cdrom_tocentry) */
852#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
853#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
854#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
ths5fafdf22007-09-16 21:08:06 +0000855#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
bellard31e31b82003-02-18 22:55:36 +0000856 (struct cdrom_volctrl) */
ths5fafdf22007-09-16 21:08:06 +0000857#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
bellard31e31b82003-02-18 22:55:36 +0000858 (struct cdrom_subchnl) */
ths5fafdf22007-09-16 21:08:06 +0000859#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
bellard31e31b82003-02-18 22:55:36 +0000860 (struct cdrom_read) */
861#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
862 (struct cdrom_read) */
863#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
864#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
ths5fafdf22007-09-16 21:08:06 +0000865#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
866 address of multi session disks
bellard31e31b82003-02-18 22:55:36 +0000867 (struct cdrom_multisession) */
ths5fafdf22007-09-16 21:08:06 +0000868#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
bellard31e31b82003-02-18 22:55:36 +0000869 if available (struct cdrom_mcn) */
ths5fafdf22007-09-16 21:08:06 +0000870#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is depricated,
Dong Xu Wangb4916d72011-11-22 18:06:17 +0800871 but here anyway for compatibility */
bellard31e31b82003-02-18 22:55:36 +0000872#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
ths5fafdf22007-09-16 21:08:06 +0000873#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
bellard31e31b82003-02-18 22:55:36 +0000874 (struct cdrom_volctrl) */
875#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
876 (struct cdrom_read) */
ths5fafdf22007-09-16 21:08:06 +0000877/*
bellard31e31b82003-02-18 22:55:36 +0000878 * These ioctls are used only used in aztcd.c and optcd.c
879 */
880#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
881#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
ths3b46e622007-09-17 08:09:54 +0000882
bellard31e31b82003-02-18 22:55:36 +0000883/*
ths3b46e622007-09-17 08:09:54 +0000884 * This ioctl is only used by the scsi-cd driver.
bellard31e31b82003-02-18 22:55:36 +0000885 It is for playing audio in logical block addressing mode.
886 */
887#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
888
ths5fafdf22007-09-16 21:08:06 +0000889/*
bellard31e31b82003-02-18 22:55:36 +0000890 * These ioctls are only used in optcd.c
891 */
892#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
893
ths5fafdf22007-09-16 21:08:06 +0000894/*
895 * These ioctls are (now) only in ide-cd.c for controlling
bellard31e31b82003-02-18 22:55:36 +0000896 * drive spindown time. They should be implemented in the
897 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
898 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
899 * -Erik
900 */
901#define TARGET_CDROMGETSPINDOWN 0x531d
902#define TARGET_CDROMSETSPINDOWN 0x531e
903
ths5fafdf22007-09-16 21:08:06 +0000904/*
bellard31e31b82003-02-18 22:55:36 +0000905 * These ioctls are implemented through the uniform CD-ROM driver
906 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
907 * drivers are eventually ported to the uniform CD-ROM driver interface.
908 */
909#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
910#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
911#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
912#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
913#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
914#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
915#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
916#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
917#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
918#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
919#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
920#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
921
922/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
923 * Future CDROM ioctls should be kept below 0x537F
924 */
925
926/* This ioctl is only used by sbpcd at the moment */
927#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
928 /* conflict with SCSI_IOCTL_GET_IDLUN */
929
930/* DVD-ROM Specific ioctls */
931#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
932#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
933#define TARGET_DVD_AUTH 0x5392 /* Authentication */
934
935#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
936#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
937#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
938
939/* HD commands */
940
941/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
942#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
943#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
944#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
bellard31e31b82003-02-18 22:55:36 +0000945#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
946#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
947#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
948#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
bellard2521d692003-06-15 19:58:13 +0000949#define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
bellard31e31b82003-02-18 22:55:36 +0000950#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
951
952/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
953#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
954#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
955#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
956#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
957#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
958#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
959#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
bellard2521d692003-06-15 19:58:13 +0000960
balrogb8005912008-04-26 14:44:49 +0000961/* loop ioctls */
962#define TARGET_LOOP_SET_FD 0x4C00
963#define TARGET_LOOP_CLR_FD 0x4C01
964#define TARGET_LOOP_SET_STATUS 0x4C02
965#define TARGET_LOOP_GET_STATUS 0x4C03
966#define TARGET_LOOP_SET_STATUS64 0x4C04
967#define TARGET_LOOP_GET_STATUS64 0x4C05
968#define TARGET_LOOP_CHANGE_FD 0x4C06
bellard2521d692003-06-15 19:58:13 +0000969
Ulrich Hechtf7680a52009-10-16 17:00:44 +0200970/* fb ioctls */
971#define TARGET_FBIOGET_VSCREENINFO 0x4600
972#define TARGET_FBIOPUT_VSCREENINFO 0x4601
973#define TARGET_FBIOGET_FSCREENINFO 0x4602
Cédric VINCENT12b81b72011-06-29 15:09:11 +0200974#define TARGET_FBIOGETCMAP 0x4604
975#define TARGET_FBIOPUTCMAP 0x4605
976#define TARGET_FBIOPAN_DISPLAY 0x4606
977#define TARGET_FBIOGET_CON2FBMAP 0x460F
978#define TARGET_FBIOPUT_CON2FBMAP 0x4610
Ulrich Hechtf7680a52009-10-16 17:00:44 +0200979
980/* vt ioctls */
981#define TARGET_VT_OPENQRY 0x5600
982#define TARGET_VT_GETSTATE 0x5603
983#define TARGET_VT_ACTIVATE 0x5606
984#define TARGET_VT_WAITACTIVE 0x5607
985#define TARGET_VT_LOCKSWITCH 0x560b
986#define TARGET_VT_UNLOCKSWITCH 0x560c
Cédric VINCENT774750c2011-06-29 15:09:10 +0200987#define TARGET_VT_GETMODE 0x5601
988#define TARGET_VT_SETMODE 0x5602
989#define TARGET_VT_RELDISP 0x5605
990#define TARGET_VT_DISALLOCATE 0x5608
Ulrich Hechtf7680a52009-10-16 17:00:44 +0200991
bellard2521d692003-06-15 19:58:13 +0000992/* from asm/termbits.h */
993
bellard3bfd9da2004-01-04 15:52:31 +0000994#define TARGET_NCC 8
995struct target_termio {
996 unsigned short c_iflag; /* input mode flags */
997 unsigned short c_oflag; /* output mode flags */
998 unsigned short c_cflag; /* control mode flags */
999 unsigned short c_lflag; /* local mode flags */
1000 unsigned char c_line; /* line discipline */
1001 unsigned char c_cc[TARGET_NCC]; /* control characters */
bellard2521d692003-06-15 19:58:13 +00001002};
1003
bellard3bfd9da2004-01-04 15:52:31 +00001004struct target_winsize {
1005 unsigned short ws_row;
1006 unsigned short ws_col;
1007 unsigned short ws_xpixel;
1008 unsigned short ws_ypixel;
1009};
bellard2521d692003-06-15 19:58:13 +00001010
bellard3bfd9da2004-01-04 15:52:31 +00001011#include "termbits.h"
bellard2521d692003-06-15 19:58:13 +00001012
Paul Brook9e0b74a2010-06-16 13:03:51 +01001013#if defined(TARGET_MIPS)
1014#define TARGET_PROT_SEM 0x10
1015#else
1016#define TARGET_PROT_SEM 0x08
1017#endif
1018
aurel32e44a3e72008-09-29 17:23:09 +00001019/* Common */
bellard2521d692003-06-15 19:58:13 +00001020#define TARGET_MAP_SHARED 0x01 /* Share changes */
1021#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
aurel32e44a3e72008-09-29 17:23:09 +00001022#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
1023
1024/* Target specific */
bellard048f6b42005-11-26 18:47:20 +00001025#if defined(TARGET_MIPS)
aurel32e44a3e72008-09-29 17:23:09 +00001026#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
bellard048f6b42005-11-26 18:47:20 +00001027#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
1028#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
1029#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
1030#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1031#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
1032#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
ths540635b2007-09-30 01:58:33 +00001033#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
1034#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
aurel32e44a3e72008-09-29 17:23:09 +00001035#elif defined(TARGET_PPC)
1036#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
bellard2521d692003-06-15 19:58:13 +00001037#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
bellard2521d692003-06-15 19:58:13 +00001038#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1039#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1040#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
j_mayer7ec931962007-09-18 21:54:57 +00001041#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
1042#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
aurel32e44a3e72008-09-29 17:23:09 +00001043#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1044#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
1045#elif defined(TARGET_ALPHA)
1046#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
1047#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
1048#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
1049#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
1050#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
1051#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
1052#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
1053#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
1054#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
j_mayer7ec931962007-09-18 21:54:57 +00001055#else
aurel32e44a3e72008-09-29 17:23:09 +00001056#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
1057#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
1058#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
1059#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
1060#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
bellard2521d692003-06-15 19:58:13 +00001061#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
1062#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
ths540635b2007-09-30 01:58:33 +00001063#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
1064#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
Mike Frysinger906c1b82011-02-07 01:05:52 -05001065#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
j_mayer7ec931962007-09-18 21:54:57 +00001066#endif
bellard2521d692003-06-15 19:58:13 +00001067
Guan Xuetaod2fbca92011-04-12 16:27:03 +08001068#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) \
1069 || defined(TARGET_CRIS) || defined(TARGET_UNICORE32)
bellard2521d692003-06-15 19:58:13 +00001070struct target_stat {
1071 unsigned short st_dev;
1072 unsigned short __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001073 abi_ulong st_ino;
bellard2521d692003-06-15 19:58:13 +00001074 unsigned short st_mode;
1075 unsigned short st_nlink;
1076 unsigned short st_uid;
1077 unsigned short st_gid;
1078 unsigned short st_rdev;
1079 unsigned short __pad2;
blueswir1992f48a2007-10-14 16:27:31 +00001080 abi_ulong st_size;
1081 abi_ulong st_blksize;
1082 abi_ulong st_blocks;
1083 abi_ulong target_st_atime;
1084 abi_ulong __unused1;
1085 abi_ulong target_st_mtime;
1086 abi_ulong __unused2;
1087 abi_ulong target_st_ctime;
1088 abi_ulong __unused3;
1089 abi_ulong __unused4;
1090 abi_ulong __unused5;
bellard2521d692003-06-15 19:58:13 +00001091};
1092
1093/* This matches struct stat64 in glibc2.1, hence the absolutely
1094 * insane amounts of padding around dev_t's.
1095 */
1096struct target_stat64 {
1097 unsigned short st_dev;
1098 unsigned char __pad0[10];
1099
1100#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001101 abi_ulong __st_ino;
bellard2521d692003-06-15 19:58:13 +00001102
1103 unsigned int st_mode;
1104 unsigned int st_nlink;
1105
blueswir1992f48a2007-10-14 16:27:31 +00001106 abi_ulong st_uid;
1107 abi_ulong st_gid;
bellard2521d692003-06-15 19:58:13 +00001108
1109 unsigned short st_rdev;
1110 unsigned char __pad3[10];
1111
1112 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001113 abi_ulong st_blksize;
bellard2521d692003-06-15 19:58:13 +00001114
blueswir1992f48a2007-10-14 16:27:31 +00001115 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
1116 abi_ulong __pad4; /* future possible st_blocks high bits */
bellard2521d692003-06-15 19:58:13 +00001117
blueswir1992f48a2007-10-14 16:27:31 +00001118 abi_ulong target_st_atime;
1119 abi_ulong __pad5;
bellard2521d692003-06-15 19:58:13 +00001120
blueswir1992f48a2007-10-14 16:27:31 +00001121 abi_ulong target_st_mtime;
1122 abi_ulong __pad6;
bellard2521d692003-06-15 19:58:13 +00001123
blueswir1992f48a2007-10-14 16:27:31 +00001124 abi_ulong target_st_ctime;
1125 abi_ulong __pad7; /* will be high 32 bits of ctime someday */
bellard2521d692003-06-15 19:58:13 +00001126
1127 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001128} QEMU_PACKED;
bellard2521d692003-06-15 19:58:13 +00001129
pbrookce4defa2006-02-09 16:49:55 +00001130#ifdef TARGET_ARM
1131struct target_eabi_stat64 {
1132 unsigned long long st_dev;
1133 unsigned int __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001134 abi_ulong __st_ino;
pbrookce4defa2006-02-09 16:49:55 +00001135 unsigned int st_mode;
1136 unsigned int st_nlink;
1137
blueswir1992f48a2007-10-14 16:27:31 +00001138 abi_ulong st_uid;
1139 abi_ulong st_gid;
pbrookce4defa2006-02-09 16:49:55 +00001140
1141 unsigned long long st_rdev;
1142 unsigned int __pad2[2];
1143
1144 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001145 abi_ulong st_blksize;
pbrookce4defa2006-02-09 16:49:55 +00001146 unsigned int __pad3;
1147 unsigned long long st_blocks;
1148
blueswir1992f48a2007-10-14 16:27:31 +00001149 abi_ulong target_st_atime;
1150 abi_ulong target_st_atime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001151
blueswir1992f48a2007-10-14 16:27:31 +00001152 abi_ulong target_st_mtime;
1153 abi_ulong target_st_mtime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001154
blueswir1992f48a2007-10-14 16:27:31 +00001155 abi_ulong target_st_ctime;
1156 abi_ulong target_st_ctime_nsec;
pbrookce4defa2006-02-09 16:49:55 +00001157
1158 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001159} QEMU_PACKED;
pbrookce4defa2006-02-09 16:49:55 +00001160#endif
1161
blueswir1992f48a2007-10-14 16:27:31 +00001162#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
blueswir11b8dd642007-07-08 10:08:24 +00001163struct target_stat {
1164 unsigned int st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001165 abi_ulong st_ino;
blueswir11b8dd642007-07-08 10:08:24 +00001166 unsigned int st_mode;
1167 unsigned int st_nlink;
1168 unsigned int st_uid;
1169 unsigned int st_gid;
1170 unsigned int st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001171 abi_long st_size;
1172 abi_long target_st_atime;
1173 abi_long target_st_mtime;
1174 abi_long target_st_ctime;
1175 abi_long st_blksize;
1176 abi_long st_blocks;
1177 abi_ulong __unused4[2];
blueswir11b8dd642007-07-08 10:08:24 +00001178};
1179
1180struct target_stat64 {
1181 unsigned char __pad0[6];
1182 unsigned short st_dev;
1183
1184 uint64_t st_ino;
1185 uint64_t st_nlink;
1186
1187 unsigned int st_mode;
1188
1189 unsigned int st_uid;
1190 unsigned int st_gid;
1191
1192 unsigned char __pad2[6];
1193 unsigned short st_rdev;
1194
1195 int64_t st_size;
1196 int64_t st_blksize;
1197
1198 unsigned char __pad4[4];
1199 unsigned int st_blocks;
1200
blueswir1992f48a2007-10-14 16:27:31 +00001201 abi_ulong target_st_atime;
1202 abi_ulong __unused1;
blueswir11b8dd642007-07-08 10:08:24 +00001203
blueswir1992f48a2007-10-14 16:27:31 +00001204 abi_ulong target_st_mtime;
1205 abi_ulong __unused2;
blueswir11b8dd642007-07-08 10:08:24 +00001206
blueswir1992f48a2007-10-14 16:27:31 +00001207 abi_ulong target_st_ctime;
1208 abi_ulong __unused3;
blueswir11b8dd642007-07-08 10:08:24 +00001209
blueswir1992f48a2007-10-14 16:27:31 +00001210 abi_ulong __unused4[3];
blueswir11b8dd642007-07-08 10:08:24 +00001211};
1212
bellard3bfd9da2004-01-04 15:52:31 +00001213#elif defined(TARGET_SPARC)
1214
1215struct target_stat {
1216 unsigned short st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001217 abi_ulong st_ino;
bellard3bfd9da2004-01-04 15:52:31 +00001218 unsigned short st_mode;
1219 short st_nlink;
1220 unsigned short st_uid;
1221 unsigned short st_gid;
1222 unsigned short st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001223 abi_long st_size;
1224 abi_long target_st_atime;
1225 abi_ulong __unused1;
1226 abi_long target_st_mtime;
1227 abi_ulong __unused2;
1228 abi_long target_st_ctime;
1229 abi_ulong __unused3;
1230 abi_long st_blksize;
1231 abi_long st_blocks;
1232 abi_ulong __unused4[2];
bellard3bfd9da2004-01-04 15:52:31 +00001233};
1234
1235struct target_stat64 {
1236 unsigned char __pad0[6];
1237 unsigned short st_dev;
1238
1239 uint64_t st_ino;
1240
1241 unsigned int st_mode;
1242 unsigned int st_nlink;
1243
1244 unsigned int st_uid;
1245 unsigned int st_gid;
1246
1247 unsigned char __pad2[6];
1248 unsigned short st_rdev;
1249
1250 unsigned char __pad3[8];
1251
1252 int64_t st_size;
1253 unsigned int st_blksize;
1254
1255 unsigned char __pad4[8];
1256 unsigned int st_blocks;
1257
1258 unsigned int target_st_atime;
1259 unsigned int __unused1;
1260
1261 unsigned int target_st_mtime;
1262 unsigned int __unused2;
1263
1264 unsigned int target_st_ctime;
1265 unsigned int __unused3;
1266
1267 unsigned int __unused4;
1268 unsigned int __unused5;
1269};
1270
bellard67867302003-11-23 17:05:30 +00001271#elif defined(TARGET_PPC)
1272
1273struct target_stat {
j_mayere32448e2007-12-10 08:24:59 +00001274 abi_ulong st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001275 abi_ulong st_ino;
j_mayer325e6512007-11-21 13:06:54 +00001276#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
j_mayere32448e2007-12-10 08:24:59 +00001277 abi_ulong st_nlink;
j_mayer325e6512007-11-21 13:06:54 +00001278 unsigned int st_mode;
1279#else
bellard67867302003-11-23 17:05:30 +00001280 unsigned int st_mode;
1281 unsigned short st_nlink;
j_mayer325e6512007-11-21 13:06:54 +00001282#endif
bellard67867302003-11-23 17:05:30 +00001283 unsigned int st_uid;
1284 unsigned int st_gid;
j_mayere32448e2007-12-10 08:24:59 +00001285 abi_ulong st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001286 abi_ulong st_size;
1287 abi_ulong st_blksize;
1288 abi_ulong st_blocks;
1289 abi_ulong target_st_atime;
j_mayere32448e2007-12-10 08:24:59 +00001290 abi_ulong target_st_atime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001291 abi_ulong target_st_mtime;
j_mayere32448e2007-12-10 08:24:59 +00001292 abi_ulong target_st_mtime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001293 abi_ulong target_st_ctime;
j_mayere32448e2007-12-10 08:24:59 +00001294 abi_ulong target_st_ctime_nsec;
blueswir1992f48a2007-10-14 16:27:31 +00001295 abi_ulong __unused4;
1296 abi_ulong __unused5;
j_mayer325e6512007-11-21 13:06:54 +00001297#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1298 abi_ulong __unused6;
1299#endif
bellard67867302003-11-23 17:05:30 +00001300};
1301
Stefan Weil541dc0d2011-08-31 12:38:01 +02001302struct QEMU_PACKED target_stat64 {
bellard67867302003-11-23 17:05:30 +00001303 unsigned long long st_dev;
bellard67867302003-11-23 17:05:30 +00001304 unsigned long long st_ino;
bellard3bfd9da2004-01-04 15:52:31 +00001305 unsigned int st_mode;
1306 unsigned int st_nlink;
bellard67867302003-11-23 17:05:30 +00001307 unsigned int st_uid;
1308 unsigned int st_gid;
bellard3bfd9da2004-01-04 15:52:31 +00001309 unsigned long long st_rdev;
aurel32e1ce5e42009-01-30 19:48:32 +00001310 unsigned long long __pad0;
j_mayere32448e2007-12-10 08:24:59 +00001311 long long st_size;
1312 int st_blksize;
aurel32e1ce5e42009-01-30 19:48:32 +00001313 unsigned int __pad1;
Max Filippov61322e92009-09-01 23:27:47 +04001314 long long st_blocks; /* Number 512-byte blocks allocated. */
j_mayere32448e2007-12-10 08:24:59 +00001315 int target_st_atime;
1316 unsigned int target_st_atime_nsec;
1317 int target_st_mtime;
1318 unsigned int target_st_mtime_nsec;
1319 int target_st_ctime;
1320 unsigned int target_st_ctime_nsec;
1321 unsigned int __unused4;
1322 unsigned int __unused5;
bellard67867302003-11-23 17:05:30 +00001323};
1324
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001325#elif defined(TARGET_MICROBLAZE)
1326
1327struct target_stat {
1328 abi_ulong st_dev;
1329 abi_ulong st_ino;
1330 unsigned int st_mode;
1331 unsigned short st_nlink;
1332 unsigned int st_uid;
1333 unsigned int st_gid;
1334 abi_ulong st_rdev;
1335 abi_ulong st_size;
1336 abi_ulong st_blksize;
1337 abi_ulong st_blocks;
1338 abi_ulong target_st_atime;
1339 abi_ulong target_st_atime_nsec;
1340 abi_ulong target_st_mtime;
1341 abi_ulong target_st_mtime_nsec;
1342 abi_ulong target_st_ctime;
1343 abi_ulong target_st_ctime_nsec;
1344 abi_ulong __unused4;
1345 abi_ulong __unused5;
1346};
1347
1348/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
Stefan Weil541dc0d2011-08-31 12:38:01 +02001349struct QEMU_PACKED target_stat64 {
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001350 uint64_t st_dev;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001351#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
1352 uint32_t pad0;
1353 uint32_t __st_ino;
1354
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001355 uint32_t st_mode;
1356 uint32_t st_nlink;
1357 uint32_t st_uid;
1358 uint32_t st_gid;
1359 uint64_t st_rdev;
Edgar E. Iglesias21ebeb22009-06-23 19:19:33 +02001360 uint64_t __pad1;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001361
1362 int64_t st_size;
Edgar E. Iglesias21ebeb22009-06-23 19:19:33 +02001363 int32_t st_blksize;
1364 uint32_t __pad2;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001365 int64_t st_blocks; /* Number 512-byte blocks allocated. */
1366
1367 int target_st_atime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001368 unsigned int target_st_atime_nsec;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001369 int target_st_mtime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001370 unsigned int target_st_mtime_nsec;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001371 int target_st_ctime;
Edgar E. Iglesiasa523eb02010-08-09 10:13:33 +02001372 unsigned int target_st_ctime_nsec;
1373 uint64_t st_ino;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001374};
1375
pbrooke6e59062006-10-22 00:18:54 +00001376#elif defined(TARGET_M68K)
1377
1378struct target_stat {
1379 unsigned short st_dev;
1380 unsigned short __pad1;
blueswir1992f48a2007-10-14 16:27:31 +00001381 abi_ulong st_ino;
pbrooke6e59062006-10-22 00:18:54 +00001382 unsigned short st_mode;
1383 unsigned short st_nlink;
1384 unsigned short st_uid;
1385 unsigned short st_gid;
1386 unsigned short st_rdev;
1387 unsigned short __pad2;
blueswir1992f48a2007-10-14 16:27:31 +00001388 abi_ulong st_size;
1389 abi_ulong st_blksize;
1390 abi_ulong st_blocks;
1391 abi_ulong target_st_atime;
1392 abi_ulong __unused1;
1393 abi_ulong target_st_mtime;
1394 abi_ulong __unused2;
1395 abi_ulong target_st_ctime;
1396 abi_ulong __unused3;
1397 abi_ulong __unused4;
1398 abi_ulong __unused5;
pbrooke6e59062006-10-22 00:18:54 +00001399};
1400
1401/* This matches struct stat64 in glibc2.1, hence the absolutely
1402 * insane amounts of padding around dev_t's.
1403 */
1404struct target_stat64 {
1405 unsigned long long st_dev;
1406 unsigned char __pad1[2];
1407
1408#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001409 abi_ulong __st_ino;
pbrooke6e59062006-10-22 00:18:54 +00001410
1411 unsigned int st_mode;
1412 unsigned int st_nlink;
1413
blueswir1992f48a2007-10-14 16:27:31 +00001414 abi_ulong st_uid;
1415 abi_ulong st_gid;
pbrooke6e59062006-10-22 00:18:54 +00001416
1417 unsigned long long st_rdev;
1418 unsigned char __pad3[2];
1419
1420 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001421 abi_ulong st_blksize;
pbrooke6e59062006-10-22 00:18:54 +00001422
blueswir1992f48a2007-10-14 16:27:31 +00001423 abi_ulong __pad4; /* future possible st_blocks high bits */
1424 abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
pbrooke6e59062006-10-22 00:18:54 +00001425
blueswir1992f48a2007-10-14 16:27:31 +00001426 abi_ulong target_st_atime;
1427 abi_ulong target_st_atime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001428
blueswir1992f48a2007-10-14 16:27:31 +00001429 abi_ulong target_st_mtime;
1430 abi_ulong target_st_mtime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001431
blueswir1992f48a2007-10-14 16:27:31 +00001432 abi_ulong target_st_ctime;
1433 abi_ulong target_st_ctime_nsec;
pbrooke6e59062006-10-22 00:18:54 +00001434
1435 unsigned long long st_ino;
Stefan Weil541dc0d2011-08-31 12:38:01 +02001436} QEMU_PACKED;
pbrooke6e59062006-10-22 00:18:54 +00001437
thsd26bc212007-11-08 18:05:37 +00001438#elif defined(TARGET_ABI_MIPSN64)
ths540635b2007-09-30 01:58:33 +00001439
1440/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
1441struct target_stat {
1442 unsigned int st_dev;
1443 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1444
blueswir1992f48a2007-10-14 16:27:31 +00001445 abi_ulong st_ino;
ths540635b2007-09-30 01:58:33 +00001446
1447 unsigned int st_mode;
1448 unsigned int st_nlink;
1449
1450 int st_uid;
1451 int st_gid;
1452
1453 unsigned int st_rdev;
1454 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1455
blueswir1992f48a2007-10-14 16:27:31 +00001456 abi_ulong st_size;
ths540635b2007-09-30 01:58:33 +00001457
1458 /*
1459 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1460 * but we don't have it under Linux.
1461 */
1462 unsigned int target_st_atime;
1463 unsigned int target_st_atime_nsec;
1464
1465 unsigned int target_st_mtime;
1466 unsigned int target_st_mtime_nsec;
1467
1468 unsigned int target_st_ctime;
1469 unsigned int target_st_ctime_nsec;
1470
1471 unsigned int st_blksize;
1472 unsigned int st_pad2;
1473
blueswir1992f48a2007-10-14 16:27:31 +00001474 abi_ulong st_blocks;
ths540635b2007-09-30 01:58:33 +00001475};
1476
thsd26bc212007-11-08 18:05:37 +00001477#elif defined(TARGET_ABI_MIPSN32)
ths540635b2007-09-30 01:58:33 +00001478
1479struct target_stat {
1480 unsigned st_dev;
1481 int st_pad1[3]; /* Reserved for network id */
1482 unsigned int st_ino;
1483 unsigned int st_mode;
1484 unsigned int st_nlink;
1485 int st_uid;
1486 int st_gid;
1487 unsigned st_rdev;
1488 unsigned int st_pad2[2];
1489 unsigned int st_size;
1490 unsigned int st_pad3;
1491 /*
1492 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1493 * but we don't have it under Linux.
1494 */
1495 unsigned int target_st_atime;
1496 unsigned int target_st_atime_nsec;
1497 unsigned int target_st_mtime;
1498 unsigned int target_st_mtime_nsec;
1499 unsigned int target_st_ctime;
1500 unsigned int target_st_ctime_nsec;
1501 unsigned int st_blksize;
1502 unsigned int st_blocks;
1503 unsigned int st_pad4[14];
1504};
1505
1506/*
1507 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1508 * amounts of padding around dev_t's. The memory layout is the same as of
1509 * struct stat of the 64-bit kernel.
1510 */
1511
1512struct target_stat64 {
1513 unsigned int st_dev;
1514 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
1515
1516 target_ulong st_ino;
1517
1518 unsigned int st_mode;
1519 unsigned int st_nlink;
1520
1521 int st_uid;
1522 int st_gid;
1523
1524 unsigned int st_rdev;
1525 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
1526
1527 int st_size;
1528
1529 /*
1530 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1531 * but we don't have it under Linux.
1532 */
1533 int target_st_atime;
1534 unsigned int target_st_atime_nsec; /* Reserved for st_atime expansion */
1535
1536 int target_st_mtime;
1537 unsigned int target_st_mtime_nsec; /* Reserved for st_mtime expansion */
1538
1539 int target_st_ctime;
1540 unsigned int target_st_ctime_nsec; /* Reserved for st_ctime expansion */
1541
1542 unsigned int st_blksize;
1543 unsigned int st_pad2;
1544
1545 int st_blocks;
1546};
1547
thsd26bc212007-11-08 18:05:37 +00001548#elif defined(TARGET_ABI_MIPSO32)
bellard048f6b42005-11-26 18:47:20 +00001549
1550struct target_stat {
1551 unsigned st_dev;
blueswir1992f48a2007-10-14 16:27:31 +00001552 abi_long st_pad1[3]; /* Reserved for network id */
1553 abi_ulong st_ino;
bellard048f6b42005-11-26 18:47:20 +00001554 unsigned int st_mode;
1555 unsigned int st_nlink;
1556 int st_uid;
1557 int st_gid;
1558 unsigned st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001559 abi_long st_pad2[2];
1560 abi_long st_size;
1561 abi_long st_pad3;
bellard048f6b42005-11-26 18:47:20 +00001562 /*
1563 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1564 * but we don't have it under Linux.
1565 */
blueswir1992f48a2007-10-14 16:27:31 +00001566 abi_long target_st_atime;
1567 abi_long target_st_atime_nsec;
1568 abi_long target_st_mtime;
1569 abi_long target_st_mtime_nsec;
1570 abi_long target_st_ctime;
1571 abi_long target_st_ctime_nsec;
1572 abi_long st_blksize;
1573 abi_long st_blocks;
1574 abi_long st_pad4[14];
bellard048f6b42005-11-26 18:47:20 +00001575};
1576
1577/*
1578 * This matches struct stat64 in glibc2.1, hence the absolutely insane
1579 * amounts of padding around dev_t's. The memory layout is the same as of
1580 * struct stat of the 64-bit kernel.
1581 */
1582
1583struct target_stat64 {
blueswir1992f48a2007-10-14 16:27:31 +00001584 abi_ulong st_dev;
1585 abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
bellard048f6b42005-11-26 18:47:20 +00001586
1587 uint64_t st_ino;
1588
1589 unsigned int st_mode;
1590 unsigned int st_nlink;
1591
1592 int st_uid;
1593 int st_gid;
1594
blueswir1992f48a2007-10-14 16:27:31 +00001595 abi_ulong st_rdev;
1596 abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
bellard048f6b42005-11-26 18:47:20 +00001597
1598 int64_t st_size;
1599
1600 /*
1601 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1602 * but we don't have it under Linux.
1603 */
blueswir1992f48a2007-10-14 16:27:31 +00001604 abi_long target_st_atime;
1605 abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
bellard048f6b42005-11-26 18:47:20 +00001606
blueswir1992f48a2007-10-14 16:27:31 +00001607 abi_long target_st_mtime;
1608 abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
bellard048f6b42005-11-26 18:47:20 +00001609
blueswir1992f48a2007-10-14 16:27:31 +00001610 abi_long target_st_ctime;
1611 abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
bellard048f6b42005-11-26 18:47:20 +00001612
blueswir1992f48a2007-10-14 16:27:31 +00001613 abi_ulong st_blksize;
1614 abi_ulong st_pad2;
bellard048f6b42005-11-26 18:47:20 +00001615
1616 int64_t st_blocks;
1617};
j_mayer7a3148a2007-04-05 07:13:51 +00001618
1619#elif defined(TARGET_ALPHA)
1620
1621struct target_stat {
1622 unsigned int st_dev;
1623 unsigned int st_ino;
1624 unsigned int st_mode;
1625 unsigned int st_nlink;
1626 unsigned int st_uid;
1627 unsigned int st_gid;
1628 unsigned int st_rdev;
blueswir1992f48a2007-10-14 16:27:31 +00001629 abi_long st_size;
1630 abi_ulong target_st_atime;
1631 abi_ulong target_st_mtime;
1632 abi_ulong target_st_ctime;
j_mayer7a3148a2007-04-05 07:13:51 +00001633 unsigned int st_blksize;
1634 unsigned int st_blocks;
1635 unsigned int st_flags;
1636 unsigned int st_gen;
1637};
1638
1639struct target_stat64 {
blueswir1992f48a2007-10-14 16:27:31 +00001640 abi_ulong st_dev;
1641 abi_ulong st_ino;
1642 abi_ulong st_rdev;
1643 abi_long st_size;
1644 abi_ulong st_blocks;
j_mayer7a3148a2007-04-05 07:13:51 +00001645
1646 unsigned int st_mode;
1647 unsigned int st_uid;
1648 unsigned int st_gid;
1649 unsigned int st_blksize;
1650 unsigned int st_nlink;
1651 unsigned int __pad0;
1652
blueswir1992f48a2007-10-14 16:27:31 +00001653 abi_ulong target_st_atime;
1654 abi_ulong target_st_atime_nsec;
1655 abi_ulong target_st_mtime;
1656 abi_ulong target_st_mtime_nsec;
1657 abi_ulong target_st_ctime;
1658 abi_ulong target_st_ctime_nsec;
1659 abi_long __unused[3];
j_mayer7a3148a2007-04-05 07:13:51 +00001660};
1661
ths6db45e62007-06-22 10:15:10 +00001662#elif defined(TARGET_SH4)
1663
1664struct target_stat {
blueswir1992f48a2007-10-14 16:27:31 +00001665 abi_ulong st_dev;
1666 abi_ulong st_ino;
ths6db45e62007-06-22 10:15:10 +00001667 unsigned short st_mode;
1668 unsigned short st_nlink;
1669 unsigned short st_uid;
1670 unsigned short st_gid;
blueswir1992f48a2007-10-14 16:27:31 +00001671 abi_ulong st_rdev;
1672 abi_ulong st_size;
1673 abi_ulong st_blksize;
1674 abi_ulong st_blocks;
1675 abi_ulong target_st_atime;
1676 abi_ulong target_st_atime_nsec;
1677 abi_ulong target_st_mtime;
1678 abi_ulong target_st_mtime_nsec;
1679 abi_ulong target_st_ctime;
1680 abi_ulong target_st_ctime_nsec;
1681 abi_ulong __unused4;
1682 abi_ulong __unused5;
ths6db45e62007-06-22 10:15:10 +00001683};
1684
1685/* This matches struct stat64 in glibc2.1, hence the absolutely
1686 * insane amounts of padding around dev_t's.
1687 */
Stefan Weil541dc0d2011-08-31 12:38:01 +02001688struct QEMU_PACKED target_stat64 {
ths6db45e62007-06-22 10:15:10 +00001689 unsigned long long st_dev;
1690 unsigned char __pad0[4];
1691
1692#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
blueswir1992f48a2007-10-14 16:27:31 +00001693 abi_ulong __st_ino;
ths6db45e62007-06-22 10:15:10 +00001694
1695 unsigned int st_mode;
1696 unsigned int st_nlink;
1697
blueswir1992f48a2007-10-14 16:27:31 +00001698 abi_ulong st_uid;
1699 abi_ulong st_gid;
ths6db45e62007-06-22 10:15:10 +00001700
1701 unsigned long long st_rdev;
1702 unsigned char __pad3[4];
1703
1704 long long st_size;
blueswir1992f48a2007-10-14 16:27:31 +00001705 abi_ulong st_blksize;
ths6db45e62007-06-22 10:15:10 +00001706
1707 unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
1708
blueswir1992f48a2007-10-14 16:27:31 +00001709 abi_ulong target_st_atime;
1710 abi_ulong target_st_atime_nsec;
ths6db45e62007-06-22 10:15:10 +00001711
blueswir1992f48a2007-10-14 16:27:31 +00001712 abi_ulong target_st_mtime;
1713 abi_ulong target_st_mtime_nsec;
ths6db45e62007-06-22 10:15:10 +00001714
blueswir1992f48a2007-10-14 16:27:31 +00001715 abi_ulong target_st_ctime;
1716 abi_ulong target_st_ctime_nsec;
ths6db45e62007-06-22 10:15:10 +00001717
1718 unsigned long long st_ino;
1719};
1720
bellardd2fd1af2007-11-14 18:08:56 +00001721#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1722struct target_stat {
1723 abi_ulong st_dev;
1724 abi_ulong st_ino;
1725 abi_ulong st_nlink;
1726
1727 unsigned int st_mode;
1728 unsigned int st_uid;
1729 unsigned int st_gid;
1730 unsigned int __pad0;
1731 abi_ulong st_rdev;
1732 abi_long st_size;
1733 abi_long st_blksize;
1734 abi_long st_blocks; /* Number 512-byte blocks allocated. */
1735
1736 abi_ulong target_st_atime;
1737 abi_ulong target_st_atime_nsec;
1738 abi_ulong target_st_mtime;
1739 abi_ulong target_st_mtime_nsec;
1740 abi_ulong target_st_ctime;
1741 abi_ulong target_st_ctime_nsec;
1742
1743 abi_long __unused[3];
1744};
Ulrich Hechta4c075f2009-07-24 16:57:31 +02001745#elif defined(TARGET_S390X)
1746struct target_stat {
1747 abi_ulong st_dev;
1748 abi_ulong st_ino;
1749 abi_ulong st_nlink;
1750 unsigned int st_mode;
1751 unsigned int st_uid;
1752 unsigned int st_gid;
1753 unsigned int __pad1;
1754 abi_ulong st_rdev;
1755 abi_ulong st_size;
1756 abi_ulong target_st_atime;
1757 abi_ulong target_st_atime_nsec;
1758 abi_ulong target_st_mtime;
1759 abi_ulong target_st_mtime_nsec;
1760 abi_ulong target_st_ctime;
1761 abi_ulong target_st_ctime_nsec;
1762 abi_ulong st_blksize;
1763 abi_long st_blocks;
1764 abi_ulong __unused[3];
1765};
bellard048f6b42005-11-26 18:47:20 +00001766#else
1767#error unsupported CPU
1768#endif
bellard2521d692003-06-15 19:58:13 +00001769
ths4ce6f8d2007-07-20 15:54:27 +00001770typedef struct {
1771 int val[2];
Anthony Liguoric227f092009-10-01 16:12:16 -05001772} target_fsid_t;
ths4ce6f8d2007-07-20 15:54:27 +00001773
bellard56c8f682005-11-28 22:28:41 +00001774#ifdef TARGET_MIPS
thsd26bc212007-11-08 18:05:37 +00001775#ifdef TARGET_ABI_MIPSN32
ths540635b2007-09-30 01:58:33 +00001776struct target_statfs {
1777 int32_t f_type;
1778 int32_t f_bsize;
1779 int32_t f_frsize; /* Fragment size - unsupported */
1780 int32_t f_blocks;
1781 int32_t f_bfree;
1782 int32_t f_files;
1783 int32_t f_ffree;
1784 int32_t f_bavail;
1785
1786 /* Linux specials */
Anthony Liguoric227f092009-10-01 16:12:16 -05001787 target_fsid_t f_fsid;
ths540635b2007-09-30 01:58:33 +00001788 int32_t f_namelen;
1789 int32_t f_spare[6];
1790};
1791#else
bellard56c8f682005-11-28 22:28:41 +00001792struct target_statfs {
blueswir1992f48a2007-10-14 16:27:31 +00001793 abi_long f_type;
1794 abi_long f_bsize;
1795 abi_long f_frsize; /* Fragment size - unsupported */
1796 abi_long f_blocks;
1797 abi_long f_bfree;
1798 abi_long f_files;
1799 abi_long f_ffree;
1800 abi_long f_bavail;
bellard56c8f682005-11-28 22:28:41 +00001801
1802 /* Linux specials */
Anthony Liguoric227f092009-10-01 16:12:16 -05001803 target_fsid_t f_fsid;
blueswir1992f48a2007-10-14 16:27:31 +00001804 abi_long f_namelen;
1805 abi_long f_spare[6];
bellard56c8f682005-11-28 22:28:41 +00001806};
ths540635b2007-09-30 01:58:33 +00001807#endif
bellard56c8f682005-11-28 22:28:41 +00001808
1809struct target_statfs64 {
1810 uint32_t f_type;
1811 uint32_t f_bsize;
1812 uint32_t f_frsize; /* Fragment size - unsupported */
1813 uint32_t __pad;
1814 uint64_t f_blocks;
1815 uint64_t f_bfree;
1816 uint64_t f_files;
1817 uint64_t f_ffree;
1818 uint64_t f_bavail;
Anthony Liguoric227f092009-10-01 16:12:16 -05001819 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00001820 uint32_t f_namelen;
1821 uint32_t f_spare[6];
1822};
balrogc4d10622008-07-19 09:38:52 +00001823#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
1824 defined(TARGET_SPARC64)) && !defined(TARGET_ABI32)
j_mayer325e6512007-11-21 13:06:54 +00001825struct target_statfs {
1826 abi_long f_type;
1827 abi_long f_bsize;
1828 abi_long f_blocks;
1829 abi_long f_bfree;
1830 abi_long f_bavail;
1831 abi_long f_files;
1832 abi_long f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05001833 target_fsid_t f_fsid;
j_mayer325e6512007-11-21 13:06:54 +00001834 abi_long f_namelen;
1835 abi_long f_frsize;
1836 abi_long f_spare[5];
1837};
1838
1839struct target_statfs64 {
1840 abi_long f_type;
1841 abi_long f_bsize;
1842 abi_long f_blocks;
1843 abi_long f_bfree;
1844 abi_long f_bavail;
1845 abi_long f_files;
1846 abi_long f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05001847 target_fsid_t f_fsid;
j_mayer325e6512007-11-21 13:06:54 +00001848 abi_long f_namelen;
1849 abi_long f_frsize;
1850 abi_long f_spare[5];
1851};
Ulrich Hechta4c075f2009-07-24 16:57:31 +02001852#elif defined(TARGET_S390X)
1853struct target_statfs {
1854 int32_t f_type;
1855 int32_t f_bsize;
1856 abi_long f_blocks;
1857 abi_long f_bfree;
1858 abi_long f_bavail;
1859 abi_long f_files;
1860 abi_long f_ffree;
1861 kernel_fsid_t f_fsid;
1862 int32_t f_namelen;
1863 int32_t f_frsize;
1864 int32_t f_spare[5];
1865};
1866
1867struct target_statfs64 {
1868 int32_t f_type;
1869 int32_t f_bsize;
1870 abi_long f_blocks;
1871 abi_long f_bfree;
1872 abi_long f_bavail;
1873 abi_long f_files;
1874 abi_long f_ffree;
1875 kernel_fsid_t f_fsid;
1876 int32_t f_namelen;
1877 int32_t f_frsize;
1878 int32_t f_spare[5];
1879};
bellard56c8f682005-11-28 22:28:41 +00001880#else
1881struct target_statfs {
1882 uint32_t f_type;
1883 uint32_t f_bsize;
1884 uint32_t f_blocks;
1885 uint32_t f_bfree;
1886 uint32_t f_bavail;
1887 uint32_t f_files;
1888 uint32_t f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05001889 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00001890 uint32_t f_namelen;
1891 uint32_t f_frsize;
1892 uint32_t f_spare[5];
1893};
1894
1895struct target_statfs64 {
1896 uint32_t f_type;
1897 uint32_t f_bsize;
1898 uint64_t f_blocks;
1899 uint64_t f_bfree;
1900 uint64_t f_bavail;
1901 uint64_t f_files;
1902 uint64_t f_ffree;
Anthony Liguoric227f092009-10-01 16:12:16 -05001903 target_fsid_t f_fsid;
bellard56c8f682005-11-28 22:28:41 +00001904 uint32_t f_namelen;
1905 uint32_t f_frsize;
1906 uint32_t f_spare[5];
1907};
1908#endif
1909
1910
bellard2521d692003-06-15 19:58:13 +00001911#define TARGET_F_DUPFD 0 /* dup */
1912#define TARGET_F_GETFD 1 /* get close_on_exec */
1913#define TARGET_F_SETFD 2 /* set/clear close_on_exec */
1914#define TARGET_F_GETFL 3 /* get file->f_flags */
1915#define TARGET_F_SETFL 4 /* set file->f_flags */
1916
1917#if defined(TARGET_ALPHA)
1918#define TARGET_F_GETLK 7
1919#define TARGET_F_SETLK 8
1920#define TARGET_F_SETLKW 9
1921#define TARGET_F_SETOWN 5 /* for sockets. */
1922#define TARGET_F_GETOWN 6 /* for sockets. */
Arnaud Patard (Rtp)5f106812009-06-03 14:35:04 +02001923#elif defined(TARGET_MIPS)
1924#define TARGET_F_GETLK 14
1925#define TARGET_F_SETLK 6
1926#define TARGET_F_SETLKW 7
1927#define TARGET_F_SETOWN 24 /* for sockets. */
1928#define TARGET_F_GETOWN 25 /* for sockets. */
bellard2521d692003-06-15 19:58:13 +00001929#else
1930#define TARGET_F_GETLK 5
1931#define TARGET_F_SETLK 6
1932#define TARGET_F_SETLKW 7
1933#define TARGET_F_SETOWN 8 /* for sockets. */
1934#define TARGET_F_GETOWN 9 /* for sockets. */
1935#endif
1936
1937#define TARGET_F_SETSIG 10 /* for sockets. */
1938#define TARGET_F_GETSIG 11 /* for sockets. */
1939
Arnaud Patard (Rtp)5f106812009-06-03 14:35:04 +02001940#if defined(TARGET_MIPS)
1941#define TARGET_F_GETLK64 33 /* using 'struct flock64' */
1942#define TARGET_F_SETLK64 34
1943#define TARGET_F_SETLKW64 35
1944#else
bellard2521d692003-06-15 19:58:13 +00001945#define TARGET_F_GETLK64 12 /* using 'struct flock64' */
1946#define TARGET_F_SETLK64 13
1947#define TARGET_F_SETLKW64 14
Arnaud Patard (Rtp)5f106812009-06-03 14:35:04 +02001948#endif
Ulrich Hecht7e22e542009-07-24 19:10:27 +02001949
1950#define TARGET_F_LINUX_SPECIFIC_BASE 1024
1951#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
1952#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
1953#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
1954#define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
1955
bellardf09936a2004-01-18 22:39:25 +00001956#if defined (TARGET_ARM)
1957#define TARGET_O_ACCMODE 0003
1958#define TARGET_O_RDONLY 00
1959#define TARGET_O_WRONLY 01
1960#define TARGET_O_RDWR 02
1961#define TARGET_O_CREAT 0100 /* not fcntl */
1962#define TARGET_O_EXCL 0200 /* not fcntl */
1963#define TARGET_O_NOCTTY 0400 /* not fcntl */
1964#define TARGET_O_TRUNC 01000 /* not fcntl */
1965#define TARGET_O_APPEND 02000
1966#define TARGET_O_NONBLOCK 04000
bellard048f6b42005-11-26 18:47:20 +00001967#define TARGET_O_NDELAY TARGET_O_NONBLOCK
bellardf09936a2004-01-18 22:39:25 +00001968#define TARGET_O_SYNC 010000
1969#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
1970#define TARGET_O_DIRECTORY 040000 /* must be a directory */
1971#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */
1972#define TARGET_O_DIRECT 0200000 /* direct disk access hint */
1973#define TARGET_O_LARGEFILE 0400000
1974#elif defined (TARGET_PPC)
bellardffa65c32004-01-04 23:57:22 +00001975#define TARGET_O_ACCMODE 0003
1976#define TARGET_O_RDONLY 00
1977#define TARGET_O_WRONLY 01
1978#define TARGET_O_RDWR 02
1979#define TARGET_O_CREAT 0100 /* not fcntl */
1980#define TARGET_O_EXCL 0200 /* not fcntl */
1981#define TARGET_O_NOCTTY 0400 /* not fcntl */
1982#define TARGET_O_TRUNC 01000 /* not fcntl */
1983#define TARGET_O_APPEND 02000
1984#define TARGET_O_NONBLOCK 04000
bellard048f6b42005-11-26 18:47:20 +00001985#define TARGET_O_NDELAY TARGET_O_NONBLOCK
bellardffa65c32004-01-04 23:57:22 +00001986#define TARGET_O_SYNC 010000
1987#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
1988#define TARGET_O_DIRECTORY 040000 /* must be a directory */
1989#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */
1990#define TARGET_O_LARGEFILE 0200000
1991#define TARGET_O_DIRECT 0400000 /* direct disk access hint */
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02001992#elif defined (TARGET_MICROBLAZE)
1993#define TARGET_O_ACCMODE 0003
1994#define TARGET_O_RDONLY 00
1995#define TARGET_O_WRONLY 01
1996#define TARGET_O_RDWR 02
1997#define TARGET_O_CREAT 0100 /* not fcntl */
1998#define TARGET_O_EXCL 0200 /* not fcntl */
1999#define TARGET_O_NOCTTY 0400 /* not fcntl */
2000#define TARGET_O_TRUNC 01000 /* not fcntl */
2001#define TARGET_O_APPEND 02000
2002#define TARGET_O_NONBLOCK 04000
2003#define TARGET_O_NDELAY TARGET_O_NONBLOCK
2004#define TARGET_O_SYNC 010000
2005#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
2006#define TARGET_O_DIRECTORY 040000 /* must be a directory */
2007#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */
2008#define TARGET_O_LARGEFILE 0200000
2009#define TARGET_O_DIRECT 0400000 /* direct disk access hint */
bellard6d5e2162004-09-30 22:04:13 +00002010#elif defined (TARGET_SPARC)
2011#define TARGET_O_RDONLY 0x0000
2012#define TARGET_O_WRONLY 0x0001
2013#define TARGET_O_RDWR 0x0002
2014#define TARGET_O_ACCMODE 0x0003
2015#define TARGET_O_APPEND 0x0008
2016#define TARGET_FASYNC 0x0040 /* fcntl, for BSD compatibility */
2017#define TARGET_O_CREAT 0x0200 /* not fcntl */
2018#define TARGET_O_TRUNC 0x0400 /* not fcntl */
2019#define TARGET_O_EXCL 0x0800 /* not fcntl */
2020#define TARGET_O_SYNC 0x2000
2021#define TARGET_O_NONBLOCK 0x4000
bellard048f6b42005-11-26 18:47:20 +00002022#define TARGET_O_NDELAY (0x0004 | TARGET_O_NONBLOCK)
bellard6d5e2162004-09-30 22:04:13 +00002023#define TARGET_O_NOCTTY 0x8000 /* not fcntl */
2024#define TARGET_O_DIRECTORY 0x10000 /* must be a directory */
2025#define TARGET_O_NOFOLLOW 0x20000 /* don't follow links */
2026#define TARGET_O_LARGEFILE 0x40000
2027#define TARGET_O_DIRECT 0x100000 /* direct disk access hint */
bellard048f6b42005-11-26 18:47:20 +00002028#elif defined(TARGET_MIPS)
2029#define TARGET_O_ACCMODE 0x0003
2030#define TARGET_O_RDONLY 0x0000
2031#define TARGET_O_WRONLY 0x0001
2032#define TARGET_O_RDWR 0x0002
2033#define TARGET_O_APPEND 0x0008
2034#define TARGET_O_SYNC 0x0010
2035#define TARGET_O_NONBLOCK 0x0080
2036#define TARGET_O_CREAT 0x0100 /* not fcntl */
2037#define TARGET_O_TRUNC 0x0200 /* not fcntl */
2038#define TARGET_O_EXCL 0x0400 /* not fcntl */
2039#define TARGET_O_NOCTTY 0x0800 /* not fcntl */
2040#define TARGET_FASYNC 0x1000 /* fcntl, for BSD compatibility */
2041#define TARGET_O_LARGEFILE 0x2000 /* allow large file opens */
2042#define TARGET_O_DIRECT 0x8000 /* direct disk access hint */
2043#define TARGET_O_DIRECTORY 0x10000 /* must be a directory */
2044#define TARGET_O_NOFOLLOW 0x20000 /* don't follow links */
2045#define TARGET_O_NOATIME 0x40000
2046#define TARGET_O_NDELAY TARGET_O_NONBLOCK
aurel321f961122008-11-11 11:30:48 +00002047#elif defined(TARGET_ALPHA)
2048#define TARGET_O_ACCMODE 0x0003
2049#define TARGET_O_RDONLY 0x0000
2050#define TARGET_O_WRONLY 0x0001
2051#define TARGET_O_RDWR 0x0002
2052#define TARGET_O_APPEND 0x0008
2053#define TARGET_O_SYNC 0x4000
2054#define TARGET_O_NONBLOCK 0x0004
2055#define TARGET_O_CREAT 0x0200 /* not fcntl */
2056#define TARGET_O_TRUNC 0x0400 /* not fcntl */
2057#define TARGET_O_EXCL 0x0800 /* not fcntl */
2058#define TARGET_O_NOCTTY 0x1000 /* not fcntl */
2059#define TARGET_FASYNC 0x2000 /* fcntl, for BSD compatibility */
2060#define TARGET_O_LARGEFILE 0x0000 /* not necessary, always 64-bit */
2061#define TARGET_O_DIRECT 0x80000 /* direct disk access hint */
2062#define TARGET_O_DIRECTORY 0x8000 /* must be a directory */
2063#define TARGET_O_NOFOLLOW 0x10000 /* don't follow links */
2064#define TARGET_O_NOATIME 0x100000
2065#define TARGET_O_NDELAY TARGET_O_NONBLOCK
bellardffa65c32004-01-04 23:57:22 +00002066#else
2067#define TARGET_O_ACCMODE 0003
2068#define TARGET_O_RDONLY 00
2069#define TARGET_O_WRONLY 01
2070#define TARGET_O_RDWR 02
2071#define TARGET_O_CREAT 0100 /* not fcntl */
2072#define TARGET_O_EXCL 0200 /* not fcntl */
2073#define TARGET_O_NOCTTY 0400 /* not fcntl */
2074#define TARGET_O_TRUNC 01000 /* not fcntl */
2075#define TARGET_O_APPEND 02000
2076#define TARGET_O_NONBLOCK 04000
bellard048f6b42005-11-26 18:47:20 +00002077#define TARGET_O_NDELAY TARGET_O_NONBLOCK
bellardffa65c32004-01-04 23:57:22 +00002078#define TARGET_O_SYNC 010000
2079#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
2080#define TARGET_O_DIRECT 040000 /* direct disk access hint */
2081#define TARGET_O_LARGEFILE 0100000
2082#define TARGET_O_DIRECTORY 0200000 /* must be a directory */
2083#define TARGET_O_NOFOLLOW 0400000 /* don't follow links */
2084#endif
2085
bellard2521d692003-06-15 19:58:13 +00002086struct target_flock {
2087 short l_type;
2088 short l_whence;
blueswir1992f48a2007-10-14 16:27:31 +00002089 abi_ulong l_start;
2090 abi_ulong l_len;
bellard2521d692003-06-15 19:58:13 +00002091 int l_pid;
2092};
2093
2094struct target_flock64 {
2095 short l_type;
2096 short l_whence;
Edgar E. Iglesiasb779e292009-05-20 21:31:33 +02002097#if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) || defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined (TARGET_MICROBLAZE)
aurel32ce3f0e22008-03-28 22:31:51 +00002098 int __pad;
2099#endif
bellard2521d692003-06-15 19:58:13 +00002100 unsigned long long l_start;
2101 unsigned long long l_len;
2102 int l_pid;
Stefan Weil541dc0d2011-08-31 12:38:01 +02002103} QEMU_PACKED;
bellard2521d692003-06-15 19:58:13 +00002104
pbrookce4defa2006-02-09 16:49:55 +00002105#ifdef TARGET_ARM
2106struct target_eabi_flock64 {
2107 short l_type;
2108 short l_whence;
2109 int __pad;
2110 unsigned long long l_start;
2111 unsigned long long l_len;
2112 int l_pid;
Stefan Weil541dc0d2011-08-31 12:38:01 +02002113} QEMU_PACKED;
pbrookce4defa2006-02-09 16:49:55 +00002114#endif
bellard2521d692003-06-15 19:58:13 +00002115
2116/* soundcard defines */
2117/* XXX: convert them all to arch indepedent entries */
2118#define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
2119#define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
2120#define TARGET_SNDCTL_COPR_RCODE 0xc0144303
2121#define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
2122#define TARGET_SNDCTL_COPR_RDATA 0xc0144302
2123#define TARGET_SNDCTL_COPR_RESET 0x00004300
2124#define TARGET_SNDCTL_COPR_RUN 0xc0144306
2125#define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
2126#define TARGET_SNDCTL_COPR_WCODE 0x40144305
2127#define TARGET_SNDCTL_COPR_WDATA 0x40144304
2128#define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
2129#define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
2130#define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
2131#define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
2132#define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
2133#define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
2134#define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
2135#define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
2136#define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
2137#define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
2138#define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
2139#define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
2140#define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
2141#define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
2142#define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
2143#define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
2144#define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
2145#define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
2146#define TARGET_SNDCTL_DSP_MAPINBUF 0x80085013
2147#define TARGET_SNDCTL_DSP_MAPOUTBUF 0x80085014
2148#define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
2149#define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
2150#define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
2151#define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
2152#define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
2153#define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
2154#define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
2155#define TARGET_SNDCTL_MIDI_INFO 0xc074510c
2156#define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
2157#define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
2158#define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
2159#define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
2160#define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
2161#define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
2162#define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
2163#define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
2164#define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
2165#define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
2166#define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
2167#define TARGET_SNDCTL_SEQ_PANIC 0x00005111
2168#define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
2169#define TARGET_SNDCTL_SEQ_RESET 0x00005100
2170#define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
2171#define TARGET_SNDCTL_SEQ_SYNC 0x00005101
2172#define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
2173#define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
2174#define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
2175#define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
2176#define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
2177#define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
2178#define TARGET_SNDCTL_TMR_METRONOME 0x40045407
2179#define TARGET_SNDCTL_TMR_SELECT 0x40045408
2180#define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
2181#define TARGET_SNDCTL_TMR_START 0x00005402
2182#define TARGET_SNDCTL_TMR_STOP 0x00005403
2183#define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
2184#define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
2185#define TARGET_SOUND_PCM_READ_RATE 0x80045002
2186#define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
2187#define TARGET_SOUND_PCM_READ_BITS 0x80045005
2188#define TARGET_SOUND_PCM_READ_FILTER 0x80045007
2189#define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
2190#define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
2191#define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
2192#define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
2193#define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
2194#define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
2195#define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
2196
2197#define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
2198
2199#define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
2200#define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
2201#define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
2202#define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
2203#define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
2204#define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
2205#define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
2206#define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
2207#define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
2208#define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
2209#define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
2210#define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
2211#define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
2212#define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
2213#define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
2214#define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
2215#define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
2216
2217/* Obsolete macros */
2218#define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
2219#define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
2220#define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
2221
2222#define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
2223#define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
2224#define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
2225#define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
2226#define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
2227
2228#define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
2229
2230#define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
2231#define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
2232#define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
2233#define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
2234#define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
2235#define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
2236#define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
2237#define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
2238#define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
2239#define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
2240#define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
2241#define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
2242#define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
2243#define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
2244#define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
2245#define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
2246#define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
2247
2248/* Obsolete macros */
2249#define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
2250#define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
2251#define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
2252
2253#define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
2254
2255/* vfat ioctls */
2256#define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
2257#define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
bellarda5448a72004-06-19 16:59:03 +00002258
balrog8fbd6b52008-09-20 03:03:09 +00002259#define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct mtop)
2260#define TARGET_MTIOCGET TARGET_IOR('m', 2, struct mtget)
2261#define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct mtpos)
2262
bellarda5448a72004-06-19 16:59:03 +00002263struct target_sysinfo {
blueswir1992f48a2007-10-14 16:27:31 +00002264 abi_long uptime; /* Seconds since boot */
2265 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
2266 abi_ulong totalram; /* Total usable main memory size */
2267 abi_ulong freeram; /* Available memory size */
2268 abi_ulong sharedram; /* Amount of shared memory */
2269 abi_ulong bufferram; /* Memory used by buffers */
2270 abi_ulong totalswap; /* Total swap space size */
2271 abi_ulong freeswap; /* swap space still available */
bellarda5448a72004-06-19 16:59:03 +00002272 unsigned short procs; /* Number of current processes */
2273 unsigned short pad; /* explicit padding for m68k */
blueswir1992f48a2007-10-14 16:27:31 +00002274 abi_ulong totalhigh; /* Total high memory size */
2275 abi_ulong freehigh; /* Available high memory size */
bellarda5448a72004-06-19 16:59:03 +00002276 unsigned int mem_unit; /* Memory unit size in bytes */
blueswir1992f48a2007-10-14 16:27:31 +00002277 char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
bellarda5448a72004-06-19 16:59:03 +00002278};
bellard3532fa72006-06-24 15:06:03 +00002279
aurel326556a832008-10-13 21:08:17 +00002280struct linux_dirent {
2281 long d_ino;
2282 unsigned long d_off;
2283 unsigned short d_reclen;
2284 char d_name[256]; /* We must not include limits.h! */
2285};
2286
2287struct linux_dirent64 {
2288 uint64_t d_ino;
2289 int64_t d_off;
2290 unsigned short d_reclen;
2291 unsigned char d_type;
2292 char d_name[256];
2293};
2294
aurel3224e10032009-04-15 16:11:43 +00002295struct target_mq_attr {
2296 abi_long mq_flags;
2297 abi_long mq_maxmsg;
2298 abi_long mq_msgsize;
2299 abi_long mq_curmsgs;
2300};
2301
bellard3532fa72006-06-24 15:06:03 +00002302#include "socket.h"
ths637947f2007-06-01 12:09:19 +00002303
2304#include "errno_defs.h"
Riku Voipio03dfe9f2009-06-18 22:51:31 +03002305
2306#define FUTEX_WAIT 0
2307#define FUTEX_WAKE 1
2308#define FUTEX_FD 2
2309#define FUTEX_REQUEUE 3
2310#define FUTEX_CMP_REQUEUE 4
2311#define FUTEX_WAKE_OP 5
2312#define FUTEX_LOCK_PI 6
2313#define FUTEX_UNLOCK_PI 7
2314#define FUTEX_TRYLOCK_PI 8
2315#define FUTEX_WAIT_BITSET 9
2316#define FUTEX_WAKE_BITSET 10
2317
2318#define FUTEX_PRIVATE_FLAG 128
2319#define FUTEX_CLOCK_REALTIME 256
2320#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2321
Peter Maydell3b6edd12011-02-15 18:35:05 +00002322#ifdef CONFIG_EPOLL
2323typedef union target_epoll_data {
2324 abi_ulong ptr;
2325 abi_ulong fd;
2326 uint32_t u32;
2327 uint64_t u64;
2328} target_epoll_data_t;
2329
2330struct target_epoll_event {
2331 uint32_t events;
2332 target_epoll_data_t data;
2333};
2334#endif
Peter Maydell163a05a2011-06-27 17:44:52 +01002335struct target_rlimit64 {
2336 uint64_t rlim_cur;
2337 uint64_t rlim_max;
2338};