separated helpers from micro operations
[qemu] / syscall-i386.h
index 312edc6..178b638 100644 (file)
 #define TARGET_NR_removexattr  235
 #define TARGET_NR_lremovexattr 236
 #define TARGET_NR_fremovexattr 237
+#define TARGET_NR_tkill                238
+#define TARGET_NR_sendfile64           239
+#define TARGET_NR_futex                240
+#define TARGET_NR_sched_setaffinity    241
+#define TARGET_NR_sched_getaffinity    242
+#define TARGET_NR_set_thread_area      243
+#define TARGET_NR_get_thread_area      244
+#define TARGET_NR_io_setup             245
+#define TARGET_NR_io_destroy           246
+#define TARGET_NR_io_getevents 247
+#define TARGET_NR_io_submit            248
+#define TARGET_NR_io_cancel            249
+#define TARGET_NR_fadvise64            250
+
+#define TARGET_NR_exit_group           252
+#define TARGET_NR_lookup_dcookie       253
+#define TARGET_NR_epoll_create 254
+#define TARGET_NR_epoll_ctl            255
+#define TARGET_NR_epoll_wait           256
+#define TARGET_NR_remap_file_pages     257
+#define TARGET_NR_set_tid_address      258
+#define TARGET_NR_timer_create 259
+#define TARGET_NR_timer_settime        (TARGET_NR_timer_create+1)
+#define TARGET_NR_timer_gettime        (TARGET_NR_timer_create+2)
+#define TARGET_NR_timer_getoverrun     (TARGET_NR_timer_create+3)
+#define TARGET_NR_timer_delete (TARGET_NR_timer_create+4)
+#define TARGET_NR_clock_settime        (TARGET_NR_timer_create+5)
+#define TARGET_NR_clock_gettime        (TARGET_NR_timer_create+6)
+#define TARGET_NR_clock_getres (TARGET_NR_timer_create+7)
+#define TARGET_NR_clock_nanosleep      (TARGET_NR_timer_create+8)
 
 #define TARGET_SIG_BLOCK          0    /* for blocking signals */
 #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
 struct target_stat {
        unsigned short st_dev;
        unsigned short __pad1;
-       unsigned long st_ino;
+       target_ulong st_ino;
        unsigned short st_mode;
        unsigned short st_nlink;
        unsigned short st_uid;
        unsigned short st_gid;
        unsigned short st_rdev;
        unsigned short __pad2;
-       unsigned long  st_size;
-       unsigned long  st_blksize;
-       unsigned long  st_blocks;
-       unsigned long  st_atime;
-       unsigned long  __unused1;
-       unsigned long  st_mtime;
-       unsigned long  __unused2;
-       unsigned long  st_ctime;
-       unsigned long  __unused3;
-       unsigned long  __unused4;
-       unsigned long  __unused5;
+       target_ulong  st_size;
+       target_ulong  st_blksize;
+       target_ulong  st_blocks;
+       target_ulong  target_st_atime;
+       target_ulong  __unused1;
+       target_ulong  target_st_mtime;
+       target_ulong  __unused2;
+       target_ulong  target_st_ctime;
+       target_ulong  __unused3;
+       target_ulong  __unused4;
+       target_ulong  __unused5;
 };
 
 /* This matches struct stat64 in glibc2.1, hence the absolutely
@@ -272,55 +302,94 @@ struct target_stat64 {
        unsigned short  st_dev;
        unsigned char   __pad0[10];
 
-#define STAT64_HAS_BROKEN_ST_INO       1
-       unsigned long   __st_ino;
+#define TARGET_STAT64_HAS_BROKEN_ST_INO        1
+       target_ulong    __st_ino;
 
        unsigned int    st_mode;
        unsigned int    st_nlink;
 
-       unsigned long   st_uid;
-       unsigned long   st_gid;
+       target_ulong    st_uid;
+       target_ulong    st_gid;
 
        unsigned short  st_rdev;
        unsigned char   __pad3[10];
 
        long long       st_size;
-       unsigned long   st_blksize;
+       target_ulong    st_blksize;
 
-       unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
-       unsigned long   __pad4;         /* future possible st_blocks high bits */
+       target_ulong    st_blocks;      /* Number 512-byte blocks allocated. */
+       target_ulong    __pad4;         /* future possible st_blocks high bits */
 
-       unsigned long   st_atime;
-       unsigned long   __pad5;
+       target_ulong    target_st_atime;
+       target_ulong    __pad5;
 
-       unsigned long   st_mtime;
-       unsigned long   __pad6;
+       target_ulong    target_st_mtime;
+       target_ulong    __pad6;
 
-       unsigned long   st_ctime;
-       unsigned long   __pad7;         /* will be high 32 bits of ctime someday */
+       target_ulong    target_st_ctime;
+       target_ulong    __pad7;         /* will be high 32 bits of ctime someday */
 
        unsigned long long      st_ino;
-};
+} __attribute__((packed));
+
+#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
 
-typedef unsigned long old_sigset_t;            /* at least 32 bits */
+#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
+#define TARGET_SIGRTMIN         32
 
 struct target_old_sigaction {
         target_ulong _sa_handler;
         target_ulong sa_mask;
         target_ulong sa_flags;
-        void (*sa_restorer)(void);
+        target_ulong sa_restorer;
 };
 
 struct target_sigaction {
         target_ulong _sa_handler;
-        target_sigset_t sa_mask;
         target_ulong sa_flags;
         target_ulong sa_restorer;
+        target_sigset_t sa_mask;
 };
 
 typedef union target_sigval {
        int sival_int;
-       void *sival_ptr;
+        target_ulong sival_ptr;
 } target_sigval_t;
 
 #define TARGET_SI_MAX_SIZE     128
@@ -350,7 +419,7 @@ typedef struct target_siginfo {
                struct {
                        pid_t _pid;             /* sender's pid */
                        uid_t _uid;             /* sender's uid */
-                       sigval_t _sigval;
+                       target_sigval_t _sigval;
                } _rt;
 
                /* SIGCHLD */
@@ -358,13 +427,13 @@ typedef struct target_siginfo {
                        pid_t _pid;             /* which child */
                        uid_t _uid;             /* sender's uid */
                        int _status;            /* exit code */
-                       clock_t _utime;
-                       clock_t _stime;
+                       target_clock_t _utime;
+                        target_clock_t _stime;
                } _sigchld;
 
                /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
                struct {
-                       void *_addr; /* faulting insn/memory ref. */
+                       target_ulong _addr; /* faulting insn/memory ref. */
                } _sigfault;
 
                /* SIGPOLL */
@@ -375,6 +444,70 @@ typedef struct target_siginfo {
        } _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
+ */
+#define TARGET_ILL_ILLOPN      (2)     /* illegal operand */
+
+/*
+ * 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 */
+
+/*
+ * SIGTRAP si_codes
+ */
+#define TARGET_TRAP_BRKPT      (1)     /* process breakpoint */
+#define TARGET_TRAP_TRACE      (2)     /* process trace trap */
+
+/* default linux values for the selectors */
+#define __USER_CS      (0x23)
+#define __USER_DS      (0x2B)
+
+struct target_pt_regs {
+       long ebx;
+       long ecx;
+       long edx;
+       long esi;
+       long edi;
+       long ebp;
+       long eax;
+       int  xds;
+       int  xes;
+       long orig_eax;
+       long eip;
+       int  xcs;
+       long eflags;
+       long esp;
+       int  xss;
+};
+
 /* ioctls */
 
 /*
@@ -463,8 +596,8 @@ typedef struct target_siginfo {
 #define TARGET_TIOCSBRK        0x5427  /* BSD compatibility */
 #define TARGET_TIOCCBRK        0x5428  /* BSD compatibility */
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
-#define TARGET_TIOCGPTN        _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
-#define TARGET_TIOCSPTLCK      _IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
@@ -632,6 +765,242 @@ struct target_termios {
 #define TARGET_VLNEXT  15
 #define TARGET_VEOL2   16
 
+#define TARGET_LDT_ENTRIES      8192
+#define TARGET_LDT_ENTRY_SIZE  8
+
+#define TARGET_GDT_ENTRY_TLS_ENTRIES   3
+#define TARGET_GDT_ENTRY_TLS_MIN       6
+#define TARGET_GDT_ENTRY_TLS_MAX       (TARGET_GDT_ENTRY_TLS_MIN + TARGET_GDT_ENTRY_TLS_ENTRIES - 1)
+
+struct target_modify_ldt_ldt_s {
+    unsigned int  entry_number;
+    target_ulong base_addr;
+    unsigned int limit;
+    unsigned int flags;
+};
+
+
+/* vm86 defines */
+
+#define TARGET_BIOSSEG         0x0f000
+
+#define TARGET_CPU_086         0
+#define TARGET_CPU_186         1
+#define TARGET_CPU_286         2
+#define TARGET_CPU_386         3
+#define TARGET_CPU_486         4
+#define TARGET_CPU_586         5
+
+#define TARGET_VM86_SIGNAL     0       /* return due to signal */
+#define TARGET_VM86_UNKNOWN    1       /* unhandled GP fault - IO-instruction or similar */
+#define TARGET_VM86_INTx       2       /* int3/int x instruction (ARG = x) */
+#define TARGET_VM86_STI        3       /* sti/popf/iret instruction enabled virtual interrupts */
+
+/*
+ * Additional return values when invoking new vm86()
+ */
+#define TARGET_VM86_PICRETURN  4       /* return due to pending PIC request */
+#define TARGET_VM86_TRAP       6       /* return due to DOS-debugger request */
+
+/*
+ * function codes when invoking new vm86()
+ */
+#define TARGET_VM86_PLUS_INSTALL_CHECK 0
+#define TARGET_VM86_ENTER              1
+#define TARGET_VM86_ENTER_NO_BYPASS    2
+#define        TARGET_VM86_REQUEST_IRQ 3
+#define TARGET_VM86_FREE_IRQ           4
+#define TARGET_VM86_GET_IRQ_BITS       5
+#define TARGET_VM86_GET_AND_RESET_IRQ  6
+
+/*
+ * This is the stack-layout seen by the user space program when we have
+ * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout
+ * is 'kernel_vm86_regs' (see below).
+ */
+
+struct target_vm86_regs {
+/*
+ * normal regs, with special meaning for the segment descriptors..
+ */
+       target_long ebx;
+       target_long ecx;
+       target_long edx;
+       target_long esi;
+       target_long edi;
+       target_long ebp;
+       target_long eax;
+       target_long __null_ds;
+       target_long __null_es;
+       target_long __null_fs;
+       target_long __null_gs;
+       target_long orig_eax;
+       target_long eip;
+       unsigned short cs, __csh;
+       target_long eflags;
+       target_long esp;
+       unsigned short ss, __ssh;
+/*
+ * these are specific to v86 mode:
+ */
+       unsigned short es, __esh;
+       unsigned short ds, __dsh;
+       unsigned short fs, __fsh;
+       unsigned short gs, __gsh;
+};
+
+struct target_revectored_struct {
+       target_ulong __map[8];                  /* 256 bits */
+};
+
+struct target_vm86_struct {
+       struct target_vm86_regs regs;
+       target_ulong flags;
+       target_ulong screen_bitmap;
+       target_ulong cpu_type;
+       struct target_revectored_struct int_revectored;
+       struct target_revectored_struct int21_revectored;
+};
+
+/*
+ * flags masks
+ */
+#define TARGET_VM86_SCREEN_BITMAP      0x0001
+
+struct target_vm86plus_info_struct {
+        target_ulong flags;
+#define TARGET_force_return_for_pic (1 << 0)
+#define TARGET_vm86dbg_active       (1 << 1)  /* for debugger */
+#define TARGET_vm86dbg_TFpendig     (1 << 2)  /* for debugger */
+#define TARGET_is_vm86pus           (1 << 31) /* for vm86 internal use */
+       unsigned char vm86dbg_intxxtab[32];   /* for debugger */
+};
+
+struct target_vm86plus_struct {
+       struct target_vm86_regs regs;
+       target_ulong flags;
+       target_ulong screen_bitmap;
+       target_ulong cpu_type;
+       struct target_revectored_struct int_revectored;
+       struct target_revectored_struct int21_revectored;
+       struct target_vm86plus_info_struct vm86plus;
+};
+
+/* ipcs */
+
+#define TARGET_SEMOP           1
+#define TARGET_SEMGET          2
+#define TARGET_SEMCTL          3 
+#define TARGET_MSGSND          11 
+#define TARGET_MSGRCV          12
+#define TARGET_MSGGET          13
+#define TARGET_MSGCTL          14
+#define TARGET_SHMAT           21
+#define TARGET_SHMDT           22
+#define TARGET_SHMGET          23
+#define TARGET_SHMCTL          24
+
+struct target_msgbuf {
+       int mtype;
+       char mtext[1];
+};
+
+struct target_ipc_kludge {
+       unsigned int    msgp;   /* Really (struct msgbuf *) */
+       int msgtyp;
+};     
+
+struct alpha_msgbuf {
+       long    mtype;
+       char    mtext[4096];
+};
+
+struct target_ipc_perm {
+       int     key;
+       unsigned short  uid;
+       unsigned short  gid;
+       unsigned short  cuid;
+       unsigned short  cgid;
+       unsigned short  mode;
+       unsigned short  seq;
+};
+
+struct target_msqid_ds {
+       struct target_ipc_perm  msg_perm;
+       unsigned int            msg_first;      /* really struct target_msg* */
+       unsigned int            msg_last;       /* really struct target_msg* */
+       unsigned int            msg_stime;      /* really target_time_t */
+       unsigned int            msg_rtime;      /* really target_time_t */
+       unsigned int            msg_ctime;      /* really target_time_t */
+       unsigned int            wwait;          /* really struct wait_queue* */
+       unsigned int            rwait;          /* really struct wait_queue* */
+       unsigned short          msg_cbytes;
+       unsigned short          msg_qnum;
+       unsigned short          msg_qbytes;
+       unsigned short          msg_lspid;
+       unsigned short          msg_lrpid;
+};
+
+struct target_shmid_ds {
+       struct target_ipc_perm  shm_perm;
+       int                     shm_segsz;
+       unsigned int            shm_atime;      /* really target_time_t */
+       unsigned int            shm_dtime;      /* really target_time_t */
+       unsigned int            shm_ctime;      /* really target_time_t */
+       unsigned short          shm_cpid;
+       unsigned short          shm_lpid;
+       short                   shm_nattch;
+       unsigned short          shm_npages;
+       unsigned long           *shm_pages;
+       void                    *attaches;      /* really struct shm_desc * */
+};
+
+#define TARGET_IPC_RMID        0
+#define TARGET_IPC_SET 1
+#define TARGET_IPC_STAT        2
+
+union target_semun {
+    int val;
+    unsigned int buf;  /* really struct semid_ds * */
+    unsigned int array; /* really unsigned short * */
+    unsigned int __buf;        /* really struct seminfo * */
+    unsigned int __pad;        /* really void* */
+};
+
+#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 */
+#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. */
+#define TARGET_F_SETSIG        10      /*  for sockets. */
+#define TARGET_F_GETSIG        11      /*  for sockets. */
+
+#define TARGET_F_GETLK64       12      /*  using 'struct flock64' */
+#define TARGET_F_SETLK64       13
+#define TARGET_F_SETLKW64      14
+
+struct target_flock {
+       short l_type;
+       short l_whence;
+       target_ulong l_start;
+       target_ulong l_len;
+       int l_pid;
+};
+
+struct target_flock64 {
+       short  l_type;
+       short  l_whence;
+       unsigned long long l_start;
+       unsigned long long l_len;
+       int  l_pid;
+};
+
 /* soundcard defines (XXX: move them to generic file syscall_defs.h) */
 
 #define TARGET_SNDCTL_COPR_HALT           0xc0144307
@@ -758,3 +1127,8 @@ struct target_termios {
 #define TARGET_SOUND_MIXER_WRITE_ENHANCE  0xc0044d1f
 #define TARGET_SOUND_MIXER_WRITE_LOUD     0xc0044d1f
 #define TARGET_SOUND_MIXER_WRITE_RECSRC   0xc0044dff
+
+#define TARGET_VFAT_IOCTL_READDIR_BOTH    0x82187201
+#define TARGET_VFAT_IOCTL_READDIR_SHORT   0x82187202
+
+#define TARGET_SIOCATMARK      0x8905