Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:25:25

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- AMD64/Linux-specific kernel interface.     vki-amd64-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_AMD64_LINUX_H
0030 #define __VKI_AMD64_LINUX_H
0031 
0032 // AMD64 is little-endian.
0033 #define VKI_LITTLE_ENDIAN  1
0034 
0035 //----------------------------------------------------------------------
0036 // From linux-2.6.9/include/asm-x86_64/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.9/include/asm-x86_64/page.h
0056 //----------------------------------------------------------------------
0057 
0058 #define VKI_PAGE_SHIFT  12
0059 #define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
0060 #define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
0061 #define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
0062 
0063 //----------------------------------------------------------------------
0064 // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
0065 //----------------------------------------------------------------------
0066 
0067 #define VKI_SHMLBA  VKI_PAGE_SIZE
0068 
0069 //----------------------------------------------------------------------
0070 // From linux-2.6.9/include/asm-x86_64/signal.h
0071 //----------------------------------------------------------------------
0072 
0073 #define _VKI_NSIG   64
0074 #define _VKI_NSIG_BPW   64
0075 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
0076 
0077 typedef unsigned long vki_old_sigset_t;     /* at least 32 bits */
0078 
0079 typedef struct {
0080     unsigned long sig[_VKI_NSIG_WORDS];
0081 } vki_sigset_t;
0082 
0083 #define VKI_SIGHUP       1
0084 #define VKI_SIGINT       2
0085 #define VKI_SIGQUIT      3
0086 #define VKI_SIGILL       4
0087 #define VKI_SIGTRAP      5
0088 #define VKI_SIGABRT      6
0089 #define VKI_SIGBUS       7
0090 #define VKI_SIGFPE       8
0091 #define VKI_SIGKILL      9
0092 #define VKI_SIGUSR1     10
0093 #define VKI_SIGSEGV     11
0094 #define VKI_SIGUSR2     12
0095 #define VKI_SIGPIPE     13
0096 #define VKI_SIGALRM     14
0097 #define VKI_SIGTERM     15
0098 #define VKI_SIGSTKFLT       16
0099 #define VKI_SIGCHLD     17
0100 #define VKI_SIGCONT     18
0101 #define VKI_SIGSTOP     19
0102 #define VKI_SIGTSTP     20
0103 #define VKI_SIGTTIN     21
0104 #define VKI_SIGTTOU     22
0105 #define VKI_SIGURG      23
0106 #define VKI_SIGXCPU     24
0107 #define VKI_SIGXFSZ     25
0108 #define VKI_SIGVTALRM       26
0109 #define VKI_SIGPROF     27
0110 #define VKI_SIGWINCH        28
0111 #define VKI_SIGIO       29
0112 #define VKI_SIGPWR      30
0113 #define VKI_SIGSYS      31
0114 #define VKI_SIGUNUSED       31
0115 
0116 #define VKI_SIGRTMIN        32
0117 #define VKI_SIGRTMAX        _VKI_NSIG
0118 
0119 #define VKI_SA_NOCLDSTOP    0x00000001
0120 #define VKI_SA_NOCLDWAIT    0x00000002
0121 #define VKI_SA_SIGINFO      0x00000004
0122 #define VKI_SA_ONSTACK      0x08000000
0123 #define VKI_SA_RESTART      0x10000000
0124 #define VKI_SA_NODEFER      0x40000000
0125 #define VKI_SA_RESETHAND    0x80000000
0126 
0127 #define VKI_SA_NOMASK   VKI_SA_NODEFER
0128 #define VKI_SA_ONESHOT  VKI_SA_RESETHAND
0129 
0130 #define VKI_SA_RESTORER 0x04000000
0131 
0132 #define VKI_SS_ONSTACK  1
0133 #define VKI_SS_DISABLE  2
0134 
0135 #define VKI_MINSIGSTKSZ 2048
0136 
0137 #define VKI_SIG_BLOCK          0    /* for blocking signals */
0138 #define VKI_SIG_UNBLOCK        1    /* for unblocking signals */
0139 #define VKI_SIG_SETMASK        2    /* for setting the signal mask */
0140 
0141 typedef void __vki_signalfn_t(int);
0142 typedef __vki_signalfn_t __user *__vki_sighandler_t;
0143 
0144 typedef void __vki_restorefn_t(void);
0145 typedef __vki_restorefn_t __user *__vki_sigrestore_t;
0146 
0147 #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
0148 #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
0149 
0150 struct vki_sigaction_base {
0151         // [[Nb: a 'k' prefix is added to "sa_handler" because
0152         // bits/sigaction.h (which gets dragged in somehow via signal.h)
0153         // #defines it as something else.  Since that is done for glibc's
0154         // purposes, which we don't care about here, we use our own name.]]
0155     __vki_sighandler_t ksa_handler;
0156     unsigned long sa_flags;
0157     __vki_sigrestore_t sa_restorer;
0158     vki_sigset_t sa_mask;       /* mask last for extensibility */
0159 };
0160 
0161 /* On Linux we use the same type for passing sigactions to
0162    and from the kernel.  Hence: */
0163 typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
0164 typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
0165 
0166 
0167 typedef struct vki_sigaltstack {
0168     void __user *ss_sp;
0169     int ss_flags;
0170     vki_size_t ss_size;
0171 } vki_stack_t;
0172 
0173 //----------------------------------------------------------------------
0174 // From linux-2.6.9/include/asm-x86_64/sigcontext.h
0175 //----------------------------------------------------------------------
0176 
0177 struct _vki_fpstate {
0178     __vki_u16   cwd;
0179     __vki_u16   swd;
0180     __vki_u16   twd;    /* Note this is not the same as the 32bit/x87/FSAVE twd */
0181     __vki_u16   fop;
0182     __vki_u64   rip;
0183     __vki_u64   rdp; 
0184     __vki_u32   mxcsr;
0185     __vki_u32   mxcsr_mask;
0186     __vki_u32   st_space[32];   /* 8*16 bytes for each FP-reg */
0187     __vki_u32   xmm_space[64];  /* 16*16 bytes for each XMM-reg  */
0188     __vki_u32   reserved2[24];
0189 };
0190 
0191 struct vki_sigcontext { 
0192     unsigned long r8;
0193     unsigned long r9;
0194     unsigned long r10;
0195     unsigned long r11;
0196     unsigned long r12;
0197     unsigned long r13;
0198     unsigned long r14;
0199     unsigned long r15;
0200     unsigned long rdi;
0201     unsigned long rsi;
0202     unsigned long rbp;
0203     unsigned long rbx;
0204     unsigned long rdx;
0205     unsigned long rax;
0206     unsigned long rcx;
0207     unsigned long rsp;
0208     unsigned long rip;
0209     unsigned long eflags;       /* RFLAGS */
0210     unsigned short cs;
0211     unsigned short gs;
0212     unsigned short fs;
0213     unsigned short __pad0; 
0214     unsigned long err;
0215     unsigned long trapno;
0216     unsigned long oldmask;
0217     unsigned long cr2;
0218     struct _vki_fpstate __user *fpstate;    /* zero when no FPU context */
0219     unsigned long reserved1[8];
0220 };
0221 
0222 //----------------------------------------------------------------------
0223 // From linux-2.6.9/include/asm-x86_64/mman.h
0224 //----------------------------------------------------------------------
0225 
0226 #define VKI_PROT_READ   0x1     /* page can be read */
0227 #define VKI_PROT_WRITE  0x2     /* page can be written */
0228 #define VKI_PROT_EXEC   0x4     /* page can be executed */
0229 #define VKI_PROT_NONE   0x0     /* page can not be accessed */
0230 #define VKI_PROT_GROWSDOWN  0x01000000  /* mprotect flag: extend change to start of growsdown vma */
0231 #define VKI_PROT_GROWSUP    0x02000000  /* mprotect flag: extend change to end of growsup vma */
0232 
0233 #define VKI_MAP_SHARED  0x01        /* Share changes */
0234 #define VKI_MAP_PRIVATE 0x02        /* Changes are private */
0235 #define VKI_MAP_FIXED   0x10        /* Interpret addr exactly */
0236 #define VKI_MAP_ANONYMOUS   0x20    /* don't use a file */
0237 #define VKI_MAP_32BIT   0x40        /* only give out 32bit addresses */
0238 #define VKI_MAP_NORESERVE       0x4000  /* don't check for reservations */
0239 
0240 //----------------------------------------------------------------------
0241 // From linux-2.6.9/include/asm-x86_64/fcntl.h
0242 //----------------------------------------------------------------------
0243 
0244 #define VKI_O_ACCMODE        03
0245 #define VKI_O_RDONLY         00
0246 #define VKI_O_WRONLY         01
0247 #define VKI_O_RDWR       02
0248 #define VKI_O_CREAT    0100 /* not fcntl */
0249 #define VKI_O_EXCL     0200 /* not fcntl */
0250 #define VKI_O_TRUNC   01000 /* not fcntl */
0251 #define VKI_O_APPEND      02000
0252 #define VKI_O_NONBLOCK    04000
0253 #define VKI_O_LARGEFILE 0100000
0254 
0255 #define VKI_AT_FDCWD            -100
0256 
0257 #define VKI_F_DUPFD     0   /* dup */
0258 #define VKI_F_GETFD     1   /* get close_on_exec */
0259 #define VKI_F_SETFD     2   /* set/clear close_on_exec */
0260 #define VKI_F_GETFL     3   /* get file->f_flags */
0261 #define VKI_F_SETFL     4   /* set file->f_flags */
0262 #define VKI_F_GETLK     5
0263 #define VKI_F_SETLK     6
0264 #define VKI_F_SETLKW        7
0265 
0266 #define VKI_F_SETOWN        8   /*  for sockets. */
0267 #define VKI_F_GETOWN        9   /*  for sockets. */
0268 #define VKI_F_SETSIG        10  /*  for sockets. */
0269 #define VKI_F_GETSIG        11  /*  for sockets. */
0270 
0271 #define VKI_F_SETOWN_EX     15
0272 #define VKI_F_GETOWN_EX     16
0273 
0274 #define VKI_F_OFD_GETLK     36
0275 #define VKI_F_OFD_SETLK     37
0276 #define VKI_F_OFD_SETLKW    38
0277 
0278 #define VKI_F_OWNER_TID     0
0279 #define VKI_F_OWNER_PID     1
0280 #define VKI_F_OWNER_PGRP    2
0281 
0282 struct vki_f_owner_ex {
0283     int type;
0284     __vki_kernel_pid_t  pid;
0285 };
0286 
0287 #define VKI_FD_CLOEXEC  1   /* actually anything with low bit set goes */
0288 
0289 #define VKI_F_LINUX_SPECIFIC_BASE   1024
0290 
0291 //----------------------------------------------------------------------
0292 // From linux-2.6.9/include/asm-x86_64/resource.h
0293 //----------------------------------------------------------------------
0294 
0295 #define VKI_RLIMIT_DATA     2   /* max data size */
0296 #define VKI_RLIMIT_STACK    3   /* max stack size */
0297 #define VKI_RLIMIT_CORE     4   /* max core file size */
0298 #define VKI_RLIMIT_NOFILE   7   /* max number of open files */
0299 
0300 //----------------------------------------------------------------------
0301 // From linux-5.0.0/arch/x86/include/uapi/asm/siginfo.h
0302 //----------------------------------------------------------------------
0303 
0304 /* We need that to ensure that sizeof(siginfo) == 128. */
0305 #ifdef __x86_64__
0306 # ifdef __ILP32__
0307 typedef long long __vki_kernel_si_clock_t __attribute__((aligned(4)));
0308 #  define __VKI_ARCH_SI_CLOCK_T             __vki_kernel_si_clock_t
0309 #  define __VKI_ARCH_SI_ATTRIBUTES          __attribute__((aligned(8)))
0310 # else
0311 #  define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
0312 # endif
0313 #endif
0314 
0315 //----------------------------------------------------------------------
0316 // From linux-2.6.9/include/asm-x86_64/socket.h
0317 //----------------------------------------------------------------------
0318 
0319 #define VKI_SOL_SOCKET  1
0320 
0321 #define VKI_SO_TYPE 3
0322 
0323 #define VKI_SO_ATTACH_FILTER    26
0324 
0325 //----------------------------------------------------------------------
0326 // From linux-2.6.9/include/asm-x86_64/sockios.h
0327 //----------------------------------------------------------------------
0328 
0329 #define VKI_SIOCSPGRP       0x8902
0330 #define VKI_SIOCGPGRP       0x8904
0331 #define VKI_SIOCATMARK      0x8905
0332 #define VKI_SIOCGSTAMP      0x8906      /* Get stamp (timeval) */
0333 #define VKI_SIOCGSTAMPNS    0x8907      /* Get stamp (timespec) */
0334 
0335 //----------------------------------------------------------------------
0336 // From linux-2.6.9/include/asm-x86_64/stat.h
0337 //----------------------------------------------------------------------
0338 
0339 struct vki_stat {
0340     unsigned long   st_dev;
0341     unsigned long   st_ino;
0342     unsigned long   st_nlink;
0343 
0344     unsigned int    st_mode;
0345     unsigned int    st_uid;
0346     unsigned int    st_gid;
0347     unsigned int    __pad0;
0348     unsigned long   st_rdev;
0349     long        st_size;
0350     long        st_blksize;
0351     long        st_blocks;  /* Number 512-byte blocks allocated. */
0352 
0353     unsigned long   st_atime;
0354     unsigned long   st_atime_nsec; 
0355     unsigned long   st_mtime;
0356     unsigned long   st_mtime_nsec;
0357     unsigned long   st_ctime;
0358     unsigned long   st_ctime_nsec;
0359     long        __unused0[3];
0360 };
0361 
0362 //----------------------------------------------------------------------
0363 // From linux-2.6.9/include/asm-x86_64/statfs.h
0364 //----------------------------------------------------------------------
0365 
0366 struct vki_statfs {
0367     long f_type;
0368     long f_bsize;
0369     long f_blocks;
0370     long f_bfree;
0371     long f_bavail;
0372     long f_files;
0373     long f_ffree;
0374     __vki_kernel_fsid_t f_fsid;
0375     long f_namelen;
0376     long f_frsize;
0377     long f_spare[5];
0378 };
0379 
0380 //----------------------------------------------------------------------
0381 // From linux-2.6.9/include/asm-x86_64/termios.h
0382 //----------------------------------------------------------------------
0383 
0384 struct vki_winsize {
0385     unsigned short ws_row;
0386     unsigned short ws_col;
0387     unsigned short ws_xpixel;
0388     unsigned short ws_ypixel;
0389 };
0390 
0391 #define VKI_NCC 8
0392 struct vki_termio {
0393     unsigned short c_iflag;     /* input mode flags */
0394     unsigned short c_oflag;     /* output mode flags */
0395     unsigned short c_cflag;     /* control mode flags */
0396     unsigned short c_lflag;     /* local mode flags */
0397     unsigned char c_line;       /* line discipline */
0398     unsigned char c_cc[VKI_NCC];    /* control characters */
0399 };
0400 
0401 //----------------------------------------------------------------------
0402 // From linux-2.6.9/include/asm-x86_64/termbits.h
0403 //----------------------------------------------------------------------
0404 
0405 typedef unsigned char   vki_cc_t;
0406 typedef unsigned int    vki_tcflag_t;
0407 
0408 #define VKI_NCCS 19
0409 struct vki_termios {
0410     vki_tcflag_t c_iflag;       /* input mode flags */
0411     vki_tcflag_t c_oflag;       /* output mode flags */
0412     vki_tcflag_t c_cflag;       /* control mode flags */
0413     vki_tcflag_t c_lflag;       /* local mode flags */
0414     vki_cc_t c_line;        /* line discipline */
0415     vki_cc_t c_cc[VKI_NCCS];    /* control characters */
0416 };
0417 
0418 
0419 //----------------------------------------------------------------------
0420 // From linux-2.6.9/include/asm-x86_64/ioctl.h
0421 //----------------------------------------------------------------------
0422 
0423 #define _VKI_IOC_NRBITS     8
0424 #define _VKI_IOC_TYPEBITS   8
0425 #define _VKI_IOC_SIZEBITS   14
0426 #define _VKI_IOC_DIRBITS    2
0427 
0428 #define _VKI_IOC_SIZEMASK   ((1 << _VKI_IOC_SIZEBITS)-1)
0429 #define _VKI_IOC_DIRMASK    ((1 << _VKI_IOC_DIRBITS)-1)
0430 
0431 #define _VKI_IOC_NRSHIFT    0
0432 #define _VKI_IOC_TYPESHIFT  (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
0433 #define _VKI_IOC_SIZESHIFT  (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
0434 #define _VKI_IOC_DIRSHIFT   (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
0435 
0436 #define _VKI_IOC_NONE   0U
0437 #define _VKI_IOC_WRITE  1U
0438 #define _VKI_IOC_READ   2U
0439 
0440 #define _VKI_IOC(dir,type,nr,size) \
0441     (((dir)  << _VKI_IOC_DIRSHIFT) | \
0442      ((type) << _VKI_IOC_TYPESHIFT) | \
0443      ((nr)   << _VKI_IOC_NRSHIFT) | \
0444      ((size) << _VKI_IOC_SIZESHIFT))
0445 
0446 #define _VKI_IO(type,nr)        _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
0447 #define _VKI_IOR(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr),sizeof(size))
0448 #define _VKI_IOW(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size))
0449 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size))
0450 
0451 #define _VKI_IOC_DIR(nr)        (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
0452 #define _VKI_IOC_SIZE(nr)       (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
0453 
0454 //----------------------------------------------------------------------
0455 // From linux-2.6.9/include/asm-x86_64/ioctls.h
0456 //----------------------------------------------------------------------
0457 
0458 #define VKI_TCGETS  0x5401
0459 #define VKI_TCSETS  0x5402
0460 #define VKI_TCSETSW 0x5403
0461 #define VKI_TCSETSF 0x5404
0462 #define VKI_TCGETA  0x5405
0463 #define VKI_TCSETA  0x5406
0464 #define VKI_TCSETAW 0x5407
0465 #define VKI_TCSETAF 0x5408
0466 #define VKI_TCSBRK  0x5409
0467 #define VKI_TCXONC  0x540A
0468 #define VKI_TCFLSH  0x540B
0469 #define VKI_TIOCSCTTY   0x540E
0470 #define VKI_TIOCGPGRP   0x540F
0471 #define VKI_TIOCSPGRP   0x5410
0472 #define VKI_TIOCOUTQ    0x5411
0473 #define VKI_TIOCGWINSZ  0x5413
0474 #define VKI_TIOCSWINSZ  0x5414
0475 #define VKI_TIOCMGET    0x5415
0476 #define VKI_TIOCMBIS    0x5416
0477 #define VKI_TIOCMBIC    0x5417
0478 #define VKI_TIOCMSET    0x5418
0479 #define VKI_FIONREAD    0x541B
0480 #define VKI_TIOCLINUX   0x541C
0481 #define VKI_FIONBIO 0x5421
0482 #define VKI_TIOCNOTTY   0x5422
0483 #define VKI_TCSBRKP 0x5425  /* Needed for POSIX tcsendbreak() */
0484 #define VKI_TIOCGPTN    _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
0485 #define VKI_TIOCSPTLCK  _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
0486 
0487 #define VKI_FIONCLEX    0x5450
0488 #define VKI_FIOCLEX     0x5451
0489 #define VKI_FIOASYNC    0x5452
0490 #define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
0491 
0492 #define VKI_TIOCGICOUNT 0x545D  /* read serial port inline interrupt counts */
0493 
0494 //----------------------------------------------------------------------
0495 // From linux-2.6.9/include/asm-x86_64/poll.h
0496 //----------------------------------------------------------------------
0497 
0498 #define VKI_POLLIN      0x0001
0499 
0500 struct vki_pollfd {
0501     int fd;
0502     short events;
0503     short revents;
0504 };
0505 
0506 //----------------------------------------------------------------------
0507 // From linux-2.6.9/include/asm-x86_64/user.h
0508 //----------------------------------------------------------------------
0509 
0510 struct vki_user_i387_struct {
0511     unsigned short  cwd;
0512     unsigned short  swd;
0513     unsigned short  twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
0514     unsigned short  fop;
0515     __vki_u64   rip;
0516     __vki_u64   rdp;
0517     __vki_u32   mxcsr;
0518     __vki_u32   mxcsr_mask;
0519     __vki_u32   st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
0520     __vki_u32   xmm_space[64];  /* 16*16 bytes for each XMM-reg = 256 bytes */
0521     __vki_u32   padding[24];
0522 };
0523 
0524 struct vki_user_regs_struct {
0525     unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10;
0526     unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax;
0527     unsigned long rip,cs,eflags;
0528     unsigned long rsp,ss;
0529     unsigned long fs_base, gs_base;
0530     unsigned long ds,es,fs,gs; 
0531 }; 
0532 
0533 //----------------------------------------------------------------------
0534 // From linux-2.6.9/include/asm-x86_64/elf.h
0535 //----------------------------------------------------------------------
0536 
0537 typedef unsigned long vki_elf_greg_t;
0538 
0539 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
0540 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
0541 
0542 typedef struct vki_user_i387_struct vki_elf_fpregset_t;
0543 
0544 //----------------------------------------------------------------------
0545 // From linux-2.6.9/include/asm-x86_64/ucontext.h
0546 //----------------------------------------------------------------------
0547 
0548 struct vki_ucontext {
0549     unsigned long       uc_flags;
0550     struct vki_ucontext    *uc_link;
0551     vki_stack_t     uc_stack;
0552     struct vki_sigcontext   uc_mcontext;
0553     vki_sigset_t        uc_sigmask; /* mask last for extensibility */
0554 };
0555 
0556 //----------------------------------------------------------------------
0557 // From linux-2.6.9/include/asm-x86_64/segment.h
0558 //----------------------------------------------------------------------
0559 
0560 #define VKI_GDT_ENTRY_TLS_ENTRIES 3
0561 
0562 #define VKI_GDT_ENTRY_TLS_MIN 11
0563 #define VKI_GDT_ENTRY_TLS_MAX 13
0564 
0565 //----------------------------------------------------------------------
0566 // From linux-2.6.11.9/include/asm-x86_64/prctl.h
0567 //----------------------------------------------------------------------
0568 
0569 #define VKI_ARCH_SET_GS 0x1001
0570 #define VKI_ARCH_SET_FS 0x1002
0571 #define VKI_ARCH_GET_FS 0x1003
0572 #define VKI_ARCH_GET_GS 0x1004
0573 
0574 //----------------------------------------------------------------------
0575 // Originally from linux-2.6.9/include/asm-x86_64/ldt.h
0576 //----------------------------------------------------------------------
0577 
0578 // Note that the type here is very slightly different to the
0579 // type for x86 (the final 'lm' field is added).
0580 /* The explanation is: the final bit is not present in 32 bit code running
0581    on 64 bits kernel. The kernel has to assume this value is 0 whenever
0582    user_desc arrives from a 32-bit program.
0583    See /usr/include/asm/ldt.h. */
0584 
0585 /* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
0586    to confuse and annoy everyone, this is _not_ the same as an
0587    VgLdtEntry and has to be translated into such.  The logic for doing
0588    so, in vg_ldt.c, is copied from the kernel sources.]] */
0589 /* Note also that a comment in ldt.h indicates that the below
0590    contains several fields ignored on 64bit, and that modify_ldt
0591    is rather for 32bit. */
0592 struct vki_user_desc {
0593     unsigned int  entry_number;
0594     unsigned int  base_addr;
0595     unsigned int  limit;
0596     unsigned int  seg_32bit:1;
0597     unsigned int  contents:2;
0598     unsigned int  read_exec_only:1;
0599     unsigned int  limit_in_pages:1;
0600     unsigned int  seg_not_present:1;
0601     unsigned int  useable:1;
0602         unsigned int  lm:1;
0603 };
0604 
0605 // [[Nb: for our convenience within Valgrind, use a more specific name]]
0606 typedef struct vki_user_desc vki_modify_ldt_t;
0607 
0608 //----------------------------------------------------------------------
0609 // From linux-2.6.11.2/include/asm-x86_64/ipcbuf.h
0610 //----------------------------------------------------------------------
0611 
0612 struct vki_ipc64_perm
0613 {
0614     __vki_kernel_key_t  key;
0615     __vki_kernel_uid32_t    uid;
0616     __vki_kernel_gid32_t    gid;
0617     __vki_kernel_uid32_t    cuid;
0618     __vki_kernel_gid32_t    cgid;
0619     __vki_kernel_mode_t mode;
0620     unsigned short      __pad1;
0621     unsigned short      seq;
0622     unsigned short      __pad2;
0623     unsigned long       __unused1;
0624     unsigned long       __unused2;
0625 };
0626 
0627 //----------------------------------------------------------------------
0628 // From linux-2.6.11.2/include/asm-x86_64/sembuf.h
0629 //----------------------------------------------------------------------
0630 
0631 struct vki_semid64_ds {
0632     struct vki_ipc64_perm sem_perm;     /* permissions .. see ipc.h */
0633     __vki_kernel_time_t sem_otime;      /* last semop time */
0634     unsigned long   __unused1;
0635     __vki_kernel_time_t sem_ctime;      /* last change time */
0636     unsigned long   __unused2;
0637     unsigned long   sem_nsems;      /* no. of semaphores in array */
0638     unsigned long   __unused3;
0639     unsigned long   __unused4;
0640 };
0641 
0642 //----------------------------------------------------------------------
0643 // From linux-2.6.11.2/include/asm-x86_64/msgbuf.h
0644 //----------------------------------------------------------------------
0645 
0646 struct vki_msqid64_ds {
0647     struct vki_ipc64_perm msg_perm;
0648     __vki_kernel_time_t msg_stime;  /* last msgsnd time */
0649     __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
0650     __vki_kernel_time_t msg_ctime;  /* last change time */
0651     unsigned long  msg_cbytes;  /* current number of bytes on queue */
0652     unsigned long  msg_qnum;    /* number of messages in queue */
0653     unsigned long  msg_qbytes;  /* max number of bytes on queue */
0654     __vki_kernel_pid_t msg_lspid;   /* pid of last msgsnd */
0655     __vki_kernel_pid_t msg_lrpid;   /* last receive pid */
0656     unsigned long  __unused4;
0657     unsigned long  __unused5;
0658 };
0659 
0660 //----------------------------------------------------------------------
0661 // From linux-2.6.11.2/include/asm-x86_64/shmbuf.h
0662 //----------------------------------------------------------------------
0663 
0664 struct vki_shmid64_ds {
0665     struct vki_ipc64_perm   shm_perm;   /* operation perms */
0666     vki_size_t      shm_segsz;  /* size of segment (bytes) */
0667     __vki_kernel_time_t shm_atime;  /* last attach time */
0668     __vki_kernel_time_t shm_dtime;  /* last detach time */
0669     __vki_kernel_time_t shm_ctime;  /* last change time */
0670     __vki_kernel_pid_t  shm_cpid;   /* pid of creator */
0671     __vki_kernel_pid_t  shm_lpid;   /* pid of last operator */
0672     unsigned long       shm_nattch; /* no. of current attaches */
0673     unsigned long       __unused4;
0674     unsigned long       __unused5;
0675 };
0676 
0677 struct vki_shminfo64 {
0678     unsigned long   shmmax;
0679     unsigned long   shmmin;
0680     unsigned long   shmmni;
0681     unsigned long   shmseg;
0682     unsigned long   shmall;
0683     unsigned long   __unused1;
0684     unsigned long   __unused2;
0685     unsigned long   __unused3;
0686     unsigned long   __unused4;
0687 };
0688 
0689 //----------------------------------------------------------------------
0690 // From linux-2.6.12.2/include/asm-x86_64/ptrace.h
0691 //----------------------------------------------------------------------
0692 
0693 #define VKI_PTRACE_GETREGS            12
0694 #define VKI_PTRACE_SETREGS            13
0695 #define VKI_PTRACE_GETFPREGS          14
0696 #define VKI_PTRACE_SETFPREGS          15
0697 
0698 // From /usr/include/asm/ptrace-abit.h
0699 /* only useful for access 32bit programs / kernels */
0700 #define VKI_PTRACE_GET_THREAD_AREA    25
0701 #define VKI_PTRACE_SET_THREAD_AREA    26
0702 
0703 //----------------------------------------------------------------------
0704 // From linux-2.6.8.1/include/asm-generic/errno.h
0705 //----------------------------------------------------------------------
0706 
0707 #define VKI_ENOSYS       38  /* Function not implemented */
0708 #define VKI_EOVERFLOW    75  /* Value too large for defined data type */
0709 
0710 //----------------------------------------------------------------------
0711 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
0712 //----------------------------------------------------------------------
0713 
0714 #define VKI_TIOCGSERIAL     0x541E
0715 #define VKI_TIOCSSERIAL     0x541F
0716 
0717 //----------------------------------------------------------------------
0718 // And that's it!
0719 //----------------------------------------------------------------------
0720 
0721 #endif // __VKI_AMD64_LINUX_H
0722 
0723 /*--------------------------------------------------------------------*/
0724 /*--- end                                                          ---*/
0725 /*--------------------------------------------------------------------*/