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