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