Home | History | Annotate | Download | only in vki
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- PPC64/Linux-specific kernel interface.     vki-ppc64-linux.h ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2005-2017 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_PPC64_LINUX_H
     32 #define __VKI_PPC64_LINUX_H
     33 
     34 #if defined(VGP_ppc32_linux) || defined(VGP_ppc64be_linux)
     35 #define VKI_BIG_ENDIAN  1
     36 #elif defined(VGP_ppc64le_linux)
     37 #define VKI_LITTLE_ENDIAN  1
     38 #endif
     39 //----------------------------------------------------------------------
     40 // From linux-2.6.13/include/asm-ppc64/types.h
     41 //----------------------------------------------------------------------
     42 
     43 typedef __signed__ char __vki_s8;
     44 typedef unsigned char __vki_u8;
     45 
     46 typedef __signed__ short __vki_s16;
     47 typedef unsigned short __vki_u16;
     48 
     49 typedef __signed__ int __vki_s32;
     50 typedef unsigned int __vki_u32;
     51 
     52 typedef __signed__ long __vki_s64;
     53 typedef unsigned long __vki_u64;
     54 
     55 typedef struct {
     56   __vki_u32 u[4];
     57 } __attribute((aligned(16))) __vki_vector128;
     58 
     59 typedef unsigned short vki_u16;
     60 
     61 typedef unsigned int vki_u32;
     62 
     63 //----------------------------------------------------------------------
     64 // From linux-2.6.13/include/asm-ppc64/page.h
     65 //----------------------------------------------------------------------
     66 
     67 /* PAGE_SHIFT determines the page size, unfortunately
     68    page size might vary between 32-bit and 64-bit ppc kernels */
     69 extern UWord VKI_PAGE_SHIFT;
     70 extern UWord VKI_PAGE_SIZE;
     71 #define VKI_MAX_PAGE_SHIFT	16
     72 #define VKI_MAX_PAGE_SIZE	(1UL << VKI_MAX_PAGE_SHIFT)
     73 
     74 //----------------------------------------------------------------------
     75 // From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h
     76 //----------------------------------------------------------------------
     77 
     78 #define VKI_SHMLBA  VKI_PAGE_SIZE
     79 
     80 //----------------------------------------------------------------------
     81 // From linux-2.6.13/include/asm-ppc64/signal.h
     82 //----------------------------------------------------------------------
     83 
     84 #define VKI_MINSIGSTKSZ     2048
     85 
     86 /* Next 9 non-blank lines asm-generic/signal.h */
     87 #define VKI_SIG_BLOCK          0 /* for blocking signals */
     88 #define VKI_SIG_UNBLOCK        1 /* for unblocking signals */
     89 #define VKI_SIG_SETMASK        2 /* for setting the signal mask */
     90 
     91 typedef void __vki_signalfn_t(int);
     92 typedef __vki_signalfn_t __user *__vki_sighandler_t;
     93 
     94 typedef void __vki_restorefn_t(void);
     95 typedef __vki_restorefn_t __user *__vki_sigrestore_t;
     96 
     97 #define VKI_SIG_DFL ((__vki_sighandler_t)0)     /* default signal handling */
     98 #define VKI_SIG_IGN ((__vki_sighandler_t)1)     /* ignore signal */
     99 
    100 /* Back in asm-ppc64/signal.h */
    101 #define _VKI_NSIG           64
    102 #define _VKI_NSIG_BPW       64
    103 #define _VKI_NSIG_WORDS     (_VKI_NSIG / _VKI_NSIG_BPW)
    104 
    105 typedef unsigned long vki_old_sigset_t;             /* at least 32 bits */
    106 
    107 typedef struct {
    108   unsigned long sig[_VKI_NSIG_WORDS];
    109 } vki_sigset_t;
    110 
    111 #define VKI_SIGHUP           1
    112 #define VKI_SIGINT           2
    113 #define VKI_SIGQUIT          3
    114 #define VKI_SIGILL           4
    115 #define VKI_SIGTRAP          5
    116 #define VKI_SIGABRT          6
    117 #define VKI_SIGIOT           6
    118 #define VKI_SIGBUS           7
    119 #define VKI_SIGFPE           8
    120 #define VKI_SIGKILL          9
    121 #define VKI_SIGUSR1         10
    122 #define VKI_SIGSEGV         11
    123 #define VKI_SIGUSR2         12
    124 #define VKI_SIGPIPE         13
    125 #define VKI_SIGALRM         14
    126 #define VKI_SIGTERM         15
    127 #define VKI_SIGSTKFLT       16
    128 #define VKI_SIGCHLD         17
    129 #define VKI_SIGCONT         18
    130 #define VKI_SIGSTOP         19
    131 #define VKI_SIGTSTP         20
    132 #define VKI_SIGTTIN         21
    133 #define VKI_SIGTTOU         22
    134 #define VKI_SIGURG          23
    135 #define VKI_SIGXCPU         24
    136 #define VKI_SIGXFSZ         25
    137 #define VKI_SIGVTALRM       26
    138 #define VKI_SIGPROF         27
    139 #define VKI_SIGWINCH        28
    140 #define VKI_SIGIO           29
    141 #define VKI_SIGPOLL         VKI_SIGIO
    142 #define VKI_SIGPWR          30
    143 #define VKI_SIGSYS          31
    144 #define VKI_SIGUNUSED       31
    145 
    146 /* These should not be considered constants from userland.  */
    147 #define VKI_SIGRTMIN        32
    148 #define VKI_SIGRTMAX        _VKI_NSIG
    149 
    150 #define VKI_SA_NOCLDSTOP    0x00000001u
    151 #define VKI_SA_NOCLDWAIT    0x00000002u
    152 #define VKI_SA_SIGINFO      0x00000004u
    153 #define VKI_SA_ONSTACK      0x08000000u
    154 #define VKI_SA_RESTART      0x10000000u
    155 #define VKI_SA_NODEFER      0x40000000u
    156 #define VKI_SA_RESETHAND    0x80000000u
    157 
    158 #define VKI_SA_NOMASK       VKI_SA_NODEFER
    159 #define VKI_SA_ONESHOT      VKI_SA_RESETHAND
    160 //#define VKI_SA_INTERRUPT    0x20000000u /* dummy -- ignored */
    161 
    162 #define VKI_SA_RESTORER     0x04000000u
    163 
    164 #define VKI_SS_ONSTACK      1
    165 #define VKI_SS_DISABLE      2
    166 
    167 // See comments on corresponding decls in vki-x86-linux.h re ksa_handler
    168 struct vki_old_sigaction {
    169   __vki_sighandler_t ksa_handler;
    170   vki_old_sigset_t sa_mask;
    171   unsigned long sa_flags;
    172   __vki_sigrestore_t sa_restorer;
    173 };
    174 
    175 struct vki_sigaction_base {
    176   __vki_sighandler_t ksa_handler;
    177   unsigned long sa_flags;
    178   __vki_sigrestore_t sa_restorer;
    179   vki_sigset_t sa_mask;               /* mask last for extensibility */
    180 };
    181 
    182 /* On Linux we use the same type for passing sigactions to
    183    and from the kernel.  Hence: */
    184 typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
    185 typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
    186 
    187 
    188 typedef struct vki_sigaltstack {
    189   void __user *ss_sp;
    190   int ss_flags;
    191   vki_size_t ss_size;
    192 } vki_stack_t;
    193 
    194 //----------------------------------------------------------------------
    195 // From linux-2.6.13/include/asm-ppc64/ptrace.h
    196 //----------------------------------------------------------------------
    197 
    198 #define VKI_PPC_REG unsigned long
    199 struct vki_pt_regs {
    200   VKI_PPC_REG gpr[32];
    201   VKI_PPC_REG nip;
    202   VKI_PPC_REG msr;
    203   VKI_PPC_REG orig_gpr3;      /* Used for restarting system calls */
    204   VKI_PPC_REG ctr;
    205   VKI_PPC_REG link;
    206   VKI_PPC_REG xer;
    207   VKI_PPC_REG ccr;
    208   VKI_PPC_REG softe;          /* Soft enabled/disabled */
    209   VKI_PPC_REG trap;           /* Reason for being here */
    210   VKI_PPC_REG dar;            /* Fault registers */
    211   VKI_PPC_REG dsisr;
    212   VKI_PPC_REG result;         /* Result of a system call */
    213 
    214   /* Not in kernel's definition, but apparently needed to stop
    215      assertion at coredump-elf.c:267 firing.  These padding words make
    216      the struct have the same size as a 'vki_elf_greg_t'.  See message
    217      from Ghassan Hammouri on valgrind-developers on 6 April 06, and
    218      also the analogous kludge for ppc32-linux (svn r5852 and bug
    219      #121617). */
    220   unsigned long pad[4];
    221 };
    222 
    223 /* Kludge?  I don't know where this came from or if it is right. */
    224 #define vki_user_regs_struct vki_pt_regs
    225 
    226 #define VKI_PT_R0   0
    227 #define VKI_PT_R1   1
    228 #define VKI_PT_R2   2
    229 #define VKI_PT_R3   3
    230 #define VKI_PT_R4   4
    231 #define VKI_PT_R5   5
    232 #define VKI_PT_R6   6
    233 #define VKI_PT_R7   7
    234 #define VKI_PT_R8   8
    235 #define VKI_PT_R9   9
    236 #define VKI_PT_R10  10
    237 #define VKI_PT_R11  11
    238 #define VKI_PT_R12  12
    239 #define VKI_PT_R13  13
    240 #define VKI_PT_R14  14
    241 #define VKI_PT_R15  15
    242 #define VKI_PT_R16  16
    243 #define VKI_PT_R17  17
    244 #define VKI_PT_R18  18
    245 #define VKI_PT_R19  19
    246 #define VKI_PT_R20  20
    247 #define VKI_PT_R21  21
    248 #define VKI_PT_R22  22
    249 #define VKI_PT_R23  23
    250 #define VKI_PT_R24  24
    251 #define VKI_PT_R25  25
    252 #define VKI_PT_R26  26
    253 #define VKI_PT_R27  27
    254 #define VKI_PT_R28  28
    255 #define VKI_PT_R29  29
    256 #define VKI_PT_R30  30
    257 #define VKI_PT_R31  31
    258 #define VKI_PT_NIP  32
    259 #define VKI_PT_MSR  33
    260 #define VKI_PT_ORIG_R3 34
    261 #define VKI_PT_CTR  35
    262 #define VKI_PT_LNK  36
    263 #define VKI_PT_XER  37
    264 #define VKI_PT_CCR  38
    265 #define VKI_PT_SOFTE 39
    266 #define VKI_PT_RESULT 43
    267 
    268 //----------------------------------------------------------------------
    269 // From linux-2.6.13/include/asm-ppc64/elf.h
    270 //----------------------------------------------------------------------
    271 
    272 #define VKI_ELF_NGREG       48      /* includes nip, msr, lr, etc. */
    273 #define VKI_ELF_NFPREG      33      /* includes fpscr */
    274 #define VKI_ELF_NVRREG      34      /* includes vscr & vrsave in split vectors */
    275 
    276 typedef unsigned long vki_elf_greg_t64;
    277 typedef vki_elf_greg_t64 vki_elf_gregset_t64[VKI_ELF_NGREG];
    278 
    279 typedef vki_elf_gregset_t64 vki_elf_gregset_t;
    280 
    281 typedef double vki_elf_fpreg_t;
    282 typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
    283 
    284 /* Altivec registers */
    285 /*
    286  * The entries with indexes 0-31 contain the corresponding vector registers.
    287  * The entry with index 32 contains the vscr as the last word (offset 12)
    288  * within the quadword.  This allows the vscr to be stored as either a
    289  * quadword (since it must be copied via a vector register to/from storage)
    290  * or as a word.  The entry with index 33 contains the vrsave as the first
    291  * word (offset 0) within the quadword.
    292  *
    293  * This definition of the VMX state is compatible with the current PPC32
    294  * ptrace interface.  This allows signal handling and ptrace to use the same
    295  * structures.  This also simplifies the implementation of a bi-arch
    296  * (combined (32- and 64-bit) gdb.
    297  *
    298  * Note that it's _not_ compatible with 32 bits ucontext which stuffs the
    299  * vrsave along with vscr and so only uses 33 vectors for the register set
    300  */
    301 typedef __vki_vector128 vki_elf_vrreg_t;
    302 typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
    303 
    304 //----------------------------------------------------------------------
    305 // From linux-2.6.13/include/asm-ppc64/sigcontext.h
    306 //----------------------------------------------------------------------
    307 
    308 struct vki_sigcontext {
    309   unsigned long       _unused[4];
    310   int                 signal;
    311   int                 _pad0;
    312   unsigned long       handler;
    313   unsigned long       oldmask;
    314   struct vki_pt_regs  __user *regs;
    315   vki_elf_gregset_t   gp_regs;
    316   vki_elf_fpregset_t  fp_regs;
    317   /*
    318    * To maintain compatibility with current implementations the sigcontext is
    319    * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
    320    * followed by an unstructured (vmx_reserve) field of 69 doublewords.  This
    321    * allows the array of vector registers to be quadword aligned independent of
    322    * the alignment of the containing sigcontext or ucontext. It is the
    323    * responsibility of the code setting the sigcontext to set this pointer to
    324    * either NULL (if this processor does not support the VMX feature) or the
    325    * address of the first quadword within the allocated (vmx_reserve) area.
    326    *
    327    * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
    328    * an array of 34 quadword entries (elf_vrregset_t).  The entries with
    329    * indexes 0-31 contain the corresponding vector registers.  The entry with
    330    * index 32 contains the vscr as the last word (offset 12) within the
    331    * quadword.  This allows the vscr to be stored as either a quadword (since
    332    * it must be copied via a vector register to/from storage) or as a word.
    333    * The entry with index 33 contains the vrsave as the first word (offset 0)
    334    * within the quadword.
    335    */
    336   vki_elf_vrreg_t  __user *v_regs;
    337   long             vmx_reserve[VKI_ELF_NVRREG+VKI_ELF_NVRREG+1];
    338 };
    339 
    340 //----------------------------------------------------------------------
    341 // From linux-2.6.13/include/asm-ppc64/mman.h
    342 //----------------------------------------------------------------------
    343 
    344 #define VKI_PROT_NONE       0x0             /* page can not be accessed */
    345 #define VKI_PROT_READ       0x1             /* page can be read */
    346 #define VKI_PROT_WRITE      0x2             /* page can be written */
    347 #define VKI_PROT_EXEC       0x4             /* page can be executed */
    348 #define VKI_PROT_GROWSDOWN  0x01000000      /* mprotect flag: extend
    349 					       change to start of
    350 					       growsdown vma */
    351 #define VKI_PROT_GROWSUP    0x02000000      /* mprotect flag: extend
    352 					       change to end of
    353 					       growsup vma */
    354 
    355 #define VKI_MAP_SHARED      0x01            /* Share changes */
    356 #define VKI_MAP_PRIVATE     0x02            /* Changes are private */
    357 #define VKI_MAP_FIXED       0x10            /* Interpret addr exactly */
    358 #define VKI_MAP_ANONYMOUS   0x20            /* don't use a file */
    359 #define VKI_MAP_NORESERVE   0x40            /* don't reserve swap pages */
    360 
    361 //----------------------------------------------------------------------
    362 // From linux-2.6.13/include/asm-ppc64/fcntl.h
    363 //----------------------------------------------------------------------
    364 
    365 #define VKI_O_ACCMODE	         03
    366 #define VKI_O_RDONLY             00
    367 #define VKI_O_WRONLY             01
    368 #define VKI_O_RDWR               02
    369 #define VKI_O_CREAT            0100 /* not fcntl */
    370 #define VKI_O_EXCL             0200 /* not fcntl */
    371 #define VKI_O_TRUNC           01000 /* not fcntl */
    372 #define VKI_O_APPEND          02000
    373 #define VKI_O_NONBLOCK        04000
    374 #define VKI_O_LARGEFILE     0200000
    375 
    376 #define VKI_AT_FDCWD            -100
    377 
    378 #define VKI_F_DUPFD         0       /* dup */
    379 #define VKI_F_GETFD         1       /* get close_on_exec */
    380 #define VKI_F_SETFD         2       /* set/clear close_on_exec */
    381 #define VKI_F_GETFL         3       /* get file->f_flags */
    382 #define VKI_F_SETFL         4       /* set file->f_flags */
    383 #define VKI_F_GETLK         5
    384 #define VKI_F_SETLK         6
    385 #define VKI_F_SETLKW        7
    386 
    387 #define VKI_F_SETOWN        8       /*  for sockets. */
    388 #define VKI_F_GETOWN        9       /*  for sockets. */
    389 #define VKI_F_SETSIG        10      /*  for sockets. */
    390 #define VKI_F_GETSIG        11      /*  for sockets. */
    391 
    392 #define VKI_F_SETOWN_EX		15
    393 #define VKI_F_GETOWN_EX		16
    394 
    395 #define VKI_F_OFD_GETLK		36
    396 #define VKI_F_OFD_SETLK		37
    397 #define VKI_F_OFD_SETLKW	38
    398 
    399 #define VKI_F_OWNER_TID		0
    400 #define VKI_F_OWNER_PID		1
    401 #define VKI_F_OWNER_PGRP	2
    402 
    403 struct vki_f_owner_ex {
    404 	int	type;
    405 	__vki_kernel_pid_t	pid;
    406 };
    407 
    408 /* for F_[GET|SET]FL */
    409 #define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
    410 
    411 #define VKI_F_LINUX_SPECIFIC_BASE   1024
    412 
    413 //----------------------------------------------------------------------
    414 // From linux-2.6.13/include/asm-ppc64/resource.h
    415 //----------------------------------------------------------------------
    416 
    417 // which just does #include <asm-generic/resource.h>
    418 
    419 #define VKI_RLIMIT_DATA             2       /* max data size */
    420 #define VKI_RLIMIT_STACK            3       /* max stack size */
    421 #define VKI_RLIMIT_CORE             4       /* max core file size */
    422 #define VKI_RLIMIT_NOFILE           7       /* max number of open files */
    423 
    424 //----------------------------------------------------------------------
    425 // From linux-2.6.13/include/asm-ppc64/socket.h
    426 //----------------------------------------------------------------------
    427 
    428 #define VKI_SOL_SOCKET      1
    429 
    430 #define VKI_SO_TYPE         3
    431 
    432 #define VKI_SO_ATTACH_FILTER	26
    433 
    434 //----------------------------------------------------------------------
    435 // From linux-2.6.13/include/asm-ppc64/sockios.h
    436 //----------------------------------------------------------------------
    437 
    438 #define VKI_SIOCSPGRP       0x8902
    439 #define VKI_SIOCGPGRP       0x8904
    440 #define VKI_SIOCATMARK      0x8905
    441 #define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
    442 #define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
    443 
    444 //----------------------------------------------------------------------
    445 // From linux-2.6.13/include/asm-ppc64/stat.h
    446 //----------------------------------------------------------------------
    447 
    448 struct vki_stat {
    449   unsigned long   st_dev;
    450   unsigned long   st_ino;
    451   unsigned long   st_nlink;
    452   unsigned int    st_mode;
    453   unsigned int    st_uid;
    454   unsigned int    st_gid;
    455   unsigned long   st_rdev;
    456   long            st_size;
    457   unsigned long   st_blksize;
    458   unsigned long   st_blocks;
    459   unsigned long   st_atime;
    460   unsigned long   st_atime_nsec;
    461   unsigned long   st_mtime;
    462   unsigned long   st_mtime_nsec;
    463   unsigned long   st_ctime;
    464   unsigned long   st_ctime_nsec;
    465   unsigned long   __unused4;
    466   unsigned long   __unused5;
    467   unsigned long   __unused6;
    468 };
    469 
    470 #define VKI_STAT_HAVE_NSEC 1
    471 
    472 /* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
    473 struct vki_stat64 {
    474   unsigned long st_dev;           /* Device.  */
    475   unsigned long st_ino;           /* File serial number.  */
    476   unsigned int st_mode;           /* File mode.  */
    477   unsigned int st_nlink;          /* Link count.  */
    478   unsigned int st_uid;            /* User ID of the file's owner.  */
    479   unsigned int st_gid;            /* Group ID of the file's group. */
    480   unsigned long st_rdev;          /* Device number, if device.  */
    481   unsigned short __pad2;
    482   long st_size;                   /* Size of file, in bytes.  */
    483   int  st_blksize;                /* Optimal block size for I/O.  */
    484 
    485   long st_blocks;                 /* Number 512-byte blocks allocated. */
    486   int   st_atime;                 /* Time of last access.  */
    487   int   st_atime_nsec;
    488   int   st_mtime;                 /* Time of last modification.  */
    489   int   st_mtime_nsec;
    490   int   st_ctime;                 /* Time of last status change.  */
    491   int   st_ctime_nsec;
    492   unsigned int   __unused4;
    493   unsigned int   __unused5;
    494 };
    495 
    496 //----------------------------------------------------------------------
    497 // From linux-2.6.13/include/asm-ppc64/statfs.h
    498 //----------------------------------------------------------------------
    499 
    500 struct vki_statfs {
    501   long f_type;
    502   long f_bsize;
    503   long f_blocks;
    504   long f_bfree;
    505   long f_bavail;
    506   long f_files;
    507   long f_ffree;
    508   __vki_kernel_fsid_t f_fsid;
    509   long f_namelen;
    510   long f_frsize;
    511   long f_spare[5];
    512 };
    513 
    514 //----------------------------------------------------------------------
    515 // From linux-2.6.13/include/asm-ppc64/termios.h
    516 //----------------------------------------------------------------------
    517 
    518 struct vki_winsize {
    519   unsigned short ws_row;
    520   unsigned short ws_col;
    521   unsigned short ws_xpixel;
    522   unsigned short ws_ypixel;
    523 };
    524 
    525 #define VKI_NCC 10
    526 struct vki_termio {
    527   unsigned short c_iflag;         /* input mode flags */
    528   unsigned short c_oflag;         /* output mode flags */
    529   unsigned short c_cflag;         /* control mode flags */
    530   unsigned short c_lflag;         /* local mode flags */
    531   unsigned char c_line;           /* line discipline */
    532   unsigned char c_cc[VKI_NCC];    /* control characters */
    533 };
    534 
    535 //----------------------------------------------------------------------
    536 // From linux-2.6.13/include/asm-ppc64/termbits.h
    537 //----------------------------------------------------------------------
    538 
    539 typedef unsigned char   vki_cc_t;
    540 typedef unsigned int    vki_speed_t;
    541 typedef unsigned int    vki_tcflag_t;
    542 
    543 #define VKI_NCCS 19
    544 struct vki_termios {
    545   vki_tcflag_t c_iflag;               /* input mode flags */
    546   vki_tcflag_t c_oflag;               /* output mode flags */
    547   vki_tcflag_t c_cflag;               /* control mode flags */
    548   vki_tcflag_t c_lflag;               /* local mode flags */
    549   vki_cc_t c_cc[VKI_NCCS];            /* control characters */
    550   vki_cc_t c_line;                    /* line discipline (== c_cc[19]) */
    551   vki_speed_t c_ispeed;               /* input speed */
    552   vki_speed_t c_ospeed;               /* output speed */
    553 };
    554 
    555 //----------------------------------------------------------------------
    556 // From linux-2.6.13/include/asm-ppc64/ioctl.h
    557 //----------------------------------------------------------------------
    558 
    559 #define _VKI_IOC_NRBITS     8
    560 #define _VKI_IOC_TYPEBITS   8
    561 #define _VKI_IOC_SIZEBITS   13
    562 #define _VKI_IOC_DIRBITS    3
    563 
    564 #define _VKI_IOC_NRMASK     ((1 << _VKI_IOC_NRBITS)-1)
    565 #define _VKI_IOC_TYPEMASK   ((1 << _VKI_IOC_TYPEBITS)-1)
    566 #define _VKI_IOC_SIZEMASK   ((1 << _VKI_IOC_SIZEBITS)-1)
    567 #define _VKI_IOC_DIRMASK    ((1 << _VKI_IOC_DIRBITS)-1)
    568 
    569 #define _VKI_IOC_NRSHIFT    0
    570 #define _VKI_IOC_TYPESHIFT  (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
    571 #define _VKI_IOC_SIZESHIFT  (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
    572 #define _VKI_IOC_DIRSHIFT   (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
    573 
    574 /*
    575  * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
    576  * And this turns out useful to catch old ioctl numbers in header
    577  * files for us.
    578  */
    579 #define _VKI_IOC_NONE       1U
    580 #define _VKI_IOC_READ       2U
    581 #define _VKI_IOC_WRITE      4U
    582 
    583 #define _VKI_IOC(dir,type,nr,size) \
    584         (((dir)  << _VKI_IOC_DIRSHIFT) | \
    585          ((type) << _VKI_IOC_TYPESHIFT) | \
    586          ((nr)   << _VKI_IOC_NRSHIFT) | \
    587          ((size) << _VKI_IOC_SIZESHIFT))
    588 
    589 /* used to create numbers */
    590 #define _VKI_IO(type,nr)            _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
    591 #define _VKI_IOR(type,nr,size)      _VKI_IOC(_VKI_IOC_READ,(type),(nr), \
    592                                        (_VKI_IOC_TYPECHECK(size)))
    593 #define _VKI_IOW(type,nr,size)      _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \
    594                                        (_VKI_IOC_TYPECHECK(size)))
    595 #define _VKI_IOWR(type,nr,size)     _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \
    596                                        (type),(nr),(_VKI_IOC_TYPECHECK(size)))
    597 #define _VKI_IOR_BAD(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr), \
    598                                        sizeof(size))
    599 #define _VKI_IOW_BAD(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \
    600                                        sizeof(size))
    601 #define _VKI_IOWR_BAD(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \
    602                                        (type),(nr),sizeof(size))
    603 
    604 /* used to decode them.. */
    605 #define _VKI_IOC_DIR(nr)        (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
    606 #define _VKI_IOC_TYPE(nr)       (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
    607 #define _VKI_IOC_NR(nr)         (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
    608 #define _VKI_IOC_SIZE(nr)       (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
    609 
    610 //----------------------------------------------------------------------
    611 // From linux-2.6.13/include/asm-ppc64/ioctls.h
    612 //----------------------------------------------------------------------
    613 
    614 #define VKI_FIOCLEX         _VKI_IO('f', 1)
    615 #define VKI_FIONCLEX        _VKI_IO('f', 2)
    616 
    617 #define VKI_TCGETS          _VKI_IOR('t', 19, struct vki_termios)
    618 #define VKI_TCSETS          _VKI_IOW('t', 20, struct vki_termios)
    619 #define VKI_TCSETSW         _VKI_IOW('t', 21, struct vki_termios)
    620 #define VKI_TCSETSF         _VKI_IOW('t', 22, struct vki_termios)
    621 #define VKI_TCGETA          _VKI_IOR('t', 23, struct vki_termio)
    622 #define VKI_TCSETA          _VKI_IOW('t', 24, struct vki_termio)
    623 #define VKI_TCSETAW         _VKI_IOW('t', 25, struct vki_termio)
    624 #define VKI_TCSETAF         _VKI_IOW('t', 28, struct vki_termio)
    625 #define VKI_TCSBRK          _VKI_IO('t', 29)
    626 #define VKI_TCXONC          _VKI_IO('t', 30)
    627 #define VKI_TCFLSH          _VKI_IO('t', 31)
    628 #define VKI_TIOCSCTTY       0x540E
    629 #define VKI_TIOCGPGRP       _VKI_IOR('t', 119, int)
    630 #define VKI_TIOCSPGRP       _VKI_IOW('t', 118, int)
    631 #define VKI_TIOCOUTQ        _VKI_IOR('t', 115, int)     /* output queue size */
    632 #define VKI_TIOCGWINSZ      _VKI_IOR('t', 104, struct vki_winsize)
    633 #define VKI_TIOCSWINSZ      _VKI_IOW('t', 103, struct vki_winsize)
    634 #define VKI_TIOCMGET        0x5415
    635 #define VKI_TIOCMBIS        0x5416
    636 #define VKI_TIOCMBIC        0x5417
    637 #define VKI_TIOCMSET        0x5418
    638 #define VKI_FIONREAD        _VKI_IOR('f', 127, int)
    639 #define VKI_TIOCLINUX       0x541C
    640 #define VKI_FIONBIO         _VKI_IOW('f', 126, int)
    641 #define VKI_TIOCNOTTY       0x5422
    642 #define VKI_TCSBRKP         0x5425  /* Needed for POSIX tcsendbreak() */
    643 #define VKI_TIOCGPTN        _VKI_IOR('T',0x30, unsigned int)
    644                             /* Get Pty Number (of pty-mux device) */
    645 #define VKI_TIOCSPTLCK      _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
    646 #define VKI_FIOASYNC        _VKI_IOW('f', 125, int)
    647 #define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
    648 #define VKI_TIOCGICOUNT	    0x545D /* read serial port inline interrupt counts */
    649 #define VKI_FIOQSIZE        _VKI_IOR('f', 128, vki_loff_t)
    650 
    651 //----------------------------------------------------------------------
    652 // From linux-2.6.13/include/asm-ppc64/poll.h
    653 //----------------------------------------------------------------------
    654 
    655 #define VKI_POLLIN          0x0001
    656 
    657 struct vki_pollfd {
    658   int fd;
    659   short events;
    660   short revents;
    661 };
    662 
    663 //----------------------------------------------------------------------
    664 // From linux-2.6.13/include/asm-ppc64/user.h
    665 //----------------------------------------------------------------------
    666 
    667 // Not sure what's needed from here
    668 
    669 //----------------------------------------------------------------------
    670 // From linux-2.6.13/include/asm-ppc64/elf.h
    671 //----------------------------------------------------------------------
    672 
    673 // Not sure what's needed from here
    674 
    675 //----------------------------------------------------------------------
    676 // From linux-2.6.13/include/asm-ppc64/ucontext.h
    677 //----------------------------------------------------------------------
    678 
    679 struct vki_ucontext {
    680   unsigned long         uc_flags;
    681   struct vki_ucontext  *uc_link;
    682   vki_stack_t           uc_stack;
    683   vki_sigset_t          uc_sigmask;
    684   vki_sigset_t          __unused0[15]; /* Allow for uc_sigmask growth */
    685   struct vki_sigcontext uc_mcontext;  /* last for extensibility */
    686 };
    687 
    688 // CAB: TODO
    689 typedef char vki_modify_ldt_t;
    690 
    691 //----------------------------------------------------------------------
    692 // From linux-2.6.13/include/asm-ppc64/ipcbuf.h
    693 //----------------------------------------------------------------------
    694 
    695 struct vki_ipc64_perm
    696 {
    697   __vki_kernel_key_t  key;
    698   __vki_kernel_uid_t  uid;
    699   __vki_kernel_gid_t  gid;
    700   __vki_kernel_uid_t  cuid;
    701   __vki_kernel_gid_t  cgid;
    702   __vki_kernel_mode_t mode;
    703   unsigned int        seq;
    704   unsigned int        __pad1;
    705   unsigned long       __unused1;
    706   unsigned long       __unused2;
    707 };
    708 
    709 //----------------------------------------------------------------------
    710 // From linux-2.6.13/include/asm-ppc64/sembuf.h
    711 //----------------------------------------------------------------------
    712 
    713 struct vki_semid64_ds {
    714   struct vki_ipc64_perm sem_perm;     /* permissions .. see ipc.h */
    715   __vki_kernel_time_t   sem_otime;      /* last semop time */
    716   __vki_kernel_time_t   sem_ctime;      /* last change time */
    717   unsigned long         sem_nsems;      /* no. of semaphores in array */
    718   unsigned long         __unused1;
    719   unsigned long         __unused2;
    720 };
    721 
    722 //----------------------------------------------------------------------
    723 // From linux-2.6.13/include/asm-ppc64/msgbuf.h
    724 //----------------------------------------------------------------------
    725 
    726 struct vki_msqid64_ds {
    727   struct vki_ipc64_perm msg_perm;
    728   __vki_kernel_time_t   msg_stime;      /* last msgsnd time */
    729   __vki_kernel_time_t   msg_rtime;      /* last msgrcv time */
    730   __vki_kernel_time_t   msg_ctime;      /* last change time */
    731   unsigned long         msg_cbytes;      /* current number of bytes on queue */
    732   unsigned long         msg_qnum;        /* number of messages in queue */
    733   unsigned long         msg_qbytes;      /* max number of bytes on queue */
    734   __vki_kernel_pid_t    msg_lspid;       /* pid of last msgsnd */
    735   __vki_kernel_pid_t    msg_lrpid;       /* last receive pid */
    736   unsigned long         __unused1;
    737   unsigned long         __unused2;
    738 };
    739 
    740 //----------------------------------------------------------------------
    741 // From linux-2.6.13/include/asm-ppc64/ipc.h
    742 //----------------------------------------------------------------------
    743 
    744 // this just does #include <asm-generic/ipc.h>
    745 
    746 struct vki_ipc_kludge {
    747   struct vki_msgbuf __user *msgp;
    748   long msgtyp;
    749 };
    750 
    751 #define VKI_SEMOP            1
    752 #define VKI_SEMGET           2
    753 #define VKI_SEMCTL           3
    754 #define VKI_SEMTIMEDOP       4
    755 #define VKI_MSGSND          11
    756 #define VKI_MSGRCV          12
    757 #define VKI_MSGGET          13
    758 #define VKI_MSGCTL          14
    759 #define VKI_SHMAT           21
    760 #define VKI_SHMDT           22
    761 #define VKI_SHMGET          23
    762 #define VKI_SHMCTL          24
    763 
    764 //----------------------------------------------------------------------
    765 // From linux-2.6.13/include/asm-ppc64/shmbuf.h
    766 //----------------------------------------------------------------------
    767 
    768 struct vki_shmid64_ds {
    769   struct vki_ipc64_perm       shm_perm;       /* operation perms */
    770   __vki_kernel_time_t         shm_atime;      /* last attach time */
    771   __vki_kernel_time_t         shm_dtime;      /* last detach time */
    772   __vki_kernel_time_t         shm_ctime;      /* last change time */
    773   vki_size_t                  shm_segsz;      /* size of segment (bytes) */
    774   __vki_kernel_pid_t          shm_cpid;       /* pid of creator */
    775   __vki_kernel_pid_t          shm_lpid;       /* pid of last operator */
    776   unsigned long               shm_nattch;     /* no. of current attaches */
    777   unsigned long               __unused1;
    778   unsigned long               __unused2;
    779 };
    780 
    781 struct vki_shminfo64 {
    782   unsigned long   shmmax;
    783   unsigned long   shmmin;
    784   unsigned long   shmmni;
    785   unsigned long   shmseg;
    786   unsigned long   shmall;
    787   unsigned long   __unused1;
    788   unsigned long   __unused2;
    789   unsigned long   __unused3;
    790   unsigned long   __unused4;
    791 };
    792 
    793 //----------------------------------------------------------------------
    794 // From linux-2.6.8.1/include/asm-generic/errno.h
    795 //----------------------------------------------------------------------
    796 
    797 #define	VKI_ENOSYS       38  /* Function not implemented */
    798 #define	VKI_EOVERFLOW    75  /* Value too large for defined data type */
    799 
    800 //----------------------------------------------------------------------
    801 // From linux-3.19.0/arch/powerpc/include/uapi/asm/ioctls.h
    802 //----------------------------------------------------------------------
    803 
    804 #define VKI_TIOCGSERIAL     0x541E
    805 #define VKI_TIOCSSERIAL     0x541F
    806 
    807 //----------------------------------------------------------------------
    808 // end
    809 //----------------------------------------------------------------------
    810 
    811 #endif // __VKI_PPC64_LINUX_H
    812 
    813 /*--------------------------------------------------------------------*/
    814 /*--- end                                                          ---*/
    815 /*--------------------------------------------------------------------*/
    816