vki-arm-linux.h 29 KB

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