typo
[qemu] / linux-user / syscall_defs.h
index 91e1fe5..4e2dd17 100644 (file)
@@ -48,7 +48,7 @@
 #define TARGET_IOC_NRBITS      8
 #define TARGET_IOC_TYPEBITS    8
 
-#if defined(TARGET_I386) || defined(TARGET_ARM)
+#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4)
 
 #define TARGET_IOC_SIZEBITS    14
 #define TARGET_IOC_DIRBITS     2
@@ -57,7 +57,8 @@
 #define TARGET_IOC_WRITE  1U
 #define TARGET_IOC_READ          2U
 
-#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_SPARC)
+#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
+      defined(TARGET_SPARC) || defined(TARGET_MIPS)
 
 #define TARGET_IOC_SIZEBITS    13
 #define TARGET_IOC_DIRBITS     3
@@ -292,8 +293,26 @@ struct target_sigaction;
 int do_sigaction(int sig, const struct target_sigaction *act,
                  struct target_sigaction *oact);
 
-#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC)
-
+#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined (TARGET_SH4)
+
+#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
+#define TARGET_SA_RESTORER     0x04000000      /* Only for o32 */
+#else
 #define TARGET_SA_NOCLDSTOP    0x00000001
 #define TARGET_SA_NOCLDWAIT    0x00000002 /* not supported yet */
 #define TARGET_SA_SIGINFO      0x00000004
@@ -302,6 +321,92 @@ int do_sigaction(int sig, const struct target_sigaction *act,
 #define TARGET_SA_NODEFER      0x40000000
 #define TARGET_SA_RESETHAND    0x80000000
 #define TARGET_SA_RESTORER     0x04000000
+#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 */
+
+#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 */
+
+#else
 
 #define TARGET_SIGHUP           1
 #define TARGET_SIGINT           2
@@ -341,6 +446,8 @@ int do_sigaction(int sig, const struct target_sigaction *act,
 #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
 #define TARGET_SIG_SETMASK        2    /* for setting the signal mask */
 
+#endif
+
 struct target_old_sigaction {
         target_ulong _sa_handler;
         target_ulong sa_mask;
@@ -359,6 +466,30 @@ typedef union target_sigval {
        int sival_int;
         target_ulong sival_ptr;
 } target_sigval_t;
+#if 0
+#if defined (TARGET_SPARC)
+typedef struct {
+       struct {
+               target_ulong psr;
+               target_ulong pc;
+               target_ulong npc;
+               target_ulong y;
+               target_ulong u_regs[16]; /* globals and ins */
+       }               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
 
 #define TARGET_SI_MAX_SIZE     128
 #define TARGET_SI_PAD_SIZE     ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
@@ -716,15 +847,23 @@ struct target_winsize {
 #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 */
+#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 */
+#else
 #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 */
 #define TARGET_MAP_LOCKED      0x2000          /* pages are locked */
 #define TARGET_MAP_NORESERVE   0x4000          /* don't check for reservations */
+#endif
 
-#if defined(TARGET_I386) || defined(TARGET_ARM)
+#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4)
 struct target_stat {
        unsigned short st_dev;
        unsigned short __pad1;
@@ -785,6 +924,38 @@ struct target_stat64 {
        unsigned long long      st_ino;
 } __attribute__((packed));
 
+#ifdef TARGET_ARM
+struct target_eabi_stat64 {
+        unsigned long long st_dev;
+        unsigned int    __pad1;
+        unsigned long   __st_ino;
+        unsigned int    st_mode;
+        unsigned int    st_nlink;
+
+        unsigned long   st_uid;
+        unsigned long   st_gid;
+
+        unsigned long long st_rdev;
+        unsigned int    __pad2[2];
+
+        long long       st_size;
+        unsigned long   st_blksize;
+        unsigned int    __pad3;
+        unsigned long long st_blocks;
+
+        unsigned long   target_st_atime;
+        unsigned long   target_st_atime_nsec;
+
+        unsigned long   target_st_mtime;
+        unsigned long   target_st_mtime_nsec;
+
+        unsigned long   target_st_ctime;
+        unsigned long   target_st_ctime_nsec;
+
+        unsigned long long st_ino;
+} __attribute__ ((packed));
+#endif
+
 #elif defined(TARGET_SPARC)
 
 struct target_stat {
@@ -889,7 +1060,141 @@ struct target_stat64 {
         target_ulong    __unused5;
 };
 
-#endif /* defined(TARGET_PPC) */
+#elif defined(TARGET_MIPS)
+
+struct target_stat {
+       unsigned        st_dev;
+       target_long     st_pad1[3];             /* Reserved for network id */
+       target_ulong    st_ino;
+       unsigned int    st_mode;
+       unsigned int    st_nlink;
+       int             st_uid;
+       int             st_gid;
+       unsigned        st_rdev;
+       target_long     st_pad2[2];
+       target_long     st_size;
+       target_long     st_pad3;
+       /*
+        * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
+        * but we don't have it under Linux.
+        */
+       target_long             target_st_atime;
+       target_long             target_st_atime_nsec;
+       target_long             target_st_mtime;
+       target_long             target_st_mtime_nsec;
+       target_long             target_st_ctime;
+       target_long             target_st_ctime_nsec;
+       target_long             st_blksize;
+       target_long             st_blocks;
+       target_long             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 {
+       target_ulong    st_dev;
+       target_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;
+
+       target_ulong    st_rdev;
+       target_ulong    st_pad1[3];     /* Reserved for st_rdev expansion  */
+
+       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.
+        */
+       target_long     target_st_atime;
+       target_ulong    target_st_atime_nsec;   /* Reserved for st_atime expansion  */
+
+       target_long     target_st_mtime;
+       target_ulong    target_st_mtime_nsec;   /* Reserved for st_mtime expansion  */
+
+       target_long     target_st_ctime;
+       target_ulong    target_st_ctime_nsec;   /* Reserved for st_ctime expansion  */
+
+       target_ulong    st_blksize;
+       target_ulong    st_pad2;
+
+       int64_t         st_blocks;
+};
+#else
+#error unsupported CPU
+#endif
+
+#ifdef TARGET_MIPS
+struct target_statfs {
+       target_long             f_type;
+       target_long             f_bsize;
+       target_long             f_frsize;       /* Fragment size - unsupported */
+       target_long             f_blocks;
+       target_long             f_bfree;
+       target_long             f_files;
+       target_long             f_ffree;
+       target_long             f_bavail;
+
+       /* Linux specials */
+       int     f_fsid;
+       target_long             f_namelen;
+       target_long             f_spare[6];
+};
+
+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;
+       int f_fsid;
+       uint32_t        f_namelen;
+       uint32_t        f_spare[6];
+};
+#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;
+       int f_fsid;
+       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;
+       int f_fsid;
+        uint32_t f_namelen;
+       uint32_t f_frsize;
+       uint32_t f_spare[5];
+};
+#endif
+
 
 #define TARGET_F_DUPFD         0       /* dup */
 #define TARGET_F_GETFD         1       /* get close_on_exec */
@@ -929,7 +1234,7 @@ struct target_stat64 {
 #define TARGET_O_TRUNC           01000 /* not fcntl */
 #define TARGET_O_APPEND          02000
 #define TARGET_O_NONBLOCK        04000
-#define TARGET_O_NDELAY        O_NONBLOCK
+#define TARGET_O_NDELAY        TARGET_O_NONBLOCK
 #define TARGET_O_SYNC           010000
 #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
 #define TARGET_O_DIRECTORY      040000 /* must be a directory */
@@ -947,13 +1252,50 @@ struct target_stat64 {
 #define TARGET_O_TRUNC           01000 /* not fcntl */
 #define TARGET_O_APPEND          02000
 #define TARGET_O_NONBLOCK        04000
-#define TARGET_O_NDELAY        O_NONBLOCK
+#define TARGET_O_NDELAY        TARGET_O_NONBLOCK
 #define TARGET_O_SYNC           010000
 #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
 #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 */
+#elif defined (TARGET_SPARC)
+#define TARGET_O_RDONLY        0x0000
+#define TARGET_O_WRONLY        0x0001
+#define TARGET_O_RDWR          0x0002
+#define TARGET_O_ACCMODE       0x0003
+#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_SYNC          0x2000
+#define TARGET_O_NONBLOCK      0x4000
+#define TARGET_O_NDELAY        (0x0004 | TARGET_O_NONBLOCK)
+#define TARGET_O_NOCTTY        0x8000  /* not fcntl */
+#define TARGET_O_DIRECTORY     0x10000 /* must be a directory */
+#define TARGET_O_NOFOLLOW      0x20000 /* don't follow links */
+#define TARGET_O_LARGEFILE     0x40000
+#define TARGET_O_DIRECT        0x100000 /* direct disk access hint */
+#elif defined(TARGET_MIPS)
+#define TARGET_O_ACCMODE       0x0003
+#define TARGET_O_RDONLY        0x0000
+#define TARGET_O_WRONLY        0x0001
+#define TARGET_O_RDWR          0x0002
+#define TARGET_O_APPEND        0x0008
+#define TARGET_O_SYNC          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_DIRECT        0x8000  /* direct disk access hint */
+#define TARGET_O_DIRECTORY     0x10000 /* must be a directory */
+#define TARGET_O_NOFOLLOW      0x20000 /* don't follow links */
+#define TARGET_O_NOATIME       0x40000
+#define TARGET_O_NDELAY        TARGET_O_NONBLOCK
 #else
 #define TARGET_O_ACCMODE          0003
 #define TARGET_O_RDONLY             00
@@ -965,7 +1307,7 @@ struct target_stat64 {
 #define TARGET_O_TRUNC           01000 /* not fcntl */
 #define TARGET_O_APPEND          02000
 #define TARGET_O_NONBLOCK        04000
-#define TARGET_O_NDELAY        O_NONBLOCK
+#define TARGET_O_NDELAY        TARGET_O_NONBLOCK
 #define TARGET_O_SYNC           010000
 #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
 #define TARGET_O_DIRECT         040000 /* direct disk access hint */
@@ -988,8 +1330,18 @@ struct target_flock64 {
        unsigned long long l_start;
        unsigned long long l_len;
        int  l_pid;
-};
+}__attribute__((packed));
 
+#ifdef TARGET_ARM
+struct target_eabi_flock64 {
+       short  l_type;
+       short  l_whence;
+        int __pad;
+       unsigned long long l_start;
+       unsigned long long l_len;
+       int  l_pid;
+}__attribute__((packed));
+#endif
 
 /* soundcard defines */
 /* XXX: convert them all to arch indepedent entries */