nethercote | 73b526f | 2004-10-31 18:48:21 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- x86/Linux-specific kernel interface. x86-linux/vki_arch.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, an extensible x86 protected-mode |
| 8 | emulator for monitoring program execution on x86-Unixes. |
| 9 | |
| 10 | Copyright (C) 2000-2004 Julian Seward |
| 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __X86_LINUX_VKI_ARCH_H |
| 32 | #define __X86_LINUX_VKI_ARCH_H |
| 33 | |
| 34 | // x86 is little-endian. |
| 35 | #define VKI_LITTLE_ENDIAN 1 |
| 36 | |
| 37 | //---------------------------------------------------------------------- |
| 38 | // From linux-2.6.8.1/include/asm-i386/types.h |
| 39 | //---------------------------------------------------------------------- |
| 40 | |
| 41 | typedef unsigned char __vki_u8; |
| 42 | |
| 43 | typedef __signed__ short __vki_s16; |
| 44 | typedef unsigned short __vki_u16; |
| 45 | |
| 46 | typedef unsigned int __vki_u32; |
| 47 | |
| 48 | typedef __signed__ long long __vki_s64; |
| 49 | typedef unsigned long long __vki_u64; |
| 50 | |
| 51 | typedef unsigned short vki_u16; |
| 52 | |
| 53 | //---------------------------------------------------------------------- |
| 54 | // From linux-2.6.8.1/include/asm-i386/page.h |
| 55 | //---------------------------------------------------------------------- |
| 56 | |
| 57 | /* PAGE_SHIFT determines the page size */ |
| 58 | #define VKI_PAGE_SHIFT 12 |
| 59 | #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) |
| 60 | |
| 61 | //---------------------------------------------------------------------- |
| 62 | // From linux-2.6.8.1/include/asm-i386/signal.h |
| 63 | //---------------------------------------------------------------------- |
| 64 | |
| 65 | #define VKI_MINSIGSTKSZ 2048 |
| 66 | |
| 67 | #define VKI_SIG_BLOCK 0 /* for blocking signals */ |
| 68 | #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */ |
| 69 | #define VKI_SIG_SETMASK 2 /* for setting the signal mask */ |
| 70 | |
| 71 | /* Type of a signal handler. */ |
| 72 | typedef void __vki_signalfn_t(int); |
| 73 | typedef __vki_signalfn_t __user *__vki_sighandler_t; |
| 74 | |
| 75 | typedef void __vki_restorefn_t(void); |
| 76 | typedef __vki_restorefn_t __user *__vki_sigrestore_t; |
| 77 | |
| 78 | #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */ |
| 79 | #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */ |
| 80 | |
| 81 | //#ifdef __KERNEL__ |
| 82 | /* Most things should be clean enough to redefine this at will, if care |
| 83 | is taken to make libc match. */ |
| 84 | |
| 85 | #define _VKI_NSIG 64 |
| 86 | #define _VKI_NSIG_BPW 32 |
| 87 | #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW) |
| 88 | |
| 89 | typedef struct { |
| 90 | unsigned long sig[_VKI_NSIG_WORDS]; |
| 91 | } vki_sigset_t; |
| 92 | //#endif |
| 93 | |
| 94 | #define VKI_SIGHUP 1 |
| 95 | #define VKI_SIGINT 2 |
| 96 | #define VKI_SIGQUIT 3 |
| 97 | #define VKI_SIGILL 4 |
| 98 | #define VKI_SIGTRAP 5 |
| 99 | #define VKI_SIGABRT 6 |
| 100 | //#define VKI_SIGIOT 6 |
| 101 | #define VKI_SIGBUS 7 |
| 102 | #define VKI_SIGFPE 8 |
| 103 | #define VKI_SIGKILL 9 |
| 104 | #define VKI_SIGUSR1 10 |
| 105 | #define VKI_SIGSEGV 11 |
| 106 | #define VKI_SIGUSR2 12 |
| 107 | #define VKI_SIGPIPE 13 |
| 108 | #define VKI_SIGALRM 14 |
| 109 | #define VKI_SIGTERM 15 |
| 110 | #define VKI_SIGSTKFLT 16 |
| 111 | #define VKI_SIGCHLD 17 |
| 112 | #define VKI_SIGCONT 18 |
| 113 | #define VKI_SIGSTOP 19 |
| 114 | #define VKI_SIGTSTP 20 |
| 115 | #define VKI_SIGTTIN 21 |
| 116 | #define VKI_SIGTTOU 22 |
| 117 | #define VKI_SIGURG 23 |
| 118 | #define VKI_SIGXCPU 24 |
| 119 | #define VKI_SIGXFSZ 25 |
| 120 | #define VKI_SIGVTALRM 26 |
| 121 | #define VKI_SIGPROF 27 |
| 122 | #define VKI_SIGWINCH 28 |
| 123 | #define VKI_SIGIO 29 |
| 124 | #define VKI_SIGPWR 30 |
| 125 | #define VKI_SIGSYS 31 |
| 126 | #define VKI_SIGUNUSED 31 |
| 127 | |
| 128 | /* These should not be considered constants from userland. */ |
| 129 | #define VKI_SIGRTMIN 32 |
| 130 | // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]] |
| 131 | #define VKI_SIGRTMAX _VKI_NSIG |
| 132 | |
| 133 | #define VKI_SIGVGINT (VKI_SIGRTMIN+0) // [[internal: interrupt]] |
| 134 | #define VKI_SIGVGKILL (VKI_SIGRTMIN+1) // [[internal: kill]] |
| 135 | #define VKI_SIGVGRTUSERMIN (VKI_SIGRTMIN+2) // [[internal: first |
| 136 | // user-usable RT signal]] |
| 137 | |
| 138 | #define VKI_SA_NOCLDSTOP 0x00000001u |
| 139 | #define VKI_SA_NOCLDWAIT 0x00000002u |
| 140 | #define VKI_SA_SIGINFO 0x00000004u |
| 141 | #define VKI_SA_ONSTACK 0x08000000u |
| 142 | #define VKI_SA_RESTART 0x10000000u |
| 143 | #define VKI_SA_NODEFER 0x40000000u |
| 144 | #define VKI_SA_RESETHAND 0x80000000u |
| 145 | |
| 146 | #define VKI_SA_NOMASK VKI_SA_NODEFER |
| 147 | #define VKI_SA_ONESHOT VKI_SA_RESETHAND |
| 148 | //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */ |
| 149 | |
| 150 | #define VKI_SA_RESTORER 0x04000000 |
| 151 | |
| 152 | #define VKI_SS_ONSTACK 1 |
| 153 | #define VKI_SS_DISABLE 2 |
| 154 | |
| 155 | struct vki_sigaction { |
| 156 | // [[Nb: a 'k' prefix is added to "sa_handler" because |
| 157 | // bits/sigaction.h (which gets dragged in somehow via signal.h) |
| 158 | // #defines it as something else. Since that is done for glibc's |
| 159 | // purposes, which we don't care about here, we use our own name.]] |
| 160 | __vki_sighandler_t ksa_handler; |
| 161 | unsigned long sa_flags; |
| 162 | __vki_sigrestore_t sa_restorer; |
| 163 | vki_sigset_t sa_mask; /* mask last for extensibility */ |
| 164 | }; |
| 165 | |
| 166 | typedef struct vki_sigaltstack { |
| 167 | void __user *ss_sp; |
| 168 | int ss_flags; |
| 169 | vki_size_t ss_size; |
| 170 | } vki_stack_t; |
| 171 | |
| 172 | //---------------------------------------------------------------------- |
| 173 | // From linux-2.6.8.1/include/asm-i386/sigcontext.h |
| 174 | //---------------------------------------------------------------------- |
| 175 | |
| 176 | struct _vki_fpreg { |
| 177 | unsigned short significand[4]; |
| 178 | unsigned short exponent; |
| 179 | }; |
| 180 | |
| 181 | struct _vki_fpxreg { |
| 182 | unsigned short significand[4]; |
| 183 | unsigned short exponent; |
| 184 | unsigned short padding[3]; |
| 185 | }; |
| 186 | |
| 187 | struct _vki_xmmreg { |
| 188 | unsigned long element[4]; |
| 189 | }; |
| 190 | |
| 191 | struct _vki_fpstate { |
| 192 | /* Regular FPU environment */ |
| 193 | unsigned long cw; |
| 194 | unsigned long sw; |
| 195 | unsigned long tag; |
| 196 | unsigned long ipoff; |
| 197 | unsigned long cssel; |
| 198 | unsigned long dataoff; |
| 199 | unsigned long datasel; |
| 200 | struct _vki_fpreg _st[8]; |
| 201 | unsigned short status; |
| 202 | unsigned short magic; /* 0xffff = regular FPU data only */ |
| 203 | |
| 204 | /* FXSR FPU environment */ |
| 205 | unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ |
| 206 | unsigned long mxcsr; |
| 207 | unsigned long reserved; |
| 208 | struct _vki_fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ |
| 209 | struct _vki_xmmreg _xmm[8]; |
| 210 | unsigned long padding[56]; |
| 211 | }; |
| 212 | |
| 213 | struct vki_sigcontext { |
| 214 | unsigned short gs, __gsh; |
| 215 | unsigned short fs, __fsh; |
| 216 | unsigned short es, __esh; |
| 217 | unsigned short ds, __dsh; |
| 218 | unsigned long edi; |
| 219 | unsigned long esi; |
| 220 | unsigned long ebp; |
| 221 | unsigned long esp; |
| 222 | unsigned long ebx; |
| 223 | unsigned long edx; |
| 224 | unsigned long ecx; |
| 225 | unsigned long eax; |
| 226 | unsigned long trapno; |
| 227 | unsigned long err; |
| 228 | unsigned long eip; |
| 229 | unsigned short cs, __csh; |
| 230 | unsigned long eflags; |
| 231 | unsigned long esp_at_signal; |
| 232 | unsigned short ss, __ssh; |
| 233 | struct _vki_fpstate __user * fpstate; |
| 234 | unsigned long oldmask; |
| 235 | unsigned long cr2; |
| 236 | }; |
| 237 | |
| 238 | //---------------------------------------------------------------------- |
| 239 | // From linux-2.6.8.1/include/asm-i386/mman.h |
| 240 | //---------------------------------------------------------------------- |
| 241 | |
| 242 | //#define VKI_PROT_NONE 0x0 /* No page permissions */ |
| 243 | #define VKI_PROT_READ 0x1 /* page can be read */ |
| 244 | #define VKI_PROT_WRITE 0x2 /* page can be written */ |
| 245 | #define VKI_PROT_EXEC 0x4 /* page can be executed */ |
| 246 | |
| 247 | #define VKI_MAP_SHARED 0x01 /* Share changes */ |
| 248 | #define VKI_MAP_PRIVATE 0x02 /* Changes are private */ |
| 249 | //#define VKI_MAP_TYPE 0x0f /* Mask for type of mapping */ |
| 250 | #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */ |
| 251 | #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */ |
| 252 | |
| 253 | //---------------------------------------------------------------------- |
| 254 | // From linux-2.6.8.1/include/asm-i386/fcntl.h |
| 255 | //---------------------------------------------------------------------- |
| 256 | |
| 257 | #define VKI_O_RDONLY 00 |
| 258 | #define VKI_O_WRONLY 01 |
| 259 | #define VKI_O_CREAT 0100 /* not fcntl */ |
| 260 | #define VKI_O_EXCL 0200 /* not fcntl */ |
| 261 | #define VKI_O_TRUNC 01000 /* not fcntl */ |
| 262 | #define VKI_O_NONBLOCK 04000 |
| 263 | |
| 264 | #define VKI_F_DUPFD 0 /* dup */ |
| 265 | //#define VKI_F_GETFD 1 /* get close_on_exec */ |
| 266 | #define VKI_F_SETFD 2 /* set/clear close_on_exec */ |
| 267 | #define VKI_F_GETFL 3 /* get file->f_flags */ |
| 268 | #define VKI_F_SETFL 4 /* set file->f_flags */ |
| 269 | //#define VKI_F_GETLK 5 |
| 270 | //#define VKI_F_SETLK 6 |
| 271 | #define VKI_F_SETLKW 7 |
| 272 | |
| 273 | #define VKI_F_SETLKW64 14 |
| 274 | |
| 275 | /* for F_[GET|SET]FL */ |
| 276 | #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */ |
| 277 | |
| 278 | |
| 279 | //---------------------------------------------------------------------- |
| 280 | // From linux-2.6.8.1/include/asm-i386/resource.h |
| 281 | //---------------------------------------------------------------------- |
| 282 | |
| 283 | #define VKI_RLIMIT_DATA 2 /* max data size */ |
| 284 | #define VKI_RLIMIT_STACK 3 /* max stack size */ |
| 285 | #define VKI_RLIMIT_CORE 4 /* max core file size */ |
| 286 | #define VKI_RLIMIT_NOFILE 7 /* max number of open files */ |
| 287 | |
| 288 | //---------------------------------------------------------------------- |
| 289 | // From linux-2.6.8.1/include/asm-i386/socket.h |
| 290 | //---------------------------------------------------------------------- |
| 291 | |
| 292 | #define VKI_SOL_SOCKET 1 |
| 293 | |
| 294 | #define VKI_SO_TYPE 3 |
| 295 | |
| 296 | #define VKI_SOCK_STREAM 1 /* stream (connection) socket */ |
| 297 | |
| 298 | //---------------------------------------------------------------------- |
| 299 | // From linux-2.6.8.1/include/asm-i386/sockios.h |
| 300 | //---------------------------------------------------------------------- |
| 301 | |
| 302 | #define VKI_SIOCSPGRP 0x8902 |
| 303 | #define VKI_SIOCGPGRP 0x8904 |
| 304 | #define VKI_SIOCGSTAMP 0x8906 /* Get stamp */ |
| 305 | |
| 306 | //---------------------------------------------------------------------- |
| 307 | // From linux-2.6.8.1/include/asm-i386/stat.h |
| 308 | //---------------------------------------------------------------------- |
| 309 | |
| 310 | struct vki_stat { |
| 311 | unsigned long st_dev; |
| 312 | unsigned long st_ino; |
| 313 | unsigned short st_mode; |
| 314 | unsigned short st_nlink; |
| 315 | unsigned short st_uid; |
| 316 | unsigned short st_gid; |
| 317 | unsigned long st_rdev; |
| 318 | unsigned long st_size; |
| 319 | unsigned long st_blksize; |
| 320 | unsigned long st_blocks; |
| 321 | unsigned long st_atime; |
| 322 | unsigned long st_atime_nsec; |
| 323 | unsigned long st_mtime; |
| 324 | unsigned long st_mtime_nsec; |
| 325 | unsigned long st_ctime; |
| 326 | unsigned long st_ctime_nsec; |
| 327 | unsigned long __unused4; |
| 328 | unsigned long __unused5; |
| 329 | }; |
| 330 | |
| 331 | struct vki_stat64 { |
| 332 | unsigned long long st_dev; |
| 333 | unsigned char __pad0[4]; |
| 334 | |
| 335 | #define STAT64_HAS_BROKEN_ST_INO 1 |
| 336 | unsigned long __st_ino; |
| 337 | |
| 338 | unsigned int st_mode; |
| 339 | unsigned int st_nlink; |
| 340 | |
| 341 | unsigned long st_uid; |
| 342 | unsigned long st_gid; |
| 343 | |
| 344 | unsigned long long st_rdev; |
| 345 | unsigned char __pad3[4]; |
| 346 | |
| 347 | long long st_size; |
| 348 | unsigned long st_blksize; |
| 349 | |
| 350 | unsigned long st_blocks; /* Number 512-byte blocks allocated. */ |
| 351 | unsigned long __pad4; /* future possible st_blocks high bits */ |
| 352 | |
| 353 | unsigned long st_atime; |
| 354 | unsigned long st_atime_nsec; |
| 355 | |
| 356 | unsigned long st_mtime; |
| 357 | unsigned int st_mtime_nsec; |
| 358 | |
| 359 | unsigned long st_ctime; |
| 360 | unsigned long st_ctime_nsec; |
| 361 | |
| 362 | unsigned long long st_ino; |
| 363 | }; |
| 364 | |
| 365 | //---------------------------------------------------------------------- |
| 366 | // From linux-2.6.8.1/include/asm-i386/statfs.h |
| 367 | //---------------------------------------------------------------------- |
| 368 | |
| 369 | struct vki_statfs { |
| 370 | __vki_u32 f_type; |
| 371 | __vki_u32 f_bsize; |
| 372 | __vki_u32 f_blocks; |
| 373 | __vki_u32 f_bfree; |
| 374 | __vki_u32 f_bavail; |
| 375 | __vki_u32 f_files; |
| 376 | __vki_u32 f_ffree; |
| 377 | __vki_kernel_fsid_t f_fsid; |
| 378 | __vki_u32 f_namelen; |
| 379 | __vki_u32 f_frsize; |
| 380 | __vki_u32 f_spare[5]; |
| 381 | }; |
| 382 | |
| 383 | //---------------------------------------------------------------------- |
| 384 | // From linux-2.6.8.1/include/asm-i386/termios.h |
| 385 | //---------------------------------------------------------------------- |
| 386 | |
| 387 | struct vki_winsize { |
| 388 | unsigned short ws_row; |
| 389 | unsigned short ws_col; |
| 390 | unsigned short ws_xpixel; |
| 391 | unsigned short ws_ypixel; |
| 392 | }; |
| 393 | |
| 394 | #define VKI_NCC 8 |
| 395 | struct vki_termio { |
| 396 | unsigned short c_iflag; /* input mode flags */ |
| 397 | unsigned short c_oflag; /* output mode flags */ |
| 398 | unsigned short c_cflag; /* control mode flags */ |
| 399 | unsigned short c_lflag; /* local mode flags */ |
| 400 | unsigned char c_line; /* line discipline */ |
| 401 | unsigned char c_cc[VKI_NCC]; /* control characters */ |
| 402 | }; |
| 403 | |
| 404 | |
| 405 | //---------------------------------------------------------------------- |
| 406 | // From linux-2.6.8.1/include/asm-i386/termbits.h |
| 407 | //---------------------------------------------------------------------- |
| 408 | |
nethercote | 017e583 | 2004-11-01 16:22:00 +0000 | [diff] [blame^] | 409 | typedef unsigned char vki_cc_t; |
| 410 | typedef unsigned int vki_tcflag_t; |
| 411 | |
| 412 | #define VKI_NCCS 19 |
| 413 | struct vki_termios { |
| 414 | vki_tcflag_t c_iflag; /* input mode flags */ |
| 415 | vki_tcflag_t c_oflag; /* output mode flags */ |
| 416 | vki_tcflag_t c_cflag; /* control mode flags */ |
| 417 | vki_tcflag_t c_lflag; /* local mode flags */ |
| 418 | vki_cc_t c_line; /* line discipline */ |
| 419 | vki_cc_t c_cc[VKI_NCCS]; /* control characters */ |
| 420 | }; |
nethercote | 73b526f | 2004-10-31 18:48:21 +0000 | [diff] [blame] | 421 | |
| 422 | //---------------------------------------------------------------------- |
| 423 | // From linux-2.6.8.1/include/asm-i386/ioctl.h |
| 424 | //---------------------------------------------------------------------- |
| 425 | |
| 426 | #define _VKI_IOC_NRBITS 8 |
| 427 | #define _VKI_IOC_TYPEBITS 8 |
| 428 | #define _VKI_IOC_SIZEBITS 14 |
| 429 | #define _VKI_IOC_DIRBITS 2 |
| 430 | |
| 431 | #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1) |
| 432 | #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1) |
| 433 | |
| 434 | #define _VKI_IOC_NRSHIFT 0 |
| 435 | #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) |
| 436 | #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) |
| 437 | #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) |
| 438 | |
| 439 | #define _VKI_IOC_NONE 0U |
| 440 | #define _VKI_IOC_WRITE 1U |
| 441 | #define _VKI_IOC_READ 2U |
| 442 | |
| 443 | #define _VKI_IOC(dir,type,nr,size) \ |
| 444 | (((dir) << _VKI_IOC_DIRSHIFT) | \ |
| 445 | ((type) << _VKI_IOC_TYPESHIFT) | \ |
| 446 | ((nr) << _VKI_IOC_NRSHIFT) | \ |
| 447 | ((size) << _VKI_IOC_SIZESHIFT)) |
| 448 | |
| 449 | /* provoke compile error for invalid uses of size argument */ |
| 450 | extern unsigned int __vki_invalid_size_argument_for_IOC; |
| 451 | #define _VKI_IOC_TYPECHECK(t) \ |
| 452 | ((sizeof(t) == sizeof(t[1]) && \ |
| 453 | sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ |
| 454 | sizeof(t) : __vki_invalid_size_argument_for_IOC) |
| 455 | |
| 456 | /* used to create numbers */ |
| 457 | #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) |
| 458 | #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) |
| 459 | #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) |
| 460 | #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) |
| 461 | |
| 462 | /* used to decode ioctl numbers.. */ |
| 463 | #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) |
| 464 | #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) |
| 465 | |
| 466 | //---------------------------------------------------------------------- |
| 467 | // From linux-2.6.8.1/include/asm-i386/ioctls.h |
| 468 | //---------------------------------------------------------------------- |
| 469 | |
| 470 | #define VKI_TCGETS 0x5401 |
| 471 | #define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ |
| 472 | #define VKI_TCSETSW 0x5403 |
| 473 | #define VKI_TCSETSF 0x5404 |
| 474 | #define VKI_TCGETA 0x5405 |
| 475 | #define VKI_TCSETA 0x5406 |
| 476 | #define VKI_TCSETAW 0x5407 |
| 477 | #define VKI_TCSETAF 0x5408 |
| 478 | #define VKI_TCSBRK 0x5409 |
| 479 | #define VKI_TCXONC 0x540A |
| 480 | #define VKI_TCFLSH 0x540B |
| 481 | #define VKI_TIOCSCTTY 0x540E |
| 482 | #define VKI_TIOCGPGRP 0x540F |
| 483 | #define VKI_TIOCSPGRP 0x5410 |
| 484 | #define VKI_TIOCOUTQ 0x5411 |
| 485 | #define VKI_TIOCGWINSZ 0x5413 |
| 486 | #define VKI_TIOCSWINSZ 0x5414 |
| 487 | #define VKI_TIOCMBIS 0x5416 |
| 488 | #define VKI_TIOCMBIC 0x5417 |
| 489 | #define VKI_TIOCMSET 0x5418 |
| 490 | #define VKI_FIONREAD 0x541B |
| 491 | #define VKI_TIOCLINUX 0x541C |
| 492 | #define VKI_FIONBIO 0x5421 |
| 493 | #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ |
| 494 | #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ |
| 495 | #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ |
| 496 | |
| 497 | #define VKI_FIOASYNC 0x5452 |
| 498 | |
| 499 | //---------------------------------------------------------------------- |
| 500 | // From linux-2.6.8.1/include/asm-i386/poll.h |
| 501 | //---------------------------------------------------------------------- |
| 502 | |
| 503 | /* These are specified by iBCS2 */ |
| 504 | #define VKI_POLLIN 0x0001 |
| 505 | |
| 506 | struct vki_pollfd { |
| 507 | int fd; |
| 508 | short events; |
| 509 | short revents; |
| 510 | }; |
| 511 | |
| 512 | //---------------------------------------------------------------------- |
| 513 | // From linux-2.6.8.1/include/asm-i386/user.h |
| 514 | //---------------------------------------------------------------------- |
| 515 | |
| 516 | struct vki_user_i387_struct { |
| 517 | long cwd; |
| 518 | long swd; |
| 519 | long twd; |
| 520 | long fip; |
| 521 | long fcs; |
| 522 | long foo; |
| 523 | long fos; |
| 524 | long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ |
| 525 | }; |
| 526 | |
| 527 | struct vki_user_fxsr_struct { |
| 528 | unsigned short cwd; |
| 529 | unsigned short swd; |
| 530 | unsigned short twd; |
| 531 | unsigned short fop; |
| 532 | long fip; |
| 533 | long fcs; |
| 534 | long foo; |
| 535 | long fos; |
| 536 | long mxcsr; |
| 537 | long reserved; |
| 538 | long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ |
| 539 | long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ |
| 540 | long padding[56]; |
| 541 | }; |
| 542 | |
| 543 | /* |
| 544 | * This is the old layout of "struct pt_regs", and |
| 545 | * is still the layout used by user mode (the new |
| 546 | * pt_regs doesn't have all registers as the kernel |
| 547 | * doesn't use the extra segment registers) |
| 548 | */ |
| 549 | struct vki_user_regs_struct { |
| 550 | long ebx, ecx, edx, esi, edi, ebp, eax; |
| 551 | unsigned short ds, __ds, es, __es; |
| 552 | unsigned short fs, __fs, gs, __gs; |
| 553 | long orig_eax, eip; |
| 554 | unsigned short cs, __cs; |
| 555 | long eflags, esp; |
| 556 | unsigned short ss, __ss; |
| 557 | }; |
| 558 | |
| 559 | //---------------------------------------------------------------------- |
| 560 | // From linux-2.6.8.1/include/asm-i386/elf.h |
| 561 | //---------------------------------------------------------------------- |
| 562 | |
| 563 | typedef unsigned long vki_elf_greg_t; |
| 564 | |
| 565 | #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) |
| 566 | typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; |
| 567 | |
| 568 | typedef struct vki_user_i387_struct vki_elf_fpregset_t; |
| 569 | typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t; |
| 570 | |
| 571 | #define VKI_AT_SYSINFO 32 |
| 572 | |
| 573 | //---------------------------------------------------------------------- |
| 574 | // From linux-2.6.8.1/include/asm-i386/ucontext.h |
| 575 | //---------------------------------------------------------------------- |
| 576 | |
| 577 | struct vki_ucontext { |
| 578 | unsigned long uc_flags; |
| 579 | struct vki_ucontext *uc_link; |
| 580 | vki_stack_t uc_stack; |
| 581 | struct vki_sigcontext uc_mcontext; |
| 582 | vki_sigset_t uc_sigmask; /* mask last for extensibility */ |
| 583 | }; |
| 584 | |
| 585 | //---------------------------------------------------------------------- |
| 586 | // From linux-2.6.8.1/include/asm-i386/segment.h |
| 587 | //---------------------------------------------------------------------- |
| 588 | |
| 589 | #define VKI_GDT_ENTRY_TLS_ENTRIES 3 |
| 590 | #define VKI_GDT_ENTRY_TLS_MIN 6 |
| 591 | #define VKI_GDT_ENTRY_TLS_MAX (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1) |
| 592 | |
| 593 | //---------------------------------------------------------------------- |
| 594 | // From linux-2.6.8.1/include/asm-i386/ldt.h |
| 595 | //---------------------------------------------------------------------- |
| 596 | |
| 597 | /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as |
| 598 | to confuse and annoy everyone, this is _not_ the same as an |
| 599 | VgLdtEntry and has to be translated into such. The logic for doing |
| 600 | so, in vg_ldt.c, is copied from the kernel sources.]] */ |
| 601 | struct vki_user_desc { |
| 602 | unsigned int entry_number; |
| 603 | unsigned long base_addr; |
| 604 | unsigned int limit; |
| 605 | unsigned int seg_32bit:1; |
| 606 | unsigned int contents:2; |
| 607 | unsigned int read_exec_only:1; |
| 608 | unsigned int limit_in_pages:1; |
| 609 | unsigned int seg_not_present:1; |
| 610 | unsigned int useable:1; |
| 611 | // [[Nb: this field is not in the kernel sources, but it has always |
| 612 | // been in the Valgrind sources so I will keep it there in case it's |
| 613 | // important... this is an x86-defined data structure so who |
| 614 | // knows; maybe it's important to set this field to zero at some |
| 615 | // point. --njn]] |
| 616 | unsigned int reserved:25; |
| 617 | }; |
| 618 | |
| 619 | // [[Nb: for our convenience within Valgrind, use a more specific name]] |
| 620 | typedef struct vki_user_desc vki_modify_ldt_t; |
| 621 | |
| 622 | //---------------------------------------------------------------------- |
| 623 | // From linux-2.6.8.1/include/asm-i386/ipcbuf.h |
| 624 | //---------------------------------------------------------------------- |
| 625 | |
| 626 | struct vki_ipc64_perm |
| 627 | { |
| 628 | __vki_kernel_key_t key; |
| 629 | __vki_kernel_uid32_t uid; |
| 630 | __vki_kernel_gid32_t gid; |
| 631 | __vki_kernel_uid32_t cuid; |
| 632 | __vki_kernel_gid32_t cgid; |
| 633 | __vki_kernel_mode_t mode; |
| 634 | unsigned short __pad1; |
| 635 | unsigned short seq; |
| 636 | unsigned short __pad2; |
| 637 | unsigned long __unused1; |
| 638 | unsigned long __unused2; |
| 639 | }; |
| 640 | |
| 641 | //---------------------------------------------------------------------- |
| 642 | // From linux-2.6.8.1/include/asm-i386/sembuf.h |
| 643 | //---------------------------------------------------------------------- |
| 644 | |
| 645 | struct vki_semid64_ds { |
| 646 | struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */ |
| 647 | __vki_kernel_time_t sem_otime; /* last semop time */ |
| 648 | unsigned long __unused1; |
| 649 | __vki_kernel_time_t sem_ctime; /* last change time */ |
| 650 | unsigned long __unused2; |
| 651 | unsigned long sem_nsems; /* no. of semaphores in array */ |
| 652 | unsigned long __unused3; |
| 653 | unsigned long __unused4; |
| 654 | }; |
| 655 | |
| 656 | //---------------------------------------------------------------------- |
| 657 | // From linux-2.6.8.1/include/asm-i386/msgbuf.h |
| 658 | //---------------------------------------------------------------------- |
| 659 | |
| 660 | struct vki_msqid64_ds { |
| 661 | struct vki_ipc64_perm msg_perm; |
| 662 | __vki_kernel_time_t msg_stime; /* last msgsnd time */ |
| 663 | unsigned long __unused1; |
| 664 | __vki_kernel_time_t msg_rtime; /* last msgrcv time */ |
| 665 | unsigned long __unused2; |
| 666 | __vki_kernel_time_t msg_ctime; /* last change time */ |
| 667 | unsigned long __unused3; |
| 668 | unsigned long msg_cbytes; /* current number of bytes on queue */ |
| 669 | unsigned long msg_qnum; /* number of messages in queue */ |
| 670 | unsigned long msg_qbytes; /* max number of bytes on queue */ |
| 671 | __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */ |
| 672 | __vki_kernel_pid_t msg_lrpid; /* last receive pid */ |
| 673 | unsigned long __unused4; |
| 674 | unsigned long __unused5; |
| 675 | }; |
| 676 | |
| 677 | //---------------------------------------------------------------------- |
| 678 | // From linux-2.6.8.1/include/asm-i386/ipc.h |
| 679 | //---------------------------------------------------------------------- |
| 680 | |
| 681 | struct vki_ipc_kludge { |
| 682 | struct vki_msgbuf __user *msgp; |
| 683 | long msgtyp; |
| 684 | }; |
| 685 | |
| 686 | //---------------------------------------------------------------------- |
| 687 | // From linux-2.6.8.1/include/asm-i386/shmbuf.h |
| 688 | //---------------------------------------------------------------------- |
| 689 | |
| 690 | struct vki_shmid64_ds { |
| 691 | struct vki_ipc64_perm shm_perm; /* operation perms */ |
| 692 | vki_size_t shm_segsz; /* size of segment (bytes) */ |
| 693 | __vki_kernel_time_t shm_atime; /* last attach time */ |
| 694 | unsigned long __unused1; |
| 695 | __vki_kernel_time_t shm_dtime; /* last detach time */ |
| 696 | unsigned long __unused2; |
| 697 | __vki_kernel_time_t shm_ctime; /* last change time */ |
| 698 | unsigned long __unused3; |
| 699 | __vki_kernel_pid_t shm_cpid; /* pid of creator */ |
| 700 | __vki_kernel_pid_t shm_lpid; /* pid of last operator */ |
| 701 | unsigned long shm_nattch; /* no. of current attaches */ |
| 702 | unsigned long __unused4; |
| 703 | unsigned long __unused5; |
| 704 | }; |
| 705 | |
| 706 | struct vki_shminfo64 { |
| 707 | unsigned long shmmax; |
| 708 | unsigned long shmmin; |
| 709 | unsigned long shmmni; |
| 710 | unsigned long shmseg; |
| 711 | unsigned long shmall; |
| 712 | unsigned long __unused1; |
| 713 | unsigned long __unused2; |
| 714 | unsigned long __unused3; |
| 715 | unsigned long __unused4; |
| 716 | }; |
| 717 | |
| 718 | //---------------------------------------------------------------------- |
| 719 | // From linux-2.6.8.1/include/linux/module.h |
| 720 | //---------------------------------------------------------------------- |
| 721 | |
| 722 | // [[This VKI_SIZEOF_* value is arch-specific, because it depends on the |
| 723 | // word size. The values are really guesses, but they are only needed for |
| 724 | // init_module() which is very rare]] |
| 725 | |
| 726 | #if defined(KERNEL_2_2) || defined(KERNEL_2_4) |
| 727 | // [[This is actually an over-estimate; only 60 bytes are mandated.]] |
| 728 | # define VKI_SIZEOF_STRUCT_MODULE 96 |
| 729 | #else |
| 730 | // [[This is a conservative guesstimate; it can be longer, depending on |
| 731 | // certain #ifdefs. Close enough.]] |
| 732 | # define VKI_SIZEOF_STRUCT_MODULE 160 |
| 733 | #endif |
| 734 | |
| 735 | //---------------------------------------------------------------------- |
| 736 | // And that's it! |
| 737 | //---------------------------------------------------------------------- |
| 738 | |
| 739 | #endif // __X86_LINUX_VKI_ARCH_H |
| 740 | |
| 741 | /*--------------------------------------------------------------------*/ |
| 742 | /*--- end ---*/ |
| 743 | /*--------------------------------------------------------------------*/ |