syscall_defs.h 64.1 KB
Newer Older
1 2
/* common syscall defines for all architectures */

3 4 5 6
/* Note: although the syscall numbers change between architectures,
   most of them stay the same, so we handle it by puting ifdefs if
   necessary */

bellard's avatar
bellard committed
7
#include "syscall_nr.h"
8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#define SOCKOP_socket           1
#define SOCKOP_bind             2
#define SOCKOP_connect          3
#define SOCKOP_listen           4
#define SOCKOP_accept           5
#define SOCKOP_getsockname      6
#define SOCKOP_getpeername      7
#define SOCKOP_socketpair       8
#define SOCKOP_send             9
#define SOCKOP_recv             10
#define SOCKOP_sendto           11
#define SOCKOP_recvfrom         12
#define SOCKOP_shutdown         13
#define SOCKOP_setsockopt       14
#define SOCKOP_getsockopt       15
#define SOCKOP_sendmsg          16
#define SOCKOP_recvmsg          17

27 28 29 30 31 32 33 34 35 36 37 38 39
#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

40 41 42 43 44 45 46 47 48 49 50
/*
 * 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

pbrook's avatar
pbrook committed
51
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
52
    || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS)
53 54 55 56 57 58 59 60

#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

bellard's avatar
bellard committed
61 62
#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
      defined(TARGET_SPARC) || defined(TARGET_MIPS)
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

#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

#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)

bellard's avatar
bellard committed
102 103 104 105 106
struct target_sockaddr {
    uint16_t sa_family;
    uint8_t sa_data[14];
};

107
struct target_timeval {
108 109
    abi_long tv_sec;
    abi_long tv_usec;
110 111
};

bellard's avatar
bellard committed
112
struct target_timespec {
113 114
    abi_long tv_sec;
    abi_long tv_nsec;
bellard's avatar
bellard committed
115 116
};

bellard's avatar
bellard committed
117 118 119 120 121
struct target_itimerval {
    struct target_timeval it_interval;
    struct target_timeval it_value;
};

122
typedef abi_long target_clock_t;
bellard's avatar
bellard committed
123

bellard's avatar
bellard committed
124 125
#define TARGET_HZ 100

bellard's avatar
bellard committed
126 127 128 129 130 131 132
struct target_tms {
    target_clock_t tms_utime;
    target_clock_t tms_stime;
    target_clock_t tms_cutime;
    target_clock_t tms_cstime;
};

bellard's avatar
bellard committed
133
struct target_utimbuf {
134 135
    abi_long actime;
    abi_long modtime;
bellard's avatar
bellard committed
136 137
};

bellard's avatar
bellard committed
138
struct target_sel_arg_struct {
139 140 141
    abi_long n;
    abi_long inp, outp, exp;
    abi_long tvp;
bellard's avatar
bellard committed
142 143
};

144
struct target_iovec {
145 146
    abi_long iov_base;   /* Starting address */
    abi_long iov_len;   /* Number of bytes */
147 148
};

bellard's avatar
bellard committed
149
struct target_msghdr {
150 151 152 153 154 155
    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 */
bellard's avatar
bellard committed
156 157 158
    unsigned int msg_flags;
};

bellard's avatar
bellard committed
159
struct target_cmsghdr {
160
    abi_long     cmsg_len;
bellard's avatar
bellard committed
161 162 163 164 165 166
    int          cmsg_level;
    int          cmsg_type;
};

#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
#define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
167 168
#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
                               & (size_t) ~(sizeof (abi_long) - 1))
bellard's avatar
bellard committed
169 170 171 172 173 174 175
#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
                               + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
#define TARGET_CMSG_LEN(len)   (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))

static __inline__ struct target_cmsghdr *
__target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
{
176 177 178 179 180 181
  struct target_cmsghdr *__ptr;

  __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
                                    + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
  if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
      > tswapl(__mhdr->msg_controllen))
bellard's avatar
bellard committed
182
    /* No more entries.  */
183
    return (struct target_cmsghdr *)0;
bellard's avatar
bellard committed
184 185 186 187
  return __cmsg;
}


188 189 190
struct  target_rusage {
        struct target_timeval ru_utime;        /* user time used */
        struct target_timeval ru_stime;        /* system time used */
191 192 193 194 195 196 197 198 199 200 201 202 203 204
        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 " */
205 206 207 208 209 210
};

typedef struct {
        int     val[2];
} kernel_fsid_t;

bellard's avatar
bellard committed
211
struct kernel_statfs {
212 213 214 215 216 217 218 219 220 221 222 223
	int f_type;
	int f_bsize;
	int f_blocks;
	int f_bfree;
	int f_bavail;
	int f_files;
	int f_ffree;
        kernel_fsid_t f_fsid;
	int f_namelen;
	int f_spare[6];
};

bellard's avatar
bellard committed
224
struct target_dirent {
225 226
	abi_long	d_ino;
	abi_long	d_off;
bellard's avatar
bellard committed
227 228 229 230 231 232 233 234 235 236 237 238 239
	unsigned short	d_reclen;
	char		d_name[256]; /* We must not include limits.h! */
};

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


240
/* mostly generic signal stuff */
241 242 243
#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 */
244 245 246 247 248 249

#ifdef TARGET_MIPS
#define TARGET_NSIG	   128
#else
#define TARGET_NSIG	   64
#endif
250
#define TARGET_NSIG_BPW	   TARGET_ABI_BITS
251 252 253
#define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)

typedef struct {
254
    abi_ulong sig[TARGET_NSIG_WORDS];
255 256
} target_sigset_t;

bellard's avatar
bellard committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270
#ifdef BSWAP_NEEDED
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
{
    int i;
    for(i = 0;i < TARGET_NSIG_WORDS; i++)
        d->sig[i] = tswapl(s->sig[i]);
}
#else
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
{
    *d = *s;
}
#endif

271
static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
bellard's avatar
bellard committed
272 273 274 275 276 277 278
{
    int i;
    d->sig[0] = set;
    for(i = 1;i < TARGET_NSIG_WORDS; i++)
        d->sig[i] = 0;
}

bellard's avatar
bellard committed
279 280
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);
281
void host_to_target_old_sigset(abi_ulong *old_sigset,
bellard's avatar
bellard committed
282
                               const sigset_t *sigset);
283
void target_to_host_old_sigset(sigset_t *sigset,
284
                               const abi_ulong *old_sigset);
bellard's avatar
bellard committed
285 286 287 288
struct target_sigaction;
int do_sigaction(int sig, const struct target_sigaction *act,
                 struct target_sigaction *oact);

289
#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)
290

bellard's avatar
bellard committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
#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
#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
307 308
#if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
#define TARGET_SA_RESTORER	0x04000000	/* Only for O32 */
309
#endif
bellard's avatar
bellard committed
310
#else
311 312 313 314 315 316 317 318
#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
bellard's avatar
bellard committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
#endif

#if defined(TARGET_SPARC)

#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 */

bellard's avatar
bellard committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
#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 */

bellard's avatar
bellard committed
404
#else
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435

#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
bellard's avatar
bellard committed
436 437
#define TARGET_SIGPWR		30
#define TARGET_SIGSYS		31
438 439 440 441 442 443
#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 */

bellard's avatar
bellard committed
444 445
#endif

446 447 448
#if defined(TARGET_MIPS)

struct target_sigaction {
449
	uint32_t	sa_flags;
450
#if defined(TARGET_ABI_MIPSN32)
451 452
	uint32_t	_sa_handler;
#else
453
	abi_ulong	_sa_handler;
454
#endif
455 456 457 458
	target_sigset_t	sa_mask;
};

#else
459
struct target_old_sigaction {
460 461 462 463
        abi_ulong _sa_handler;
        abi_ulong sa_mask;
        abi_ulong sa_flags;
        abi_ulong sa_restorer;
464 465 466
};

struct target_sigaction {
467 468 469
        abi_ulong _sa_handler;
        abi_ulong sa_flags;
        abi_ulong sa_restorer;
470 471
        target_sigset_t sa_mask;
};
472
#endif
473 474 475

typedef union target_sigval {
	int sival_int;
476
        abi_ulong sival_ptr;
477
} target_sigval_t;
bellard's avatar
bellard committed
478 479 480 481
#if 0
#if defined (TARGET_SPARC)
typedef struct {
	struct {
482 483 484 485 486
		abi_ulong psr;
		abi_ulong pc;
		abi_ulong npc;
		abi_ulong y;
		abi_ulong u_regs[16]; /* globals and ins */
bellard's avatar
bellard committed
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
	}		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
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 540 541 542 543

#define TARGET_SI_MAX_SIZE	128
#define TARGET_SI_PAD_SIZE	((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)

typedef struct target_siginfo {
	int si_signo;
	int si_errno;
	int si_code;

	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 */
			target_sigval_t _sigval;
		} _rt;

		/* SIGCHLD */
		struct {
			pid_t _pid;		/* which child */
			uid_t _uid;		/* sender's uid */
			int _status;		/* exit code */
			target_clock_t _utime;
                        target_clock_t _stime;
		} _sigchld;

		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
		struct {
544
			abi_ulong _addr; /* faulting insn/memory ref. */
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
		} _sigfault;

		/* SIGPOLL */
		struct {
			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
			int _fd;
		} _sigpoll;
	} _sifields;
} target_siginfo_t;

/*
 * 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
 */
570
#define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
571
#define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
572 573 574 575 576 577
#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 */
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597

/*
 * 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 */

598 599 600 601 602 603 604
/*
 * SIGBUS si_codes
 */
#define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
#define TARGET_BUS_ADRERR       (2)	/* non-existant physical address */
#define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */

605 606 607 608 609 610 611 612
/*
 * SIGTRAP si_codes
 */
#define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
#define TARGET_TRAP_TRACE	(2)	/* process trace trap */

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

bellard's avatar
bellard committed
613
struct target_rlimit {
614 615
        abi_ulong   rlim_cur;
        abi_ulong   rlim_max;
bellard's avatar
bellard committed
616 617 618 619 620 621 622 623
};

struct target_pollfd {
    int fd;           /* file descriptor */
    short events;     /* requested events */
    short revents;    /* returned events */
};

bellard's avatar
bellard committed
624
/* virtual terminal ioctls */
bellard's avatar
bellard committed
625 626
#define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
#define TARGET_KDMKTONE	       0x4B30	/* generate tone */
bellard's avatar
bellard committed
627
#define TARGET_KDGKBTYPE       0x4b33
bellard's avatar
bellard committed
628 629
#define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
#define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
bellard's avatar
bellard committed
630

631 632
#define TARGET_SIOCATMARK      0x8905

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 662 663 664 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 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
/* 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

/* 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           */


/* 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 */
/* A jump here: 108-111 have been used for various private purposes. */
#define TARGET_BLKBSZGET  TARGET_IOR(0x12,112,sizeof(int))
#define TARGET_BLKBSZSET  TARGET_IOW(0x12,113,sizeof(int))
#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
#define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
#define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */

/* cdrom commands */
715
#define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
716 717
#define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
#define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
718
#define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
719
                                           (struct cdrom_ti) */
720
#define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
721
                                           (struct cdrom_tochdr) */
722
#define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
723 724 725 726
                                           (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 */
727
#define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
728
                                           (struct cdrom_volctrl) */
729
#define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
730
                                           (struct cdrom_subchnl) */
731
#define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
732 733 734 735 736
                                           (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 */
737 738
#define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
                                           address of multi session disks
739
                                           (struct cdrom_multisession) */
740
#define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
741
                                           if available (struct cdrom_mcn) */
742
#define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is depricated,
743 744
                                          but here anyway for compatability */
#define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
745
#define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
746 747 748
                                          (struct cdrom_volctrl) */
#define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
                                           (struct cdrom_read) */
749
/*
750 751 752 753
 * 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 */
754

755
/*
756
 * This ioctl is only used by the scsi-cd driver.
757 758 759 760
   It is for playing audio in logical block addressing mode.
 */
#define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */

761
/*
762 763 764 765
 * These ioctls are only used in optcd.c
 */
#define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */

766 767
/*
 * These ioctls are (now) only in ide-cd.c for controlling
768 769 770 771 772 773 774 775
 * 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

776
/*
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
 * 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 */
821
#define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
822 823 824 825 826 827 828 829 830 831
#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 */
832

balrog's avatar
balrog committed
833 834 835 836 837 838 839 840
/* 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
841 842 843

/* from asm/termbits.h */

bellard's avatar
bellard committed
844 845 846 847 848 849 850 851 852
#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 */
};
853

bellard's avatar
bellard committed
854 855 856 857 858
struct target_winsize {
	unsigned short ws_row;
	unsigned short ws_col;
	unsigned short ws_xpixel;
	unsigned short ws_ypixel;
859 860
};

bellard's avatar
bellard committed
861
#include "termbits.h"
862 863 864 865 866

#define TARGET_MAP_SHARED	0x01		/* Share changes */
#define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
#define TARGET_MAP_TYPE	0x0f		/* Mask for type of mapping */
#define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
bellard's avatar
bellard committed
867 868 869 870 871 872 873
#if defined(TARGET_MIPS)
#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 */
874 875
#define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
bellard's avatar
bellard committed
876
#else
877 878 879 880
#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 */
881 882 883 884
#if defined(TARGET_PPC)
#define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
#define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
#else
885 886
#define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
#define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
bellard's avatar
bellard committed
887
#endif
888 889
#define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
890
#endif
891

bellard's avatar
bellard committed
892
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_CRIS)
893 894 895
struct target_stat {
	unsigned short st_dev;
	unsigned short __pad1;
896
	abi_ulong st_ino;
897 898 899 900 901 902
	unsigned short st_mode;
	unsigned short st_nlink;
	unsigned short st_uid;
	unsigned short st_gid;
	unsigned short st_rdev;
	unsigned short __pad2;
903 904 905 906 907 908 909 910 911 912 913
	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;
914 915 916 917 918 919 920 921 922 923
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
struct target_stat64 {
	unsigned short	st_dev;
	unsigned char	__pad0[10];

#define TARGET_STAT64_HAS_BROKEN_ST_INO	1
924
	abi_ulong	__st_ino;
925 926 927 928

	unsigned int	st_mode;
	unsigned int	st_nlink;

929 930
	abi_ulong	st_uid;
	abi_ulong	st_gid;
931 932 933 934 935

	unsigned short	st_rdev;
	unsigned char	__pad3[10];

	long long	st_size;
936
	abi_ulong	st_blksize;
937

938 939
	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
	abi_ulong	__pad4;		/* future possible st_blocks high bits */
940

941 942
	abi_ulong	target_st_atime;
	abi_ulong	__pad5;
943

944 945
	abi_ulong	target_st_mtime;
	abi_ulong	__pad6;
946

947 948
	abi_ulong	target_st_ctime;
	abi_ulong	__pad7;		/* will be high 32 bits of ctime someday */
949 950 951 952

	unsigned long long	st_ino;
} __attribute__((packed));

pbrook's avatar
pbrook committed
953 954 955 956
#ifdef TARGET_ARM
struct target_eabi_stat64 {
        unsigned long long st_dev;
        unsigned int    __pad1;
957
        abi_ulong    __st_ino;
pbrook's avatar
pbrook committed
958 959 960
        unsigned int    st_mode;
        unsigned int    st_nlink;

961 962
        abi_ulong    st_uid;
        abi_ulong    st_gid;
pbrook's avatar
pbrook committed
963 964 965 966 967

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

        long long       st_size;
968
        abi_ulong    st_blksize;
pbrook's avatar
pbrook committed
969 970 971
        unsigned int    __pad3;
        unsigned long long st_blocks;

972 973
        abi_ulong    target_st_atime;
        abi_ulong    target_st_atime_nsec;
pbrook's avatar
pbrook committed
974

975 976
        abi_ulong    target_st_mtime;
        abi_ulong    target_st_mtime_nsec;
pbrook's avatar
pbrook committed
977

978 979
        abi_ulong    target_st_ctime;
        abi_ulong    target_st_ctime_nsec;
pbrook's avatar
pbrook committed
980 981 982 983 984

        unsigned long long st_ino;
} __attribute__ ((packed));
#endif

985
#elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
blueswir1's avatar
blueswir1 committed
986 987
struct target_stat {
	unsigned int	st_dev;
988
	abi_ulong	st_ino;
blueswir1's avatar
blueswir1 committed
989 990 991 992 993
	unsigned int	st_mode;
	unsigned int	st_nlink;
	unsigned int	st_uid;
	unsigned int	st_gid;
	unsigned int	st_rdev;
994 995 996 997 998 999 1000
	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];
blueswir1's avatar
blueswir1 committed
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
};

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;

1024 1025
	abi_ulong	target_st_atime;
	abi_ulong	__unused1;
blueswir1's avatar
blueswir1 committed
1026

1027 1028
	abi_ulong	target_st_mtime;
	abi_ulong	__unused2;
blueswir1's avatar
blueswir1 committed
1029

1030 1031
	abi_ulong	target_st_ctime;
	abi_ulong	__unused3;
blueswir1's avatar
blueswir1 committed
1032

1033
	abi_ulong	__unused4[3];
blueswir1's avatar
blueswir1 committed
1034 1035
};

bellard's avatar
bellard committed
1036 1037 1038 1039
#elif defined(TARGET_SPARC)

struct target_stat {
	unsigned short	st_dev;
1040
	abi_ulong	st_ino;
bellard's avatar
bellard committed
1041 1042 1043 1044 1045
	unsigned short	st_mode;
	short		st_nlink;
	unsigned short	st_uid;
	unsigned short	st_gid;
	unsigned short	st_rdev;
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
	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];
bellard's avatar
bellard committed
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 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
};

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;
};

1094 1095 1096
#elif defined(TARGET_PPC)

struct target_stat {
1097
	abi_ulong st_dev;
1098
	abi_ulong st_ino;
1099
#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1100
	abi_ulong st_nlink;
1101 1102
	unsigned int st_mode;
#else
1103 1104
	unsigned int st_mode;
	unsigned short st_nlink;
1105
#endif
1106 1107
	unsigned int st_uid;
	unsigned int st_gid;
1108
	abi_ulong  st_rdev;
1109 1110 1111 1112
	abi_ulong  st_size;
	abi_ulong  st_blksize;
	abi_ulong  st_blocks;
	abi_ulong  target_st_atime;
1113
	abi_ulong  target_st_atime_nsec;
1114
	abi_ulong  target_st_mtime;
1115
	abi_ulong  target_st_mtime_nsec;
1116
	abi_ulong  target_st_ctime;
1117
	abi_ulong  target_st_ctime_nsec;
1118 1119
	abi_ulong  __unused4;
	abi_ulong  __unused5;
1120 1121 1122
#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
	abi_ulong  __unused6;
#endif
1123 1124 1125 1126 1127
};

struct target_stat64 {
	unsigned long long st_dev;
        unsigned long long st_ino;
bellard's avatar
bellard committed
1128 1129
	unsigned int st_mode;
	unsigned int st_nlink;
1130 1131
	unsigned int st_uid;
	unsigned int st_gid;
bellard's avatar
bellard committed
1132
	unsigned long long st_rdev;
1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
	unsigned short pad0;
	long long      st_size;
	int	       st_blksize;
	long long      st_blocks;	/* Number 512-byte blocks allocated. */
	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;
1145 1146
};

pbrook's avatar
pbrook committed
1147 1148 1149 1150 1151
#elif defined(TARGET_M68K)

struct target_stat {
	unsigned short st_dev;
	unsigned short __pad1;
1152
	abi_ulong st_ino;
pbrook's avatar
pbrook committed
1153 1154 1155 1156 1157 1158
	unsigned short st_mode;
	unsigned short st_nlink;
	unsigned short st_uid;
	unsigned short st_gid;
	unsigned short st_rdev;
	unsigned short __pad2;
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
	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;
pbrook's avatar
pbrook committed
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
struct target_stat64 {
	unsigned long long	st_dev;
	unsigned char	__pad1[2];

#define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1180
	abi_ulong	__st_ino;
pbrook's avatar
pbrook committed
1181 1182 1183 1184

	unsigned int	st_mode;
	unsigned int	st_nlink;

1185 1186
	abi_ulong	st_uid;
	abi_ulong	st_gid;
pbrook's avatar
pbrook committed
1187 1188 1189 1190 1191

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

	long long	st_size;
1192
	abi_ulong	st_blksize;
pbrook's avatar
pbrook committed
1193

1194 1195
	abi_ulong	__pad4;		/* future possible st_blocks high bits */
	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
pbrook's avatar
pbrook committed
1196

1197 1198
	abi_ulong	target_st_atime;
	abi_ulong	target_st_atime_nsec;
pbrook's avatar
pbrook committed
1199

1200 1201
	abi_ulong	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;
pbrook's avatar
pbrook committed
1202

1203 1204
	abi_ulong	target_st_ctime;
	abi_ulong	target_st_ctime_nsec;
pbrook's avatar
pbrook committed
1205 1206 1207 1208

	unsigned long long	st_ino;
} __attribute__((packed));

1209
#elif defined(TARGET_ABI_MIPSN64)
1210 1211 1212 1213 1214 1215

/* 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 */

1216
	abi_ulong		st_ino;
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226

	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 */

1227
	abi_ulong		st_size;
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244

	/*
	 * 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;

1245
	abi_ulong		st_blocks;
1246 1247
};

1248
#elif defined(TARGET_ABI_MIPSN32)
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318

struct target_stat {
	unsigned	st_dev;
	int		st_pad1[3];		/* Reserved for network id */
	unsigned int	st_ino;
	unsigned int	st_mode;
	unsigned int	st_nlink;
	int		st_uid;
	int		st_gid;
	unsigned 	st_rdev;
	unsigned int	st_pad2[2];
	unsigned int	st_size;
	unsigned int	st_pad3;
	/*
	 * 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_blocks;
	unsigned int		st_pad4[14];
};

/*
 * 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.
 */

struct target_stat64 {
	unsigned int	st_dev;
	unsigned int	st_pad0[3];	/* Reserved for st_dev expansion  */

	target_ulong	st_ino;

        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  */

	int		st_size;

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

	int		target_st_mtime;
	unsigned int	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */

	int		target_st_ctime;
	unsigned int	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */

	unsigned int	st_blksize;
	unsigned int	st_pad2;

	int		st_blocks;
};

1319
#elif defined(TARGET_ABI_MIPSO32)
bellard's avatar
bellard committed
1320 1321 1322

struct target_stat {
	unsigned	st_dev;
1323 1324
	abi_long	st_pad1[3];		/* Reserved for network id */
	abi_ulong	st_ino;
bellard's avatar
bellard committed
1325 1326 1327 1328 1329
	unsigned int	st_mode;
	unsigned int	st_nlink;
	int		st_uid;
	int		st_gid;
	unsigned 	st_rdev;
1330 1331 1332
	abi_long	st_pad2[2];
	abi_long	st_size;
	abi_long	st_pad3;
bellard's avatar
bellard committed
1333 1334 1335 1336
	/*
	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
	 * but we don't have it under Linux.
	 */
1337 1338 1339 1340 1341 1342 1343 1344 1345
	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];
bellard's avatar
bellard committed
1346 1347 1348 1349 1350 1351 1352 1353 1354
};

/*
 * 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.
 */

struct target_stat64 {
1355 1356
	abi_ulong	st_dev;
	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
bellard's avatar
bellard committed
1357 1358 1359 1360 1361 1362 1363 1364 1365

	uint64_t	st_ino;

        unsigned int	st_mode;
        unsigned int	st_nlink;

	int		st_uid;
	int		st_gid;

1366 1367
	abi_ulong	st_rdev;
	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
bellard's avatar
bellard committed
1368 1369 1370 1371 1372 1373 1374

	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.
	 */
1375 1376
	abi_long	target_st_atime;
	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
bellard's avatar
bellard committed
1377

1378 1379
	abi_long	target_st_mtime;
	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
bellard's avatar
bellard committed
1380

1381 1382
	abi_long	target_st_ctime;
	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
bellard's avatar
bellard committed
1383

1384 1385
	abi_ulong	st_blksize;
	abi_ulong	st_pad2;
bellard's avatar
bellard committed
1386 1387 1388

	int64_t  	st_blocks;
};