Home | History | Annotate | Download | only in vki
      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-2012 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 unsigned long VKI_PAGE_SHIFT;
     67 extern unsigned long 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_RDONLY		   00
    311 #define VKI_O_WRONLY		   01
    312 #define VKI_O_RDWR		   02
    313 #define VKI_O_CREAT		 0100		/* not fcntl */
    314 #define VKI_O_EXCL		 0200		/* not fcntl */
    315 #define VKI_O_TRUNC		01000		/* not fcntl */
    316 #define VKI_O_APPEND		02000
    317 #define VKI_O_NONBLOCK		04000
    318 #define VKI_O_LARGEFILE     0200000
    319 
    320 #define VKI_AT_FDCWD            -100
    321 
    322 #define VKI_F_DUPFD		 0			/* dup */
    323 #define VKI_F_GETFD		 1			/* get close_on_exec */
    324 #define VKI_F_SETFD		 2			/* set/clear close_on_exec */
    325 #define VKI_F_GETFL		 3			/* get file->f_flags */
    326 #define VKI_F_SETFL		 4			/* set file->f_flags */
    327 #define VKI_F_GETLK		 5
    328 #define VKI_F_SETLK		 6
    329 #define VKI_F_SETLKW		 7
    330 
    331 #define VKI_F_SETOWN		 8			/*  for sockets. */
    332 #define VKI_F_GETOWN		 9			/*  for sockets. */
    333 #define VKI_F_SETSIG		10			/*  for sockets. */
    334 #define VKI_F_GETSIG		11			/*  for sockets. */
    335 
    336 #define VKI_F_GETLK64		12			/*  using 'struct flock64' */
    337 #define VKI_F_SETLK64		13
    338 #define VKI_F_SETLKW64		14
    339 
    340 #define VKI_F_SETOWN_EX		15
    341 #define VKI_F_GETOWN_EX		16
    342 
    343 #define VKI_F_OWNER_TID		0
    344 #define VKI_F_OWNER_PID		1
    345 #define VKI_F_OWNER_PGRP	2
    346 
    347 struct vki_f_owner_ex {
    348 	int	type;
    349 	__vki_kernel_pid_t	pid;
    350 };
    351 
    352 /* for F_[GET|SET]FL */
    353 #define VKI_FD_CLOEXEC	 1		/* actually anything with low bit set goes */
    354 
    355 #define VKI_F_LINUX_SPECIFIC_BASE	1024
    356 
    357 //----------------------------------------------------------------------
    358 // From linux-2.6.9/include/asm-ppc/resource.h
    359 //----------------------------------------------------------------------
    360 
    361 #define VKI_RLIMIT_DATA		2   /* max data size */
    362 #define VKI_RLIMIT_STACK	3   /* max stack size */
    363 #define VKI_RLIMIT_CORE		4   /* max core file size */
    364 #define VKI_RLIMIT_NOFILE	7   /* max number of open files */
    365 
    366 //----------------------------------------------------------------------
    367 // From linux-2.6.9/include/asm-ppc/socket.h
    368 //----------------------------------------------------------------------
    369 
    370 #define VKI_SOL_SOCKET	1
    371 #define VKI_SO_TYPE	3
    372 
    373 #define VKI_SIOCSPGRP		0x8902
    374 #define VKI_SIOCGPGRP		0x8904
    375 #define VKI_SIOCGSTAMP		0x8906          /* Get stamp (timeval) */
    376 #define VKI_SIOCGSTAMPNS	0x8907          /* Get stamp (timespec) */
    377 
    378 //----------------------------------------------------------------------
    379 // From linux-2.6.10/include/asm-ppc/stat.h
    380 //----------------------------------------------------------------------
    381 
    382 //.. #define VKI_S_IFMT		00170000
    383 //.. #define VKI_S_IFSOCK	 0140000
    384 //.. #define VKI_S_IFLNK	 0120000
    385 //.. #define VKI_S_IFREG	 0100000
    386 //.. #define VKI_S_IFBLK	 0060000
    387 //.. #define VKI_S_IFDIR	 0040000
    388 //.. #define VKI_S_IFCHR	 0020000
    389 //.. #define VKI_S_IFIFO	 0010000
    390 //.. #define VKI_S_ISUID	 0004000
    391 //.. #define VKI_S_ISGID	 0002000
    392 //.. #define VKI_S_ISVTX	 0001000
    393 //..
    394 //.. #define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
    395 //.. #define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
    396 //.. #define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
    397 //.. #define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
    398 //.. #define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
    399 //.. #define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
    400 //.. #define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
    401 
    402 struct vki_stat {
    403    unsigned		st_dev;
    404    unsigned long	st_ino;
    405    unsigned int		st_mode;
    406    unsigned short	st_nlink;
    407    unsigned int		st_uid;
    408    unsigned int		st_gid;
    409    unsigned		st_rdev;
    410    long			st_size;
    411    unsigned long	st_blksize;
    412    unsigned long	st_blocks;
    413    unsigned long	st_atime;
    414    unsigned long	st_atime_nsec;
    415    unsigned long	st_mtime;
    416    unsigned long	st_mtime_nsec;
    417    unsigned long	st_ctime;
    418    unsigned long	st_ctime_nsec;
    419    unsigned long	__unused4;
    420    unsigned long	__unused5;
    421 };
    422 
    423 struct vki_stat64 {
    424    unsigned long long   st_dev;
    425    unsigned long long   st_ino;
    426    unsigned int         st_mode;
    427    unsigned int         st_nlink;
    428    unsigned int         st_uid;
    429    unsigned int         st_gid;
    430    unsigned long long   st_rdev;
    431    unsigned short int   __pad2;
    432    long long            st_size;
    433    long                 st_blksize;
    434 
    435    long long            st_blocks;
    436    long                 st_atime;
    437    unsigned long        st_atime_nsec;
    438    long                 st_mtime;
    439    unsigned long int    st_mtime_nsec;
    440    long                 st_ctime;
    441    unsigned long int    st_ctime_nsec;
    442    unsigned long int    __unused4;
    443    unsigned long int    __unused5;
    444 };
    445 
    446 
    447 //----------------------------------------------------------------------
    448 // From linux-2.6.9/include/asm-ppc/statfs.h
    449 //----------------------------------------------------------------------
    450 
    451 // [[Nb: asm-ppc/statfs.h just #include asm-generic/statfs.h directly]]
    452 struct vki_statfs {
    453    __vki_u32 f_type;
    454    __vki_u32 f_bsize;
    455    __vki_u32 f_blocks;
    456    __vki_u32 f_bfree;
    457    __vki_u32 f_bavail;
    458    __vki_u32 f_files;
    459    __vki_u32 f_ffree;
    460    __vki_kernel_fsid_t f_fsid;
    461    __vki_u32 f_namelen;
    462    __vki_u32 f_frsize;
    463    __vki_u32 f_spare[5];
    464 };
    465 
    466 //----------------------------------------------------------------------
    467 // From linux-2.6.9/include/asm-ppc/termios.h
    468 //----------------------------------------------------------------------
    469 
    470 struct vki_winsize {
    471    unsigned short ws_row;
    472    unsigned short ws_col;
    473    unsigned short ws_xpixel;
    474    unsigned short ws_ypixel;
    475 };
    476 
    477 #define NCC 10
    478 struct vki_termio {
    479    unsigned short	c_iflag;		/* input mode flags */
    480    unsigned short	c_oflag;		/* output mode flags */
    481    unsigned short	c_cflag;		/* control mode flags */
    482    unsigned short	c_lflag;		/* local mode flags */
    483    unsigned char	c_line;			/* line discipline */
    484    unsigned char	c_cc[NCC];		/* control characters */
    485 };
    486 
    487 //----------------------------------------------------------------------
    488 // From linux-2.6.9/include/asm-ppc/termbits.h
    489 //----------------------------------------------------------------------
    490 
    491 typedef unsigned char   vki_cc_t;
    492 typedef unsigned int    vki_speed_t;
    493 typedef unsigned int    vki_tcflag_t;
    494 
    495 #define NCCS 19
    496 struct vki_termios {
    497         vki_tcflag_t	c_iflag;		/* input mode flags */
    498         vki_tcflag_t	c_oflag;		/* output mode flags */
    499         vki_tcflag_t	c_cflag;		/* control mode flags */
    500         vki_tcflag_t	c_lflag;		/* local mode flags */
    501         vki_cc_t	c_cc[NCCS];		/* control characters */
    502         vki_cc_t	c_line;			/* line discipline (== c_cc[19]) */
    503         vki_speed_t	c_ispeed;		/* input speed */
    504         vki_speed_t	c_ospeed;		/* output speed */
    505 };
    506 
    507 //----------------------------------------------------------------------
    508 // From linux-2.6.9/include/asm-ppc/ioctl.h
    509 //----------------------------------------------------------------------
    510 
    511 #define _VKI_IOC_NRBITS		 8
    512 #define _VKI_IOC_TYPEBITS	 8
    513 #define _VKI_IOC_SIZEBITS	13
    514 #define _VKI_IOC_DIRBITS	 3
    515 
    516 #define _VKI_IOC_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
    517 #define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
    518 #define _VKI_IOC_SIZEMASK	((1 << _VKI_IOC_SIZEBITS)-1)
    519 #define _VKI_IOC_DIRMASK	((1 << _VKI_IOC_DIRBITS)-1)
    520 
    521 #define _VKI_IOC_NRSHIFT	0
    522 #define _VKI_IOC_TYPESHIFT	(_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
    523 #define _VKI_IOC_SIZESHIFT	(_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
    524 #define _VKI_IOC_DIRSHIFT	(_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
    525 
    526 #define _VKI_IOC_NONE	1U
    527 #define _VKI_IOC_READ	2U
    528 #define _VKI_IOC_WRITE	4U
    529 
    530 #define _VKI_IOC(dir,type,nr,size) \
    531         (((dir)  << _VKI_IOC_DIRSHIFT) | \
    532          ((type) << _VKI_IOC_TYPESHIFT) | \
    533          ((nr)   << _VKI_IOC_NRSHIFT) | \
    534          ((size) << _VKI_IOC_SIZESHIFT))
    535 
    536 /* used to create numbers */
    537 #define _VKI_IO(type,nr)			_VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
    538 #define _VKI_IOR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
    539 #define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
    540 #define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
    541 
    542 /* used to decode them.. */
    543 #define _VKI_IOC_DIR(nr)		(((nr) >> _VKI_IOC_DIRSHIFT)  & _VKI_IOC_DIRMASK)
    544 //.. #define _VKI_IOC_TYPE(nr)		(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
    545 //.. #define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT)   & _VKI_IOC_NRMASK)
    546 #define _VKI_IOC_SIZE(nr)		(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
    547 
    548 //----------------------------------------------------------------------
    549 // From linux-2.6.9/include/asm-ppc/ioctls.h
    550 //----------------------------------------------------------------------
    551 
    552 //#define VKI_FIOCLEX		_VKI_IO('f', 1)
    553 //#define VKI_FIONCLEX		_VKI_IO('f', 2)
    554 #define VKI_FIOASYNC		_VKI_IOW('f', 125, int)
    555 #define VKI_FIONBIO		_VKI_IOW('f', 126, int)
    556 #define VKI_FIONREAD		_VKI_IOR('f', 127, int)
    557 //#define VKI_TIOCINQ		VKI_FIONREAD
    558 #define VKI_FIOQSIZE		_VKI_IOR('f', 128, vki_loff_t)
    559 
    560 //#define VKI_TIOCGETP		_VKI_IOR('t', 8, struct vki_sgttyb)
    561 //#define VKI_TIOCSETP		_VKI_IOW('t', 9, struct vki_sgttyb)
    562 //#define VKI_TIOCSETN		_VKI_IOW('t', 10, struct vki_sgttyb)    /* TIOCSETP wo flush */
    563 
    564 //#define VKI_TIOCSETC		_VKI_IOW('t', 17, struct vki_tchars)
    565 //#define VKI_TIOCGETC		_VKI_IOR('t', 18, struct vki_tchars)
    566 #define VKI_TCGETS		_VKI_IOR('t', 19, struct vki_termios)
    567 #define VKI_TCSETS		_VKI_IOW('t', 20, struct vki_termios)
    568 #define VKI_TCSETSW		_VKI_IOW('t', 21, struct vki_termios)
    569 #define VKI_TCSETSF		_VKI_IOW('t', 22, struct vki_termios)
    570 
    571 #define VKI_TCGETA		_VKI_IOR('t', 23, struct vki_termio)
    572 #define VKI_TCSETA		_VKI_IOW('t', 24, struct vki_termio)
    573 #define VKI_TCSETAW		_VKI_IOW('t', 25, struct vki_termio)
    574 #define VKI_TCSETAF		_VKI_IOW('t', 28, struct vki_termio)
    575 
    576 #define VKI_TCSBRK		_VKI_IO('t', 29)
    577 #define VKI_TCXONC		_VKI_IO('t', 30)
    578 #define VKI_TCFLSH		_VKI_IO('t', 31)
    579 
    580 #define VKI_TIOCSWINSZ		_VKI_IOW('t', 103, struct vki_winsize)
    581 #define VKI_TIOCGWINSZ		_VKI_IOR('t', 104, struct vki_winsize)
    582 //#define VKI_TIOCSTART		_VKI_IO('t', 110)	   /* start output, like ^Q */
    583 //#define VKI_TIOCSTOP		_VKI_IO('t', 111)	   /* stop output, like ^S */
    584 #define VKI_TIOCOUTQ		_VKI_IOR('t', 115, int)	   /* output queue size */
    585 
    586 //#define VKI_TIOCGLTC		_VKI_IOR('t', 116, struct vki_ltchars)
    587 //#define VKI_TIOCSLTC		_VKI_IOW('t', 117, struct vki_ltchars)
    588 #define VKI_TIOCSPGRP		_VKI_IOW('t', 118, int)
    589 #define VKI_TIOCGPGRP		_VKI_IOR('t', 119, int)
    590 
    591 //#define VKI_TIOCEXCL		0x540C
    592 //#define VKI_TIOCNXCL		0x540D
    593 #define VKI_TIOCSCTTY		0x540E
    594 
    595 //#define VKI_TIOCSTI		0x5412
    596 #define VKI_TIOCMGET		0x5415
    597 #define VKI_TIOCMBIS		0x5416
    598 #define VKI_TIOCMBIC		0x5417
    599 #define VKI_TIOCMSET		0x5418
    600 //# define VKI_TIOCM_LE		0x001
    601 //# define VKI_TIOCM_DTR	0x002
    602 //# define VKI_TIOCM_RTS	0x004
    603 //# define VKI_TIOCM_ST		0x008
    604 //# define VKI_TIOCM_SR		0x010
    605 //# define VKI_TIOCM_CTS	0x020
    606 //# define VKI_TIOCM_CAR	0x040
    607 //# define VKI_TIOCM_RNG	0x080
    608 //# define VKI_TIOCM_DSR	0x100
    609 //# define VKI_TIOCM_CD		VKI_TIOCM_CAR
    610 //# define VKI_TIOCM_RI		VKI_TIOCM_RNG
    611 
    612 //#define VKI_TIOCGSOFTCAR	0x5419
    613 //#define VKI_TIOCSSOFTCAR	0x541A
    614 #define VKI_TIOCLINUX		0x541C
    615 //#define VKI_TIOCCONS		0x541D
    616 //#define VKI_TIOCGSERIAL	0x541E
    617 //#define VKI_TIOCSSERIAL	0x541F
    618 //#define VKI_TIOCPKT		0x5420
    619 //# define VKI_TIOCPKT_DATA		 0
    620 //# define VKI_TIOCPKT_FLUSHREAD	 1
    621 //# define VKI_TIOCPKT_FLUSHWRITE	 2
    622 //# define VKI_TIOCPKT_STOP		 4
    623 //# define VKI_TIOCPKT_START		 8
    624 //# define VKI_TIOCPKT_NOSTOP		16
    625 //# define VKI_TIOCPKT_DOSTOP		32
    626 
    627 //#define VKI_TIOCNOTTY		0x5422
    628 //#define VKI_TIOCSETD		0x5423
    629 //#define VKI_TIOCGETD		0x5424
    630 #define VKI_TCSBRKP		0x5425  /* Needed for POSIX tcsendbreak() */
    631 //#define VKI_TIOCSBRK		0x5427  /* BSD compatibility */
    632 //#define VKI_TIOCCBRK		0x5428  /* BSD compatibility */
    633 //#define VKI_TIOCGSID		0x5429  /* Return the session ID of FD */
    634 #define VKI_TIOCGPTN		_VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
    635 #define VKI_TIOCSPTLCK		_VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
    636 
    637 //#define VKI_TIOCSERCONFIG	0x5453
    638 //#define VKI_TIOCSERGWILD	0x5454
    639 //#define VKI_TIOCSERSWILD  	0x5455
    640 //#define VKI_TIOCGLCKTRMIOS	0x5456
    641 //#define VKI_TIOCSLCKTRMIOS	0x5457
    642 //#define VKI_TIOCSERGSTRUCT	0x5458 /* For debugging only */
    643 #define VKI_TIOCSERGETLSR	0x5459 /* Get line status register */
    644   /* ioctl (fd, VKI_TIOCSERGETLSR, &result) where result may be as below */
    645 //# define VKI_TIOCSER_TEMT	0x01   /* Transmitter physically empty */
    646 //#define VKI_TIOCSERGETMULTI	0x545A /* Get multiport config  */
    647 //#define VKI_TIOCSERSETMULTI	0x545B /* Set multiport config */
    648 
    649 //#define VKI_TIOCMIWAIT	0x545C  /* wait for a change on serial input line(s) */
    650 #define VKI_TIOCGICOUNT		0x545D  /* read serial port inline interrupt counts */
    651 
    652 //----------------------------------------------------------------------
    653 // From linux-2.6.9/include/asm-ppc/poll.h
    654 //----------------------------------------------------------------------
    655 
    656 //.. /* These are specified by iBCS2 */
    657 //.. #define VKI_POLLIN		0x0001
    658 
    659 struct vki_pollfd {
    660 	int fd;
    661 	short events;
    662 	short revents;
    663 };
    664 
    665 //.. //----------------------------------------------------------------------
    666 //.. // From linux-2.6.8.1/include/asm-i386/user.h
    667 //.. //----------------------------------------------------------------------
    668 //..
    669 //.. struct vki_user_i387_struct {
    670 //.. 	long	cwd;
    671 //.. 	long	swd;
    672 //.. 	long	twd;
    673 //.. 	long	fip;
    674 //.. 	long	fcs;
    675 //.. 	long	foo;
    676 //.. 	long	fos;
    677 //.. 	long	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
    678 //.. };
    679 //..
    680 //.. struct vki_user_fxsr_struct {
    681 //.. 	unsigned short	cwd;
    682 //.. 	unsigned short	swd;
    683 //.. 	unsigned short	twd;
    684 //.. 	unsigned short	fop;
    685 //.. 	long	fip;
    686 //.. 	long	fcs;
    687 //.. 	long	foo;
    688 //.. 	long	fos;
    689 //.. 	long	mxcsr;
    690 //.. 	long	reserved;
    691 //.. 	long	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
    692 //.. 	long	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
    693 //.. 	long	padding[56];
    694 //.. };
    695 //..
    696 //.. /*
    697 //..  * This is the old layout of "struct pt_regs", and
    698 //..  * is still the layout used by user mode (the new
    699 //..  * pt_regs doesn't have all registers as the kernel
    700 //..  * doesn't use the extra segment registers)
    701 //..  */
    702 //.. struct vki_user_regs_struct {
    703 //.. 	long ebx, ecx, edx, esi, edi, ebp, eax;
    704 //.. 	unsigned short ds, __ds, es, __es;
    705 //.. 	unsigned short fs, __fs, gs, __gs;
    706 //.. 	long orig_eax, eip;
    707 //.. 	unsigned short cs, __cs;
    708 //.. 	long eflags, esp;
    709 //.. 	unsigned short ss, __ss;
    710 //.. };
    711 
    712 //----------------------------------------------------------------------
    713 // From linux-2.6.9/include/asm-ppc/elf.h
    714 //----------------------------------------------------------------------
    715 
    716 #define VKI_ELF_NGREG			48	/* includes nip, msr, lr, etc. */
    717 #define VKI_ELF_NFPREG			33	/* includes fpscr */
    718 #define VKI_ELF_NVRREG			33	/* includes vscr */
    719 
    720 /* General registers */
    721 typedef unsigned long vki_elf_greg_t;
    722 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
    723 
    724 /* Floating point registers */
    725 typedef double vki_elf_fpreg_t;
    726 typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
    727 
    728 /* Altivec registers */
    729 typedef __vki_vector128 vki_elf_vrreg_t;
    730 typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
    731 
    732 #define VKI_AT_DCACHEBSIZE		19
    733 #define VKI_AT_ICACHEBSIZE		20
    734 #define VKI_AT_UCACHEBSIZE		21
    735 /* A special ignored type value for PPC, for glibc compatibility.  */
    736 #define VKI_AT_IGNOREPPC	  	22
    737 
    738 /* CAB: Do we want these? */
    739 //#define VKI_AT_SYSINFO		32
    740 //#define VKI_AT_SYSINFO_EHDR  		33
    741 
    742 //----------------------------------------------------------------------
    743 // From linux-2.6.9/include/asm-ppc/ucontext.h
    744 //----------------------------------------------------------------------
    745 
    746 struct vki_mcontext {
    747         vki_elf_gregset_t	mc_gregs;
    748         vki_elf_fpregset_t	mc_fregs;
    749         unsigned long		mc_pad[2];
    750         vki_elf_vrregset_t	mc_vregs __attribute__((__aligned__(16)));
    751 };
    752 
    753 struct vki_ucontext {
    754         unsigned long		uc_flags;
    755         struct vki_ucontext	__user *uc_link;
    756         vki_stack_t		uc_stack;
    757         int			uc_pad[7];
    758         struct vki_mcontext	__user *uc_regs;		/* points to uc_mcontext field */
    759         vki_sigset_t		uc_sigmask;
    760         /* glibc has 1024-bit signal masks, ours are 64-bit */
    761         int			uc_maskext[30];
    762         int			uc_pad2[3];
    763         struct vki_mcontext	uc_mcontext;
    764 };
    765 
    766 //.. //----------------------------------------------------------------------
    767 //.. // From linux-2.6.8.1/include/asm-i386/segment.h
    768 //.. //----------------------------------------------------------------------
    769 //..
    770 //.. #define VKI_GDT_ENTRY_TLS_ENTRIES	3
    771 //.. #define VKI_GDT_ENTRY_TLS_MIN	6
    772 //.. #define VKI_GDT_ENTRY_TLS_MAX 	(VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
    773 
    774 //----------------------------------------------------------------------
    775 // From linux-2.6.9/include/asm-ppc/ldt.h
    776 //----------------------------------------------------------------------
    777 
    778 //.. /* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
    779 //..    to confuse and annoy everyone, this is _not_ the same as an
    780 //..    VgLdtEntry and has to be translated into such.  The logic for doing
    781 //..    so, in vg_ldt.c, is copied from the kernel sources.]] */
    782 //.. struct vki_user_desc {
    783 //.. 	unsigned int	entry_number;
    784 //.. 	unsigned long	base_addr;
    785 //.. 	unsigned int	limit;
    786 //.. 	unsigned int	seg_32bit:1;
    787 //.. 	unsigned int	contents:2;
    788 //.. 	unsigned int	read_exec_only:1;
    789 //.. 	unsigned int	limit_in_pages:1;
    790 //.. 	unsigned int	seg_not_present:1;
    791 //.. 	unsigned int	useable:1;
    792 //..         // [[Nb: this field is not in the kernel sources, but it has always
    793 //..         // been in the Valgrind sources so I will keep it there in case it's
    794 //..         // important... this is an x86-defined data structure so who
    795 //..         // knows;  maybe it's important to set this field to zero at some
    796 //..         // point.  --njn]]
    797 //.. 	unsigned int	reserved:25;
    798 //.. };
    799 //..
    800 //.. // [[Nb: for our convenience within Valgrind, use a more specific name]]
    801 //.. typedef struct vki_user_desc vki_modify_ldt_t;
    802 
    803 // CAB: TODO
    804 typedef void vki_modify_ldt_t;
    805 
    806 
    807 //----------------------------------------------------------------------
    808 // From linux-2.6.9/include/asm-ppc/ipcbuf.h
    809 //----------------------------------------------------------------------
    810 
    811 struct vki_ipc64_perm
    812 {
    813    __vki_kernel_key_t	key;
    814    __vki_kernel_uid_t	uid;
    815    __vki_kernel_gid_t	gid;
    816    __vki_kernel_uid_t	cuid;
    817    __vki_kernel_gid_t	cgid;
    818    __vki_kernel_mode_t	mode;
    819    unsigned long	seq;
    820    unsigned int		__pad2;
    821    unsigned long long	__unused1;
    822    unsigned long long	__unused2;
    823 };
    824 
    825 //----------------------------------------------------------------------
    826 // From linux-2.6.9/include/asm-ppc/sembuf.h
    827 //----------------------------------------------------------------------
    828 
    829 struct vki_semid64_ds {
    830    struct vki_ipc64_perm	sem_perm;		/* permissions .. see ipc.h */
    831    unsigned int			__unused1;
    832    __vki_kernel_time_t		sem_otime;		/* last semop time */
    833    unsigned int			__unused2;
    834    __vki_kernel_time_t		sem_ctime;		/* last change time */
    835    unsigned long		sem_nsems;		/* no. of semaphores in array */
    836    unsigned long		__unused3;
    837    unsigned long		__unused4;
    838 };
    839 
    840 //----------------------------------------------------------------------
    841 // From linux-2.6.9/include/asm-ppc/msgbuf.h
    842 //----------------------------------------------------------------------
    843 
    844 struct vki_msqid64_ds {
    845    struct vki_ipc64_perm	msg_perm;
    846    unsigned int			__unused1;
    847    __vki_kernel_time_t		msg_stime;		/* last msgsnd time */
    848    unsigned int			__unused2;
    849    __vki_kernel_time_t		msg_rtime;		/* last msgrcv time */
    850    unsigned int			__unused3;
    851    __vki_kernel_time_t		msg_ctime;		/* last change time */
    852    unsigned long		msg_cbytes;		/* current number of bytes on queue */
    853    unsigned long		msg_qnum;		/* number of messages in queue */
    854    unsigned long		msg_qbytes;		/* max number of bytes on queue */
    855    __vki_kernel_pid_t		msg_lspid;		/* pid of last msgsnd */
    856    __vki_kernel_pid_t		msg_lrpid;		/* last receive pid */
    857    unsigned long		__unused4;
    858    unsigned long		__unused5;
    859 };
    860 
    861 //----------------------------------------------------------------------
    862 // From linux-2.6.8.1/include/asm-ppc/ipc.h
    863 //----------------------------------------------------------------------
    864 
    865 struct vki_ipc_kludge {
    866         struct vki_msgbuf __user *msgp;
    867         long msgtyp;
    868 };
    869 
    870 #define VKI_SEMOP            1
    871 #define VKI_SEMGET           2
    872 #define VKI_SEMCTL           3
    873 #define VKI_SEMTIMEDOP       4
    874 #define VKI_MSGSND          11
    875 #define VKI_MSGRCV          12
    876 #define VKI_MSGGET          13
    877 #define VKI_MSGCTL          14
    878 #define VKI_SHMAT           21
    879 #define VKI_SHMDT           22
    880 #define VKI_SHMGET          23
    881 #define VKI_SHMCTL          24
    882 
    883 //----------------------------------------------------------------------
    884 // From linux-2.6.9/include/asm-ppc/shmbuf.h
    885 //----------------------------------------------------------------------
    886 
    887 struct vki_shmid64_ds {
    888    struct vki_ipc64_perm	shm_perm;		/* operation perms */
    889    unsigned int			__unused1;
    890    __vki_kernel_time_t		shm_atime;		/* last attach time */
    891    unsigned int			__unused2;
    892    __vki_kernel_time_t		shm_dtime;		/* last detach time */
    893    unsigned int			__unused3;
    894    __vki_kernel_time_t		shm_ctime;		/* last change time */
    895    unsigned int			__unused4;
    896    vki_size_t			shm_segsz;		/* size of segment (bytes) */
    897    __vki_kernel_pid_t		shm_cpid;		/* pid of creator */
    898    __vki_kernel_pid_t		shm_lpid;		/* pid of last operator */
    899    unsigned long		shm_nattch;		/* no. of current attaches */
    900    unsigned long		__unused5;
    901    unsigned long		__unused6;
    902 };
    903 
    904 struct vki_shminfo64 {
    905    unsigned long	shmmax;
    906    unsigned long	shmmin;
    907    unsigned long	shmmni;
    908    unsigned long	shmseg;
    909    unsigned long	shmall;
    910    unsigned long	__unused1;
    911    unsigned long	__unused2;
    912    unsigned long	__unused3;
    913    unsigned long	__unused4;
    914 };
    915 
    916 //.. //----------------------------------------------------------------------
    917 //.. // DRM ioctls
    918 //.. //----------------------------------------------------------------------
    919 //..
    920 //.. // jrs 20050207: where did all this stuff come from?  Is it really
    921 //.. // i386 specific, or should it go into the linux-generic category?
    922 //.. //struct vki_drm_buf_pub {
    923 //.. //	Int		  idx;	       /**< Index into the master buffer list */
    924 //.. //	Int		  total;       /**< Buffer size */
    925 //.. //	Int		  used;	       /**< Amount of buffer in use (for DMA) */
    926 //.. //	void	  __user *address;     /**< Address of buffer */
    927 //.. //};
    928 //.. //
    929 //.. //struct vki_drm_buf_map {
    930 //.. //	Int	      count;		/**< Length of the buffer list */
    931 //.. //	void	      __user *virtual;	/**< Mmap'd area in user-virtual */
    932 //.. //	struct vki_drm_buf_pub __user *list;	/**< Buffer information */
    933 //.. //};
    934 //.. //
    935 //.. ///* We need to pay attention to this, because it mmaps memory */
    936 //.. //#define VKI_DRM_IOCTL_MAP_BUFS		_VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
    937 
    938 //----------------------------------------------------------------------
    939 // And that's it!
    940 //----------------------------------------------------------------------
    941 
    942 #endif // __VKI_PPC32_LINUX_H
    943 
    944 /*--------------------------------------------------------------------*/
    945 /*--- end                                                          ---*/
    946 /*--------------------------------------------------------------------*/
    947