Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:28

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- x86/Linux-specific kernel interface.         vki-x86-linux.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2000-2017 Julian Seward 
0011       jseward@acm.org
0012 
0013    This program is free software; you can redistribute it and/or
0014    modify it under the terms of the GNU General Public License as
0015    published by the Free Software Foundation; either version 2 of the
0016    License, or (at your option) any later version.
0017 
0018    This program is distributed in the hope that it will be useful, but
0019    WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021    General Public License for more details.
0022 
0023    You should have received a copy of the GNU General Public License
0024    along with this program; if not, see <http://www.gnu.org/licenses/>.
0025 
0026    The GNU General Public License is contained in the file COPYING.
0027 */
0028 
0029 #ifndef __VKI_X86_LINUX_H
0030 #define __VKI_X86_LINUX_H
0031 
0032 // x86 is little-endian.
0033 #define VKI_LITTLE_ENDIAN  1
0034 
0035 //----------------------------------------------------------------------
0036 // From linux-2.6.8.1/include/asm-i386/types.h
0037 //----------------------------------------------------------------------
0038 
0039 typedef unsigned char __vki_u8;
0040 
0041 typedef __signed__ short __vki_s16;
0042 typedef unsigned short __vki_u16;
0043 
0044 typedef __signed__ int __vki_s32;
0045 typedef unsigned int __vki_u32;
0046 
0047 typedef __signed__ long long __vki_s64;
0048 typedef unsigned long long __vki_u64;
0049 
0050 typedef unsigned short vki_u16;
0051 
0052 typedef unsigned int vki_u32;
0053 
0054 //----------------------------------------------------------------------
0055 // From linux-2.6.8.1/include/asm-i386/page.h
0056 //----------------------------------------------------------------------
0057 
0058 /* PAGE_SHIFT determines the page size */
0059 #define VKI_PAGE_SHIFT  12
0060 #define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
0061 #define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
0062 #define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
0063 
0064 //----------------------------------------------------------------------
0065 // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
0066 //----------------------------------------------------------------------
0067 
0068 #define VKI_SHMLBA  VKI_PAGE_SIZE
0069 
0070 //----------------------------------------------------------------------
0071 // From linux-2.6.8.1/include/asm-i386/signal.h
0072 //----------------------------------------------------------------------
0073 
0074 #define VKI_MINSIGSTKSZ 2048
0075 
0076 #define VKI_SIG_BLOCK          0    /* for blocking signals */
0077 #define VKI_SIG_UNBLOCK        1    /* for unblocking signals */
0078 #define VKI_SIG_SETMASK        2    /* for setting the signal mask */
0079 
0080 /* Type of a signal handler.  */
0081 typedef void __vki_signalfn_t(int);
0082 typedef __vki_signalfn_t __user *__vki_sighandler_t;
0083 
0084 typedef void __vki_restorefn_t(void);
0085 typedef __vki_restorefn_t __user *__vki_sigrestore_t;
0086 
0087 #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
0088 #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
0089 
0090 #define _VKI_NSIG   64
0091 #define _VKI_NSIG_BPW   32
0092 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
0093 
0094 typedef unsigned long vki_old_sigset_t;     /* at least 32 bits */
0095 
0096 typedef struct {
0097     unsigned long sig[_VKI_NSIG_WORDS];
0098 } vki_sigset_t;
0099 
0100 #define VKI_SIGHUP       1
0101 #define VKI_SIGINT       2
0102 #define VKI_SIGQUIT      3
0103 #define VKI_SIGILL       4
0104 #define VKI_SIGTRAP      5
0105 #define VKI_SIGABRT      6
0106 //#define VKI_SIGIOT         6
0107 #define VKI_SIGBUS       7
0108 #define VKI_SIGFPE       8
0109 #define VKI_SIGKILL      9
0110 #define VKI_SIGUSR1     10
0111 #define VKI_SIGSEGV     11
0112 #define VKI_SIGUSR2     12
0113 #define VKI_SIGPIPE     13
0114 #define VKI_SIGALRM     14
0115 #define VKI_SIGTERM     15
0116 #define VKI_SIGSTKFLT       16
0117 #define VKI_SIGCHLD     17
0118 #define VKI_SIGCONT     18
0119 #define VKI_SIGSTOP     19
0120 #define VKI_SIGTSTP     20
0121 #define VKI_SIGTTIN     21
0122 #define VKI_SIGTTOU     22
0123 #define VKI_SIGURG      23
0124 #define VKI_SIGXCPU     24
0125 #define VKI_SIGXFSZ     25
0126 #define VKI_SIGVTALRM       26
0127 #define VKI_SIGPROF     27
0128 #define VKI_SIGWINCH        28
0129 #define VKI_SIGIO       29
0130 #define VKI_SIGPWR      30
0131 #define VKI_SIGSYS      31
0132 #define VKI_SIGUNUSED       31
0133 
0134 /* These should not be considered constants from userland.  */
0135 #define VKI_SIGRTMIN    32
0136 // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
0137 #define VKI_SIGRTMAX    _VKI_NSIG
0138 
0139 #define VKI_SA_NOCLDSTOP    0x00000001u
0140 #define VKI_SA_NOCLDWAIT    0x00000002u
0141 #define VKI_SA_SIGINFO      0x00000004u
0142 #define VKI_SA_ONSTACK      0x08000000u
0143 #define VKI_SA_RESTART      0x10000000u
0144 #define VKI_SA_NODEFER      0x40000000u
0145 #define VKI_SA_RESETHAND    0x80000000u
0146 
0147 #define VKI_SA_NOMASK       VKI_SA_NODEFER
0148 #define VKI_SA_ONESHOT      VKI_SA_RESETHAND
0149 //#define VKI_SA_INTERRUPT  0x20000000 /* dummy -- ignored */
0150 
0151 #define VKI_SA_RESTORER     0x04000000
0152 
0153 #define VKI_SS_ONSTACK  1
0154 #define VKI_SS_DISABLE  2
0155 
0156 /* These are 'legacy' sigactions in which the size of sa_mask is fixed
0157    (cannot be expanded at any future point) because it is sandwiched
0158    between two other fields.
0159    (there is identical kludgery in vki-ppc32-linux.h) */
0160 struct vki_old_sigaction {
0161         // [[Nb: a 'k' prefix is added to "sa_handler" because
0162         // bits/sigaction.h (which gets dragged in somehow via signal.h)
0163         // #defines it as something else.  Since that is done for glibc's
0164         // purposes, which we don't care about here, we use our own name.]]
0165         __vki_sighandler_t ksa_handler;
0166         vki_old_sigset_t sa_mask;
0167         unsigned long sa_flags;
0168         __vki_sigrestore_t sa_restorer;
0169 };
0170 
0171 struct vki_sigaction_base {
0172         // [[See comment about extra 'k' above]]
0173     __vki_sighandler_t ksa_handler;
0174     unsigned long sa_flags;
0175     __vki_sigrestore_t sa_restorer;
0176     vki_sigset_t sa_mask;       /* mask last for extensibility */
0177 };
0178 
0179 /* On Linux we use the same type for passing sigactions to
0180    and from the kernel.  Hence: */
0181 typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
0182 typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
0183 
0184 
0185 typedef struct vki_sigaltstack {
0186     void __user *ss_sp;
0187     int ss_flags;
0188     vki_size_t ss_size;
0189 } vki_stack_t;
0190 
0191 //----------------------------------------------------------------------
0192 // From linux-2.6.8.1/include/asm-i386/sigcontext.h
0193 //----------------------------------------------------------------------
0194 
0195 struct _vki_fpreg {
0196     unsigned short significand[4];
0197     unsigned short exponent;
0198 };
0199 
0200 struct _vki_fpxreg {
0201     unsigned short significand[4];
0202     unsigned short exponent;
0203     unsigned short padding[3];
0204 };
0205 
0206 struct _vki_xmmreg {
0207     unsigned long element[4];
0208 };
0209 
0210 struct _vki_fpstate {
0211     /* Regular FPU environment */
0212     unsigned long   cw;
0213     unsigned long   sw;
0214     unsigned long   tag;
0215     unsigned long   ipoff;
0216     unsigned long   cssel;
0217     unsigned long   dataoff;
0218     unsigned long   datasel;
0219     struct _vki_fpreg   _st[8];
0220     unsigned short  status;
0221     unsigned short  magic;      /* 0xffff = regular FPU data only */
0222 
0223     /* FXSR FPU environment */
0224     unsigned long   _fxsr_env[6];   /* FXSR FPU env is ignored */
0225     unsigned long   mxcsr;
0226     unsigned long   reserved;
0227     struct _vki_fpxreg  _fxsr_st[8];    /* FXSR FPU reg data is ignored */
0228     struct _vki_xmmreg  _xmm[8];
0229     unsigned long   padding[56];
0230 };
0231 
0232 struct vki_sigcontext {
0233     unsigned short gs, __gsh;
0234     unsigned short fs, __fsh;
0235     unsigned short es, __esh;
0236     unsigned short ds, __dsh;
0237     unsigned long edi;
0238     unsigned long esi;
0239     unsigned long ebp;
0240     unsigned long esp;
0241     unsigned long ebx;
0242     unsigned long edx;
0243     unsigned long ecx;
0244     unsigned long eax;
0245     unsigned long trapno;
0246     unsigned long err;
0247     unsigned long eip;
0248     unsigned short cs, __csh;
0249     unsigned long eflags;
0250     unsigned long esp_at_signal;
0251     unsigned short ss, __ssh;
0252     struct _vki_fpstate __user * fpstate;
0253     unsigned long oldmask;
0254     unsigned long cr2;
0255 };
0256 
0257 //----------------------------------------------------------------------
0258 // From linux-2.6.8.1/include/asm-i386/mman.h
0259 //----------------------------------------------------------------------
0260 
0261 #define VKI_PROT_NONE   0x0     /* No page permissions */
0262 #define VKI_PROT_READ   0x1     /* page can be read */
0263 #define VKI_PROT_WRITE  0x2     /* page can be written */
0264 #define VKI_PROT_EXEC   0x4     /* page can be executed */
0265 #define VKI_PROT_GROWSDOWN  0x01000000  /* mprotect flag: extend change to start of growsdown vma */
0266 #define VKI_PROT_GROWSUP    0x02000000  /* mprotect flag: extend change to end of growsup vma */
0267 
0268 #define VKI_MAP_SHARED  0x01        /* Share changes */
0269 #define VKI_MAP_PRIVATE 0x02        /* Changes are private */
0270 //#define VKI_MAP_TYPE  0x0f        /* Mask for type of mapping */
0271 #define VKI_MAP_FIXED   0x10        /* Interpret addr exactly */
0272 #define VKI_MAP_ANONYMOUS   0x20    /* don't use a file */
0273 #define VKI_MAP_NORESERVE   0x4000      /* don't check for reservations */
0274 
0275 //----------------------------------------------------------------------
0276 // From linux-2.6.8.1/include/asm-i386/fcntl.h
0277 //----------------------------------------------------------------------
0278 
0279 #define VKI_O_ACCMODE        03
0280 #define VKI_O_RDONLY         00
0281 #define VKI_O_WRONLY         01
0282 #define VKI_O_RDWR       02
0283 #define VKI_O_CREAT    0100 /* not fcntl */
0284 #define VKI_O_EXCL     0200 /* not fcntl */
0285 #define VKI_O_TRUNC   01000 /* not fcntl */
0286 #define VKI_O_APPEND      02000
0287 #define VKI_O_NONBLOCK    04000
0288 #define VKI_O_LARGEFILE 0100000
0289 
0290 #define VKI_AT_FDCWD            -100
0291 
0292 #define VKI_F_DUPFD     0   /* dup */
0293 #define VKI_F_GETFD     1   /* get close_on_exec */
0294 #define VKI_F_SETFD     2   /* set/clear close_on_exec */
0295 #define VKI_F_GETFL     3   /* get file->f_flags */
0296 #define VKI_F_SETFL     4   /* set file->f_flags */
0297 #define VKI_F_GETLK     5
0298 #define VKI_F_SETLK     6
0299 #define VKI_F_SETLKW        7
0300 
0301 #define VKI_F_SETOWN        8   /*  for sockets. */
0302 #define VKI_F_GETOWN        9   /*  for sockets. */
0303 #define VKI_F_SETSIG        10  /*  for sockets. */
0304 #define VKI_F_GETSIG        11  /*  for sockets. */
0305 
0306 #define VKI_F_GETLK64       12  /*  using 'struct flock64' */
0307 #define VKI_F_SETLK64       13
0308 #define VKI_F_SETLKW64      14
0309 
0310 #define VKI_F_SETOWN_EX     15
0311 #define VKI_F_GETOWN_EX     16
0312 
0313 #define VKI_F_OFD_GETLK     36
0314 #define VKI_F_OFD_SETLK     37
0315 #define VKI_F_OFD_SETLKW    38
0316 
0317 #define VKI_F_OWNER_TID     0
0318 #define VKI_F_OWNER_PID     1
0319 #define VKI_F_OWNER_PGRP    2
0320 
0321 struct vki_f_owner_ex {
0322     int type;
0323     __vki_kernel_pid_t  pid;
0324 };
0325 
0326 /* for F_[GET|SET]FL */
0327 #define VKI_FD_CLOEXEC  1   /* actually anything with low bit set goes */
0328 
0329 #define VKI_F_LINUX_SPECIFIC_BASE   1024
0330 
0331 //----------------------------------------------------------------------
0332 // From linux-2.6.8.1/include/asm-i386/resource.h
0333 //----------------------------------------------------------------------
0334 
0335 #define VKI_RLIMIT_DATA     2   /* max data size */
0336 #define VKI_RLIMIT_STACK    3   /* max stack size */
0337 #define VKI_RLIMIT_CORE     4   /* max core file size */
0338 #define VKI_RLIMIT_NOFILE   7   /* max number of open files */
0339 
0340 //----------------------------------------------------------------------
0341 // From linux-2.6.8.1/include/asm-i386/socket.h
0342 //----------------------------------------------------------------------
0343 
0344 #define VKI_SOL_SOCKET  1
0345 
0346 #define VKI_SO_TYPE 3
0347 
0348 #define VKI_SO_ATTACH_FILTER    26
0349 
0350 //----------------------------------------------------------------------
0351 // From linux-2.6.8.1/include/asm-i386/sockios.h
0352 //----------------------------------------------------------------------
0353 
0354 #define VKI_SIOCSPGRP       0x8902
0355 #define VKI_SIOCGPGRP       0x8904
0356 #define VKI_SIOCATMARK      0x8905
0357 #define VKI_SIOCGSTAMP      0x8906      /* Get stamp (timeval) */
0358 #define VKI_SIOCGSTAMPNS    0x8907      /* Get stamp (timespec) */
0359 
0360 //----------------------------------------------------------------------
0361 // From linux-2.6.8.1/include/asm-i386/stat.h
0362 //----------------------------------------------------------------------
0363 
0364 struct vki_stat {
0365     unsigned long  st_dev;
0366     unsigned long  st_ino;
0367     unsigned short st_mode;
0368     unsigned short st_nlink;
0369     unsigned short st_uid;
0370     unsigned short st_gid;
0371     unsigned long  st_rdev;
0372     unsigned long  st_size;
0373     unsigned long  st_blksize;
0374     unsigned long  st_blocks;
0375     unsigned long  st_atime;
0376     unsigned long  st_atime_nsec;
0377     unsigned long  st_mtime;
0378     unsigned long  st_mtime_nsec;
0379     unsigned long  st_ctime;
0380     unsigned long  st_ctime_nsec;
0381     unsigned long  __unused4;
0382     unsigned long  __unused5;
0383 };
0384 
0385 struct vki_stat64 {
0386     unsigned long long  st_dev;
0387     unsigned char   __pad0[4];
0388 
0389 #define STAT64_HAS_BROKEN_ST_INO    1
0390     unsigned long   __st_ino;
0391 
0392     unsigned int    st_mode;
0393     unsigned int    st_nlink;
0394 
0395     unsigned long   st_uid;
0396     unsigned long   st_gid;
0397 
0398     unsigned long long  st_rdev;
0399     unsigned char   __pad3[4];
0400 
0401     long long   st_size;
0402     unsigned long   st_blksize;
0403 
0404     unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
0405     unsigned long   __pad4;     /* future possible st_blocks high bits */
0406 
0407     unsigned long   st_atime;
0408     unsigned long   st_atime_nsec;
0409 
0410     unsigned long   st_mtime;
0411     unsigned int    st_mtime_nsec;
0412 
0413     unsigned long   st_ctime;
0414     unsigned long   st_ctime_nsec;
0415 
0416     unsigned long long  st_ino;
0417 };
0418 
0419 //----------------------------------------------------------------------
0420 // From linux-2.6.8.1/include/asm-i386/statfs.h
0421 //----------------------------------------------------------------------
0422 
0423 // [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
0424 struct vki_statfs {
0425     __vki_u32 f_type;
0426     __vki_u32 f_bsize;
0427     __vki_u32 f_blocks;
0428     __vki_u32 f_bfree;
0429     __vki_u32 f_bavail;
0430     __vki_u32 f_files;
0431     __vki_u32 f_ffree;
0432     __vki_kernel_fsid_t f_fsid;
0433     __vki_u32 f_namelen;
0434     __vki_u32 f_frsize;
0435     __vki_u32 f_spare[5];
0436 };
0437 
0438 //----------------------------------------------------------------------
0439 // From linux-2.6.8.1/include/asm-i386/termios.h
0440 //----------------------------------------------------------------------
0441 
0442 struct vki_winsize {
0443     unsigned short ws_row;
0444     unsigned short ws_col;
0445     unsigned short ws_xpixel;
0446     unsigned short ws_ypixel;
0447 };
0448 
0449 #define VKI_NCC 8
0450 struct vki_termio {
0451     unsigned short c_iflag;     /* input mode flags */
0452     unsigned short c_oflag;     /* output mode flags */
0453     unsigned short c_cflag;     /* control mode flags */
0454     unsigned short c_lflag;     /* local mode flags */
0455     unsigned char c_line;       /* line discipline */
0456     unsigned char c_cc[VKI_NCC];    /* control characters */
0457 };
0458 
0459 
0460 //----------------------------------------------------------------------
0461 // From linux-2.6.8.1/include/asm-i386/termbits.h
0462 //----------------------------------------------------------------------
0463 
0464 typedef unsigned char   vki_cc_t;
0465 typedef unsigned int    vki_tcflag_t;
0466 
0467 #define VKI_NCCS 19
0468 struct vki_termios {
0469     vki_tcflag_t c_iflag;       /* input mode flags */
0470     vki_tcflag_t c_oflag;       /* output mode flags */
0471     vki_tcflag_t c_cflag;       /* control mode flags */
0472     vki_tcflag_t c_lflag;       /* local mode flags */
0473     vki_cc_t c_line;        /* line discipline */
0474     vki_cc_t c_cc[VKI_NCCS];    /* control characters */
0475 };
0476 
0477 //----------------------------------------------------------------------
0478 // From linux-2.6.8.1/include/asm-i386/ioctl.h
0479 //----------------------------------------------------------------------
0480 
0481 #define _VKI_IOC_NRBITS     8
0482 #define _VKI_IOC_TYPEBITS   8
0483 #define _VKI_IOC_SIZEBITS   14
0484 #define _VKI_IOC_DIRBITS    2
0485 
0486 #define _VKI_IOC_NRMASK     ((1 << _VKI_IOC_NRBITS)-1)
0487 #define _VKI_IOC_TYPEMASK   ((1 << _VKI_IOC_TYPEBITS)-1)
0488 #define _VKI_IOC_SIZEMASK   ((1 << _VKI_IOC_SIZEBITS)-1)
0489 #define _VKI_IOC_DIRMASK    ((1 << _VKI_IOC_DIRBITS)-1)
0490 
0491 #define _VKI_IOC_NRSHIFT    0
0492 #define _VKI_IOC_TYPESHIFT  (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
0493 #define _VKI_IOC_SIZESHIFT  (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
0494 #define _VKI_IOC_DIRSHIFT   (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
0495 
0496 #define _VKI_IOC_NONE   0U
0497 #define _VKI_IOC_WRITE  1U
0498 #define _VKI_IOC_READ   2U
0499 
0500 #define _VKI_IOC(dir,type,nr,size) \
0501     (((dir)  << _VKI_IOC_DIRSHIFT) | \
0502      ((type) << _VKI_IOC_TYPESHIFT) | \
0503      ((nr)   << _VKI_IOC_NRSHIFT) | \
0504      ((size) << _VKI_IOC_SIZESHIFT))
0505 
0506 /* used to create numbers */
0507 #define _VKI_IO(type,nr)    _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
0508 #define _VKI_IOR(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0509 #define _VKI_IOW(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0510 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0511 
0512 /* used to decode ioctl numbers.. */
0513 #define _VKI_IOC_DIR(nr)    (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
0514 #define _VKI_IOC_TYPE(nr)   (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
0515 #define _VKI_IOC_NR(nr)     (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
0516 #define _VKI_IOC_SIZE(nr)   (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
0517 
0518 //----------------------------------------------------------------------
0519 // From linux-2.6.8.1/include/asm-i386/ioctls.h
0520 //----------------------------------------------------------------------
0521 
0522 #define VKI_TCGETS  0x5401
0523 #define VKI_TCSETS  0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
0524 #define VKI_TCSETSW 0x5403
0525 #define VKI_TCSETSF 0x5404
0526 #define VKI_TCGETA  0x5405
0527 #define VKI_TCSETA  0x5406
0528 #define VKI_TCSETAW 0x5407
0529 #define VKI_TCSETAF 0x5408
0530 #define VKI_TCSBRK  0x5409
0531 #define VKI_TCXONC  0x540A
0532 #define VKI_TCFLSH  0x540B
0533 #define VKI_TIOCSCTTY   0x540E
0534 #define VKI_TIOCGPGRP   0x540F
0535 #define VKI_TIOCSPGRP   0x5410
0536 #define VKI_TIOCOUTQ    0x5411
0537 #define VKI_TIOCGWINSZ  0x5413
0538 #define VKI_TIOCSWINSZ  0x5414
0539 #define VKI_TIOCMGET    0x5415
0540 #define VKI_TIOCMBIS    0x5416
0541 #define VKI_TIOCMBIC    0x5417
0542 #define VKI_TIOCMSET    0x5418
0543 #define VKI_FIONREAD    0x541B
0544 #define VKI_TIOCLINUX   0x541C
0545 #define VKI_FIONBIO 0x5421
0546 #define VKI_TIOCNOTTY   0x5422
0547 #define VKI_TCSBRKP 0x5425  /* Needed for POSIX tcsendbreak() */
0548 #define VKI_TIOCGPTN    _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
0549 #define VKI_TIOCSPTLCK  _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
0550 
0551 #define VKI_FIONCLEX    0x5450
0552 #define VKI_FIOCLEX     0x5451
0553 #define VKI_FIOASYNC    0x5452
0554 #define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
0555 
0556 #define VKI_TIOCGICOUNT 0x545D  /* read serial port inline interrupt counts */
0557 
0558 //----------------------------------------------------------------------
0559 // From linux-2.6.8.1/include/asm-i386/poll.h
0560 //----------------------------------------------------------------------
0561 
0562 /* These are specified by iBCS2 */
0563 #define VKI_POLLIN      0x0001
0564 
0565 struct vki_pollfd {
0566     int fd;
0567     short events;
0568     short revents;
0569 };
0570 
0571 //----------------------------------------------------------------------
0572 // From linux-2.6.8.1/include/asm-i386/user.h
0573 //----------------------------------------------------------------------
0574 
0575 struct vki_user_i387_struct {
0576     long    cwd;
0577     long    swd;
0578     long    twd;
0579     long    fip;
0580     long    fcs;
0581     long    foo;
0582     long    fos;
0583     long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
0584 };
0585 
0586 struct vki_user_fxsr_struct {
0587     unsigned short  cwd;
0588     unsigned short  swd;
0589     unsigned short  twd;
0590     unsigned short  fop;
0591     long    fip;
0592     long    fcs;
0593     long    foo;
0594     long    fos;
0595     long    mxcsr;
0596     long    reserved;
0597     long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
0598     long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
0599     long    padding[56];
0600 };
0601 
0602 /*
0603  * This is the old layout of "struct pt_regs", and
0604  * is still the layout used by user mode (the new
0605  * pt_regs doesn't have all registers as the kernel
0606  * doesn't use the extra segment registers)
0607  */
0608 struct vki_user_regs_struct {
0609     long ebx, ecx, edx, esi, edi, ebp, eax;
0610     unsigned short ds, __ds, es, __es;
0611     unsigned short fs, __fs, gs, __gs;
0612     long orig_eax, eip;
0613     unsigned short cs, __cs;
0614     long eflags, esp;
0615     unsigned short ss, __ss;
0616 };
0617 
0618 //----------------------------------------------------------------------
0619 // From linux-2.6.8.1/include/asm-i386/elf.h
0620 //----------------------------------------------------------------------
0621 
0622 typedef unsigned long vki_elf_greg_t;
0623 
0624 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
0625 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
0626 
0627 typedef struct vki_user_i387_struct vki_elf_fpregset_t;
0628 typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t;
0629 
0630 #define VKI_AT_SYSINFO      32
0631 
0632 //----------------------------------------------------------------------
0633 // From linux-2.6.8.1/include/asm-i386/ucontext.h
0634 //----------------------------------------------------------------------
0635 
0636 struct vki_ucontext {
0637     unsigned long       uc_flags;
0638     struct vki_ucontext    *uc_link;
0639     vki_stack_t     uc_stack;
0640     struct vki_sigcontext   uc_mcontext;
0641     vki_sigset_t        uc_sigmask; /* mask last for extensibility */
0642 };
0643 
0644 //----------------------------------------------------------------------
0645 // From linux-2.6.8.1/include/asm-i386/segment.h
0646 //----------------------------------------------------------------------
0647 
0648 #define VKI_GDT_ENTRY_TLS_ENTRIES   3
0649 #define VKI_GDT_ENTRY_TLS_MIN   6
0650 #define VKI_GDT_ENTRY_TLS_MAX   (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
0651 
0652 //----------------------------------------------------------------------
0653 // From linux-2.6.8.1/include/asm-i386/ldt.h
0654 //----------------------------------------------------------------------
0655 
0656 /* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
0657    to confuse and annoy everyone, this is _not_ the same as an
0658    VgLdtEntry and has to be translated into such.  The logic for doing
0659    so, in vg_ldt.c, is copied from the kernel sources.]] */
0660 struct vki_user_desc {
0661     unsigned int  entry_number;
0662     unsigned long base_addr;
0663     unsigned int  limit;
0664     unsigned int  seg_32bit:1;
0665     unsigned int  contents:2;
0666     unsigned int  read_exec_only:1;
0667     unsigned int  limit_in_pages:1;
0668     unsigned int  seg_not_present:1;
0669     unsigned int  useable:1;
0670         // [[Nb: this field is not in the kernel sources, but it has always
0671         // been in the Valgrind sources so I will keep it there in case it's
0672         // important... this is an x86-defined data structure so who
0673         // knows;  maybe it's important to set this field to zero at some
0674         // point.  --njn]]
0675     unsigned int  reserved:25;
0676 };
0677 
0678 // [[Nb: for our convenience within Valgrind, use a more specific name]]
0679 typedef struct vki_user_desc vki_modify_ldt_t;
0680 
0681 //----------------------------------------------------------------------
0682 // From linux-2.6.8.1/include/asm-i386/ipcbuf.h
0683 //----------------------------------------------------------------------
0684 
0685 struct vki_ipc64_perm
0686 {
0687     __vki_kernel_key_t  key;
0688     __vki_kernel_uid32_t    uid;
0689     __vki_kernel_gid32_t    gid;
0690     __vki_kernel_uid32_t    cuid;
0691     __vki_kernel_gid32_t    cgid;
0692     __vki_kernel_mode_t mode;
0693     unsigned short      __pad1;
0694     unsigned short      seq;
0695     unsigned short      __pad2;
0696     unsigned long       __unused1;
0697     unsigned long       __unused2;
0698 };
0699 
0700 //----------------------------------------------------------------------
0701 // From linux-2.6.8.1/include/asm-i386/sembuf.h
0702 //----------------------------------------------------------------------
0703 
0704 struct vki_semid64_ds {
0705     struct vki_ipc64_perm sem_perm;     /* permissions .. see ipc.h */
0706     __vki_kernel_time_t sem_otime;      /* last semop time */
0707     unsigned long   __unused1;
0708     __vki_kernel_time_t sem_ctime;      /* last change time */
0709     unsigned long   __unused2;
0710     unsigned long   sem_nsems;      /* no. of semaphores in array */
0711     unsigned long   __unused3;
0712     unsigned long   __unused4;
0713 };
0714 
0715 //----------------------------------------------------------------------
0716 // From linux-2.6.8.1/include/asm-i386/msgbuf.h
0717 //----------------------------------------------------------------------
0718 
0719 struct vki_msqid64_ds {
0720     struct vki_ipc64_perm msg_perm;
0721     __vki_kernel_time_t msg_stime;  /* last msgsnd time */
0722     unsigned long   __unused1;
0723     __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
0724     unsigned long   __unused2;
0725     __vki_kernel_time_t msg_ctime;  /* last change time */
0726     unsigned long   __unused3;
0727     unsigned long  msg_cbytes;  /* current number of bytes on queue */
0728     unsigned long  msg_qnum;    /* number of messages in queue */
0729     unsigned long  msg_qbytes;  /* max number of bytes on queue */
0730     __vki_kernel_pid_t msg_lspid;   /* pid of last msgsnd */
0731     __vki_kernel_pid_t msg_lrpid;   /* last receive pid */
0732     unsigned long  __unused4;
0733     unsigned long  __unused5;
0734 };
0735 
0736 //----------------------------------------------------------------------
0737 // From linux-2.6.8.1/include/asm-i386/ipc.h
0738 //----------------------------------------------------------------------
0739 
0740 struct vki_ipc_kludge {
0741     struct vki_msgbuf __user *msgp;
0742     long msgtyp;
0743 };
0744 
0745 #define VKI_SEMOP        1
0746 #define VKI_SEMGET       2
0747 #define VKI_SEMCTL       3
0748 #define VKI_SEMTIMEDOP       4
0749 #define VKI_MSGSND      11
0750 #define VKI_MSGRCV      12
0751 #define VKI_MSGGET      13
0752 #define VKI_MSGCTL      14
0753 #define VKI_SHMAT       21
0754 #define VKI_SHMDT       22
0755 #define VKI_SHMGET      23
0756 #define VKI_SHMCTL      24
0757 
0758 
0759 //----------------------------------------------------------------------
0760 // From linux-2.6.8.1/include/asm-i386/shmbuf.h
0761 //----------------------------------------------------------------------
0762 
0763 struct vki_shmid64_ds {
0764     struct vki_ipc64_perm   shm_perm;   /* operation perms */
0765     vki_size_t      shm_segsz;  /* size of segment (bytes) */
0766     __vki_kernel_time_t shm_atime;  /* last attach time */
0767     unsigned long       __unused1;
0768     __vki_kernel_time_t shm_dtime;  /* last detach time */
0769     unsigned long       __unused2;
0770     __vki_kernel_time_t shm_ctime;  /* last change time */
0771     unsigned long       __unused3;
0772     __vki_kernel_pid_t  shm_cpid;   /* pid of creator */
0773     __vki_kernel_pid_t  shm_lpid;   /* pid of last operator */
0774     unsigned long       shm_nattch; /* no. of current attaches */
0775     unsigned long       __unused4;
0776     unsigned long       __unused5;
0777 };
0778 
0779 struct vki_shminfo64 {
0780     unsigned long   shmmax;
0781     unsigned long   shmmin;
0782     unsigned long   shmmni;
0783     unsigned long   shmseg;
0784     unsigned long   shmall;
0785     unsigned long   __unused1;
0786     unsigned long   __unused2;
0787     unsigned long   __unused3;
0788     unsigned long   __unused4;
0789 };
0790 
0791 //----------------------------------------------------------------------
0792 // DRM ioctls
0793 //----------------------------------------------------------------------
0794 
0795 // jrs 20050207: where did all this stuff come from?  Is it really
0796 // i386 specific, or should it go into the linux-generic category?
0797 //struct vki_drm_buf_pub {
0798 //  Int       idx;         /**< Index into the master buffer list */
0799 //  Int       total;       /**< Buffer size */
0800 //  Int       used;        /**< Amount of buffer in use (for DMA) */
0801 //  void      __user *address;     /**< Address of buffer */
0802 //};
0803 //
0804 //struct vki_drm_buf_map {
0805 //  Int       count;        /**< Length of the buffer list */
0806 //  void          __user *virtual;  /**< Mmap'd area in user-virtual */
0807 //  struct vki_drm_buf_pub __user *list;    /**< Buffer information */
0808 //};
0809 //
0810 ///* We need to pay attention to this, because it mmaps memory */
0811 //#define VKI_DRM_IOCTL_MAP_BUFS        _VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
0812 
0813 //----------------------------------------------------------------------
0814 // From linux-2.6.9/include/asm-i386/ptrace.h
0815 //----------------------------------------------------------------------
0816 
0817 #define VKI_PTRACE_GETREGS            12
0818 #define VKI_PTRACE_SETREGS            13
0819 #define VKI_PTRACE_GETFPREGS          14
0820 #define VKI_PTRACE_SETFPREGS          15
0821 #define VKI_PTRACE_GETFPXREGS         18
0822 #define VKI_PTRACE_SETFPXREGS         19
0823 #define VKI_PTRACE_GET_THREAD_AREA    25
0824 #define VKI_PTRACE_SET_THREAD_AREA    26
0825 
0826 //----------------------------------------------------------------------
0827 // From linux-2.6.15.4/include/asm-i386/vm86.h
0828 //----------------------------------------------------------------------
0829 
0830 #define VKI_VM86_PLUS_INSTALL_CHECK 0
0831 #define VKI_VM86_ENTER          1
0832 #define VKI_VM86_ENTER_NO_BYPASS    2
0833 #define VKI_VM86_REQUEST_IRQ        3
0834 #define VKI_VM86_FREE_IRQ       4
0835 #define VKI_VM86_GET_IRQ_BITS       5
0836 #define VKI_VM86_GET_AND_RESET_IRQ  6
0837 
0838 struct vki_vm86_regs {
0839 /*
0840  * normal regs, with special meaning for the segment descriptors..
0841  */
0842     long ebx;
0843     long ecx;
0844     long edx;
0845     long esi;
0846     long edi;
0847     long ebp;
0848     long eax;
0849     long __null_ds;
0850     long __null_es;
0851     long __null_fs;
0852     long __null_gs;
0853     long orig_eax;
0854     long eip;
0855     unsigned short cs, __csh;
0856     long eflags;
0857     long esp;
0858     unsigned short ss, __ssh;
0859 /*
0860  * these are specific to v86 mode:
0861  */
0862     unsigned short es, __esh;
0863     unsigned short ds, __dsh;
0864     unsigned short fs, __fsh;
0865     unsigned short gs, __gsh;
0866 };
0867 
0868 struct vki_revectored_struct {
0869     unsigned long __map[8];         /* 256 bits */
0870 };
0871 
0872 struct vki_vm86_struct {
0873     struct vki_vm86_regs regs;
0874     unsigned long flags;
0875     unsigned long screen_bitmap;
0876     unsigned long cpu_type;
0877     struct vki_revectored_struct int_revectored;
0878     struct vki_revectored_struct int21_revectored;
0879 };
0880 
0881 struct vki_vm86plus_info_struct {
0882     unsigned long force_return_for_pic:1;
0883     unsigned long vm86dbg_active:1;       /* for debugger */
0884     unsigned long vm86dbg_TFpendig:1;     /* for debugger */
0885     unsigned long unused:28;
0886     unsigned long is_vm86pus:1;       /* for vm86 internal use */
0887     unsigned char vm86dbg_intxxtab[32];   /* for debugger */
0888 };
0889 
0890 struct vki_vm86plus_struct {
0891     struct vki_vm86_regs regs;
0892     unsigned long flags;
0893     unsigned long screen_bitmap;
0894     unsigned long cpu_type;
0895     struct vki_revectored_struct int_revectored;
0896     struct vki_revectored_struct int21_revectored;
0897     struct vki_vm86plus_info_struct vm86plus;
0898 };
0899 
0900 //----------------------------------------------------------------------
0901 // From linux-2.6.8.1/include/asm-generic/errno.h
0902 //----------------------------------------------------------------------
0903 
0904 #define VKI_ENOSYS       38  /* Function not implemented */
0905 #define VKI_EOVERFLOW    75  /* Value too large for defined data type */
0906 
0907 //----------------------------------------------------------------------
0908 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
0909 //----------------------------------------------------------------------
0910 
0911 #define VKI_TIOCGSERIAL     0x541E
0912 #define VKI_TIOCSSERIAL     0x541F
0913 
0914 //----------------------------------------------------------------------
0915 // And that's it!
0916 //----------------------------------------------------------------------
0917 
0918 #endif // __VKI_X86_LINUX_H
0919 
0920 /*--------------------------------------------------------------------*/
0921 /*--- end                                                          ---*/
0922 /*--------------------------------------------------------------------*/