syscall_defs.h 96.2 KB
Newer Older
1 2
/* 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 6
   necessary */

P
Paolo Bonzini 已提交
7
#ifndef SYSCALL_DEFS_H
8
#define SYSCALL_DEFS_H
P
Paolo Bonzini 已提交
9

B
bellard 已提交
10
#include "syscall_nr.h"
11

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

/* socket operations for socketcall() */
#define TARGET_SYS_SOCKET       1         /* socket()              */
#define TARGET_SYS_BIND         2         /* bind()                */
#define TARGET_SYS_CONNECT      3         /* connect()             */
#define TARGET_SYS_LISTEN       4         /* listen()              */
#define TARGET_SYS_ACCEPT       5         /* accept()              */
#define TARGET_SYS_GETSOCKNAME  6         /* getsockname()         */
#define TARGET_SYS_GETPEERNAME  7         /* getpeername()         */
#define TARGET_SYS_SOCKETPAIR   8         /* socketpair()          */
#define TARGET_SYS_SEND         9         /* send()                */
#define TARGET_SYS_RECV         10        /* recv()                */
#define TARGET_SYS_SENDTO       11        /* sendto()              */
#define TARGET_SYS_RECVFROM     12        /* recvfrom()            */
#define TARGET_SYS_SHUTDOWN     13        /* shutdown()            */
#define TARGET_SYS_SETSOCKOPT   14        /* setsockopt()          */
#define TARGET_SYS_GETSOCKOPT   15        /* getsockopt()          */
#define TARGET_SYS_SENDMSG      16        /* sendmsg()             */
#define TARGET_SYS_RECVMSG      17        /* recvmsg()             */
#define TARGET_SYS_ACCEPT4      18        /* accept4()             */
#define TARGET_SYS_RECVMMSG     19        /* recvmmsg()            */
#define TARGET_SYS_SENDMMSG     20        /* sendmmsg()            */
34

35 36 37 38 39 40 41 42 43 44 45 46 47
#define IPCOP_semop		1
#define IPCOP_semget		2
#define IPCOP_semctl		3
#define IPCOP_semtimedop	4
#define IPCOP_msgsnd		11
#define IPCOP_msgrcv		12
#define IPCOP_msgget		13
#define IPCOP_msgctl		14
#define IPCOP_shmat		21
#define IPCOP_shmdt		22
#define IPCOP_shmget		23
#define IPCOP_shmctl		24

48 49 50 51 52 53 54 55 56 57 58
/*
 * The following is for compatibility across the various Linux
 * platforms.  The i386 ioctl numbering scheme doesn't really enforce
 * a type field.  De facto, however, the top 8 bits of the lower 16
 * bits are indeed used as a type field, so we might just as well make
 * this explicit here.  Please be sure to use the decoding macros
 * below from now on.
 */
#define TARGET_IOC_NRBITS	8
#define TARGET_IOC_TYPEBITS	8

59 60
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
    || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
61
    || defined(TARGET_SPARC) \
62
    || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
63 64
    /* 16 bit uid wrappers emulation */
#define USE_UID16
65 66 67
#define target_id uint16_t
#else
#define target_id uint32_t
68 69
#endif

P
pbrook 已提交
70
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
71 72
    || defined(TARGET_M68K) || defined(TARGET_CRIS) \
    || defined(TARGET_UNICORE32) || defined(TARGET_S390X) \
73
    || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
M
Michael Clark 已提交
74
    || defined(TARGET_NIOS2) || defined(TARGET_RISCV)
75 76 77 78 79 80 81 82

#define TARGET_IOC_SIZEBITS	14
#define TARGET_IOC_DIRBITS	2

#define TARGET_IOC_NONE	  0U
#define TARGET_IOC_WRITE  1U
#define TARGET_IOC_READ	  2U

B
bellard 已提交
83
#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
84 85
      defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
      defined(TARGET_MIPS)
86 87 88 89 90 91 92 93

#define TARGET_IOC_SIZEBITS	13
#define TARGET_IOC_DIRBITS	3

#define TARGET_IOC_NONE	  1U
#define TARGET_IOC_READ	  2U
#define TARGET_IOC_WRITE  4U

94 95 96 97 98 99 100 101 102
#elif defined(TARGET_HPPA)

#define TARGET_IOC_SIZEBITS  14
#define TARGET_IOC_DIRBITS    2

#define TARGET_IOC_NONE   0U
#define TARGET_IOC_WRITE  2U
#define TARGET_IOC_READ   1U

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
#else
#error unsupported CPU
#endif

#define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
#define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
#define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
#define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)

#define TARGET_IOC_NRSHIFT	0
#define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
#define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
#define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)

#define TARGET_IOC(dir,type,nr,size) \
	(((dir)  << TARGET_IOC_DIRSHIFT) | \
	 ((type) << TARGET_IOC_TYPESHIFT) | \
	 ((nr)   << TARGET_IOC_NRSHIFT) | \
	 ((size) << TARGET_IOC_SIZESHIFT))

/* used to create numbers */
#define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
#define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
#define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
#define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))

/* the size is automatically computed for these defines */
#define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
#define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
#define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)

B
bellard 已提交
134 135 136 137 138
struct target_sockaddr {
    uint16_t sa_family;
    uint8_t sa_data[14];
};

139 140 141 142 143 144 145 146 147 148
struct target_sockaddr_ll {
    uint16_t sll_family;   /* Always AF_PACKET */
    uint16_t sll_protocol; /* Physical layer protocol */
    int      sll_ifindex;  /* Interface number */
    uint16_t sll_hatype;   /* ARP hardware type */
    uint8_t  sll_pkttype;  /* Packet type */
    uint8_t  sll_halen;    /* Length of address */
    uint8_t  sll_addr[8];  /* Physical layer address */
};

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
struct target_sockaddr_un {
    uint16_t su_family;
    uint8_t sun_path[108];
};

struct target_in_addr {
    uint32_t s_addr; /* big endian */
};

struct target_sockaddr_in {
  uint16_t sin_family;
  int16_t sin_port; /* big endian */
  struct target_in_addr sin_addr;
  uint8_t __pad[sizeof(struct target_sockaddr) -
                sizeof(uint16_t) - sizeof(int16_t) -
                sizeof(struct target_in_addr)];
};

167 168 169 170 171 172 173 174
struct target_sockaddr_in6 {
    uint16_t sin6_family;
    uint16_t sin6_port; /* big endian */
    uint32_t sin6_flowinfo; /* big endian */
    struct in6_addr sin6_addr; /* IPv6 address, big endian */
    uint32_t sin6_scope_id;
};

175 176 177 178 179 180 181 182 183 184 185 186
struct target_sock_filter {
    abi_ushort code;
    uint8_t jt;
    uint8_t jf;
    abi_uint k;
};

struct target_sock_fprog {
    abi_ushort len;
    abi_ulong filter;
};

187 188 189 190 191 192 193 194 195 196 197
struct target_ip_mreq {
    struct target_in_addr imr_multiaddr;
    struct target_in_addr imr_address;
};

struct target_ip_mreqn {
    struct target_in_addr imr_multiaddr;
    struct target_in_addr imr_address;
    abi_long imr_ifindex;
};

198 199 200 201 202 203 204
struct target_ip_mreq_source {
    /* big endian */
    uint32_t imr_multiaddr;
    uint32_t imr_interface;
    uint32_t imr_sourceaddr;
};

205
struct target_timeval {
206 207
    abi_long tv_sec;
    abi_long tv_usec;
208 209
};

B
bellard 已提交
210
struct target_timespec {
211 212
    abi_long tv_sec;
    abi_long tv_nsec;
B
bellard 已提交
213 214
};

215 216 217 218 219
struct target_timezone {
    abi_int tz_minuteswest;
    abi_int tz_dsttime;
};

B
bellard 已提交
220 221 222 223 224
struct target_itimerval {
    struct target_timeval it_interval;
    struct target_timeval it_value;
};

225 226 227 228 229
struct target_itimerspec {
    struct target_timespec it_interval;
    struct target_timespec it_value;
};

230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
struct target_timex {
    abi_uint modes;              /* Mode selector */
    abi_long offset;             /* Time offset */
    abi_long freq;               /* Frequency offset */
    abi_long maxerror;           /* Maximum error (microseconds) */
    abi_long esterror;           /* Estimated error (microseconds) */
    abi_int status;              /* Clock command/status */
    abi_long constant;           /* PLL (phase-locked loop) time constant */
    abi_long precision;          /* Clock precision (microseconds, ro) */
    abi_long tolerance;          /* Clock freq. tolerance (ppm, ro) */
    struct target_timeval time;  /* Current time */
    abi_long tick;               /* Microseconds between clock ticks */
    abi_long ppsfreq;            /* PPS (pulse per second) frequency */
    abi_long jitter;             /* PPS jitter (ro); nanoseconds */
    abi_int shift;               /* PPS interval duration (seconds) */
    abi_long stabil;             /* PPS stability */
    abi_long jitcnt;             /* PPS jitter limit exceeded (ro) */
    abi_long calcnt;             /* PPS calibration intervals */
    abi_long errcnt;             /* PPS calibration errors */
    abi_long stbcnt;             /* PPS stability limit exceeded */
    abi_int tai;                 /* TAI offset */

    /* Further padding bytes to allow for future expansion */
    abi_int:32; abi_int:32; abi_int:32; abi_int:32;
    abi_int:32; abi_int:32; abi_int:32; abi_int:32;
    abi_int:32; abi_int:32; abi_int:32;
};

A
Anthony Liguori 已提交
258
typedef abi_long target_clock_t;
B
bellard 已提交
259

B
bellard 已提交
260 261
#define TARGET_HZ 100

B
bellard 已提交
262
struct target_tms {
A
Anthony Liguori 已提交
263 264 265 266
    target_clock_t tms_utime;
    target_clock_t tms_stime;
    target_clock_t tms_cutime;
    target_clock_t tms_cstime;
B
bellard 已提交
267 268
};

B
bellard 已提交
269
struct target_utimbuf {
270 271
    abi_long actime;
    abi_long modtime;
B
bellard 已提交
272 273
};

B
bellard 已提交
274
struct target_sel_arg_struct {
275 276 277
    abi_long n;
    abi_long inp, outp, exp;
    abi_long tvp;
B
bellard 已提交
278 279
};

280
struct target_iovec {
281 282
    abi_long iov_base;   /* Starting address */
    abi_long iov_len;   /* Number of bytes */
283 284
};

B
bellard 已提交
285
struct target_msghdr {
286 287 288 289 290 291
    abi_long	 msg_name;	 /* Socket name			*/
    int		 msg_namelen;	 /* Length of name		*/
    abi_long	 msg_iov;	 /* Data blocks			*/
    abi_long	 msg_iovlen;	 /* Number of blocks		*/
    abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
    abi_long	 msg_controllen; /* Length of cmsg list */
B
bellard 已提交
292 293 294
    unsigned int msg_flags;
};

B
bellard 已提交
295
struct target_cmsghdr {
296
    abi_long     cmsg_len;
B
bellard 已提交
297 298 299 300 301
    int          cmsg_level;
    int          cmsg_type;
};

#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
302 303
#define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
                               __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
304 305
#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
                               & (size_t) ~(sizeof (abi_long) - 1))
306 307 308
#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
                                TARGET_CMSG_ALIGN(len))
#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
B
bellard 已提交
309 310

static __inline__ struct target_cmsghdr *
311 312 313
__target_cmsg_nxthdr(struct target_msghdr *__mhdr,
                     struct target_cmsghdr *__cmsg,
                     struct target_cmsghdr *__cmsg_start)
B
bellard 已提交
314
{
315 316 317
  struct target_cmsghdr *__ptr;

  __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
318
                                    + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
319 320
  if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
      > tswapal(__mhdr->msg_controllen)) {
B
bellard 已提交
321
    /* No more entries.  */
322
    return (struct target_cmsghdr *)0;
323 324
  }
  return __ptr;
B
bellard 已提交
325 326
}

327 328 329 330
struct target_mmsghdr {
    struct target_msghdr msg_hdr;              /* Message header */
    unsigned int         msg_len;              /* Number of bytes transmitted */
};
B
bellard 已提交
331

332 333 334
struct  target_rusage {
        struct target_timeval ru_utime;        /* user time used */
        struct target_timeval ru_stime;        /* system time used */
335 336 337 338 339 340 341 342 343 344 345 346 347 348
        abi_long    ru_maxrss;                 /* maximum resident set size */
        abi_long    ru_ixrss;                  /* integral shared memory size */
        abi_long    ru_idrss;                  /* integral unshared data size */
        abi_long    ru_isrss;                  /* integral unshared stack size */
        abi_long    ru_minflt;                 /* page reclaims */
        abi_long    ru_majflt;                 /* page faults */
        abi_long    ru_nswap;                  /* swaps */
        abi_long    ru_inblock;                /* block input operations */
        abi_long    ru_oublock;                /* block output operations */
        abi_long    ru_msgsnd;                 /* messages sent */
        abi_long    ru_msgrcv;                 /* messages received */
        abi_long    ru_nsignals;               /* signals received */
        abi_long    ru_nvcsw;                  /* voluntary context switches */
        abi_long    ru_nivcsw;                 /* involuntary " */
349 350 351 352
};

typedef struct {
        int     val[2];
A
Anthony Liguori 已提交
353
} kernel_fsid_t;
354

B
bellard 已提交
355
struct kernel_statfs {
356 357 358 359 360 361 362
	int f_type;
	int f_bsize;
	int f_blocks;
	int f_bfree;
	int f_bavail;
	int f_files;
	int f_ffree;
A
Anthony Liguori 已提交
363
        kernel_fsid_t f_fsid;
364 365 366 367
	int f_namelen;
	int f_spare[6];
};

B
bellard 已提交
368
struct target_dirent {
369 370 371 372
        abi_long        d_ino;
        abi_long        d_off;
        unsigned short  d_reclen;
        char            d_name[];
B
bellard 已提交
373 374 375 376 377 378 379 380 381 382 383
};

struct target_dirent64 {
	uint64_t	d_ino;
	int64_t		d_off;
	unsigned short	d_reclen;
	unsigned char	d_type;
	char		d_name[256];
};


384
/* mostly generic signal stuff */
385 386 387
#define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
#define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
#define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
388 389 390 391 392 393

#ifdef TARGET_MIPS
#define TARGET_NSIG	   128
#else
#define TARGET_NSIG	   64
#endif
394
#define TARGET_NSIG_BPW	   TARGET_ABI_BITS
395 396 397
#define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)

typedef struct {
398
    abi_ulong sig[TARGET_NSIG_WORDS];
A
Anthony Liguori 已提交
399
} target_sigset_t;
400

B
bellard 已提交
401
#ifdef BSWAP_NEEDED
A
Anthony Liguori 已提交
402
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
B
bellard 已提交
403 404 405
{
    int i;
    for(i = 0;i < TARGET_NSIG_WORDS; i++)
406
        d->sig[i] = tswapal(s->sig[i]);
B
bellard 已提交
407 408
}
#else
A
Anthony Liguori 已提交
409
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
B
bellard 已提交
410 411 412 413 414
{
    *d = *s;
}
#endif

A
Anthony Liguori 已提交
415
static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
B
bellard 已提交
416 417 418 419 420 421 422
{
    int i;
    d->sig[0] = set;
    for(i = 1;i < TARGET_NSIG_WORDS; i++)
        d->sig[i] = 0;
}

A
Anthony Liguori 已提交
423 424
void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
425
void host_to_target_old_sigset(abi_ulong *old_sigset,
B
bellard 已提交
426
                               const sigset_t *sigset);
427
void target_to_host_old_sigset(sigset_t *sigset,
428
                               const abi_ulong *old_sigset);
B
bellard 已提交
429 430 431 432
struct target_sigaction;
int do_sigaction(int sig, const struct target_sigaction *act,
                 struct target_sigaction *oact);

433 434 435
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
    || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
    || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
U
Ulrich Hecht 已提交
436
    || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
437
    || defined(TARGET_S390X) || defined(TARGET_OPENRISC) \
M
Michael Clark 已提交
438 439
    || defined(TARGET_TILEGX) || defined(TARGET_HPPA) || defined(TARGET_NIOS2) \
    || defined(TARGET_RISCV)
440

B
bellard 已提交
441 442 443 444 445 446 447 448
#if defined(TARGET_SPARC)
#define TARGET_SA_NOCLDSTOP    8u
#define TARGET_SA_NOCLDWAIT    0x100u
#define TARGET_SA_SIGINFO      0x200u
#define TARGET_SA_ONSTACK      1u
#define TARGET_SA_RESTART      2u
#define TARGET_SA_NODEFER      0x20u
#define TARGET_SA_RESETHAND    4u
449
#define TARGET_ARCH_HAS_SA_RESTORER 1
B
bellard 已提交
450 451 452 453 454 455 456 457
#elif defined(TARGET_MIPS)
#define TARGET_SA_NOCLDSTOP	0x00000001
#define TARGET_SA_NOCLDWAIT	0x00010000
#define TARGET_SA_SIGINFO	0x00000008
#define TARGET_SA_ONSTACK	0x08000000
#define TARGET_SA_NODEFER	0x40000000
#define TARGET_SA_RESTART	0x10000000
#define TARGET_SA_RESETHAND	0x80000000
458 459
#if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
#define TARGET_SA_RESTORER	0x04000000	/* Only for O32 */
460
#endif
J
Jia Liu 已提交
461 462 463 464 465 466 467 468
#elif defined(TARGET_OPENRISC)
#define TARGET_SA_NOCLDSTOP    0x00000001
#define TARGET_SA_NOCLDWAIT    0x00000002
#define TARGET_SA_SIGINFO      0x00000004
#define TARGET_SA_ONSTACK      0x08000000
#define TARGET_SA_RESTART      0x10000000
#define TARGET_SA_NODEFER      0x40000000
#define TARGET_SA_RESETHAND    0x80000000
469 470 471 472 473 474 475 476
#elif defined(TARGET_ALPHA)
#define TARGET_SA_ONSTACK	0x00000001
#define TARGET_SA_RESTART	0x00000002
#define TARGET_SA_NOCLDSTOP	0x00000004
#define TARGET_SA_NODEFER	0x00000008
#define TARGET_SA_RESETHAND	0x00000010
#define TARGET_SA_NOCLDWAIT	0x00000020 /* not supported yet */
#define TARGET_SA_SIGINFO	0x00000040
477 478 479 480 481 482 483 484
#elif defined(TARGET_HPPA)
#define TARGET_SA_ONSTACK       0x00000001
#define TARGET_SA_RESETHAND     0x00000004
#define TARGET_SA_NOCLDSTOP     0x00000008
#define TARGET_SA_SIGINFO       0x00000010
#define TARGET_SA_NODEFER       0x00000020
#define TARGET_SA_RESTART       0x00000040
#define TARGET_SA_NOCLDWAIT     0x00000080
B
bellard 已提交
485
#else
486 487 488 489 490 491 492 493
#define TARGET_SA_NOCLDSTOP	0x00000001
#define TARGET_SA_NOCLDWAIT	0x00000002 /* not supported yet */
#define TARGET_SA_SIGINFO	0x00000004
#define TARGET_SA_ONSTACK	0x08000000
#define TARGET_SA_RESTART	0x10000000
#define TARGET_SA_NODEFER	0x40000000
#define TARGET_SA_RESETHAND	0x80000000
#define TARGET_SA_RESTORER	0x04000000
B
bellard 已提交
494 495
#endif

496 497 498 499
#ifdef TARGET_SA_RESTORER
#define TARGET_ARCH_HAS_SA_RESTORER 1
#endif

500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
#if defined(TARGET_ALPHA)

#define TARGET_SIGHUP            1
#define TARGET_SIGINT            2
#define TARGET_SIGQUIT           3
#define TARGET_SIGILL            4
#define TARGET_SIGTRAP           5
#define TARGET_SIGABRT           6
#define TARGET_SIGSTKFLT         7 /* actually SIGEMT */
#define TARGET_SIGFPE            8
#define TARGET_SIGKILL           9
#define TARGET_SIGBUS           10
#define TARGET_SIGSEGV          11
#define TARGET_SIGSYS           12
#define TARGET_SIGPIPE          13
#define TARGET_SIGALRM          14
#define TARGET_SIGTERM          15
#define TARGET_SIGURG           16
#define TARGET_SIGSTOP          17
#define TARGET_SIGTSTP          18
#define TARGET_SIGCONT          19
#define TARGET_SIGCHLD          20
#define TARGET_SIGTTIN          21
#define TARGET_SIGTTOU          22
#define TARGET_SIGIO            23
#define TARGET_SIGXCPU          24
#define TARGET_SIGXFSZ          25
#define TARGET_SIGVTALRM        26
#define TARGET_SIGPROF          27
#define TARGET_SIGWINCH         28
#define TARGET_SIGPWR           29 /* actually SIGINFO */
#define TARGET_SIGUSR1          30
#define TARGET_SIGUSR2          31
#define TARGET_SIGRTMIN         32

#define TARGET_SIG_BLOCK         1
#define TARGET_SIG_UNBLOCK       2
#define TARGET_SIG_SETMASK       3

#elif defined(TARGET_SPARC)
B
bellard 已提交
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578

#define TARGET_SIGHUP		 1
#define TARGET_SIGINT		 2
#define TARGET_SIGQUIT		 3
#define TARGET_SIGILL		 4
#define TARGET_SIGTRAP		 5
#define TARGET_SIGABRT		 6
#define TARGET_SIGIOT		 6
#define TARGET_SIGSTKFLT	 7 /* actually EMT */
#define TARGET_SIGFPE		 8
#define TARGET_SIGKILL		 9
#define TARGET_SIGBUS		10
#define TARGET_SIGSEGV		11
#define TARGET_SIGSYS		12
#define TARGET_SIGPIPE		13
#define TARGET_SIGALRM		14
#define TARGET_SIGTERM		15
#define TARGET_SIGURG		16
#define TARGET_SIGSTOP		17
#define TARGET_SIGTSTP		18
#define TARGET_SIGCONT		19
#define TARGET_SIGCHLD		20
#define TARGET_SIGTTIN		21
#define TARGET_SIGTTOU		22
#define TARGET_SIGIO		23
#define TARGET_SIGXCPU		24
#define TARGET_SIGXFSZ		25
#define TARGET_SIGVTALRM	26
#define TARGET_SIGPROF		27
#define TARGET_SIGWINCH	        28
#define TARGET_SIGPWR		29
#define TARGET_SIGUSR1		30
#define TARGET_SIGUSR2		31
#define TARGET_SIGRTMIN         32

#define TARGET_SIG_BLOCK          0x01 /* for blocking signals */
#define TARGET_SIG_UNBLOCK        0x02 /* for unblocking signals */
#define TARGET_SIG_SETMASK        0x04 /* for setting the signal mask */

B
bellard 已提交
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
#elif defined(TARGET_MIPS)

#define TARGET_SIGHUP		 1	/* Hangup (POSIX).  */
#define TARGET_SIGINT		 2	/* Interrupt (ANSI).  */
#define TARGET_SIGQUIT		 3	/* Quit (POSIX).  */
#define TARGET_SIGILL		 4	/* Illegal instruction (ANSI).  */
#define TARGET_SIGTRAP		 5	/* Trace trap (POSIX).  */
#define TARGET_SIGIOT		 6	/* IOT trap (4.2 BSD).  */
#define TARGET_SIGABRT		 TARGET_SIGIOT	/* Abort (ANSI).  */
#define TARGET_SIGEMT		 7
#define TARGET_SIGSTKFLT	 7 /* XXX: incorrect */
#define TARGET_SIGFPE		 8	/* Floating-point exception (ANSI).  */
#define TARGET_SIGKILL		 9	/* Kill, unblockable (POSIX).  */
#define TARGET_SIGBUS		10	/* BUS error (4.2 BSD).  */
#define TARGET_SIGSEGV		11	/* Segmentation violation (ANSI).  */
#define TARGET_SIGSYS		12
#define TARGET_SIGPIPE		13	/* Broken pipe (POSIX).  */
#define TARGET_SIGALRM		14	/* Alarm clock (POSIX).  */
#define TARGET_SIGTERM		15	/* Termination (ANSI).  */
#define TARGET_SIGUSR1		16	/* User-defined signal 1 (POSIX).  */
#define TARGET_SIGUSR2		17	/* User-defined signal 2 (POSIX).  */
#define TARGET_SIGCHLD		18	/* Child status has changed (POSIX).  */
#define TARGET_SIGCLD		TARGET_SIGCHLD	/* Same as TARGET_SIGCHLD (System V).  */
#define TARGET_SIGPWR		19	/* Power failure restart (System V).  */
#define TARGET_SIGWINCH	20	/* Window size change (4.3 BSD, Sun).  */
#define TARGET_SIGURG		21	/* Urgent condition on socket (4.2 BSD).  */
#define TARGET_SIGIO		22	/* I/O now possible (4.2 BSD).  */
#define TARGET_SIGPOLL		TARGET_SIGIO	/* Pollable event occurred (System V).  */
#define TARGET_SIGSTOP		23	/* Stop, unblockable (POSIX).  */
#define TARGET_SIGTSTP		24	/* Keyboard stop (POSIX).  */
#define TARGET_SIGCONT		25	/* Continue (POSIX).  */
#define TARGET_SIGTTIN		26	/* Background read from tty (POSIX).  */
#define TARGET_SIGTTOU		27	/* Background write to tty (POSIX).  */
#define TARGET_SIGVTALRM	28	/* Virtual alarm clock (4.2 BSD).  */
#define TARGET_SIGPROF		29	/* Profiling alarm clock (4.2 BSD).  */
#define TARGET_SIGXCPU		30	/* CPU limit exceeded (4.2 BSD).  */
#define TARGET_SIGXFSZ		31	/* File size limit exceeded (4.2 BSD).  */
#define TARGET_SIGRTMIN         32

#define TARGET_SIG_BLOCK	1	/* for blocking signals */
#define TARGET_SIG_UNBLOCK	2	/* for unblocking signals */
#define TARGET_SIG_SETMASK	3	/* for setting the signal mask */

622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
#elif defined(TARGET_HPPA)

#define TARGET_SIGHUP           1
#define TARGET_SIGINT           2
#define TARGET_SIGQUIT          3
#define TARGET_SIGILL           4
#define TARGET_SIGTRAP          5
#define TARGET_SIGABRT          6
#define TARGET_SIGIOT           6
#define TARGET_SIGSTKFLT        7
#define TARGET_SIGFPE           8
#define TARGET_SIGKILL          9
#define TARGET_SIGBUS          10
#define TARGET_SIGSEGV         11
#define TARGET_SIGXCPU         12
#define TARGET_SIGPIPE         13
#define TARGET_SIGALRM         14
#define TARGET_SIGTERM         15
#define TARGET_SIGUSR1         16
#define TARGET_SIGUSR2         17
#define TARGET_SIGCHLD         18
#define TARGET_SIGPWR          19
#define TARGET_SIGVTALRM       20
#define TARGET_SIGPROF         21
#define TARGET_SIGIO           22
#define TARGET_SIGPOLL         TARGET_SIGIO
#define TARGET_SIGWINCH        23
#define TARGET_SIGSTOP         24
#define TARGET_SIGTSTP         25
#define TARGET_SIGCONT         26
#define TARGET_SIGTTIN         27
#define TARGET_SIGTTOU         28
#define TARGET_SIGURG          29
#define TARGET_SIGXFSZ         30
#define TARGET_SIGSYS          31

#define TARGET_SIG_BLOCK       0
#define TARGET_SIG_UNBLOCK     1
#define TARGET_SIG_SETMASK     2

B
bellard 已提交
662
#else
663

J
Jia Liu 已提交
664
/* OpenRISC Using the general signals */
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
#define TARGET_SIGHUP		 1
#define TARGET_SIGINT		 2
#define TARGET_SIGQUIT		 3
#define TARGET_SIGILL		 4
#define TARGET_SIGTRAP		 5
#define TARGET_SIGABRT		 6
#define TARGET_SIGIOT		 6
#define TARGET_SIGBUS		 7
#define TARGET_SIGFPE		 8
#define TARGET_SIGKILL		 9
#define TARGET_SIGUSR1		10
#define TARGET_SIGSEGV		11
#define TARGET_SIGUSR2		12
#define TARGET_SIGPIPE		13
#define TARGET_SIGALRM		14
#define TARGET_SIGTERM		15
#define TARGET_SIGSTKFLT	16
#define TARGET_SIGCHLD		17
#define TARGET_SIGCONT		18
#define TARGET_SIGSTOP		19
#define TARGET_SIGTSTP		20
#define TARGET_SIGTTIN		21
#define TARGET_SIGTTOU		22
#define TARGET_SIGURG		23
#define TARGET_SIGXCPU		24
#define TARGET_SIGXFSZ		25
#define TARGET_SIGVTALRM	26
#define TARGET_SIGPROF		27
#define TARGET_SIGWINCH	        28
#define TARGET_SIGIO		29
B
bellard 已提交
695 696
#define TARGET_SIGPWR		30
#define TARGET_SIGSYS		31
697 698 699 700 701 702
#define TARGET_SIGRTMIN         32

#define TARGET_SIG_BLOCK          0    /* for blocking signals */
#define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
#define TARGET_SIG_SETMASK        2    /* for setting the signal mask */

B
bellard 已提交
703 704
#endif

705 706 707 708
#if defined(TARGET_ALPHA)
struct target_old_sigaction {
    abi_ulong _sa_handler;
    abi_ulong sa_mask;
709
    int32_t sa_flags;
710 711 712 713 714 715 716
};

struct target_rt_sigaction {
    abi_ulong _sa_handler;
    abi_ulong sa_flags;
    target_sigset_t sa_mask;
};
717

718 719 720 721 722 723 724 725 726
/* This is the struct used inside the kernel.  The ka_restorer
   field comes from the 5th argument to sys_rt_sigaction.  */
struct target_sigaction {
    abi_ulong _sa_handler;
    abi_ulong sa_flags;
    target_sigset_t sa_mask;
    abi_ulong sa_restorer;
};
#elif defined(TARGET_MIPS)
727
struct target_sigaction {
728
	uint32_t	sa_flags;
729
#if defined(TARGET_ABI_MIPSN32)
730 731
	uint32_t	_sa_handler;
#else
732
	abi_ulong	_sa_handler;
733
#endif
A
Anthony Liguori 已提交
734
	target_sigset_t	sa_mask;
735 736 737 738
#ifdef TARGET_ARCH_HAS_SA_RESTORER
        /* ??? This is always present, but ignored unless O32.  */
        abi_ulong sa_restorer;
#endif
739 740
};
#else
741
struct target_old_sigaction {
742 743 744
        abi_ulong _sa_handler;
        abi_ulong sa_mask;
        abi_ulong sa_flags;
745
#ifdef TARGET_ARCH_HAS_SA_RESTORER
746
        abi_ulong sa_restorer;
747
#endif
748 749 750
};

struct target_sigaction {
751 752
        abi_ulong _sa_handler;
        abi_ulong sa_flags;
753
#ifdef TARGET_ARCH_HAS_SA_RESTORER
754
        abi_ulong sa_restorer;
755
#endif
A
Anthony Liguori 已提交
756
        target_sigset_t sa_mask;
757
};
758
#endif
759 760 761

typedef union target_sigval {
	int sival_int;
762
        abi_ulong sival_ptr;
A
Anthony Liguori 已提交
763
} target_sigval_t;
B
bellard 已提交
764 765 766 767
#if 0
#if defined (TARGET_SPARC)
typedef struct {
	struct {
768 769 770 771 772
		abi_ulong psr;
		abi_ulong pc;
		abi_ulong npc;
		abi_ulong y;
		abi_ulong u_regs[16]; /* globals and ins */
B
bellard 已提交
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
	}		si_regs;
	int		si_mask;
} __siginfo_t;

typedef struct {
	unsigned   long si_float_regs [32];
	unsigned   long si_fsr;
	unsigned   long si_fpqdepth;
	struct {
		unsigned long *insn_addr;
		unsigned long insn;
	} si_fpqueue [16];
} __siginfo_fpu_t;
#endif
#endif
788 789

#define TARGET_SI_MAX_SIZE	128
790 791 792 793 794 795 796 797

#if TARGET_ABI_BITS == 32
#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
#else
#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
#endif

#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
798

799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
/* Within QEMU the top 16 bits of si_code indicate which of the parts of
 * the union in target_siginfo is valid. This only applies between
 * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
 * appear either within host siginfo_t or in target_siginfo structures
 * which we get from the guest userspace program. (The Linux kernel
 * does a similar thing with using the top bits for its own internal
 * purposes but not letting them be visible to userspace.)
 */
#define QEMU_SI_KILL 0
#define QEMU_SI_TIMER 1
#define QEMU_SI_POLL 2
#define QEMU_SI_FAULT 3
#define QEMU_SI_CHLD 4
#define QEMU_SI_RT 5

814
typedef struct target_siginfo {
P
pbrook 已提交
815 816 817 818 819
#ifdef TARGET_MIPS
	int si_signo;
	int si_code;
	int si_errno;
#else
820 821 822
	int si_signo;
	int si_errno;
	int si_code;
P
pbrook 已提交
823
#endif
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843

	union {
		int _pad[TARGET_SI_PAD_SIZE];

		/* kill() */
		struct {
			pid_t _pid;		/* sender's pid */
			uid_t _uid;		/* sender's uid */
		} _kill;

		/* POSIX.1b timers */
		struct {
			unsigned int _timer1;
			unsigned int _timer2;
		} _timer;

		/* POSIX.1b signals */
		struct {
			pid_t _pid;		/* sender's pid */
			uid_t _uid;		/* sender's uid */
A
Anthony Liguori 已提交
844
			target_sigval_t _sigval;
845 846 847 848 849 850 851
		} _rt;

		/* SIGCHLD */
		struct {
			pid_t _pid;		/* which child */
			uid_t _uid;		/* sender's uid */
			int _status;		/* exit code */
A
Anthony Liguori 已提交
852 853
			target_clock_t _utime;
                        target_clock_t _stime;
854 855 856 857
		} _sigchld;

		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
		struct {
858
			abi_ulong _addr; /* faulting insn/memory ref. */
859 860 861 862 863 864 865 866
		} _sigfault;

		/* SIGPOLL */
		struct {
			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
			int _fd;
		} _sigpoll;
	} _sifields;
A
Anthony Liguori 已提交
867
} target_siginfo_t;
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883

/*
 * si_code values
 * Digital reserves positive values for kernel-generated signals.
 */
#define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
#define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
#define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
#define TARGET_SI_TIMER -2              /* sent by timer expiration */
#define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
#define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
#define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */

/*
 * SIGILL si_codes
 */
B
bellard 已提交
884
#define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
885
#define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
B
bellard 已提交
886 887 888 889 890 891
#define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
#define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
#define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
#define TARGET_ILL_PRVREG	(6)	/* privileged register */
#define TARGET_ILL_COPROC	(7)	/* coprocessor error */
#define TARGET_ILL_BADSTK	(8)	/* internal stack error */
892 893 894 895
#ifdef TARGET_TILEGX
#define TARGET_ILL_DBLFLT       (9)     /* double fault */
#define TARGET_ILL_HARDWALL     (10)    /* user networks hardwall violation */
#endif
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914

/*
 * SIGFPE si_codes
 */
#define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
#define TARGET_FPE_INTOVF      (2)  /* integer overflow */
#define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
#define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
#define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
#define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
#define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
#define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
#define TARGET_NSIGFPE         8

/*
 * SIGSEGV si_codes
 */
#define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
#define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
915
#define TARGET_SEGV_BNDERR     (3)  /* failed address bound checks */
916

B
bellard 已提交
917 918 919 920
/*
 * SIGBUS si_codes
 */
#define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
921
#define TARGET_BUS_ADRERR       (2)	/* non-existent physical address */
B
bellard 已提交
922
#define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
923 924 925 926
/* hardware memory error consumed on a machine check: action required */
#define TARGET_BUS_MCEERR_AR    (4)
/* hardware memory error detected in process but not consumed: action optional*/
#define TARGET_BUS_MCEERR_AO    (5)
B
bellard 已提交
927

928 929 930 931 932
/*
 * SIGTRAP si_codes
 */
#define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
#define TARGET_TRAP_TRACE	(2)	/* process trace trap */
933 934
#define TARGET_TRAP_BRANCH      (3)     /* process taken branch trap */
#define TARGET_TRAP_HWBKPT      (4)     /* hardware breakpoint/watchpoint */
935 936 937

#endif /* defined(TARGET_I386) || defined(TARGET_ARM) */

B
bellard 已提交
938
struct target_rlimit {
939 940
        abi_ulong   rlim_cur;
        abi_ulong   rlim_max;
B
bellard 已提交
941 942
};

943
#if defined(TARGET_ALPHA)
944
#define TARGET_RLIM_INFINITY	0x7fffffffffffffffull
945
#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
946 947
#define TARGET_RLIM_INFINITY	0x7fffffffUL
#else
948
#define TARGET_RLIM_INFINITY	((abi_ulong)-1)
949 950
#endif

951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973
#if defined(TARGET_MIPS)
#define TARGET_RLIMIT_CPU		0
#define TARGET_RLIMIT_FSIZE		1
#define TARGET_RLIMIT_DATA		2
#define TARGET_RLIMIT_STACK		3
#define TARGET_RLIMIT_CORE		4
#define TARGET_RLIMIT_RSS		7
#define TARGET_RLIMIT_NPROC		8
#define TARGET_RLIMIT_NOFILE		5
#define TARGET_RLIMIT_MEMLOCK		9
#define TARGET_RLIMIT_AS		6
#define TARGET_RLIMIT_LOCKS		10
#define TARGET_RLIMIT_SIGPENDING	11
#define TARGET_RLIMIT_MSGQUEUE		12
#define TARGET_RLIMIT_NICE		13
#define TARGET_RLIMIT_RTPRIO		14
#else
#define TARGET_RLIMIT_CPU		0
#define TARGET_RLIMIT_FSIZE		1
#define TARGET_RLIMIT_DATA		2
#define TARGET_RLIMIT_STACK		3
#define TARGET_RLIMIT_CORE		4
#define TARGET_RLIMIT_RSS		5
974 975 976 977
#if defined(TARGET_SPARC)
#define TARGET_RLIMIT_NOFILE		6
#define TARGET_RLIMIT_NPROC		7
#else
978 979
#define TARGET_RLIMIT_NPROC		6
#define TARGET_RLIMIT_NOFILE		7
980
#endif
981 982 983 984 985 986 987 988 989
#define TARGET_RLIMIT_MEMLOCK		8
#define TARGET_RLIMIT_AS		9
#define TARGET_RLIMIT_LOCKS		10
#define TARGET_RLIMIT_SIGPENDING	11
#define TARGET_RLIMIT_MSGQUEUE		12
#define TARGET_RLIMIT_NICE		13
#define TARGET_RLIMIT_RTPRIO		14
#endif

B
bellard 已提交
990 991 992 993 994 995
struct target_pollfd {
    int fd;           /* file descriptor */
    short events;     /* requested events */
    short revents;    /* returned events */
};

B
bellard 已提交
996
/* virtual terminal ioctls */
B
bellard 已提交
997 998
#define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
#define TARGET_KDMKTONE	       0x4B30	/* generate tone */
B
bellard 已提交
999
#define TARGET_KDGKBTYPE       0x4b33
U
Ulrich Hecht 已提交
1000 1001 1002
#define TARGET_KDSETMODE       0x4b3a
#define TARGET_KDGKBMODE       0x4b44
#define TARGET_KDSKBMODE       0x4b45
B
bellard 已提交
1003 1004
#define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
#define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
1005 1006 1007 1008
#define TARGET_KDGKBLED        0x4B64	/* get led flags (not lights) */
#define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
#define TARGET_KDGETLED        0x4B31	/* return current led state */
#define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
1009
#define TARGET_KDSIGACCEPT     0x4B4E
B
bellard 已提交
1010

1011 1012
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4)
#define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
1013
#define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
1014
#else
1015
#define TARGET_SIOCATMARK      0x8905
1016
#define TARGET_SIOCGPGRP       0x8904
1017
#endif
1018 1019
#define TARGET_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
#define TARGET_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
1020

1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
/* Networking ioctls */
#define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
#define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
#define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
#define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
#define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
#define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
#define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
#define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
#define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
#define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
#define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
#define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
#define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
#define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
#define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
#define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
#define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
#define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
#define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
#define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
#define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
#define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
#define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
#define TARGET_SIOCSIFENCAP    0x8926
#define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
#define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
#define TARGET_SIOCSIFSLAVE    0x8930
#define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
#define TARGET_SIOCDELMULTI    0x8932
1051
#define TARGET_SIOCGIFINDEX    0x8933
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080

/* Bridging control calls */
#define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
#define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */

#define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
#define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */

/* ARP cache control calls. */
#define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
#define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
#define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
#define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
#define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
#define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */

/* RARP cache control calls. */
#define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
#define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
#define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */

/* Driver configuration calls */
#define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
#define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */

/* DLCI configuration calls */
#define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
#define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */

1081 1082 1083
/* From <linux/wireless.h> */

#define TARGET_SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
1084

1085 1086 1087 1088 1089 1090 1091
/* From <linux/random.h> */

#define TARGET_RNDGETENTCNT    TARGET_IOR('R', 0x00, int)
#define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
#define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
#define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)

1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
/* From <linux/fs.h> */

#define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
#define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
#define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
#define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
#define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
#define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
#define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
#define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
#define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
1106
#define TARGET_BLKPG      TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
1107
/* A jump here: 108-111 have been used for various private purposes. */
1108 1109
#define TARGET_BLKBSZGET  TARGET_IOR(0x12, 112, abi_ulong)
#define TARGET_BLKBSZSET  TARGET_IOW(0x12, 113, abi_ulong)
1110 1111 1112
#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
                                             /* return device size in bytes
                                                (u64 *arg) */
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123

#define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
#define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
#define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
#define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
#define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
#define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
#define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
#define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
#define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)

1124 1125
#define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
#define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
1126 1127 1128 1129

#define TARGET_FICLONE    TARGET_IOW(0x94, 9, int)
#define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)

1130 1131 1132
/* Note that the ioctl numbers claim type "long" but the actual type
 * used by the kernel is "int".
 */
1133 1134
#define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
#define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
1135

1136
#define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
1137 1138

/* cdrom commands */
1139
#define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
1140 1141
#define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
#define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
1142
#define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
1143
                                           (struct cdrom_ti) */
1144
#define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
1145
                                           (struct cdrom_tochdr) */
1146
#define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
1147 1148 1149 1150
                                           (struct cdrom_tocentry) */
#define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
#define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
#define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
1151
#define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
1152
                                           (struct cdrom_volctrl) */
1153
#define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
1154
                                           (struct cdrom_subchnl) */
1155
#define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
1156 1157 1158 1159 1160
                                           (struct cdrom_read) */
#define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
                                           (struct cdrom_read) */
#define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
#define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
1161 1162
#define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
                                           address of multi session disks
1163
                                           (struct cdrom_multisession) */
1164
#define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
1165
                                           if available (struct cdrom_mcn) */
V
Veres Lajos 已提交
1166
#define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is deprecated,
1167
                                          but here anyway for compatibility */
1168
#define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
1169
#define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
1170 1171 1172
                                          (struct cdrom_volctrl) */
#define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
                                           (struct cdrom_read) */
1173
/*
1174 1175 1176 1177
 * These ioctls are used only used in aztcd.c and optcd.c
 */
#define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
#define TARGET_CDROMSEEK		0x5316  /* seek msf address */
1178

1179
/*
1180
 * This ioctl is only used by the scsi-cd driver.
1181 1182 1183 1184
   It is for playing audio in logical block addressing mode.
 */
#define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */

1185
/*
1186 1187 1188 1189
 * These ioctls are only used in optcd.c
 */
#define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */

1190 1191
/*
 * These ioctls are (now) only in ide-cd.c for controlling
1192 1193 1194 1195 1196 1197 1198 1199
 * drive spindown time.  They should be implemented in the
 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
 *  -Erik
 */
#define TARGET_CDROMGETSPINDOWN        0x531d
#define TARGET_CDROMSETSPINDOWN        0x531e

1200
/*
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
 * These ioctls are implemented through the uniform CD-ROM driver
 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
 * drivers are eventually ported to the uniform CD-ROM driver interface.
 */
#define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
#define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
#define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
#define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
#define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
#define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
#define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
#define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
#define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
#define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
#define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
#define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */

/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
 * Future CDROM ioctls should be kept below 0x537F
 */

/* This ioctl is only used by sbpcd at the moment */
#define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
					/* conflict with SCSI_IOCTL_GET_IDLUN */

/* DVD-ROM Specific ioctls */
#define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
#define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
#define TARGET_DVD_AUTH		0x5392  /* Authentication */

#define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
#define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
#define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */

/* HD commands */

/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
#define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
#define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
#define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
#define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
#define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
#define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
#define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
1245
#define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
#define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */

/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
#define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
#define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
#define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
#define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
#define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
#define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
#define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
1256

B
balrog 已提交
1257 1258 1259 1260 1261 1262 1263 1264
/* loop ioctls */
#define TARGET_LOOP_SET_FD            0x4C00
#define TARGET_LOOP_CLR_FD            0x4C01
#define TARGET_LOOP_SET_STATUS        0x4C02
#define TARGET_LOOP_GET_STATUS        0x4C03
#define TARGET_LOOP_SET_STATUS64      0x4C04
#define TARGET_LOOP_GET_STATUS64      0x4C05
#define TARGET_LOOP_CHANGE_FD         0x4C06
1265

1266 1267 1268 1269
#define TARGET_LOOP_CTL_ADD           0x4C80
#define TARGET_LOOP_CTL_REMOVE        0x4C81
#define TARGET_LOOP_CTL_GET_FREE      0x4C82

U
Ulrich Hecht 已提交
1270 1271 1272 1273
/* fb ioctls */
#define TARGET_FBIOGET_VSCREENINFO    0x4600
#define TARGET_FBIOPUT_VSCREENINFO    0x4601
#define TARGET_FBIOGET_FSCREENINFO    0x4602
1274 1275 1276 1277 1278
#define TARGET_FBIOGETCMAP            0x4604
#define TARGET_FBIOPUTCMAP            0x4605
#define TARGET_FBIOPAN_DISPLAY        0x4606
#define TARGET_FBIOGET_CON2FBMAP      0x460F
#define TARGET_FBIOPUT_CON2FBMAP      0x4610
U
Ulrich Hecht 已提交
1279 1280 1281 1282 1283 1284 1285 1286

/* vt ioctls */
#define TARGET_VT_OPENQRY             0x5600
#define TARGET_VT_GETSTATE            0x5603
#define TARGET_VT_ACTIVATE            0x5606
#define TARGET_VT_WAITACTIVE          0x5607
#define TARGET_VT_LOCKSWITCH          0x560b
#define TARGET_VT_UNLOCKSWITCH        0x560c
1287 1288 1289 1290
#define TARGET_VT_GETMODE             0x5601
#define TARGET_VT_SETMODE             0x5602
#define TARGET_VT_RELDISP             0x5605
#define TARGET_VT_DISALLOCATE         0x5608
U
Ulrich Hecht 已提交
1291

1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
/* device mapper */
#define TARGET_DM_VERSION             TARGET_IOWRU(0xfd, 0x00)
#define TARGET_DM_REMOVE_ALL          TARGET_IOWRU(0xfd, 0x01)
#define TARGET_DM_LIST_DEVICES        TARGET_IOWRU(0xfd, 0x02)
#define TARGET_DM_DEV_CREATE          TARGET_IOWRU(0xfd, 0x03)
#define TARGET_DM_DEV_REMOVE          TARGET_IOWRU(0xfd, 0x04)
#define TARGET_DM_DEV_RENAME          TARGET_IOWRU(0xfd, 0x05)
#define TARGET_DM_DEV_SUSPEND         TARGET_IOWRU(0xfd, 0x06)
#define TARGET_DM_DEV_STATUS          TARGET_IOWRU(0xfd, 0x07)
#define TARGET_DM_DEV_WAIT            TARGET_IOWRU(0xfd, 0x08)
#define TARGET_DM_TABLE_LOAD          TARGET_IOWRU(0xfd, 0x09)
#define TARGET_DM_TABLE_CLEAR         TARGET_IOWRU(0xfd, 0x0a)
#define TARGET_DM_TABLE_DEPS          TARGET_IOWRU(0xfd, 0x0b)
#define TARGET_DM_TABLE_STATUS        TARGET_IOWRU(0xfd, 0x0c)
#define TARGET_DM_LIST_VERSIONS       TARGET_IOWRU(0xfd, 0x0d)
#define TARGET_DM_TARGET_MSG          TARGET_IOWRU(0xfd, 0x0e)
#define TARGET_DM_DEV_SET_GEOMETRY    TARGET_IOWRU(0xfd, 0x0f)

1310 1311
/* from asm/termbits.h */

B
bellard 已提交
1312 1313 1314 1315 1316 1317 1318 1319 1320
#define TARGET_NCC 8
struct target_termio {
	unsigned short c_iflag;		/* input mode flags */
	unsigned short c_oflag;		/* output mode flags */
	unsigned short c_cflag;		/* control mode flags */
	unsigned short c_lflag;		/* local mode flags */
	unsigned char c_line;		/* line discipline */
	unsigned char c_cc[TARGET_NCC];	/* control characters */
};
1321

B
bellard 已提交
1322 1323 1324 1325 1326
struct target_winsize {
	unsigned short ws_row;
	unsigned short ws_col;
	unsigned short ws_xpixel;
	unsigned short ws_ypixel;
1327 1328
};

B
bellard 已提交
1329
#include "termbits.h"
1330

P
Paul Brook 已提交
1331 1332 1333 1334 1335 1336
#if defined(TARGET_MIPS)
#define TARGET_PROT_SEM         0x10
#else
#define TARGET_PROT_SEM         0x08
#endif

1337
/* Common */
1338 1339
#define TARGET_MAP_SHARED	0x01		/* Share changes */
#define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
1340 1341 1342 1343 1344
#if defined(TARGET_HPPA)
#define TARGET_MAP_TYPE         0x03		/* Mask for type of mapping */
#else
#define TARGET_MAP_TYPE         0x0f		/* Mask for type of mapping */
#endif
1345 1346

/* Target specific */
B
bellard 已提交
1347
#if defined(TARGET_MIPS)
1348
#define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
B
bellard 已提交
1349 1350 1351 1352 1353 1354
#define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
#define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
#define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
#define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
#define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
#define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
1355 1356
#define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1357 1358
#define TARGET_MAP_STACK        0x40000         /* ignored */
#define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1359 1360
#elif defined(TARGET_PPC)
#define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
1361 1362 1363 1364
#define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
#define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
#define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
#define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
1365 1366
#define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
#define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
1367 1368
#define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1369 1370
#define TARGET_MAP_STACK        0x20000         /* ignored */
#define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380
#elif defined(TARGET_ALPHA)
#define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
#define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
#define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
#define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
#define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
#define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
#define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
#define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
1381 1382
#define TARGET_MAP_STACK        0x80000         /* ignored */
#define TARGET_MAP_HUGETLB      0x100000        /* create a huge page mapping */
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
#elif defined(TARGET_HPPA)
#define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
#define TARGET_MAP_FIXED	0x04		/* Interpret addr exactly */
#define TARGET_MAP_GROWSDOWN	0x08000		/* stack-like segment */
#define TARGET_MAP_DENYWRITE	0x00800		/* ETXTBSY */
#define TARGET_MAP_EXECUTABLE	0x01000		/* mark it as an executable */
#define TARGET_MAP_LOCKED	0x02000		/* lock the mapping */
#define TARGET_MAP_NORESERVE	0x04000		/* no check for reservations */
#define TARGET_MAP_POPULATE	0x10000		/* pop (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
1393 1394
#define TARGET_MAP_STACK        0x40000         /* ignored */
#define TARGET_MAP_HUGETLB      0x80000         /* create a huge page mapping */
1395
#else
1396 1397 1398 1399 1400
#define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
#define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
#define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
#define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
#define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
1401 1402
#define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
#define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
1403 1404
#define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
1405 1406
#define TARGET_MAP_STACK        0x20000         /* ignored */
#define TARGET_MAP_HUGETLB      0x40000         /* create a huge page mapping */
1407
#define TARGET_MAP_UNINITIALIZED 0x4000000	/* for anonymous mmap, memory could be uninitialized */
1408
#endif
1409

1410 1411
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
    || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
1412
    || defined(TARGET_CRIS) || defined(TARGET_UNICORE32)
1413 1414 1415
struct target_stat {
	unsigned short st_dev;
	unsigned short __pad1;
1416
	abi_ulong st_ino;
1417 1418 1419 1420 1421 1422
	unsigned short st_mode;
	unsigned short st_nlink;
	unsigned short st_uid;
	unsigned short st_gid;
	unsigned short st_rdev;
	unsigned short __pad2;
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
	abi_ulong  __unused1;
	abi_ulong  target_st_mtime;
	abi_ulong  __unused2;
	abi_ulong  target_st_ctime;
	abi_ulong  __unused3;
	abi_ulong  __unused4;
	abi_ulong  __unused5;
1434 1435 1436 1437 1438
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
1439
#define TARGET_HAS_STRUCT_STAT64
1440 1441 1442 1443 1444
struct target_stat64 {
	unsigned short	st_dev;
	unsigned char	__pad0[10];

#define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1445
	abi_ulong	__st_ino;
1446 1447 1448 1449

	unsigned int	st_mode;
	unsigned int	st_nlink;

1450 1451
	abi_ulong	st_uid;
	abi_ulong	st_gid;
1452 1453 1454 1455 1456

	unsigned short	st_rdev;
	unsigned char	__pad3[10];

	long long	st_size;
1457
	abi_ulong	st_blksize;
1458

1459 1460
	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1461

1462 1463
	abi_ulong	target_st_atime;
	abi_ulong	__pad5;
1464

1465 1466
	abi_ulong	target_st_mtime;
	abi_ulong	__pad6;
1467

1468 1469
	abi_ulong	target_st_ctime;
	abi_ulong	__pad7;		/* will be high 32 bits of ctime someday */
1470 1471

	unsigned long long	st_ino;
1472
} QEMU_PACKED;
1473

P
pbrook 已提交
1474
#ifdef TARGET_ARM
1475
#define TARGET_HAS_STRUCT_STAT64
P
pbrook 已提交
1476 1477 1478
struct target_eabi_stat64 {
        unsigned long long st_dev;
        unsigned int    __pad1;
1479
        abi_ulong    __st_ino;
P
pbrook 已提交
1480 1481 1482
        unsigned int    st_mode;
        unsigned int    st_nlink;

1483 1484
        abi_ulong    st_uid;
        abi_ulong    st_gid;
P
pbrook 已提交
1485 1486 1487 1488 1489

        unsigned long long st_rdev;
        unsigned int    __pad2[2];

        long long       st_size;
1490
        abi_ulong    st_blksize;
P
pbrook 已提交
1491 1492 1493
        unsigned int    __pad3;
        unsigned long long st_blocks;

1494 1495
        abi_ulong    target_st_atime;
        abi_ulong    target_st_atime_nsec;
P
pbrook 已提交
1496

1497 1498
        abi_ulong    target_st_mtime;
        abi_ulong    target_st_mtime_nsec;
P
pbrook 已提交
1499

1500 1501
        abi_ulong    target_st_ctime;
        abi_ulong    target_st_ctime_nsec;
P
pbrook 已提交
1502 1503

        unsigned long long st_ino;
1504
} QEMU_PACKED;
P
pbrook 已提交
1505 1506
#endif

1507
#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
B
blueswir1 已提交
1508 1509
struct target_stat {
	unsigned int	st_dev;
1510
	abi_ulong	st_ino;
B
blueswir1 已提交
1511 1512 1513 1514 1515
	unsigned int	st_mode;
	unsigned int	st_nlink;
	unsigned int	st_uid;
	unsigned int	st_gid;
	unsigned int	st_rdev;
1516 1517 1518 1519 1520 1521 1522
	abi_long	st_size;
	abi_long	target_st_atime;
	abi_long	target_st_mtime;
	abi_long	target_st_ctime;
	abi_long	st_blksize;
	abi_long	st_blocks;
	abi_ulong	__unused4[2];
B
blueswir1 已提交
1523 1524
};

1525
#define TARGET_HAS_STRUCT_STAT64
B
blueswir1 已提交
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546
struct target_stat64 {
	unsigned char	__pad0[6];
	unsigned short	st_dev;

	uint64_t	st_ino;
	uint64_t	st_nlink;

	unsigned int	st_mode;

	unsigned int	st_uid;
	unsigned int	st_gid;

	unsigned char	__pad2[6];
	unsigned short	st_rdev;

        int64_t		st_size;
	int64_t		st_blksize;

	unsigned char	__pad4[4];
	unsigned int	st_blocks;

1547 1548
	abi_ulong	target_st_atime;
	abi_ulong	__unused1;
B
blueswir1 已提交
1549

1550 1551
	abi_ulong	target_st_mtime;
	abi_ulong	__unused2;
B
blueswir1 已提交
1552

1553 1554
	abi_ulong	target_st_ctime;
	abi_ulong	__unused3;
B
blueswir1 已提交
1555

1556
	abi_ulong	__unused4[3];
B
blueswir1 已提交
1557 1558
};

B
bellard 已提交
1559 1560 1561 1562
#elif defined(TARGET_SPARC)

struct target_stat {
	unsigned short	st_dev;
1563
	abi_ulong	st_ino;
B
bellard 已提交
1564 1565 1566 1567 1568
	unsigned short	st_mode;
	short		st_nlink;
	unsigned short	st_uid;
	unsigned short	st_gid;
	unsigned short	st_rdev;
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578
	abi_long	st_size;
	abi_long	target_st_atime;
	abi_ulong	__unused1;
	abi_long	target_st_mtime;
	abi_ulong	__unused2;
	abi_long	target_st_ctime;
	abi_ulong	__unused3;
	abi_long	st_blksize;
	abi_long	st_blocks;
	abi_ulong	__unused4[2];
B
bellard 已提交
1579 1580
};

1581
#define TARGET_HAS_STRUCT_STAT64
B
bellard 已提交
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617
struct target_stat64 {
	unsigned char	__pad0[6];
	unsigned short	st_dev;

	uint64_t st_ino;

	unsigned int	st_mode;
	unsigned int	st_nlink;

	unsigned int	st_uid;
	unsigned int	st_gid;

	unsigned char	__pad2[6];
	unsigned short	st_rdev;

	unsigned char	__pad3[8];

        int64_t	st_size;
	unsigned int	st_blksize;

	unsigned char	__pad4[8];
	unsigned int	st_blocks;

	unsigned int	target_st_atime;
	unsigned int	__unused1;

	unsigned int	target_st_mtime;
	unsigned int	__unused2;

	unsigned int	target_st_ctime;
	unsigned int	__unused3;

	unsigned int	__unused4;
	unsigned int	__unused5;
};

1618 1619 1620
#elif defined(TARGET_PPC)

struct target_stat {
1621
	abi_ulong st_dev;
1622
	abi_ulong st_ino;
1623
#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1624
	abi_ulong st_nlink;
1625 1626
	unsigned int st_mode;
#else
1627 1628
	unsigned int st_mode;
	unsigned short st_nlink;
1629
#endif
1630 1631
	unsigned int st_uid;
	unsigned int st_gid;
1632
	abi_ulong  st_rdev;
1633 1634 1635 1636
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
1637
	abi_ulong  target_st_atime_nsec;
1638
	abi_ulong  target_st_mtime;
1639
	abi_ulong  target_st_mtime_nsec;
1640
	abi_ulong  target_st_ctime;
1641
	abi_ulong  target_st_ctime_nsec;
1642 1643
	abi_ulong  __unused4;
	abi_ulong  __unused5;
1644 1645 1646
#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
	abi_ulong  __unused6;
#endif
1647 1648
};

1649 1650
#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
#define TARGET_HAS_STRUCT_STAT64
1651
struct QEMU_PACKED target_stat64 {
1652 1653
	unsigned long long st_dev;
        unsigned long long st_ino;
B
bellard 已提交
1654 1655
	unsigned int st_mode;
	unsigned int st_nlink;
1656 1657
	unsigned int st_uid;
	unsigned int st_gid;
B
bellard 已提交
1658
	unsigned long long st_rdev;
1659
	unsigned long long __pad0;
1660 1661
	long long      st_size;
	int	       st_blksize;
1662
	unsigned int   __pad1;
1663
	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1664 1665 1666 1667 1668 1669 1670 1671
	int	       target_st_atime;
        unsigned int   target_st_atime_nsec;
	int	       target_st_mtime;
        unsigned int   target_st_mtime_nsec;
	int            target_st_ctime;
        unsigned int   target_st_ctime_nsec;
        unsigned int   __unused4;
        unsigned int   __unused5;
1672
};
1673
#endif
1674

1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
#elif defined(TARGET_MICROBLAZE)

struct target_stat {
	abi_ulong st_dev;
	abi_ulong st_ino;
	unsigned int st_mode;
	unsigned short st_nlink;
	unsigned int st_uid;
	unsigned int st_gid;
	abi_ulong  st_rdev;
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
	abi_ulong  target_st_atime_nsec;
	abi_ulong  target_st_mtime;
	abi_ulong  target_st_mtime_nsec;
	abi_ulong  target_st_ctime;
	abi_ulong  target_st_ctime_nsec;
	abi_ulong  __unused4;
	abi_ulong  __unused5;
};

/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout...  */
1699
#define TARGET_HAS_STRUCT_STAT64
1700
struct QEMU_PACKED target_stat64 {
1701
	uint64_t st_dev;
1702 1703 1704 1705
#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
	uint32_t pad0;
	uint32_t __st_ino;

1706 1707 1708 1709 1710
	uint32_t st_mode;
	uint32_t st_nlink;
	uint32_t st_uid;
	uint32_t st_gid;
	uint64_t st_rdev;
1711
	uint64_t __pad1;
1712 1713

	int64_t  st_size;
1714 1715
	int32_t  st_blksize;
	uint32_t __pad2;
1716 1717 1718
	int64_t st_blocks;	/* Number 512-byte blocks allocated. */

	int	       target_st_atime;
1719
	unsigned int   target_st_atime_nsec;
1720
	int	       target_st_mtime;
1721
	unsigned int   target_st_mtime_nsec;
1722
	int            target_st_ctime;
1723 1724
	unsigned int   target_st_ctime_nsec;
	uint64_t st_ino;
1725 1726
};

P
pbrook 已提交
1727 1728 1729 1730 1731
#elif defined(TARGET_M68K)

struct target_stat {
	unsigned short st_dev;
	unsigned short __pad1;
1732
	abi_ulong st_ino;
P
pbrook 已提交
1733 1734 1735 1736 1737 1738
	unsigned short st_mode;
	unsigned short st_nlink;
	unsigned short st_uid;
	unsigned short st_gid;
	unsigned short st_rdev;
	unsigned short __pad2;
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
	abi_ulong  __unused1;
	abi_ulong  target_st_mtime;
	abi_ulong  __unused2;
	abi_ulong  target_st_ctime;
	abi_ulong  __unused3;
	abi_ulong  __unused4;
	abi_ulong  __unused5;
P
pbrook 已提交
1750 1751 1752 1753 1754
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
1755
#define TARGET_HAS_STRUCT_STAT64
P
pbrook 已提交
1756 1757 1758 1759 1760
struct target_stat64 {
	unsigned long long	st_dev;
	unsigned char	__pad1[2];

#define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1761
	abi_ulong	__st_ino;
P
pbrook 已提交
1762 1763 1764 1765

	unsigned int	st_mode;
	unsigned int	st_nlink;

1766 1767
	abi_ulong	st_uid;
	abi_ulong	st_gid;
P
pbrook 已提交
1768 1769 1770 1771 1772

	unsigned long long	st_rdev;
	unsigned char	__pad3[2];

	long long	st_size;
1773
	abi_ulong	st_blksize;
P
pbrook 已提交
1774

1775 1776
	abi_ulong	__pad4;		/* future possible st_blocks high bits */
	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
P
pbrook 已提交
1777

1778 1779
	abi_ulong	target_st_atime;
	abi_ulong	target_st_atime_nsec;
P
pbrook 已提交
1780

1781 1782
	abi_ulong	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;
P
pbrook 已提交
1783

1784 1785
	abi_ulong	target_st_ctime;
	abi_ulong	target_st_ctime_nsec;
P
pbrook 已提交
1786 1787

	unsigned long long	st_ino;
1788
} QEMU_PACKED;
P
pbrook 已提交
1789

1790
#elif defined(TARGET_ABI_MIPSN64)
1791 1792 1793 1794 1795 1796

/* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
struct target_stat {
	unsigned int		st_dev;
	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */

1797
	abi_ulong		st_ino;
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807

	unsigned int		st_mode;
	unsigned int		st_nlink;

	int			st_uid;
	int			st_gid;

	unsigned int		st_rdev;
	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */

1808
	abi_ulong		st_size;
1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825

	/*
	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
	 * but we don't have it under Linux.
	 */
	unsigned int		target_st_atime;
	unsigned int		target_st_atime_nsec;

	unsigned int		target_st_mtime;
	unsigned int		target_st_mtime_nsec;

	unsigned int		target_st_ctime;
	unsigned int		target_st_ctime_nsec;

	unsigned int		st_blksize;
	unsigned int		st_pad2;

1826
	abi_ulong		st_blocks;
1827 1828
};

1829
#elif defined(TARGET_ABI_MIPSN32)
1830 1831

struct target_stat {
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850
        abi_ulong    st_dev;
        abi_ulong    st_pad0[3]; /* Reserved for st_dev expansion */
        uint64_t     st_ino;
        unsigned int st_mode;
        unsigned int st_nlink;
        int          st_uid;
        int          st_gid;
        abi_ulong    st_rdev;
        abi_ulong    st_pad1[3]; /* Reserved for st_rdev expansion */
        int64_t      st_size;
        abi_long     target_st_atime;
        abi_ulong    target_st_atime_nsec; /* Reserved for st_atime expansion */
        abi_long     target_st_mtime;
        abi_ulong    target_st_mtime_nsec; /* Reserved for st_mtime expansion */
        abi_long     target_st_ctime;
        abi_ulong    target_st_ctime_nsec; /* Reserved for st_ctime expansion */
        abi_ulong    st_blksize;
        abi_ulong    st_pad2;
        int64_t      st_blocks;
1851 1852
};

1853
#elif defined(TARGET_ABI_MIPSO32)
B
bellard 已提交
1854 1855 1856

struct target_stat {
	unsigned	st_dev;
1857 1858
	abi_long	st_pad1[3];		/* Reserved for network id */
	abi_ulong	st_ino;
B
bellard 已提交
1859 1860 1861 1862 1863
	unsigned int	st_mode;
	unsigned int	st_nlink;
	int		st_uid;
	int		st_gid;
	unsigned 	st_rdev;
1864 1865 1866
	abi_long	st_pad2[2];
	abi_long	st_size;
	abi_long	st_pad3;
B
bellard 已提交
1867 1868 1869 1870
	/*
	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
	 * but we don't have it under Linux.
	 */
1871 1872 1873 1874 1875 1876 1877 1878 1879
	abi_long		target_st_atime;
	abi_long		target_st_atime_nsec;
	abi_long		target_st_mtime;
	abi_long		target_st_mtime_nsec;
	abi_long		target_st_ctime;
	abi_long		target_st_ctime_nsec;
	abi_long		st_blksize;
	abi_long		st_blocks;
	abi_long		st_pad4[14];
B
bellard 已提交
1880 1881 1882 1883 1884 1885 1886 1887
};

/*
 * This matches struct stat64 in glibc2.1, hence the absolutely insane
 * amounts of padding around dev_t's.  The memory layout is the same as of
 * struct stat of the 64-bit kernel.
 */

1888
#define TARGET_HAS_STRUCT_STAT64
B
bellard 已提交
1889
struct target_stat64 {
1890 1891
	abi_ulong	st_dev;
	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
B
bellard 已提交
1892 1893 1894 1895 1896 1897 1898 1899 1900

	uint64_t	st_ino;

        unsigned int	st_mode;
        unsigned int	st_nlink;

	int		st_uid;
	int		st_gid;

1901 1902
	abi_ulong	st_rdev;
	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
B
bellard 已提交
1903 1904 1905 1906 1907 1908 1909

	int64_t 	st_size;

	/*
	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
	 * but we don't have it under Linux.
	 */
1910 1911
	abi_long	target_st_atime;
	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
B
bellard 已提交
1912

1913 1914
	abi_long	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
B
bellard 已提交
1915

1916 1917
	abi_long	target_st_ctime;
	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
B
bellard 已提交
1918

1919 1920
	abi_ulong	st_blksize;
	abi_ulong	st_pad2;
B
bellard 已提交
1921 1922 1923

	int64_t  	st_blocks;
};
1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934

#elif defined(TARGET_ALPHA)

struct target_stat {
       unsigned int    st_dev;
       unsigned int    st_ino;
       unsigned int    st_mode;
       unsigned int    st_nlink;
       unsigned int    st_uid;
       unsigned int    st_gid;
       unsigned int    st_rdev;
1935 1936 1937 1938
       abi_long     st_size;
       abi_ulong    target_st_atime;
       abi_ulong    target_st_mtime;
       abi_ulong    target_st_ctime;
1939 1940 1941 1942 1943 1944
       unsigned int    st_blksize;
       unsigned int    st_blocks;
       unsigned int    st_flags;
       unsigned int    st_gen;
};

1945
#define TARGET_HAS_STRUCT_STAT64
1946
struct target_stat64 {
1947 1948 1949 1950 1951
       abi_ulong    st_dev;
       abi_ulong    st_ino;
       abi_ulong    st_rdev;
       abi_long     st_size;
       abi_ulong    st_blocks;
1952 1953 1954 1955 1956 1957 1958 1959

       unsigned int    st_mode;
       unsigned int    st_uid;
       unsigned int    st_gid;
       unsigned int    st_blksize;
       unsigned int    st_nlink;
       unsigned int    __pad0;

1960 1961 1962 1963 1964 1965 1966
       abi_ulong    target_st_atime;
       abi_ulong    target_st_atime_nsec;
       abi_ulong    target_st_mtime;
       abi_ulong    target_st_mtime_nsec;
       abi_ulong    target_st_ctime;
       abi_ulong    target_st_ctime_nsec;
       abi_long     __unused[3];
1967 1968
};

1969 1970 1971
#elif defined(TARGET_SH4)

struct target_stat {
1972 1973
	abi_ulong  st_dev;
	abi_ulong  st_ino;
1974 1975 1976 1977
	unsigned short st_mode;
	unsigned short st_nlink;
	unsigned short st_uid;
	unsigned short st_gid;
1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989
	abi_ulong  st_rdev;
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
	abi_ulong  target_st_atime_nsec;
	abi_ulong  target_st_mtime;
	abi_ulong  target_st_mtime_nsec;
	abi_ulong  target_st_ctime;
	abi_ulong  target_st_ctime_nsec;
	abi_ulong  __unused4;
	abi_ulong  __unused5;
1990 1991 1992 1993 1994
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
1995
#define TARGET_HAS_STRUCT_STAT64
1996
struct QEMU_PACKED target_stat64 {
1997 1998 1999 2000
	unsigned long long	st_dev;
	unsigned char	__pad0[4];

#define TARGET_STAT64_HAS_BROKEN_ST_INO	1
2001
	abi_ulong	__st_ino;
2002 2003 2004 2005

	unsigned int	st_mode;
	unsigned int	st_nlink;

2006 2007
	abi_ulong	st_uid;
	abi_ulong	st_gid;
2008 2009 2010 2011 2012

	unsigned long long	st_rdev;
	unsigned char	__pad3[4];

	long long	st_size;
2013
	abi_ulong	st_blksize;
2014 2015 2016

	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */

2017 2018
	abi_ulong	target_st_atime;
	abi_ulong	target_st_atime_nsec;
2019

2020 2021
	abi_ulong	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;
2022

2023 2024
	abi_ulong	target_st_ctime;
	abi_ulong	target_st_ctime_nsec;
2025 2026 2027 2028

	unsigned long long	st_ino;
};

B
bellard 已提交
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052
#elif defined(TARGET_I386) && !defined(TARGET_ABI32)
struct target_stat {
	abi_ulong	st_dev;
	abi_ulong	st_ino;
	abi_ulong	st_nlink;

	unsigned int	st_mode;
	unsigned int	st_uid;
	unsigned int	st_gid;
	unsigned int	__pad0;
	abi_ulong	st_rdev;
	abi_long	st_size;
	abi_long	st_blksize;
    	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */

	abi_ulong	target_st_atime;
	abi_ulong 	target_st_atime_nsec; 
	abi_ulong	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;
	abi_ulong	target_st_ctime;
	abi_ulong       target_st_ctime_nsec;

  	abi_long	__unused[3];
};
U
Ulrich Hecht 已提交
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073
#elif defined(TARGET_S390X)
struct target_stat {
    abi_ulong  st_dev;
    abi_ulong  st_ino;
    abi_ulong  st_nlink;
    unsigned int   st_mode;
    unsigned int   st_uid;
    unsigned int   st_gid;
    unsigned int   __pad1;
    abi_ulong  st_rdev;
    abi_ulong  st_size;
    abi_ulong  target_st_atime;
    abi_ulong  target_st_atime_nsec;
    abi_ulong  target_st_mtime;
    abi_ulong  target_st_mtime_nsec;
    abi_ulong  target_st_ctime;
    abi_ulong  target_st_ctime_nsec;
    abi_ulong  st_blksize;
    abi_long       st_blocks;
    abi_ulong  __unused[3];
};
2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095
#elif defined(TARGET_AARCH64)
struct target_stat {
    abi_ulong  st_dev;
    abi_ulong  st_ino;
    unsigned int st_mode;
    unsigned int st_nlink;
    unsigned int   st_uid;
    unsigned int   st_gid;
    abi_ulong  st_rdev;
    abi_ulong  _pad1;
    abi_long  st_size;
    int        st_blksize;
    int        __pad2;
    abi_long   st_blocks;
    abi_long  target_st_atime;
    abi_ulong  target_st_atime_nsec;
    abi_long  target_st_mtime;
    abi_ulong  target_st_mtime_nsec;
    abi_long  target_st_ctime;
    abi_ulong  target_st_ctime_nsec;
    unsigned int __unused[2];
};
2096
#elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
M
Michael Clark 已提交
2097
      defined(TARGET_NIOS2) || defined(TARGET_RISCV)
2098 2099 2100

/* These are the asm-generic versions of the stat and stat64 structures */

J
Jia Liu 已提交
2101 2102 2103 2104
struct target_stat {
    abi_ulong st_dev;
    abi_ulong st_ino;
    unsigned int st_mode;
2105
    unsigned int st_nlink;
J
Jia Liu 已提交
2106 2107 2108
    unsigned int st_uid;
    unsigned int st_gid;
    abi_ulong st_rdev;
2109
    abi_ulong __pad1;
J
Jia Liu 已提交
2110
    abi_long st_size;
2111 2112 2113 2114
    int st_blksize;
    int __pad2;
    abi_long st_blocks;
    abi_long target_st_atime;
J
Jia Liu 已提交
2115
    abi_ulong target_st_atime_nsec;
2116
    abi_long target_st_mtime;
J
Jia Liu 已提交
2117
    abi_ulong target_st_mtime_nsec;
2118
    abi_long target_st_ctime;
J
Jia Liu 已提交
2119
    abi_ulong target_st_ctime_nsec;
2120 2121 2122
    unsigned int __unused4;
    unsigned int __unused5;
};
J
Jia Liu 已提交
2123

M
Michael Clark 已提交
2124
#if !defined(TARGET_RISCV64)
2125
#define TARGET_HAS_STRUCT_STAT64
2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
struct target_stat64 {
    uint64_t st_dev;
    uint64_t st_ino;
    unsigned int st_mode;
    unsigned int st_nlink;
    unsigned int st_uid;
    unsigned int st_gid;
    uint64_t st_rdev;
    uint64_t __pad1;
    int64_t st_size;
    int st_blksize;
    int __pad2;
    int64_t st_blocks;
    int target_st_atime;
    unsigned int target_st_atime_nsec;
    int target_st_mtime;
    unsigned int target_st_mtime_nsec;
    int target_st_ctime;
    unsigned int target_st_ctime_nsec;
    unsigned int __unused4;
    unsigned int __unused5;
J
Jia Liu 已提交
2147
};
M
Michael Clark 已提交
2148
#endif
2149

2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205
#elif defined(TARGET_HPPA)

struct target_stat {
    abi_uint   st_dev;
    abi_uint   st_ino;
    abi_ushort st_mode;
    abi_ushort st_nlink;
    abi_ushort _res1;
    abi_ushort _res2;
    abi_uint   st_rdev;
    abi_int    st_size;
    abi_int    target_st_atime;
    abi_uint   target_st_atime_nsec;
    abi_int    target_st_mtime;
    abi_uint   target_st_mtime_nsec;
    abi_int    target_st_ctime;
    abi_uint   target_st_ctime_nsec;
    abi_int    st_blksize;
    abi_int    st_blocks;
    abi_uint   _unused1;
    abi_uint   _unused2;
    abi_uint   _unused3;
    abi_uint   _unused4;
    abi_ushort _unused5;
    abi_short  st_fstype;
    abi_uint   st_realdev;
    abi_ushort st_basemode;
    abi_ushort _unused6;
    abi_uint   st_uid;
    abi_uint   st_gid;
    abi_uint   _unused7[3];
};

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
    uint64_t   st_dev;
    abi_uint   _pad1;
    abi_uint   _res1;
    abi_uint   st_mode;
    abi_uint   st_nlink;
    abi_uint   st_uid;
    abi_uint   st_gid;
    uint64_t   st_rdev;
    abi_uint   _pad2;
    int64_t    st_size;
    abi_int    st_blksize;
    int64_t    st_blocks;
    abi_int    target_st_atime;
    abi_uint   target_st_atime_nsec;
    abi_int    target_st_mtime;
    abi_uint   target_st_mtime_nsec;
    abi_int    target_st_ctime;
    abi_uint   target_st_ctime_nsec;
    uint64_t   st_ino;
};

B
bellard 已提交
2206 2207 2208
#else
#error unsupported CPU
#endif
2209

2210 2211
typedef struct {
        int     val[2];
A
Anthony Liguori 已提交
2212
} target_fsid_t;
2213

B
bellard 已提交
2214
#ifdef TARGET_MIPS
2215
#ifdef TARGET_ABI_MIPSN32
2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226
struct target_statfs {
	int32_t			f_type;
	int32_t			f_bsize;
	int32_t			f_frsize;	/* Fragment size - unsupported */
	int32_t			f_blocks;
	int32_t			f_bfree;
	int32_t			f_files;
	int32_t			f_ffree;
	int32_t			f_bavail;

	/* Linux specials */
A
Anthony Liguori 已提交
2227
	target_fsid_t		f_fsid;
2228 2229 2230 2231
	int32_t			f_namelen;
	int32_t			f_spare[6];
};
#else
B
bellard 已提交
2232
struct target_statfs {
2233 2234 2235 2236 2237 2238 2239 2240
	abi_long		f_type;
	abi_long		f_bsize;
	abi_long		f_frsize;	/* Fragment size - unsupported */
	abi_long		f_blocks;
	abi_long		f_bfree;
	abi_long		f_files;
	abi_long		f_ffree;
	abi_long		f_bavail;
B
bellard 已提交
2241 2242

	/* Linux specials */
A
Anthony Liguori 已提交
2243
	target_fsid_t		f_fsid;
2244 2245
	abi_long		f_namelen;
	abi_long		f_spare[6];
B
bellard 已提交
2246
};
2247
#endif
B
bellard 已提交
2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258

struct target_statfs64 {
	uint32_t	f_type;
	uint32_t	f_bsize;
	uint32_t	f_frsize;	/* Fragment size - unsupported */
	uint32_t	__pad;
	uint64_t	f_blocks;
	uint64_t	f_bfree;
	uint64_t	f_files;
	uint64_t	f_ffree;
	uint64_t	f_bavail;
A
Anthony Liguori 已提交
2259
	target_fsid_t	f_fsid;
B
bellard 已提交
2260 2261 2262
	uint32_t	f_namelen;
	uint32_t	f_spare[6];
};
2263
#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
M
Michael Clark 已提交
2264 2265
       defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
       defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
2266 2267 2268 2269 2270 2271 2272 2273
struct target_statfs {
	abi_long f_type;
	abi_long f_bsize;
	abi_long f_blocks;
	abi_long f_bfree;
	abi_long f_bavail;
	abi_long f_files;
	abi_long f_ffree;
A
Anthony Liguori 已提交
2274
	target_fsid_t f_fsid;
2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287
	abi_long f_namelen;
	abi_long f_frsize;
	abi_long f_spare[5];
};

struct target_statfs64 {
	abi_long f_type;
	abi_long f_bsize;
	abi_long f_blocks;
	abi_long f_bfree;
	abi_long f_bavail;
	abi_long f_files;
	abi_long f_ffree;
A
Anthony Liguori 已提交
2288
	target_fsid_t f_fsid;
2289 2290 2291 2292
	abi_long f_namelen;
	abi_long f_frsize;
	abi_long f_spare[5];
};
U
Ulrich Hecht 已提交
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320
#elif defined(TARGET_S390X)
struct target_statfs {
    int32_t  f_type;
    int32_t  f_bsize;
    abi_long f_blocks;
    abi_long f_bfree;
    abi_long f_bavail;
    abi_long f_files;
    abi_long f_ffree;
    kernel_fsid_t f_fsid;
    int32_t  f_namelen;
    int32_t  f_frsize;
    int32_t  f_spare[5];
};

struct target_statfs64 {
    int32_t  f_type;
    int32_t  f_bsize;
    abi_long f_blocks;
    abi_long f_bfree;
    abi_long f_bavail;
    abi_long f_files;
    abi_long f_ffree;
    kernel_fsid_t f_fsid;
    int32_t  f_namelen;
    int32_t  f_frsize;
    int32_t  f_spare[5];
};
B
bellard 已提交
2321 2322 2323 2324 2325 2326 2327 2328 2329
#else
struct target_statfs {
	uint32_t f_type;
	uint32_t f_bsize;
	uint32_t f_blocks;
	uint32_t f_bfree;
	uint32_t f_bavail;
	uint32_t f_files;
	uint32_t f_ffree;
A
Anthony Liguori 已提交
2330
	target_fsid_t f_fsid;
B
bellard 已提交
2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343
	uint32_t f_namelen;
	uint32_t f_frsize;
	uint32_t f_spare[5];
};

struct target_statfs64 {
	uint32_t f_type;
	uint32_t f_bsize;
	uint64_t f_blocks;
	uint64_t f_bfree;
	uint64_t f_bavail;
	uint64_t f_files;
	uint64_t f_ffree;
A
Anthony Liguori 已提交
2344
	target_fsid_t f_fsid;
B
bellard 已提交
2345 2346 2347 2348 2349 2350 2351
        uint32_t f_namelen;
	uint32_t f_frsize;
	uint32_t f_spare[5];
};
#endif


2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363
#define TARGET_F_DUPFD         0       /* dup */
#define TARGET_F_GETFD         1       /* get close_on_exec */
#define TARGET_F_SETFD         2       /* set/clear close_on_exec */
#define TARGET_F_GETFL         3       /* get file->f_flags */
#define TARGET_F_SETFL         4       /* set file->f_flags */

#if defined(TARGET_ALPHA)
#define TARGET_F_GETLK         7
#define TARGET_F_SETLK         8
#define TARGET_F_SETLKW        9
#define TARGET_F_SETOWN        5       /*  for sockets. */
#define TARGET_F_GETOWN        6       /*  for sockets. */
2364 2365 2366 2367 2368 2369

#define TARGET_F_RDLCK         1
#define TARGET_F_WRLCK         2
#define TARGET_F_UNLCK         8
#define TARGET_F_EXLCK         16
#define TARGET_F_SHLCK         32
2370 2371 2372 2373 2374
#elif defined(TARGET_MIPS)
#define TARGET_F_GETLK         14
#define TARGET_F_SETLK         6
#define TARGET_F_SETLKW        7
#define TARGET_F_SETOWN        24       /*  for sockets. */
2375
#define TARGET_F_GETOWN        23       /*  for sockets. */
H
Helge Deller 已提交
2376
#elif defined(TARGET_HPPA)
2377 2378 2379
#define TARGET_F_RDLCK         1
#define TARGET_F_WRLCK         2
#define TARGET_F_UNLCK         3
H
Helge Deller 已提交
2380 2381 2382 2383 2384
#define TARGET_F_GETLK         5
#define TARGET_F_SETLK         6
#define TARGET_F_SETLKW        7
#define TARGET_F_GETOWN        11       /*  for sockets. */
#define TARGET_F_SETOWN        12       /*  for sockets. */
2385 2386 2387 2388 2389 2390 2391
#else
#define TARGET_F_GETLK         5
#define TARGET_F_SETLK         6
#define TARGET_F_SETLKW        7
#define TARGET_F_SETOWN        8       /*  for sockets. */
#define TARGET_F_GETOWN        9       /*  for sockets. */
#endif
2392 2393
#define TARGET_F_SETOWN_EX     15
#define TARGET_F_GETOWN_EX     16
2394

2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
#ifndef TARGET_F_RDLCK
#define TARGET_F_RDLCK         0
#define TARGET_F_WRLCK         1
#define TARGET_F_UNLCK         2
#endif

#ifndef TARGET_F_EXLCK
#define TARGET_F_EXLCK         4
#define TARGET_F_SHLCK         8
#endif


H
Helge Deller 已提交
2407 2408 2409 2410
#if defined(TARGET_HPPA)
#define TARGET_F_SETSIG        13      /*  for sockets. */
#define TARGET_F_GETSIG        14      /*  for sockets. */
#else
2411 2412
#define TARGET_F_SETSIG        10      /*  for sockets. */
#define TARGET_F_GETSIG        11      /*  for sockets. */
H
Helge Deller 已提交
2413
#endif
2414

2415 2416 2417 2418
#if defined(TARGET_MIPS)
#define TARGET_F_GETLK64       33      /*  using 'struct flock64' */
#define TARGET_F_SETLK64       34
#define TARGET_F_SETLKW64      35
H
Helge Deller 已提交
2419 2420 2421 2422
#elif defined(TARGET_HPPA)
#define TARGET_F_GETLK64       8       /*  using 'struct flock64' */
#define TARGET_F_SETLK64       9
#define TARGET_F_SETLKW64      10
2423
#else
2424 2425 2426
#define TARGET_F_GETLK64       12      /*  using 'struct flock64' */
#define TARGET_F_SETLK64       13
#define TARGET_F_SETLKW64      14
2427
#endif
U
Ulrich Hecht 已提交
2428 2429 2430 2431 2432

#define TARGET_F_LINUX_SPECIFIC_BASE 1024
#define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
#define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
#define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
2433 2434
#define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
#define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
U
Ulrich Hecht 已提交
2435 2436
#define TARGET_F_NOTIFY  (TARGET_F_LINUX_SPECIFIC_BASE+2)

2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452
#if defined(TARGET_ALPHA)
#define TARGET_O_NONBLOCK           04
#define TARGET_O_APPEND            010
#define TARGET_O_CREAT           01000 /* not fcntl */
#define TARGET_O_TRUNC           02000 /* not fcntl */
#define TARGET_O_EXCL            04000 /* not fcntl */
#define TARGET_O_NOCTTY         010000 /* not fcntl */
#define TARGET_O_DSYNC          040000
#define TARGET_O_LARGEFILE           0 /* not necessary, always 64-bit */
#define TARGET_O_DIRECTORY     0100000 /* must be a directory */
#define TARGET_O_NOFOLLOW      0200000 /* don't follow links */
#define TARGET_O_DIRECT       02000000 /* direct disk access hint */
#define TARGET_O_NOATIME      04000000
#define TARGET_O_CLOEXEC     010000000
#define TARGET___O_SYNC      020000000
#define TARGET_O_PATH        040000000
2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466
#elif defined(TARGET_HPPA)
#define TARGET_O_NONBLOCK    000200004 /* HPUX has separate NDELAY & NONBLOCK */
#define TARGET_O_APPEND      000000010
#define TARGET_O_CREAT       000000400 /* not fcntl */
#define TARGET_O_EXCL        000002000 /* not fcntl */
#define TARGET_O_NOCTTY      000400000 /* not fcntl */
#define TARGET_O_DSYNC       001000000
#define TARGET_O_LARGEFILE   000004000
#define TARGET_O_DIRECTORY   000010000 /* must be a directory */
#define TARGET_O_NOFOLLOW    000000200 /* don't follow links */
#define TARGET_O_NOATIME     004000000
#define TARGET_O_CLOEXEC     010000000
#define TARGET___O_SYNC      000100000
#define TARGET_O_PATH        020000000
R
Riku Voipio 已提交
2467
#elif defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_AARCH64)
2468 2469 2470 2471
#define TARGET_O_DIRECTORY      040000 /* must be a directory */
#define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
#define TARGET_O_DIRECT        0200000 /* direct disk access hint */
#define TARGET_O_LARGEFILE     0400000
2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483
#elif defined(TARGET_MIPS)
#define TARGET_O_APPEND         0x0008
#define TARGET_O_DSYNC          0x0010
#define TARGET_O_NONBLOCK       0x0080
#define TARGET_O_CREAT          0x0100  /* not fcntl */
#define TARGET_O_TRUNC          0x0200  /* not fcntl */
#define TARGET_O_EXCL           0x0400  /* not fcntl */
#define TARGET_O_NOCTTY         0x0800  /* not fcntl */
#define TARGET_FASYNC           0x1000  /* fcntl, for BSD compatibility */
#define TARGET_O_LARGEFILE      0x2000  /* allow large file opens */
#define TARGET___O_SYNC         0x4000
#define TARGET_O_DIRECT         0x8000  /* direct disk access hint */
2484
#elif defined (TARGET_PPC)
2485 2486 2487 2488
#define TARGET_O_DIRECTORY      040000 /* must be a directory */
#define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
#define TARGET_O_LARGEFILE     0200000
#define TARGET_O_DIRECT        0400000 /* direct disk access hint */
B
bellard 已提交
2489
#elif defined (TARGET_SPARC)
2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502
#define TARGET_O_APPEND         0x0008
#define TARGET_FASYNC           0x0040  /* fcntl, for BSD compatibility */
#define TARGET_O_CREAT          0x0200  /* not fcntl */
#define TARGET_O_TRUNC          0x0400  /* not fcntl */
#define TARGET_O_EXCL           0x0800  /* not fcntl */
#define TARGET_O_DSYNC          0x2000
#define TARGET_O_NONBLOCK       0x4000
# ifdef TARGET_SPARC64
#  define TARGET_O_NDELAY       0x0004
# else
#  define TARGET_O_NDELAY       (0x0004 | TARGET_O_NONBLOCK)
# endif
#define TARGET_O_NOCTTY         0x8000  /* not fcntl */
B
bellard 已提交
2503
#define TARGET_O_LARGEFILE     0x40000
2504 2505 2506 2507 2508 2509 2510 2511
#define TARGET_O_DIRECT       0x100000  /* direct disk access hint */
#define TARGET_O_NOATIME      0x200000
#define TARGET_O_CLOEXEC      0x400000
#define TARGET___O_SYNC       0x800000
#define TARGET_O_PATH        0x1000000
#endif

/* <asm-generic/fcntl.h> values follow.  */
B
bellard 已提交
2512 2513 2514 2515
#define TARGET_O_ACCMODE          0003
#define TARGET_O_RDONLY             00
#define TARGET_O_WRONLY             01
#define TARGET_O_RDWR               02
2516
#ifndef TARGET_O_CREAT
B
bellard 已提交
2517
#define TARGET_O_CREAT            0100 /* not fcntl */
2518 2519
#endif
#ifndef TARGET_O_EXCL
B
bellard 已提交
2520
#define TARGET_O_EXCL             0200 /* not fcntl */
2521 2522
#endif
#ifndef TARGET_O_NOCTTY
B
bellard 已提交
2523
#define TARGET_O_NOCTTY           0400 /* not fcntl */
2524 2525
#endif
#ifndef TARGET_O_TRUNC
B
bellard 已提交
2526
#define TARGET_O_TRUNC           01000 /* not fcntl */
2527 2528
#endif
#ifndef TARGET_O_APPEND
B
bellard 已提交
2529
#define TARGET_O_APPEND          02000
2530 2531
#endif
#ifndef TARGET_O_NONBLOCK
B
bellard 已提交
2532
#define TARGET_O_NONBLOCK        04000
2533 2534 2535 2536 2537
#endif
#ifndef TARGET_O_DSYNC
#define TARGET_O_DSYNC          010000
#endif
#ifndef TARGET_FASYNC
B
bellard 已提交
2538
#define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
2539 2540
#endif
#ifndef TARGET_O_DIRECT
B
bellard 已提交
2541
#define TARGET_O_DIRECT         040000 /* direct disk access hint */
2542 2543
#endif
#ifndef TARGET_O_LARGEFILE
B
bellard 已提交
2544
#define TARGET_O_LARGEFILE     0100000
2545 2546
#endif
#ifndef TARGET_O_DIRECTORY
B
bellard 已提交
2547
#define TARGET_O_DIRECTORY     0200000 /* must be a directory */
2548 2549
#endif
#ifndef TARGET_O_NOFOLLOW
B
bellard 已提交
2550 2551
#define TARGET_O_NOFOLLOW      0400000 /* don't follow links */
#endif
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563
#ifndef TARGET_O_NOATIME
#define TARGET_O_NOATIME      01000000
#endif
#ifndef TARGET_O_CLOEXEC
#define TARGET_O_CLOEXEC      02000000
#endif
#ifndef TARGET___O_SYNC
#define TARGET___O_SYNC       04000000
#endif
#ifndef TARGET_O_PATH
#define TARGET_O_PATH        010000000
#endif
R
Riku Voipio 已提交
2564 2565 2566 2567 2568 2569
#ifndef TARGET___O_TMPFILE
#define TARGET___O_TMPFILE   020000000
#endif
#ifndef TARGET_O_TMPFILE
#define TARGET_O_TMPFILE     (TARGET___O_TMPFILE | TARGET_O_DIRECTORY)
#endif
2570 2571 2572 2573 2574 2575
#ifndef TARGET_O_NDELAY
#define TARGET_O_NDELAY  TARGET_O_NONBLOCK
#endif
#ifndef TARGET_O_SYNC
#define TARGET_O_SYNC    (TARGET___O_SYNC | TARGET_O_DSYNC)
#endif
B
bellard 已提交
2576

2577
struct target_flock {
2578 2579 2580 2581
    short l_type;
    short l_whence;
    abi_long l_start;
    abi_long l_len;
2582 2583 2584
#if defined(TARGET_MIPS)
    abi_long l_sysid;
#endif
2585
    int l_pid;
2586 2587 2588
#if defined(TARGET_MIPS)
    abi_long pad[4];
#endif
2589 2590 2591
};

struct target_flock64 {
2592 2593
    short  l_type;
    short  l_whence;
2594 2595
#if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) \
    || defined(TARGET_SPARC) || defined(TARGET_HPPA) \
2596
    || defined(TARGET_MICROBLAZE) || defined(TARGET_TILEGX)
2597
    int __pad;
2598
#endif
2599 2600 2601
    abi_llong l_start;
    abi_llong l_len;
    int  l_pid;
2602
} QEMU_PACKED;
2603

P
pbrook 已提交
2604 2605
#ifdef TARGET_ARM
struct target_eabi_flock64 {
2606 2607 2608 2609 2610 2611
    short  l_type;
    short  l_whence;
    int __pad;
    abi_llong l_start;
    abi_llong l_len;
    int  l_pid;
2612
} QEMU_PACKED;
P
pbrook 已提交
2613
#endif
2614

2615 2616 2617 2618 2619
struct target_f_owner_ex {
        int type;	/* Owner type of ID.  */
        int pid;	/* ID of owner.  */
};

2620
/* soundcard defines */
V
Veres Lajos 已提交
2621
/* XXX: convert them all to arch independent entries */
2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
#define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
#define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
#define TARGET_SNDCTL_COPR_RCODE          0xc0144303
#define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
#define TARGET_SNDCTL_COPR_RDATA          0xc0144302
#define TARGET_SNDCTL_COPR_RESET          0x00004300
#define TARGET_SNDCTL_COPR_RUN            0xc0144306
#define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
#define TARGET_SNDCTL_COPR_WCODE          0x40144305
#define TARGET_SNDCTL_COPR_WDATA          0x40144304
#define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
#define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
#define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
#define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
#define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
#define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
#define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
#define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
#define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
#define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
#define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
#define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
#define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
#define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
#define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
#define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
#define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
#define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
2650 2651
#define TARGET_SNDCTL_DSP_MAPINBUF        TARGET_IORU('P', 19)
#define TARGET_SNDCTL_DSP_MAPOUTBUF       TARGET_IORU('P', 20)
2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761
#define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
#define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
#define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
#define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
#define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
#define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
#define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
#define TARGET_SNDCTL_MIDI_INFO           0xc074510c
#define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
#define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
#define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
#define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
#define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
#define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
#define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
#define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
#define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
#define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
#define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
#define TARGET_SNDCTL_SEQ_PANIC           0x00005111
#define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
#define TARGET_SNDCTL_SEQ_RESET           0x00005100
#define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
#define TARGET_SNDCTL_SEQ_SYNC            0x00005101
#define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
#define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
#define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
#define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
#define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
#define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
#define TARGET_SNDCTL_TMR_METRONOME       0x40045407
#define TARGET_SNDCTL_TMR_SELECT          0x40045408
#define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
#define TARGET_SNDCTL_TMR_START           0x00005402
#define TARGET_SNDCTL_TMR_STOP            0x00005403
#define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
#define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
#define TARGET_SOUND_PCM_READ_RATE        0x80045002
#define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
#define TARGET_SOUND_PCM_READ_BITS        0x80045005
#define TARGET_SOUND_PCM_READ_FILTER      0x80045007
#define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
#define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
#define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
#define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
#define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
#define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
#define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)

#define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)

#define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
#define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
#define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
#define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
#define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
#define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
#define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
#define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
#define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
#define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
#define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
#define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
#define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
#define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
#define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
#define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
#define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)

/* Obsolete macros */
#define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
#define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
#define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)

#define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
#define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
#define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
#define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
#define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)

#define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)

#define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
#define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
#define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
#define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
#define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
#define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
#define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
#define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
#define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
#define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
#define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
#define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
#define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
#define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
#define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
#define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
#define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)

/* Obsolete macros */
#define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
#define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
#define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)

#define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)

/* vfat ioctls */
#define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
#define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
B
bellard 已提交
2762

2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790
struct target_mtop {
    abi_short mt_op;
    abi_int mt_count;
};

#if defined(TARGET_SPARC) || defined(TARGET_MIPS)
typedef abi_long target_kernel_daddr_t;
#else
typedef abi_int target_kernel_daddr_t;
#endif

struct target_mtget {
    abi_long mt_type;
    abi_long mt_resid;
    abi_long mt_dsreg;
    abi_long mt_gstat;
    abi_long mt_erreg;
    target_kernel_daddr_t mt_fileno;
    target_kernel_daddr_t mt_blkno;
};

struct target_mtpos {
    abi_long mt_blkno;
};

#define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct target_mtop)
#define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct target_mtget)
#define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct target_mtpos)
2791

B
bellard 已提交
2792
struct target_sysinfo {
2793 2794 2795 2796 2797 2798 2799 2800
    abi_long uptime;                /* Seconds since boot */
    abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
    abi_ulong totalram;             /* Total usable main memory size */
    abi_ulong freeram;              /* Available memory size */
    abi_ulong sharedram;            /* Amount of shared memory */
    abi_ulong bufferram;            /* Memory used by buffers */
    abi_ulong totalswap;            /* Total swap space size */
    abi_ulong freeswap;             /* swap space still available */
B
bellard 已提交
2801 2802
    unsigned short procs;           /* Number of current processes */
    unsigned short pad;             /* explicit padding for m68k */
2803 2804
    abi_ulong totalhigh;            /* Total high memory size */
    abi_ulong freehigh;             /* Available high memory size */
B
bellard 已提交
2805
    unsigned int mem_unit;          /* Memory unit size in bytes */
2806
    char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
B
bellard 已提交
2807
};
2808

A
aurel32 已提交
2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
struct linux_dirent {
    long            d_ino;
    unsigned long   d_off;
    unsigned short  d_reclen;
    char            d_name[256]; /* We must not include limits.h! */
};

struct linux_dirent64 {
    uint64_t        d_ino;
    int64_t         d_off;
    unsigned short  d_reclen;
    unsigned char   d_type;
    char            d_name[256];
};

2824 2825 2826 2827 2828 2829 2830
struct target_mq_attr {
    abi_long mq_flags;
    abi_long mq_maxmsg;
    abi_long mq_msgsize;
    abi_long mq_curmsgs;
};

2831
#include "socket.h"
2832 2833

#include "errno_defs.h"
2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850

#define FUTEX_WAIT              0
#define FUTEX_WAKE              1
#define FUTEX_FD                2
#define FUTEX_REQUEUE           3
#define FUTEX_CMP_REQUEUE       4
#define FUTEX_WAKE_OP           5
#define FUTEX_LOCK_PI           6
#define FUTEX_UNLOCK_PI         7
#define FUTEX_TRYLOCK_PI        8
#define FUTEX_WAIT_BITSET       9
#define FUTEX_WAKE_BITSET       10

#define FUTEX_PRIVATE_FLAG      128
#define FUTEX_CLOCK_REALTIME    256
#define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)

2851
#ifdef CONFIG_EPOLL
2852 2853 2854 2855 2856 2857
#if defined(TARGET_X86_64)
#define TARGET_EPOLL_PACKED QEMU_PACKED
#else
#define TARGET_EPOLL_PACKED
#endif

2858 2859
typedef union target_epoll_data {
    abi_ulong ptr;
2860 2861 2862
    abi_int fd;
    abi_uint u32;
    abi_ullong u64;
2863 2864 2865
} target_epoll_data_t;

struct target_epoll_event {
2866
    abi_uint events;
2867
    target_epoll_data_t data;
2868
} TARGET_EPOLL_PACKED;
2869 2870 2871

#define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))

2872
#endif
2873 2874 2875 2876
struct target_rlimit64 {
    uint64_t rlim_cur;
    uint64_t rlim_max;
};
2877 2878 2879 2880 2881 2882

struct target_ucred {
    uint32_t pid;
    uint32_t uid;
    uint32_t gid;
};
P
Paolo Bonzini 已提交
2883

2884
typedef int32_t target_timer_t;
2885

2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899
#define TARGET_SIGEV_MAX_SIZE 64

/* This is architecture-specific but most architectures use the default */
#ifdef TARGET_MIPS
#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
#else
#define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
                                    + sizeof(target_sigval_t))
#endif

#define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
                                - TARGET_SIGEV_PREAMBLE_SIZE) \
                               / sizeof(int32_t))

2900 2901
struct target_sigevent {
    target_sigval_t sigev_value;
2902 2903
    abi_int sigev_signo;
    abi_int sigev_notify;
2904
    union {
2905 2906
        abi_int _pad[TARGET_SIGEV_PAD_SIZE];
        abi_int _tid;
2907

2908 2909 2910 2911
        /* The kernel (and thus QEMU) never looks at these;
         * they're only used as part of the ABI between a
         * userspace program and libc.
         */
2912
        struct {
2913 2914
            abi_ulong _function;
            abi_ulong _attribute;
2915 2916 2917
        } _sigev_thread;
    } _sigev_un;
};
2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928

struct target_user_cap_header {
    uint32_t version;
    int pid;
};

struct target_user_cap_data {
    uint32_t effective;
    uint32_t permitted;
    uint32_t inheritable;
};
2929

2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954
/* from kernel's include/linux/syslog.h */

/* Close the log.  Currently a NOP. */
#define TARGET_SYSLOG_ACTION_CLOSE          0
/* Open the log. Currently a NOP. */
#define TARGET_SYSLOG_ACTION_OPEN           1
/* Read from the log. */
#define TARGET_SYSLOG_ACTION_READ           2
/* Read all messages remaining in the ring buffer. */
#define TARGET_SYSLOG_ACTION_READ_ALL       3
/* Read and clear all messages remaining in the ring buffer */
#define TARGET_SYSLOG_ACTION_READ_CLEAR     4
/* Clear ring buffer. */
#define TARGET_SYSLOG_ACTION_CLEAR          5
/* Disable printk's to console */
#define TARGET_SYSLOG_ACTION_CONSOLE_OFF    6
/* Enable printk's to console */
#define TARGET_SYSLOG_ACTION_CONSOLE_ON     7
/* Set level of messages printed to console */
#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL  8
/* Return number of unread characters in the log buffer */
#define TARGET_SYSLOG_ACTION_SIZE_UNREAD    9
/* Return size of the log buffer */
#define TARGET_SYSLOG_ACTION_SIZE_BUFFER   10

2955
#endif