1 
2 /*--------------------------------------------------------------------*/
3 /*--- arm/Linux-specific kernel interface.         vki-arm-linux.h ---*/
4 /*--------------------------------------------------------------------*/
5 
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9 
10    Copyright (C) 2000-2015 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_ARM_LINUX_H
32 #define __VKI_ARM_LINUX_H
33 
34 // arm is little-endian.
35 #define VKI_LITTLE_ENDIAN  1
36 
37 // The various comments below indicating i386-ness should be regarded
38 // with great skepticism -- they are quite possibly wrong.  But see
39 // also bug 269079 comment 0.
40 
41 //----------------------------------------------------------------------
42 // From linux-2.6.8.1/include/asm-i386/types.h
43 //----------------------------------------------------------------------
44 
45 typedef unsigned char __vki_u8;
46 
47 typedef __signed__ short __vki_s16;
48 typedef unsigned short __vki_u16;
49 
50 typedef __signed__ int __vki_s32;
51 typedef unsigned int __vki_u32;
52 
53 typedef __signed__ long long __vki_s64;
54 typedef unsigned long long __vki_u64;
55 
56 typedef unsigned short vki_u16;
57 
58 typedef unsigned int vki_u32;
59 
60 //----------------------------------------------------------------------
61 // From linux-2.6.8.1/include/asm-i386/page.h
62 //----------------------------------------------------------------------
63 
64 /* PAGE_SHIFT determines the page size */
65 #define VKI_PAGE_SHIFT	12
66 #define VKI_PAGE_SIZE	(1UL << VKI_PAGE_SHIFT)
67 #define VKI_MAX_PAGE_SHIFT	VKI_PAGE_SHIFT
68 #define VKI_MAX_PAGE_SIZE	VKI_PAGE_SIZE
69 
70 //----------------------------------------------------------------------
71 // From linux-2.6.35.4/arch/arm/include/asm/shmparam.h
72 //----------------------------------------------------------------------
73 
74 #define VKI_SHMLBA  (4 * VKI_PAGE_SIZE)
75 
76 //----------------------------------------------------------------------
77 // From linux-2.6.8.1/include/asm-i386/signal.h
78 //----------------------------------------------------------------------
79 
80 #define VKI_MINSIGSTKSZ	2048
81 
82 #define VKI_SIG_BLOCK          0	/* for blocking signals */
83 #define VKI_SIG_UNBLOCK        1	/* for unblocking signals */
84 #define VKI_SIG_SETMASK        2	/* for setting the signal mask */
85 
86 /* Type of a signal handler.  */
87 typedef void __vki_signalfn_t(int);
88 typedef __vki_signalfn_t __user *__vki_sighandler_t;
89 
90 typedef void __vki_restorefn_t(void);
91 typedef __vki_restorefn_t __user *__vki_sigrestore_t;
92 
93 #define VKI_SIG_DFL	((__vki_sighandler_t)0)	/* default signal handling */
94 #define VKI_SIG_IGN	((__vki_sighandler_t)1)	/* ignore signal */
95 
96 #define _VKI_NSIG	64
97 #define _VKI_NSIG_BPW	32
98 #define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
99 
100 typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
101 
102 typedef struct {
103 	unsigned long sig[_VKI_NSIG_WORDS];
104 } vki_sigset_t;
105 
106 #define VKI_SIGHUP		 1
107 #define VKI_SIGINT		 2
108 #define VKI_SIGQUIT		 3
109 #define VKI_SIGILL		 4
110 #define VKI_SIGTRAP		 5
111 #define VKI_SIGABRT		 6
112 //#define VKI_SIGIOT		 6
113 #define VKI_SIGBUS		 7
114 #define VKI_SIGFPE		 8
115 #define VKI_SIGKILL		 9
116 #define VKI_SIGUSR1		10
117 #define VKI_SIGSEGV		11
118 #define VKI_SIGUSR2		12
119 #define VKI_SIGPIPE		13
120 #define VKI_SIGALRM		14
121 #define VKI_SIGTERM		15
122 #define VKI_SIGSTKFLT		16
123 #define VKI_SIGCHLD		17
124 #define VKI_SIGCONT		18
125 #define VKI_SIGSTOP		19
126 #define VKI_SIGTSTP		20
127 #define VKI_SIGTTIN		21
128 #define VKI_SIGTTOU		22
129 #define VKI_SIGURG		23
130 #define VKI_SIGXCPU		24
131 #define VKI_SIGXFSZ		25
132 #define VKI_SIGVTALRM		26
133 #define VKI_SIGPROF		27
134 #define VKI_SIGWINCH		28
135 #define VKI_SIGIO		29
136 #define VKI_SIGPWR		30
137 #define VKI_SIGSYS		31
138 #define	VKI_SIGUNUSED		31
139 
140 /* These should not be considered constants from userland.  */
141 #define VKI_SIGRTMIN	32
142 // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
143 #define VKI_SIGRTMAX	_VKI_NSIG
144 
145 #define VKI_SA_NOCLDSTOP	0x00000001u
146 #define VKI_SA_NOCLDWAIT	0x00000002u
147 #define VKI_SA_SIGINFO		0x00000004u
148 #define VKI_SA_ONSTACK		0x08000000u
149 #define VKI_SA_RESTART		0x10000000u
150 #define VKI_SA_NODEFER		0x40000000u
151 #define VKI_SA_RESETHAND	0x80000000u
152 
153 #define VKI_SA_NOMASK		VKI_SA_NODEFER
154 #define VKI_SA_ONESHOT		VKI_SA_RESETHAND
155 //#define VKI_SA_INTERRUPT	0x20000000 /* dummy -- ignored */
156 
157 #define VKI_SA_RESTORER		0x04000000
158 
159 #define VKI_SS_ONSTACK	1
160 #define VKI_SS_DISABLE	2
161 
162 struct vki_old_sigaction {
163         // [[Nb: a 'k' prefix is added to "sa_handler" because
164         // bits/sigaction.h (which gets dragged in somehow via signal.h)
165         // #defines it as something else.  Since that is done for glibc's
166         // purposes, which we don't care about here, we use our own name.]]
167         __vki_sighandler_t ksa_handler;
168         vki_old_sigset_t sa_mask;
169         unsigned long sa_flags;
170         __vki_sigrestore_t sa_restorer;
171 };
172 
173 struct vki_sigaction_base {
174         // [[See comment about extra 'k' above]]
175 	__vki_sighandler_t ksa_handler;
176 	unsigned long sa_flags;
177 	__vki_sigrestore_t sa_restorer;
178 	vki_sigset_t sa_mask;		/* mask last for extensibility */
179 };
180 
181 /* On Linux we use the same type for passing sigactions to
182    and from the kernel.  Hence: */
183 typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
184 typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
185 
186 
187 typedef struct vki_sigaltstack {
188 	void __user *ss_sp;
189 	int ss_flags;
190 	vki_size_t ss_size;
191 } vki_stack_t;
192 
193 //----------------------------------------------------------------------
194 // From linux-2.6.8.1/include/asm-i386/sigcontext.h
195 //----------------------------------------------------------------------
196 
197 struct vki_sigcontext {
198 		unsigned long trap_no;
199 		unsigned long error_code;
200 		unsigned long oldmask;
201 		unsigned long arm_r0;
202 		unsigned long arm_r1;
203 		unsigned long arm_r2;
204 		unsigned long arm_r3;
205 		unsigned long arm_r4;
206 		unsigned long arm_r5;
207 		unsigned long arm_r6;
208 		unsigned long arm_r7;
209 		unsigned long arm_r8;
210 		unsigned long arm_r9;
211 		unsigned long arm_r10;
212 		unsigned long arm_fp;
213 		unsigned long arm_ip;
214 		unsigned long arm_sp;
215 		unsigned long arm_lr;
216 		unsigned long arm_pc;
217 		unsigned long arm_cpsr;
218 		unsigned long fault_address;
219 };
220 
221 //----------------------------------------------------------------------
222 // From linux-2.6.8.1/include/asm-i386/mman.h
223 //----------------------------------------------------------------------
224 
225 #define VKI_PROT_NONE	0x0		/* No page permissions */
226 #define VKI_PROT_READ	0x1		/* page can be read */
227 #define VKI_PROT_WRITE	0x2		/* page can be written */
228 #define VKI_PROT_EXEC	0x4		/* page can be executed */
229 #define VKI_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
230 #define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
231 
232 #define VKI_MAP_SHARED	0x01		/* Share changes */
233 #define VKI_MAP_PRIVATE	0x02		/* Changes are private */
234 //#define VKI_MAP_TYPE	0x0f		/* Mask for type of mapping */
235 #define VKI_MAP_FIXED	0x10		/* Interpret addr exactly */
236 #define VKI_MAP_ANONYMOUS	0x20	/* don't use a file */
237 #define VKI_MAP_NORESERVE	0x4000		/* don't check for reservations */
238 
239 //----------------------------------------------------------------------
240 // From linux-2.6.8.1/include/asm-i386/fcntl.h
241 //----------------------------------------------------------------------
242 
243 #define VKI_O_ACCMODE	     03
244 #define VKI_O_RDONLY	     00
245 #define VKI_O_WRONLY	     01
246 #define VKI_O_RDWR	     02
247 #define VKI_O_CREAT	   0100	/* not fcntl */
248 #define VKI_O_EXCL	   0200	/* not fcntl */
249 #define VKI_O_TRUNC	  01000	/* not fcntl */
250 #define VKI_O_APPEND	  02000
251 #define VKI_O_NONBLOCK	  04000
252 #define VKI_O_LARGEFILE	0100000
253 
254 #define VKI_AT_FDCWD            -100
255 
256 #define VKI_F_DUPFD		0	/* dup */
257 #define VKI_F_GETFD		1	/* get close_on_exec */
258 #define VKI_F_SETFD		2	/* set/clear close_on_exec */
259 #define VKI_F_GETFL		3	/* get file->f_flags */
260 #define VKI_F_SETFL		4	/* set file->f_flags */
261 #define VKI_F_GETLK		5
262 #define VKI_F_SETLK		6
263 #define VKI_F_SETLKW		7
264 
265 #define VKI_F_SETOWN		8	/*  for sockets. */
266 #define VKI_F_GETOWN		9	/*  for sockets. */
267 #define VKI_F_SETSIG		10	/*  for sockets. */
268 #define VKI_F_GETSIG		11	/*  for sockets. */
269 
270 #define VKI_F_GETLK64		12	/*  using 'struct flock64' */
271 #define VKI_F_SETLK64		13
272 #define VKI_F_SETLKW64		14
273 
274 #define VKI_F_SETOWN_EX		15
275 #define VKI_F_GETOWN_EX		16
276 
277 #define VKI_F_OFD_GETLK		36
278 #define VKI_F_OFD_SETLK		37
279 #define VKI_F_OFD_SETLKW	38
280 
281 #define VKI_F_OWNER_TID		0
282 #define VKI_F_OWNER_PID		1
283 #define VKI_F_OWNER_PGRP	2
284 
285 struct vki_f_owner_ex {
286 	int	type;
287 	__vki_kernel_pid_t	pid;
288 };
289 
290 /* for F_[GET|SET]FL */
291 #define VKI_FD_CLOEXEC	1	/* actually anything with low bit set goes */
292 
293 #define VKI_F_LINUX_SPECIFIC_BASE	1024
294 
295 //----------------------------------------------------------------------
296 // From linux-2.6.8.1/include/asm-i386/resource.h
297 //----------------------------------------------------------------------
298 
299 #define VKI_RLIMIT_DATA		2	/* max data size */
300 #define VKI_RLIMIT_STACK	3	/* max stack size */
301 #define VKI_RLIMIT_CORE		4	/* max core file size */
302 #define VKI_RLIMIT_NOFILE	7	/* max number of open files */
303 
304 //----------------------------------------------------------------------
305 // From linux-2.6.8.1/include/asm-i386/socket.h
306 //----------------------------------------------------------------------
307 
308 #define VKI_SOL_SOCKET	1
309 
310 #define VKI_SO_TYPE	3
311 
312 #define VKI_SO_ATTACH_FILTER	26
313 
314 //----------------------------------------------------------------------
315 // From linux-2.6.8.1/include/asm-i386/sockios.h
316 //----------------------------------------------------------------------
317 
318 #define VKI_SIOCSPGRP           0x8902
319 #define VKI_SIOCGPGRP           0x8904
320 #define VKI_SIOCATMARK          0x8905
321 #define VKI_SIOCGSTAMP          0x8906      /* Get stamp (timeval) */
322 #define VKI_SIOCGSTAMPNS        0x8907      /* Get stamp (timespec) */
323 
324 //----------------------------------------------------------------------
325 // From linux-2.6.8.1/include/asm-i386/stat.h
326 //----------------------------------------------------------------------
327 
328 struct vki_stat {
329 	unsigned long  st_dev;
330 	unsigned long  st_ino;
331 	unsigned short st_mode;
332 	unsigned short st_nlink;
333 	unsigned short st_uid;
334 	unsigned short st_gid;
335 	unsigned long  st_rdev;
336 	unsigned long  st_size;
337 	unsigned long  st_blksize;
338 	unsigned long  st_blocks;
339 	unsigned long  st_atime;
340 	unsigned long  st_atime_nsec;
341 	unsigned long  st_mtime;
342 	unsigned long  st_mtime_nsec;
343 	unsigned long  st_ctime;
344 	unsigned long  st_ctime_nsec;
345 	unsigned long  __unused4;
346 	unsigned long  __unused5;
347 };
348 
349 struct vki_stat64 {
350 	unsigned long long	st_dev;
351 	unsigned char	__pad0[4];
352 
353 #define STAT64_HAS_BROKEN_ST_INO	1
354 	unsigned long	__st_ino;
355 
356 	unsigned int	st_mode;
357 	unsigned int	st_nlink;
358 
359 	unsigned long	st_uid;
360 	unsigned long	st_gid;
361 
362 	unsigned long long	st_rdev;
363 	unsigned char	__pad3[4];
364 
365 	long long	st_size;
366 	unsigned long	st_blksize;
367 
368 	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
369 	unsigned long	__pad4;		/* future possible st_blocks high bits */
370 
371 	unsigned long	st_atime;
372 	unsigned long	st_atime_nsec;
373 
374 	unsigned long	st_mtime;
375 	unsigned int	st_mtime_nsec;
376 
377 	unsigned long	st_ctime;
378 	unsigned long	st_ctime_nsec;
379 
380 	unsigned long long	st_ino;
381 };
382 
383 //----------------------------------------------------------------------
384 // From linux-2.6.8.1/include/asm-i386/statfs.h
385 //----------------------------------------------------------------------
386 
387 // [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
388 struct vki_statfs {
389 	__vki_u32 f_type;
390 	__vki_u32 f_bsize;
391 	__vki_u32 f_blocks;
392 	__vki_u32 f_bfree;
393 	__vki_u32 f_bavail;
394 	__vki_u32 f_files;
395 	__vki_u32 f_ffree;
396 	__vki_kernel_fsid_t f_fsid;
397 	__vki_u32 f_namelen;
398 	__vki_u32 f_frsize;
399 	__vki_u32 f_spare[5];
400 };
401 
402 //----------------------------------------------------------------------
403 // From linux-2.6.8.1/include/asm-i386/termios.h
404 //----------------------------------------------------------------------
405 
406 struct vki_winsize {
407 	unsigned short ws_row;
408 	unsigned short ws_col;
409 	unsigned short ws_xpixel;
410 	unsigned short ws_ypixel;
411 };
412 
413 #define VKI_NCC 8
414 struct vki_termio {
415 	unsigned short c_iflag;		/* input mode flags */
416 	unsigned short c_oflag;		/* output mode flags */
417 	unsigned short c_cflag;		/* control mode flags */
418 	unsigned short c_lflag;		/* local mode flags */
419 	unsigned char c_line;		/* line discipline */
420 	unsigned char c_cc[VKI_NCC];	/* control characters */
421 };
422 
423 
424 //----------------------------------------------------------------------
425 // From linux-2.6.8.1/include/asm-i386/termbits.h
426 //----------------------------------------------------------------------
427 
428 typedef unsigned char   vki_cc_t;
429 typedef unsigned int    vki_tcflag_t;
430 
431 #define VKI_NCCS 19
432 struct vki_termios {
433 	vki_tcflag_t c_iflag;		/* input mode flags */
434 	vki_tcflag_t c_oflag;		/* output mode flags */
435 	vki_tcflag_t c_cflag;		/* control mode flags */
436 	vki_tcflag_t c_lflag;		/* local mode flags */
437 	vki_cc_t c_line;		/* line discipline */
438 	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
439 };
440 
441 //----------------------------------------------------------------------
442 // From linux-2.6.8.1/include/asm-i386/ioctl.h
443 //----------------------------------------------------------------------
444 
445 #define _VKI_IOC_NRBITS		8
446 #define _VKI_IOC_TYPEBITS	8
447 #define _VKI_IOC_SIZEBITS	14
448 #define _VKI_IOC_DIRBITS	2
449 
450 #define _VKI_IOC_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
451 #define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
452 #define _VKI_IOC_SIZEMASK	((1 << _VKI_IOC_SIZEBITS)-1)
453 #define _VKI_IOC_DIRMASK	((1 << _VKI_IOC_DIRBITS)-1)
454 
455 #define _VKI_IOC_NRSHIFT	0
456 #define _VKI_IOC_TYPESHIFT	(_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
457 #define _VKI_IOC_SIZESHIFT	(_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
458 #define _VKI_IOC_DIRSHIFT	(_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
459 
460 #define _VKI_IOC_NONE	0U
461 #define _VKI_IOC_WRITE	1U
462 #define _VKI_IOC_READ	2U
463 
464 #define _VKI_IOC(dir,type,nr,size) \
465 	(((dir)  << _VKI_IOC_DIRSHIFT) | \
466 	 ((type) << _VKI_IOC_TYPESHIFT) | \
467 	 ((nr)   << _VKI_IOC_NRSHIFT) | \
468 	 ((size) << _VKI_IOC_SIZESHIFT))
469 
470 /* used to create numbers */
471 #define _VKI_IO(type,nr)	_VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
472 #define _VKI_IOR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
473 #define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
474 #define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
475 
476 /* used to decode ioctl numbers.. */
477 #define _VKI_IOC_DIR(nr)	(((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
478 #define _VKI_IOC_TYPE(nr)	(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
479 #define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
480 #define _VKI_IOC_SIZE(nr)	(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
481 
482 //----------------------------------------------------------------------
483 // From linux-2.6.8.1/include/asm-i386/ioctls.h
484 //----------------------------------------------------------------------
485 
486 #define VKI_TCGETS	0x5401
487 #define VKI_TCSETS	0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
488 #define VKI_TCSETSW	0x5403
489 #define VKI_TCSETSF	0x5404
490 #define VKI_TCGETA	0x5405
491 #define VKI_TCSETA	0x5406
492 #define VKI_TCSETAW	0x5407
493 #define VKI_TCSETAF	0x5408
494 #define VKI_TCSBRK	0x5409
495 #define VKI_TCXONC	0x540A
496 #define VKI_TCFLSH	0x540B
497 #define VKI_TIOCSCTTY	0x540E
498 #define VKI_TIOCGPGRP	0x540F
499 #define VKI_TIOCSPGRP	0x5410
500 #define VKI_TIOCOUTQ	0x5411
501 #define VKI_TIOCGWINSZ	0x5413
502 #define VKI_TIOCSWINSZ	0x5414
503 #define VKI_TIOCMGET	0x5415
504 #define VKI_TIOCMBIS	0x5416
505 #define VKI_TIOCMBIC	0x5417
506 #define VKI_TIOCMSET	0x5418
507 #define VKI_FIONREAD	0x541B
508 #define VKI_TIOCLINUX	0x541C
509 #define VKI_FIONBIO	0x5421
510 #define VKI_TIOCNOTTY	0x5422
511 #define VKI_TCSBRKP	0x5425	/* Needed for POSIX tcsendbreak() */
512 #define VKI_TIOCGPTN	_VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
513 #define VKI_TIOCSPTLCK	_VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
514 
515 #define VKI_FIONCLEX	0x5450
516 #define VKI_FIOCLEX	0x5451
517 #define VKI_FIOASYNC	0x5452
518 #define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
519 
520 #define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
521 
522 //----------------------------------------------------------------------
523 // From linux-2.6.39-rc2/arch/arm/include/asm/ioctls.h
524 //----------------------------------------------------------------------
525 
526 #define VKI_FIOQSIZE 0x545E
527 
528 //----------------------------------------------------------------------
529 // From asm-generic/poll.h
530 //----------------------------------------------------------------------
531 
532 /* These are specified by iBCS2 */
533 #define VKI_POLLIN		0x0001
534 
535 struct vki_pollfd {
536 	int fd;
537 	short events;
538 	short revents;
539 };
540 
541 //----------------------------------------------------------------------
542 // From linux-2.6.8.1/include/asm-i386/user.h
543 //----------------------------------------------------------------------
544 
545 struct vki_user_fp {
546 	struct vki_fp_reg {
547 		unsigned int sign1:1;
548 		unsigned int unused:15;
549 		unsigned int sign2:1;
550 		unsigned int exponent:14;
551 		unsigned int j:1;
552 		unsigned int mantissa1:31;
553 		unsigned int mantissa0:32;
554 	} fpregs[8];
555 	unsigned int fpsr:32;
556 	unsigned int fpcr:32;
557 	unsigned char ftype[8];
558 	unsigned int init_flag;
559 };
560 
561 struct vki_user_vfp {
562 	unsigned long long fpregs[32];
563 	unsigned long fpscr;
564 };
565 
566 #define VKI_IWMMXT_SIZE 0x98
567 
568 struct vki_iwmmxt_struct {
569 	unsigned int save[VKI_IWMMXT_SIZE / sizeof(unsigned int)];
570 };
571 
572 struct vki_crunch_state {
573 	unsigned int    mvdx[16][2];
574 	unsigned int    mvax[4][3];
575 	unsigned int    dspsc[2];
576 };
577 
578 #define VKI_CRUNCH_SIZE sizeof(struct vki_crunch_state)
579 
580 struct vki_user_regs_struct {
581     long uregs[18];
582 };
583 #define ARM_cpsr	uregs[16]
584 #define ARM_pc		uregs[15]
585 #define ARM_lr		uregs[14]
586 #define ARM_sp		uregs[13]
587 #define ARM_ip		uregs[12]
588 #define ARM_fp		uregs[11]
589 #define ARM_r10		uregs[10]
590 #define ARM_r9		uregs[9]
591 #define ARM_r8		uregs[8]
592 #define ARM_r7		uregs[7]
593 #define ARM_r6		uregs[6]
594 #define ARM_r5		uregs[5]
595 #define ARM_r4		uregs[4]
596 #define ARM_r3		uregs[3]
597 #define ARM_r2		uregs[2]
598 #define ARM_r1		uregs[1]
599 #define ARM_r0		uregs[0]
600 #define ARM_ORIG_r0	uregs[17]
601 //----------------------------------------------------------------------
602 // From linux-2.6.8.1/include/asm-i386/elf.h
603 //----------------------------------------------------------------------
604 
605 typedef unsigned long vki_elf_greg_t;
606 
607 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
608 typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
609 
610 typedef struct vki_user_fp vki_elf_fpregset_t;
611 
612 #define VKI_AT_SYSINFO		32
613 
614 //----------------------------------------------------------------------
615 // From linux-2.6.8.1/include/asm-i386/ucontext.h
616 //----------------------------------------------------------------------
617 
618 struct vki_ucontext {
619 	unsigned long		uc_flags;
620 	struct vki_ucontext    *uc_link;
621 	vki_stack_t		uc_stack;
622 	struct vki_sigcontext	uc_mcontext;
623 	vki_sigset_t		uc_sigmask;	/* mask last for extensibility */
624 	int              __unused0[32 - (sizeof (vki_sigset_t) / sizeof (int))];
625 	unsigned long     uc_regspace[128] __attribute__((__aligned__(8)));
626 
627 };
628 
629 //----------------------------------------------------------------------
630 // From linux-2.6.8.1/include/asm-i386/segment.h
631 //----------------------------------------------------------------------
632 
633 #define VKI_GDT_ENTRY_TLS_ENTRIES	3
634 #define VKI_GDT_ENTRY_TLS_MIN	6
635 #define VKI_GDT_ENTRY_TLS_MAX 	(VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
636 
637 //----------------------------------------------------------------------
638 // From linux-2.6.8.1/include/asm-i386/ldt.h
639 //----------------------------------------------------------------------
640 
641 /* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
642    to confuse and annoy everyone, this is _not_ the same as an
643    VgLdtEntry and has to be translated into such.  The logic for doing
644    so, in vg_ldt.c, is copied from the kernel sources.]] */
645 struct vki_user_desc {
646 	unsigned int  entry_number;
647 	unsigned long base_addr;
648 	unsigned int  limit;
649 	unsigned int  seg_32bit:1;
650 	unsigned int  contents:2;
651 	unsigned int  read_exec_only:1;
652 	unsigned int  limit_in_pages:1;
653 	unsigned int  seg_not_present:1;
654 	unsigned int  useable:1;
655         // [[Nb: this field is not in the kernel sources, but it has always
656         // been in the Valgrind sources so I will keep it there in case it's
657         // important... this is an x86-defined data structure so who
658         // knows;  maybe it's important to set this field to zero at some
659         // point.  --njn]]
660 	unsigned int  reserved:25;
661 };
662 
663 // [[Nb: for our convenience within Valgrind, use a more specific name]]
664 typedef struct vki_user_desc vki_modify_ldt_t;
665 
666 //----------------------------------------------------------------------
667 // From linux-2.6.8.1/include/asm-i386/ipcbuf.h
668 //----------------------------------------------------------------------
669 
670 struct vki_ipc64_perm
671 {
672 	__vki_kernel_key_t	key;
673 	__vki_kernel_uid32_t	uid;
674 	__vki_kernel_gid32_t	gid;
675 	__vki_kernel_uid32_t	cuid;
676 	__vki_kernel_gid32_t	cgid;
677 	__vki_kernel_mode_t	mode;
678 	unsigned short		__pad1;
679 	unsigned short		seq;
680 	unsigned short		__pad2;
681 	unsigned long		__unused1;
682 	unsigned long		__unused2;
683 };
684 
685 //----------------------------------------------------------------------
686 // From linux-2.6.8.1/include/asm-i386/sembuf.h
687 //----------------------------------------------------------------------
688 
689 struct vki_semid64_ds {
690 	struct vki_ipc64_perm sem_perm;		/* permissions .. see ipc.h */
691 	__vki_kernel_time_t	sem_otime;		/* last semop time */
692 	unsigned long	__unused1;
693 	__vki_kernel_time_t	sem_ctime;		/* last change time */
694 	unsigned long	__unused2;
695 	unsigned long	sem_nsems;		/* no. of semaphores in array */
696 	unsigned long	__unused3;
697 	unsigned long	__unused4;
698 };
699 
700 //----------------------------------------------------------------------
701 // From linux-2.6.8.1/include/asm-i386/msgbuf.h
702 //----------------------------------------------------------------------
703 
704 struct vki_msqid64_ds {
705 	struct vki_ipc64_perm msg_perm;
706 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
707 	unsigned long	__unused1;
708 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
709 	unsigned long	__unused2;
710 	__vki_kernel_time_t msg_ctime;	/* last change time */
711 	unsigned long	__unused3;
712 	unsigned long  msg_cbytes;	/* current number of bytes on queue */
713 	unsigned long  msg_qnum;	/* number of messages in queue */
714 	unsigned long  msg_qbytes;	/* max number of bytes on queue */
715 	__vki_kernel_pid_t msg_lspid;	/* pid of last msgsnd */
716 	__vki_kernel_pid_t msg_lrpid;	/* last receive pid */
717 	unsigned long  __unused4;
718 	unsigned long  __unused5;
719 };
720 
721 //----------------------------------------------------------------------
722 // From linux-2.6.8.1/include/asm-i386/ipc.h
723 //----------------------------------------------------------------------
724 
725 struct vki_ipc_kludge {
726 	struct vki_msgbuf __user *msgp;
727 	long msgtyp;
728 };
729 
730 #define VKI_SEMOP		 1
731 #define VKI_SEMGET		 2
732 #define VKI_SEMCTL		 3
733 #define VKI_SEMTIMEDOP	 	 4
734 #define VKI_MSGSND		11
735 #define VKI_MSGRCV		12
736 #define VKI_MSGGET		13
737 #define VKI_MSGCTL		14
738 #define VKI_SHMAT		21
739 #define VKI_SHMDT		22
740 #define VKI_SHMGET		23
741 #define VKI_SHMCTL		24
742 
743 //----------------------------------------------------------------------
744 // From linux-2.6.8.1/include/asm-i386/shmbuf.h
745 //----------------------------------------------------------------------
746 
747 struct vki_shmid64_ds {
748 	struct vki_ipc64_perm	shm_perm;	/* operation perms */
749 	vki_size_t		shm_segsz;	/* size of segment (bytes) */
750 	__vki_kernel_time_t	shm_atime;	/* last attach time */
751 	unsigned long		__unused1;
752 	__vki_kernel_time_t	shm_dtime;	/* last detach time */
753 	unsigned long		__unused2;
754 	__vki_kernel_time_t	shm_ctime;	/* last change time */
755 	unsigned long		__unused3;
756 	__vki_kernel_pid_t	shm_cpid;	/* pid of creator */
757 	__vki_kernel_pid_t	shm_lpid;	/* pid of last operator */
758 	unsigned long		shm_nattch;	/* no. of current attaches */
759 	unsigned long		__unused4;
760 	unsigned long		__unused5;
761 };
762 
763 struct vki_shminfo64 {
764 	unsigned long	shmmax;
765 	unsigned long	shmmin;
766 	unsigned long	shmmni;
767 	unsigned long	shmseg;
768 	unsigned long	shmall;
769 	unsigned long	__unused1;
770 	unsigned long	__unused2;
771 	unsigned long	__unused3;
772 	unsigned long	__unused4;
773 };
774 
775 //----------------------------------------------------------------------
776 // DRM ioctls
777 //----------------------------------------------------------------------
778 
779 // jrs 20050207: where did all this stuff come from?  Is it really
780 // i386 specific, or should it go into the linux-generic category?
781 //struct vki_drm_buf_pub {
782 //	Int		  idx;	       /**< Index into the master buffer list */
783 //	Int		  total;       /**< Buffer size */
784 //	Int		  used;	       /**< Amount of buffer in use (for DMA) */
785 //	void	  __user *address;     /**< Address of buffer */
786 //};
787 //
788 //struct vki_drm_buf_map {
789 //	Int	      count;		/**< Length of the buffer list */
790 //	void	      __user *virtual;	/**< Mmap'd area in user-virtual */
791 //	struct vki_drm_buf_pub __user *list;	/**< Buffer information */
792 //};
793 //
794 ///* We need to pay attention to this, because it mmaps memory */
795 //#define VKI_DRM_IOCTL_MAP_BUFS		_VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
796 
797 //----------------------------------------------------------------------
798 // From linux-2.6.9/include/asm-i386/ptrace.h
799 //----------------------------------------------------------------------
800 
801 #define VKI_PTRACE_GETREGS            12
802 #define VKI_PTRACE_SETREGS            13
803 #define VKI_PTRACE_GETFPREGS          14
804 #define VKI_PTRACE_SETFPREGS          15
805 #define VKI_PTRACE_GETWMMXREGS        18
806 #define VKI_PTRACE_SETWMMXREGS        19
807 #define VKI_PTRACE_GET_THREAD_AREA    22
808 #define VKI_PTRACE_SET_SYSCALL        23
809 #define VKI_PTRACE_GETCRUNCHREGS      25
810 #define VKI_PTRACE_SETCRUNCHREGS      26
811 #define VKI_PTRACE_GETVFPREGS         27
812 #define VKI_PTRACE_SETVFPREGS         28
813 #define VKI_PTRACE_GETHBPREGS         29
814 #define VKI_PTRACE_SETHBPREGS         30
815 
816 //----------------------------------------------------------------------
817 // From linux-2.6.15.4/include/asm-i386/vm86.h
818 //----------------------------------------------------------------------
819 
820 #define VKI_VM86_PLUS_INSTALL_CHECK	0
821 #define VKI_VM86_ENTER			1
822 #define VKI_VM86_ENTER_NO_BYPASS	2
823 #define	VKI_VM86_REQUEST_IRQ		3
824 #define VKI_VM86_FREE_IRQ		4
825 #define VKI_VM86_GET_IRQ_BITS		5
826 #define VKI_VM86_GET_AND_RESET_IRQ	6
827 
828 struct vki_vm86_regs {
829 /*
830  * normal regs, with special meaning for the segment descriptors..
831  */
832 	long ebx;
833 	long ecx;
834 	long edx;
835 	long esi;
836 	long edi;
837 	long ebp;
838 	long eax;
839 	long __null_ds;
840 	long __null_es;
841 	long __null_fs;
842 	long __null_gs;
843 	long orig_eax;
844 	long eip;
845 	unsigned short cs, __csh;
846 	long eflags;
847 	long esp;
848 	unsigned short ss, __ssh;
849 /*
850  * these are specific to v86 mode:
851  */
852 	unsigned short es, __esh;
853 	unsigned short ds, __dsh;
854 	unsigned short fs, __fsh;
855 	unsigned short gs, __gsh;
856 };
857 
858 struct vki_revectored_struct {
859 	unsigned long __map[8];			/* 256 bits */
860 };
861 
862 struct vki_vm86_struct {
863 	struct vki_vm86_regs regs;
864 	unsigned long flags;
865 	unsigned long screen_bitmap;
866 	unsigned long cpu_type;
867 	struct vki_revectored_struct int_revectored;
868 	struct vki_revectored_struct int21_revectored;
869 };
870 
871 struct vki_vm86plus_info_struct {
872 	unsigned long force_return_for_pic:1;
873 	unsigned long vm86dbg_active:1;       /* for debugger */
874 	unsigned long vm86dbg_TFpendig:1;     /* for debugger */
875 	unsigned long unused:28;
876 	unsigned long is_vm86pus:1;	      /* for vm86 internal use */
877 	unsigned char vm86dbg_intxxtab[32];   /* for debugger */
878 };
879 
880 struct vki_vm86plus_struct {
881 	struct vki_vm86_regs regs;
882 	unsigned long flags;
883 	unsigned long screen_bitmap;
884 	unsigned long cpu_type;
885 	struct vki_revectored_struct int_revectored;
886 	struct vki_revectored_struct int21_revectored;
887 	struct vki_vm86plus_info_struct vm86plus;
888 };
889 
890 //----------------------------------------------------------------------
891 // From linux-2.6.35.4/arch/arm/include/asm/hwcap.h
892 //----------------------------------------------------------------------
893 
894 #define VKI_HWCAP_NEON      4096
895 
896 //----------------------------------------------------------------------
897 // From linux-2.6.8.1/include/asm-generic/errno.h
898 //----------------------------------------------------------------------
899 
900 #define	VKI_ENOSYS       38  /* Function not implemented */
901 #define	VKI_EOVERFLOW    75  /* Value too large for defined data type */
902 
903 //----------------------------------------------------------------------
904 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
905 //----------------------------------------------------------------------
906 
907 #define VKI_TIOCGSERIAL     0x541E
908 #define VKI_TIOCSSERIAL     0x541F
909 
910 //----------------------------------------------------------------------
911 // And that's it!
912 //----------------------------------------------------------------------
913 
914 #endif // __VKI_ARM_LINUX_H
915 
916 /*--------------------------------------------------------------------*/
917 /*--- end                                          vki-arm-linux.h ---*/
918 /*--------------------------------------------------------------------*/
919