njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- AMD64/Linux-specific kernel interface. ---*/ |
njn | 4de47b1 | 2005-05-16 03:25:12 +0000 | [diff] [blame] | 4 | /*--- vki-amd64-linux.h ---*/ |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 8 | This file is part of Valgrind, a dynamic binary instrumentation |
| 9 | framework. |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 10 | |
njn | 5361242 | 2005-03-12 16:22:54 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2005 Julian Seward |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 12 | jseward@acm.org |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or |
| 15 | modify it under the terms of the GNU General Public License as |
| 16 | published by the Free Software Foundation; either version 2 of the |
| 17 | License, or (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but |
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 27 | 02111-1307, USA. |
| 28 | |
| 29 | The GNU General Public License is contained in the file COPYING. |
| 30 | */ |
| 31 | |
njn | 4de47b1 | 2005-05-16 03:25:12 +0000 | [diff] [blame] | 32 | #ifndef __VKI_AMD64_LINUX_H |
| 33 | #define __VKI_AMD64_LINUX_H |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 34 | |
| 35 | // AMD64 is little-endian. |
| 36 | #define VKI_LITTLE_ENDIAN 1 |
| 37 | |
| 38 | //---------------------------------------------------------------------- |
| 39 | // From linux-2.6.9/include/asm-x86_64/types.h |
| 40 | //---------------------------------------------------------------------- |
| 41 | |
| 42 | typedef unsigned char __vki_u8; |
| 43 | |
| 44 | typedef __signed__ short __vki_s16; |
| 45 | typedef unsigned short __vki_u16; |
| 46 | |
| 47 | typedef unsigned int __vki_u32; |
| 48 | |
| 49 | typedef __signed__ long long __vki_s64; |
| 50 | typedef unsigned long long __vki_u64; |
| 51 | |
| 52 | typedef unsigned short vki_u16; |
| 53 | |
| 54 | typedef unsigned int vki_u32; |
| 55 | |
| 56 | //---------------------------------------------------------------------- |
| 57 | // From linux-2.6.9/include/asm-x86_64/page.h |
| 58 | //---------------------------------------------------------------------- |
| 59 | |
| 60 | #define VKI_PAGE_SHIFT 12 |
| 61 | #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) |
| 62 | |
| 63 | //---------------------------------------------------------------------- |
| 64 | // From linux-2.6.9/include/asm-x86_64/signal.h |
| 65 | //---------------------------------------------------------------------- |
| 66 | |
| 67 | #define _VKI_NSIG 64 |
| 68 | #define _VKI_NSIG_BPW 64 |
| 69 | #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW) |
| 70 | |
| 71 | typedef unsigned long vki_old_sigset_t; /* at least 32 bits */ |
| 72 | |
| 73 | typedef struct { |
| 74 | unsigned long sig[_VKI_NSIG_WORDS]; |
| 75 | } vki_sigset_t; |
| 76 | |
| 77 | #define VKI_SIGHUP 1 |
| 78 | #define VKI_SIGINT 2 |
| 79 | #define VKI_SIGQUIT 3 |
| 80 | #define VKI_SIGILL 4 |
| 81 | #define VKI_SIGTRAP 5 |
| 82 | #define VKI_SIGABRT 6 |
| 83 | #define VKI_SIGBUS 7 |
| 84 | #define VKI_SIGFPE 8 |
| 85 | #define VKI_SIGKILL 9 |
| 86 | #define VKI_SIGUSR1 10 |
| 87 | #define VKI_SIGSEGV 11 |
| 88 | #define VKI_SIGUSR2 12 |
| 89 | #define VKI_SIGPIPE 13 |
| 90 | #define VKI_SIGALRM 14 |
| 91 | #define VKI_SIGTERM 15 |
| 92 | #define VKI_SIGSTKFLT 16 |
| 93 | #define VKI_SIGCHLD 17 |
| 94 | #define VKI_SIGCONT 18 |
| 95 | #define VKI_SIGSTOP 19 |
| 96 | #define VKI_SIGTSTP 20 |
| 97 | #define VKI_SIGTTIN 21 |
| 98 | #define VKI_SIGTTOU 22 |
| 99 | #define VKI_SIGURG 23 |
| 100 | #define VKI_SIGXCPU 24 |
| 101 | #define VKI_SIGXFSZ 25 |
| 102 | #define VKI_SIGVTALRM 26 |
| 103 | #define VKI_SIGPROF 27 |
| 104 | #define VKI_SIGWINCH 28 |
| 105 | #define VKI_SIGIO 29 |
| 106 | #define VKI_SIGPWR 30 |
| 107 | #define VKI_SIGSYS 31 |
| 108 | #define VKI_SIGUNUSED 31 |
| 109 | |
| 110 | #define VKI_SIGRTMIN 32 |
| 111 | #define VKI_SIGRTMAX _VKI_NSIG |
| 112 | |
| 113 | #define VKI_SA_NOCLDSTOP 0x00000001 |
| 114 | #define VKI_SA_NOCLDWAIT 0x00000002 |
| 115 | #define VKI_SA_SIGINFO 0x00000004 |
| 116 | #define VKI_SA_ONSTACK 0x08000000 |
| 117 | #define VKI_SA_RESTART 0x10000000 |
| 118 | #define VKI_SA_NODEFER 0x40000000 |
| 119 | #define VKI_SA_RESETHAND 0x80000000 |
| 120 | |
| 121 | #define VKI_SA_NOMASK VKI_SA_NODEFER |
| 122 | #define VKI_SA_ONESHOT VKI_SA_RESETHAND |
| 123 | |
| 124 | #define VKI_SA_RESTORER 0x04000000 |
| 125 | |
| 126 | #define VKI_SS_ONSTACK 1 |
| 127 | #define VKI_SS_DISABLE 2 |
| 128 | |
| 129 | #define VKI_MINSIGSTKSZ 2048 |
| 130 | |
| 131 | #define VKI_SIG_BLOCK 0 /* for blocking signals */ |
| 132 | #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */ |
| 133 | #define VKI_SIG_SETMASK 2 /* for setting the signal mask */ |
| 134 | |
| 135 | typedef void __vki_signalfn_t(int); |
| 136 | typedef __vki_signalfn_t __user *__vki_sighandler_t; |
| 137 | |
| 138 | typedef void __vki_restorefn_t(void); |
| 139 | typedef __vki_restorefn_t __user *__vki_sigrestore_t; |
| 140 | |
| 141 | #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */ |
| 142 | #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */ |
| 143 | |
| 144 | struct vki_sigaction { |
| 145 | // [[Nb: a 'k' prefix is added to "sa_handler" because |
| 146 | // bits/sigaction.h (which gets dragged in somehow via signal.h) |
| 147 | // #defines it as something else. Since that is done for glibc's |
| 148 | // purposes, which we don't care about here, we use our own name.]] |
| 149 | __vki_sighandler_t ksa_handler; |
| 150 | unsigned long sa_flags; |
| 151 | __vki_sigrestore_t sa_restorer; |
| 152 | vki_sigset_t sa_mask; /* mask last for extensibility */ |
| 153 | }; |
| 154 | |
| 155 | typedef struct vki_sigaltstack { |
| 156 | void __user *ss_sp; |
| 157 | int ss_flags; |
| 158 | vki_size_t ss_size; |
| 159 | } vki_stack_t; |
| 160 | |
| 161 | //---------------------------------------------------------------------- |
| 162 | // From linux-2.6.9/include/asm-x86_64/sigcontext.h |
| 163 | //---------------------------------------------------------------------- |
| 164 | |
| 165 | struct _vki_fpstate { |
| 166 | __vki_u16 cwd; |
| 167 | __vki_u16 swd; |
| 168 | __vki_u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ |
| 169 | __vki_u16 fop; |
| 170 | __vki_u64 rip; |
| 171 | __vki_u64 rdp; |
| 172 | __vki_u32 mxcsr; |
| 173 | __vki_u32 mxcsr_mask; |
| 174 | __vki_u32 st_space[32]; /* 8*16 bytes for each FP-reg */ |
| 175 | __vki_u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ |
| 176 | __vki_u32 reserved2[24]; |
| 177 | }; |
| 178 | |
| 179 | struct vki_sigcontext { |
| 180 | unsigned long r8; |
| 181 | unsigned long r9; |
| 182 | unsigned long r10; |
| 183 | unsigned long r11; |
| 184 | unsigned long r12; |
| 185 | unsigned long r13; |
| 186 | unsigned long r14; |
| 187 | unsigned long r15; |
| 188 | unsigned long rdi; |
| 189 | unsigned long rsi; |
| 190 | unsigned long rbp; |
| 191 | unsigned long rbx; |
| 192 | unsigned long rdx; |
| 193 | unsigned long rax; |
| 194 | unsigned long rcx; |
| 195 | unsigned long rsp; |
| 196 | unsigned long rip; |
| 197 | unsigned long eflags; /* RFLAGS */ |
| 198 | unsigned short cs; |
| 199 | unsigned short gs; |
| 200 | unsigned short fs; |
| 201 | unsigned short __pad0; |
| 202 | unsigned long err; |
| 203 | unsigned long trapno; |
| 204 | unsigned long oldmask; |
| 205 | unsigned long cr2; |
| 206 | struct _vki_fpstate __user *fpstate; /* zero when no FPU context */ |
| 207 | unsigned long reserved1[8]; |
| 208 | }; |
| 209 | |
| 210 | //---------------------------------------------------------------------- |
| 211 | // From linux-2.6.9/include/asm-x86_64/mman.h |
| 212 | //---------------------------------------------------------------------- |
| 213 | |
| 214 | #define VKI_PROT_READ 0x1 /* page can be read */ |
| 215 | #define VKI_PROT_WRITE 0x2 /* page can be written */ |
| 216 | #define VKI_PROT_EXEC 0x4 /* page can be executed */ |
sewardj | 4d89e30 | 2005-03-16 22:04:40 +0000 | [diff] [blame] | 217 | #define VKI_PROT_NONE 0x0 /* page can not be accessed */ |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 218 | |
| 219 | #define VKI_MAP_SHARED 0x01 /* Share changes */ |
| 220 | #define VKI_MAP_PRIVATE 0x02 /* Changes are private */ |
| 221 | #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */ |
| 222 | #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */ |
rjwalsh | d804ab8 | 2005-06-19 17:52:41 +0000 | [diff] [blame] | 223 | #define VKI_MAP_NORESERVE 0x4000 /* don't check for reservations */ |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 224 | |
| 225 | //---------------------------------------------------------------------- |
| 226 | // From linux-2.6.9/include/asm-x86_64/fcntl.h |
| 227 | //---------------------------------------------------------------------- |
| 228 | |
| 229 | #define VKI_O_RDONLY 00 |
| 230 | #define VKI_O_WRONLY 01 |
| 231 | #define VKI_O_CREAT 0100 /* not fcntl */ |
| 232 | #define VKI_O_EXCL 0200 /* not fcntl */ |
| 233 | #define VKI_O_TRUNC 01000 /* not fcntl */ |
| 234 | #define VKI_O_APPEND 02000 |
| 235 | #define VKI_O_NONBLOCK 04000 |
| 236 | |
| 237 | #define VKI_F_DUPFD 0 /* dup */ |
| 238 | #define VKI_F_GETFD 1 /* get close_on_exec */ |
| 239 | #define VKI_F_SETFD 2 /* set/clear close_on_exec */ |
| 240 | #define VKI_F_GETFL 3 /* get file->f_flags */ |
| 241 | #define VKI_F_SETFL 4 /* set file->f_flags */ |
| 242 | #define VKI_F_GETLK 5 |
| 243 | #define VKI_F_SETLK 6 |
| 244 | #define VKI_F_SETLKW 7 |
| 245 | |
| 246 | #define VKI_F_SETOWN 8 /* for sockets. */ |
| 247 | #define VKI_F_GETOWN 9 /* for sockets. */ |
| 248 | #define VKI_F_SETSIG 10 /* for sockets. */ |
| 249 | #define VKI_F_GETSIG 11 /* for sockets. */ |
| 250 | |
| 251 | #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */ |
| 252 | |
| 253 | #define VKI_F_LINUX_SPECIFIC_BASE 1024 |
| 254 | |
| 255 | //---------------------------------------------------------------------- |
| 256 | // From linux-2.6.9/include/asm-x86_64/resource.h |
| 257 | //---------------------------------------------------------------------- |
| 258 | |
| 259 | #define VKI_RLIMIT_DATA 2 /* max data size */ |
| 260 | #define VKI_RLIMIT_STACK 3 /* max stack size */ |
| 261 | #define VKI_RLIMIT_CORE 4 /* max core file size */ |
| 262 | #define VKI_RLIMIT_NOFILE 7 /* max number of open files */ |
| 263 | |
| 264 | //---------------------------------------------------------------------- |
| 265 | // From linux-2.6.9/include/asm-x86_64/socket.h |
| 266 | //---------------------------------------------------------------------- |
| 267 | |
| 268 | #define VKI_SOL_SOCKET 1 |
| 269 | |
| 270 | #define VKI_SO_TYPE 3 |
| 271 | |
| 272 | //---------------------------------------------------------------------- |
| 273 | // From linux-2.6.9/include/asm-x86_64/sockios.h |
| 274 | //---------------------------------------------------------------------- |
| 275 | |
| 276 | #define VKI_SIOCSPGRP 0x8902 |
| 277 | #define VKI_SIOCGPGRP 0x8904 |
| 278 | #define VKI_SIOCGSTAMP 0x8906 /* Get stamp */ |
| 279 | |
| 280 | //---------------------------------------------------------------------- |
| 281 | // From linux-2.6.9/include/asm-x86_64/stat.h |
| 282 | //---------------------------------------------------------------------- |
| 283 | |
| 284 | struct vki_stat { |
| 285 | unsigned long st_dev; |
| 286 | unsigned long st_ino; |
| 287 | unsigned long st_nlink; |
| 288 | |
| 289 | unsigned int st_mode; |
| 290 | unsigned int st_uid; |
| 291 | unsigned int st_gid; |
| 292 | unsigned int __pad0; |
| 293 | unsigned long st_rdev; |
| 294 | long st_size; |
| 295 | long st_blksize; |
| 296 | long st_blocks; /* Number 512-byte blocks allocated. */ |
| 297 | |
| 298 | unsigned long st_atime; |
| 299 | unsigned long st_atime_nsec; |
| 300 | unsigned long st_mtime; |
| 301 | unsigned long st_mtime_nsec; |
| 302 | unsigned long st_ctime; |
| 303 | unsigned long st_ctime_nsec; |
| 304 | long __unused[3]; |
| 305 | }; |
| 306 | |
| 307 | //---------------------------------------------------------------------- |
| 308 | // From linux-2.6.9/include/asm-x86_64/statfs.h |
| 309 | //---------------------------------------------------------------------- |
| 310 | |
| 311 | struct vki_statfs { |
| 312 | long f_type; |
| 313 | long f_bsize; |
| 314 | long f_blocks; |
| 315 | long f_bfree; |
| 316 | long f_bavail; |
| 317 | long f_files; |
| 318 | long f_ffree; |
| 319 | __vki_kernel_fsid_t f_fsid; |
| 320 | long f_namelen; |
| 321 | long f_frsize; |
| 322 | long f_spare[5]; |
| 323 | }; |
| 324 | |
| 325 | //---------------------------------------------------------------------- |
| 326 | // From linux-2.6.9/include/asm-x86_64/termios.h |
| 327 | //---------------------------------------------------------------------- |
| 328 | |
| 329 | struct vki_winsize { |
| 330 | unsigned short ws_row; |
| 331 | unsigned short ws_col; |
| 332 | unsigned short ws_xpixel; |
| 333 | unsigned short ws_ypixel; |
| 334 | }; |
| 335 | |
| 336 | #define VKI_NCC 8 |
| 337 | struct vki_termio { |
| 338 | unsigned short c_iflag; /* input mode flags */ |
| 339 | unsigned short c_oflag; /* output mode flags */ |
| 340 | unsigned short c_cflag; /* control mode flags */ |
| 341 | unsigned short c_lflag; /* local mode flags */ |
| 342 | unsigned char c_line; /* line discipline */ |
| 343 | unsigned char c_cc[VKI_NCC]; /* control characters */ |
| 344 | }; |
| 345 | |
| 346 | //---------------------------------------------------------------------- |
| 347 | // From linux-2.6.9/include/asm-x86_64/termbits.h |
| 348 | //---------------------------------------------------------------------- |
| 349 | |
| 350 | typedef unsigned char vki_cc_t; |
| 351 | typedef unsigned int vki_tcflag_t; |
| 352 | |
| 353 | #define VKI_NCCS 19 |
| 354 | struct vki_termios { |
| 355 | vki_tcflag_t c_iflag; /* input mode flags */ |
| 356 | vki_tcflag_t c_oflag; /* output mode flags */ |
| 357 | vki_tcflag_t c_cflag; /* control mode flags */ |
| 358 | vki_tcflag_t c_lflag; /* local mode flags */ |
| 359 | vki_cc_t c_line; /* line discipline */ |
| 360 | vki_cc_t c_cc[VKI_NCCS]; /* control characters */ |
| 361 | }; |
| 362 | |
| 363 | |
| 364 | //---------------------------------------------------------------------- |
| 365 | // From linux-2.6.9/include/asm-x86_64/ioctl.h |
| 366 | //---------------------------------------------------------------------- |
| 367 | |
| 368 | #define _VKI_IOC_NRBITS 8 |
| 369 | #define _VKI_IOC_TYPEBITS 8 |
| 370 | #define _VKI_IOC_SIZEBITS 14 |
| 371 | #define _VKI_IOC_DIRBITS 2 |
| 372 | |
| 373 | #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1) |
| 374 | #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1) |
| 375 | |
| 376 | #define _VKI_IOC_NRSHIFT 0 |
| 377 | #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) |
| 378 | #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) |
| 379 | #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) |
| 380 | |
| 381 | #define _VKI_IOC_NONE 0U |
| 382 | #define _VKI_IOC_WRITE 1U |
| 383 | #define _VKI_IOC_READ 2U |
| 384 | |
| 385 | #define _VKI_IOC(dir,type,nr,size) \ |
| 386 | (((dir) << _VKI_IOC_DIRSHIFT) | \ |
| 387 | ((type) << _VKI_IOC_TYPESHIFT) | \ |
| 388 | ((nr) << _VKI_IOC_NRSHIFT) | \ |
| 389 | ((size) << _VKI_IOC_SIZESHIFT)) |
| 390 | |
| 391 | #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) |
| 392 | #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),sizeof(size)) |
| 393 | #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size)) |
| 394 | #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size)) |
| 395 | |
| 396 | #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) |
| 397 | #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) |
| 398 | |
| 399 | //---------------------------------------------------------------------- |
| 400 | // From linux-2.6.9/include/asm-x86_64/ioctls.h |
| 401 | //---------------------------------------------------------------------- |
| 402 | |
| 403 | #define VKI_TCGETS 0x5401 |
| 404 | #define VKI_TCSETS 0x5402 |
| 405 | #define VKI_TCSETSW 0x5403 |
| 406 | #define VKI_TCSETSF 0x5404 |
| 407 | #define VKI_TCGETA 0x5405 |
| 408 | #define VKI_TCSETA 0x5406 |
| 409 | #define VKI_TCSETAW 0x5407 |
| 410 | #define VKI_TCSETAF 0x5408 |
| 411 | #define VKI_TCSBRK 0x5409 |
| 412 | #define VKI_TCXONC 0x540A |
| 413 | #define VKI_TCFLSH 0x540B |
| 414 | #define VKI_TIOCSCTTY 0x540E |
| 415 | #define VKI_TIOCGPGRP 0x540F |
| 416 | #define VKI_TIOCSPGRP 0x5410 |
| 417 | #define VKI_TIOCOUTQ 0x5411 |
| 418 | #define VKI_TIOCGWINSZ 0x5413 |
| 419 | #define VKI_TIOCSWINSZ 0x5414 |
| 420 | #define VKI_TIOCMBIS 0x5416 |
| 421 | #define VKI_TIOCMBIC 0x5417 |
| 422 | #define VKI_TIOCMSET 0x5418 |
| 423 | #define VKI_FIONREAD 0x541B |
| 424 | #define VKI_TIOCLINUX 0x541C |
| 425 | #define VKI_FIONBIO 0x5421 |
| 426 | #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ |
| 427 | #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ |
| 428 | #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ |
| 429 | |
| 430 | #define VKI_FIOASYNC 0x5452 |
| 431 | |
| 432 | //---------------------------------------------------------------------- |
| 433 | // From linux-2.6.9/include/asm-x86_64/poll.h |
| 434 | //---------------------------------------------------------------------- |
| 435 | |
| 436 | #define VKI_POLLIN 0x0001 |
| 437 | |
| 438 | struct vki_pollfd { |
| 439 | int fd; |
| 440 | short events; |
| 441 | short revents; |
| 442 | }; |
| 443 | |
| 444 | //---------------------------------------------------------------------- |
| 445 | // From linux-2.6.9/include/asm-x86_64/user.h |
| 446 | //---------------------------------------------------------------------- |
| 447 | |
| 448 | struct vki_user_regs_struct { |
| 449 | unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10; |
| 450 | unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax; |
| 451 | unsigned long rip,cs,eflags; |
| 452 | unsigned long rsp,ss; |
| 453 | unsigned long fs_base, gs_base; |
| 454 | unsigned long ds,es,fs,gs; |
| 455 | }; |
| 456 | |
| 457 | //---------------------------------------------------------------------- |
| 458 | // From linux-2.6.9/include/asm-x86_64/elf.h |
| 459 | //---------------------------------------------------------------------- |
| 460 | |
| 461 | typedef unsigned long vki_elf_greg_t; |
| 462 | |
| 463 | #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) |
| 464 | typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; |
| 465 | |
| 466 | //---------------------------------------------------------------------- |
| 467 | // From linux-2.6.9/include/asm-x86_64/ucontext.h |
| 468 | //---------------------------------------------------------------------- |
| 469 | |
| 470 | struct vki_ucontext { |
| 471 | unsigned long uc_flags; |
| 472 | struct vki_ucontext *uc_link; |
| 473 | vki_stack_t uc_stack; |
| 474 | struct vki_sigcontext uc_mcontext; |
| 475 | vki_sigset_t uc_sigmask; /* mask last for extensibility */ |
| 476 | }; |
| 477 | |
| 478 | //---------------------------------------------------------------------- |
| 479 | // From linux-2.6.9/include/asm-x86_64/segment.h |
| 480 | //---------------------------------------------------------------------- |
| 481 | |
| 482 | #define VKI_GDT_ENTRY_TLS_ENTRIES 3 |
| 483 | |
| 484 | #define VKI_GDT_ENTRY_TLS_MIN 11 |
| 485 | #define VKI_GDT_ENTRY_TLS_MAX 13 |
| 486 | |
tom | f5e7ee2 | 2005-06-13 08:46:57 +0000 | [diff] [blame] | 487 | //---------------------------------------------------------------------- |
| 488 | // From linux-2.6.11.9/include/asm-x86_64/prctl.h |
| 489 | //---------------------------------------------------------------------- |
| 490 | |
sewardj | f25e902 | 2005-06-09 14:17:47 +0000 | [diff] [blame] | 491 | #define VKI_ARCH_SET_GS 0x1001 |
| 492 | #define VKI_ARCH_SET_FS 0x1002 |
| 493 | #define VKI_ARCH_GET_FS 0x1003 |
| 494 | #define VKI_ARCH_GET_GS 0x1004 |
| 495 | |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 496 | //---------------------------------------------------------------------- |
| 497 | // From linux-2.6.9/include/asm-x86_64/ldt.h |
| 498 | //---------------------------------------------------------------------- |
| 499 | |
| 500 | // I think this LDT stuff will have to be reinstated for amd64, but I'm not |
njn | a22a93a | 2004-11-29 17:28:41 +0000 | [diff] [blame] | 501 | // certain. (Nb: The sys_arch_prctl seems to have replaced |
| 502 | // [gs]et_thread_area syscalls.) |
| 503 | // |
| 504 | // Note that the type here is very slightly different to the |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 505 | // type for x86 (the final 'lm' field is added); I'm not sure about the |
| 506 | // significance of that... --njn |
| 507 | |
| 508 | #if 0 |
| 509 | /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as |
| 510 | to confuse and annoy everyone, this is _not_ the same as an |
| 511 | VgLdtEntry and has to be translated into such. The logic for doing |
| 512 | so, in vg_ldt.c, is copied from the kernel sources.]] */ |
| 513 | struct vki_user_desc { |
| 514 | unsigned int entry_number; |
| 515 | unsigned long base_addr; |
| 516 | unsigned int limit; |
| 517 | unsigned int seg_32bit:1; |
| 518 | unsigned int contents:2; |
| 519 | unsigned int read_exec_only:1; |
| 520 | unsigned int limit_in_pages:1; |
| 521 | unsigned int seg_not_present:1; |
| 522 | unsigned int useable:1; |
| 523 | unsigned int lm:1; |
| 524 | }; |
| 525 | |
| 526 | // [[Nb: for our convenience within Valgrind, use a more specific name]] |
| 527 | typedef struct vki_user_desc vki_modify_ldt_t; |
| 528 | #endif |
| 529 | |
sewardj | 4d89e30 | 2005-03-16 22:04:40 +0000 | [diff] [blame] | 530 | typedef void vki_modify_ldt_t; |
| 531 | |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 532 | //---------------------------------------------------------------------- |
sewardj | b369c5e | 2005-03-24 17:52:02 +0000 | [diff] [blame] | 533 | // From linux-2.6.11.2/include/asm-x86_64/ipcbuf.h |
| 534 | //---------------------------------------------------------------------- |
| 535 | |
| 536 | struct vki_ipc64_perm |
| 537 | { |
| 538 | __vki_kernel_key_t key; |
| 539 | __vki_kernel_uid32_t uid; |
| 540 | __vki_kernel_gid32_t gid; |
| 541 | __vki_kernel_uid32_t cuid; |
| 542 | __vki_kernel_gid32_t cgid; |
| 543 | __vki_kernel_mode_t mode; |
| 544 | unsigned short __pad1; |
| 545 | unsigned short seq; |
| 546 | unsigned short __pad2; |
| 547 | unsigned long __unused1; |
| 548 | unsigned long __unused2; |
| 549 | }; |
| 550 | |
| 551 | //---------------------------------------------------------------------- |
| 552 | // From linux-2.6.11.2/include/asm-x86_64/sembuf.h |
| 553 | //---------------------------------------------------------------------- |
| 554 | |
| 555 | struct vki_semid64_ds { |
| 556 | struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */ |
| 557 | __vki_kernel_time_t sem_otime; /* last semop time */ |
| 558 | unsigned long __unused1; |
| 559 | __vki_kernel_time_t sem_ctime; /* last change time */ |
| 560 | unsigned long __unused2; |
| 561 | unsigned long sem_nsems; /* no. of semaphores in array */ |
| 562 | unsigned long __unused3; |
| 563 | unsigned long __unused4; |
| 564 | }; |
| 565 | |
| 566 | //---------------------------------------------------------------------- |
| 567 | // From linux-2.6.11.2/include/asm-x86_64/msgbuf.h |
| 568 | //---------------------------------------------------------------------- |
| 569 | |
| 570 | struct vki_msqid64_ds { |
| 571 | struct vki_ipc64_perm msg_perm; |
| 572 | __vki_kernel_time_t msg_stime; /* last msgsnd time */ |
| 573 | __vki_kernel_time_t msg_rtime; /* last msgrcv time */ |
| 574 | __vki_kernel_time_t msg_ctime; /* last change time */ |
| 575 | unsigned long msg_cbytes; /* current number of bytes on queue */ |
| 576 | unsigned long msg_qnum; /* number of messages in queue */ |
| 577 | unsigned long msg_qbytes; /* max number of bytes on queue */ |
| 578 | __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */ |
| 579 | __vki_kernel_pid_t msg_lrpid; /* last receive pid */ |
| 580 | unsigned long __unused4; |
| 581 | unsigned long __unused5; |
| 582 | }; |
| 583 | |
| 584 | //---------------------------------------------------------------------- |
| 585 | // From linux-2.6.11.2/include/asm-x86_64/shmbuf.h |
| 586 | //---------------------------------------------------------------------- |
| 587 | |
| 588 | struct vki_shmid64_ds { |
| 589 | struct vki_ipc64_perm shm_perm; /* operation perms */ |
| 590 | vki_size_t shm_segsz; /* size of segment (bytes) */ |
| 591 | __vki_kernel_time_t shm_atime; /* last attach time */ |
| 592 | __vki_kernel_time_t shm_dtime; /* last detach time */ |
| 593 | __vki_kernel_time_t shm_ctime; /* last change time */ |
| 594 | __vki_kernel_pid_t shm_cpid; /* pid of creator */ |
| 595 | __vki_kernel_pid_t shm_lpid; /* pid of last operator */ |
| 596 | unsigned long shm_nattch; /* no. of current attaches */ |
| 597 | unsigned long __unused4; |
| 598 | unsigned long __unused5; |
| 599 | }; |
| 600 | |
| 601 | struct vki_shminfo64 { |
| 602 | unsigned long shmmax; |
| 603 | unsigned long shmmin; |
| 604 | unsigned long shmmni; |
| 605 | unsigned long shmseg; |
| 606 | unsigned long shmall; |
| 607 | unsigned long __unused1; |
| 608 | unsigned long __unused2; |
| 609 | unsigned long __unused3; |
| 610 | unsigned long __unused4; |
| 611 | }; |
| 612 | |
| 613 | //---------------------------------------------------------------------- |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 614 | // And that's it! |
| 615 | //---------------------------------------------------------------------- |
| 616 | |
njn | 4de47b1 | 2005-05-16 03:25:12 +0000 | [diff] [blame] | 617 | #endif // __VKI_AMD64_LINUX_H |
njn | c616819 | 2004-11-29 13:54:10 +0000 | [diff] [blame] | 618 | |
| 619 | /*--------------------------------------------------------------------*/ |
| 620 | /*--- end ---*/ |
| 621 | /*--------------------------------------------------------------------*/ |