1 2 /*--------------------------------------------------------------------*/ 3 /*--- mips/Linux-specific kernel interface. vki-mips32-linux.h ---*/ 4 /*--------------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2010-2012 RT-RK 11 mips-valgrind (at) rt-rk.com 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 __VKI_MIPS32_LINUX_H 32 #define __VKI_MIPS32_LINUX_H 33 34 #include <config.h> 35 36 // mips endian 37 #if defined (_MIPSEL) 38 #define VKI_LITTLE_ENDIAN 1 39 #elif defined (_MIPSEB) 40 #define VKI_BIG_ENDIAN 1 41 #endif 42 43 44 //---------------------------------------------------------------------- 45 // From linux-2.6.35.5/include/asm-generic/int-ll64.h 46 //---------------------------------------------------------------------- 47 48 typedef __signed__ char __vki_s8; 49 typedef unsigned char __vki_u8; 50 51 typedef __signed__ short __vki_s16; 52 typedef unsigned short __vki_u16; 53 54 typedef __signed__ int __vki_s32; 55 typedef unsigned int __vki_u32; 56 57 typedef __signed char vki_s8; 58 typedef unsigned char vki_u8; 59 60 typedef __signed short vki_s16; 61 typedef unsigned short vki_u16; 62 63 typedef __signed int vki_s32; 64 typedef unsigned int vki_u32; 65 66 typedef __signed__ long long __vki_s64; 67 typedef unsigned long long __vki_u64; 68 69 70 //---------------------------------------------------------------------- 71 // From linux-2.6.35.5/include/asm-mips/page.h 72 //---------------------------------------------------------------------- 73 74 /* PAGE_SHIFT determines the page size */ 75 #define VKI_PAGE_SHIFT MIPS_PAGE_SHIFT 76 #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) 77 #define VKI_PAGE_MASK (~(VKI_PAGE_SIZE-1)) 78 #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT 79 #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE 80 81 //---------------------------------------------------------------------- 82 // From linux-2.6.35.5/arch/mips/include/asm-generic/shmparam.h 83 //---------------------------------------------------------------------- 84 85 #define VKI_SHMLBA SHM_ALIGNMENT 86 87 //---------------------------------------------------------------------- 88 // From linux-2.6.35.5/include/asm/signal.h 89 //---------------------------------------------------------------------- 90 91 #define VKI_MINSIGSTKSZ 2048 92 93 #define VKI_SIG_BLOCK 1 /* for blocking signals */ 94 #define VKI_SIG_UNBLOCK 2 /* for unblocking signals */ 95 #define VKI_SIG_SETMASK 3 /* for setting the signal mask */ 96 97 /* Type of a signal handler. */ 98 typedef void __vki_signalfn_t(int); 99 typedef __vki_signalfn_t __user *__vki_sighandler_t; 100 101 typedef void __vki_restorefn_t(void); 102 typedef __vki_restorefn_t __user *__vki_sigrestore_t; 103 104 #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */ 105 #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */ 106 107 #define _VKI_NSIG 128 108 #define _VKI_NSIG_BPW 32 109 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW) 110 111 typedef unsigned long vki_old_sigset_t; /* at least 32 bits */ 112 113 typedef struct { 114 unsigned long sig[_VKI_NSIG_WORDS]; 115 } vki_sigset_t; 116 117 #define VKI_SIGHUP 1 /* Hangup (POSIX). */ 118 #define VKI_SIGINT 2 /* Interrupt (ANSI). */ 119 #define VKI_SIGQUIT 3 /* Quit (POSIX). */ 120 #define VKI_SIGILL 4 /* Illegal instruction (ANSI). */ 121 #define VKI_SIGTRAP 5 /* Trace trap (POSIX). */ 122 #define VKI_SIGIOT 6 /* IOT trap (4.2 BSD). */ 123 #define VKI_SIGABRT VKI_SIGIOT /* Abort (ANSI). */ 124 #define VKI_SIGEMT 7 125 #define VKI_SIGFPE 8 /* Floating-point exception (ANSI). */ 126 #define VKI_SIGKILL 9 /* Kill, unblockable (POSIX). */ 127 #define VKI_SIGBUS 10 /* BUS error (4.2 BSD). */ 128 #define VKI_SIGSEGV 11 /* Segmentation violation (ANSI). */ 129 #define VKI_SIGSYS 12 130 #define VKI_SIGPIPE 13 /* Broken pipe (POSIX). */ 131 #define VKI_SIGALRM 14 /* Alarm clock (POSIX). */ 132 #define VKI_SIGTERM 15 /* Termination (ANSI). */ 133 #define VKI_SIGUSR1 16 /* User-defined signal 1 (POSIX). */ 134 #define VKI_SIGUSR2 17 /* User-defined signal 2 (POSIX). */ 135 #define VKI_SIGCHLD 18 /* Child status has changed (POSIX). */ 136 #define VKI_SIGCLD VKI_SIGCHLD /* Same as SIGCHLD (System V). */ 137 #define VKI_SIGPWR 19 /* Power failure restart (System V). */ 138 #define VKI_SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */ 139 #define VKI_SIGURG 21 /* Urgent condition on socket (4.2 BSD). */ 140 #define VKI_SIGIO 22 /* I/O now possible (4.2 BSD). */ 141 #define VKI_SIGPOLL VKI_SIGIO /* Pollable event occurred (System V). */ 142 #define VKI_SIGSTOP 23 /* Stop, unblockable (POSIX). */ 143 #define VKI_SIGTSTP 24 /* Keyboard stop (POSIX). */ 144 #define VKI_SIGCONT 25 /* Continue (POSIX). */ 145 #define VKI_SIGTTIN 26 /* Background read from tty (POSIX). */ 146 #define VKI_SIGTTOU 27 /* Background write to tty (POSIX). */ 147 #define VKI_SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */ 148 #define VKI_SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */ 149 #define VKI_SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */ 150 #define VKI_SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */ 151 152 /* These should not be considered constants from userland. */ 153 #define VKI_SIGRTMIN 32 154 // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]] 155 #define VKI_SIGRTMAX _VKI_NSIG 156 157 #define VKI_SA_ONSTACK 0x08000000 158 #define VKI_SA_RESETHAND 0x80000000 159 #define VKI_SA_RESTART 0x10000000 160 #define VKI_SA_SIGINFO 0x00000008 161 #define VKI_SA_NODEFER 0x40000000 162 #define VKI_SA_NOCLDWAIT 0x00010000 163 #define VKI_SA_NOCLDSTOP 0x00000001 164 165 #define VKI_SA_NOMASK VKI_SA_NODEFER 166 #define VKI_SA_ONESHOT VKI_SA_RESETHAND 167 //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */ 168 169 #define VKI_SA_RESTORER 0x04000000 170 171 #define VKI_SS_ONSTACK 1 172 #define VKI_SS_DISABLE 2 173 174 struct vki_old_sigaction { 175 // [[Nb: a 'k' prefix is added to "sa_handler" because 176 // bits/sigaction.h (which gets dragged in somehow via signal.h) 177 // #defines it as something else. Since that is done for glibc's 178 // purposes, which we don't care about here, we use our own name.]] 179 unsigned long sa_flags; 180 __vki_sighandler_t ksa_handler; 181 vki_old_sigset_t sa_mask; 182 __vki_sigrestore_t sa_restorer; 183 }; 184 185 struct vki_sigaction { 186 unsigned int sa_flags; 187 __vki_sighandler_t sa_handler; 188 vki_sigset_t sa_mask; 189 }; 190 191 192 struct vki_sigaction_base { 193 // [[See comment about extra 'k' above]] 194 unsigned long sa_flags; 195 __vki_sighandler_t ksa_handler; 196 197 vki_sigset_t sa_mask; /* mask last for extensibility */ 198 __vki_sigrestore_t sa_restorer; 199 }; 200 201 /* On Linux we use the same type for passing sigactions to 202 and from the kernel. Hence: */ 203 typedef struct vki_sigaction_base vki_sigaction_toK_t; 204 typedef struct vki_sigaction_base vki_sigaction_fromK_t; 205 206 typedef struct vki_sigaltstack { 207 void __user *ss_sp; 208 vki_size_t ss_size; 209 int ss_flags; 210 211 } vki_stack_t; 212 213 214 //---------------------------------------------------------------------- 215 // From 2.6.35.5/include/asm-mips/sigcontext.h 216 //---------------------------------------------------------------------- 217 218 struct _vki_fpreg { 219 unsigned short significand[4]; 220 unsigned short exponent; 221 }; 222 223 struct _vki_fpxreg { 224 unsigned short significand[4]; 225 unsigned short exponent; 226 unsigned short padding[3]; 227 }; 228 229 struct _vki_xmmreg { 230 unsigned long element[4]; 231 }; 232 233 struct _vki_fpstate { 234 /* Regular FPU environment */ 235 unsigned long cw; 236 unsigned long sw; 237 unsigned long tag; 238 unsigned long ipoff; 239 unsigned long cssel; 240 unsigned long dataoff; 241 unsigned long datasel; 242 struct _vki_fpreg _st[8]; 243 unsigned short status; 244 unsigned short magic; /* 0xffff = regular FPU data only */ 245 246 /* FXSR FPU environment */ 247 unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ 248 unsigned long mxcsr; 249 unsigned long reserved; 250 struct _vki_fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ 251 struct _vki_xmmreg _xmm[8]; 252 unsigned long padding[56]; 253 }; 254 255 //---------------------------------------------------------------------- 256 // From linux-2.6.35.5/include/asm-mips/sigcontext.h 257 //---------------------------------------------------------------------- 258 259 struct vki_sigcontext { 260 unsigned int sc_regmask; /* Unused */ 261 unsigned int sc_status; /* Unused */ 262 unsigned long long sc_pc; 263 unsigned long long sc_regs[32]; 264 unsigned long long sc_fpregs[32]; 265 unsigned int sc_acx; /* Was sc_ownedfp */ 266 unsigned int sc_fpc_csr; 267 unsigned int sc_fpc_eir; /* Unused */ 268 unsigned int sc_used_math; 269 unsigned int sc_dsp; /* dsp status, was sc_ssflags */ 270 unsigned long long sc_mdhi; 271 unsigned long long sc_mdlo; 272 unsigned long sc_hi1; /* Was sc_cause */ 273 unsigned long sc_lo1; /* Was sc_badvaddr */ 274 unsigned long sc_hi2; /* Was sc_sigset[4] */ 275 unsigned long sc_lo2; 276 unsigned long sc_hi3; 277 unsigned long sc_lo3; 278 }; 279 280 //---------------------------------------------------------------------- 281 // From linux-2.6.35.5/include/asm-mips/mman.h 282 //---------------------------------------------------------------------- 283 284 #define VKI_PROT_NONE 0x0 /* No page permissions */ 285 #define VKI_PROT_READ 0x1 /* page can be read */ 286 #define VKI_PROT_WRITE 0x2 /* page can be written */ 287 #define VKI_PROT_EXEC 0x4 /* page can be executed */ 288 #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ 289 #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ 290 291 #define VKI_MAP_SHARED 0x001 /* Share changes */ 292 #define VKI_MAP_PRIVATE 0x002 /* Changes are private */ 293 #define VKI_MAP_FIXED 0x010 /* Interpret addr exactly */ 294 295 #define VKI_MAP_NORESERVE 0x0400 /* don't reserve swap pages */ 296 297 /* These are linux-specific */ 298 #define VKI_MAP_NORESERVE 0x0400 /* don't check for reservations */ 299 #define VKI_MAP_ANONYMOUS 0x0800 /* don't use a file */ 300 #define VKI_MAP_GROWSDOWN 0x1000 /* stack-like segment */ 301 #define VKI_MAP_DENYWRITE 0x2000 /* ETXTBSY */ 302 #define VKI_MAP_EXECUTABLE 0x4000 /* mark it as an executable */ 303 #define VKI_MAP_LOCKED 0x8000 /* pages are locked */ 304 #define VKI_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ 305 #define VKI_MAP_NONBLOCK 0x20000 /* do not block on IO */ 306 307 308 //---------------------------------------------------------------------- 309 // From linux-2.6.35.5/include/asm-mips/fcntl.h 310 //---------------------------------------------------------------------- 311 312 #define VKI_O_RDONLY 00 313 #define VKI_O_WRONLY 01 314 #define VKI_O_RDWR 02 315 316 #define VKI_O_CREAT 0x0100 /* not fcntl */ 317 #define VKI_O_EXCL 0x0400 /* not fcntl */ 318 319 #define VKI_O_TRUNC 0x0200 /* not fcntl */ 320 321 #define VKI_O_APPEND 0x0008 322 #define VKI_O_NONBLOCK 0x0080 323 #define VKI_O_LARGEFILE 0x2000 324 325 #define VKI_AT_FDCWD -100 326 327 #define VKI_F_DUPFD 0 /* dup */ 328 #define VKI_F_GETFD 1 /* get close_on_exec */ 329 #define VKI_F_SETFD 2 /* set/clear close_on_exec */ 330 #define VKI_F_GETFL 3 /* get file->f_flags */ 331 #define VKI_F_SETFL 4 /* set file->f_flags */ 332 333 #define VKI_F_GETLK 14 334 #define VKI_F_SETLK 6 335 #define VKI_F_SETLKW 7 336 337 #define VKI_F_SETOWN 24 /* for sockets. */ 338 #define VKI_F_GETOWN 23 /* for sockets. */ 339 #define VKI_F_SETSIG 10 /* for sockets. */ 340 #define VKI_F_GETSIG 11 /* for sockets. */ 341 342 #define VKI_F_SETOWN_EX 15 343 #define VKI_F_GETOWN_EX 16 344 345 #define VKI_F_GETLK64 33 /* using 'struct flock64' */ 346 #define VKI_F_SETLK64 34 347 #define VKI_F_SETLKW64 35 348 349 /* for F_[GET|SET]FL */ 350 #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */ 351 352 #define VKI_F_LINUX_SPECIFIC_BASE 1024 353 354 struct vki_f_owner_ex { 355 int type; 356 __vki_kernel_pid_t pid; 357 }; 358 359 //---------------------------------------------------------------------- 360 // From linux-2.6.35.5/include/asm-mips/resource.h 361 //---------------------------------------------------------------------- 362 363 #define VKI_RLIMIT_DATA 2 /* max data size */ 364 #define VKI_RLIMIT_STACK 3 /* max stack size */ 365 #define VKI_RLIMIT_CORE 4 /* max core file size */ 366 #define VKI_RLIMIT_NOFILE 5 /* max number of open files */ 367 368 //---------------------------------------------------------------------- 369 // From linux-2.6.35.5/include/asm-mips/socket.h 370 //---------------------------------------------------------------------- 371 372 #define VKI_SOL_SOCKET 0xffff 373 #define VKI_SO_TYPE 0x1008 374 375 //---------------------------------------------------------------------- 376 // From linux-2.6.35.5/include/asm-i386/sockios.h 377 //---------------------------------------------------------------------- 378 379 #define VKI_SIOCSPGRP 0x8902 380 #define VKI_SIOCGPGRP 0x8904 381 #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ 382 #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ 383 384 //---------------------------------------------------------------------- 385 // From linux-2.6.35.5/include/asm-mips/stat.h 386 //---------------------------------------------------------------------- 387 388 struct vki_stat { 389 unsigned st_dev; 390 long st_pad1[3]; /* Reserved for network id */ 391 unsigned long st_ino; 392 unsigned int st_mode; 393 unsigned long st_nlink; 394 unsigned int st_uid; 395 unsigned int st_gid; 396 unsigned st_rdev; 397 long st_pad2[2]; 398 long st_size; 399 long st_pad3; 400 /* 401 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime 402 * but we don't have it under Linux. 403 */ 404 long st_atime; 405 long st_atime_nsec; 406 long st_mtime; 407 long st_mtime_nsec; 408 long st_ctime; 409 long st_ctime_nsec; 410 long st_blksize; 411 long st_blocks; 412 long st_pad4[14]; 413 }; 414 415 /* 416 * This matches struct stat64 in glibc2.1, hence the absolutely insane 417 * amounts of padding around dev_t's. The memory layout is the same as of 418 * struct stat of the 64-bit kernel. 419 */ 420 421 struct vki_stat64 { 422 unsigned long st_dev; 423 unsigned long st_pad0[3]; /* Reserved for st_dev expansion */ 424 425 unsigned long long st_ino; 426 427 unsigned int st_mode; 428 unsigned long st_nlink; 429 430 unsigned int st_uid; 431 unsigned int st_gid; 432 433 unsigned long st_rdev; 434 unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ 435 436 long long st_size; 437 438 /* 439 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime 440 * but we don't have it under Linux. 441 */ 442 long st_atime; 443 unsigned long st_atime_nsec; /* Reserved for st_atime expansion */ 444 445 long st_mtime; 446 unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */ 447 448 long st_ctime; 449 unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */ 450 451 unsigned long st_blksize; 452 unsigned long st_pad2; 453 454 long long st_blocks; 455 }; 456 457 //---------------------------------------------------------------------- 458 // From linux-2.6.35.5/include/asm-mips/statfs.h 459 //---------------------------------------------------------------------- 460 461 struct vki_statfs { 462 long f_type; 463 long f_bsize; 464 long f_frsize; /* Fragment size - unsupported */ 465 long f_blocks; 466 long f_bfree; 467 long f_files; 468 long f_ffree; 469 long f_bavail; 470 471 /* Linux specials */ 472 __vki_kernel_fsid_t f_fsid; 473 long f_namelen; 474 long f_spare[6]; 475 }; 476 477 //---------------------------------------------------------------------- 478 // From linux-2.6.35.5/include/asm-mips/termios.h 479 //---------------------------------------------------------------------- 480 481 struct vki_winsize { 482 unsigned short ws_row; 483 unsigned short ws_col; 484 unsigned short ws_xpixel; 485 unsigned short ws_ypixel; 486 }; 487 488 #define NCC 8 489 #define NCCS 23 490 struct vki_termio { 491 unsigned short c_iflag; /* input mode flags */ 492 unsigned short c_oflag; /* output mode flags */ 493 unsigned short c_cflag; /* control mode flags */ 494 unsigned short c_lflag; /* local mode flags */ 495 char c_line; /* line discipline */ 496 unsigned char c_cc[NCCS]; /* control characters */ 497 }; 498 499 500 //---------------------------------------------------------------------- 501 // From linux-2.6.35.5/include/asm-mips/termbits.h 502 //---------------------------------------------------------------------- 503 504 typedef unsigned char vki_cc_t; 505 typedef unsigned long vki_speed_t; 506 typedef unsigned long vki_tcflag_t; 507 508 struct vki_termios { 509 vki_tcflag_t c_iflag; /* input mode flags */ 510 vki_tcflag_t c_oflag; /* output mode flags */ 511 vki_tcflag_t c_cflag; /* control mode flags */ 512 vki_tcflag_t c_lflag; /* local mode flags */ 513 vki_cc_t c_line; /* line discipline */ 514 vki_cc_t c_cc[NCCS]; /* control characters */ 515 }; 516 517 //---------------------------------------------------------------------- 518 // From linux-2.6.35.5/include/asm-mips/ioctl.h 519 //---------------------------------------------------------------------- 520 521 #define _VKI_IOC_NRBITS 8 522 #define _VKI_IOC_TYPEBITS 8 523 #define _VKI_IOC_SIZEBITS 14 524 #define _VKI_IOC_DIRBITS 2 525 526 #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1) 527 #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1) 528 #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1) 529 #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1) 530 531 #define _VKI_IOC_NRSHIFT 0 532 #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) 533 #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) 534 #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) 535 536 #define _VKI_IOC_NONE 1U 537 #define _VKI_IOC_WRITE 2U 538 #define _VKI_IOC_READ 4U 539 540 #define _VKI_IOC(dir,type,nr,size) \ 541 (((dir) << _VKI_IOC_DIRSHIFT) | \ 542 ((type) << _VKI_IOC_TYPESHIFT) | \ 543 ((nr) << _VKI_IOC_NRSHIFT) | \ 544 ((size) << _VKI_IOC_SIZESHIFT)) 545 546 /* provoke compile error for invalid uses of size argument */ 547 extern unsigned int __VKI_invalid_size_argument_for_IOC; 548 /* used to create numbers */ 549 #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) 550 #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 551 #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 552 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 553 554 /* used to decode ioctl numbers.. */ 555 #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) 556 #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK) 557 #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK) 558 #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) 559 560 //---------------------------------------------------------------------- 561 // From linux-2.6.35.5/include/asm-mips/ioctls.h 562 //---------------------------------------------------------------------- 563 564 #define VKI_TCGETA 0x5401 565 #define VKI_TCSETA 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ 566 #define VKI_TCSETAW 0x5403 567 #define VKI_TCSETAF 0x5404 568 569 #define VKI_TCSBRK 0x5405 570 #define VKI_TCXONC 0x5406 571 #define VKI_TCFLSH 0x5407 572 573 #define VKI_TCGETS 0x540d 574 #define VKI_TCSETS 0x540e 575 #define VKI_TCSETSW 0x540f 576 #define VKI_TCSETSF 0x5410 577 578 #define VKI_TIOCEXCL 0x740d /* set exclusive use of tty */ 579 #define VKI_TIOCNXCL 0x740e /* reset exclusive use of tty */ 580 #define VKI_TIOCOUTQ 0x7472 /* output queue size */ 581 #define VKI_TIOCSTI 0x5472 /* simulate terminal input */ 582 #define VKI_TIOCMGET 0x741d /* get all modem bits */ 583 #define VKI_TIOCMBIS 0x741b /* bis modem bits */ 584 #define VKI_TIOCMBIC 0x741c /* bic modem bits */ 585 #define VKI_TIOCMSET 0x741a /* set all modem bits */ 586 #define VKI_TIOCPKT 0x5470 /* pty: set/clear packet mode */ 587 #define VKI_TIOCPKT_DATA 0x00 /* data packet */ 588 #define VKI_TIOCPKT_FLUSHREAD 0x01 /* flush packet */ 589 #define VKI_TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ 590 #define VKI_TIOCPKT_STOP 0x04 /* stop output */ 591 #define VKI_TIOCPKT_START 0x08 /* start output */ 592 #define VKI_TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ 593 #define VKI_TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ 594 /* #define TIOCPKT_IOCTL 0x40 state change of pty driver */ 595 #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */ 596 #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */ 597 #define VKI_TIOCNOTTY 0x5471 /* void tty association */ 598 #define VKI_TIOCSETD 0x7401 599 #define VKI_TIOCGETD 0x7400 600 601 #define VKI_FIOCLEX 0x6601 602 #define VKI_FIONCLEX 0x6602 603 #define VKI_FIOASYNC 0x667d 604 #define VKI_FIONBIO 0x667e 605 #define VKI_FIOQSIZE 0x667f 606 607 #define VKI_TIOCGLTC 0x7474 /* get special local chars */ 608 #define VKI_TIOCSLTC 0x7475 /* set special local chars */ 609 #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) /* set pgrp of tty */ 610 #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) /* get pgrp of tty */ 611 #define VKI_TIOCCONS _VKI_IOW('t', 120, int) /* become virtual console */ 612 613 #define VKI_FIONREAD 0x467f 614 #define VKI_TIOCINQ FIONREAD 615 616 #define VKI_TIOCGETP 0x7408 617 #define VKI_TIOCSETP 0x7409 618 #define VKI_TIOCSETN 0x740a /* TIOCSETP wo flush */ 619 620 #define VKI_TIOCSBRK 0x5427 /* BSD compatibility */ 621 #define VKI_TIOCCBRK 0x5428 /* BSD compatibility */ 622 #define VKI_TIOCGSID 0x7416 /* Return the session ID of FD */ 623 #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 624 #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ 625 626 /* I hope the range from 0x5480 on is free ... */ 627 #define VKI_TIOCSCTTY 0x5480 /* become controlling tty */ 628 #define VKI_TIOCGSOFTCAR 0x5481 629 #define VKI_TIOCSSOFTCAR 0x5482 630 #define VKI_TIOCLINUX 0x5483 631 #define VKI_TIOCGSERIAL 0x5484 632 #define VKI_TIOCSSERIAL 0x5485 633 #define VKI_TCSBRKP 0x5486 /* Needed for POSIX tcsendbreak() */ 634 #define VKI_TIOCSERCONFIG 0x5488 635 #define VKI_TIOCSERGWILD 0x5489 636 #define VKI_TIOCSERSWILD 0x548a 637 #define VKI_TIOCGLCKTRMIOS 0x548b 638 #define VKI_TIOCSLCKTRMIOS 0x548c 639 #define VKI_TIOCSERGSTRUCT 0x548d /* For debugging only */ 640 #define VKI_TIOCSERGETLSR 0x548e /* Get line status register */ 641 #define VKI_TIOCSERGETMULTI 0x548f /* Get multiport config */ 642 #define VKI_TIOCSERSETMULTI 0x5490 /* Set multiport config */ 643 #define VKI_TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */ 644 #define VKI_TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */ 645 #define VKI_TIOCGHAYESESP 0x5493 /* Get Hayes ESP configuration */ 646 #define VKI_TIOCSHAYESESP 0x5494 /* Set Hayes ESP configuration */ 647 648 //---------------------------------------------------------------------- 649 // From asm-generic/poll.h 650 //---------------------------------------------------------------------- 651 652 /* These are specified by iBCS2 */ 653 #define VKI_POLLIN 0x0001 654 655 struct vki_pollfd { 656 int fd; 657 short events; 658 short revents; 659 }; 660 //---------------------------------------------------------------------- 661 // From linux-2.6.35.5/include/asm-mips/ucontext.h 662 //---------------------------------------------------------------------- 663 664 struct vki_ucontext { 665 unsigned long uc_flags; 666 struct vki_ucontext *uc_link; 667 vki_stack_t uc_stack; 668 struct vki_sigcontext uc_mcontext; 669 vki_sigset_t uc_sigmask; /* mask last for extensibility */ 670 }; 671 672 // CAB: TODO 673 typedef void vki_modify_ldt_t; 674 675 //---------------------------------------------------------------------- 676 // From linux-2.6.35.5/include/asm-mips/ipcbuf.h 677 //---------------------------------------------------------------------- 678 679 struct vki_ipc64_perm 680 { 681 __vki_kernel_key_t key; 682 __vki_kernel_uid_t uid; 683 __vki_kernel_gid_t gid; 684 __vki_kernel_uid_t cuid; 685 __vki_kernel_gid_t cgid; 686 __vki_kernel_mode_t mode; 687 unsigned short seq; 688 unsigned short __pad1; 689 unsigned long __unused1; 690 unsigned long __unused2; 691 }; 692 693 //---------------------------------------------------------------------- 694 // From linux-2.6.35.5/include/asm-mips/sembuf.h 695 //---------------------------------------------------------------------- 696 697 struct vki_semid64_ds { 698 struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */ 699 __vki_kernel_time_t sem_otime; /* last semop time */ 700 __vki_kernel_time_t sem_ctime; /* last change time */ 701 unsigned long sem_nsems; /* no. of semaphores in array */ 702 unsigned long __unused1; 703 unsigned long __unused2; 704 }; 705 706 707 //---------------------------------------------------------------------- 708 // From linux-2.6.35.5/include/asm-mips/msgbuf.h 709 //---------------------------------------------------------------------- 710 711 struct vki_msqid64_ds { 712 struct vki_ipc64_perm msg_perm; 713 __vki_kernel_time_t msg_stime; /* last msgsnd time */ 714 unsigned long __unused1; 715 __vki_kernel_time_t msg_rtime; /* last msgrcv time */ 716 unsigned long __unused2; 717 __vki_kernel_time_t msg_ctime; /* last change time */ 718 unsigned long __unused3; 719 unsigned long msg_cbytes; /* current number of bytes on queue */ 720 unsigned long msg_qnum; /* number of messages in queue */ 721 unsigned long msg_qbytes; /* max number of bytes on queue */ 722 __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */ 723 __vki_kernel_pid_t msg_lrpid; /* last receive pid */ 724 unsigned long __unused4; 725 unsigned long __unused5; 726 }; 727 728 //---------------------------------------------------------------------- 729 // From linux-2.6.35.5/include/asm-mips/ipc.h 730 //---------------------------------------------------------------------- 731 732 struct vki_ipc_kludge { 733 struct vki_msgbuf __user *msgp; 734 long msgtyp; 735 }; 736 737 #define VKI_SEMOP 1 738 #define VKI_SEMGET 2 739 #define VKI_SEMCTL 3 740 #define VKI_SEMTIMEDOP 4 741 #define VKI_MSGSND 11 742 #define VKI_MSGRCV 12 743 #define VKI_MSGGET 13 744 #define VKI_MSGCTL 14 745 #define VKI_SHMAT 21 746 #define VKI_SHMDT 22 747 #define VKI_SHMGET 23 748 #define VKI_SHMCTL 24 749 750 //---------------------------------------------------------------------- 751 // From linux-2.6.35.5/include/asm-mips/shmbuf.h 752 //---------------------------------------------------------------------- 753 754 struct vki_shmid64_ds { 755 struct vki_ipc64_perm shm_perm; /* operation perms */ 756 vki_size_t shm_segsz; /* size of segment (bytes) */ 757 __vki_kernel_time_t shm_atime; /* last attach time */ 758 __vki_kernel_time_t shm_dtime; /* last detach time */ 759 __vki_kernel_time_t shm_ctime; /* last change time */ 760 __vki_kernel_pid_t shm_cpid; /* pid of creator */ 761 __vki_kernel_pid_t shm_lpid; /* pid of last operator */ 762 unsigned long shm_nattch; /* no. of current attaches */ 763 unsigned long __unused1; 764 unsigned long __unused2; 765 }; 766 767 struct vki_shminfo64 { 768 unsigned long shmmax; 769 unsigned long shmmin; 770 unsigned long shmmni; 771 unsigned long shmseg; 772 unsigned long shmall; 773 unsigned long __unused1; 774 unsigned long __unused2; 775 unsigned long __unused3; 776 unsigned long __unused4; 777 }; 778 //---------------------------------------------------------------------- 779 // From linux-2.6.35.5/include/asm-mips/ptrace.h 780 //---------------------------------------------------------------------- 781 782 struct vki_pt_regs { 783 #ifdef CONFIG_32BIT 784 /* Pad bytes for argument save space on the stack. */ 785 unsigned long pad0[6]; 786 #endif 787 /* Saved main processor registers. */ 788 unsigned long regs[32]; 789 790 /* Saved special registers. */ 791 unsigned long cp0_status; 792 unsigned long hi; 793 unsigned long lo; 794 #ifdef CONFIG_CPU_HAS_SMARTMIPS 795 unsigned long acx; 796 #endif 797 unsigned long cp0_badvaddr; 798 unsigned long cp0_cause; 799 unsigned long cp0_epc; 800 #ifdef CONFIG_MIPS_MT_SMTC 801 unsigned long cp0_tcstatus; 802 #endif /* CONFIG_MIPS_MT_SMTC */ 803 #ifdef CONFIG_CPU_CAVIUM_OCTEON 804 unsigned long long mpl[3]; /* MTM{0,1,2} */ 805 unsigned long long mtp[3]; /* MTP{0,1,2} */ 806 #endif 807 } __attribute__ ((aligned (8))); 808 809 810 #define vki_user_regs_struct vki_pt_regs 811 812 #define MIPS_lo lo 813 #define MIPS_hi hi 814 //#define MIPS_pc regs[32] 815 #define MIPS_r31 regs[31] 816 #define MIPS_r30 regs[30] 817 #define MIPS_r29 regs[29] 818 #define MIPS_r28 regs[28] 819 #define MIPS_r27 regs[27] 820 #define MIPS_r26 regs[26] 821 #define MIPS_r25 regs[25] 822 #define MIPS_r24 regs[24] 823 #define MIPS_r23 regs[23] 824 #define MIPS_r22 regs[22] 825 #define MIPS_r21 regs[21] 826 #define MIPS_r20 regs[20] 827 #define MIPS_r19 regs[19] 828 #define MIPS_r18 regs[18] 829 #define MIPS_r17 regs[17] 830 #define MIPS_r16 regs[16] 831 #define MIPS_r15 regs[15] 832 #define MIPS_r14 regs[14] 833 #define MIPS_r13 regs[13] 834 #define MIPS_r12 regs[12] 835 #define MIPS_r11 regs[11] 836 #define MIPS_r10 regs[10] 837 #define MIPS_r9 regs[9] 838 #define MIPS_r8 regs[8] 839 #define MIPS_r7 regs[7] 840 #define MIPS_r6 regs[6] 841 #define MIPS_r5 regs[5] 842 #define MIPS_r4 regs[4] 843 #define MIPS_r3 regs[3] 844 #define MIPS_r2 regs[2] 845 #define MIPS_r1 regs[1] 846 #define MIPS_r0 regs[0] 847 848 #define VKI_PTRACE_GETREGS 12 849 #define VKI_PTRACE_SETREGS 13 850 #define VKI_PTRACE_GETFPREGS 14 851 #define VKI_PTRACE_SETFPREGS 15 852 //---------------------------------------------------------------------- 853 // From linux-2.6.35.5/include/asm-mips/elf.h 854 //---------------------------------------------------------------------- 855 typedef unsigned long vki_elf_greg_t; 856 857 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) 858 #define VKI_ELF_NFPREG 33 /* includes fpscr */ 859 860 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; 861 862 typedef double vki_elf_fpreg_t; 863 typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG]; 864 865 typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t; 866 867 #define VKI_AT_SYSINFO 32 868 //---------------------------------------------------------------------- 869 // From linux-2.6.35.5/include/asm-generic/siginfo.h 870 //---------------------------------------------------------------------- 871 #define HAVE_ARCH_SIGINFO_T 872 873 typedef union vki_sigval { 874 int sival_int; 875 void __user *sival_ptr; 876 } vki_sigval_t; 877 878 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE 879 #define __VKI_ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) 880 #endif 881 882 #define VKI_SI_MAX_SIZE 128 883 884 #ifndef VKI_SI_PAD_SIZE 885 #define VKI_SI_PAD_SIZE ((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) 886 #endif 887 888 #ifndef __VKI_ARCH_SI_UID_T 889 #define __VKI_ARCH_SI_UID_T vki_uid_t 890 #endif 891 892 #ifndef __VKI_ARCH_SI_BAND_T 893 #define __VKI_ARCH_SI_BAND_T long 894 #endif 895 896 typedef struct vki_siginfo { 897 int si_signo; 898 int si_code; 899 int si_errno; 900 int __pad0[VKI_SI_MAX_SIZE / sizeof(int) - VKI_SI_PAD_SIZE - 3]; 901 902 union { 903 int _pad[VKI_SI_PAD_SIZE]; 904 905 /* kill() */ 906 struct { 907 vki_pid_t _pid; /* sender's pid */ 908 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 909 } _kill; 910 911 /* POSIX.1b timers */ 912 struct { 913 vki_timer_t _tid; /* timer id */ 914 int _overrun; /* overrun count */ 915 char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)]; 916 vki_sigval_t _sigval; /* same as below */ 917 int _sys_private; /* not to be passed to user */ 918 } _timer; 919 920 /* POSIX.1b signals */ 921 struct { 922 vki_pid_t _pid; /* sender's pid */ 923 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 924 vki_sigval_t _sigval; 925 } _rt; 926 927 /* SIGCHLD */ 928 struct { 929 vki_pid_t _pid; /* which child */ 930 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 931 int _status; /* exit code */ 932 vki_clock_t _utime; 933 vki_clock_t _stime; 934 } _sigchld; 935 936 /* IRIX SIGCHLD */ 937 struct { 938 vki_pid_t _pid; /* which child */ 939 vki_clock_t _utime; 940 int _status; /* exit code */ 941 vki_clock_t _stime; 942 } _irix_sigchld; 943 944 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 945 struct { 946 void __user *_addr; /* faulting insn/memory ref. */ 947 #ifdef __ARCH_SI_TRAPNO 948 int _trapno; /* TRAP # which caused the signal */ 949 #endif 950 } _sigfault; 951 952 /* SIGPOLL, SIGXFSZ (To do ...) */ 953 struct { 954 __VKI_ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 955 int _fd; 956 } _sigpoll; 957 } _sifields; 958 } vki_siginfo_t; 959 960 //---------------------------------------------------------------------- 961 // From linux-2.6.35.5/include/asm/break.h 962 //---------------------------------------------------------------------- 963 #define VKI_BRK_OVERFLOW 6 /* Overflow check */ 964 #define VKI_BRK_DIVZERO 7 /* Divide by zero check */ 965 966 #endif // __VKI_MIPS32_LINUX_H 967 968 969 /*--------------------------------------------------------------------*/ 970 /*--- end vki-mips32-linux.h ---*/ 971 /*--------------------------------------------------------------------*/ 972