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