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