1 2 /*--------------------------------------------------------------------*/ 3 /*--- PPC32/Linux-specific kernel interface. vki-ppc32-linux.h ---*/ 4 /*--------------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2005-2013 Julian Seward 11 jseward (at) 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 __VKI_PPC32_LINUX_H 32 #define __VKI_PPC32_LINUX_H 33 34 // ppc32 is big-endian. 35 #define VKI_BIG_ENDIAN 1 36 37 //---------------------------------------------------------------------- 38 // From linux-2.6.9/include/asm-ppc/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 __signed__ int __vki_s32; 47 typedef unsigned int __vki_u32; 48 49 typedef __signed__ long long __vki_s64; 50 typedef unsigned long long __vki_u64; 51 52 typedef unsigned short vki_u16; 53 54 typedef unsigned int vki_u32; 55 56 typedef struct { 57 __vki_u32 u[4]; 58 } __vki_vector128; 59 60 //---------------------------------------------------------------------- 61 // From linux-2.6.9/include/asm-ppc/page.h 62 //---------------------------------------------------------------------- 63 64 /* PAGE_SHIFT determines the page size, unfortunately 65 page size might vary between 32-bit and 64-bit ppc kernels */ 66 extern UWord VKI_PAGE_SHIFT; 67 extern UWord VKI_PAGE_SIZE; 68 #define VKI_MAX_PAGE_SHIFT 16 69 #define VKI_MAX_PAGE_SIZE (1UL << VKI_MAX_PAGE_SHIFT) 70 71 //---------------------------------------------------------------------- 72 // From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h 73 //---------------------------------------------------------------------- 74 75 #define VKI_SHMLBA VKI_PAGE_SIZE 76 77 //---------------------------------------------------------------------- 78 // From linux-2.6.9/include/asm-ppc/signal.h 79 //---------------------------------------------------------------------- 80 81 #define VKI_MINSIGSTKSZ 2048 82 83 #define VKI_SIG_BLOCK 0 /* for blocking signals */ 84 #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */ 85 #define VKI_SIG_SETMASK 2 /* for setting the signal mask */ 86 87 /* Type of a signal handler. */ 88 typedef void __vki_signalfn_t(int); 89 typedef __vki_signalfn_t __user *__vki_sighandler_t; 90 91 typedef void __vki_restorefn_t(void); 92 typedef __vki_restorefn_t __user *__vki_sigrestore_t; 93 94 #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */ 95 #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */ 96 97 #define _VKI_NSIG 64 98 #define _VKI_NSIG_BPW 32 99 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW) 100 101 typedef unsigned long vki_old_sigset_t; /* at least 32 bits */ 102 103 typedef struct { 104 unsigned long sig[_VKI_NSIG_WORDS]; 105 } vki_sigset_t; 106 107 #define VKI_SIGHUP 1 108 #define VKI_SIGINT 2 109 #define VKI_SIGQUIT 3 110 #define VKI_SIGILL 4 111 #define VKI_SIGTRAP 5 112 #define VKI_SIGABRT 6 113 //#define VKI_SIGIOT 6 114 #define VKI_SIGBUS 7 115 #define VKI_SIGFPE 8 116 #define VKI_SIGKILL 9 117 #define VKI_SIGUSR1 10 118 #define VKI_SIGSEGV 11 119 #define VKI_SIGUSR2 12 120 #define VKI_SIGPIPE 13 121 #define VKI_SIGALRM 14 122 #define VKI_SIGTERM 15 123 #define VKI_SIGSTKFLT 16 124 #define VKI_SIGCHLD 17 125 #define VKI_SIGCONT 18 126 #define VKI_SIGSTOP 19 127 #define VKI_SIGTSTP 20 128 #define VKI_SIGTTIN 21 129 #define VKI_SIGTTOU 22 130 #define VKI_SIGURG 23 131 #define VKI_SIGXCPU 24 132 #define VKI_SIGXFSZ 25 133 #define VKI_SIGVTALRM 26 134 #define VKI_SIGPROF 27 135 #define VKI_SIGWINCH 28 136 #define VKI_SIGIO 29 137 #define VKI_SIGPWR 30 138 #define VKI_SIGSYS 31 139 #define VKI_SIGUNUSED 31 140 141 /* These should not be considered constants from userland. */ 142 #define VKI_SIGRTMIN 32 143 // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]] 144 #define VKI_SIGRTMAX _VKI_NSIG 145 146 #define VKI_SA_NOCLDSTOP 0x00000001 147 #define VKI_SA_NOCLDWAIT 0x00000002 148 #define VKI_SA_SIGINFO 0x00000004 149 #define VKI_SA_ONSTACK 0x08000000 150 #define VKI_SA_RESTART 0x10000000 151 #define VKI_SA_NODEFER 0x40000000 152 #define VKI_SA_RESETHAND 0x80000000 153 154 #define VKI_SA_NOMASK VKI_SA_NODEFER 155 #define VKI_SA_ONESHOT VKI_SA_RESETHAND 156 //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */ 157 158 #define VKI_SA_RESTORER 0x04000000 159 160 #define VKI_SS_ONSTACK 1 161 #define VKI_SS_DISABLE 2 162 163 /* These are 'legacy' sigactions in which the size of sa_mask is fixed 164 (cannot be expanded at any future point) because it is sandwiched 165 between two other fields. 166 (there is identical kludgery in vki-x86-linux.h) */ 167 struct vki_old_sigaction { 168 // [[Nb: a 'k' prefix is added to "sa_handler" because 169 // bits/sigaction.h (which gets dragged in somehow via signal.h) 170 // #defines it as something else. Since that is done for glibc's 171 // purposes, which we don't care about here, we use our own name.]] 172 __vki_sighandler_t ksa_handler; 173 vki_old_sigset_t sa_mask; 174 unsigned long sa_flags; 175 __vki_sigrestore_t sa_restorer; 176 }; 177 178 struct vki_sigaction_base { 179 // [[See comment about extra 'k' above]] 180 __vki_sighandler_t ksa_handler; 181 unsigned long sa_flags; 182 __vki_sigrestore_t sa_restorer; 183 vki_sigset_t sa_mask; /* mask last for extensibility */ 184 }; 185 186 /* On Linux we use the same type for passing sigactions to 187 and from the kernel. Hence: */ 188 typedef struct vki_sigaction_base vki_sigaction_toK_t; 189 typedef struct vki_sigaction_base vki_sigaction_fromK_t; 190 191 192 typedef struct vki_sigaltstack { 193 void __user *ss_sp; 194 int ss_flags; 195 vki_size_t ss_size; 196 } vki_stack_t; 197 198 199 //---------------------------------------------------------------------- 200 // From linux-2.6.9/include/asm-ppc/ptrace.h 201 //---------------------------------------------------------------------- 202 203 struct vki_pt_regs { 204 unsigned long gpr[32]; 205 unsigned long nip; 206 unsigned long msr; 207 unsigned long orig_gpr3; /* Used for restarting system calls */ 208 unsigned long ctr; 209 unsigned long link; 210 unsigned long xer; 211 unsigned long ccr; 212 unsigned long mq; /* 601 only (not used at present) */ 213 /* Used on APUS to hold IPL value. */ 214 unsigned long trap; /* Reason for being here */ 215 /* N.B. for critical exceptions on 4xx, the dar and dsisr 216 fields are overloaded to hold srr0 and srr1. */ 217 unsigned long dar; /* Fault registers */ 218 unsigned long dsisr; /* on 4xx/Book-E used for ESR */ 219 unsigned long result; /* Result of a system call */ 220 221 /* Not in kernel's definition, but apparently needed to stop 222 assertion at coredump-elf.c:267 firing. These padding 223 words make the struct have the same size as a 224 'vki_elf_greg_t'. See message from Ghassan Hammouri on 225 valgrind-developers on 6 April 06. */ 226 unsigned long pad[4]; 227 }; 228 229 #define vki_user_regs_struct vki_pt_regs 230 231 #define VKI_PT_R0 0 232 #define VKI_PT_R1 1 233 #define VKI_PT_R2 2 234 #define VKI_PT_R3 3 235 #define VKI_PT_R4 4 236 #define VKI_PT_R5 5 237 #define VKI_PT_R6 6 238 #define VKI_PT_R7 7 239 #define VKI_PT_R8 8 240 #define VKI_PT_R9 9 241 #define VKI_PT_R10 10 242 #define VKI_PT_R11 11 243 #define VKI_PT_R12 12 244 #define VKI_PT_R13 13 245 #define VKI_PT_R14 14 246 #define VKI_PT_R15 15 247 #define VKI_PT_R16 16 248 #define VKI_PT_R17 17 249 #define VKI_PT_R18 18 250 #define VKI_PT_R19 19 251 #define VKI_PT_R20 20 252 #define VKI_PT_R21 21 253 #define VKI_PT_R22 22 254 #define VKI_PT_R23 23 255 #define VKI_PT_R24 24 256 #define VKI_PT_R25 25 257 #define VKI_PT_R26 26 258 #define VKI_PT_R27 27 259 #define VKI_PT_R28 28 260 #define VKI_PT_R29 29 261 #define VKI_PT_R30 30 262 #define VKI_PT_R31 31 263 #define VKI_PT_NIP 32 264 #define VKI_PT_MSR 33 265 #define VKI_PT_ORIG_R3 34 266 #define VKI_PT_CTR 35 267 #define VKI_PT_LNK 36 268 #define VKI_PT_XER 37 269 #define VKI_PT_CCR 38 270 #define VKI_PT_MQ 39 271 #define VKI_PT_TRAP 40 272 #define VKI_PT_DAR 41 273 #define VKI_PT_DSISR 42 274 #define VKI_PT_RESULT 43 275 276 //---------------------------------------------------------------------- 277 // From linux-2.6.9/include/asm-ppc/sigcontext.h 278 //---------------------------------------------------------------------- 279 280 struct vki_sigcontext { 281 unsigned long _unused[4]; 282 int signal; 283 unsigned long handler; 284 unsigned long oldmask; 285 struct vki_pt_regs *regs; 286 }; 287 288 //---------------------------------------------------------------------- 289 // From linux-2.6.9/include/asm-ppc/mman.h 290 //---------------------------------------------------------------------- 291 292 #define VKI_PROT_NONE 0x0 /* No page permissions */ 293 #define VKI_PROT_READ 0x1 /* page can be read */ 294 #define VKI_PROT_WRITE 0x2 /* page can be written */ 295 #define VKI_PROT_EXEC 0x4 /* page can be executed */ 296 #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ 297 #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ 298 299 #define VKI_MAP_SHARED 0x01 /* Share changes */ 300 #define VKI_MAP_PRIVATE 0x02 /* Changes are private */ 301 //#define VKI_MAP_TYPE 0x0f /* Mask for type of mapping */ 302 #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */ 303 #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */ 304 #define VKI_MAP_NORESERVE 0x40 /* don't reserve swap pages */ 305 306 //---------------------------------------------------------------------- 307 // From linux-2.6.9/include/asm-ppc/fcntl.h 308 //---------------------------------------------------------------------- 309 310 #define VKI_O_ACCMODE 03 311 #define VKI_O_RDONLY 00 312 #define VKI_O_WRONLY 01 313 #define VKI_O_RDWR 02 314 #define VKI_O_CREAT 0100 /* not fcntl */ 315 #define VKI_O_EXCL 0200 /* not fcntl */ 316 #define VKI_O_TRUNC 01000 /* not fcntl */ 317 #define VKI_O_APPEND 02000 318 #define VKI_O_NONBLOCK 04000 319 #define VKI_O_LARGEFILE 0200000 320 321 #define VKI_AT_FDCWD -100 322 323 #define VKI_F_DUPFD 0 /* dup */ 324 #define VKI_F_GETFD 1 /* get close_on_exec */ 325 #define VKI_F_SETFD 2 /* set/clear close_on_exec */ 326 #define VKI_F_GETFL 3 /* get file->f_flags */ 327 #define VKI_F_SETFL 4 /* set file->f_flags */ 328 #define VKI_F_GETLK 5 329 #define VKI_F_SETLK 6 330 #define VKI_F_SETLKW 7 331 332 #define VKI_F_SETOWN 8 /* for sockets. */ 333 #define VKI_F_GETOWN 9 /* for sockets. */ 334 #define VKI_F_SETSIG 10 /* for sockets. */ 335 #define VKI_F_GETSIG 11 /* for sockets. */ 336 337 #define VKI_F_GETLK64 12 /* using 'struct flock64' */ 338 #define VKI_F_SETLK64 13 339 #define VKI_F_SETLKW64 14 340 341 #define VKI_F_SETOWN_EX 15 342 #define VKI_F_GETOWN_EX 16 343 344 #define VKI_F_OWNER_TID 0 345 #define VKI_F_OWNER_PID 1 346 #define VKI_F_OWNER_PGRP 2 347 348 struct vki_f_owner_ex { 349 int type; 350 __vki_kernel_pid_t pid; 351 }; 352 353 /* for F_[GET|SET]FL */ 354 #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */ 355 356 #define VKI_F_LINUX_SPECIFIC_BASE 1024 357 358 //---------------------------------------------------------------------- 359 // From linux-2.6.9/include/asm-ppc/resource.h 360 //---------------------------------------------------------------------- 361 362 #define VKI_RLIMIT_DATA 2 /* max data size */ 363 #define VKI_RLIMIT_STACK 3 /* max stack size */ 364 #define VKI_RLIMIT_CORE 4 /* max core file size */ 365 #define VKI_RLIMIT_NOFILE 7 /* max number of open files */ 366 367 //---------------------------------------------------------------------- 368 // From linux-2.6.9/include/asm-ppc/socket.h 369 //---------------------------------------------------------------------- 370 371 #define VKI_SOL_SOCKET 1 372 373 #define VKI_SO_TYPE 3 374 375 #define VKI_SO_ATTACH_FILTER 26 376 377 //---------------------------------------------------------------------- 378 // From linux-2.6.8.1/include/asm-ppc/sockios.h 379 //---------------------------------------------------------------------- 380 381 #define VKI_SIOCSPGRP 0x8902 382 #define VKI_SIOCGPGRP 0x8904 383 #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ 384 #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ 385 386 //---------------------------------------------------------------------- 387 // From linux-2.6.10/include/asm-ppc/stat.h 388 //---------------------------------------------------------------------- 389 390 //.. #define VKI_S_IFMT 00170000 391 //.. #define VKI_S_IFSOCK 0140000 392 //.. #define VKI_S_IFLNK 0120000 393 //.. #define VKI_S_IFREG 0100000 394 //.. #define VKI_S_IFBLK 0060000 395 //.. #define VKI_S_IFDIR 0040000 396 //.. #define VKI_S_IFCHR 0020000 397 //.. #define VKI_S_IFIFO 0010000 398 //.. #define VKI_S_ISUID 0004000 399 //.. #define VKI_S_ISGID 0002000 400 //.. #define VKI_S_ISVTX 0001000 401 //.. 402 //.. #define VKI_S_ISLNK(m) (((m) & VKI_S_IFMT) == VKI_S_IFLNK) 403 //.. #define VKI_S_ISREG(m) (((m) & VKI_S_IFMT) == VKI_S_IFREG) 404 //.. #define VKI_S_ISDIR(m) (((m) & VKI_S_IFMT) == VKI_S_IFDIR) 405 //.. #define VKI_S_ISCHR(m) (((m) & VKI_S_IFMT) == VKI_S_IFCHR) 406 //.. #define VKI_S_ISBLK(m) (((m) & VKI_S_IFMT) == VKI_S_IFBLK) 407 //.. #define VKI_S_ISFIFO(m) (((m) & VKI_S_IFMT) == VKI_S_IFIFO) 408 //.. #define VKI_S_ISSOCK(m) (((m) & VKI_S_IFMT) == VKI_S_IFSOCK) 409 410 struct vki_stat { 411 unsigned st_dev; 412 unsigned long st_ino; 413 unsigned int st_mode; 414 unsigned short st_nlink; 415 unsigned int st_uid; 416 unsigned int st_gid; 417 unsigned st_rdev; 418 long st_size; 419 unsigned long st_blksize; 420 unsigned long st_blocks; 421 unsigned long st_atime; 422 unsigned long st_atime_nsec; 423 unsigned long st_mtime; 424 unsigned long st_mtime_nsec; 425 unsigned long st_ctime; 426 unsigned long st_ctime_nsec; 427 unsigned long __unused4; 428 unsigned long __unused5; 429 }; 430 431 struct vki_stat64 { 432 unsigned long long st_dev; 433 unsigned long long st_ino; 434 unsigned int st_mode; 435 unsigned int st_nlink; 436 unsigned int st_uid; 437 unsigned int st_gid; 438 unsigned long long st_rdev; 439 unsigned short int __pad2; 440 long long st_size; 441 long st_blksize; 442 443 long long st_blocks; 444 long st_atime; 445 unsigned long st_atime_nsec; 446 long st_mtime; 447 unsigned long int st_mtime_nsec; 448 long st_ctime; 449 unsigned long int st_ctime_nsec; 450 unsigned long int __unused4; 451 unsigned long int __unused5; 452 }; 453 454 455 //---------------------------------------------------------------------- 456 // From linux-2.6.9/include/asm-ppc/statfs.h 457 //---------------------------------------------------------------------- 458 459 // [[Nb: asm-ppc/statfs.h just #include asm-generic/statfs.h directly]] 460 struct vki_statfs { 461 __vki_u32 f_type; 462 __vki_u32 f_bsize; 463 __vki_u32 f_blocks; 464 __vki_u32 f_bfree; 465 __vki_u32 f_bavail; 466 __vki_u32 f_files; 467 __vki_u32 f_ffree; 468 __vki_kernel_fsid_t f_fsid; 469 __vki_u32 f_namelen; 470 __vki_u32 f_frsize; 471 __vki_u32 f_spare[5]; 472 }; 473 474 //---------------------------------------------------------------------- 475 // From linux-2.6.9/include/asm-ppc/termios.h 476 //---------------------------------------------------------------------- 477 478 struct vki_winsize { 479 unsigned short ws_row; 480 unsigned short ws_col; 481 unsigned short ws_xpixel; 482 unsigned short ws_ypixel; 483 }; 484 485 #define NCC 10 486 struct vki_termio { 487 unsigned short c_iflag; /* input mode flags */ 488 unsigned short c_oflag; /* output mode flags */ 489 unsigned short c_cflag; /* control mode flags */ 490 unsigned short c_lflag; /* local mode flags */ 491 unsigned char c_line; /* line discipline */ 492 unsigned char c_cc[NCC]; /* control characters */ 493 }; 494 495 //---------------------------------------------------------------------- 496 // From linux-2.6.9/include/asm-ppc/termbits.h 497 //---------------------------------------------------------------------- 498 499 typedef unsigned char vki_cc_t; 500 typedef unsigned int vki_speed_t; 501 typedef unsigned int vki_tcflag_t; 502 503 #define NCCS 19 504 struct vki_termios { 505 vki_tcflag_t c_iflag; /* input mode flags */ 506 vki_tcflag_t c_oflag; /* output mode flags */ 507 vki_tcflag_t c_cflag; /* control mode flags */ 508 vki_tcflag_t c_lflag; /* local mode flags */ 509 vki_cc_t c_cc[NCCS]; /* control characters */ 510 vki_cc_t c_line; /* line discipline (== c_cc[19]) */ 511 vki_speed_t c_ispeed; /* input speed */ 512 vki_speed_t c_ospeed; /* output speed */ 513 }; 514 515 //---------------------------------------------------------------------- 516 // From linux-2.6.9/include/asm-ppc/ioctl.h 517 //---------------------------------------------------------------------- 518 519 #define _VKI_IOC_NRBITS 8 520 #define _VKI_IOC_TYPEBITS 8 521 #define _VKI_IOC_SIZEBITS 13 522 #define _VKI_IOC_DIRBITS 3 523 524 #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1) 525 #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1) 526 #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1) 527 #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1) 528 529 #define _VKI_IOC_NRSHIFT 0 530 #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) 531 #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) 532 #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) 533 534 #define _VKI_IOC_NONE 1U 535 #define _VKI_IOC_READ 2U 536 #define _VKI_IOC_WRITE 4U 537 538 #define _VKI_IOC(dir,type,nr,size) \ 539 (((dir) << _VKI_IOC_DIRSHIFT) | \ 540 ((type) << _VKI_IOC_TYPESHIFT) | \ 541 ((nr) << _VKI_IOC_NRSHIFT) | \ 542 ((size) << _VKI_IOC_SIZESHIFT)) 543 544 /* used to create numbers */ 545 #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) 546 #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 547 #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 548 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) 549 550 /* used to decode them.. */ 551 #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) 552 //.. #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK) 553 //.. #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK) 554 #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) 555 556 //---------------------------------------------------------------------- 557 // From linux-2.6.9/include/asm-ppc/ioctls.h 558 //---------------------------------------------------------------------- 559 560 #define VKI_FIOCLEX _VKI_IO('f', 1) 561 #define VKI_FIONCLEX _VKI_IO('f', 2) 562 #define VKI_FIOASYNC _VKI_IOW('f', 125, int) 563 #define VKI_FIONBIO _VKI_IOW('f', 126, int) 564 #define VKI_FIONREAD _VKI_IOR('f', 127, int) 565 //#define VKI_TIOCINQ VKI_FIONREAD 566 #define VKI_FIOQSIZE _VKI_IOR('f', 128, vki_loff_t) 567 568 //#define VKI_TIOCGETP _VKI_IOR('t', 8, struct vki_sgttyb) 569 //#define VKI_TIOCSETP _VKI_IOW('t', 9, struct vki_sgttyb) 570 //#define VKI_TIOCSETN _VKI_IOW('t', 10, struct vki_sgttyb) /* TIOCSETP wo flush */ 571 572 //#define VKI_TIOCSETC _VKI_IOW('t', 17, struct vki_tchars) 573 //#define VKI_TIOCGETC _VKI_IOR('t', 18, struct vki_tchars) 574 #define VKI_TCGETS _VKI_IOR('t', 19, struct vki_termios) 575 #define VKI_TCSETS _VKI_IOW('t', 20, struct vki_termios) 576 #define VKI_TCSETSW _VKI_IOW('t', 21, struct vki_termios) 577 #define VKI_TCSETSF _VKI_IOW('t', 22, struct vki_termios) 578 579 #define VKI_TCGETA _VKI_IOR('t', 23, struct vki_termio) 580 #define VKI_TCSETA _VKI_IOW('t', 24, struct vki_termio) 581 #define VKI_TCSETAW _VKI_IOW('t', 25, struct vki_termio) 582 #define VKI_TCSETAF _VKI_IOW('t', 28, struct vki_termio) 583 584 #define VKI_TCSBRK _VKI_IO('t', 29) 585 #define VKI_TCXONC _VKI_IO('t', 30) 586 #define VKI_TCFLSH _VKI_IO('t', 31) 587 588 #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) 589 #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) 590 //#define VKI_TIOCSTART _VKI_IO('t', 110) /* start output, like ^Q */ 591 //#define VKI_TIOCSTOP _VKI_IO('t', 111) /* stop output, like ^S */ 592 #define VKI_TIOCOUTQ _VKI_IOR('t', 115, int) /* output queue size */ 593 594 //#define VKI_TIOCGLTC _VKI_IOR('t', 116, struct vki_ltchars) 595 //#define VKI_TIOCSLTC _VKI_IOW('t', 117, struct vki_ltchars) 596 #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) 597 #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) 598 599 //#define VKI_TIOCEXCL 0x540C 600 //#define VKI_TIOCNXCL 0x540D 601 #define VKI_TIOCSCTTY 0x540E 602 603 //#define VKI_TIOCSTI 0x5412 604 #define VKI_TIOCMGET 0x5415 605 #define VKI_TIOCMBIS 0x5416 606 #define VKI_TIOCMBIC 0x5417 607 #define VKI_TIOCMSET 0x5418 608 //# define VKI_TIOCM_LE 0x001 609 //# define VKI_TIOCM_DTR 0x002 610 //# define VKI_TIOCM_RTS 0x004 611 //# define VKI_TIOCM_ST 0x008 612 //# define VKI_TIOCM_SR 0x010 613 //# define VKI_TIOCM_CTS 0x020 614 //# define VKI_TIOCM_CAR 0x040 615 //# define VKI_TIOCM_RNG 0x080 616 //# define VKI_TIOCM_DSR 0x100 617 //# define VKI_TIOCM_CD VKI_TIOCM_CAR 618 //# define VKI_TIOCM_RI VKI_TIOCM_RNG 619 620 //#define VKI_TIOCGSOFTCAR 0x5419 621 //#define VKI_TIOCSSOFTCAR 0x541A 622 #define VKI_TIOCLINUX 0x541C 623 //#define VKI_TIOCCONS 0x541D 624 //#define VKI_TIOCGSERIAL 0x541E 625 //#define VKI_TIOCSSERIAL 0x541F 626 //#define VKI_TIOCPKT 0x5420 627 //# define VKI_TIOCPKT_DATA 0 628 //# define VKI_TIOCPKT_FLUSHREAD 1 629 //# define VKI_TIOCPKT_FLUSHWRITE 2 630 //# define VKI_TIOCPKT_STOP 4 631 //# define VKI_TIOCPKT_START 8 632 //# define VKI_TIOCPKT_NOSTOP 16 633 //# define VKI_TIOCPKT_DOSTOP 32 634 635 //#define VKI_TIOCNOTTY 0x5422 636 //#define VKI_TIOCSETD 0x5423 637 //#define VKI_TIOCGETD 0x5424 638 #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 639 //#define VKI_TIOCSBRK 0x5427 /* BSD compatibility */ 640 //#define VKI_TIOCCBRK 0x5428 /* BSD compatibility */ 641 //#define VKI_TIOCGSID 0x5429 /* Return the session ID of FD */ 642 #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 643 #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ 644 645 //#define VKI_TIOCSERCONFIG 0x5453 646 //#define VKI_TIOCSERGWILD 0x5454 647 //#define VKI_TIOCSERSWILD 0x5455 648 //#define VKI_TIOCGLCKTRMIOS 0x5456 649 //#define VKI_TIOCSLCKTRMIOS 0x5457 650 //#define VKI_TIOCSERGSTRUCT 0x5458 /* For debugging only */ 651 #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */ 652 /* ioctl (fd, VKI_TIOCSERGETLSR, &result) where result may be as below */ 653 //# define VKI_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 654 //#define VKI_TIOCSERGETMULTI 0x545A /* Get multiport config */ 655 //#define VKI_TIOCSERSETMULTI 0x545B /* Set multiport config */ 656 657 //#define VKI_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 658 #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 659 660 //---------------------------------------------------------------------- 661 // From linux-2.6.9/include/asm-ppc/poll.h 662 //---------------------------------------------------------------------- 663 664 //.. /* These are specified by iBCS2 */ 665 //.. #define VKI_POLLIN 0x0001 666 667 struct vki_pollfd { 668 int fd; 669 short events; 670 short revents; 671 }; 672 673 //.. //---------------------------------------------------------------------- 674 //.. // From linux-2.6.8.1/include/asm-i386/user.h 675 //.. //---------------------------------------------------------------------- 676 //.. 677 //.. struct vki_user_i387_struct { 678 //.. long cwd; 679 //.. long swd; 680 //.. long twd; 681 //.. long fip; 682 //.. long fcs; 683 //.. long foo; 684 //.. long fos; 685 //.. long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ 686 //.. }; 687 //.. 688 //.. struct vki_user_fxsr_struct { 689 //.. unsigned short cwd; 690 //.. unsigned short swd; 691 //.. unsigned short twd; 692 //.. unsigned short fop; 693 //.. long fip; 694 //.. long fcs; 695 //.. long foo; 696 //.. long fos; 697 //.. long mxcsr; 698 //.. long reserved; 699 //.. long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ 700 //.. long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ 701 //.. long padding[56]; 702 //.. }; 703 //.. 704 //.. /* 705 //.. * This is the old layout of "struct pt_regs", and 706 //.. * is still the layout used by user mode (the new 707 //.. * pt_regs doesn't have all registers as the kernel 708 //.. * doesn't use the extra segment registers) 709 //.. */ 710 //.. struct vki_user_regs_struct { 711 //.. long ebx, ecx, edx, esi, edi, ebp, eax; 712 //.. unsigned short ds, __ds, es, __es; 713 //.. unsigned short fs, __fs, gs, __gs; 714 //.. long orig_eax, eip; 715 //.. unsigned short cs, __cs; 716 //.. long eflags, esp; 717 //.. unsigned short ss, __ss; 718 //.. }; 719 720 //---------------------------------------------------------------------- 721 // From linux-2.6.9/include/asm-ppc/elf.h 722 //---------------------------------------------------------------------- 723 724 #define VKI_ELF_NGREG 48 /* includes nip, msr, lr, etc. */ 725 #define VKI_ELF_NFPREG 33 /* includes fpscr */ 726 #define VKI_ELF_NVRREG 33 /* includes vscr */ 727 728 /* General registers */ 729 typedef unsigned long vki_elf_greg_t; 730 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; 731 732 /* Floating point registers */ 733 typedef double vki_elf_fpreg_t; 734 typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG]; 735 736 /* Altivec registers */ 737 typedef __vki_vector128 vki_elf_vrreg_t; 738 typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG]; 739 740 #define VKI_AT_DCACHEBSIZE 19 741 #define VKI_AT_ICACHEBSIZE 20 742 #define VKI_AT_UCACHEBSIZE 21 743 /* A special ignored type value for PPC, for glibc compatibility. */ 744 #define VKI_AT_IGNOREPPC 22 745 746 /* CAB: Do we want these? */ 747 //#define VKI_AT_SYSINFO 32 748 //#define VKI_AT_SYSINFO_EHDR 33 749 750 //---------------------------------------------------------------------- 751 // From linux-2.6.9/include/asm-ppc/ucontext.h 752 //---------------------------------------------------------------------- 753 754 struct vki_mcontext { 755 vki_elf_gregset_t mc_gregs; 756 vki_elf_fpregset_t mc_fregs; 757 unsigned long mc_pad[2]; 758 vki_elf_vrregset_t mc_vregs __attribute__((__aligned__(16))); 759 }; 760 761 struct vki_ucontext { 762 unsigned long uc_flags; 763 struct vki_ucontext __user *uc_link; 764 vki_stack_t uc_stack; 765 int uc_pad[7]; 766 struct vki_mcontext __user *uc_regs; /* points to uc_mcontext field */ 767 vki_sigset_t uc_sigmask; 768 /* glibc has 1024-bit signal masks, ours are 64-bit */ 769 int uc_maskext[30]; 770 int uc_pad2[3]; 771 struct vki_mcontext uc_mcontext; 772 }; 773 774 //.. //---------------------------------------------------------------------- 775 //.. // From linux-2.6.8.1/include/asm-i386/segment.h 776 //.. //---------------------------------------------------------------------- 777 //.. 778 //.. #define VKI_GDT_ENTRY_TLS_ENTRIES 3 779 //.. #define VKI_GDT_ENTRY_TLS_MIN 6 780 //.. #define VKI_GDT_ENTRY_TLS_MAX (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1) 781 782 //---------------------------------------------------------------------- 783 // From linux-2.6.9/include/asm-ppc/ldt.h 784 //---------------------------------------------------------------------- 785 786 //.. /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as 787 //.. to confuse and annoy everyone, this is _not_ the same as an 788 //.. VgLdtEntry and has to be translated into such. The logic for doing 789 //.. so, in vg_ldt.c, is copied from the kernel sources.]] */ 790 //.. struct vki_user_desc { 791 //.. unsigned int entry_number; 792 //.. unsigned long base_addr; 793 //.. unsigned int limit; 794 //.. unsigned int seg_32bit:1; 795 //.. unsigned int contents:2; 796 //.. unsigned int read_exec_only:1; 797 //.. unsigned int limit_in_pages:1; 798 //.. unsigned int seg_not_present:1; 799 //.. unsigned int useable:1; 800 //.. // [[Nb: this field is not in the kernel sources, but it has always 801 //.. // been in the Valgrind sources so I will keep it there in case it's 802 //.. // important... this is an x86-defined data structure so who 803 //.. // knows; maybe it's important to set this field to zero at some 804 //.. // point. --njn]] 805 //.. unsigned int reserved:25; 806 //.. }; 807 //.. 808 //.. // [[Nb: for our convenience within Valgrind, use a more specific name]] 809 //.. typedef struct vki_user_desc vki_modify_ldt_t; 810 811 // CAB: TODO 812 typedef void vki_modify_ldt_t; 813 814 815 //---------------------------------------------------------------------- 816 // From linux-2.6.9/include/asm-ppc/ipcbuf.h 817 //---------------------------------------------------------------------- 818 819 struct vki_ipc64_perm 820 { 821 __vki_kernel_key_t key; 822 __vki_kernel_uid_t uid; 823 __vki_kernel_gid_t gid; 824 __vki_kernel_uid_t cuid; 825 __vki_kernel_gid_t cgid; 826 __vki_kernel_mode_t mode; 827 unsigned long seq; 828 unsigned int __pad2; 829 unsigned long long __unused1; 830 unsigned long long __unused2; 831 }; 832 833 //---------------------------------------------------------------------- 834 // From linux-2.6.9/include/asm-ppc/sembuf.h 835 //---------------------------------------------------------------------- 836 837 struct vki_semid64_ds { 838 struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */ 839 unsigned int __unused1; 840 __vki_kernel_time_t sem_otime; /* last semop time */ 841 unsigned int __unused2; 842 __vki_kernel_time_t sem_ctime; /* last change time */ 843 unsigned long sem_nsems; /* no. of semaphores in array */ 844 unsigned long __unused3; 845 unsigned long __unused4; 846 }; 847 848 //---------------------------------------------------------------------- 849 // From linux-2.6.9/include/asm-ppc/msgbuf.h 850 //---------------------------------------------------------------------- 851 852 struct vki_msqid64_ds { 853 struct vki_ipc64_perm msg_perm; 854 unsigned int __unused1; 855 __vki_kernel_time_t msg_stime; /* last msgsnd time */ 856 unsigned int __unused2; 857 __vki_kernel_time_t msg_rtime; /* last msgrcv time */ 858 unsigned int __unused3; 859 __vki_kernel_time_t msg_ctime; /* last change time */ 860 unsigned long msg_cbytes; /* current number of bytes on queue */ 861 unsigned long msg_qnum; /* number of messages in queue */ 862 unsigned long msg_qbytes; /* max number of bytes on queue */ 863 __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */ 864 __vki_kernel_pid_t msg_lrpid; /* last receive pid */ 865 unsigned long __unused4; 866 unsigned long __unused5; 867 }; 868 869 //---------------------------------------------------------------------- 870 // From linux-2.6.8.1/include/asm-ppc/ipc.h 871 //---------------------------------------------------------------------- 872 873 struct vki_ipc_kludge { 874 struct vki_msgbuf __user *msgp; 875 long msgtyp; 876 }; 877 878 #define VKI_SEMOP 1 879 #define VKI_SEMGET 2 880 #define VKI_SEMCTL 3 881 #define VKI_SEMTIMEDOP 4 882 #define VKI_MSGSND 11 883 #define VKI_MSGRCV 12 884 #define VKI_MSGGET 13 885 #define VKI_MSGCTL 14 886 #define VKI_SHMAT 21 887 #define VKI_SHMDT 22 888 #define VKI_SHMGET 23 889 #define VKI_SHMCTL 24 890 891 //---------------------------------------------------------------------- 892 // From linux-2.6.9/include/asm-ppc/shmbuf.h 893 //---------------------------------------------------------------------- 894 895 struct vki_shmid64_ds { 896 struct vki_ipc64_perm shm_perm; /* operation perms */ 897 unsigned int __unused1; 898 __vki_kernel_time_t shm_atime; /* last attach time */ 899 unsigned int __unused2; 900 __vki_kernel_time_t shm_dtime; /* last detach time */ 901 unsigned int __unused3; 902 __vki_kernel_time_t shm_ctime; /* last change time */ 903 unsigned int __unused4; 904 vki_size_t shm_segsz; /* size of segment (bytes) */ 905 __vki_kernel_pid_t shm_cpid; /* pid of creator */ 906 __vki_kernel_pid_t shm_lpid; /* pid of last operator */ 907 unsigned long shm_nattch; /* no. of current attaches */ 908 unsigned long __unused5; 909 unsigned long __unused6; 910 }; 911 912 struct vki_shminfo64 { 913 unsigned long shmmax; 914 unsigned long shmmin; 915 unsigned long shmmni; 916 unsigned long shmseg; 917 unsigned long shmall; 918 unsigned long __unused1; 919 unsigned long __unused2; 920 unsigned long __unused3; 921 unsigned long __unused4; 922 }; 923 924 //---------------------------------------------------------------------- 925 // From linux-2.6.8.1/include/asm-generic/errno.h 926 //---------------------------------------------------------------------- 927 928 #define VKI_ENOSYS 38 /* Function not implemented */ 929 #define VKI_EOVERFLOW 75 /* Value too large for defined data type */ 930 931 //.. //---------------------------------------------------------------------- 932 //.. // DRM ioctls 933 //.. //---------------------------------------------------------------------- 934 //.. 935 //.. // jrs 20050207: where did all this stuff come from? Is it really 936 //.. // i386 specific, or should it go into the linux-generic category? 937 //.. //struct vki_drm_buf_pub { 938 //.. // Int idx; /**< Index into the master buffer list */ 939 //.. // Int total; /**< Buffer size */ 940 //.. // Int used; /**< Amount of buffer in use (for DMA) */ 941 //.. // void __user *address; /**< Address of buffer */ 942 //.. //}; 943 //.. // 944 //.. //struct vki_drm_buf_map { 945 //.. // Int count; /**< Length of the buffer list */ 946 //.. // void __user *virtual; /**< Mmap'd area in user-virtual */ 947 //.. // struct vki_drm_buf_pub __user *list; /**< Buffer information */ 948 //.. //}; 949 //.. // 950 //.. ///* We need to pay attention to this, because it mmaps memory */ 951 //.. //#define VKI_DRM_IOCTL_MAP_BUFS _VKI_IOWR('d', 0x19, struct vki_drm_buf_map) 952 953 //---------------------------------------------------------------------- 954 // And that's it! 955 //---------------------------------------------------------------------- 956 957 #endif // __VKI_PPC32_LINUX_H 958 959 /*--------------------------------------------------------------------*/ 960 /*--- end ---*/ 961 /*--------------------------------------------------------------------*/ 962