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-2015 RT-RK 11 mips-valgrind@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.9/arch/mips/include/bits/shm.h 83 //---------------------------------------------------------------------- 84 85 #define VKI_SHMLBA 0x40000 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_ACCMODE 03 313 #define VKI_O_RDONLY 00 314 #define VKI_O_WRONLY 01 315 #define VKI_O_RDWR 02 316 317 #define VKI_O_CREAT 0x0100 /* not fcntl */ 318 #define VKI_O_EXCL 0x0400 /* not fcntl */ 319 320 #define VKI_O_TRUNC 0x0200 /* not fcntl */ 321 322 #define VKI_O_APPEND 0x0008 323 #define VKI_O_NONBLOCK 0x0080 324 #define VKI_O_LARGEFILE 0x2000 325 326 #define VKI_AT_FDCWD -100 327 328 #define VKI_F_DUPFD 0 /* dup */ 329 #define VKI_F_GETFD 1 /* get close_on_exec */ 330 #define VKI_F_SETFD 2 /* set/clear close_on_exec */ 331 #define VKI_F_GETFL 3 /* get file->f_flags */ 332 #define VKI_F_SETFL 4 /* set file->f_flags */ 333 334 #define VKI_F_GETLK 14 335 #define VKI_F_SETLK 6 336 #define VKI_F_SETLKW 7 337 338 #define VKI_F_SETOWN 24 /* for sockets. */ 339 #define VKI_F_GETOWN 23 /* for sockets. */ 340 #define VKI_F_SETSIG 10 /* for sockets. */ 341 #define VKI_F_GETSIG 11 /* for sockets. */ 342 343 #define VKI_F_SETOWN_EX 15 344 #define VKI_F_GETOWN_EX 16 345 346 #define VKI_F_OFD_GETLK 36 347 #define VKI_F_OFD_SETLK 37 348 #define VKI_F_OFD_SETLKW 38 349 350 #define VKI_F_GETLK64 33 /* using 'struct flock64' */ 351 #define VKI_F_SETLK64 34 352 #define VKI_F_SETLKW64 35 353 354 /* for F_[GET|SET]FL */ 355 #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */ 356 357 #define VKI_F_LINUX_SPECIFIC_BASE 1024 358 359 struct vki_f_owner_ex { 360 int type; 361 __vki_kernel_pid_t pid; 362 }; 363 364 //---------------------------------------------------------------------- 365 // From linux-2.6.35.5/include/asm-mips/resource.h 366 //---------------------------------------------------------------------- 367 368 #define VKI_RLIMIT_DATA 2 /* max data size */ 369 #define VKI_RLIMIT_STACK 3 /* max stack size */ 370 #define VKI_RLIMIT_CORE 4 /* max core file size */ 371 #define VKI_RLIMIT_NOFILE 5 /* max number of open files */ 372 373 //---------------------------------------------------------------------- 374 // From linux-2.6.35.5/include/asm-mips/socket.h 375 //---------------------------------------------------------------------- 376 377 #define VKI_SOL_SOCKET 0xffff 378 379 #define VKI_SO_TYPE 0x1008 380 381 #define VKI_SO_ATTACH_FILTER 26 382 383 //---------------------------------------------------------------------- 384 // From linux-2.6.35.5/include/asm-i386/sockios.h 385 //---------------------------------------------------------------------- 386 387 #define VKI_SIOCSPGRP 0x8902 388 #define VKI_SIOCGPGRP 0x8904 389 #define VKI_SIOCATMARK 0x8905 390 #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ 391 #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ 392 393 //---------------------------------------------------------------------- 394 // From linux-2.6.35.5/include/asm-mips/stat.h 395 //---------------------------------------------------------------------- 396 397 struct vki_stat { 398 unsigned st_dev; 399 long st_pad1[3]; /* Reserved for network id */ 400 unsigned long st_ino; 401 unsigned int st_mode; 402 unsigned long st_nlink; 403 unsigned int st_uid; 404 unsigned int st_gid; 405 unsigned st_rdev; 406 long st_pad2[2]; 407 long st_size; 408 long st_pad3; 409 /* 410 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime 411 * but we don't have it under Linux. 412 */ 413 long st_atime; 414 long st_atime_nsec; 415 long st_mtime; 416 long st_mtime_nsec; 417 long st_ctime; 418 long st_ctime_nsec; 419 long st_blksize; 420 long st_blocks; 421 long st_pad4[14]; 422 }; 423 424 /* 425 * This matches struct stat64 in glibc2.1, hence the absolutely insane 426 * amounts of padding around dev_t's. The memory layout is the same as of 427 * struct stat of the 64-bit kernel. 428 */ 429 430 struct vki_stat64 { 431 unsigned long st_dev; 432 unsigned long st_pad0[3]; /* Reserved for st_dev expansion */ 433 434 unsigned long long st_ino; 435 436 unsigned int st_mode; 437 unsigned long st_nlink; 438 439 unsigned int st_uid; 440 unsigned int st_gid; 441 442 unsigned long st_rdev; 443 unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ 444 445 long long st_size; 446 447 /* 448 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime 449 * but we don't have it under Linux. 450 */ 451 long st_atime; 452 unsigned long st_atime_nsec; /* Reserved for st_atime expansion */ 453 454 long st_mtime; 455 unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */ 456 457 long st_ctime; 458 unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */ 459 460 unsigned long st_blksize; 461 unsigned long st_pad2; 462 463 long long st_blocks; 464 }; 465 466 //---------------------------------------------------------------------- 467 // From linux-2.6.35.5/include/asm-mips/statfs.h 468 //---------------------------------------------------------------------- 469 470 struct vki_statfs { 471 long f_type; 472 long f_bsize; 473 long f_frsize; /* Fragment size - unsupported */ 474 long f_blocks; 475 long f_bfree; 476 long f_files; 477 long f_ffree; 478 long f_bavail; 479 480 /* Linux specials */ 481 __vki_kernel_fsid_t f_fsid; 482 long f_namelen; 483 long f_spare[6]; 484 }; 485 486 //---------------------------------------------------------------------- 487 // From linux-2.6.35.5/include/asm-mips/termios.h 488 //---------------------------------------------------------------------- 489 490 struct vki_winsize { 491 unsigned short ws_row; 492 unsigned short ws_col; 493 unsigned short ws_xpixel; 494 unsigned short ws_ypixel; 495 }; 496 497 #define NCC 8 498 #define NCCS 23 499 struct vki_termio { 500 unsigned short c_iflag; /* input mode flags */ 501 unsigned short c_oflag; /* output mode flags */ 502 unsigned short c_cflag; /* control mode flags */ 503 unsigned short c_lflag; /* local mode flags */ 504 char c_line; /* line discipline */ 505 unsigned char c_cc[NCCS]; /* control characters */ 506 }; 507 508 509 //---------------------------------------------------------------------- 510 // From linux-2.6.35.5/include/asm-mips/termbits.h 511 //---------------------------------------------------------------------- 512 513 typedef unsigned char vki_cc_t; 514 typedef unsigned long vki_speed_t; 515 typedef unsigned long vki_tcflag_t; 516 517 struct vki_termios { 518 vki_tcflag_t c_iflag; /* input mode flags */ 519 vki_tcflag_t c_oflag; /* output mode flags */ 520 vki_tcflag_t c_cflag; /* control mode flags */ 521 vki_tcflag_t c_lflag; /* local mode flags */ 522 vki_cc_t c_line; /* line discipline */ 523 vki_cc_t c_cc[NCCS]; /* control characters */ 524 }; 525 526 //---------------------------------------------------------------------- 527 // From linux-2.6.35.5/include/asm-mips/ioctl.h 528 //---------------------------------------------------------------------- 529 530 #define _VKI_IOC_NRBITS 8 531 #define _VKI_IOC_TYPEBITS 8 532 #define _VKI_IOC_SIZEBITS 13 533 #define _VKI_IOC_DIRBITS 3 534 535 #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1) 536 #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1) 537 #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1) 538 #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1) 539 540 #define _VKI_IOC_NRSHIFT 0 541 #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) 542 #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) 543 #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) 544 545 #define _VKI_IOC_NONE 1U 546 #define _VKI_IOC_READ 2U 547 #define _VKI_IOC_WRITE 4U 548 549 #define _VKI_IOC(dir,type,nr,size) \ 550 (((dir) << _VKI_IOC_DIRSHIFT) | \ 551 ((type) << _VKI_IOC_TYPESHIFT) | \ 552 ((nr) << _VKI_IOC_NRSHIFT) | \ 553 ((size) << _VKI_IOC_SIZESHIFT)) 554 555 /* provoke compile error for invalid uses of size argument */ 556 extern unsigned int __VKI_invalid_size_argument_for_IOC; 557 /* used to create numbers */ 558 #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) 559 #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 560 #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 561 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 562 563 /* used to decode ioctl numbers.. */ 564 #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) 565 #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK) 566 #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK) 567 #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) 568 569 //---------------------------------------------------------------------- 570 // From linux-2.6.35.5/include/asm-mips/ioctls.h 571 //---------------------------------------------------------------------- 572 573 #define VKI_TCGETA 0x5401 574 #define VKI_TCSETA 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ 575 #define VKI_TCSETAW 0x5403 576 #define VKI_TCSETAF 0x5404 577 578 #define VKI_TCSBRK 0x5405 579 #define VKI_TCXONC 0x5406 580 #define VKI_TCFLSH 0x5407 581 582 #define VKI_TCGETS 0x540d 583 #define VKI_TCSETS 0x540e 584 #define VKI_TCSETSW 0x540f 585 #define VKI_TCSETSF 0x5410 586 587 #define VKI_TIOCEXCL 0x740d /* set exclusive use of tty */ 588 #define VKI_TIOCNXCL 0x740e /* reset exclusive use of tty */ 589 #define VKI_TIOCOUTQ 0x7472 /* output queue size */ 590 #define VKI_TIOCSTI 0x5472 /* simulate terminal input */ 591 #define VKI_TIOCMGET 0x741d /* get all modem bits */ 592 #define VKI_TIOCMBIS 0x741b /* bis modem bits */ 593 #define VKI_TIOCMBIC 0x741c /* bic modem bits */ 594 #define VKI_TIOCMSET 0x741a /* set all modem bits */ 595 #define VKI_TIOCPKT 0x5470 /* pty: set/clear packet mode */ 596 #define VKI_TIOCPKT_DATA 0x00 /* data packet */ 597 #define VKI_TIOCPKT_FLUSHREAD 0x01 /* flush packet */ 598 #define VKI_TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ 599 #define VKI_TIOCPKT_STOP 0x04 /* stop output */ 600 #define VKI_TIOCPKT_START 0x08 /* start output */ 601 #define VKI_TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ 602 #define VKI_TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ 603 /* #define TIOCPKT_IOCTL 0x40 state change of pty driver */ 604 #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */ 605 #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */ 606 #define VKI_TIOCNOTTY 0x5471 /* void tty association */ 607 #define VKI_TIOCSETD 0x7401 608 #define VKI_TIOCGETD 0x7400 609 610 #define VKI_FIOCLEX 0x6601 611 #define VKI_FIONCLEX 0x6602 612 #define VKI_FIOASYNC 0x667d 613 #define VKI_FIONBIO 0x667e 614 #define VKI_FIOQSIZE 0x667f 615 616 #define VKI_TIOCGLTC 0x7474 /* get special local chars */ 617 #define VKI_TIOCSLTC 0x7475 /* set special local chars */ 618 #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) /* set pgrp of tty */ 619 #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) /* get pgrp of tty */ 620 #define VKI_TIOCCONS _VKI_IOW('t', 120, int) /* become virtual console */ 621 622 #define VKI_FIONREAD 0x467f 623 #define VKI_TIOCINQ FIONREAD 624 625 #define VKI_TIOCGETP 0x7408 626 #define VKI_TIOCSETP 0x7409 627 #define VKI_TIOCSETN 0x740a /* TIOCSETP wo flush */ 628 629 #define VKI_TIOCSBRK 0x5427 /* BSD compatibility */ 630 #define VKI_TIOCCBRK 0x5428 /* BSD compatibility */ 631 #define VKI_TIOCGSID 0x7416 /* Return the session ID of FD */ 632 #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 633 #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ 634 635 /* I hope the range from 0x5480 on is free ... */ 636 #define VKI_TIOCSCTTY 0x5480 /* become controlling tty */ 637 #define VKI_TIOCGSOFTCAR 0x5481 638 #define VKI_TIOCSSOFTCAR 0x5482 639 #define VKI_TIOCLINUX 0x5483 640 #define VKI_TIOCGSERIAL 0x5484 641 #define VKI_TIOCSSERIAL 0x5485 642 #define VKI_TCSBRKP 0x5486 /* Needed for POSIX tcsendbreak() */ 643 #define VKI_TIOCSERCONFIG 0x5488 644 #define VKI_TIOCSERGWILD 0x5489 645 #define VKI_TIOCSERSWILD 0x548a 646 #define VKI_TIOCGLCKTRMIOS 0x548b 647 #define VKI_TIOCSLCKTRMIOS 0x548c 648 #define VKI_TIOCSERGSTRUCT 0x548d /* For debugging only */ 649 #define VKI_TIOCSERGETLSR 0x548e /* Get line status register */ 650 #define VKI_TIOCSERGETMULTI 0x548f /* Get multiport config */ 651 #define VKI_TIOCSERSETMULTI 0x5490 /* Set multiport config */ 652 #define VKI_TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */ 653 #define VKI_TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */ 654 #define VKI_TIOCGHAYESESP 0x5493 /* Get Hayes ESP configuration */ 655 #define VKI_TIOCSHAYESESP 0x5494 /* Set Hayes ESP configuration */ 656 657 //---------------------------------------------------------------------- 658 // From asm-generic/poll.h 659 //---------------------------------------------------------------------- 660 661 /* These are specified by iBCS2 */ 662 #define VKI_POLLIN 0x0001 663 664 struct vki_pollfd { 665 int fd; 666 short events; 667 short revents; 668 }; 669 //---------------------------------------------------------------------- 670 // From linux-2.6.35.5/include/asm-mips/ucontext.h 671 //---------------------------------------------------------------------- 672 673 struct vki_ucontext { 674 unsigned long uc_flags; 675 struct vki_ucontext *uc_link; 676 vki_stack_t uc_stack; 677 struct vki_sigcontext uc_mcontext; 678 vki_sigset_t uc_sigmask; /* mask last for extensibility */ 679 }; 680 681 // CAB: TODO 682 typedef void vki_modify_ldt_t; 683 684 //---------------------------------------------------------------------- 685 // From linux-2.6.35.5/include/asm-mips/ipcbuf.h 686 //---------------------------------------------------------------------- 687 688 struct vki_ipc64_perm 689 { 690 __vki_kernel_key_t key; 691 __vki_kernel_uid_t uid; 692 __vki_kernel_gid_t gid; 693 __vki_kernel_uid_t cuid; 694 __vki_kernel_gid_t cgid; 695 __vki_kernel_mode_t mode; 696 unsigned short seq; 697 unsigned short __pad1; 698 unsigned long __unused1; 699 unsigned long __unused2; 700 }; 701 702 //---------------------------------------------------------------------- 703 // From linux-2.6.35.5/include/asm-mips/sembuf.h 704 //---------------------------------------------------------------------- 705 706 struct vki_semid64_ds { 707 struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */ 708 __vki_kernel_time_t sem_otime; /* last semop time */ 709 __vki_kernel_time_t sem_ctime; /* last change time */ 710 unsigned long sem_nsems; /* no. of semaphores in array */ 711 unsigned long __unused1; 712 unsigned long __unused2; 713 }; 714 715 716 //---------------------------------------------------------------------- 717 // From linux-2.6.35.5/include/asm-mips/msgbuf.h 718 //---------------------------------------------------------------------- 719 720 struct vki_msqid64_ds { 721 struct vki_ipc64_perm msg_perm; 722 __vki_kernel_time_t msg_stime; /* last msgsnd time */ 723 unsigned long __unused1; 724 __vki_kernel_time_t msg_rtime; /* last msgrcv time */ 725 unsigned long __unused2; 726 __vki_kernel_time_t msg_ctime; /* last change time */ 727 unsigned long __unused3; 728 unsigned long msg_cbytes; /* current number of bytes on queue */ 729 unsigned long msg_qnum; /* number of messages in queue */ 730 unsigned long msg_qbytes; /* max number of bytes on queue */ 731 __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */ 732 __vki_kernel_pid_t msg_lrpid; /* last receive pid */ 733 unsigned long __unused4; 734 unsigned long __unused5; 735 }; 736 737 //---------------------------------------------------------------------- 738 // From linux-2.6.35.5/include/asm-mips/ipc.h 739 //---------------------------------------------------------------------- 740 741 struct vki_ipc_kludge { 742 struct vki_msgbuf __user *msgp; 743 long msgtyp; 744 }; 745 746 #define VKI_SEMOP 1 747 #define VKI_SEMGET 2 748 #define VKI_SEMCTL 3 749 #define VKI_SEMTIMEDOP 4 750 #define VKI_MSGSND 11 751 #define VKI_MSGRCV 12 752 #define VKI_MSGGET 13 753 #define VKI_MSGCTL 14 754 #define VKI_SHMAT 21 755 #define VKI_SHMDT 22 756 #define VKI_SHMGET 23 757 #define VKI_SHMCTL 24 758 759 //---------------------------------------------------------------------- 760 // From linux-2.6.35.5/include/asm-mips/shmbuf.h 761 //---------------------------------------------------------------------- 762 763 struct vki_shmid64_ds { 764 struct vki_ipc64_perm shm_perm; /* operation perms */ 765 vki_size_t shm_segsz; /* size of segment (bytes) */ 766 __vki_kernel_time_t shm_atime; /* last attach time */ 767 __vki_kernel_time_t shm_dtime; /* last detach time */ 768 __vki_kernel_time_t shm_ctime; /* last change time */ 769 __vki_kernel_pid_t shm_cpid; /* pid of creator */ 770 __vki_kernel_pid_t shm_lpid; /* pid of last operator */ 771 unsigned long shm_nattch; /* no. of current attaches */ 772 unsigned long __unused1; 773 unsigned long __unused2; 774 }; 775 776 struct vki_shminfo64 { 777 unsigned long shmmax; 778 unsigned long shmmin; 779 unsigned long shmmni; 780 unsigned long shmseg; 781 unsigned long shmall; 782 unsigned long __unused1; 783 unsigned long __unused2; 784 unsigned long __unused3; 785 unsigned long __unused4; 786 }; 787 //---------------------------------------------------------------------- 788 // From linux-2.6.35.5/include/asm-mips/ptrace.h 789 //---------------------------------------------------------------------- 790 791 struct vki_pt_regs { 792 #ifdef CONFIG_32BIT 793 /* Pad bytes for argument save space on the stack. */ 794 unsigned long pad0[6]; 795 #endif 796 /* Saved main processor registers. */ 797 unsigned long regs[32]; 798 799 /* Saved special registers. */ 800 unsigned long cp0_status; 801 unsigned long hi; 802 unsigned long lo; 803 #ifdef CONFIG_CPU_HAS_SMARTMIPS 804 unsigned long acx; 805 #endif 806 unsigned long cp0_badvaddr; 807 unsigned long cp0_cause; 808 unsigned long cp0_epc; 809 #ifdef CONFIG_MIPS_MT_SMTC 810 unsigned long cp0_tcstatus; 811 #endif /* CONFIG_MIPS_MT_SMTC */ 812 #ifdef CONFIG_CPU_CAVIUM_OCTEON 813 unsigned long long mpl[3]; /* MTM{0,1,2} */ 814 unsigned long long mtp[3]; /* MTP{0,1,2} */ 815 #endif 816 } __attribute__ ((aligned (8))); 817 818 819 #define vki_user_regs_struct vki_pt_regs 820 821 #define MIPS_lo lo 822 #define MIPS_hi hi 823 //#define MIPS_pc regs[32] 824 #define MIPS_r31 regs[31] 825 #define MIPS_r30 regs[30] 826 #define MIPS_r29 regs[29] 827 #define MIPS_r28 regs[28] 828 #define MIPS_r27 regs[27] 829 #define MIPS_r26 regs[26] 830 #define MIPS_r25 regs[25] 831 #define MIPS_r24 regs[24] 832 #define MIPS_r23 regs[23] 833 #define MIPS_r22 regs[22] 834 #define MIPS_r21 regs[21] 835 #define MIPS_r20 regs[20] 836 #define MIPS_r19 regs[19] 837 #define MIPS_r18 regs[18] 838 #define MIPS_r17 regs[17] 839 #define MIPS_r16 regs[16] 840 #define MIPS_r15 regs[15] 841 #define MIPS_r14 regs[14] 842 #define MIPS_r13 regs[13] 843 #define MIPS_r12 regs[12] 844 #define MIPS_r11 regs[11] 845 #define MIPS_r10 regs[10] 846 #define MIPS_r9 regs[9] 847 #define MIPS_r8 regs[8] 848 #define MIPS_r7 regs[7] 849 #define MIPS_r6 regs[6] 850 #define MIPS_r5 regs[5] 851 #define MIPS_r4 regs[4] 852 #define MIPS_r3 regs[3] 853 #define MIPS_r2 regs[2] 854 #define MIPS_r1 regs[1] 855 #define MIPS_r0 regs[0] 856 857 #define VKI_PTRACE_GETREGS 12 858 #define VKI_PTRACE_SETREGS 13 859 #define VKI_PTRACE_GETFPREGS 14 860 #define VKI_PTRACE_SETFPREGS 15 861 //---------------------------------------------------------------------- 862 // From linux-2.6.35.5/include/asm-mips/elf.h 863 //---------------------------------------------------------------------- 864 typedef unsigned long vki_elf_greg_t; 865 866 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) 867 #define VKI_ELF_NFPREG 33 /* includes fpscr */ 868 869 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; 870 871 typedef double vki_elf_fpreg_t; 872 typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG]; 873 874 typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t; 875 876 #define VKI_AT_SYSINFO 32 877 //---------------------------------------------------------------------- 878 // From linux-2.6.35.5/include/asm-generic/siginfo.h 879 //---------------------------------------------------------------------- 880 #define HAVE_ARCH_SIGINFO_T 881 882 typedef union vki_sigval { 883 int sival_int; 884 void __user *sival_ptr; 885 } vki_sigval_t; 886 887 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE 888 #define __VKI_ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) 889 #endif 890 891 #define VKI_SI_MAX_SIZE 128 892 893 #ifndef VKI_SI_PAD_SIZE 894 #define VKI_SI_PAD_SIZE ((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) 895 #endif 896 897 #ifndef __VKI_ARCH_SI_UID_T 898 #define __VKI_ARCH_SI_UID_T vki_uid_t 899 #endif 900 901 #ifndef __VKI_ARCH_SI_BAND_T 902 #define __VKI_ARCH_SI_BAND_T long 903 #endif 904 905 typedef struct vki_siginfo { 906 int si_signo; 907 int si_code; 908 int si_errno; 909 int __pad0[VKI_SI_MAX_SIZE / sizeof(int) - VKI_SI_PAD_SIZE - 3]; 910 911 union { 912 int _pad[VKI_SI_PAD_SIZE]; 913 914 /* kill() */ 915 struct { 916 vki_pid_t _pid; /* sender's pid */ 917 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 918 } _kill; 919 920 /* POSIX.1b timers */ 921 struct { 922 vki_timer_t _tid; /* timer id */ 923 int _overrun; /* overrun count */ 924 char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)]; 925 vki_sigval_t _sigval; /* same as below */ 926 int _sys_private; /* not to be passed to user */ 927 } _timer; 928 929 /* POSIX.1b signals */ 930 struct { 931 vki_pid_t _pid; /* sender's pid */ 932 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 933 vki_sigval_t _sigval; 934 } _rt; 935 936 /* SIGCHLD */ 937 struct { 938 vki_pid_t _pid; /* which child */ 939 __VKI_ARCH_SI_UID_T _uid; /* sender's uid */ 940 int _status; /* exit code */ 941 vki_clock_t _utime; 942 vki_clock_t _stime; 943 } _sigchld; 944 945 /* IRIX SIGCHLD */ 946 struct { 947 vki_pid_t _pid; /* which child */ 948 vki_clock_t _utime; 949 int _status; /* exit code */ 950 vki_clock_t _stime; 951 } _irix_sigchld; 952 953 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 954 struct { 955 void __user *_addr; /* faulting insn/memory ref. */ 956 #ifdef __ARCH_SI_TRAPNO 957 int _trapno; /* TRAP # which caused the signal */ 958 #endif 959 } _sigfault; 960 961 /* SIGPOLL, SIGXFSZ (To do ...) */ 962 struct { 963 __VKI_ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 964 int _fd; 965 } _sigpoll; 966 } _sifields; 967 } vki_siginfo_t; 968 969 //---------------------------------------------------------------------- 970 // From linux-2.6.35.5/include/asm/break.h 971 //---------------------------------------------------------------------- 972 #define VKI_BRK_OVERFLOW 6 /* Overflow check */ 973 #define VKI_BRK_DIVZERO 7 /* Divide by zero check */ 974 975 //---------------------------------------------------------------------- 976 // From linux-3.6.35.5/arch/mips/include/socket.h 977 //---------------------------------------------------------------------- 978 enum vki_sock_type { 979 VKI_SOCK_STREAM = 2, 980 // [[others omitted]] 981 }; 982 #define ARCH_HAS_SOCKET_TYPES 1 983 984 //---------------------------------------------------------------------- 985 // From linux-3.13.0/include/asm/errno.h 986 //---------------------------------------------------------------------- 987 988 #define VKI_ENOSYS 89 /* Function not implemented */ 989 #define VKI_EOVERFLOW 79 /* Value too large for defined data type */ 990 991 #endif // __VKI_MIPS32_LINUX_H 992 993 /*--------------------------------------------------------------------*/ 994 /*--- end vki-mips32-linux.h ---*/ 995 /*--------------------------------------------------------------------*/ 996