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